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 7EE3C41EB2; Thu, 16 Mar 2023 18:17:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5DC4240DF6; Thu, 16 Mar 2023 18:17:16 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2059.outbound.protection.outlook.com [40.107.223.59]) by mails.dpdk.org (Postfix) with ESMTP id 0061C40DDC; Thu, 16 Mar 2023 18:17:14 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WMzdXFfs8FjFzmL+ZmCThZm/eT9K0+16gggDrtGMreQKbc63Bufx9PCuDVh0DIAs2UjwF8uTUoRq6enHZy1jfKNCvE9yEV3PgFkCoUcJLd0K4cM2TGf56VunTOA2KUJGUwsbaMDNaLryznUvQQZj4DbGk7KutVPoV2A6iaAkiUw8Afr9X9v2RJCIB5b8UylPnmsW4WImJ0zQ8qxDRY7LQ3kmUkztK84eDMZtGj1ydwGbfgOkNnhVexAGYMkvIlZN4HmcJGetaWIqXmVv0jQ68ex8m3kD7cSBfULj2bsg8mkxnrTLr9kqtXPTBU1gCJZhQfJm21LkXVrO81k75EH+Bg== 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=mVkNkrotqdK3/QM2WAmZXzBFgvYKeBkSvKpajkSEymk=; b=jxmzj3ga1Ns5VED2ULz9tTNSYnbFz9r6iWgJyBuCbjo0virc6FxHEYCXRuDA5CapgAr8it9B1CowxCHU3p7t2Z9XhqR3CusWyFF3yZTUmlWnYp1wAvHIEI5kVXlr/Mr6bXs41rMBEre+Eq1619WrQWO6cT2/qTILOpfbtHHMGmL950i2XqJICZHR2wd2Jma3VTl5qzUqBnMRiuIGHA0Ck6PmkyFhyN939Xj5t7pY4nAWBtLPTEG0KkbqfTf/ipYuZacyGQjlQWuV3OEzz1TKrlUK/3f8DUvgbSV3PiCY+mlTfyo4BnVU6omFq0OHu5IAYgbc/rggXesolbMBZ6MHtg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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=mVkNkrotqdK3/QM2WAmZXzBFgvYKeBkSvKpajkSEymk=; b=ZGRQau0LQ+Odn8vWPSbxXeSr4GYH4z4nMa2vWaBpZ2G7uXxsVzsvMg1O5cvSoZfPlFtMELMI5k2cQXJoSsAna3zsnIguMQafSNcwJ2hLNGFk8lFy/4TCjdV0K3CGa2l3oDPf/lYOrt0FEIfAtQCZodyrRx8Ktd2WDPv+cgfMbeu+tto0VB9bws0vXClU5CgdUQZPBv3P7MwUyDYS3dr8r01RrnMY8M9mIxfUmPo++AulvbLHUz89T2kWV8SXi3te8UnbWyUfo3osFyTvcvbzi8pWMiPUZMMp3PQDUijCEP0EnQ5IKAm9ahZK+1egoW9E/I+4O+Gjtvn9erNDNqmvGg== Received: from BN0PR04CA0068.namprd04.prod.outlook.com (2603:10b6:408:ea::13) by CY8PR12MB7339.namprd12.prod.outlook.com (2603:10b6:930:51::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.26; Thu, 16 Mar 2023 17:17:13 +0000 Received: from BN8NAM11FT097.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ea:cafe::50) by BN0PR04CA0068.outlook.office365.com (2603:10b6:408:ea::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.33 via Frontend Transport; Thu, 16 Mar 2023 17:17:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) 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.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by BN8NAM11FT097.mail.protection.outlook.com (10.13.176.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6199.17 via Frontend Transport; Thu, 16 Mar 2023 17:17:12 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) 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 10:17:00 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) 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 10:16:59 -0700 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.181) 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 10:16:58 -0700 From: Michael Baum To: CC: Aman Singh , Yuying Zhang , Ferruh Yigit , "Thomas Monjalon" , , Subject: [PATCH] app/testpmd: fix wrong encap/decap size calculation Date: Thu, 16 Mar 2023 19:16:54 +0200 Message-ID: <20230316171654.1827514-1-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT097:EE_|CY8PR12MB7339:EE_ X-MS-Office365-Filtering-Correlation-Id: fe0665f9-f9c0-43da-0e6d-08db26424835 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: wIeb/SEVfbRAsDYdpHfajrFzsAfu25Y00t+VOqAjIjm4RpFlevZsR1gNBPJ4+LYmKkMqjo0h9WJjyzynP2YypcjMmWqYP8E0bQbX8lejrs5VyJoVeq5l41YQdvZzxpfkIb5BcaEO41HX6PAhCAVsQ8pF/iWQC6v8i6ysbdLpc8LFpUqnO9nppr5RmjCiBI50/vvg2DIdz/BUxza3PKXNUTUrdwxRHcAuXpgbpF7aBoZp4aM82I/U8FjtLgLzg4n1bWj/jjDtjIxqjdNUxY04KEH7pFX1YS6M+dC1/9CeAoL4PIfYkHdAuYeyIsfC76Rd60QJfdR1m84ZZ4w5cGiPRe2WC2EimC02V1RFFzCOPgn2WrzVWQ9XHmRWaVf1Hf2s9hnXUVvzGfDa9FeNZrb/jxile8OXhq4eOosDl9veZcf0b2nH1gYOpOwNX3W6I79HeVQ/rnulSQRrqi4nBLdRnjFM7uZOMqPY3jY3wP+gjOf+C03+aWSnBWlcGSd23RrjFzY3fDkhVDDER92ut/ocPMUUOCyfn2HV2doaFNGkyXcJaPxyDk5S/G8+oCjAd8kMHOh96YydEzXwoEknopvpqk8lH+UKS/nZsl8xJIH5y8WaqvVYThYT4czAwFoAdrReBddf1ohj5t3OQfA6NmqYScWipl6NLJPVnlqydX/MC5UNQJkZj7ptfzOi19Bfb+zUC6gRZiAi8e51/XEhOKrXP9yXumMuRWXve/J/LWljMej9io9ehAhby9eERA5LIbT6 X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230025)(4636009)(346002)(39860400002)(136003)(396003)(376002)(451199018)(40470700004)(36840700001)(46966006)(36756003)(83380400001)(82310400005)(426003)(54906003)(47076005)(336012)(40480700001)(40460700003)(316002)(55016003)(26005)(478600001)(6666004)(7696005)(6286002)(186003)(8936002)(5660300002)(356005)(41300700001)(86362001)(2906002)(4326008)(6916009)(36860700001)(8676002)(82740400003)(1076003)(7636003)(70206006)(2616005)(70586007); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Mar 2023 17:17:12.2315 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fe0665f9-f9c0-43da-0e6d-08db26424835 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT097.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7339 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 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 capculated 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_LEN" and "RTE_VLAN_HLEN" macros in 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 --- 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 63a0b36622..fff0cb3d57 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -7988,15 +7988,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, RTE_ETHER_HDR_LEN); + header += RTE_ETHER_HDR_LEN; 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, RTE_VLAN_HLEN); + header += RTE_VLAN_HLEN; } action_encap_data->conf.size = header - action_encap_data->data; @@ -8044,11 +8044,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, RTE_ETHER_HDR_LEN); + header += RTE_ETHER_HDR_LEN; if (l2_decap_conf.select_vlan) { - memcpy(header, &vlan, sizeof(vlan)); - header += sizeof(vlan); + memcpy(header, &vlan.hdr, RTE_VLAN_HLEN); + header += RTE_VLAN_HLEN; } action_decap_data->conf.size = header - action_decap_data->data; @@ -8128,15 +8128,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, RTE_ETHER_HDR_LEN); + header += RTE_ETHER_HDR_LEN; 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, RTE_VLAN_HLEN); + header += RTE_VLAN_HLEN; } if (mplsogre_encap_conf.select_ipv4) { memcpy(header, &ipv4, sizeof(ipv4)); @@ -8223,15 +8223,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, RTE_ETHER_HDR_LEN); + header += RTE_ETHER_HDR_LEN; 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, RTE_VLAN_HLEN); + header += RTE_VLAN_HLEN; } if (mplsogre_encap_conf.select_ipv4) { memcpy(header, &ipv4, sizeof(ipv4)); @@ -8322,15 +8322,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, RTE_ETHER_HDR_LEN); + header += RTE_ETHER_HDR_LEN; 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, RTE_VLAN_HLEN); + header += RTE_VLAN_HLEN; } if (mplsoudp_encap_conf.select_ipv4) { memcpy(header, &ipv4, sizeof(ipv4)); @@ -8419,15 +8419,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, RTE_ETHER_HDR_LEN); + header += RTE_ETHER_HDR_LEN; 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, RTE_VLAN_HLEN); + header += RTE_VLAN_HLEN; } if (mplsoudp_encap_conf.select_ipv4) { memcpy(header, &ipv4, sizeof(ipv4)); -- 2.25.1