]> git.feebdaed.xyz Git - 0xmirror/ovs.git/commitdiff
netdev-dpdk: Fix IP checksum with net/virtio.
authorDavid Marchand <david.marchand@redhat.com>
Wed, 10 Sep 2025 15:25:34 +0000 (17:25 +0200)
committerIlya Maximets <i.maximets@ovn.org>
Thu, 11 Sep 2025 22:20:34 +0000 (00:20 +0200)
OVS checks a netdev checksum offload capabilities before calling its
transmit helper.
Yet the OVS transmit preparation helper for DPDK drivers requests IP
checksum (setting RTE_MBUF_F_TX_IP_CSUM) regardless of the DPDK driver
support if some L4 checksum is requested.

This is problematic since net/virtio does support L4 checksum offload,
but does not support nor announce IP checksum offload and this DPDK
driver tx prepare helper (calling helper shared with other DPDK drivers)
clears the ip checksum in packet data if RTE_MBUF_F_TX_IP_CSUM is set.

The DPDK mbuf API mandates IP csum when TCP segmentation is requested.
However, IP csum is not required when TCP or other L4 checksum is
requested.

While most DPDK drivers implement both IP and L4 checksums (and this is
likely why the bug was never caught), let's avoid requesting an
unsupported offload.

Reported-at: https://issues.redhat.com/browse/FDP-1666
Link: https://git.dpdk.org/dpdk-stable/tree/drivers/net/virtio/virtio_rxtx.c?h=v24.11.2#n1742
Link: https://git.dpdk.org/dpdk-stable/tree/lib/net/rte_net.h?h=v24.11.2#n179
Fixes: 8b5fe2dc6080 ("userspace: Add Generic Segmentation Offloading.")
Signed-off-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
lib/netdev-dpdk.c

index 17b4d6677902c482789a665c82f53682d3ec3c1d..2d0449726e68eab00bd11af5a5f925cdc334f4ee 100644 (file)
@@ -2785,12 +2785,11 @@ netdev_dpdk_prep_hwol_packet(struct netdev_dpdk *dev, struct rte_mbuf *mbuf)
             return false;
         }
         mbuf->ol_flags |= RTE_MBUF_F_TX_TCP_SEG;
-    }
 
-    /* If L4 checksum is requested, IPv4 should be requested as well. */
-    if (mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK
-        && mbuf->ol_flags & RTE_MBUF_F_TX_IPV4) {
-        mbuf->ol_flags |= RTE_MBUF_F_TX_IP_CKSUM;
+        /* DPDK API mandates IPv4 checksum when requesting TSO. */
+        if (IP_VER(ip->ip_ihl_ver) == 4) {
+            mbuf->ol_flags |= RTE_MBUF_F_TX_IP_CKSUM;
+        }
     }
 
     return true;