Article View: linux.kernel.netdev
Article #14205[PATCH net v6 1/3] net: virtio: fix UDP tunnel GSO header of VLAN tagged packets
From: Eric Dumazet
Date: Tue, 10 Nov 2026 21:36
Date: Tue, 10 Nov 2026 21:36
76 lines
11352 bytes
11352 bytes
virtio_net_hdr_tnl_from_skb() builds a wrong header for VLAN tagged UDP
tunnel GSO packets.
1) When the skb carries a hwaccel VLAN tag, tun_put_user() inserts the
802.1Q header in the frame it copies to user space or vhost-net, and
passes vlan_hlen = VLAN_HLEN. virtio_net_hdr_from_skb() adds
vlan_hlen to csum_start, but inner_nh_offset and outer_th_offset do
not account for it, and are 4 bytes short of the real inner L3 and
outer UDP headers in the emitted frame.
tun advertises NETIF_F_HW_VLAN_CTAG_TX and NETIF_F_HW_VLAN_STAG_TX
in hw_enc_features, and its vlan_features keep the UDP tunnel GSO
features, so this happens for example with a VLAN filtering bridge
with a tagged port, or with a vlan device on top of a tap.
2) The outer family comes from skb->protocol, which is ETH_P_8021Q or
ETH_P_8021AD when the VLAN tag is in the packet data, so a packet
with an outer IPv6 header is reported as
VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV4. This happens when
__vlan_hwaccel_push_inside() inserted the tag because the device does
not offload it: virtio_net never offloads VLAN insertion but keeps
UDP tunnel GSO in its vlan_features, and tun does the same with VLAN
TX offload disabled, or with QinQ (outer tag offloaded, inner tag in
the data).
The receiver sets inner_network_header and transport_header from these
offsets, and checks them with the wrong outer family. A forwarded
packet that gets segmented again uses the wrong inner headers, and a
receiver checking the outer headers against the virtio header drops
the packet.
Add vlan_hlen to both offsets like csum_start, and take the outer
family from vlan_get_protocol(), which skips VLAN tags in the data.
Fixes: a2fb4bc4e2a6 ("net: implement virtio helpers to handle UDP GSO tunneling.")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/netdev/179421814766.994134.3669228181251158303@kernel.org/
Closes: https://lore.kernel.org/netdev/179433950084.994134.15100186606737698605@kernel.org/
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
---
include/linux/virtio_net.h | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
index d6466f96cdd0..83f801ff5700 100644
--- a/include/linux/virtio_net.h
+++ b/include/linux/virtio_net.h
@@ -453,7 +453,10 @@ virtio_net_hdr_tnl_from_skb(const struct sk_buff *skb,
if (feature_hdrlen && hdr->hdr_len)
__virtio_net_set_tnl_hdrlen(skb, hdr);
- if (skb->protocol == htons(ETH_P_IPV6))
+ /* skb->protocol is the VLAN protocol when the tag is in the
+ * packet data.
+ */
+ if (vlan_get_protocol(skb) == htons(ETH_P_IPV6))
hdr->gso_type |= VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV6;
else
hdr->gso_type |= VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV4;
@@ -461,8 +464,11 @@ virtio_net_hdr_tnl_from_skb(const struct sk_buff *skb,
if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_TUNNEL_CSUM)
hdr->flags |= VIRTIO_NET_HDR_F_UDP_TUNNEL_CSUM;
- inner_nh = skb->inner_network_header - skb_headroom(skb);
- outer_th = skb->transport_header - skb_headroom(skb);
+ /* Like csum_start, the offsets must account for a VLAN tag
+ * the caller inserts in the frame.
+ */
+ inner_nh = skb->inner_network_header - skb_headroom(skb) + vlan_hlen;
+ outer_th = skb->transport_header - skb_headroom(skb) + vlan_hlen;
vhdr->inner_nh_offset = cpu_to_le16(inner_nh);
vhdr->outer_th_offset = cpu_to_le16(outer_th);
return 0;
--
2.53.0
Technical Details
Message-ID:
<20261110213628.3476051-2-edumazet@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-360636-linux-kernel-netdev=dewy.ruReferences:
<20261110213628.3476051-1-edumazet@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-360636-linux-kernel-netdev=dewy.ru From: edumazet@kernel.org (Eric Dumazet) Newsgroups: linux.kernel.netdev Subject: [PATCH net v6 1/3] net: virtio: fix UDP tunnel GSO header of VLAN tagged packets Date: Tue, 10 Nov 2026 22:36:26 +0100 Organization: Usenet Network Message-ID: <20261110213628.3476051-2-edumazet@kernel.org> References: <20261110213628.3476051-1-edumazet@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="707725"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:3Jsvb47PNZgGkBOyGWSYaK6rwTg= sha256:ksguOGiWsK/s2fndoJ2snX93hrA0CS7FRM00plV2cQE= sha1:pgJCeZul2L0qvsLdsWpyBw1fuIo= sha256:Q2Mh9xPXhrt6UqQYeHbUFBhYOkOlYolIQkhQBz6KHJs= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id F3CE7113D49; Wed, 11 Nov 2026 00:36:59 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JMvAYMNk6mCf; Wed, 11 Nov 2026 00:36:56 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-360636-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 4454E113D3F; Wed, 11 Nov 2026 00:36:48 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 9AFD661B7F0; Tue, 10 Nov 2026 21:36:40 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794346599; b=ElYkGDUYqRWjkcGOQjlk55voaF8OJzTAlOX2GfEvs9Ow1I+IftBn7+fDgbV5lYdZv+tS ENr4IRMwTGYcH4s6KOLPXvpNQbJ5lkTL+EaECBVKTq4EFo2URLu/MZ0KqFdLi/IZCgO6/ 7TfsY4Z7a0fD2xXhXv8M7Em1QsD8AV6P+k+MAiI179yVPq9LHNjzpH+t5zZBp/LFN8Lhu RogwKt6cRqSp8D0h8M5S0NlA8BGPHkCwUVrESgQsXgVjQFUOj4tHQmi0pal/fS92WPmqx Ic/mPSHITmlCgjGdjA8872rQGWhfxlumCe9ppxKIFHg3S9atwgY/SJRxUkO0YzrQTRA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794346599; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List: List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe: List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding; bh=HTmxr13iXWhhDne07Lv/d84VD/IopfjenubeoJyRVDg=; b=FQ7eBzsVRdW1aA1U3nBybXao+TBQ2gsAtZgP0QIm8lDb6w7FEUtnEQUNkQC1QE53lX+J QJV3ItNNHbGp1UJZuoJIsLEEb7hK8nidqiKXBR42wj357xuwMg8dYZ9jm4Gn8lBL/u7kD sg6TQofnm1c6qA2qr/7gEYydG8/K/t7kqe8AbYTVjAUrM+2LfXsi0w8r7Xdf0tb0uR8Ig M1VfIKkevYDEFXzzjRwDQg+MJ/KonKfKo8AgNoxDWQvR8XWH8yrI5DMGEZGXWcN5cgH1B f7FkfP464vUXhuCtDCLbQVK5S9Q0H8iJx/MukrRG6ITEAnCnNsV/qVHiwnaxJFQNE4A== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Efec3Ayb; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 62EC8606A334; Tue, 10 Nov 2026 21:36:39 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Efec3Ayb X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794346598; b=VjwEISbIhg1mP0SbArIEmgZQBoTz1hKfl0PxwfdxeN/upuIZiIm39aqUxiBNfUGirdKJ 1EtptH+GWqMdDXEKgZYNwDsMj7tRC8iF87OlxGUGUHmTU6WfbxeyIF2cI87zg1Xti0gtc nnXbL2ulzYwYJ6TGHfjY4Q/k92MneOfgWE8rZH4HrL1odfNXX6DVGCeaJdR14QHLj35rm JEOTVp1XvWtP4QFcaYrQ+Bw6e4WG/y6I0oKk/KSV8e/3oD2NUADHZyzn6UBmRv1CE86Dt d2n2CrDJkXea/LnsotwTKICgwa2DpTTE75KR0YfiSkFfChezMp3kDrIDBaTQWW8fdSA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794346598; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=HTmxr13iXWhhDne07Lv/d84VD/IopfjenubeoJyRVDg=; b=t/IuSrqA2f9o3kxM5Og25ZH589N70389EGl4kC505Ebhi6sm17XUeNSahRfgr/ZPfabf 4M4KHTArINP+OWCrXYVICfdW0NpQ2oj/KcbFkobqIiSKYgWjgwQUc/NbngazRRu9re0+u uHG5c+VgMwGkQ9pkS+WRtgyy+oqB8CUeLACDHGHnH8V3aFnTJCJuAwLJD/xB80WYXwLk6 DqpmNDp6rfRxPZ0acl3BfjBhzOVTnO4t7NmYOMjDSp8Oc3EbNM55VN4/DnL7bs1w92md7 vlJ2pgYqn3k537OtMYno3RPcfFWoBEBZhV883e0eohDKvnhx7RQXeSiTnDzipVjSmVA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Efec3Ayb; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37296606A325; Tue, 10 Nov 2026 21:36:38 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA5371F0089F; Tue, 10 Nov 2026 21:36:34 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794346597; bh=HTmxr13iXWhhDne07Lv/d84VD/IopfjenubeoJyRVDg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Efec3AybM5Qt9jhSaZU7KiJWQym9Fi9wY0tLjQOxwQK0rEzyjVPFnaaysZV9KaX23 jAMQYwfeytZic+wEIcuioBB3SdBuZnVb9L9eUMM4Ov8SzLtwfqf7re+6/I/qacPNdo G50Yx8b296b2lZnS6mli+h536H6yt6iB9IueE0nF1QduaGNS/DDw/IH0X/TgT8qFR1 sHzGQ/tqdeOo7bjYFvVGYE3IYSZ/ykn4M6F3X2Xa2BWFGZ2hTpcEiklGZGnkPLRBBB dxCmh6LswsnyV5BF/Bx7mq/h8/xxmZbzWt4pBBU4xZZ+hZ/bBh1DePLtIi3pExQX9J cOqoF6jXG5lcw== X-Cc: Willem de Bruijn <willemb@google.com>, Simon Horman <horms@kernel.org>, edumazet@kernel.org, "Michael S. Tsirkin" <mst@redhat.com>, Jason Wang <jasowangio@gmail.com>, Xuan Zhuo <xuanzhuo@linux.alibaba.com>, Eugenio PΓ©rez <eperezma@redhat.com>, Hassan Sultan <hassansultan@google.com>, virtualization@lists.linux.dev, Sashiko <sashiko-bot@kernel.org> X-Mailer: git-send-email 2.53.0 X-In-Reply-To: <20261110213628.3476051-1-edumazet@kernel.org> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list