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 30473606A32C for ; Thu, 3 Dec 2026 01:30:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20260707.gappssmtp.com header.i=@networkplumber-org.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=V19mzMoP Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 43582402A7; Thu, 3 Dec 2026 02:30:19 +0100 (CET) Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by mails.dpdk.org (Postfix) with ESMTPS id 141AF4028B for ; Thu, 3 Dec 2026 02:30:17 +0100 (CET) Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2f06ff94acfso68229165ad.0 for ; Wed, 02 Dec 2026 17:30:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20260707.gappssmtp.com; s=20260707; t=1796261415; x=1796866215; darn=dpdk.org; h=content-type:mime-version:references:in-reply-to:message-id:subject :cc:to:from:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=QY3J8X6tOuuaNEbY6bMuWPw3TIhsXGo4vTkUmscz0Ew=; b=V19mzMoPY/0CeqQdKqkj44mMh6oMPa+C93CYuH0A6AIGqkuKA779Eh1taGnFqW+38V T1FmaUxN4ytgWwOxqQZ9ntSt+7BCHPWgAmEVu3I5Ev1YAlnkkvGUj5YVzyHgVzB86ZE4 vjyQQCQ9kI7bTAGWc16rpP630EonuJK26ZTwBFOmnxa36EVKSJHcdGN74TDDI3dxM7+Q dtz9U9cZd8u8xfa0oKsZSNGy2SRkoxMDPj73Ek4chpF/0zWt1PQ946Bwk4PX8S2KdBkb go6xKigylkzqUKJNJwn58fEN+Rb2LdyudMnKMdrqif5A6Cjs9IDi/ij1pVXkEh/potP9 gC2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796261415; x=1796866215; h=content-type:mime-version:references:in-reply-to:message-id:subject :cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=QY3J8X6tOuuaNEbY6bMuWPw3TIhsXGo4vTkUmscz0Ew=; b=GqtjZwpo3piRx5nsjsSzFg5YIm2NS/gnzlEJQ1g7SSxjaQtBV0UltlmDTyTOR12GrG llRPQRGaXduQ9FuGYOPg9+9X+XoTQunB+wTDrXwHGmexodFdQ5mDpxKmprGK6GHi8A7g 1XRolCktmRvpqDFk3TPV2eK/DtPkemwPoX7wFBIXD9WfpX228qX7MjL4/plCeAXR9m1o ovzCyWCsgaLcx0LPp6IRnKNyI0FtG3wpKASPLmOnLs4pcRMTDFGCjkyXpd1iaZg7Fvch 4iowVs8nbOX8kFmlaO6lLGydDFmGvsbw/Jk4Ktzi+/GAEbVP95aeyz+E/QiMcq7OLqSj nS8g== X-Forwarded-Encrypted: i=1; AL+hErGhhRgF5zdsRSYSmuovU/BFlOUs0I505DWtCNTvlSbTuQP/aR61Yy9S6QfdJZhScPGgpns=@dpdk.org X-Gm-Message-State: APuU4Z/hHVRJWV5i8bnogonskKNfgywB/Okf52BsUyNRArXjcdpktyN3 Yk4JeaOcSFy/2MSeuPj8qpz0BQQNfDIYroKCXLeycEX2OEA6aepjbMYzLevsZcyNcqE= X-Gm-Gg: AZFdTZfdmzQO7bKsETGbVssi8gi94e6eIvlTqzXCFFzuYk/WY/AO/ToIvX3J21LMOX2 I57Fn7O+snOJ+ha4c+whFDoFMwdE2cF09jY739nLqdaf5MD+VBgWBiK+FYFMjyf6lccvWk+6yKB 6OVpGarhfA49gs9Mi/eskcjrwpLEnuui89sF9D6Tsd8kvzYyPWHKLmyeSv0cWM1jyA//4LqKbgM 98zs+GNQum49y5tuiEVRxeFoEEQzdsPzKekOig8t2lgenVHwKRN+lvH4z6+IlqZm0oTy/2Gw/rE efn/NqFk0ZyH4atY+5w14k8bCuLvsoF4WWWeXdG01RwDK30pjPs8bYnf9l9LrsBF1uaRfCYF4cn t4A3NkIb+9igrILTaPqSPs2tfRR5YKTa4yubZgce57ywYKGdmvwNzMVQBDQ/ySya3ieh63+PIvh JK54DTdDqL5PVRY8zbLXAMmtADl2A/ttBNwOG0hgwjdgNz+8dKWul19GDm+J42bT8qoYLROFAWs ROCI1OkQq112BOK8hsF5LnJlasBWS4lDgQ0WMGP5usDu+C4GyVaMiBI7zuDwr+nEnByG33VoTzX HRhCu5c6qef/O3A584zOWcWVhjTGLb5htTAX99IU4RnuM5fympWRBhwZA63FQluZPzN4XA== X-Received: by 2002:a17:90b:4b05:b0:3a0:516d:9f88 with SMTP id 98e67ed59e1d1-3b41c911c9emr39181379a91.26.1796261415322; Wed, 02 Dec 2026 17:30:15 -0800 (PST) Received: from phoenix.local (204-195-112-43.wavecable.com. [204.195.112.43]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5c764a033sm1680626a91.1.2026.12.02.17.30.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 17:30:15 -0800 (PST) Date: Wed, 2 Dec 2026 17:30:12 -0800 From: Stephen Hemminger To: Morten =?UTF-8?B?QnLDuHJ1cA==?= Cc: "Maxime Coquelin" , "Chenbo Xia" , , "Robin Jarry" , "David Marchand" Subject: Re: [RFC] virtio: VirtualBox GSO workaround Message-ID: <20261202173012.55d5cac0@phoenix.local> In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35F65B61@smartserver.smartshare.dk> References: <98CBD80474FA8B44BF855DF32C47DC35F65B61@smartserver.smartshare.dk> X-Archived-By: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/KFii/1BB.nUndJ/6LJNlmDb" 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,DKIM_SIGNED, DKIM_VALID,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 --MP_/KFii/1BB.nUndJ/6LJNlmDb Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Wed, 2 Dec 2026 21:10:42 +0100 Morten Br=C3=B8rup wrote: > VirtIO PMD maintainers, >=20 > VirtualBox has a well known issue: > When a packet is received in a VirtualBox host by a physical interface us= ing GSO, VirtualBox bridges that packet as-is (i.e. with VIRTIO_NET_HDR_F_N= EEDS_CSUM and invalid TCP checksum field value) into the guest, even when t= he guest's virtio port is configured without any RX offload. > When the application has configured the port without RX offload, the appl= ication doesn't consider RTE_MBUF_F_RX_L4_CKSUM_NONE (because it expects th= e 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 applicat= ion 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 c= hecksum validation or when reaching its ultimate destination.) > The virtio driver doesn't do any RX offload if RX offload is disabled. >=20 > As a workaround, I propose that the virtio driver calculates the TCP chec= ksum and sets the TCP checksum field for GSO packets when RX offload is dis= abled. The host should have done that, but VirtualBox doesn't. > What do you think about such a workaround? >=20 > Note: The workaround has only been applied to virtio_recv_mergeable_pkts(= ), which is used for VirtualBox virtio. >=20 > Diff for DPDK 25.11.2 below. Work in progress, code not yet tested. >=20 > Venlig hilsen / Kind regards, > -Morten Br=C3=B8rup AI review with Fable says this is wrong and incomplete: On the RFC itself, I would NAK it as posted: * Checksum is only half the problem. With LRO off, the app still gets a 64= K GSO packet it never asked for. A forwarder will then exceed the egress MT= U. A real driver workaround has to segment (rte_gso), not just checksum. * seg_num > 1 is the wrong test. A small GSO packet fits in one mbuf, and = a jumbo frame is multi-seg without GSO. Test hdr->flags and hdr->gso_type i= nstead. * It sets RTE_MBUF_F_RX_LRO with LRO not configured, which breaks the ethd= ev contract. * The else if condition is backwards. With has_rx_offload =3D=3D 0 it skip= s the software checksum in exactly the unknown-proto/tunnel case the origin= al else existed for. * Only one of five RX paths is covered. It proposes the two attached instead: --MP_/KFii/1BB.nUndJ/6LJNlmDb Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-net-virtio-fix-drop-of-multi-buffer-packet-on-offloa.patch >From 7f7fbf9188700d01f1d00c049b48afa74e2ce36c Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 2 Dec 2026 17:25:38 -0800 Subject: [PATCH 1/2] net/virtio: fix drop of multi-buffer packet on offload error When virtio_rx_offload() fails in the mergeable and in-order receive paths, only the first buffer of the packet is discarded. The remaining num_buffers - 1 buffers are still in the used ring and get parsed as new packets, with packet payload interpreted as virtio_net_hdr. This happens for any GSO packet the driver rejects: ECN bit set, gso_size of zero, or a gso_type other than TCPv4/TCPv6 (for example UFO from a device that sends it without GUEST_UFO being negotiated). Collect all the buffers of the packet first, then free the chain and count one error. Cc: stable@dpdk.org Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01F2mfDETH9cBBVF3tcqkwcH --- drivers/net/virtio/virtio_rxtx.c | 87 +++++++++++++++++--------------- 1 file changed, 45 insertions(+), 42 deletions(-) diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index 1afb68b..7cdab4b 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -987,6 +987,24 @@ virtio_rx_offload(struct rte_mbuf *m, struct virtio_net_hdr *hdr) return 0; } +/* + * A mergeable packet is complete: pass it up or drop it. + * The drop has to wait until here, the remaining buffers of the + * packet must be consumed first or they get parsed as new packets. + */ +static inline uint16_t +virtio_rx_mergeable_done(struct virtnet_rx *rxvq, struct rte_mbuf *m, bool drop) +{ + if (unlikely(drop)) { + rte_pktmbuf_free(m); + rxvq->stats.errors++; + return 0; + } + + virtio_rx_stats_updated(rxvq, m); + return 1; +} + #define DESC_PER_CACHELINE (RTE_CACHE_LINE_SIZE / sizeof(struct vring_desc)) uint16_t virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) @@ -1207,6 +1225,7 @@ virtio_recv_pkts_inorder(void *rx_queue, struct virtio_hw *hw = vq->hw; struct rte_mbuf *rxm; struct rte_mbuf *prev = NULL; + bool drop = false; uint16_t nb_used, num, nb_rx; uint32_t len[VIRTIO_MBUF_BURST_SZ]; struct rte_mbuf *rcv_pkts[VIRTIO_MBUF_BURST_SZ]; @@ -1274,12 +1293,8 @@ virtio_recv_pkts_inorder(void *rx_queue, rx_pkts[nb_rx] = rxm; prev = rxm; - if (vq->hw->has_rx_offload && - virtio_rx_offload(rxm, &header->hdr) < 0) { - virtio_discard_rxbuf_inorder(vq, rxm); - rxvq->stats.errors++; - continue; - } + drop = hw->has_rx_offload && + virtio_rx_offload(rxm, &header->hdr) < 0; if (hw->vlan_strip) rte_vlan_strip(rx_pkts[nb_rx]); @@ -1302,10 +1317,9 @@ virtio_recv_pkts_inorder(void *rx_queue, seg_res -= 1; } - if (!seg_res) { - virtio_rx_stats_updated(rxvq, rx_pkts[nb_rx]); - nb_rx++; - } + if (!seg_res) + nb_rx += virtio_rx_mergeable_done(rxvq, + rx_pkts[nb_rx], drop); } /* Last packet still need merge segments */ @@ -1332,10 +1346,9 @@ virtio_recv_pkts_inorder(void *rx_queue, }; seg_res -= rcv_cnt; - if (!seg_res) { - virtio_rx_stats_updated(rxvq, rx_pkts[nb_rx]); - nb_rx++; - } + if (!seg_res) + nb_rx += virtio_rx_mergeable_done(rxvq, + rx_pkts[nb_rx], drop); } else { PMD_RX_LOG(ERR, "No enough segments for packet."); @@ -1390,6 +1403,7 @@ virtio_recv_mergeable_pkts(void *rx_queue, struct virtio_hw *hw = vq->hw; struct rte_mbuf *rxm; struct rte_mbuf *prev = NULL; + bool drop = false; uint16_t nb_used, num, nb_rx = 0; uint32_t len[VIRTIO_MBUF_BURST_SZ]; struct rte_mbuf *rcv_pkts[VIRTIO_MBUF_BURST_SZ]; @@ -1452,12 +1466,8 @@ virtio_recv_mergeable_pkts(void *rx_queue, rx_pkts[nb_rx] = rxm; prev = rxm; - if (hw->has_rx_offload && - virtio_rx_offload(rxm, &header->hdr) < 0) { - virtio_discard_rxbuf(vq, rxm); - rxvq->stats.errors++; - continue; - } + drop = hw->has_rx_offload && + virtio_rx_offload(rxm, &header->hdr) < 0; if (hw->vlan_strip) rte_vlan_strip(rx_pkts[nb_rx]); @@ -1480,10 +1490,9 @@ virtio_recv_mergeable_pkts(void *rx_queue, seg_res -= 1; } - if (!seg_res) { - virtio_rx_stats_updated(rxvq, rx_pkts[nb_rx]); - nb_rx++; - } + if (!seg_res) + nb_rx += virtio_rx_mergeable_done(rxvq, + rx_pkts[nb_rx], drop); } /* Last packet still need merge segments */ @@ -1510,10 +1519,9 @@ virtio_recv_mergeable_pkts(void *rx_queue, }; seg_res -= rcv_cnt; - if (!seg_res) { - virtio_rx_stats_updated(rxvq, rx_pkts[nb_rx]); - nb_rx++; - } + if (!seg_res) + nb_rx += virtio_rx_mergeable_done(rxvq, + rx_pkts[nb_rx], drop); } else { PMD_RX_LOG(ERR, "No enough segments for packet."); @@ -1567,6 +1575,7 @@ virtio_recv_mergeable_pkts_packed(void *rx_queue, struct virtio_hw *hw = vq->hw; struct rte_mbuf *rxm; struct rte_mbuf *prev = NULL; + bool drop = false; uint16_t num, nb_rx = 0; uint32_t len[VIRTIO_MBUF_BURST_SZ]; struct rte_mbuf *rcv_pkts[VIRTIO_MBUF_BURST_SZ]; @@ -1623,12 +1632,8 @@ virtio_recv_mergeable_pkts_packed(void *rx_queue, rx_pkts[nb_rx] = rxm; prev = rxm; - if (hw->has_rx_offload && - virtio_rx_offload(rxm, &header->hdr) < 0) { - virtio_discard_rxbuf(vq, rxm); - rxvq->stats.errors++; - continue; - } + drop = hw->has_rx_offload && + virtio_rx_offload(rxm, &header->hdr) < 0; if (hw->vlan_strip) rte_vlan_strip(rx_pkts[nb_rx]); @@ -1655,10 +1660,9 @@ virtio_recv_mergeable_pkts_packed(void *rx_queue, seg_res -= 1; } - if (!seg_res) { - virtio_rx_stats_updated(rxvq, rx_pkts[nb_rx]); - nb_rx++; - } + if (!seg_res) + nb_rx += virtio_rx_mergeable_done(rxvq, + rx_pkts[nb_rx], drop); } /* Last packet still need merge segments */ @@ -1689,10 +1693,9 @@ virtio_recv_mergeable_pkts_packed(void *rx_queue, extra_idx += 1; } seg_res -= rcv_cnt; - if (!seg_res) { - virtio_rx_stats_updated(rxvq, rx_pkts[nb_rx]); - nb_rx++; - } + if (!seg_res) + nb_rx += virtio_rx_mergeable_done(rxvq, + rx_pkts[nb_rx], drop); } rxvq->stats.packets += nb_rx; -- 2.43.0 --MP_/KFii/1BB.nUndJ/6LJNlmDb Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0002-net-virtio-drop-offload-packets-sent-without-negotia.patch >From c4c0f0a489045622360fffab0fdb06067209c01f Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 2 Dec 2026 17:27:31 -0800 Subject: [PATCH 2/2] net/virtio: drop offload packets sent without negotiation If GUEST_CSUM and GUEST_TSO4/6 are not negotiated, the device must not set VIRTIO_NET_HDR_F_NEEDS_CSUM or a gso_type in the receive header. VirtualBox does it anyway when the host interface uses GRO. The driver ignores the header when no receive offload is enabled, so the application gets a packet with a partial checksum and larger than the MTU, with nothing in the mbuf to say so. It then fails checksum validation, or gets forwarded and dropped further down the path. Check the header in the non-vector receive paths. If the device violates the negotiation, drop the packet, count it in the error statistics and log the reason once. A compliant device never triggers this, so no hypervisor detection is needed. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01F2mfDETH9cBBVF3tcqkwcH --- drivers/net/virtio/virtio_rxtx.c | 53 +++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index 7cdab4b..4ce9162 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -987,6 +987,46 @@ virtio_rx_offload(struct rte_mbuf *m, struct virtio_net_hdr *hdr) return 0; } +/* Report once that the device ignores feature negotiation */ +static __rte_cold __rte_noinline void +virtio_rx_hdr_unexpected(const struct virtio_hw *hw, + const struct virtio_net_hdr *hdr) +{ + static bool warned; + + if (warned) + return; + warned = true; + + PMD_DRV_LOG(ERR, + "port %u: device sent flags %#x gso_type %#x without GUEST_CSUM/GUEST_TSO negotiated, dropping such packets", + hw->port_id, hdr->flags, hdr->gso_type); +} + +/* + * Process the receive header. + * + * If no receive offload feature was negotiated, the device is required + * to set neither NEEDS_CSUM nor a gso_type. Some devices do it anyway. + * The application did not ask for packets with a partial checksum or + * larger than MTU, so do not pass them up. + */ +static inline int +virtio_rx_hdr(const struct virtio_hw *hw, struct rte_mbuf *m, + struct virtio_net_hdr *hdr) +{ + if (hw->has_rx_offload) + return virtio_rx_offload(m, hdr); + + if (unlikely((hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) || + hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE)) { + virtio_rx_hdr_unexpected(hw, hdr); + return -EINVAL; + } + + return 0; +} + /* * A mergeable packet is complete: pass it up or drop it. * The drop has to wait until here, the remaining buffers of the @@ -1066,7 +1106,7 @@ virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) if (hw->vlan_strip) rte_vlan_strip(rxm); - if (hw->has_rx_offload && virtio_rx_offload(rxm, hdr) < 0) { + if (virtio_rx_hdr(hw, rxm, hdr) < 0) { virtio_discard_rxbuf(vq, rxm); rxvq->stats.errors++; continue; @@ -1171,7 +1211,7 @@ virtio_recv_pkts_packed(void *rx_queue, struct rte_mbuf **rx_pkts, if (hw->vlan_strip) rte_vlan_strip(rxm); - if (hw->has_rx_offload && virtio_rx_offload(rxm, hdr) < 0) { + if (virtio_rx_hdr(hw, rxm, hdr) < 0) { virtio_discard_rxbuf(vq, rxm); rxvq->stats.errors++; continue; @@ -1293,8 +1333,7 @@ virtio_recv_pkts_inorder(void *rx_queue, rx_pkts[nb_rx] = rxm; prev = rxm; - drop = hw->has_rx_offload && - virtio_rx_offload(rxm, &header->hdr) < 0; + drop = virtio_rx_hdr(hw, rxm, &header->hdr) < 0; if (hw->vlan_strip) rte_vlan_strip(rx_pkts[nb_rx]); @@ -1466,8 +1505,7 @@ virtio_recv_mergeable_pkts(void *rx_queue, rx_pkts[nb_rx] = rxm; prev = rxm; - drop = hw->has_rx_offload && - virtio_rx_offload(rxm, &header->hdr) < 0; + drop = virtio_rx_hdr(hw, rxm, &header->hdr) < 0; if (hw->vlan_strip) rte_vlan_strip(rx_pkts[nb_rx]); @@ -1632,8 +1670,7 @@ virtio_recv_mergeable_pkts_packed(void *rx_queue, rx_pkts[nb_rx] = rxm; prev = rxm; - drop = hw->has_rx_offload && - virtio_rx_offload(rxm, &header->hdr) < 0; + drop = virtio_rx_hdr(hw, rxm, &header->hdr) < 0; if (hw->vlan_strip) rte_vlan_strip(rx_pkts[nb_rx]); -- 2.43.0 --MP_/KFii/1BB.nUndJ/6LJNlmDb--