From: netdev-bot+sashiko@kernel.org
To: daniel.machon@microchip.com
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, Steen.Hegelund@microchip.com,
UNGLinuxDriver@microchip.com, casper.casan@gmail.com,
netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
haoxiang_li2024@163.com
Subject: Re: [PATCH net v3] net: sparx5/lan969x: remove MDB entries on last bridge leave
Date: Fri, 04 Dec 2026 15:13:57 +0000 [thread overview]
Message-ID: <179639723737.3146.2801107171885145585@kernel.org> (raw)
In-Reply-To: <20261203-sparx5-mdb-bridge-leave-v3-1-835c752ef628@microchip.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 (1) · Medium: 1 · Low: 0 (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 patch flushes all MDB entries, host groups included, on
the last bridge leave (sparx5_port_bridge_leave(),…
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but
sparx5_register_notifier_blocks() registers the atomic switchdev…
- [Low] The new ctx filter in sparx5_handle_port_obj_add() (`if
(info->info.ctx && info->info.ctx != netdev_priv(dev)) return 0;`,…
--
net: sparx5/lan969x: remove MDB entries on last bridge leave
This patch flushes all MDB entries when the last sparx5 port leaves the
bridge, before hw_bridge_dev is cleared. It also ignores MDB add/del while
no bridge is offloaded. To restore host groups, it has the bridge replay
its MDB on join and filters out replayed objects that belong to other
ports.
> diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c b/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c
> index dac4dd833127a..5bd5d3474e54a 100644
> --- a/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c
> +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c
[ ... ]
> @@ -227,8 +256,10 @@ static void sparx5_port_bridge_leave(struct sparx5_port *port,
> switchdev_bridge_port_unoffload(port->ndev, NULL, NULL, NULL);
>
> clear_bit(port->portno, sparx5->bridge_mask);
> - if (bitmap_empty(sparx5->bridge_mask, SPX5_PORTS))
> + if (bitmap_empty(sparx5->bridge_mask, SPX5_PORTS)) {
> + sparx5_mdb_flush(sparx5);
> sparx5->hw_bridge_dev = NULL;
> + }
[Severity: Medium]
This flush also removes the host groups. The commit message relies on the
MDB replay at the next join to bring them back. Is the replay guaranteed
to happen?
br_switchdev_mdb_replay() returns early when multicast snooping is off:
net/bridge/br_switchdev.c:br_switchdev_mdb_replay() {
...
if (!br_opt_get(br, BROPT_MULTICAST_ENABLED))
return 0;
...
}
Turning snooping back on in br_multicast_toggle() only calls
br_multicast_open() and br_multicast_enable_all_ports(). Nothing replays
the MDB to switchdev.
For example:
bridge mdb add dev br0 port br0 grp 239.1.1.1 permanent
ip link set br0 type bridge mcast_snooping 0
ip link set <last sparx5 port> nomaster -> sparx5_mdb_flush()
ip link set <port> master br0 -> replay skipped
ip link set br0 type bridge mcast_snooping 1
After this, the bridge MDB still has the host group, but the switch has no
PGID/MAC entry and no CPU copy for it. sparx5_port_bridge_join() unsyncs
the standalone mc list. Would the host then stop receiving this group's
traffic from the sparx5 ports?
Before this patch, the host group's hardware entry was not touched on
leave, so this sequence kept working.
>
> /* Clear bridge vlan settings before updating the port settings */
> port->vlan_aware = 0;
[ ... ]
> @@ -647,6 +677,9 @@ static int sparx5_handle_port_obj_add(struct net_device *dev,
> const struct switchdev_obj *obj = info->obj;
> int err;
>
> + if (info->info.ctx && info->info.ctx != netdev_priv(dev))
> + return 0;
> +
[Severity: Low]
This is a pre-existing issue rather than one introduced by this patch,
but this ctx check also drops replayed objects whose dev is the bridge
master.
br_switchdev_vlan_replay() replays the bridge's own VLAN group with dev
set to the bridge and ctx set to the port:
err = br_switchdev_vlan_replay_group(nb, br_dev, br_vlan_group(br),
ctx, action, extack);
netdev_priv() of the bridge is a struct net_bridge, which never matches
ctx. As a result, replay can never reach this branch in
sparx5_handle_port_vlan_add():
if (netif_is_bridge_master(dev)) {
...
sparx5_mact_learn(sparx5, sparx5_get_pgid(sparx5, PGID_BCAST),
dev->broadcast, v->vid);
return 0;
}
Normal notifications have a NULL ctx, so they still pass the check.
Before this patch there was no replay at all, so the broadcast entries for
bridge VLANs that existed before the blocking notifier was registered were
already missing.
Could bridge master objects be let through here, for example by checking
netif_is_bridge_master(dev) before the ctx comparison?
> switch (obj->id) {
> case SWITCHDEV_OBJ_ID_PORT_VLAN:
> err = sparx5_handle_port_vlan_add(dev, nb,
> @@ -748,6 +781,7 @@ int sparx5_register_notifier_blocks(struct sparx5 *s5)
> int err;
>
> s5->netdevice_nb.notifier_call = sparx5_netdevice_event;
> + s5->switchdev_blocking_nb.notifier_call = sparx5_switchdev_blocking_event;
> err = register_netdevice_notifier(&s5->netdevice_nb);
> if (err)
> return err;
> @@ -757,7 +791,6 @@ int sparx5_register_notifier_blocks(struct sparx5 *s5)
> if (err)
> goto err_switchdev_nb;
>
> - s5->switchdev_blocking_nb.notifier_call = sparx5_switchdev_blocking_event;
> err = register_switchdev_blocking_notifier(&s5->switchdev_blocking_nb);
> if (err)
> goto err_switchdev_blocking_nb;
[Severity: High]
This bug isn't introduced by this patch, but it sits in the ordering this
hunk touches. sparx5_register_notifier_blocks() registers switchdev_nb
before it allocates sparx5_owq. In the other direction,
sparx5_unregister_notifier_blocks() destroys sparx5_owq before it
unregisters switchdev_nb:
void sparx5_unregister_notifier_blocks(struct sparx5 *s5)
{
destroy_workqueue(sparx5_owq);
unregister_switchdev_blocking_notifier(&s5->switchdev_blocking_nb);
unregister_switchdev_notifier(&s5->switchdev_nb);
...
}
sparx5_switchdev_event() does not check that the device belongs to
sparx5. For SWITCHDEV_FDB_ADD_TO_DEVICE and SWITCHDEV_FDB_DEL_TO_DEVICE it
allocates a work item, takes dev_hold(), and calls:
static void sparx5_schedule_work(struct work_struct *work)
{
queue_work(sparx5_owq, work);
}
br_switchdev_fdb_notify() sends these events for FDB learning and ageing
on any bridge in the system, including software-only bridges.
During probe, can an FDB event between register_switchdev_notifier() and
alloc_ordered_workqueue() call queue_work() with a NULL sparx5_owq? The
window includes register_switchdev_blocking_notifier(), which can sleep.
mchp_sparx5_probe() has already registered the netdevs by then, so ports
can be in use.
During remove, can an FDB event between destroy_workqueue() and
unregister_switchdev_notifier() queue work on the freed workqueue? That
would also leak the work item and the device reference.
There is a related gap. The blocking notifier is still registered after
the netdevice notifier. If a port joins a bridge inside that window, could
objects that are not replayed be missed, such as the PVID VLAN added by
nbp_vlan_init()?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203-sparx5-mdb-bridge-leave-v3-1-835c752ef628%40microchip.com
prev parent reply other threads:[~2026-12-04 15:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 14:11 [PATCH net v3] net: sparx5/lan969x: remove MDB entries on last bridge leave Daniel Machon
2026-12-04 15:13 ` netdev-bot+sashiko [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=179639723737.3146.2801107171885145585@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=Steen.Hegelund@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew+netdev@lunn.ch \
--cc=casper.casan@gmail.com \
--cc=daniel.machon@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=haoxiang_li2024@163.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=netdev@vger.kernel.org \
--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