🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #14201

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

#14201
From: Eric Dumazet
Date: Tue, 10 Nov 2026 21:28
127 lines
14191 bytes
Le mar. 10 nov. 2026 à 20:38, <netdev-bot+sashiko@kernel.org> a écrit :
>
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
>
> Critical: 0 · High: 1 · Medium: 0 · Low: 0
>
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
>
> - [High] virtio_net_hdr_tnl_from_skb() (include/linux/virtio_net.h)
>   chooses the outer-family GSO bit with `if (skb->protocol ==…
>
> --
>
> net: virtio: account for the VLAN tag in UDP tunnel GSO offsets
>
> This commit adds vlan_hlen to inner_nh_offset and outer_th_offset in
> virtio_net_hdr_tnl_from_skb(), the same way virtio_net_hdr_from_skb()
> already adjusts csum_start. It targets the case where tun_put_user()
> inserts a hwaccel VLAN tag into the frame, which leaves both tunnel
> offsets 4 bytes short.
>
> Closes: https://lore.kernel.org/netdev/179421814766.994134.3669228181251158303@kernel.org/
>
> > diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
> > index d6466f96cdd00..ab44342cf09f7 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;
>
> [Severity: High]
> This fixes the hwaccel case. There, vlan_hlen is VLAN_HLEN and
> skb->protocol still holds the real L3 protocol. What happens when the
> skb carries its VLAN tag inside the packet data?
>
> Just above this hunk, the outer family comes from skb->protocol:
>
> include/linux/virtio_net.h:virtio_net_hdr_tnl_from_skb() {
>     ...
>         if (skb->protocol == 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;
>     ...
> }
>
> For an in-band tagged frame, vlan_insert_tag_set_proto() has already set
> skb->protocol to ETH_P_8021Q or ETH_P_8021AD. Wouldn't an IPv6 outer
> header then be reported as VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV4?
>
> The commit message says:
>
>     virtio_net passes vlan_hlen = 0 and is not affected.
>
> virtio_net has no NETIF_F_HW_VLAN_CTAG_TX, so validate_xmit_vlan() pushes
> every tag into the data:
>
> net/core/dev.c:validate_xmit_vlan() {
>         if (skb_vlan_tag_present(skb) &&
>             !vlan_hw_offload_capable(features, skb->vlan_proto))
>                 skb = __vlan_hwaccel_push_inside(skb);
>     ...
> }
>
> Its vlan_features and hw_enc_features still include
> NETIF_F_GSO_UDP_TUNNEL. Take a VXLAN or Geneve device over an IPv6
> underlay on a VLAN subinterface: it sends unsegmented skbs with
> skb->protocol == ETH_P_8021Q into
> xmit_skb()->virtio_net_hdr_tnl_from_skb(). Is virtio_net really
> unaffected in that case?
>
> tun seems to reach the same path in three cases: ethtool -K tapX txvlan
> off, QinQ (outer tag in hwaccel, inner tag in the data), and a vlan
> device created with reorder_hdr off.
>
> Before this series, a Linux receiver used this bit only to compute a
> looser outer_l3min, so the wrong value did no harm. Later in the series,
> "net: virtio: validate outer protocol of UDP tunnel GSO packets" adds
> virtio_net_tnl_offsets_ok(). That function walks the VLAN tags and
> rejects the mismatch:
>
>         if (!virtio_net_l3_start(skb, has_eth, &nhoff, &proto))
>                 return false;
>         if (outer_isv6 != (proto == htons(ETH_P_IPV6)))
>                 return false;
>
> Once that check is in place, will tun_get_user(), tun_xdp_one() and
> virtnet_receive_done() drop every VLAN tagged UDP tunnel GSO packet with
> an IPv6 outer header from these senders?
>
> Could the outer family be taken from vlan_get_protocol(skb) here instead
> of skb->protocol?

Right. When __vlan_hwaccel_push_inside() inserts the tag, skb->protocol
becomes the VLAN protocol, and an outer IPv6 header is reported as
IPv4. The offsets are correct in that case, only the family is wrong.
This is the default for virtio_net, which has no VLAN TX offload, and
happens with tun when VLAN TX offload is off or with QinQ.

v6 fixes both issues in this patch, using vlan_get_protocol() for the
outer family. The patch is renamed to
"net: virtio: fix UDP tunnel GSO header of VLAN tagged packets".

pw-bot: cr
Technical Details
Message-ID: <CAL4Wiir1500Vwthv6scfCDJVctY+PTMJ4wqJrbCXKKQ6TYFX4A@mail.gmail.com>
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-360630-linux-kernel-netdev=dewy.ru
References: <20261109163507.3102091-2-edumazet@kernel.org> <179433950084.994134.15100186606737698605@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-360630-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v5 1/3] net: virtio: account for the VLAN tag in UDP
 tunnel GSO offsets
Date: Tue, 10 Nov 2026 22:28:56 +0100
Organization: Usenet Network
Message-ID: <CAL4Wiir1500Vwthv6scfCDJVctY+PTMJ4wqJrbCXKKQ6TYFX4A@mail.gmail.com>
References: <20261109163507.3102091-2-edumazet@kernel.org> <179433950084.994134.15100186606737698605@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="706785"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:7TBQmeqvJPIdTc1k8ugOvJCQhL0= sha256:grzP/D0Cu4HetAE4wyzpOHWgrwcvFNUWdTeDh3WPCsQ=
	sha1:wTD7z/9XpXqU/7E4ufeT6NlgdDg= sha256:03dbzKjYwHhOSvUnS6ef/va56sbPL2GSaj5243ChvVg=
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 CFD72113D42; Wed, 11 Nov 2026 00:29:44 +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 1aisArOtEeyA;
	Wed, 11 Nov 2026 00:29:37 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-360630-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 097E4113D3D; Wed, 11 Nov 2026 00:29:26 +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 1D3A860947; Tue, 10 Nov 2026 21:29:13 +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=1794346150;
	b=rXpT8hXWCpCD8DYUm5oqWmPnX+mFHPKKA2t0AP5s2mOONOcXl0bavTvsbmFXVX8W1/lb
	 2Iji+K+fbAM9w18sI91q0LXA6P+/NBi2z1acrfMo4FLqbdpNcN+fbi9dAp5zc4qk2dQTi
	 dNvn5i5ylYm+Lo20vA8zaMhFmYIo2n7GSk/plAXHCArIDkjz/KoUeql5KLRn9sFOqN82x
	 cy49rFyKUQf5DOZz0mz+9sUmqNv8VCTRZnkSxwmiT993FOdnsA8Yx+dY+rXWtK3nuvaz5
	 wDYdw8AtsAt2eKB4bP8qZ8brFfev4sWXgDRTYSM5Ij/SAYvQh3IDa2EvkaqMyJY/PYQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794346150;
	h=X-Original-To:Received:Received:DKIM-Signature:Received:
	 X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:References:In-Reply-To:From:Date:
	 X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:Subject:To:Cc:
	 Content-Type:Content-Transfer-Encoding;
	bh=QvRngHIKvFqW6jRWzUlu52YQhDV4SuF4oJauIZT/Z4k=;
	b=HFZNPjedz4nc88SvBPYNwKENWeraVgbyrRlkUqg5fLqdU2bgYFdhBcqPPVWA9qo5YZ+x
	 85aqZf2rSmfPUebSMTM4BE4oH491tT6w4BlmwZnj73uyaB+2qV/WhdGn6wzxqEqDyIsZo
	 1DYYcfgwfU0+toLVn2uH9W295YejTe4o7l8YIUtvnn6c9Q78q0bjLn5YK72pD8K1ULqAd
	 XoWVXUez/2mfnG9XnpHVYVEzcZq2giVX+AapH0/NKtzczo5Tct3drhescTFUCYPnCUyL4
	 oKB4xQq6zoaEL5s2SGye48blgM3eceQIlXwZyOLWa4vT2h1ClGXOVkJOqDPxYJolgaw==
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=P3Arx0qw;
	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 90DF2606A32D;
	Tue, 10 Nov 2026 21:29:10 +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=P3Arx0qw
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=1794346149;
	b=cnBGA/W7yiHTQZqdGjRzbrnkCd45v3LT2L7Fya2FYbPmmuf6bLimPVwlCeVMZsy2jYRS
	 T8C59n608k0mqV3i6EHxXSFSNs+E6o0Kz2Ig5JWsY2rh7RC59pNPVH8kXlUke6TXkhHCu
	 CE7EMJkeUORWrFyaQMHd+FTnaoicAR9hO2he02n5rPoEMA/ft363Uzm0YoNbZNgFTLnWj
	 IaFJUS1jxWJ1D2zt4h1uPTLCxDBryjNXroYqeSPP/ssKyvaAgmNZZe8PUFI3j8Q1Yo2m3
	 MDR6HbVc2MLWFtPsRvWQibWj+2eHxhjxhbbQak6Wt/M00LQitKiOLFPaa8ic1VD5BfQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794346149;
	h=Received:DKIM-Signature:Received:X-Forwarded-Encrypted:
	 X-Gm-Message-State:X-Received:MIME-Version:References:In-Reply-To:
	 From:Date:X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:
	 Subject:To:Cc:Content-Type:Content-Transfer-Encoding;
	bh=QvRngHIKvFqW6jRWzUlu52YQhDV4SuF4oJauIZT/Z4k=;
	b=o38OAPK55uWxh9dhjFQK/W706+w/JnHXjBFKndnP7Vg1XCD6uOLB19YK8gFrKncYvRVK
	 HI0fl6PKjRNNaESj9eqWUU8ngYTzgKBMlZNRGeHHic3xpew9y3xgEXztvW/0te49ee9bc
	 4ZfZ4PO2kG62F4GIX0/4iRWOaBisEVVewwrwzI1niMPijLTsV2hUgNL8pmUOWA7eT9pHZ
	 9oxd7ETaH3IWR146PK5no4QPMAPnNzN7PTfI44oMkdqX7g6tP14wQVUjOoFx6W3WRPzn8
	 CmGMhUELA5w8mpL8mD3KKvA8S4rLIV2Yumpny8uNP/1fV2dsLZJRlOhCU1/ZaxZ00AA==
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=P3Arx0qw;
	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 EA29C606A320
	for <netdev@vger.kernel.org>; Tue, 10 Nov 2026 21:29:08 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 820C31F008A2
	for <netdev@vger.kernel.org>; Tue, 10 Nov 2026 21:29:08 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794346148;
	bh=QvRngHIKvFqW6jRWzUlu52YQhDV4SuF4oJauIZT/Z4k=;
	h=References:In-Reply-To:From:Date:Subject:To:Cc;
	b=P3Arx0qwMLaoH7WBKEiWTBLyOxfs63vXV5cHfoZHHTqKLWZSq+NNDYxB3/qPbieoR
	 Yq+Oy0HjM1n5PTu/A9FXi3ViNmWQNurAaWCdepQPRqGVazTDszbf+kAvfaUEYRLCd4
	 N7MTVVSICCpiienm1RVrG5QmMYfvh7sh8oq6Nr6L2Rzp9cUplCDsB7Rt2YCjxFxIB3
	 L7zZx8oHgLJFWVMMC0a1v4lOavDXCtqqMuz+xOii6W2Vxmwjf+JwKqVhHI3vmgHvsB
	 TkOEuVqEeowBGQUZjADVukXDCDhKnW6hSja8Kluan7Dn8ao9mCKXwd+tOXJ5Mtdf/K
	 Fam+zU5JMSLeQ==
X-Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-6deb848ddd7so1533190eaf.0
        for <netdev@vger.kernel.org>; Tue, 10 Nov 2026 13:29:08 -0800 (PST)
X-Forwarded-Encrypted: i=1; AL+hErEXMBwberu2u5xfq3iYg0mwxri+ck9T3eYd7JXWfdRSk5Y5hWY+BjtBS0S6Lm2wYK4mBD62O/k=@vger.kernel.org
X-Gm-Message-State: APuU4Z9ex+Q6t1JcKjKCmKmJKADdNkearSgnu4j9n2YahvTPXr41uPis
	yfdJLXWZaDj2aZ7MKsE4HeIw6elcDcw8cZt5sVvF8Bk8jW55YU6ie0HOXg+VG6XeG7KqG5HZURa
	UOgcW+raG5L60Qh6N6xXdtgvOe0NlWaU=
X-Received: by 2002:a05:6820:f02a:b0:709:f34e:e46e with SMTP id
 006d021491bc7-719175f8a1dmr288031eaf.1.1794346147805; Tue, 10 Nov 2026
 13:29:07 -0800 (PST)
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
X-In-Reply-To: <179433950084.994134.15100186606737698605@kernel.org>
X-Gmail-Original-Message-ID: <CAL4Wiir1500Vwthv6scfCDJVctY+PTMJ4wqJrbCXKKQ6TYFX4A@mail.gmail.com>
X-Gm-Features: AclHuK9CfxUTeJWZvRx6zMN0no9V9o8h0w5l6bkIB8qo1g_uSkervMfs31U5krs
X-Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, 
	netdev@vger.kernel.org, horms@kernel.org, willemb@google.com, mst@redhat.com, 
	jasowangio@gmail.com, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, 
	hassansultan@google.com, virtualization@lists.linux.dev, 
	sashiko-bot@kernel.org