๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20780

Re: [PATCH net 2/2] selftests: bridge_mdb: Test failed source list replace

#20780
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 07:28
140 lines
13304 bytes
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
Technical Details
Message-ID: <179541888360.3135.4706984344785286288@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369106-linux-kernel-netdev=dewy.ru
References: <20261122072504.2623702-2-idosch@nvidia.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369106-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 2/2] selftests: bridge_mdb: Test failed source list replace
Date: Mon, 23 Nov 2026 07:28:03 +0000
Organization: Usenet Network
Message-ID: <179541888360.3135.4706984344785286288@kernel.org>
References: <20261122072504.2623702-2-idosch@nvidia.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3816568"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Bd3SdMRtNx/qkEDoX2qrB9fM0SA= sha256:JlQmg8NCpEZtiRpmXK4bW4ccWtOE9ZeCrlteaZZm/+E=
	sha1:eSUchfYiDRABmnI2m4ttVVpbcOc= sha256:XwCeaN2yOmMXnb9n02WIrxmW5ItXeXgGD8p8+PMTwDs=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id D4C94125D8F; Mon, 23 Nov 2026 10:28:22 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id QabtHEw-vP7H;
	Mon, 23 Nov 2026 10:28:19 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-369106-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id F085E125D94; Mon, 23 Nov 2026 10:28:10 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 4F2282CF8B; Mon, 23 Nov 2026 07:28:06 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795418886;
	b=F/e6EMwWLekfUYONafdBQiL5MNi66ccFuq9fOiLVS0aChb5f8NOqQvnNHp9Vv3Y7iPoU
	 FLiQ33zoTGCD052a5UOnS6AZkOW11fvnuBqNV2YDbAxq91suTxc5qVRm7BjKZsVvgWSPz
	 IHiGD8XR/sqAvXIp6pWJJnGwAZDvDjs6pbpMucRMgltuEJG5GJ5bN4OYd3uGrqrlQRlnG
	 VnfuSAf3OuItMeQSAKP45EPQJtZBx9y5e7uyk/w2dPm02j2tXzcVaCu8J3m99cth4OTrY
	 NxNJUplUhQb6rR21U9kOmpDjfGmWKdYRclCBlo6ZWNcFqOSBIKcR+BdBE9sjgHP2wCQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795418886;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=BFjNFEEl1ZT74xqErJR3pC77rX17KqsrmpJsd3ndC1c=;
	b=LDvYAaDgVRrvHkVmETsnlzBqjlcC71H4m/J2sTXfrRm/ET20YPSwakwwdwNyI+H5GFVg
	 kxR6Q0eA9hsqfHWzyX3kNPexWoX8jk2qzOgMWe/g0VHxWsGa4qj70nANNcYN+1wb4vA/g
	 52lmgJEXuq1afow4SO/fInmochyYCyR/DEGRHpCNCFvPkfLxFucEYQGGe4SSAbOrxK5yz
	 9VQzuWVyDe/XUdIlSOH6cIwtEvdMKYXb7Pus82cFqELNIU4HzaKaRdJ2U9V5XCe8iSyzR
	 fY7MkluZ7ecVhGEstwUe1B9pXC8ZpXx75jpFTrJ3XFF7ngOhhauyCT7dqEoScXs+oRA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Txo8TGOe;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 26B5A606A32A;
	Mon, 23 Nov 2026 07:28:06 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Txo8TGOe
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795418885;
	b=gmjGUb7kD5K6uG+u/yKujhtZZ5G2clsNGRqg8n9G/LvTt1CEVMQYVFeWxy0/WBojVLt/
	 8vT9nIDPm4ZkI4pw/ZWf35XxINXux36mLf65AgCdhUY9vgr6ksASytMs2PfexC7FNxm0J
	 G5BUfkb0duihdk8Rh6mjPDCwLHhvKqH+eIzybH6cDYhR0EJlxlM3oW49Dkh5B3NeslRx1
	 ZLivL9oojvdxd0A/HaGu6e2Y+IF3oYKfKwLytBcKHgs9dKiy1y4RR9PYVjn9HSjKE4K/G
	 2QVR3KCbjYQK/I7YKvXCnzkdLM3TkuhCGkb8f1xx2iEVFOhhX1BzWpPuSPQ6q4VRQBQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795418885;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=BFjNFEEl1ZT74xqErJR3pC77rX17KqsrmpJsd3ndC1c=;
	b=yFGh9qYpXtLYAhzuixkm7deWJp7qu2k6aFsc3jL9EpvHXcvr+diJpVWvmg1LcluGty90
	 pc4FF9BgcsQ7Dmh/EQiL4xi9QE4+FgFEWu+rNBE5ihspiU1AqSbRpKjQaMam2Z6rrNusa
	 QtWyVhT/kO3OpUujZy2Y6kvJhUD4Q/XrDak38snAprF3hEOwAlqYcxGyTdZryPjOIFtKR
	 ha/tWD7vX3NPuhL3/FUEfpTgEJN5fuPx91I4XiQm0puwJf1kzGhmo5lz/C07fkO3B6Fhl
	 zQcxc1swDjl20l//l9WNexKU3I899oHgu/7TvS8f+OKX7Nqy9exajcgmZXr8EY4HobQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Txo8TGOe;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48054606A32E;
	Mon, 23 Nov 2026 07:28:04 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D6CF1F000CF;
	Mon, 23 Nov 2026 07:28:04 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795418884;
	bh=BFjNFEEl1ZT74xqErJR3pC77rX17KqsrmpJsd3ndC1c=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=Txo8TGOeVw2zWIThv5bGWVZsmXDaNUK+q6gnWiORIoXhewj9czojPiJYAqgmcuvzM
	 fMk8LX9Pmds7/cH6qbiiIzYP5lHPVx6vcHJr2/gNTOO1YfL9oeDzTziRT5mO782ulC
	 44n3rtgnziBhKi97kCfmRkgv/gkqVSD3YXLWJ9aw6qd24upSWWw6IiK4m0JoDYMAU5
	 QQKtHbcwqKN0lT0r5H5uJzfX2v3KA7Y6+ulWoeTrDjc9aR59qGSvFIGz0T0viHnGpU
	 1jReja7KeCtGsU/ahGIZbuyLWeTagJCOSw8s7mUNEayOlUJ+gpKpZTzi7V2+Ci9pKW
	 eg8NVlDwgjsQg==
X-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
X-In-Reply-To: <20261122072504.2623702-2-idosch@nvidia.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list