* [PATCH net-next 1/2] net: bridge: Flush multicast groups when snooping is disabled
@ 2025-10-23 14:45 Petr Machata
2025-10-23 14:45 ` [PATCH net-next 2/2] selftests: bridge_mdb: Add a test for MDB flush on snooping disable Petr Machata
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Petr Machata @ 2025-10-23 14:45 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
netdev
Cc: Simon Horman, Ido Schimmel, Nikolay Aleksandrov, bridge,
Petr Machata, mlxsw
When forwarding multicast packets, the bridge takes MDB into account when
IGMP / MLD snooping is enabled. Currently, when snooping is disabled, the
MDB is retained, even though it is not used anymore.
At the same time, during the time that snooping is disabled, the IGMP / MLD
control packets are obviously ignored, and after the snooping is reenabled,
the administrator has to assume it is out of sync. In particular, missed
join and leave messages would lead to traffic being forwarded to wrong
interfaces.
Keeping the MDB entries around thus serves no purpose, and just takes
memory. Note also that disabling per-VLAN snooping does actually flush the
relevant MDB entries.
This patch flushes non-permanent MDB entries as global snooping is
disabled.
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
---
net/bridge/br_multicast.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index 22d12e545966..d55a4ab87837 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -4649,6 +4649,14 @@ static void br_multicast_start_querier(struct net_bridge_mcast *brmctx,
rcu_read_unlock();
}
+static void br_multicast_del_grps(struct net_bridge *br)
+{
+ struct net_bridge_port *port;
+
+ list_for_each_entry(port, &br->port_list, list)
+ __br_multicast_disable_port_ctx(&port->multicast_ctx);
+}
+
int br_multicast_toggle(struct net_bridge *br, unsigned long val,
struct netlink_ext_ack *extack)
{
@@ -4669,6 +4677,7 @@ int br_multicast_toggle(struct net_bridge *br, unsigned long val,
br_opt_toggle(br, BROPT_MULTICAST_ENABLED, !!val);
if (!br_opt_get(br, BROPT_MULTICAST_ENABLED)) {
change_snoopers = true;
+ br_multicast_del_grps(br);
goto unlock;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH net-next 2/2] selftests: bridge_mdb: Add a test for MDB flush on snooping disable
2025-10-23 14:45 [PATCH net-next 1/2] net: bridge: Flush multicast groups when snooping is disabled Petr Machata
@ 2025-10-23 14:45 ` Petr Machata
2025-10-24 7:43 ` Nikolay Aleksandrov
2025-10-24 7:42 ` [PATCH net-next 1/2] net: bridge: Flush multicast groups when snooping is disabled Nikolay Aleksandrov
2025-10-28 1:10 ` patchwork-bot+netdevbpf
2 siblings, 1 reply; 5+ messages in thread
From: Petr Machata @ 2025-10-23 14:45 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
netdev
Cc: Simon Horman, Ido Schimmel, Nikolay Aleksandrov, bridge,
Petr Machata, mlxsw, linux-kselftest, Shuah Khan
Check that non-permanent MDB entries are removed as IGMP / MLD snooping is
disabled.
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
---
Notes:
CC: linux-kselftest@vger.kernel.org
CC: Shuah Khan <shuah@kernel.org>
.../selftests/net/forwarding/bridge_mdb.sh | 100 +++++++++++++++++-
1 file changed, 98 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/net/forwarding/bridge_mdb.sh b/tools/testing/selftests/net/forwarding/bridge_mdb.sh
index 8c1597ebc2d3..e86d77946585 100755
--- a/tools/testing/selftests/net/forwarding/bridge_mdb.sh
+++ b/tools/testing/selftests/net/forwarding/bridge_mdb.sh
@@ -28,6 +28,7 @@ ALL_TESTS="
cfg_test
fwd_test
ctrl_test
+ disable_test
"
NUM_NETIFS=4
@@ -64,7 +65,10 @@ h2_destroy()
switch_create()
{
- ip link add name br0 type bridge vlan_filtering 1 vlan_default_pvid 0 \
+ local vlan_filtering=$1; shift
+
+ ip link add name br0 type bridge \
+ vlan_filtering "$vlan_filtering" vlan_default_pvid 0 \
mcast_snooping 1 mcast_igmp_version 3 mcast_mld_version 2
bridge vlan add vid 10 dev br0 self
bridge vlan add vid 20 dev br0 self
@@ -118,7 +122,7 @@ setup_prepare()
h1_create
h2_create
- switch_create
+ switch_create 1
}
cleanup()
@@ -1357,6 +1361,98 @@ ctrl_test()
ctrl_mldv2_is_in_test
}
+check_group()
+{
+ local group=$1; shift
+ local vid=$1; shift
+ local should_fail=$1; shift
+ local when=$1; shift
+ local -a vidkws
+
+ if ((vid)); then
+ vidkws=(vid "$vid")
+ fi
+
+ bridge mdb get dev br0 grp "$group" "${vidkws[@]}" 2>/dev/null |
+ grep -q "port $swp1"
+ check_err_fail "$should_fail" $? "$group seen $when snooping disable:"
+}
+
+__disable_test()
+{
+ local vid=$1; shift
+ local what=$1; shift
+ local -a vidkws
+
+ if ((vid)); then
+ vidkws=(vid "$vid")
+ fi
+
+ RET=0
+
+ bridge mdb add dev br0 port "$swp1" grp ff0e::1 permanent \
+ "${vidkws[@]}" filter_mode include source_list 2001:db8:1::1
+ bridge mdb add dev br0 port "$swp1" grp ff0e::2 permanent \
+ "${vidkws[@]}" filter_mode exclude
+
+ bridge mdb add dev br0 port "$swp1" grp ff0e::3 \
+ "${vidkws[@]}" filter_mode include source_list 2001:db8:1::2
+ bridge mdb add dev br0 port "$swp1" grp ff0e::4 \
+ "${vidkws[@]}" filter_mode exclude
+
+ bridge mdb add dev br0 port "$swp1" grp 239.1.1.1 permanent \
+ "${vidkws[@]}" filter_mode include source_list 192.0.2.1
+ bridge mdb add dev br0 port "$swp1" grp 239.1.1.2 permanent \
+ "${vidkws[@]}" filter_mode exclude
+
+ bridge mdb add dev br0 port "$swp1" grp 239.1.1.3 \
+ "${vidkws[@]}" filter_mode include source_list 192.0.2.2
+ bridge mdb add dev br0 port "$swp1" grp 239.1.1.4 \
+ "${vidkws[@]}" filter_mode exclude
+
+ check_group ff0e::1 "$vid" 0 "before"
+ check_group ff0e::2 "$vid" 0 "before"
+ check_group ff0e::3 "$vid" 0 "before"
+ check_group ff0e::4 "$vid" 0 "before"
+
+ check_group 239.1.1.1 "$vid" 0 "before"
+ check_group 239.1.1.2 "$vid" 0 "before"
+ check_group 239.1.1.3 "$vid" 0 "before"
+ check_group 239.1.1.4 "$vid" 0 "before"
+
+ ip link set dev br0 type bridge mcast_snooping 0
+
+ check_group ff0e::1 "$vid" 0 "after"
+ check_group ff0e::2 "$vid" 0 "after"
+ check_group ff0e::3 "$vid" 1 "after"
+ check_group ff0e::4 "$vid" 1 "after"
+
+ check_group 239.1.1.1 "$vid" 0 "after"
+ check_group 239.1.1.2 "$vid" 0 "after"
+ check_group 239.1.1.3 "$vid" 1 "after"
+ check_group 239.1.1.4 "$vid" 1 "after"
+
+ log_test "$what: Flush after disable"
+
+ ip link set dev br0 type bridge mcast_snooping 1
+ sleep 10
+}
+
+disable_test()
+{
+ __disable_test 10 802.1q
+
+ switch_destroy
+ switch_create 0
+ setup_wait
+
+ __disable_test 0 802.1d
+
+ switch_destroy
+ switch_create 1
+ setup_wait
+}
+
if ! bridge mdb help 2>&1 | grep -q "flush"; then
echo "SKIP: iproute2 too old, missing bridge mdb flush support"
exit $ksft_skip
--
2.49.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH net-next 2/2] selftests: bridge_mdb: Add a test for MDB flush on snooping disable
2025-10-23 14:45 ` [PATCH net-next 2/2] selftests: bridge_mdb: Add a test for MDB flush on snooping disable Petr Machata
@ 2025-10-24 7:43 ` Nikolay Aleksandrov
0 siblings, 0 replies; 5+ messages in thread
From: Nikolay Aleksandrov @ 2025-10-24 7:43 UTC (permalink / raw)
To: Petr Machata, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, netdev
Cc: Simon Horman, Ido Schimmel, bridge, mlxsw, linux-kselftest,
Shuah Khan
On 10/23/25 17:45, Petr Machata wrote:
> Check that non-permanent MDB entries are removed as IGMP / MLD snooping is
> disabled.
>
> Signed-off-by: Petr Machata <petrm@nvidia.com>
> Reviewed-by: Ido Schimmel <idosch@nvidia.com>
> ---
>
> Notes:
> CC: linux-kselftest@vger.kernel.org
> CC: Shuah Khan <shuah@kernel.org>
>
> .../selftests/net/forwarding/bridge_mdb.sh | 100 +++++++++++++++++-
> 1 file changed, 98 insertions(+), 2 deletions(-)
>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 1/2] net: bridge: Flush multicast groups when snooping is disabled
2025-10-23 14:45 [PATCH net-next 1/2] net: bridge: Flush multicast groups when snooping is disabled Petr Machata
2025-10-23 14:45 ` [PATCH net-next 2/2] selftests: bridge_mdb: Add a test for MDB flush on snooping disable Petr Machata
@ 2025-10-24 7:42 ` Nikolay Aleksandrov
2025-10-28 1:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: Nikolay Aleksandrov @ 2025-10-24 7:42 UTC (permalink / raw)
To: Petr Machata, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, netdev
Cc: Simon Horman, Ido Schimmel, bridge, mlxsw
On 10/23/25 17:45, Petr Machata wrote:
> When forwarding multicast packets, the bridge takes MDB into account when
> IGMP / MLD snooping is enabled. Currently, when snooping is disabled, the
> MDB is retained, even though it is not used anymore.
>
> At the same time, during the time that snooping is disabled, the IGMP / MLD
> control packets are obviously ignored, and after the snooping is reenabled,
> the administrator has to assume it is out of sync. In particular, missed
> join and leave messages would lead to traffic being forwarded to wrong
> interfaces.
>
> Keeping the MDB entries around thus serves no purpose, and just takes
> memory. Note also that disabling per-VLAN snooping does actually flush the
> relevant MDB entries.
>
> This patch flushes non-permanent MDB entries as global snooping is
> disabled.
>
> Signed-off-by: Petr Machata <petrm@nvidia.com>
> Reviewed-by: Ido Schimmel <idosch@nvidia.com>
> ---
> net/bridge/br_multicast.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
> index 22d12e545966..d55a4ab87837 100644
> --- a/net/bridge/br_multicast.c
> +++ b/net/bridge/br_multicast.c
> @@ -4649,6 +4649,14 @@ static void br_multicast_start_querier(struct net_bridge_mcast *brmctx,
> rcu_read_unlock();
> }
>
> +static void br_multicast_del_grps(struct net_bridge *br)
> +{
> + struct net_bridge_port *port;
> +
> + list_for_each_entry(port, &br->port_list, list)
> + __br_multicast_disable_port_ctx(&port->multicast_ctx);
> +}
> +
> int br_multicast_toggle(struct net_bridge *br, unsigned long val,
> struct netlink_ext_ack *extack)
> {
> @@ -4669,6 +4677,7 @@ int br_multicast_toggle(struct net_bridge *br, unsigned long val,
> br_opt_toggle(br, BROPT_MULTICAST_ENABLED, !!val);
> if (!br_opt_get(br, BROPT_MULTICAST_ENABLED)) {
> change_snoopers = true;
> + br_multicast_del_grps(br);
> goto unlock;
> }
>
I've actually thought about this, disabling multicast has always been weird in the
bridge and I think this is an improvement:
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH net-next 1/2] net: bridge: Flush multicast groups when snooping is disabled
2025-10-23 14:45 [PATCH net-next 1/2] net: bridge: Flush multicast groups when snooping is disabled Petr Machata
2025-10-23 14:45 ` [PATCH net-next 2/2] selftests: bridge_mdb: Add a test for MDB flush on snooping disable Petr Machata
2025-10-24 7:42 ` [PATCH net-next 1/2] net: bridge: Flush multicast groups when snooping is disabled Nikolay Aleksandrov
@ 2025-10-28 1:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-10-28 1:10 UTC (permalink / raw)
To: Petr Machata
Cc: davem, edumazet, kuba, pabeni, netdev, horms, idosch, razor,
bridge, mlxsw
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 23 Oct 2025 16:45:37 +0200 you wrote:
> When forwarding multicast packets, the bridge takes MDB into account when
> IGMP / MLD snooping is enabled. Currently, when snooping is disabled, the
> MDB is retained, even though it is not used anymore.
>
> At the same time, during the time that snooping is disabled, the IGMP / MLD
> control packets are obviously ignored, and after the snooping is reenabled,
> the administrator has to assume it is out of sync. In particular, missed
> join and leave messages would lead to traffic being forwarded to wrong
> interfaces.
>
> [...]
Here is the summary with links:
- [net-next,1/2] net: bridge: Flush multicast groups when snooping is disabled
https://git.kernel.org/netdev/net-next/c/68800bbf583f
- [net-next,2/2] selftests: bridge_mdb: Add a test for MDB flush on snooping disable
https://git.kernel.org/netdev/net-next/c/d10920607ffe
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-10-28 1:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-23 14:45 [PATCH net-next 1/2] net: bridge: Flush multicast groups when snooping is disabled Petr Machata
2025-10-23 14:45 ` [PATCH net-next 2/2] selftests: bridge_mdb: Add a test for MDB flush on snooping disable Petr Machata
2025-10-24 7:43 ` Nikolay Aleksandrov
2025-10-24 7:42 ` [PATCH net-next 1/2] net: bridge: Flush multicast groups when snooping is disabled Nikolay Aleksandrov
2025-10-28 1:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).