patch 'net/virtio: deduce IP length for TSO checksum' has been queued to stable release 22.11.2

Xueming Li xuemingl at nvidia.com
Sun Apr 9 17:23:26 CEST 2023


Hi,

FYI, your patch has been queued to stable release 22.11.2

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 04/11/23. 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=22.11-staging

This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/log/?h=22.11-staging/commit/33f3ef50211ece8b98055cf1ac61a3bcd21a26a5

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From 33f3ef50211ece8b98055cf1ac61a3bcd21a26a5 Mon Sep 17 00:00:00 2001
From: Boleslav Stankevich <boleslav.stankevich at oktetlabs.ru>
Date: Fri, 3 Mar 2023 14:19:29 +0300
Subject: [PATCH] net/virtio: deduce IP length for TSO checksum
Cc: Xueming Li <xuemingl at nvidia.com>

[ upstream commit d069c80a5d8c0a05033932421851cdb7159de0df ]

The length of TSO payload could not fit into 16 bits provided by the
IPv4 total length and IPv6 payload length fields. Thus, deduce it
from the length of the packet.

Fixes: 696573046e9e ("net/virtio: support TSO")

Signed-off-by: Boleslav Stankevich <boleslav.stankevich at oktetlabs.ru>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko at oktetlabs.ru>
Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>
---
 .mailmap                         |  1 +
 drivers/net/virtio/virtio_rxtx.c | 25 ++++++++++++++++---------
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/.mailmap b/.mailmap
index 42a169ca18..8b0904d938 100644
--- a/.mailmap
+++ b/.mailmap
@@ -167,6 +167,7 @@ Bin Huang <brian.huangbin at huawei.com> <bin.huang at hxt-semitech.com>
 Bin Zheng <zhengbin.89740 at bytedance.com>
 Björn Töpel <bjorn.topel at intel.com>
 Bo Chen <box.c.chen at intel.com>
+Boleslav Stankevich <boleslav.stankevich at oktetlabs.ru>
 Boon Ang <bang at vmware.com>
 Boris Pismenny <borisp at mellanox.com>
 Brandon Lo <blo at iol.unh.edu>
diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index d9d40832e0..c3e686cf0c 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -404,29 +404,36 @@ virtio_tso_fix_cksum(struct rte_mbuf *m)
 	if (likely(rte_pktmbuf_data_len(m) >= m->l2_len + m->l3_len +
 			m->l4_len)) {
 		struct rte_ipv4_hdr *iph;
-		struct rte_ipv6_hdr *ip6h;
 		struct rte_tcp_hdr *th;
-		uint16_t prev_cksum, new_cksum, ip_len, ip_paylen;
+		uint16_t prev_cksum, new_cksum;
+		uint32_t ip_paylen;
 		uint32_t tmp;
 
 		iph = rte_pktmbuf_mtod_offset(m,
 					struct rte_ipv4_hdr *, m->l2_len);
 		th = RTE_PTR_ADD(iph, m->l3_len);
+
+		/*
+		 * Calculate IPv4 header checksum with current total length value
+		 * (whatever it is) to have correct checksum after update on edits
+		 * done by TSO.
+		 */
 		if ((iph->version_ihl >> 4) == 4) {
 			iph->hdr_checksum = 0;
 			iph->hdr_checksum = rte_ipv4_cksum(iph);
-			ip_len = iph->total_length;
-			ip_paylen = rte_cpu_to_be_16(rte_be_to_cpu_16(ip_len) -
-				m->l3_len);
-		} else {
-			ip6h = (struct rte_ipv6_hdr *)iph;
-			ip_paylen = ip6h->payload_len;
 		}
 
+		/*
+		 * Do not use IPv4 total length and IPv6 payload length fields to get
+		 * TSO payload length since it could not fit into 16 bits.
+		 */
+		ip_paylen = rte_cpu_to_be_32(rte_pktmbuf_pkt_len(m) - m->l2_len -
+					m->l3_len);
+
 		/* calculate the new phdr checksum not including ip_paylen */
 		prev_cksum = th->cksum;
 		tmp = prev_cksum;
-		tmp += ip_paylen;
+		tmp += (ip_paylen & 0xffff) + (ip_paylen >> 16);
 		tmp = (tmp & 0xffff) + (tmp >> 16);
 		new_cksum = tmp;
 
-- 
2.25.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2023-04-09 21:45:39.295518200 +0800
+++ 0018-net-virtio-deduce-IP-length-for-TSO-checksum.patch	2023-04-09 21:45:38.599042200 +0800
@@ -1 +1 @@
-From d069c80a5d8c0a05033932421851cdb7159de0df Mon Sep 17 00:00:00 2001
+From 33f3ef50211ece8b98055cf1ac61a3bcd21a26a5 Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit d069c80a5d8c0a05033932421851cdb7159de0df ]
@@ -11 +13,0 @@
-Cc: stable at dpdk.org
@@ -22 +24 @@
-index a9f4f28fba..8e7d78f37e 100644
+index 42a169ca18..8b0904d938 100644
@@ -34 +36 @@
-index 2d0afd3302..e48ff3cca7 100644
+index d9d40832e0..c3e686cf0c 100644


More information about the stable mailing list