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 CC458A0524 for ; Fri, 5 Feb 2021 12:31:08 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C3ACE40682; Fri, 5 Feb 2021 12:31:08 +0100 (CET) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by mails.dpdk.org (Postfix) with ESMTP id EE54F188949 for ; Fri, 5 Feb 2021 12:31:07 +0100 (CET) Received: by mail-wr1-f41.google.com with SMTP id l12so7337401wry.2 for ; Fri, 05 Feb 2021 03:31:07 -0800 (PST) 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=5/Lj1/EQjHlum7d4B8pJxVnEIuqCdfTGf0LczMvJe+Q=; b=fdZW0j6OhzlidJquAv89GX6FAJ+CLgwjvdm/jSkRni+43ujOcfchQ6NJ23jziDrVcI nkX4MSHiE+kApEvZK56AMTLqETXqcryT5f8YCZOv9IpW2h4lrhKrpBldH0OiFumIYbpg FX2uLaccXIKPRLFpNXXtyVw1G/QOJViMNUfAW4m3wqmoXb0uZi6+VV9IDmz6IK3hvTWf y7sqJ4MnGqSD1zyiBWgreyxYIrYpTmHa5AGLP/oSksoilmqsDcGD4isHptX/L8n/bpLc 7J9y7RymqjCS74OQRM40FCUTwi++Gs/hBy7hCbgPvVGCfLkE9IPYCulS7lBAoc955Z7r sGjw== 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=5/Lj1/EQjHlum7d4B8pJxVnEIuqCdfTGf0LczMvJe+Q=; b=I3vW+sN0KLgtd4HYiWhDE7GazQRZLDscJ2Fw/fSP7HPgO2mFBHQBl7AQjiEzFyaQob z9NZwDJj4Oir/BKG3IIlwLIVy97Rg74vSoAv4+wVCn3oTmqGLPmzdL65zS8OkEUDzeZ0 yJBCEZhVg32m6/X6AHtYLaDRCB+bXAOzqgoQylUIOi8qfxW6A05WmdCWnlDm+It3s4F0 kTRFL61E6Kr+KfzzrC6nEX0YDaicY1mvS1gLZS6w4/+Dd7TsGGCf83cu6uy8VGL2GNut W82/HvqH42viOmk9aXnhDAJ0pj5mZjeFwst9UpcTPou3wtxvK9jnwOiROA8WJmvCJSyE UUsw== X-Gm-Message-State: AOAM5308dxxfpkhisu3s2EqM2PpqLnOlelVdKSZcpLUAPIJviMIRL4Ha qQdnVQQpN++Va2cvxg78fJ+Ue+rVjyuKOsIU X-Google-Smtp-Source: ABdhPJwJbJtsMlyq27MBLxBgLyxvB0KeJ+oCgWrm6ry5SqGn0adNjCQA6N7pM48UwjK1kcf1NqfNyw== X-Received: by 2002:adf:fb0c:: with SMTP id c12mr4611795wrr.6.1612524667708; Fri, 05 Feb 2021 03:31:07 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id k131sm8815406wmb.37.2021.02.05.03.31.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 03:31:07 -0800 (PST) From: luca.boccassi@gmail.com To: Yicai Lu Cc: Konstantin Ananyev , dpdk stable Date: Fri, 5 Feb 2021 11:16:41 +0000 Message-Id: <20210205111920.1272063-115-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210205111920.1272063-1-luca.boccassi@gmail.com> References: <20210205111920.1272063-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'ip_frag: remove padding length of fragment' has been queued to stable release 20.11.1 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 Sender: "stable" Hi, FYI, your patch has been queued to stable release 20.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/07/21. 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://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/e78b76e24992c33236a9cfbc59c7665bb108f5ef Thanks. Luca Boccassi --- >From e78b76e24992c33236a9cfbc59c7665bb108f5ef Mon Sep 17 00:00:00 2001 From: Yicai Lu Date: Wed, 16 Dec 2020 21:36:30 +0800 Subject: [PATCH] ip_frag: remove padding length of fragment [ upstream commit 324242fb510b65644f025a996404abcd0b8199a6 ] In some situations, we would get several ip fragments, which total data length is less than min_ip_len(64) and padding with zeros. We simulated intermediate fragments by modifying the MTU. To illustrate the problem, we simplify the packet format and ignore the impact of the packet header.In namespace2, a packet whose data length is 1520 is sent. When the packet passes tap2, the packet is divided into two fragments: fragment A and B, similar to (1520 = 1510 + 10). When the packet passes tap3, the larger fragment packet A is divided into two fragments A1 and A2, similar to (1510 = 1500 + 10). Finally, the bond interface receives three fragments: A1, A2, and B (1520 = 1500 + 10 + 10). One fragmented packet A2 is smaller than the minimum Ethernet frame length, so it needs to be padded. |---------------------------------------------------| | HOST | | |--------------| |----------------------------| | | | ns2 | | |--------------| | | | | |--------| | | |--------| |--------| | | | | | tap1 | | | | tap2 | ns1| tap3 | | | | | |mtu=1510| | | |mtu=1510| |mtu=1500| | | | |--|1.1.1.1 |--| |--|1.1.1.2 |----|2.1.1.1 |--| | | |--------| |--------| |--------| | | | | | | | |-----------------| | | | | | | |--------| | | | bond | | |--------------------------------------|mtu=1500|---| |--------| When processing the preceding packets above, DPDK would aggregate fragmented packets A2 and B. And error packets are generated, which padding(zero) is displayed in the middle of the packet. A2 + B: 0000 fa 16 3e 9f fb 82 fa 47 b2 57 dc 20 08 00 45 00 0010 00 33 b4 66 00 ba 3f 01 c1 a5 01 01 01 01 02 01 0020 01 02 c0 c1 c2 c3 c4 c5 c6 c7 00 00 00 00 00 00 0030 00 00 00 00 00 00 00 00 00 00 00 00 c8 c9 ca cb 0040 cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db 0050 dc dd de df e0 e1 e2 e3 e4 e5 e6 So, we would calculate the length of padding, and remove the padding in pkt_len and data_len before aggregation. And also we have the fix for both ipv4 and ipv6. Fixes: 7f0983ee331c ("ip_frag: check fragment length of incoming packet") Signed-off-by: Yicai Lu Acked-by: Konstantin Ananyev --- lib/librte_ip_frag/rte_ipv4_reassembly.c | 11 ++++++++--- lib/librte_ip_frag/rte_ipv6_reassembly.c | 9 +++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/librte_ip_frag/rte_ipv4_reassembly.c b/lib/librte_ip_frag/rte_ipv4_reassembly.c index 1dda8aca02..69666c8b82 100644 --- a/lib/librte_ip_frag/rte_ipv4_reassembly.c +++ b/lib/librte_ip_frag/rte_ipv4_reassembly.c @@ -104,6 +104,7 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, const unaligned_uint64_t *psd; uint16_t flag_offset, ip_ofs, ip_flag; int32_t ip_len; + int32_t trim; flag_offset = rte_be_to_cpu_16(ip_hdr->fragment_offset); ip_ofs = (uint16_t)(flag_offset & RTE_IPV4_HDR_OFFSET_MASK); @@ -117,14 +118,15 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, ip_ofs *= RTE_IPV4_HDR_OFFSET_UNITS; ip_len = rte_be_to_cpu_16(ip_hdr->total_length) - mb->l3_len; + trim = mb->pkt_len - (ip_len + mb->l3_len + mb->l2_len); IP_FRAG_LOG(DEBUG, "%s:%d:\n" - "mbuf: %p, tms: %" PRIu64 - ", key: <%" PRIx64 ", %#x>, ofs: %u, len: %d, flags: %#x\n" + "mbuf: %p, tms: %" PRIu64 ", key: <%" PRIx64 ", %#x>" + "ofs: %u, len: %d, padding: %d, flags: %#x\n" "tbl: %p, max_cycles: %" PRIu64 ", entry_mask: %#x, " "max_entries: %u, use_entries: %u\n\n", __func__, __LINE__, - mb, tms, key.src_dst[0], key.id, ip_ofs, ip_len, ip_flag, + mb, tms, key.src_dst[0], key.id, ip_ofs, ip_len, trim, ip_flag, tbl, tbl->max_cycles, tbl->entry_mask, tbl->max_entries, tbl->use_entries); @@ -134,6 +136,9 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, return NULL; } + if (unlikely(trim > 0)) + rte_pktmbuf_trim(mb, trim); + /* try to find/add entry into the fragment's table. */ if ((fp = ip_frag_find(tbl, dr, &key, tms)) == NULL) { IP_FRAG_MBUF2DR(dr, mb); diff --git a/lib/librte_ip_frag/rte_ipv6_reassembly.c b/lib/librte_ip_frag/rte_ipv6_reassembly.c index ad01055184..6bc0bf792a 100644 --- a/lib/librte_ip_frag/rte_ipv6_reassembly.c +++ b/lib/librte_ip_frag/rte_ipv6_reassembly.c @@ -142,6 +142,7 @@ rte_ipv6_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, struct ip_frag_key key; uint16_t ip_ofs; int32_t ip_len; + int32_t trim; rte_memcpy(&key.src_dst[0], ip_hdr->src_addr, 16); rte_memcpy(&key.src_dst[2], ip_hdr->dst_addr, 16); @@ -158,16 +159,17 @@ rte_ipv6_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, * this is what we remove from the payload len. */ ip_len = rte_be_to_cpu_16(ip_hdr->payload_len) - sizeof(*frag_hdr); + trim = mb->pkt_len - (ip_len + mb->l3_len + mb->l2_len); IP_FRAG_LOG(DEBUG, "%s:%d:\n" "mbuf: %p, tms: %" PRIu64 ", key: <" IPv6_KEY_BYTES_FMT ", %#x>, " - "ofs: %u, len: %d, flags: %#x\n" + "ofs: %u, len: %d, padding: %d, flags: %#x\n" "tbl: %p, max_cycles: %" PRIu64 ", entry_mask: %#x, " "max_entries: %u, use_entries: %u\n\n", __func__, __LINE__, mb, tms, IPv6_KEY_BYTES(key.src_dst), key.id, ip_ofs, ip_len, - RTE_IPV6_GET_MF(frag_hdr->frag_data), + trim, RTE_IPV6_GET_MF(frag_hdr->frag_data), tbl, tbl->max_cycles, tbl->entry_mask, tbl->max_entries, tbl->use_entries); @@ -177,6 +179,9 @@ rte_ipv6_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, return NULL; } + if (unlikely(trim > 0)) + rte_pktmbuf_trim(mb, trim); + /* try to find/add entry into the fragment's table. */ fp = ip_frag_find(tbl, dr, &key, tms); if (fp == NULL) { -- 2.29.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-02-05 11:18:34.376287249 +0000 +++ 0115-ip_frag-remove-padding-length-of-fragment.patch 2021-02-05 11:18:28.986694539 +0000 @@ -1 +1 @@ -From 324242fb510b65644f025a996404abcd0b8199a6 Mon Sep 17 00:00:00 2001 +From e78b76e24992c33236a9cfbc59c7665bb108f5ef Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 324242fb510b65644f025a996404abcd0b8199a6 ] + @@ -56 +57,0 @@ -Cc: stable@dpdk.org