๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24721

Re: [PATCH net-next v2 4/5] packet: use Ethernet header length in vlan_get_tci()

#24721
From: netdev-bot+sashiko
Date: Mon, 30 Nov 2026 17:36
103 lines
12037 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The patch fixes VLAN metadata that userspace sees, but the commit
  has no Fixes: tag.
- [Low] The commit message says the is_vlan_dev() fallback in
  vlan_get_tci() 'has been obsolete since commit 447cbe95ebb9'.

--

packet: use Ethernet header length in vlan_get_tci()

This commit makes vlan_get_tci() read the outer VLAN header at ETH_HLEN,
and only for ARPHRD_ETHER and ARPHRD_LOOPBACK devices. The helper now
returns whether a TCI was extracted. tpacket_rcv(), prb_fill_vlan_info()
and packet_recvmsg() only set the VLAN valid flags when it was, and
packet_recvmsg() no longer looks up the device under RCU.

> vlan_get_tci() uses dev->min_header_len to locate the outer 802.1Q/AD
> header on SOCK_DGRAM captures, with an is_vlan_dev() fallback that has
> been obsolete since commit 447cbe95ebb9 ("vlan: fix skb_under_panic and
> races when toggling HW VLAN offload") stopped adding VLAN_HLEN to
> vlandev->hard_header_len.

[Severity: Low]
Is the is_vlan_dev() fallback really obsolete since 447cbe95ebb9? A VLAN
device still inherits hard_header_len from its lower device:

net/8021q/vlan_dev.c:vlan_dev_init() {
    ...
	dev->hard_header_len = real_dev->hard_header_len;
    ...
}

vlan_transfer_features() does the same thing:

	vlandev->hard_header_len = dev->hard_header_len;

vlan_setup() calls ether_setup(), so min_header_len stays at ETH_HLEN.

Some lower Ethernet devices have a hard_header_len larger than ETH_HLEN.
smsc95xx is one:

drivers/net/usb/smsc95xx.c:smsc95xx_bind() {
    ...
	dev->net->hard_header_len += SMSC95XX_TX_OVERHEAD_CSUM;
    ...
}

rndis_host is another. For a VLAN device on top of one of these,
min_header_len != hard_header_len, so the old vlan_get_tci() still took
the is_vlan_dev() branch to get header_len = ETH_HLEN.

The new code that reads at ETH_HLEN gives the right result either way,
so only the explanation is affected. Could the wording be changed so
backporters don't read it as a dependency on 447cbe95ebb9?

[ ... ]

> This changes the reported VLAN metadata in three cases:
>
> - Ethernet devices with hard_header_len != ETH_HLEN (e.g., smsc95xx,
>   rndis_host) previously failed the min_header_len == hard_header_len
>   test and reported TCI 0. They now report the actual TCI.
> - Non-Ethernet devices and frames without an extractable VLAN header
>   previously still set TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID:
>   headerless devices (e.g., tun, rmnet) matched 0 == 0 and read payload
>   bytes at offset 0 as TCI, while other non-Ethernet devices and
>   truncated frames reported TCI 0. They now omit VLAN metadata and flags.
> - packet_recvmsg() previously omitted the VLAN fields if the device
>   had been unregistered since the packet was queued. It now fills
>   them from the queued skb.
>
> Signed-off-by: Willem de Bruijn <willemb@google.com>

[Severity: Low]
The first two cases fix wrong VLAN metadata that userspace sees, so
should this have a Fixes: tag?

Two pieces of code come from 79eecf631c14. One is the min_header_len /
hard_header_len / is_vlan_dev() logic in vlan_get_tci(). The other is
the code in tpacket_rcv(), prb_fill_vlan_info() and packet_recvmsg() that
sets TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID whatever
vlan_get_tci() returns. The old return value of 0 could not be told apart
from a valid TCI of 0.

Fixes: 79eecf631c14 ("af_packet: Handle outgoing VLAN packets without hardware offloading")

Since that commit, a SOCK_DGRAM capture of software-tagged VLAN traffic on
smsc95xx reports TCI 0 with the valid flags set. Headerless devices report
payload bytes as the TCI, also with the valid flags set.

Without the tag, stable trees that carry 79eecf631c14 have nothing
pointing them at this fix. The subject "use Ethernet header length in
vlan_get_tci()" and the "removing the last min_header_len reader" framing
also read like a refactor rather than a fix for wrong output.

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129163327.893403-1-willemb%40google.com
Technical Details
Message-ID: <179606019715.3146.2252735958159883067@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374352-linux-kernel-netdev=dewy.ru
References: <20261129163327.893403-5-willemb@google.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374352-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v2 4/5] packet: use Ethernet header length in
 vlan_get_tci()
