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 BC23BA0547; Sun, 11 Apr 2021 00:47:59 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C66AA14132C; Sun, 11 Apr 2021 00:47:48 +0200 (CEST) Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by mails.dpdk.org (Postfix) with ESMTP id A734F1412F0 for ; Sun, 11 Apr 2021 00:47:44 +0200 (CEST) Received: by mail-lf1-f44.google.com with SMTP id h19so15358845lfu.9 for ; Sat, 10 Apr 2021 15:47:44 -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=4fxhlEkLW3b/WPvnj/tHnGMIffgTltb79nquaFKFKKM=; b=KzqVWEkzqGtObnJoi0NOg1+Ol4uPvqV2Hi6R8mxa06w3Pr9zQZRB9yvFkYfkhv5jpZ SeYR3xmxeQlydQz7ZGrMzFq5XJZsAURpUx37nlKKLgGb8mwgKFCxGDvPna6gPUYQS079 Dq36nuaDJ6lcGljeToli3AB03JG/oYSJVqoPCxjaQUQCnpfDdS6kc2NIh1UeLwTfnoMs uZG2riHYBBJoFpE6AbtYYNry+omLw5Qwx2fHLPjt+SocmmPwYF3eVx2gQM/7qLCBRgdx 6V3zVnl2zMave0vn55WHyfVPmRbhI1jppdWhQtXc0qt+8eJe4GvJBe5ZPoj87sWrrmf5 2nPg== 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=4fxhlEkLW3b/WPvnj/tHnGMIffgTltb79nquaFKFKKM=; b=nmZMUBo+pXSIoIS3VsOouOMpJUWiBl5BKuCkG+N12jKsI8WSWTQkVK0tHRsUYzNnVT VFjaCKUczIaiyaov62cwI97bZG/vwZn+y/c+WqvFGzqL7eKhrUWIWRUXmiRjKZCsZqDX 06HsscGPwQRAmjG1hKb3JXH+z3qzXdi6D2gaUoXlLPHrwY8lSW1jnzK5ux0QqnTJOtdB TSMqk8wXZDrSuOY49a0D8TGu42npOiXm6YU5Wqmwmuk9ugvAiJq31AzGq7Yp8V+ly2Rl X9BZmrgxskYNl1DIoJm9y/78O0w+6W3vhh+9+SrU0gO/VHZJ1oaT/B98V70DQgStsUM7 EMpA== X-Gm-Message-State: AOAM533gYs1i7RHM1OjSKvI3OIfOFYkoyRHQOouiyo83/ciD8Y9zyTqv sfAuSu6I95aOP1am6QdVoxvRHhHRg6wk4w== X-Google-Smtp-Source: ABdhPJz30yRjkc06DQyV9o+vZTzDf1Iajm1MMF/LzfSvvvUppqTijpTwKIXMS9LgX2IMR++TlcyJGA== X-Received: by 2002:ac2:5a0c:: with SMTP id q12mr14520605lfn.119.1618094863967; Sat, 10 Apr 2021 15:47:43 -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 o15sm370270lfu.155.2021.04.10.15.47.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Apr 2021 15:47:43 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Kozlyuk , Ranjit Menon , Olivier Matz Date: Sun, 11 Apr 2021 01:47:31 +0300 Message-Id: <20210410224732.20234-4-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20210410224732.20234-1-dmitry.kozliuk@gmail.com> References: <20210407222249.6729-1-dmitry.kozliuk@gmail.com> <20210410224732.20234-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v9 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 Acked-by: Olivier Matz --- 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