VirtIO PMD maintainers,

VirtualBox has a well known issue:
When a packet is received in a VirtualBox host by a physical interface using 
GSO, VirtualBox bridges that packet as-is (i.e. with 
VIRTIO_NET_HDR_F_NEEDS_CSUM and invalid TCP checksum field value) into the 
guest, even when the guest's virtio port is configured without any RX offload.
When the application has configured the port without RX offload, the 
application doesn't consider RTE_MBUF_F_RX_L4_CKSUM_NONE (because it expects 
the hardware/driver has not checked the TCP checksum), and when it checks the 
TCP checksum, it discards the packet as being invalid. (Or if the application 
forwards the packet with an incremental TCP checksum update, the packet will 
remain invalid, and will be discarded by an on-path router with TCP checksum 
validation or when reaching its ultimate destination.)
The virtio driver doesn't do any RX offload if RX offload is disabled.

As a workaround, I propose that the virtio driver calculates the TCP checksum 
and sets the TCP checksum field for GSO packets when RX offload is disabled. 
The host should have done that, but VirtualBox doesn't.
What do you think about such a workaround?

Note: The workaround has only been applied to virtio_recv_mergeable_pkts(), 
which is used for VirtualBox virtio.

Diff for DPDK 25.11.2 below. Work in progress, code not yet tested.

Venlig hilsen / Kind regards,
-Morten Brørup


diff -wup virtio_rxtx.c.orig virtio_rxtx.c
--- virtio_rxtx.c.orig  2026-12-02 17:54:35.010252966 +0000
+++ virtio_rxtx.c       2026-12-02 19:53:51.924504527 +0000
@@ -916,7 +916,7 @@ virtio_rx_update_hash_report(struct rte_

 /* Optionally fill offload information in structure */
 static inline int
-virtio_rx_offload(struct rte_mbuf *m, struct virtio_net_hdr *hdr)
+virtio_rx_offload(struct rte_mbuf *m, struct virtio_net_hdr *hdr, const 
uint8_t has_rx_offload)
 {
        struct rte_net_hdr_lens hdr_lens;
        uint32_t hdrlen, ptype;
@@ -937,9 +937,9 @@ virtio_rx_offload(struct rte_mbuf *m, st

        if (hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
                hdrlen = hdr_lens.l2_len + hdr_lens.l3_len + hdr_lens.l4_len;
-               if (hdr->csum_start <= hdrlen && l4_supported) {
+               if (has_rx_offload && hdr->csum_start <= hdrlen && 
l4_supported) {
                        m->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_NONE;
-               } else {
+               } else if (has_rx_offload || (hdr->csum_start <= hdrlen && 
l4_supported)) {
                        /* Unknown proto or tunnel, do sw cksum. We can assume
                         * the cksum field is in the first segment since the
                         * buffers we provided to the host are large enough.
@@ -976,8 +976,9 @@ virtio_rx_offload(struct rte_mbuf *m, st
                switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
                        case VIRTIO_NET_HDR_GSO_TCPV4:
                        case VIRTIO_NET_HDR_GSO_TCPV6:
-                               m->ol_flags |= RTE_MBUF_F_RX_LRO |
-                                       RTE_MBUF_F_RX_L4_CKSUM_NONE;
+                               m->ol_flags |= has_rx_offload ?
+                                       RTE_MBUF_F_RX_LRO | 
RTE_MBUF_F_RX_L4_CKSUM_NONE :
+                                       RTE_MBUF_F_RX_LRO;
                                break;
                        default:
                                return -EINVAL;
@@ -1048,7 +1049,7 @@ virtio_recv_pkts(void *rx_queue, struct
                if (hw->vlan_strip)
                        rte_vlan_strip(rxm);

-               if (hw->has_rx_offload && virtio_rx_offload(rxm, hdr) < 0) {
+               if (hw->has_rx_offload && virtio_rx_offload(rxm, hdr, 1) < 0) {
                        virtio_discard_rxbuf(vq, rxm);
                        rxvq->stats.errors++;
                        continue;
@@ -1153,7 +1154,7 @@ virtio_recv_pkts_packed(void *rx_queue,
                if (hw->vlan_strip)
                        rte_vlan_strip(rxm);

-               if (hw->has_rx_offload && virtio_rx_offload(rxm, hdr) < 0) {
+               if (hw->has_rx_offload && virtio_rx_offload(rxm, hdr, 1) < 0) {
                        virtio_discard_rxbuf(vq, rxm);
                        rxvq->stats.errors++;
                        continue;
@@ -1275,7 +1276,7 @@ virtio_recv_pkts_inorder(void *rx_queue,
                prev = rxm;

                if (vq->hw->has_rx_offload &&
-                               virtio_rx_offload(rxm, &header->hdr) < 0) {
+                               virtio_rx_offload(rxm, &header->hdr, 1) < 0) {
                        virtio_discard_rxbuf_inorder(vq, rxm);
                        rxvq->stats.errors++;
                        continue;
@@ -1452,8 +1453,9 @@ virtio_recv_mergeable_pkts(void *rx_queu
                rx_pkts[nb_rx] = rxm;
                prev = rxm;

-               if (hw->has_rx_offload &&
-                               virtio_rx_offload(rxm, &header->hdr) < 0) {
+               /* Workaround for VirtualBox unconditional GSO: Check seg_num 
too. */
+               if ((hw->has_rx_offload || seg_num > 1) &&
+                               virtio_rx_offload(rxm, &header->hdr, 
hw->has_rx_offload) < 0) {
                        virtio_discard_rxbuf(vq, rxm);
                        rxvq->stats.errors++;
                        continue;
@@ -1624,7 +1626,7 @@ virtio_recv_mergeable_pkts_packed(void *
                prev = rxm;

                if (hw->has_rx_offload &&
-                               virtio_rx_offload(rxm, &header->hdr) < 0) {
+                               virtio_rx_offload(rxm, &header->hdr, 1) < 0) {
                        virtio_discard_rxbuf(vq, rxm);
                        rxvq->stats.errors++;
                        continue;

Reply via email to