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

luca.boccassi at gmail.com luca.boccassi at gmail.com
Thu Mar 7 02:31:01 CET 2024


Hi,

FYI, your patch has been queued to stable release 22.11.5

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/09/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://github.com/bluca/dpdk-stable

This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/3dab00d897a3d411f13ea6a2838259121a2501fd

Thanks.

Luca Boccassi

---
>From 3dab00d897a3d411f13ea6a2838259121a2501fd 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

[ 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 0cafb980ef..8da23660c6 100644
--- a/lib/net/rte_ip.h
+++ b/lib/net/rte_ip.h
@@ -420,11 +420,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 */
 
-	if (rte_raw_cksum_mbuf(m, l4_off, m->pkt_len - l4_off, &raw_cksum))
+	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, len, &raw_cksum))
 		return 0;
 
 	cksum = raw_cksum + rte_ipv4_phdr_cksum(ipv4_hdr, 0);
@@ -650,10 +653,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.39.2

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2024-03-07 01:05:38.713364961 +0000
+++ 0044-net-fix-TCP-UDP-checksum-with-padding-data.patch	2024-03-07 01:05:34.778939592 +0000
@@ -1 +1 @@
-From e55ea3d5d970dfff2989e4a1c65b76d02512bce0 Mon Sep 17 00:00:00 2001
+From 3dab00d897a3d411f13ea6a2838259121a2501fd Mon Sep 17 00:00:00 2001
@@ -8,0 +9,2 @@
+[ upstream commit e55ea3d5d970dfff2989e4a1c65b76d02512bce0 ]
+
@@ -21 +22,0 @@
-Cc: stable at dpdk.org
@@ -30 +31 @@
-index 6fa98a5a0f..0d103d4127 100644
+index 0cafb980ef..8da23660c6 100644
@@ -33 +34 @@
-@@ -419,11 +419,14 @@ __rte_ipv4_udptcp_cksum_mbuf(const struct rte_mbuf *m,
+@@ -420,11 +420,14 @@ __rte_ipv4_udptcp_cksum_mbuf(const struct rte_mbuf *m,
@@ -51 +52 @@
-@@ -663,10 +666,10 @@ __rte_ipv6_udptcp_cksum_mbuf(const struct rte_mbuf *m,
+@@ -650,10 +653,10 @@ __rte_ipv6_udptcp_cksum_mbuf(const struct rte_mbuf *m,


More information about the stable mailing list