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 636F5A0A0F; Thu, 8 Apr 2021 00:23:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EB8CE141011; Thu, 8 Apr 2021 00:23:06 +0200 (CEST) Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by mails.dpdk.org (Postfix) with ESMTP id 87C91140FF5 for ; Thu, 8 Apr 2021 00:23:03 +0200 (CEST) Received: by mail-lf1-f50.google.com with SMTP id n8so641801lfh.1 for ; Wed, 07 Apr 2021 15:23:03 -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=KkHZwAPiooiGL8G+puT0jGGXatH1EngHEayJ5/KSni1dSF7DUvz4ii9b4DRKvYu7E/ avcz6/yp4Tv1YlTPe8gj4Kn0KJCyq739tPZiWsu9zxkOHUILu6BihWKQ+cwUTgiTEgMk X+IRGFO2hbBUIvLVDSChzMoq3Rh1HjO2bUSK6x3znMEvJCACH931qvywiAZ8nsr18YTJ OttUOZtjZlB0rML0m19/+xTZQpZFvfIIN8ew6ZSMI3XYtoYjUiWf8DxoSFtsGKSSWEpH Cj0G22tI/G/MdM/kIcHaa/txTMweerfpNEZhL4oXz4focNmpRRp3dOodfUmHx4zA2/sS jQYg== 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=bNEuhG4TdENesX7D8R/MK8abTEAJ0tlCXdIzzECLkmThYy7xAHPYGoA9M0UDW5RBou FKBTKAz1Y+6uEX2rAB2HDzrVxqjzlz1TquTdrs8SsZOr9Azv1uv02KjzGvghC9Idrg7M ApED/gw2UGK9OK+WWDBfZdu3XQPO+Z5zhJpNdxNcEL+33o9SHZ6Vk5lVrZcasI/d5WL0 rwCc/y85XRZcUCasFdUkD9TTuohgg1CbJ4gojVlSUYdymznsYTOYgQuSyQOnZhoaktdI XdhkokmTf1/A7xiJU2iFwRUzePuyPRGmrZx/aMImJIW3kkMLDbXVRxiFc+R+L5TCgSQa IrzA== X-Gm-Message-State: AOAM531RS8bPaVmS7JIIJTnm21D0hD+Fll8Lsa1RaXpYGoZE+r/OBVy6 NTj30+/32vYn3XSpJJlnl71JPmAvuvDcEHA7 X-Google-Smtp-Source: ABdhPJzDFUkkWpz9DBo3wxGkuNacL/fC7Uiiyh+veJHHcU/TgrFbIgso/6Cioa6JOzl1xz16bb0hzg== X-Received: by 2002:a19:fc11:: with SMTP id a17mr3834345lfi.409.1617834182883; Wed, 07 Apr 2021 15:23:02 -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 u27sm441965lfk.254.2021.04.07.15.23.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Apr 2021 15:23:01 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Tyler Retzlaff , Jie Zhou , Nick Connolly , Dmitry Kozlyuk , Ranjit Menon , Olivier Matz Date: Thu, 8 Apr 2021 01:22:48 +0300 Message-Id: <20210407222249.6729-4-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20210407222249.6729-1-dmitry.kozliuk@gmail.com> References: <20210403234129.20296-1-dmitry.kozliuk@gmail.com> <20210407222249.6729-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v8 3/4] 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