Date: Mon, 30 Nov 2026 17:36:37 +0000
Organization: Usenet Network
Message-ID: <179606019715.3146.2252735958159883067@kernel.org>
References: <20261129163327.893403-5-willemb@google.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1487243"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:0CfFLD3dgq3V2AYF7FMpD0MebR8= sha256:Zg1YMNGdQCjZC/LO7shN18dmd0l1jJuTRVI/U1aUS+Q=
	sha1:gGTOl4dMACggCV1d+ylt1bQDQr8= sha256:mK3NE+0Z92kJv/B9ABQJ0GppoAA0C4a8imoGwesbIl4=
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 DF765125FFA; Mon, 30 Nov 2026 20:36:56 +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 oS1hiDrr77-U;
	Mon, 30 Nov 2026 20:36:53 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374352-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 82503125FF6; Mon, 30 Nov 2026 20:36:44 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id A8DDB2C011; Mon, 30 Nov 2026 17:36:39 +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=1796060199;
	b=R2Cq1165jR6nuJ1bYUXs+EdtptsdYMh4YVfBhSbYGGvChI274qv4mEGnq7caNxZWqzSH
	 yXjEt9m0C7sA0kFD+xxQlfFuu6yzDlRTmBc3XbI5snLUgoTP0ThuvWjTpyTXsoLMzhl1y
	 ZzPm5o1vVgjatZdIw1cEkVjivv/OBDLTW8YpTwxL0iPjdGRZd2pyWfsUt+HKBDy7LTgG2
	 +h6bjjmoZlhYHEGzIFXfNRTzbEa1Hd5CdgQqA+0onAbz9kSy13+YjxxeV97fdGZppyrxU
	 GTOydt/CxJc9bx2yPiwRg7gSTRJUkAeCpFgIqb6uB0ReYssOfyhhvOOcaUOeuH8gG2A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796060199;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=MEFuHJ3mke1qEblqtW3JNj+0TcfaptiKIOztC6qslgA=;
	b=KGufq2ss6dMp5iZTHUXU5XozN1gahtMUBlbSiJZB/YkrTMWxAbatNxGmXhUAWmJX2Giv
	 9XAJMwFvfT815XmAp4xif18f3ptoXQJk+cbAc5r/I0rS993YjSAMlBN5ipD/VoSegsELT
	 B6a0SNtLvBuIDYfPKAG8itVNt9Gax9PqrM5iM6GJZ62Qky/xSYkztZ5HfAVc8XuOCBMbx
	 fKRq2yLtI9444nD9DVA/jqG95Z2zO3b0ByVzTEE4L0KrSbxqf9fBtwT7N4nQfqgduZBGU
	 Ii36Q0ZM0kgwXK31VtK9TOBiktQ6jwdgi+bx6e4PmxJOiyyC2h1wlGMH2uhf8kf8UFQ==
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=NdwaVtV6;
	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 7BABC606A329;
	Mon, 30 Nov 2026 17: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=NdwaVtV6
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=1796060198;
	b=JFz6dEY7PexOQvQs9eFXjSh3eU1aXYdkYYYU1lDcHK3nCI4Fs9hl2YZDy6SWSBM7q14+
	 SCH+BozwRUilyD5D900r2CohVF+ASUwhsCgk2uoXt07dmkBXzYgMv8Tf4J1oEHS6cPWt9
	 PpRZH0iGDhzqE/+JtLe1VWxCEPNjJ4LrpUjWOzkRzrvT0kIbmRQ9qZ5L7kZlKlUZWR/80
	 fjyn7TW/qhR1Ouc7in4lQ0Q+GeVi5KIdOYraXrsaW/s+kwtjw6zyAQQL9zO4DgSsMfeRj
	 Jf95+DP9d3L+1kIpGcvyLoG3ADrcSpsaHBoKgJ90EIFzmxaatXF59VSkmYfZhtcH7PA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796060198;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=MEFuHJ3mke1qEblqtW3JNj+0TcfaptiKIOztC6qslgA=;
	b=gkfcwgqIPbRtf58DOKkbHpZ8p6oOs1H0Qm2uXgWaxSgjQv2UyhgtOylzhTZ6mDz7VZtL
	 Pz1Rv/4QfkBuYlrPQyHAD4FLVCgtR0g5HWBHZpOcUz0O52h/4vQAyy7cMMdArio3OGP9K
	 PaZvrFF5LqLziYF/8qblPDwxLwQZ4XYUrY9NnSgJKJih/e/IT/xBpHApwlkafuqUy+oBY
	 tFCfGakkqsLhXz7qts5cbU9E2llcRSmd4WFGk4HAOhDZK2ouuz1zLXdAZHFNz42rRGWjn
	 ZOqW6fiiExt3nsFLEF/lZ3POL4/0ydLUtKMeLY3Y1/apmemzFU3Ez2JUkqaPTrwcvew==
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=NdwaVtV6;
	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 9B55B606A32E
	for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 17:36:38 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E0601F00898;
	Mon, 30 Nov 2026 17:36:37 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796060198;
	bh=MEFuHJ3mke1qEblqtW3JNj+0TcfaptiKIOztC6qslgA=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=NdwaVtV6JkQT07vDA22kaWGuD7NxHfM1rm6pOcodxyGIR2fiIx5ndVe6M+Qoj/O8n
	 UTkcT+K7jH15B4/HinmD/aooHI7RYz1T/ewV62MFl/g0UxQyJe+F2oVGxzj67If9Oy
	 KGspLST9b7fzCI/+icpY7YxfyKseiaM1ywsStNDtVZco+G2keGX1fAp9sVft//VQce
	 G+muXf7fq88NIBMfA8/QRryI3z+57peb1DK0pkdbAloAMSCeQ/7ylonVVva0vPQVMQ
	 DwlxepggWRfNIyCwCOnD0fdWiQzloD5UPWEE61ZUxqXUTi8n9sSVHOn7Gd4/piS2nC
	 md7/x1aqlnVwA==
X-Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
 elder@kernel.org
X-In-Reply-To: <20261129163327.893403-5-willemb@google.com>
X-sashiko-severity: Low
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