From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B344E606A68D for ; Wed, 2 Dec 2026 20:10:46 +0000 (UTC) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DF336402D5; Wed, 2 Dec 2026 21:10:44 +0100 (CET) Received: from dkmailrelay1.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTPS id 63AC2402D1 for ; Wed, 2 Dec 2026 21:10:43 +0100 (CET) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesys.local [192.168.4.10]) by dkmailrelay1.smartsharesystems.com (Postfix) with ESMTP id F0A9720BE1; Wed, 2 Dec 2026 21:10:42 +0100 (CET) Content-class: urn:content-classes:message X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: [RFC] virtio: VirtualBox GSO workaround X-MimeOLE: Produced By Microsoft Exchange V6.5 Date: Wed, 2 Dec 2026 21:10:42 +0100 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35F65B61@smartserver.smartshare.dk> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [RFC] virtio: VirtualBox GSO workaround Thread-Index: Ad2CmTUphPJjokbjRNyL8W4wc9LGDg== From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Maxime Coquelin" , "Chenbo Xia" Cc: , "Robin Jarry" , "David Marchand" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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=F8rup 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 =3D hdr_lens.l2_len + hdr_lens.l3_len + = hdr_lens.l4_len; - if (hdr->csum_start <=3D hdrlen && l4_supported) { + if (has_rx_offload && hdr->csum_start <=3D hdrlen && = l4_supported) { m->ol_flags |=3D RTE_MBUF_F_RX_L4_CKSUM_NONE; - } else { + } else if (has_rx_offload || (hdr->csum_start <=3D = 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 |=3D RTE_MBUF_F_RX_LRO | - RTE_MBUF_F_RX_L4_CKSUM_NONE; + m->ol_flags |=3D 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 =3D 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] =3D rxm; prev =3D 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 =3D 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;