All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: JensEmil.SchulzOstergaard@microchip.com, sashiko-reviews@lists.linux.dev
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH net-next v11 1/9] net: dsa: add tag driver for LAN9645X
Date: Tue, 11 Aug 2026 12:55:14 +0200	[thread overview]
Message-ID: <c22fb728-516d-4dcc-b9d6-64ac4968fcfe@redhat.com> (raw)
In-Reply-To: <ed13dca89e3b2131a717476b9e13d5a3012a0e30.camel@microchip.com>

On 8/7/26 4:41 PM, JensEmil.SchulzOstergaard@microchip.com wrote:
> On Thu, 2026-08-06 at 14:38 +0000, sashiko-bot@kernel.org wrote:
>> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>>
>> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
>> - [High] The tag driver drops hardware-accelerated VLAN tags on transmit, leading to switch misclassification and double tagging.
>> --
>>
>> --- Patch [1]: [PATCH net-next v11 1/9] net: dsa: add tag driver for LAN9645X ---
>> commit 97f24952991b201e3d0f1948d98e9534914b9db3
>> Author: Jens Emil Schulz Østergaard <jensemil.schulzostergaard@microchip.com>
>>
>> net: dsa: add tag driver for LAN9645X
>>
>> This commit introduces a new DSA tag driver for the LAN9645X switch family,
>> using an NPI port for CPU connection. It supports prepending a 28-byte
>> internal frame header (IFH) on injection and handling a long prefix on
>> extraction.
>>
>>> diff --git a/net/dsa/tag_lan9645x.c b/net/dsa/tag_lan9645x.c
>>> new file mode 100644
>>> index 0000000000000..6a33216c7792f
>>> --- /dev/null
>>> +++ b/net/dsa/tag_lan9645x.c
>>
>> [ ... ]
>>
>>> +static void lan9645x_xmit_get_vlan_info(struct sk_buff *skb,
>>> +                                     struct net_device *br,
>>> +                                     u32 *vlan_tci, u32 *tag_type)
>>> +{
>>> +     struct vlan_ethhdr *hdr;
>>> +     u16 proto, tci;
>>> +
>>> +     if (!br || !br_vlan_enabled(br)) {
>>> +             *vlan_tci = 0;
>>> +             *tag_type = LAN9645X_IFH_TAG_TYPE_C;
>>> +             return;
>>> +     }
>>> +
>>> +     hdr = (struct vlan_ethhdr *)skb_mac_header(skb);
>>> +     br_vlan_get_proto(br, &proto);
>>> +
>>> +     if (skb_headlen(skb) >= VLAN_ETH_HLEN &&
>>> +         ntohs(hdr->h_vlan_proto) == proto) {
>>> +             vlan_remove_tag(skb, &tci);
>>> +             *vlan_tci = tci;
>>> +     } else {
>>> +             rcu_read_lock();
>>> +             br_vlan_get_pvid_rcu(br, &tci);
>>> +             rcu_read_unlock();
>>> +             *vlan_tci = tci;
>>> +     }
>>
>> [Severity: High]
>> Does this code drop hardware-accelerated VLAN tags on transmit?
>>
>> When the network stack transmits a frame through the DSA user port with a
>> hardware-accelerated VLAN tag, the tag is stored out-of-band in skb->vlan_tci.
>>
>> By only checking the inline Ethernet header, ntohs(hdr->h_vlan_proto) will
>> evaluate to the inner network protocol (like IPv4) instead of ETH_P_8021Q.
>> This causes the check to fail and fall back to using the bridge PVID instead
>> of extracting the existing out-of-band VLAN tag.
>>
>> Because the out-of-band tag is ignored and never removed from the socket
>> buffer, will the conduit driver eventually insert the original VLAN tag into
>> the payload, resulting in a double-tagged frame on the wire?
> 
> If the conduit sets NETIF_F_HW_VLAN_CTAG_TX (or STAG_TX) in
> conduit->vlan_features, then I think the analysis is correct.
> 
> __dev_queue_xmit() calls validate_xmit_skb() -> validate_xmit_vlan()
> before ndo_start_xmit():
> 
> 	if (skb_vlan_tag_present(skb) &&
> 	    !vlan_hw_offload_capable(features, skb->vlan_proto))
> 		skb = __vlan_hwaccel_push_inside(skb);
> 
> vlan_hw_offload_capable() requires NETIF_F_HW_VLAN_CTAG_TX (or STAG_TX).
> A DSA user port inherits its features from the conduit
> 
> user->features = conduit->vlan_features | NETIF_F_HW_TC;
> 
> and user->hw_features only ever gains NETIF_F_HW_TC and
> NETIF_F_HW_VLAN_CTAG_FILTER, so ethtool cannot turn the TX offload on.
> 
> But if a conduit sets those offload flags, the tag driver could receive
> an skb with the vlan tag in the hwaccel area.
> 
> I will normalise the tag into the payload at the top of
> lan9645x_xmit_get_vlan_info(), following the precedent in
> sja1105_pvid_tag_control_pkt():
> 
> if (unlikely(skb_vlan_tag_present(skb))) {
>         skb = __vlan_hwaccel_push_inside(skb);
>         if (!skb)
>                 return NULL;
> }
> 
> But the outcome would probably be worse than a double-tagged frame? We
> prepend the dsa tag, and the conduit would not know anything about that, so
> my guess is it would insert the vlan tag into the dsa tag.
What about something alike the following?

	if (skb_vlan_tag_present(skb)) {
		*vlan_tci = skb_vlan_tag_get(__skb);
	} else if (skb_headlen(skb) >= VLAN_ETH_HLEN &&
		 ntohs(hdr->h_vlan_proto) == proto) {
	// ...

Side note: I *think* the unlikely() on skb_vlan_tag_present() is not
needed; the like-wood depends on the actual traffic pattern.

/P


  reply	other threads:[~2026-08-11 10:55 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05 14:34 [PATCH net-next v11 0/9] net: dsa: add DSA support for the LAN9645x switch chip family Jens Emil Schulz Østergaard
2026-08-05 14:34 ` [PATCH net-next v11 1/9] net: dsa: add tag driver for LAN9645X Jens Emil Schulz Østergaard
2026-08-06 14:38   ` sashiko-bot
2026-08-07 14:41     ` JensEmil.SchulzOstergaard
2026-08-11 10:55       ` Paolo Abeni [this message]
2026-08-11 11:50         ` JensEmil.SchulzOstergaard
2026-08-05 14:34 ` [PATCH net-next v11 2/9] dt-bindings: net: lan9645x: add LAN9645X switch bindings Jens Emil Schulz Østergaard
2026-08-06 14:38   ` sashiko-bot
2026-08-07 14:15     ` JensEmil.SchulzOstergaard
2026-08-05 14:34 ` [PATCH net-next v11 3/9] net: dsa: lan9645x: add autogenerated register macros Jens Emil Schulz Østergaard
2026-08-05 14:34 ` [PATCH net-next v11 4/9] net: dsa: lan9645x: add basic dsa driver for LAN9645X Jens Emil Schulz Østergaard
2026-08-06 14:38   ` sashiko-bot
2026-08-07 14:07     ` JensEmil.SchulzOstergaard
2026-08-05 14:34 ` [PATCH net-next v11 5/9] net: dsa: lan9645x: add bridge support Jens Emil Schulz Østergaard
2026-08-06 14:38   ` sashiko-bot
2026-08-07 13:44     ` JensEmil.SchulzOstergaard
2026-08-05 14:34 ` [PATCH net-next v11 6/9] net: dsa: lan9645x: add vlan support Jens Emil Schulz Østergaard
2026-08-06 14:38   ` sashiko-bot
2026-08-07 13:40     ` JensEmil.SchulzOstergaard
2026-08-11 10:32   ` Paolo Abeni
2026-08-11 12:12     ` Jens Emil Schulz Ostergaard
2026-08-05 14:34 ` [PATCH net-next v11 7/9] net: dsa: lan9645x: add mac table integration Jens Emil Schulz Østergaard
2026-08-05 14:34 ` [PATCH net-next v11 8/9] net: dsa: lan9645x: add mdb management Jens Emil Schulz Østergaard
2026-08-06 14:38   ` sashiko-bot
2026-08-07 13:22     ` JensEmil.SchulzOstergaard
2026-08-05 14:34 ` [PATCH net-next v11 9/9] net: dsa: lan9645x: add port statistics Jens Emil Schulz Østergaard
2026-08-11 10:35 ` [PATCH net-next v11 0/9] net: dsa: add DSA support for the LAN9645x switch chip family Paolo Abeni
2026-08-11 10:36   ` Paolo Abeni
2026-08-11 12:18   ` Jens Emil Schulz Ostergaard

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=c22fb728-516d-4dcc-b9d6-64ac4968fcfe@redhat.com \
    --to=pabeni@redhat.com \
    --cc=JensEmil.SchulzOstergaard@microchip.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.