Re: [PATCH net-next v2 5/5] net: dsa: lan9645x: add bridge support

From: Jens Emil Schulz Østergaard

Date: Mon Nov 30 2026 - 04:03:52 EST


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.
>
> [ ... ]