Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: willemb@google.com
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
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	[thread overview]
Message-ID: <179606019715.3146.2252735958159883067@kernel.org> (raw)
In-Reply-To: <20261129163327.893403-5-willemb@google.com>

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

  reply	other threads:[~2026-11-30 17:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 16:30 [PATCH net-next v2 0/5] net: remove dev_validate_header() and net_device::min_header_len Willem de Bruijn
2026-11-29 16:30 ` [PATCH net-next v2 1/5] net: ipa: remove ethernet-specific artifacts from modem netdev setup Willem de Bruijn
2026-11-29 16:30 ` [PATCH net-next v2 2/5] net: remove header_ops->validate and dev_validate_header() Willem de Bruijn
2026-11-30 17:36   ` netdev-bot+sashiko
2026-11-29 16:30 ` [PATCH net-next v2 3/5] packet: reset network header on all headerless devices Willem de Bruijn
2026-11-30 17:36   ` netdev-bot+sashiko
2026-11-29 16:30 ` [PATCH net-next v2 4/5] packet: use Ethernet header length in vlan_get_tci() Willem de Bruijn
2026-11-30 17:36   ` netdev-bot+sashiko [this message]
2026-11-29 16:30 ` [PATCH net-next v2 5/5] net: remove unused net_device::min_header_len Willem de Bruijn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179606019715.3146.2252735958159883067@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=elder@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox