From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E41FFA0548; Sun, 4 Apr 2021 01:42:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 91F98140E59; Sun, 4 Apr 2021 01:41:44 +0200 (CEST) Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) by mails.dpdk.org (Postfix) with ESMTP id 3C8BD140E3B for ; Sun, 4 Apr 2021 01:41:42 +0200 (CEST) Received: by mail-lj1-f170.google.com with SMTP id u10so9140997lju.7 for ; Sat, 03 Apr 2021 16:41:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RVMkF7yTN6CjFo8o+yAjaTX5ihWMsqzlSo3HRJD7omk=; b=JN0bCkUPVkW6Rmc+BsSgORSRBZnkAF5nKOqXPX/D7A43mgzpnDrSUerqa9EtmRh+o6 MogN0m6xi98Xn5Kh/DE/1f3FWpQdTnlb2nfv4OqzVde1hkRXKH8qVqgMozWZjJfxQ4lA /Zc+Ca4ipD/mK88IxRvVVxdIqhWynb6oUrzyxHPySaX1HYE83udb5UduRRyrJ4SJq6yh 1JAJLHU7OC8pJvHmyHqID4nV5QPZIKBohJCfVZDYjLHC8RTiqgscQfeYpGnPpzNd75PT Twa0YKwLzV2T/JI5y5ioygSgpNLRcA2kFZyphlywe3Hdk3ogvyUkpfLSoPfOCg7mXBlj IcOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RVMkF7yTN6CjFo8o+yAjaTX5ihWMsqzlSo3HRJD7omk=; b=FNn687A+63SL1G0pD/4gu3vkrjFFpGcSJcyMtlRmoPm8XYeHSl4Rhi0ElTaOeYl3Xz 2SF0kR05bfz9gxlOk1LMVZP09nir4AGNcAf6gLcO6m53VIQgRoQ1MmqMyL/5KUJu0mVO DB313Jq0bpUdeYL4LqU76rWwP5/rwmoIe7LB9WkDiVrbHYYCOEd5sygR79zRyHLvK54G +zSjlhWVvu2wL/wQ5JLq++G7RR5SJzFtx8fAyv6qz1Zfnk8d51V70yxB3zD++/H/WaNa Z4COabYBJF8dV5xJPIIqZEgXKi0gLRM8UP2fKLVceKHFx8Rgl+sa7/tyd+x6Q6w6XCD1 Tqaw== X-Gm-Message-State: AOAM5327YOofPu5fUP23Tf5+lsY1MwdhZpPx8aemyXnD1VeQ0F91ia83 kGzo7Y1hd6p9rgEn4XvcYZjDIjKKzyFSuU/P X-Google-Smtp-Source: ABdhPJx/q7B+x2yZldC5mQ5UVbuCmimlYZVF44e4v6tRKEUAz97ao99G0NzerGju0Lt7v73G7GxoaA== X-Received: by 2002:a2e:a554:: with SMTP id e20mr10634087ljn.286.1617493301412; Sat, 03 Apr 2021 16:41:41 -0700 (PDT) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id f23sm1374927lja.43.2021.04.03.16.41.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Apr 2021 16:41:41 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Tyler Retzlaff , Jie Zhou , Nick Connolly , Dmitry Kozlyuk , Ranjit Menon , Olivier Matz Date: Sun, 4 Apr 2021 02:41:28 +0300 Message-Id: <20210403234129.20296-5-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20210403234129.20296-1-dmitry.kozliuk@gmail.com> References: <20210320130525.16452-1-dmitry.kozliuk@gmail.com> <20210403234129.20296-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v7 4/5] net: work around s_addr macro on Windows X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Windows Sockets headers contain `#define s_addr S_un.S_addr`, which conflicts with definition of `s_addr` field of `struct rte_ether_hdr`. Prieviously `s_addr` was undefined in , which had been breaking access to `s_addr` field of `struct in_addr`, so some DPDK and Windows headers could not be included in one file. Renaming of `struct rte_ether_hdr` is planned: https://mails.dpdk.org/archives/dev/2021-March/201444.html Temporarily disable `s_addr` macro around `struct rte_ether_hdr` definition to avoid conflict. Place source MAC address in both `s_addr` and `S_un.S_addr` fields, so that access works either directly or through the macro as defined in Windows headers. Signed-off-by: Dmitry Kozlyuk Acked-by: Ranjit Menon --- lib/librte_net/rte_ether.h | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h index 060b63fc9b..a303c24a8c 100644 --- a/lib/librte_net/rte_ether.h +++ b/lib/librte_net/rte_ether.h @@ -23,10 +23,6 @@ extern "C" { #include #include -#ifdef RTE_EXEC_ENV_WINDOWS /* Workaround conflict with rte_ether_hdr. */ -#undef s_addr /* Defined in winsock2.h included in windows.h. */ -#endif - #define RTE_ETHER_ADDR_LEN 6 /**< Length of Ethernet address. */ #define RTE_ETHER_TYPE_LEN 2 /**< Length of Ethernet type field. */ #define RTE_ETHER_CRC_LEN 4 /**< Length of Ethernet CRC. */ @@ -257,16 +253,34 @@ __rte_experimental int rte_ether_unformat_addr(const char *str, struct rte_ether_addr *eth_addr); +/* Windows Sockets headers contain `#define s_addr S_un.S_addr`. + * Temporarily disable this macro to avoid conflict at definition. + * Place source MAC address in both `s_addr` and `S_un.S_addr` fields, + * so that access works either directly or through the macro. + */ +#pragma push_macro("s_addr") +#ifdef s_addr +#undef s_addr +#endif + /** * Ethernet header: Contains the destination address, source address * and frame type. */ struct rte_ether_hdr { struct rte_ether_addr d_addr; /**< Destination address. */ - struct rte_ether_addr s_addr; /**< Source address. */ - uint16_t ether_type; /**< Frame type. */ + RTE_STD_C11 + union { + struct rte_ether_addr s_addr; /**< Source address. */ + struct { + struct rte_ether_addr S_addr; + } S_un; /**< Do not use directly; use s_addr instead.*/ + }; + uint16_t ether_type; /**< Frame type. */ } __rte_aligned(2); +#pragma pop_macro("s_addr") + /** * Ethernet VLAN Header. * Contains the 16-bit VLAN Tag Control Identifier and the Ethernet type -- 2.29.3