* [PATCH net 1/2] bridge: mcast: Fix source list rollback on failure
@ 2026-11-22 7:25 Ido Schimmel
2026-11-22 7:25 ` [PATCH net 2/2] selftests: bridge_mdb: Test failed source list replace Ido Schimmel
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Ido Schimmel @ 2026-11-22 7:25 UTC (permalink / raw)
To: netdev
Cc: davem, kuba, pabeni, edumazet, willemb, horms, razor, dsahern,
shuah, bridge, linux-kselftest, kyuwoncho18, Ido Schimmel, stable
When the bridge fails to add or replace an MDB entry with a source list,
br_mdb_add_group_srcs() rolls back the operation by looking up and
deleting the source entries of all the sources that were already
processed. This is wrong for two reasons.
First, with NLM_F_REPLACE, a source can appear more than once in the
source list. Its source entry is deleted when rolling back one
occurrence and the lookup fails for the other, triggering a
WARN_ON_ONCE() [1].
Second, when replacing an existing entry fails, sources from the new
source list that already existed before the replace are deleted together
with their (S, G) entries instead of being kept.
Fix by marking source entries that were created by the current operation
and only deleting them on failure.
[1]
WARNING: net/bridge/br_mdb.c:901 at br_mdb_add_group_srcs+0x310/0x440, CPU#10: repro/304
[...]
RIP: 0010:br_mdb_add_group_srcs (net/bridge/br_mdb.c:901 (discriminator 2) net/bridge/br_mdb.c:924 (discriminator 2))
[...]
Call Trace:
<TASK>
br_mdb_add_group_star_g (net/bridge/br_mdb.c:1021)
br_mdb_add_group (net/bridge/br_mdb.c:1082)
br_mdb_add (net/bridge/br_mdb.c:1097 net/bridge/br_mdb.c:1360)
rtnl_mdb_add (net/core/rtnetlink.c:6925)
rtnetlink_rcv_msg (net/core/rtnetlink.c:7178)
[...]
Fixes: 61f2183512a7 ("bridge: mcast: Support replacement of MDB port group entries")
Cc: stable@vger.kernel.org
Reported-by: Kyuwon Cho <kyuwoncho18@gmail.com>
Closes: https://lore.kernel.org/netdev/179489219555.3099318.10297266282803881244@gmail.com/
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
net/bridge/br_mdb.c | 29 ++++++++++++++---------------
net/bridge/br_private.h | 1 +
2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c
index 0adcd1524ab2..be65976c2f32 100644
--- a/net/bridge/br_mdb.c
+++ b/net/bridge/br_mdb.c
@@ -867,6 +867,7 @@ static int br_mdb_add_group_src(const struct br_mdb_config *cfg,
NL_SET_ERR_MSG_MOD(extack, "Failed to add new source entry");
return -ENOSPC;
}
+ ent->flags |= BR_SGRP_F_NEW;
} else if (!(cfg->nlflags & NLM_F_REPLACE)) {
NL_SET_ERR_MSG_MOD(extack, "Source entry already exists");
return -EEXIST;
@@ -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;
}
-static void br_mdb_del_group_src(struct net_bridge_port_group *pg,
- struct br_mdb_src_entry *src)
-{
- struct net_bridge_group_src *ent;
-
- ent = br_multicast_find_group_src(pg, &src->addr);
- if (WARN_ON_ONCE(!ent))
- return;
- br_multicast_del_group_src(ent, false);
-}
-
static int br_mdb_add_group_srcs(const struct br_mdb_config *cfg,
struct net_bridge_port_group *pg,
struct net_bridge_mcast *brmctx,
struct netlink_ext_ack *extack)
{
+ struct net_bridge_group_src *ent;
+ struct hlist_node *tmp;
int i, err;
for (i = 0; i < cfg->num_src_entries; i++) {
@@ -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);
+ }
return err;
}
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 014d0b8db8c7..97ad9d7bab27 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -347,6 +347,7 @@ struct net_bridge_fdb_flush_desc {
#define BR_SGRP_F_SEND BIT(1)
#define BR_SGRP_F_INSTALLED BIT(2)
#define BR_SGRP_F_USER_ADDED BIT(3)
+#define BR_SGRP_F_NEW BIT(4)
struct net_bridge_mcast_gc {
struct hlist_node gc_node;
--
2.56.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH net 2/2] selftests: bridge_mdb: Test failed source list replace 2026-11-22 7:25 [PATCH net 1/2] bridge: mcast: Fix source list rollback on failure Ido Schimmel @ 2026-11-22 7:25 ` Ido Schimmel 2026-11-22 10:23 ` Nikolay Aleksandrov 2026-11-23 7:28 ` netdev-bot+sashiko 2026-11-22 10:23 ` [PATCH net 1/2] bridge: mcast: Fix source list rollback on failure Nikolay Aleksandrov 2026-11-23 7:28 ` netdev-bot+sashiko 2 siblings, 2 replies; 7+ messages in thread From: Ido Schimmel @ 2026-11-22 7:25 UTC (permalink / raw) To: netdev Cc: davem, kuba, pabeni, edumazet, willemb, horms, razor, dsahern, shuah, bridge, linux-kselftest, kyuwoncho18, Ido Schimmel Add a test case for the issues that were fixed in "bridge: mcast: Fix source list rollback on failure". Check that a failed replace of a (*, G) entry does not change its source list, with one of the existing sources specified twice and a new source. Output without the fix: # ./bridge_mdb.sh [...] TEST: IPv4 (*, G) port group entries configuration tests [FAIL] (S, G) entry for source 192.0.2.1 deleted after failed replace TEST: IPv6 (*, G) port group entries configuration tests [FAIL] (S, G) entry for source 2001:db8:1::1 deleted after failed replace [...] Output with the fix: # ./bridge_mdb.sh [...] TEST: IPv4 (*, G) port group entries configuration tests [ OK ] TEST: IPv6 (*, G) port group entries configuration tests [ OK ] [...] Signed-off-by: Ido Schimmel <idosch@nvidia.com> --- .../selftests/net/forwarding/bridge_mdb.sh | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/bridge_mdb.sh b/tools/testing/selftests/net/forwarding/bridge_mdb.sh index e86d77946585..712b9a5a0e5f 100755 --- a/tools/testing/selftests/net/forwarding/bridge_mdb.sh +++ b/tools/testing/selftests/net/forwarding/bridge_mdb.sh @@ -293,6 +293,7 @@ __cfg_test_port_ip_star_g() local grp=$1; shift local invalid_grp=$1; shift local src_prefix=$1; shift + local invalid_src=$1; shift local src1=${src_prefix}1 local src2=${src_prefix}2 local src3=${src_prefix}3 @@ -487,6 +488,23 @@ __cfg_test_port_ip_star_g() bridge mdb del dev br0 port $swp1 grp $grp vid 10 + # Check that a failed replace does not change the source list. + bridge mdb add dev br0 port $swp1 grp $grp temp vid 10 \ + filter_mode exclude source_list $src1,$src2 + + bridge mdb replace dev br0 port $swp1 grp $grp temp vid 10 \ + filter_mode exclude source_list $src1,$src1,$src3,$invalid_src \ + &> /dev/null + check_fail $? "Managed to replace source list with an invalid source" + bridge -d mdb get dev br0 grp $grp src $src1 vid 10 &> /dev/null + check_err $? "(S, G) entry for source $src1 deleted after failed replace" + bridge -d mdb get dev br0 grp $grp src $src2 vid 10 &> /dev/null + check_err $? "(S, G) entry for source $src2 deleted after failed replace" + bridge -d mdb get dev br0 grp $grp src $src3 vid 10 &> /dev/null + check_fail $? "(S, G) entry for source $src3 created after failed replace" + + bridge mdb del dev br0 port $swp1 grp $grp vid 10 + # Check that protocol can be modified. bridge mdb add dev br0 port $swp1 grp $grp temp vid 10 \ filter_mode exclude source_list $src1 proto zebra @@ -568,8 +586,9 @@ cfg_test_port_ip_star_g() cfg_test_port_common "IPv4 (*, G)" "grp 239.1.1.1" cfg_test_port_common "IPv6 (*, G)" "grp ff0e::1" - __cfg_test_port_ip_star_g "IPv4" "239.1.1.1" "224.0.0.1" "192.0.2." - __cfg_test_port_ip_star_g "IPv6" "ff0e::1" "ff02::1" "2001:db8:1::" + __cfg_test_port_ip_star_g "IPv4" "239.1.1.1" "224.0.0.1" "192.0.2." \ + "0.0.0.0" + __cfg_test_port_ip_star_g "IPv6" "ff0e::1" "ff02::1" "2001:db8:1::" "::" } __cfg_test_port_ip_sg() -- 2.56.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net 2/2] selftests: bridge_mdb: Test failed source list replace 2026-11-22 7:25 ` [PATCH net 2/2] selftests: bridge_mdb: Test failed source list replace Ido Schimmel @ 2026-11-22 10:23 ` Nikolay Aleksandrov 2026-11-23 7:28 ` netdev-bot+sashiko 1 sibling, 0 replies; 7+ messages in thread From: Nikolay Aleksandrov @ 2026-11-22 10:23 UTC (permalink / raw) To: Ido Schimmel, netdev Cc: davem, kuba, pabeni, edumazet, willemb, horms, dsahern, shuah, bridge, linux-kselftest, kyuwoncho18 On 22/11/2026 09:25, Ido Schimmel wrote: > Add a test case for the issues that were fixed in "bridge: mcast: Fix > source list rollback on failure". Check that a failed replace of a > (*, G) entry does not change its source list, with one of the existing > sources specified twice and a new source. > > Output without the fix: > > # ./bridge_mdb.sh > [...] > TEST: IPv4 (*, G) port group entries configuration tests [FAIL] > (S, G) entry for source 192.0.2.1 deleted after failed replace > TEST: IPv6 (*, G) port group entries configuration tests [FAIL] > (S, G) entry for source 2001:db8:1::1 deleted after failed replace > [...] > > Output with the fix: > > # ./bridge_mdb.sh > [...] > TEST: IPv4 (*, G) port group entries configuration tests [ OK ] > TEST: IPv6 (*, G) port group entries configuration tests [ OK ] > [...] > > Signed-off-by: Ido Schimmel <idosch@nvidia.com> > --- > .../selftests/net/forwarding/bridge_mdb.sh | 23 +++++++++++++++++-- > 1 file changed, 21 insertions(+), 2 deletions(-) > Acked-by: Nikolay Aleksandrov <razor@blackwall.org> ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net 2/2] selftests: bridge_mdb: Test failed source list replace 2026-11-22 7:25 ` [PATCH net 2/2] selftests: bridge_mdb: Test failed source list replace Ido Schimmel 2026-11-22 10:23 ` Nikolay Aleksandrov @ 2026-11-23 7:28 ` netdev-bot+sashiko 1 sibling, 0 replies; 7+ messages in thread From: netdev-bot+sashiko @ 2026-11-23 7:28 UTC (permalink / raw) To: idosch Cc: netdev, davem, kuba, pabeni, edumazet, willemb, horms, razor, dsahern, shuah, bridge, linux-kselftest, kyuwoncho18 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] A failed (*, G) replace still leaves the existing sources partly changed, and the new test cannot see it. -- selftests: bridge_mdb: Test failed source list replace This commit adds a test case to __cfg_test_port_ip_star_g() in bridge_mdb.sh for the fix in "bridge: mcast: Fix source list rollback on failure". The replace request lists an existing source twice, then a new source, then an invalid source. The test checks that after the failed replace the existing (S, G) entries are still present and the new one was not created. > diff --git a/tools/testing/selftests/net/forwarding/bridge_mdb.sh b/tools/testing/selftests/net/forwarding/bridge_mdb.sh > index e86d779465853..712b9a5a0e5fe 100755 > --- a/tools/testing/selftests/net/forwarding/bridge_mdb.sh > +++ b/tools/testing/selftests/net/forwarding/bridge_mdb.sh [ ... ] > @@ -487,6 +488,23 @@ __cfg_test_port_ip_star_g() > > bridge mdb del dev br0 port $swp1 grp $grp vid 10 > > + # Check that a failed replace does not change the source list. > + bridge mdb add dev br0 port $swp1 grp $grp temp vid 10 \ > + filter_mode exclude source_list $src1,$src2 > + > + bridge mdb replace dev br0 port $swp1 grp $grp temp vid 10 \ > + filter_mode exclude source_list $src1,$src1,$src3,$invalid_src \ > + &> /dev/null > + check_fail $? "Managed to replace source list with an invalid source" > + bridge -d mdb get dev br0 grp $grp src $src1 vid 10 &> /dev/null > + check_err $? "(S, G) entry for source $src1 deleted after failed replace" > + bridge -d mdb get dev br0 grp $grp src $src2 vid 10 &> /dev/null > + check_err $? "(S, G) entry for source $src2 deleted after failed replace" > + bridge -d mdb get dev br0 grp $grp src $src3 vid 10 &> /dev/null > + check_fail $? "(S, G) entry for source $src3 created after failed replace" [Severity: Medium] The add and the failed replace both use temp, filter_mode exclude and the default proto. The test then only checks whether the (S, G) entries exist. Would a partly applied replace of an existing source be caught here? In net/bridge/br_mdb.c the replace path is: br_mdb_replace_group_star_g() br_mdb_replace_group_srcs() br_mdb_add_group_srcs() br_mdb_add_group_src() <- once per source, in order For a source that already exists, br_mdb_add_group_src() changes its timer and replaces its (S, G) entry before the later sources are processed: net/bridge/br_mdb.c:br_mdb_add_group_src() { ... 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); /* Install a (S, G) forwarding entry for the source. */ err = br_mdb_add_group_src_fwd(cfg, &src->addr, brmctx, extack); ... } br_mdb_add_group_src_fwd()->br_mdb_add_group_sg()->br_mdb_replace_group_sg() then rewrites the existing (S, G) port group and notifies userspace: net/bridge/br_mdb.c:br_mdb_replace_group_sg() { ... pg->flags = flags; pg->rt_protocol = cfg->rt_protocol; ... br_mdb_notify(cfg->br->dev, mp, pg, RTM_NEWMDB); ... } A later source can fail. In this test that is 0.0.0.0 or ::, where br_multicast_new_group_src() returns NULL and the call returns -ENOSPC. The rollback then only removes BR_SGRP_F_NEW entries and clears BR_SGRP_F_DELETE: br_mdb_add_group_srcs(): err_del_group_srcs: 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); } return err; br_mdb_replace_group_srcs(): err_clear_delete: hlist_for_each_entry(ent, &pg->src_list, node) ent->flags &= ~BR_SGRP_F_DELETE; return err; br_mdb_replace_group_star_g() then returns early. The (*, G) port group keeps its old flags, filter_mode and protocol. Its existing sources and their (S, G) entries keep the new settings. For example: bridge mdb add ... temp filter_mode include source_list S1 bridge mdb replace ... permanent filter_mode include source_list S1,0.0.0.0 Does this delete S1's source timer, so the temporary INCLUDE entry never ages out? Does it also leave the (S, G) entry PERMANENT while the (*, G) entry is still temporary? Userspace would also get an RTM_NEWMDB notification for a request that failed. Before this series, the rollback deleted every source it had processed, so the changed state did not survive. "bridge: mcast: Fix source list rollback on failure" now keeps the existing entries, which leaves the changed state in place. Should that fix also restore the timer and (S, G) state of the existing sources? Could the replace in this test also use different attributes, for example permanent, filter_mode include or a different proto? It could then check that the existing (S, G) entries keep their original flags, protocol and timer. [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122072504.2623702-1-idosch%40nvidia.com ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net 1/2] bridge: mcast: Fix source list rollback on failure 2026-11-22 7:25 [PATCH net 1/2] bridge: mcast: Fix source list rollback on failure Ido Schimmel 2026-11-22 7:25 ` [PATCH net 2/2] selftests: bridge_mdb: Test failed source list replace Ido Schimmel @ 2026-11-22 10:23 ` Nikolay Aleksandrov 2026-11-23 7:28 ` netdev-bot+sashiko 2 siblings, 0 replies; 7+ messages in thread From: Nikolay Aleksandrov @ 2026-11-22 10:23 UTC (permalink / raw) To: Ido Schimmel, netdev Cc: davem, kuba, pabeni, edumazet, willemb, horms, dsahern, shuah, bridge, linux-kselftest, kyuwoncho18, stable On 22/11/2026 09:25, Ido Schimmel wrote: > When the bridge fails to add or replace an MDB entry with a source list, > br_mdb_add_group_srcs() rolls back the operation by looking up and > deleting the source entries of all the sources that were already > processed. This is wrong for two reasons. > > First, with NLM_F_REPLACE, a source can appear more than once in the > source list. Its source entry is deleted when rolling back one > occurrence and the lookup fails for the other, triggering a > WARN_ON_ONCE() [1]. > > Second, when replacing an existing entry fails, sources from the new > source list that already existed before the replace are deleted together > with their (S, G) entries instead of being kept. > > Fix by marking source entries that were created by the current operation > and only deleting them on failure. > > [1] > WARNING: net/bridge/br_mdb.c:901 at br_mdb_add_group_srcs+0x310/0x440, CPU#10: repro/304 > [...] > RIP: 0010:br_mdb_add_group_srcs (net/bridge/br_mdb.c:901 (discriminator 2) net/bridge/br_mdb.c:924 (discriminator 2)) > [...] > Call Trace: > <TASK> > br_mdb_add_group_star_g (net/bridge/br_mdb.c:1021) > br_mdb_add_group (net/bridge/br_mdb.c:1082) > br_mdb_add (net/bridge/br_mdb.c:1097 net/bridge/br_mdb.c:1360) > rtnl_mdb_add (net/core/rtnetlink.c:6925) > rtnetlink_rcv_msg (net/core/rtnetlink.c:7178) > [...] > > Fixes: 61f2183512a7 ("bridge: mcast: Support replacement of MDB port group entries") > Cc: stable@vger.kernel.org > Reported-by: Kyuwon Cho <kyuwoncho18@gmail.com> > Closes: https://lore.kernel.org/netdev/179489219555.3099318.10297266282803881244@gmail.com/ > Signed-off-by: Ido Schimmel <idosch@nvidia.com> > --- > net/bridge/br_mdb.c | 29 ++++++++++++++--------------- > net/bridge/br_private.h | 1 + > 2 files changed, 15 insertions(+), 15 deletions(-) > Acked-by: Nikolay Aleksandrov <razor@blackwall.org> ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net 1/2] bridge: mcast: Fix source list rollback on failure 2026-11-22 7:25 [PATCH net 1/2] bridge: mcast: Fix source list rollback on failure Ido Schimmel 2026-11-22 7:25 ` [PATCH net 2/2] selftests: bridge_mdb: Test failed source list replace Ido Schimmel 2026-11-22 10:23 ` [PATCH net 1/2] bridge: mcast: Fix source list rollback on failure Nikolay Aleksandrov @ 2026-11-23 7:28 ` netdev-bot+sashiko 2026-11-23 8:05 ` Ido Schimmel 2 siblings, 1 reply; 7+ messages in thread From: netdev-bot+sashiko @ 2026-11-23 7:28 UTC (permalink / raw) To: idosch Cc: netdev, davem, kuba, pabeni, edumazet, willemb, horms, razor, dsahern, shuah, bridge, linux-kselftest, kyuwoncho18 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net 1/2] bridge: mcast: Fix source list rollback on failure 2026-11-23 7:28 ` netdev-bot+sashiko @ 2026-11-23 8:05 ` Ido Schimmel 0 siblings, 0 replies; 7+ messages in thread From: Ido Schimmel @ 2026-11-23 8:05 UTC (permalink / raw) To: netdev-bot+sashiko Cc: netdev, davem, kuba, pabeni, edumazet, willemb, horms, razor, dsahern, shuah, bridge, linux-kselftest, kyuwoncho18 tl;dr - I believe the patch is fine as-is. On Mon, Nov 23, 2026 at 07:28:02AM +0000, netdev-bot+sashiko@kernel.org wrote: > [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? No, but before that they were deleted (and a warning was emitted when a source was specified twice), which is worse. Making the replace fully atomic is a much bigger change that is not suitable for net and it's not worth the complexity given the failure is very unlikely in practice. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-23 8:05 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-22 7:25 [PATCH net 1/2] bridge: mcast: Fix source list rollback on failure Ido Schimmel 2026-11-22 7:25 ` [PATCH net 2/2] selftests: bridge_mdb: Test failed source list replace Ido Schimmel 2026-11-22 10:23 ` Nikolay Aleksandrov 2026-11-23 7:28 ` netdev-bot+sashiko 2026-11-22 10:23 ` [PATCH net 1/2] bridge: mcast: Fix source list rollback on failure Nikolay Aleksandrov 2026-11-23 7:28 ` netdev-bot+sashiko 2026-11-23 8:05 ` Ido Schimmel
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox