Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: idosch@nvidia.com
Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
	pabeni@redhat.com, edumazet@kernel.org, willemb@google.com,
	horms@kernel.org, razor@blackwall.org, dsahern@kernel.org,
	shuah@kernel.org, bridge@lists.linux.dev,
	linux-kselftest@vger.kernel.org, kyuwoncho18@gmail.com
Subject: Re: [PATCH net 2/2] selftests: bridge_mdb: Test failed source list replace
Date: Mon, 23 Nov 2026 07:28:03 +0000	[thread overview]
Message-ID: <179541888360.3135.4706984344785286288@kernel.org> (raw)
In-Reply-To: <20261122072504.2623702-2-idosch@nvidia.com>

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

  parent reply	other threads:[~2026-11-23  7:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=179541888360.3135.4706984344785286288@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=bridge@lists.linux.dev \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=kyuwoncho18@gmail.com \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=razor@blackwall.org \
    --cc=shuah@kernel.org \
    --cc=willemb@google.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