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 AB4CC45CE3 for ; Mon, 11 Nov 2024 07:32:39 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A3B1540E1D; Mon, 11 Nov 2024 07:32:39 +0100 (CET) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2088.outbound.protection.outlook.com [40.107.93.88]) by mails.dpdk.org (Postfix) with ESMTP id 1880240E09 for ; Mon, 11 Nov 2024 07:32:38 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xrrg7n1kKpjZZ53uExovbl0aUe0NT5hdhEqNWa4xtHd9x2ZWdvtULP7PO5R7rKqKAyaNntgodpbYnXkiF/hQr2VpQNI1kV0IC932U/BU8WtRhKQz5BShnWzCXfNo36BtvPFeuilI+J4AcrhrSp8wvNgYdGGkgf17wi+5axhGriQ9wJTO6/HUInZaHjvNudeoZwsbn5uTAUXg3O93GZeYIKX6bctcK4bVoNynGa7oLLLolTHquyX1NuXq7xqVViL4x6jStF/6FrRyc/NejPiQqITED2AwLA193UJFdXvF5kazezxnHXIac4xgv+1cPzMRzedKk/wnkcOQvDTclvmilg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=HqL6/t59wg/PBvTkoxJMqtzn4TehOVrU6CqztE7bdro=; b=kvcjuw9YLxAt1ARfeyfGoFfjxW9LT90XVv8xa69DybEMZ4nH4NovPNwZi3Jl8XcGvokUkzCSYKDKYriflgrDPNw/kvmcP9VstvCUjfIsY1hLOf9jBVKzaSMxAbSjFvdbBKTsKkKH0yXDrfAkMtdvcFaw5vBIX2BkD8MLdnqfI3ZqPrWEKZZg+JXakS/1TSvBxbjeSgt0YwedaSJ3nmMsw1oHOXrdVlpg8tYhHKB6lcFZefY5L/F6U2sehCDbfx7vW0JbMdvoLXVbe6TatRM/HvptSFRFQ6pviI4SYnC7Zgpz5xESVLR4NRbVxkSzBRjXmi8wcsioERdLZQSSXcUnog== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=interfacemasters.com 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 (0) 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=HqL6/t59wg/PBvTkoxJMqtzn4TehOVrU6CqztE7bdro=; b=M7wfuPvyMiuU7EJybQv2FdAlBtYVLGeKhoOn4qfSZ2OiwcVroVMA/RT0swUAwh4mDf8gec2oUIfcMNdMyQJku3cjAM3kYjCcvDP6mBUyBaxDiSuFhZ7TEFI7U7XRwsm8JLd0+BGgKogahNUCM2k26RqlnsbH1av8I5WLyqUYiLw4HTqdzl2MjLDwZLUhh+oLDCuDu1qarjPt8VqE2HXuo6JR5QsGEqo+RjBm7nmGNVtDL7No+7Rfa953jKrjCycEj59GcDZLXFQd4piiuiyLHDsaIR6E7kxpQXAjrpX9ZFdz5HxjIqa4hB733Nz7n02u0sDSPOWx4jnNpU+olfflog== Received: from BN9PR03CA0658.namprd03.prod.outlook.com (2603:10b6:408:13b::33) by PH7PR12MB7428.namprd12.prod.outlook.com (2603:10b6:510:203::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Mon, 11 Nov 2024 06:32:34 +0000 Received: from BN2PEPF000055DA.namprd21.prod.outlook.com (2603:10b6:408:13b:cafe::e6) by BN9PR03CA0658.outlook.office365.com (2603:10b6:408:13b::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28 via Frontend Transport; Mon, 11 Nov 2024 06:32:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BN2PEPF000055DA.mail.protection.outlook.com (10.167.245.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.1 via Frontend Transport; Mon, 11 Nov 2024 06:32:33 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Sun, 10 Nov 2024 22:32:23 -0800 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Sun, 10 Nov 2024 22:32:21 -0800 From: Xueming Li To: Oleksandr Nahnybida CC: , Stephen Hemminger , dpdk stable Subject: patch 'pcapng: fix handling of chained mbufs' has been queued to stable release 23.11.3 Date: Mon, 11 Nov 2024 14:27:17 +0800 Message-ID: <20241111062847.216344-32-xuemingl@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241111062847.216344-1-xuemingl@nvidia.com> References: <20241111062847.216344-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000055DA:EE_|PH7PR12MB7428:EE_ X-MS-Office365-Filtering-Correlation-Id: 9842c298-4f18-4b5a-a5ad-08dd021aa041 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|82310400026|1800799024|15866825006; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?K0d5OkAaXv9+mkQLnv1uWHxCsZpZSQDGKejNz1GJxk+/clEMS3rqwLqga7gJ?= =?us-ascii?Q?SyyK0QFTofsuYwnpbQF0JPRmgf+YWlZSX9JnqOCT1vE/TNVnfmHVMUuL/BVv?= =?us-ascii?Q?JRLOn+swfoyNfHRLUzWttSSxm6yeeCliQWYB/9DzjKmUIsnT4ShKPoLGpq2s?= =?us-ascii?Q?uA8ND2MeBD74UrzYhFxCi3F+AEs8ZMSaVBnUFUM3cRVHaP/vAeNx7c+GP1Qe?= =?us-ascii?Q?u28g98lXloPiSiZuzQHnkX6DNb8CtfkjR48yg+CjXGnnHxJoks8xl8jH36FB?= =?us-ascii?Q?FqSKePW/5tdVj/dbU89SWwhc0coElm3O57tJyFtyvuni3LuJxTGyiiyah3Wt?= =?us-ascii?Q?eGq5bszA0fi/jiMwgPDURDeXMRTqWXNW6dgwYCU4BbZxT9MnHU9C9/S98cu+?= =?us-ascii?Q?1+20nKw4DMvaVooAiFGTIXiX/FM5ZM+o88KUiDCbttxoUhOFm+HMW0XKmynf?= =?us-ascii?Q?jVH9TCyXUbhV1g3K5+7amTYDEaKRQ1jvzYqeReKMVqawua1f9YEwsH9FSaKv?= =?us-ascii?Q?w0sJ51mtayS1wunzruaHjXJM7HwqMLp96EG2n2DpNwb485jL2RMXkma4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Ckpd?= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230040)(376014)(36860700013)(82310400026)(1800799024)(15866825006); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2024 06:32:33.5482 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9842c298-4f18-4b5a-a5ad-08dd021aa041 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.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000055DA.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7428 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 Hi, FYI, your patch has been queued to stable release 23.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/30/24. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://git.dpdk.org/dpdk-stable/log/?h=23.11-staging This queued commit can be viewed at: https://git.dpdk.org/dpdk-stable/commit/?h=23.11-staging&id=e989eae1c9a4ec9a7fdf8014a58cdd0a241a836f Thanks. Xueming Li --- >From e989eae1c9a4ec9a7fdf8014a58cdd0a241a836f Mon Sep 17 00:00:00 2001 From: Oleksandr Nahnybida Date: Fri, 13 Sep 2024 15:34:03 +0300 Subject: [PATCH] pcapng: fix handling of chained mbufs Cc: Xueming Li [ upstream commit 6db358536fee7891b5cb670df94ec87543ddd0fb ] The pcapng generates corrupted files when dealing with chained mbufs. This issue arises because in rte_pcapng_copy the length of the EPB block is incorrectly calculated using the data_len of the first mbuf instead of the pkt_len, despite that rte_pcapng_write_packets correctly writing the mbuf chain to disk. This fix ensures that the block length is calculated based on the pkt_len, aligning it with the actual data written to disk. Fixes: 8d23ce8f5ee9 ("pcapng: add new library for writing pcapng files") Signed-off-by: Oleksandr Nahnybida Reviewed-by: Stephen Hemminger --- .mailmap | 1 + app/test/test_pcapng.c | 12 ++++++++++-- lib/pcapng/rte_pcapng.c | 12 ++++++------ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.mailmap b/.mailmap index 8b9e849d05..4022645615 100644 --- a/.mailmap +++ b/.mailmap @@ -1059,6 +1059,7 @@ Odi Assli Ognjen Joldzic Ola Liljedahl Oleg Polyakov +Oleksandr Nahnybida Olga Shern Olivier Gournet Olivier Matz diff --git a/app/test/test_pcapng.c b/app/test/test_pcapng.c index 89535efad0..5cdde0542a 100644 --- a/app/test/test_pcapng.c +++ b/app/test/test_pcapng.c @@ -102,6 +102,14 @@ mbuf1_prepare(struct dummy_mbuf *dm, uint32_t plen) pkt.udp.dgram_len = rte_cpu_to_be_16(plen); memcpy(rte_pktmbuf_mtod(dm->mb, void *), &pkt, sizeof(pkt)); + + /* Idea here is to create mbuf chain big enough that after mbuf deep copy they won't be + * compressed into single mbuf to properly test store of chained mbufs + */ + dummy_mbuf_prep(&dm->mb[1], dm->buf[1], sizeof(dm->buf[1]), pkt_len); + dummy_mbuf_prep(&dm->mb[2], dm->buf[2], sizeof(dm->buf[2]), pkt_len); + rte_pktmbuf_chain(&dm->mb[0], &dm->mb[1]); + rte_pktmbuf_chain(&dm->mb[0], &dm->mb[2]); } static int @@ -117,7 +125,7 @@ test_setup(void) /* Make a pool for cloned packets */ mp = rte_pktmbuf_pool_create_by_ops("pcapng_test_pool", - MAX_BURST, 0, 0, + MAX_BURST * 32, 0, 0, rte_pcapng_mbuf_size(pkt_len) + 128, SOCKET_ID_ANY, "ring_mp_sc"); if (mp == NULL) { @@ -155,7 +163,7 @@ fill_pcapng_file(rte_pcapng_t *pcapng, unsigned int num_packets) for (i = 0; i < burst_size; i++) { struct rte_mbuf *mc; - mc = rte_pcapng_copy(port_id, 0, orig, mp, pkt_len, + mc = rte_pcapng_copy(port_id, 0, orig, mp, rte_pktmbuf_pkt_len(orig), RTE_PCAPNG_DIRECTION_IN, NULL); if (mc == NULL) { fprintf(stderr, "Cannot copy packet\n"); diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c index 7254defce7..e5326c1d38 100644 --- a/lib/pcapng/rte_pcapng.c +++ b/lib/pcapng/rte_pcapng.c @@ -475,7 +475,7 @@ rte_pcapng_copy(uint16_t port_id, uint32_t queue, const char *comment) { struct pcapng_enhance_packet_block *epb; - uint32_t orig_len, data_len, padding, flags; + uint32_t orig_len, pkt_len, padding, flags; struct pcapng_option *opt; uint64_t timestamp; uint16_t optlen; @@ -516,8 +516,8 @@ rte_pcapng_copy(uint16_t port_id, uint32_t queue, (md->ol_flags & RTE_MBUF_F_RX_RSS_HASH)); /* pad the packet to 32 bit boundary */ - data_len = rte_pktmbuf_data_len(mc); - padding = RTE_ALIGN(data_len, sizeof(uint32_t)) - data_len; + pkt_len = rte_pktmbuf_pkt_len(mc); + padding = RTE_ALIGN(pkt_len, sizeof(uint32_t)) - pkt_len; if (padding > 0) { void *tail = rte_pktmbuf_append(mc, padding); @@ -584,7 +584,7 @@ rte_pcapng_copy(uint16_t port_id, uint32_t queue, goto fail; epb->block_type = PCAPNG_ENHANCED_PACKET_BLOCK; - epb->block_length = rte_pktmbuf_data_len(mc); + epb->block_length = rte_pktmbuf_pkt_len(mc); /* Interface index is filled in later during write */ mc->port = port_id; @@ -593,7 +593,7 @@ rte_pcapng_copy(uint16_t port_id, uint32_t queue, timestamp = rte_get_tsc_cycles(); epb->timestamp_hi = timestamp >> 32; epb->timestamp_lo = (uint32_t)timestamp; - epb->capture_length = data_len; + epb->capture_length = pkt_len; epb->original_length = orig_len; /* set trailer of block length */ @@ -623,7 +623,7 @@ rte_pcapng_write_packets(rte_pcapng_t *self, /* sanity check that is really a pcapng mbuf */ epb = rte_pktmbuf_mtod(m, struct pcapng_enhance_packet_block *); if (unlikely(epb->block_type != PCAPNG_ENHANCED_PACKET_BLOCK || - epb->block_length != rte_pktmbuf_data_len(m))) { + epb->block_length != rte_pktmbuf_pkt_len(m))) { rte_errno = EINVAL; return -1; } -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-11-11 14:23:06.730371307 +0800 +++ 0031-pcapng-fix-handling-of-chained-mbufs.patch 2024-11-11 14:23:05.072192841 +0800 @@ -1 +1 @@ -From 6db358536fee7891b5cb670df94ec87543ddd0fb Mon Sep 17 00:00:00 2001 +From e989eae1c9a4ec9a7fdf8014a58cdd0a241a836f Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 6db358536fee7891b5cb670df94ec87543ddd0fb ] @@ -16 +18,0 @@ -Cc: stable@dpdk.org @@ -27 +29 @@ -index 62ef194168..aee7c91780 100644 +index 8b9e849d05..4022645615 100644 @@ -30 +32,2 @@ -@@ -1091,6 +1091,7 @@ Ognjen Joldzic +@@ -1059,6 +1059,7 @@ Odi Assli + Ognjen Joldzic @@ -33 +35,0 @@ - Oleksandr Kolomeiets @@ -39 +41 @@ -index 2665b08c76..b219873c3a 100644 +index 89535efad0..5cdde0542a 100644