Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by netdev-bot+sashiko
Mon, 23 Nov 2026 07:28
Re: [PATCH net 1/2] bridge: mcast: Fix source list rollback on failure
Author: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 07:28
Date: Mon, 23 Nov 2026 07:28
160 lines
13482 bytes
13482 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · 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).
- [High] This patch makes a failed `NLM_F_REPLACE` keep the (*, G) source
entries that existed before the request, but it keeps them in the…
--
bridge: mcast: Fix source list rollback on failure
This commit changes the rollback in br_mdb_add_group_srcs(). On failure, it
now deletes only the source entries that the current add or replace
operation created, marked with a new BR_SGRP_F_NEW flag. Source entries
that existed before an NLM_F_REPLACE request are kept, which also avoids a
WARN_ON_ONCE() when a source appears more than once in the list.
Closes: https://lore.kernel.org/netdev/179489219555.3099318.10297266282803881244@gmail.com/
> diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c
> index 0adcd1524ab24..be65976c2f32f 100644
> --- a/net/bridge/br_mdb.c
> +++ b/net/bridge/br_mdb.c
[ ... ]
> @@ -883,31 +884,24 @@ static int br_mdb_add_group_src(const struct br_mdb_config *cfg,
> if (err)
> goto err_del_sg;
>
> - ent->flags = BR_SGRP_F_INSTALLED | BR_SGRP_F_USER_ADDED;
> + ent->flags = BR_SGRP_F_INSTALLED | BR_SGRP_F_USER_ADDED |
> + (ent->flags & BR_SGRP_F_NEW);
>
> return 0;
>
> err_del_sg:
> - __br_multicast_del_group_src(ent);
> + if (ent->flags & BR_SGRP_F_NEW)
> + __br_multicast_del_group_src(ent);
> return err;
> }
[ ... ]
> @@ -917,11 +911,16 @@ static int br_mdb_add_group_srcs(const struct br_mdb_config *cfg,
> goto err_del_group_srcs;
> }
>
> + hlist_for_each_entry(ent, &pg->src_list, node)
> + ent->flags &= ~BR_SGRP_F_NEW;
> +
> return 0;
>
> err_del_group_srcs:
> - for (i--; i >= 0; i--)
> - br_mdb_del_group_src(pg, &cfg->src_entries[i]);
> + hlist_for_each_entry_safe(ent, tmp, &pg->src_list, node) {
> + if (ent->flags & BR_SGRP_F_NEW)
> + br_multicast_del_group_src(ent, false);
> + }
[Severity: High]
With NLM_F_REPLACE, the pre-existing sources that are now kept on failure
were already changed by br_mdb_add_group_src() earlier in the loop. Is that
state ever restored?
For each pre-existing source in the new list, br_mdb_add_group_src() first
changes the source timer:
if (cfg->filter_mode == MCAST_INCLUDE &&
cfg->entry->state == MDB_TEMPORARY)
mod_timer(&ent->timer, now + br_multicast_gmi(brmctx));
else
timer_delete(&ent->timer);
Then this call chain rewrites the existing (S, G) port group and notifies
user space:
br_mdb_add_group_src_fwd()
br_mdb_add_group_sg()
br_mdb_replace_group_sg()
pg->flags = flags;
pg->rt_protocol = cfg->rt_protocol;
...
br_mdb_notify(cfg->br->dev, mp, pg, RTM_NEWMDB);
Finally, the ent->flags assignment above overwrites the source flags and
drops bits such as BR_SGRP_F_SEND.
If a later source fails, this loop deletes only the BR_SGRP_F_NEW entries.
br_mdb_replace_group_star_g() then returns before it updates the parent:
err = br_mdb_replace_group_srcs(cfg, pg, brmctx, extack);
if (err)
return err;
pg->flags = flags;
pg->filter_mode = cfg->filter_mode;
...
So the (*, G) keeps its old configuration, but the kept sources and their
(S, G) entries carry the new one. User space has also already received
RTM_NEWMDB for the (S, G) changes.
This failure is easy to trigger. A source of 0.0.0.0 or :: passes
is_valid_mdb_source(), but br_multicast_new_group_src() rejects it, so the
request fails with -ENOSPC. The selftest in the next patch ("selftests:
bridge_mdb: Test failed source list replace") uses this trigger. It only
checks that the (S, G) entries still exist, not their flags or timers.
Some states this can leave behind:
(a) A permanent INCLUDE (*, G) {S1} is replaced with a temporary INCLUDE
source list S1,0.0.0.0. S1's timer is now armed on a permanent pg, and
(S1, G) has lost MDB_PG_FLAGS_PERMANENT. After GMI,
br_multicast_group_src_expired() sees INCLUDE mode and does this:
if (pg->filter_mode == MCAST_INCLUDE) {
br_multicast_del_group_src(src, false);
if (!hlist_empty(&pg->src_list))
goto out;
br_multicast_find_del_pg(br, pg);
That deletes S1 and its (S1, G) entry, and then the permanent (*, G) entry.
(b) A temporary INCLUDE (*, G) {S1} is replaced with a permanent
S1,0.0.0.0. S1's timer is deleted, and the pg timer is only armed in
EXCLUDE mode, so the temporary entry never ages out.
(c) An EXCLUDE (*, G) {S1} is replaced with INCLUDE S1,0.0.0.0. (S1, G)
loses MDB_PG_FLAGS_BLOCKED while (*, G) is still EXCLUDE with S1 listed.
Traffic from S1 is then forwarded to a port that should exclude it.
The commit message says this patch fixes the case where:
sources from the new source list that already existed before the replace
are deleted together with their (S, G) entries instead of being kept.
In case (a), aren't those sources and their (S, G) entries still deleted,
only one GMI later, together with the permanent (*, G) entry?
Could the replace path validate or allocate everything before it touches
existing entries? Alternatively, it could save the per-source and (S, G)
state and restore it on failure.
> return err;
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122072504.2623702-1-idosch%40nvidia.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads