patch 'net: fix TCP/UDP checksum with padding data' has been queued to stable release 23.11.1

Xueming Li xuemingl at nvidia.com
Tue Mar 5 10:46:35 CET 2024


Hi,

FYI, your patch has been queued to stable release 23.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 03/31/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=c139df70dd02ed9031e82d80bd51ba1882157f63

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From c139df70dd02ed9031e82d80bd51ba1882157f63 Mon Sep 17 00:00:00 2001
From: Kaiwen Deng <kaiwenx.deng at intel.com>
Date: Thu, 14 Dec 2023 17:22:59 +0800
Subject: [PATCH] net: fix TCP/UDP checksum with padding data
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: Xueming Li <xuemingl at nvidia.com>

[ upstream commit e55ea3d5d970dfff2989e4a1c65b76d02512bce0 ]

IEEE 802 packets may have a minimum size limit. The data fields
should be padded when necessary. In some cases, the padding data
is not zero.

In 'rte_ipv4_udptcp_cksum_mbuf()', as payload length
"mbuf->pkt_len - l4_off" is used, which includes padding and if
padding is not zero it will end up producing wrong checksum.

This patch will use IP header to get the payload size to calculate
TCP/UDP checksum.

Fixes: d178f693bbfe ("net: add UDP/TCP checksum in mbuf segments")

Signed-off-by: Kaiwen Deng <kaiwenx.deng at intel.com>
Reviewed-by: Morten Brørup <mb at smartsharesystems.com>
---
 lib/net/rte_ip.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/lib/net/rte_ip.h b/lib/net/rte_ip.h
index 6fa98a5a0f..0d103d4127 100644
--- a/lib/net/rte_ip.h
+++ b/lib/net/rte_ip.h
@@ -419,11 +419,14 @@ __rte_ipv4_udptcp_cksum_mbuf(const struct rte_mbuf *m,
 {
 	uint16_t raw_cksum;
 	uint32_t cksum;
+	uint16_t len;

-	if (l4_off > m->pkt_len)
-		return 0;
+	if (unlikely(l4_off > m->pkt_len))
+		return 0; /* invalid params, return a dummy value */
+
+	len = rte_be_to_cpu_16(ipv4_hdr->total_length) - (uint16_t)rte_ipv4_hdr_len(ipv4_hdr);

-	if (rte_raw_cksum_mbuf(m, l4_off, m->pkt_len - l4_off, &raw_cksum))
+	if (rte_raw_cksum_mbuf(m, l4_off, len, &raw_cksum))
 		return 0;

 	cksum = raw_cksum + rte_ipv4_phdr_cksum(ipv4_hdr, 0);
@@ -663,10 +666,10 @@ __rte_ipv6_udptcp_cksum_mbuf(const struct rte_mbuf *m,
 	uint16_t raw_cksum;
 	uint32_t cksum;

-	if (l4_off > m->pkt_len)
-		return 0;
+	if (unlikely(l4_off > m->pkt_len))
+		return 0; /* invalid params, return a dummy value */

-	if (rte_raw_cksum_mbuf(m, l4_off, m->pkt_len - l4_off, &raw_cksum))
+	if (rte_raw_cksum_mbuf(m, l4_off, rte_be_to_cpu_16(ipv6_hdr->payload_len), &raw_cksum))
 		return 0;

 	cksum = raw_cksum + rte_ipv6_phdr_cksum(ipv6_hdr, 0);
--
2.34.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2024-03-05 17:39:32.609662554 +0800
+++ 0054-net-fix-TCP-UDP-checksum-with-padding-data.patch	2024-03-05 17:39:30.763566493 +0800
@@ -1 +1 @@
-From e55ea3d5d970dfff2989e4a1c65b76d02512bce0 Mon Sep 17 00:00:00 2001
+From c139df70dd02ed9031e82d80bd51ba1882157f63 Mon Sep 17 00:00:00 2001
@@ -7,0 +8,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit e55ea3d5d970dfff2989e4a1c65b76d02512bce0 ]
@@ -21 +23,0 @@
-Cc: stable at dpdk.org


More information about the stable mailing list