patch 'net/vhost: fix SW checksum when zero' has been queued to stable release 24.11.9
luca.boccassi at gmail.com
luca.boccassi at gmail.com
Thu Nov 5 17:41:39 CET 2026
Hi,
FYI, your patch has been queued to stable release 24.11.9
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/07/26. 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/58033ebec96c4d919f77fcc1d3a80f654178952b
Thanks.
Luca Boccassi
---
>From 58033ebec96c4d919f77fcc1d3a80f654178952b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Morten=20Br=C3=B8rup?= <mb at smartsharesystems.com>
Date: Sun, 18 Oct 2026 09:20:37 +0000
Subject: [PATCH] net/vhost: fix SW checksum when zero
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[ upstream commit f02eefb4185d73a1c0715195fd74ad2cb1a8c2e8 ]
There is a special rule for UDP, where a checksum of zero is as 0xffff
instead of zero.
Identifying packet types requires masking with the mask, not the value,
before comparing to the value.
Identifying by masking with the L4 UDP packet type value (0x00000200)
instead of the L4 packet type mask caused other L4 packet types to match;
specifically IP fragments, IGMP packets, and certain non-fragments.
This meant that some non-UDP packets followed the special UDP checksum
rule, which they should not.
Updated to mask the packet type with the L4 packet type mask and then
compare to the L4 UDP packet type value, so only UDP packets follow the
special UDP checksum rule.
Furthermore, according to the mbuf documentation, Tx checksum offload
requires that "ol_flags" is set, and only mentions "packet_type" for Rx,
so use "ol_flags" instead of "packet_type" for checking the packet type
at Tx.
Furthermore, writing the checksum needs room for 2 bytes, not 1 byte.
Note:
Using "if (unlikely(cksum == 0) && PTYPE_MATCH)" to advise the optimizer
about the need to evaluate PTYPE_MATCH being unlikely.
The probability of cksum being zero is only 1/65536, so it's better to
branch early.
Fixes: 8ba1723783b2 ("net/vhost: perform SW checksum in Tx path")
Fixes: 8f1750f42e2d ("net/vhost: perform SW checksum in Rx path")
Signed-off-by: Morten Brørup <mb at smartsharesystems.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>
---
drivers/net/vhost/rte_eth_vhost.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index 6dc98fdbdd8..abfe2975958 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -345,10 +345,11 @@ vhost_dev_tx_sw_csum(struct rte_mbuf *mbuf)
csum = ~csum;
/* See RFC768 */
- if (unlikely((mbuf->packet_type & RTE_PTYPE_L4_UDP) && csum == 0))
+ if (unlikely(csum == 0) &&
+ (mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_UDP_CKSUM)
csum = 0xffff;
- if (rte_pktmbuf_data_len(mbuf) >= csum_offset + 1)
+ if (rte_pktmbuf_data_len(mbuf) >= csum_offset + sizeof(uint16_t))
*rte_pktmbuf_mtod_offset(mbuf, uint16_t *, csum_offset) = csum;
mbuf->ol_flags &= ~RTE_MBUF_F_TX_L4_MASK;
@@ -388,10 +389,10 @@ vhost_dev_rx_sw_csum(struct rte_mbuf *mbuf)
csum = ~csum;
/* See RFC768 */
- if (unlikely((ptype & RTE_PTYPE_L4_UDP) && csum == 0))
+ if (unlikely(csum == 0) && (ptype & RTE_PTYPE_L4_MASK) == RTE_PTYPE_L4_UDP)
csum = 0xffff;
- if (rte_pktmbuf_data_len(mbuf) >= csum_offset + 1)
+ if (rte_pktmbuf_data_len(mbuf) >= csum_offset + sizeof(uint16_t))
*rte_pktmbuf_mtod_offset(mbuf, uint16_t *, csum_offset) = csum;
mbuf->ol_flags &= ~RTE_MBUF_F_RX_L4_CKSUM_MASK;
--
2.47.3
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2026-11-05 16:42:45.504227421 +0000
+++ 0012-net-vhost-fix-SW-checksum-when-zero.patch 2026-11-05 16:42:44.897060069 +0000
@@ -1 +1 @@
-From f02eefb4185d73a1c0715195fd74ad2cb1a8c2e8 Mon Sep 17 00:00:00 2001
+From 58033ebec96c4d919f77fcc1d3a80f654178952b Mon Sep 17 00:00:00 2001
@@ -8,0 +9,2 @@
+[ upstream commit f02eefb4185d73a1c0715195fd74ad2cb1a8c2e8 ]
+
@@ -39 +40,0 @@
-Cc: stable at dpdk.org
@@ -48 +49 @@
-index a468a92fe2..41b77d8533 100644
+index 6dc98fdbdd8..abfe2975958 100644
@@ -51 +52 @@
-@@ -346,10 +346,11 @@ vhost_dev_tx_sw_csum(struct rte_mbuf *mbuf)
+@@ -345,10 +345,11 @@ vhost_dev_tx_sw_csum(struct rte_mbuf *mbuf)
@@ -65 +66 @@
-@@ -389,10 +390,10 @@ vhost_dev_rx_sw_csum(struct rte_mbuf *mbuf)
+@@ -388,10 +389,10 @@ vhost_dev_rx_sw_csum(struct rte_mbuf *mbuf)
More information about the stable
mailing list