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 EA243A0A02; Thu, 15 Apr 2021 00:07:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 915CA161D7D; Thu, 15 Apr 2021 00:07:08 +0200 (CEST) Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) by mails.dpdk.org (Postfix) with ESMTP id F28E9161D6D for ; Thu, 15 Apr 2021 00:07:03 +0200 (CEST) Received: by mail-lj1-f172.google.com with SMTP id o16so24922464ljp.3 for ; Wed, 14 Apr 2021 15:07: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=Ss0sG/KD74B+jbDFJjeYohrmGmvBcb9Pj9ztRiU7YX4+ib7Ubbfdr2rMiL3doAHzNF 3U9QcXk13Srrc5XdtVQ/Xi/jM0/TJ+gtr+p7WNRGchfG0s9k64a/OqtiuW9xPrwG6LJf HNEjiUCeb+qNGUhltSjo8nXBGcEO3VHVE/m8aU5NXvpJGJqlzslXFZI1UOrEaTJvjWnF Uif6oQKRiA5Z3L4oTv6UpMX5bHIBToghZmhyhpRwCPoPs3VtleOyqoadTyJM/DqScqop vX1sT/mx+NdjceFfuHseG9b3PguM9clxKVBetw79WA50ySbzxJKKGBHXVnTTiYKGEXMe k/Ng== 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=iUFK2Ch9BZjsacStTGWypzalxYUPflfuikS7rP7lVg84yn1cLYJwBXd2TIUXx6kvzF 8+3l/LwHyyw8SrJIsuPxXyhx3lEwrZUimWZ0TGVhM5rbhDsitXp4CdvIZqJqoWVEFJ7c Wr0mLFtlYaKWlSKe3/+zqV9xGzCjyNpSF6GubpZQIGKX+D70lcMe/dPg2uIiHl4V/7ol 3mS2us4VQONk8oIqSX+Jz5GiAsP4PEf1w5SRjuwgl7EnjgG2A/sye5ztgO/7612shKHe qOT5ASdyDxRHMp1/vG9cSIjMyiNJoafXhPhZ6UDZ0BZqEnz+GwQ79yrLr8Ig0dKwQLS5 YIcQ== X-Gm-Message-State: AOAM531O7rDzD7JP4BnengW0FZhXJV9iicZFiryqQdWincfyIZ6OnTum Ub5rtUJHzyF3aLsLxt9DZrvwShdLgpncEOjj X-Google-Smtp-Source: ABdhPJxshy+ij3GhtO4zhPkxh+h1y5a0w1CsGqq1SSZF9qGL75ZEn9szNETp6kaYeKmaAhH0NrMp2w== X-Received: by 2002:a2e:8084:: with SMTP id i4mr85079ljg.122.1618438023277; Wed, 14 Apr 2021 15:07:03 -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 m28sm271489lfo.278.2021.04.14.15.07.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Apr 2021 15:07:02 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Kozlyuk , Ranjit Menon , Olivier Matz Date: Thu, 15 Apr 2021 01:06:50 +0300 Message-Id: <20210414220651.28691-4-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20210414220651.28691-1-dmitry.kozliuk@gmail.com> References: <20210410224732.20234-1-dmitry.kozliuk@gmail.com> <20210414220651.28691-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v10 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