Netdev List
 help / color / mirror / Atom feed
From: "Jens Emil Schulz Østergaard" <jensemil.schulzostergaard@microchip.com>
To: <netdev-bot+sashiko@kernel.org>,
	<jensemil.schulzostergaard@microchip.com>
Cc: <UNGLinuxDriver@microchip.com>, <andrew@lunn.ch>,
	<olteanv@gmail.com>, <davem@davemloft.net>, <edumazet@kernel.org>,
	<kuba@kernel.org>, <pabeni@redhat.com>, <linux@armlinux.org.uk>,
	<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next v2 5/5] net: dsa: lan9645x: add bridge support
Date: Mon, 30 Nov 2026 10:03:39 +0100	[thread overview]
Message-ID: <DN8FAKUTL6X4.P73PYB87C6WA@microchip.com> (raw)
In-Reply-To: <179585821765.3135.11957570145287110531@kernel.org>

On Sat Nov 28, 2026 at 10:30 AM CET, netdev-bot+sashiko wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 1
>
> 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).
>
> - [Medium] The 802.1Q-only restriction for VLAN-aware bridges is checked
>   only when a port joins, in lan9645x_port_bridge_join() through…
> - [Low] In lan9645x_port_mdb_add(), the existing `mdb->vid > VLAN_MAX`
>   check (returns -EOPNOTSUPP) runs before the new…
>
> --
>
> net: dsa: lan9645x: add bridge support
>
> This adds hardware bridge offload to the lan9645x DSA driver. Up to 8
> bridges are supported, each VLAN-unaware bridge gets its own reserved VID,
> and at most one bridge can be VLAN-aware. The patch adds STP, learning,
> flooding, host flood and ageing support, and refuses vlan_filtering
> changes while ports are bridged. It also does not install FDB or MDB
> entries that carry a VID on a VLAN-unaware bridge.
>
>> diff --git a/drivers/net/dsa/microchip/lan9645x/lan9645x_main.c b/drivers/net/dsa/microchip/lan9645x/lan9645x_main.c
>> index e840de1c918ba..94b46082cf5c4 100644
>> --- a/drivers/net/dsa/microchip/lan9645x/lan9645x_main.c
>> +++ b/drivers/net/dsa/microchip/lan9645x/lan9645x_main.c
>
> [ ... ]
>
>> +static bool lan9645x_bridge_vlan_proto_ok(const struct net_device *br)
>> +{
>> +	u16 proto;
>> +
>> +	return !br_vlan_enabled(br) || br_vlan_get_proto(br, &proto) ||
>> +	       proto == ETH_P_8021Q;
>> +}
>
> [ ... ]
>
>> +static int lan9645x_port_bridge_join(struct dsa_switch *ds, int port,
>> +				     struct dsa_bridge bridge,
>> +				     bool *tx_fwd_offload,
>> +				     struct netlink_ext_ack *extack)
>> +{
>
> [ ... ]
>
>> +	if (!lan9645x_bridge_vlan_proto_ok(bridge.dev)) {
>> +		NL_SET_ERR_MSG_MOD(extack,
>> +				   "Only 802.1Q VLAN-aware bridges are supported");
>> +		return -EINVAL;
>> +	}
>
> [Severity: Medium]
> Is checking the protocol only in lan9645x_port_bridge_join() enough to
> keep the hardware and the software bridge in agreement?
>
> Once a port has joined, a protocol change goes through
> __br_vlan_set_proto() in net/bridge/br_vlan.c:
>
> 	err = switchdev_port_attr_set(br->dev, &attr, extack);
> 	if (err && err != -EOPNOTSUPP)
> 		return err;
>
> The attribute is sent with SWITCHDEV_F_SKIP_EOPNOTSUPP. net/dsa/ has no
> handler for SWITCHDEV_ATTR_ID_BRIDGE_VLAN_PROTOCOL, so a command like
> "ip link set br0 type bridge vlan_protocol 802.1ad" succeeds on a
> VLAN-aware bridge that already has lan9645x ports.
>
> After that, the hardware still treats 0x8100 tags as VLAN tags, but the
> software bridge uses 802.1ad. Take a 0x8100-tagged VID 20 frame that
> arrives on a port with pvid 10, where the port is also a member of VLAN
> 20. The hardware forwards it in VLAN 20, but the bridge policy would
> classify it to VLAN 10.
>
> The commit message mentions this limitation:
>
>   DSA does not pass SWITCHDEV_ATTR_ID_BRIDGE_VLAN_PROTOCOL to drivers,
>   so a protocol change on a bridge that is already VLAN-aware is not
>   seen.
>
> It also says "Only bridge vlan_protocol 802.1Q is offloaded", but that
> restriction can be bypassed after the join. Should the DSA core either
> pass this attribute to drivers or refuse the change while ports are
> offloaded?
>

No, it is not enough, and the commit message says so. The driver refuses
to join a VLAN-aware 802.1ad bridge, and vlan_filtering changes are
refused while ports are bridged, so a protocol change on a bridge that is
already VLAN-aware is the only case left.

The driver cannot see that change, since net/dsa does not handle
SWITCHDEV_ATTR_ID_BRIDGE_VLAN_PROTOCOL. This applies to every DSA driver
that only supports 802.1Q bridges. Refusing the change or passing it to
drivers is a DSA core change, which I think belongs in its own patch
rather than in this series.

> [ ... ]
>
>> @@ -503,6 +844,9 @@ static int lan9645x_port_mdb_add(struct dsa_switch *ds, int port,
>>  	if (mdb->vid > VLAN_MAX)
>>  		return -EOPNOTSUPP;
>>  
>> +	if (lan9645x_db_vid_unused(lan9645x, mdb->vid, &db))
>> +		return 0;
>> +
>
> [Severity: Low]
> Should lan9645x_db_vid_unused() be checked before the VLAN_MAX check
> here?
>
> On a VLAN-unaware bridge, an MDB entry with a VID in 4032..4094 gets
> -EOPNOTSUPP on add. lan9645x_port_mdb_del() has no range check and
> returns 0 through lan9645x_db_vid_unused().
>
> That does not match the commit message, which says "3) An MDB entry can
> be added with any VID" and "they are accepted without being installed".
> It also does not match the comment above lan9645x_db_vid_unused():
>
>   so a delete skips exactly the entries that the add skipped.
>
> br_mdb_add() does not check the VID against the VLAN group when
> vlan_filtering is off, so a command like this reaches the driver:
>
>   bridge mdb add dev br0 port br0 grp 01:00:5e:01:01:01 permanent vid 4040
>
> For a host MDB the add fails, so dsa_port_do_mdb_add() never adds a
> dsa_mac_addr to cpu_dp->mdbs. The later delete then fails in
> dsa_port_do_mdb_del() with -ENOENT, and switchdev_port_obj_del_deferred()
> logs it as an error.
>
> The hardware ends up the same either way, since the entry is never
> installed.
>
> [ ... ]


      reply	other threads:[~2026-11-30  9:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  9:24 [PATCH net-next v2 0/5] net: dsa: lan9645x: add VLAN and bridge offload Jens Emil Schulz Østergaard
2026-11-27  9:24 ` [PATCH net-next v2 1/5] net: dsa: lan9645x: add the analyzer event register Jens Emil Schulz Østergaard
2026-11-27  9:24 ` [PATCH net-next v2 2/5] net: dsa: lan9645x: add vlan support Jens Emil Schulz Østergaard
2026-11-27  9:24 ` [PATCH net-next v2 3/5] net: dsa: lan9645x: add mac table integration Jens Emil Schulz Østergaard
2026-11-27  9:24 ` [PATCH net-next v2 4/5] net: dsa: lan9645x: add mdb management Jens Emil Schulz Østergaard
2026-11-28  9:30   ` netdev-bot+sashiko
2026-11-30  8:59     ` Jens Emil Schulz Østergaard
2026-11-27  9:24 ` [PATCH net-next v2 5/5] net: dsa: lan9645x: add bridge support Jens Emil Schulz Østergaard
2026-11-28  9:30   ` netdev-bot+sashiko
2026-11-30  9:03     ` Jens Emil Schulz Østergaard [this message]

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=DN8FAKUTL6X4.P73PYB87C6WA@microchip.com \
    --to=jensemil.schulzostergaard@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.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