πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #13302

[PATCH net v5 1/3] net: virtio: account for the VLAN tag in UDP tunnel GSO offsets

#13302
From: Eric Dumazet
Date: Mon, 09 Nov 2026 16:35
54 lines
10223 bytes
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 to virtio_net_hdr_tnl_from_skb().

virtio_net_hdr_from_skb() adds vlan_hlen to csum_start, but
virtio_net_hdr_tnl_from_skb() does not add it to inner_nh_offset and
outer_th_offset. Both offsets are then 4 bytes short of the real inner
L3 and outer UDP headers in the emitted frame.

The receiver sets inner_network_header and transport_header from these
wrong offsets. This goes unnoticed for local delivery, but a forwarded
packet that gets segmented again uses the wrong inner headers. A
receiver that checks the outer headers against outer_th_offset drops
the packet instead.

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 with VLAN tagged UDP tunnel GSO traffic, for
example from a VLAN filtering bridge with a tagged port, or from a vlan
device on top of a tap.

Add vlan_hlen to both offsets, like csum_start.

virtio_net passes vlan_hlen = 0 and is not affected.

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/
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
---
 include/linux/virtio_net.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
index d6466f96cdd0..ab44342cf09f 100644
--- a/include/linux/virtio_net.h
+++ b/include/linux/virtio_net.h
@@ -461,8 +461,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: <20261109163507.3102091-2-edumazet@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359439-linux-kernel-netdev=dewy.ru
References: <20261109163507.3102091-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!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359439-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v5 1/3] net: virtio: account for the VLAN tag in UDP tunnel GSO offsets
Date: Mon,  9 Nov 2026 17:35:05 +0100
Organization: Usenet Network
Message-ID: <20261109163507.3102091-2-edumazet@kernel.org>
References: <20261109163507.3102091-1-edumazet@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="401238"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:qgIeK61Fe8g7hnOOYBjB/lXM/ew= sha256:gpl+0Xai7c1OclkpoRdIHkA3uWFlFTyl3Lga0HfevFg=
	sha1:LyKSGkEGwfjpc+r0E67MauDJfCE= sha256:PEcJwCoXG6DyLePyOklloA5OMDrbpowemy+3TPczyws=
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 BBAA7113886; Mon,  9 Nov 2026 19:38:24 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, 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 263mYNYAgFWQ;
	Mon,  9 Nov 2026 19:38:20 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-359439-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 6376F11387B; Mon,  9 Nov 2026 19:38:12 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 6997239D81; Mon,  9 Nov 2026 16:35:19 +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=1794242118;
	b=Mls9/TzKt/Aulj0I1QhJdSTDCYKGyEy7I2T5yI2U49OLA9w8R2C9W4+x8dMkSTkbiEUw
	 U9s2qXkovNSpOBtI++fZd0XdtKqFe7TXbkcUJYMpKsEqT8yoXPp3AX3FcMcoxAdp+myo9
	 D5GcFLIPJNeS36u1DRAEHhLIzzkonZ3MzcbN+dNjw7AKBCQHwYk3KBNmMXsYDwUb71foN
	 8Owxcs6oYue3SRk5nSESGeB9XIq3EKMDK2+eJDP86oOrf7Iwx0NVAXAWNxBnne5TtCHdw
	 tV4rUZPEnvqfaEyuOeaSt8yCIfeDjkmkp86/sineJCv5uxc2O5K3oC7BMjGydP6YXkw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794242118;
	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=ze/VmDBOz+DDDwmzIw+36I8dhYEiqJZDITl1x1O2gXA=;
	b=AmwGcrTAyNZ6QVke2zdvEu0a0/37wIofnqYBY6GlbEQy7IXrqSWl27gvhO6usw92pwm8
	 JmkuiTDeAesi8g+/v1dy4ogTc4D+oJoYTNG7aBYTZglrQqQcsL5Dlz9/UtARdWNX3ot6q
	 /wZcSunWt7RYNAXuy49SNidd0vy9E8gJIiQaMs97vs9jmDCfRWuCUHqwUm8mLEmSEB0v0
	 SzOqeZki0m1KYnklKuHoOnxYCBA9ChWmh2uHjEWvdpOR231wYM1N3i846XomYyknyOzb4
	 i1pBldWNeFt6lajs28YVWvd4I3DBUAeaYhLh6ivju6hbgYoVTwy07WuN2eFOyGOLzjQ==
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=ZYTwJ08s;
	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 D2EE6606A336;
	Mon,  9 Nov 2026 16:35:18 +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=ZYTwJ08s
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=1794242117;
	b=U6yHk5X61lSc3LC0UDrQOrCGweMQu7AVNhgy3098V0l4Q5eZSJbY+9iFhFf/UhZVADW3
	 SQ/CSYLihHYNhYhQsChFn97dPSD2HRzu25F7YuBcVzOPEDjIujKBEHHaHj0LA/TijW3HW
	 2svLLpWDb9Ovx7Blo1Aq0MFISoo/cGIM7RDwvUerUU0Q4stUBA3IWYAQFJDIslmB2WPSI
	 yXVz30rk08IgOf+gjh2OtW+/cyBIt7wr3m0zHIxokO4Gn1VJCBJw15elDRnyu23Rtjg6Q
	 88lYTDPKi8+kTcKz3cCaKVf7TjHXHGY7ScgMN2ts6lPAB7NbdqrmrobulpKMJmAud9w==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794242117;
	h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 In-Reply-To:References:MIME-Version:Content-Transfer-Encoding;
	bh=ze/VmDBOz+DDDwmzIw+36I8dhYEiqJZDITl1x1O2gXA=;
	b=Z4mf2tgiUfehuGZ12RMDGC9QUqWlklHmn9FI3OyjDAp42sXG83HI8geP2mSFoUOrD/tr
	 PrMGkhli+DvBsbplTd857SGCsqKkeRWvZ6nDmWsv/DqBsDKM9gmlLwsL4cWuJnPP3UPB1
	 OCAtn6LGIG+tnM/zzapkeHf8j404D1OLTg+OpXkFt0wXPsxBnkf6HvU+U8rsSpSWxWwyU
	 DlB66tfuOEvhXc3zQgoCZ7ValdUfHJl/DjpkxtbSRd7Tk69MZKPy4o1/jlIxaodcua7zD
	 d4s0F395dWjYCWPYM+RthHL36Q1U0MfPLeeg9yEi1d8VNMBK+YDelFgIG3BwHJeg00A==
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=ZYTwJ08s;
	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 60D4C606A332;
	Mon,  9 Nov 2026 16:35:17 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F08C1F008A1;
	Mon,  9 Nov 2026 16:35:13 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794242117;
	bh=ze/VmDBOz+DDDwmzIw+36I8dhYEiqJZDITl1x1O2gXA=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References;
	b=ZYTwJ08sjNdKFi1Dq1CXJrzIIBsga9QsnY1OCLsu+186sV3bHCdGkiV2gRr/Ts18z
	 g4FIvx4YjKlVMCpx6NkPksbtcfA/BWJRVBLYgymC+KN11NlUtAjeOE/dY5/x8zjMGK
	 XzBo+xuqVokAOcipe2C98KFK3q51YTpzimi35ZNDjpytTQ4So4VhvPfzjH0Rb568YT
	 d2xz+CNy8HpYVTt2JtX892X+d5NWEWpxNzDSJM8Zj8r6qGRARK04xUSdSXvLtu+Ini
	 Y6vs2PirBay0TjmGJyf2vXr/FzrqsizklM61s+zOPhkSQlFZtcsp1c25cY9bJk8Gfh
	 d+1T2c7MgN0sg==
X-Cc: Simon Horman <horms@kernel.org>,
	Eric Dumazet <edumazet@kernel.org>,
	Willem de Bruijn <willemb@google.com>,
	"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: <20261109163507.3102091-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