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

luca.boccassi at gmail.com luca.boccassi at gmail.com
Wed Mar 15 23:45:59 CET 2023


Hi,

FYI, your patch has been queued to stable release 20.11.8

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

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

Thanks.

Luca Boccassi

---
>From 74a0293db637e616478d0a55de93e002c6d52641 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

[ 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>
---
 drivers/net/virtio/virtio_rxtx.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index fe6f9942a9..469da168ec 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -421,29 +421,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.39.2

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2023-03-15 22:44:50.100977161 +0000
+++ 0008-net-virtio-deduce-IP-length-for-TSO-checksum.patch	2023-03-15 22:44:49.515848835 +0000
@@ -1 +1 @@
-From d069c80a5d8c0a05033932421851cdb7159de0df Mon Sep 17 00:00:00 2001
+From 74a0293db637e616478d0a55de93e002c6d52641 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit d069c80a5d8c0a05033932421851cdb7159de0df ]
+
@@ -11 +12,0 @@
-Cc: stable at dpdk.org
@@ -17 +17,0 @@
- .mailmap                         |  1 +
@@ -19 +19 @@
- 2 files changed, 17 insertions(+), 9 deletions(-)
+ 1 file changed, 16 insertions(+), 9 deletions(-)
@@ -21,12 +20,0 @@
-diff --git a/.mailmap b/.mailmap
-index a9f4f28fba..8e7d78f37e 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>
@@ -34 +22 @@
-index 2d0afd3302..e48ff3cca7 100644
+index fe6f9942a9..469da168ec 100644
@@ -37 +25 @@
-@@ -404,29 +404,36 @@ virtio_tso_fix_cksum(struct rte_mbuf *m)
+@@ -421,29 +421,36 @@ virtio_tso_fix_cksum(struct rte_mbuf *m)


More information about the stable mailing list