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 2D6DD41EB2 for ; Thu, 16 Mar 2023 19:24:38 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 25A4342DAD; Thu, 16 Mar 2023 19:24:38 +0100 (CET) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2085.outbound.protection.outlook.com [40.107.94.85]) by mails.dpdk.org (Postfix) with ESMTP id 9E2C140DDC; Thu, 16 Mar 2023 19:24:35 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VCRMBX2NvSoxpOzluajOcn2qLKqNB44442xVPm6WV+yWttcbDlDMT8EzDGJkDqlUMoIM/Kpn6Q5xUM3FAr+xjSEKhBF8rR+JzyAbXq6wEWSD1FETyk/Hj6h5CvsJ3KRw9Lfo4L0BlrbqYVpbuLt7lTpw2PcMwdQn+nNjjn8ib9HFtScTu32AVM4gMn0UXXAtiSCHxB9kiHUxl9pq8eHh3u9G2jJa3csuFJ+H3D3WTpB3YGCFN58X+3LNaFepR6hnXwU+fczqz+Sm2EDPmcYt2EEvUR10QSLRg08ftEMgMtX6s3k+z8ouqbA/7TJFVztZc8P0jrWFXVLZjfjm887Pww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=W7oQCbFXZuOv5ty06mcqnWTUYNET9++bf4hh+S5XSg0=; b=KAkW60aPhi4LuxfRyF+B1AvR6ozdSwOLvFrCUIj+I6YtotmITO6rjnNYJ2hcjcA5A0CeZwXsHQ5FM/UPIVv8p7srTeofoI7zh0GI7bBHEa3EX+ne76PJuLw6JHnfwo8YJwa7+wM6H0eU+bDcaijZsFC555+6MVJ+fDPSX9VE+jVu1kFZxk3FtNS5CgROIQrz6kaG/ctY0yPSDVYcsyHP1z5xKDBDEh0RKil7S7AUeD+MyAPbWCSI34O+6iESQFJbLlURWjyICJB1Xno6nP2VOWV8BwaC2D/seynhhX+2t6Lx1T2ILc3Tp8XfxTIHYoRzuYbRbg7zBmPSCy2Bf0vzUw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W7oQCbFXZuOv5ty06mcqnWTUYNET9++bf4hh+S5XSg0=; b=t5FYC+1ETAwlRpVu84XfCvIjgX8HnEP8F4aq6cCCG/w0JWnAxZwYPOju+KpSJfo6KjNgtnXDZiY2k4X2Jyk8+aBpph3yPfHQPagHBzkIXe8tANgUCLcc+eKk6oDFwAyf5c3fL+Cb/9C6I9mCFXVzctFbOUgzOeiGwaOImp2KakgRLechCgT6/jx3ykgtLTsBGugxv/RFqK1D/6gor3cyXRvJWvFGZJZ5jtOGLdPIqWBbNtB9syor0ijdoL47tgxlC7uLVuZoa5gDmu1vphyI/7tVqS87j26twFxWBPILNNy1mp7J54lOkwkBBYs88mWdmOy4OOve+whfdNN6/TDdqQ== Received: from MW4PR03CA0191.namprd03.prod.outlook.com (2603:10b6:303:b8::16) by DS0PR12MB8479.namprd12.prod.outlook.com (2603:10b6:8:155::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.33; Thu, 16 Mar 2023 18:24:33 +0000 Received: from CO1NAM11FT048.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b8:cafe::ba) by MW4PR03CA0191.outlook.office365.com (2603:10b6:303:b8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.31 via Frontend Transport; Thu, 16 Mar 2023 18:24:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1NAM11FT048.mail.protection.outlook.com (10.13.175.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6199.16 via Frontend Transport; Thu, 16 Mar 2023 18:24:33 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 16 Mar 2023 11:24:21 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 16 Mar 2023 11:24:20 -0700 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5 via Frontend Transport; Thu, 16 Mar 2023 11:24:18 -0700 From: Michael Baum To: CC: Aman Singh , Yuying Zhang , Ferruh Yigit , "Thomas Monjalon" , , Subject: [PATCH v2] app/testpmd: fix wrong encap/decap size calculation Date: Thu, 16 Mar 2023 20:24:12 +0200 Message-ID: <20230316182412.1831799-1-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230316171654.1827514-1-michaelba@nvidia.com> References: <20230316171654.1827514-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT048:EE_|DS0PR12MB8479:EE_ X-MS-Office365-Filtering-Correlation-Id: f44356c3-114f-4c8c-891a-08db264bb116 X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: v+c8BpgnZrrBcnYTG0QzqJNZpwdzVHVfd5+zqbd/l5UWZjtkqiwswiqxQfiCK8uJKm6eExqd/DkijaY9gYOBmNBUCs8yRHrAKb1nXpSXfsbTGjmfEvLyCTI5hxKdgrnzc0zBlWkTJTjEHYlA0t0hgsBTalHXrnVYx+1PcY7L4ikbtBHF/rtQjzfoQ44EHT1ZqzFy5j38DJRiDzFpjtHQyda9MHwqJK7U+CXlHDmJP9ob3vWCSjMCet+d5M84wI3HRKKPPXDAVOymDlLVNa9xX1B/EBwOUw7uhKAhm3HEZblnnaM1aUyJnWmHCpjFBDtnuZM9sDOum7dy4o0809mp1EnV1ps3QjfeIHDuQM5F3fPLpQ18Zl891Oiwg9+8DqvZbUHHvMXZMDA3Z1t2a4ckNWldou2a8j05g17CeMwYaB1tUN6Y/STRfZTDXNYweW3vB+HKc53PGNSoqCwZ4KNchlvlE85KbV9oSgUmijWr4t/MuugL4b2CLPVwYm1XM0Mem/FyI56qaez/mhz8y+7PWpc666Z8uFhjEgsThSpQz3DJUFLb3j12DwY2xSElYxGG3UXFfr9Zd6DS2tIZ9zqpyYzDtWhXTtOudpQ7dzVF8vslmF4O8X+8swpzYsIutDx541cjoLm8IqMBQzIfEBhdoA5FWVreNX1uU+dSj3fcdg1pXklUjMhY1CoYOH4AfsPN8y9o2CHsQLGBQL2ndIUE7j+fPvY3U7aR4c49JBAqpIms5uS9IHQZucF+aaFAW6Pj X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230025)(4636009)(376002)(396003)(346002)(39860400002)(136003)(451199018)(40470700004)(46966006)(36840700001)(8936002)(54906003)(7636003)(478600001)(83380400001)(6916009)(4326008)(55016003)(41300700001)(8676002)(40480700001)(36860700001)(316002)(70206006)(70586007)(356005)(40460700003)(1076003)(26005)(82740400003)(82310400005)(336012)(6666004)(36756003)(6286002)(86362001)(186003)(2616005)(426003)(7696005)(5660300002)(2906002)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Mar 2023 18:24:33.6941 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f44356c3-114f-4c8c-891a-08db264bb116 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT048.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8479 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Testpmd app has some functions to create either encap or decap buffer for some special cases: - "l2_encap" and "l2_decap" - "mplsogre_encap" and "mplsogre_decap" - "mplsoudp_encap" and "mplsoudp_decap" The functions use both "rte_flow_item_eth" and "rte_flow_item_vlan" structures to represent the headers and copy them into "raw_encap" action. The size of either "raw_encap" or "raw_decap" is calculated as sum of headers size. However, the both "rte_flow_item_eth" and "rte_flow_item_vlan" contain more fields than original headers, so using them cause bad size calculation. This patch uses "rte_ether_hdr" and "rte_vlan_hdr" structures for header size calculation. Fixes: 3e77031be855 ("app/testpmd: add MPLSoGRE encapsulation") Fixes: a1191d39cb57 ("app/testpmd: add MPLSoUDP encapsulation") Cc: orika@nvidia.com Cc: stable@dpdk.org Signed-off-by: Michael Baum --- v2: - Fix typo in commit log. - Using "sizeof(struct rte_*_hdr)" instead of "*_LEN" macros. app/test-pmd/cmdline_flow.c | 48 ++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 9309607f11..58939ec321 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -8245,15 +8245,15 @@ parse_vc_action_l2_encap(struct context *ctx, const struct token *token, l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN); memcpy(eth.hdr.src_addr.addr_bytes, l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN); - memcpy(header, ð, sizeof(eth)); - header += sizeof(eth); + memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr)); + header += sizeof(struct rte_ether_hdr); if (l2_encap_conf.select_vlan) { if (l2_encap_conf.select_ipv4) vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4); else vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6); - memcpy(header, &vlan, sizeof(vlan)); - header += sizeof(vlan); + memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr)); + header += sizeof(struct rte_vlan_hdr); } action_encap_data->conf.size = header - action_encap_data->data; @@ -8301,11 +8301,11 @@ parse_vc_action_l2_decap(struct context *ctx, const struct token *token, header = action_decap_data->data; if (l2_decap_conf.select_vlan) eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN); - memcpy(header, ð, sizeof(eth)); - header += sizeof(eth); + memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr)); + header += sizeof(struct rte_ether_hdr); if (l2_decap_conf.select_vlan) { - memcpy(header, &vlan, sizeof(vlan)); - header += sizeof(vlan); + memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr)); + header += sizeof(struct rte_vlan_hdr); } action_decap_data->conf.size = header - action_decap_data->data; @@ -8385,15 +8385,15 @@ parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token, mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN); memcpy(eth.hdr.src_addr.addr_bytes, mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN); - memcpy(header, ð, sizeof(eth)); - header += sizeof(eth); + memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr)); + header += sizeof(struct rte_ether_hdr); if (mplsogre_encap_conf.select_vlan) { if (mplsogre_encap_conf.select_ipv4) vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4); else vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6); - memcpy(header, &vlan, sizeof(vlan)); - header += sizeof(vlan); + memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr)); + header += sizeof(struct rte_vlan_hdr); } if (mplsogre_encap_conf.select_ipv4) { memcpy(header, &ipv4, sizeof(ipv4)); @@ -8480,15 +8480,15 @@ parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token, mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN); memcpy(eth.hdr.src_addr.addr_bytes, mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN); - memcpy(header, ð, sizeof(eth)); - header += sizeof(eth); + memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr)); + header += sizeof(struct rte_ether_hdr); if (mplsogre_encap_conf.select_vlan) { if (mplsogre_encap_conf.select_ipv4) vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4); else vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6); - memcpy(header, &vlan, sizeof(vlan)); - header += sizeof(vlan); + memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr)); + header += sizeof(struct rte_vlan_hdr); } if (mplsogre_encap_conf.select_ipv4) { memcpy(header, &ipv4, sizeof(ipv4)); @@ -8579,15 +8579,15 @@ parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token, mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN); memcpy(eth.hdr.src_addr.addr_bytes, mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN); - memcpy(header, ð, sizeof(eth)); - header += sizeof(eth); + memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr)); + header += sizeof(struct rte_ether_hdr); if (mplsoudp_encap_conf.select_vlan) { if (mplsoudp_encap_conf.select_ipv4) vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4); else vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6); - memcpy(header, &vlan, sizeof(vlan)); - header += sizeof(vlan); + memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr)); + header += sizeof(struct rte_vlan_hdr); } if (mplsoudp_encap_conf.select_ipv4) { memcpy(header, &ipv4, sizeof(ipv4)); @@ -8676,15 +8676,15 @@ parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token, mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN); memcpy(eth.hdr.src_addr.addr_bytes, mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN); - memcpy(header, ð, sizeof(eth)); - header += sizeof(eth); + memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr)); + header += sizeof(struct rte_ether_hdr); if (mplsoudp_encap_conf.select_vlan) { if (mplsoudp_encap_conf.select_ipv4) vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4); else vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6); - memcpy(header, &vlan, sizeof(vlan)); - header += sizeof(vlan); + memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr)); + header += sizeof(struct rte_vlan_hdr); } if (mplsoudp_encap_conf.select_ipv4) { memcpy(header, &ipv4, sizeof(ipv4)); -- 2.25.1