[PATCH net v2] net: sparx5/lan969x: remove MDB entries on last bridge leave
Daniel Machon
daniel.machon at microchip.com
Thu Dec 3 04:28:35 PST 2026
> 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.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 0
>
> 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] In sparx5_port_bridge_join(), the patch now passes
> &sparx5->switchdev_blocking_nb as the blocking_nb argument to…
>
> --
>
> net: sparx5/lan969x: remove MDB entries on last bridge leave
>
> When the last port leaves the bridge, this patch flushes all MDB entries
> before hw_bridge_dev is cleared. MDB adds and deletes are ignored while no
> bridge is offloaded. To get host groups offloaded again on rejoin, the
> bridge is now asked to replay its objects through the blocking switchdev
> notifier when a port joins.
>
> > diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c b/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c
> > index dac4dd833127a..e52e6a7fbe64e 100644
> > --- a/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c
> > +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c
>
> [ ... ]
>
> > @@ -193,7 +217,8 @@ static int sparx5_port_bridge_join(struct sparx5_port *port,
> >
> > set_bit(port->portno, sparx5->bridge_mask);
> >
> > - err = switchdev_bridge_port_offload(ndev, ndev, NULL, NULL, NULL,
> > + err = switchdev_bridge_port_offload(ndev, ndev, port, NULL,
> > + &sparx5->switchdev_blocking_nb,
> > false, extack);
>
> [Severity: Medium]
> Can this call through a NULL notifier_call during probe?
>
> The bridge replay helpers do not go through the notifier chain. They call
> the nb passed here directly, and they only check that the nb pointer is
> non-NULL:
>
> net/bridge/br_switchdev.c:br_switchdev_vlan_replay_one() {
> ...
> err = nb->notifier_call(nb, action, &obj_info);
> return notifier_to_errno(err);
> }
>
> In sparx5_start(), the port netdevs are registered before the notifier
> blocks are set up:
>
> err = sparx5_register_netdevs(sparx5);
> ...
> err = sparx5_register_notifier_blocks(sparx5);
>
> Inside sparx5_register_notifier_blocks(), the netdevice notifier goes live
> before switchdev_blocking_nb.notifier_call is assigned:
>
> s5->netdevice_nb.notifier_call = sparx5_netdevice_event;
> err = register_netdevice_notifier(&s5->netdevice_nb);
> ...
> s5->switchdev_nb.notifier_call = sparx5_switchdev_event;
> err = register_switchdev_notifier(&s5->switchdev_nb);
> ...
> s5->switchdev_blocking_nb.notifier_call = sparx5_switchdev_blocking_event;
>
> The sparx5 struct is zero-allocated, so notifier_call stays NULL until that
> last assignment. If something like udev or networkd enslaves a port during
> that window, after register_netdevice_notifier() has dropped rtnl, the path
> would be:
>
> br_add_if()
> sparx5_netdevice_event() (NETDEV_CHANGEUPPER)
> sparx5_port_changeupper()
> sparx5_port_bridge_join()
> switchdev_bridge_port_offload()
> nbp_switchdev_sync_objs()
> br_switchdev_vlan_replay()
> br_switchdev_vlan_replay_one()
> nb->notifier_call(...) <-- NULL
>
> With CONFIG_BRIDGE_VLAN_FILTERING, the bridge always has its default VLAN 1
> entry, so this call is reached for any bridge. It would happen with rtnl
> held.
>
> Before this patch, blocking_nb was NULL and every replay helper returned
> early. Would it make sense to assign the notifier_call fields before
> register_netdevice_notifier(), or to initialize them statically?
Yes, it would. Will do so in v3.
pw-bot: cr
>
> > if (err)
> > goto err_switchdev_offload;
>
> [ ... ]
>
> --
> Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201-sparx5-mdb-bridge-leave-v2-1-127cacfcba6d%40microchip.com
>
More information about the linux-arm-kernel
mailing list