From nobody Sun Feb 8 04:34:22 2026 Received: from mail.aperture-lab.de (mail.aperture-lab.de [116.203.183.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB34E2773F0; Fri, 6 Feb 2026 03:01:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.183.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346899; cv=none; b=ixFVCU20+zELQxpqc8zyHvQovbpuIwmUY1BQveCrnMBTdcOcxOwnAnXreUKiccbExfZhUWdYa/CQUuaLWvs29Rp6Yvw1p2PchRmSI/OG37Oht/9p910MpdsClLg1nhhQrstVrP1pzJEFtp1vCu63+2X7nUNlx5M12UKBLK8J8qE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346899; c=relaxed/simple; bh=dz0XB9CYvpy8wlOF/lmO9X6VavxLxXyiD3askDODYG0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BNqkb9zWSJl6RXCoCeCHRkR0k6w6XaYLtrxufw/DYbuLrbrnBoX2MEIeeSu59ov2UtCynJ9PjddO3IMFXBbMCgqnEqjwz6aCZD56SDylNaMBqOdtlPUPaKXRO18fUSO7hrLlKZ4sW3dVVKCkMZtFCvO9eePKfUDZ9ImeI+lpvC8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue; spf=pass smtp.mailfrom=c0d3.blue; arc=none smtp.client-ip=116.203.183.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c0d3.blue Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 2FB3A54CCE1; Fri, 6 Feb 2026 04:01:36 +0100 (CET) From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: bridge@lists.linux.dev Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nikolay Aleksandrov , Ido Schimmel , Andrew Lunn , Simon Horman , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S . Miller" , Kuniyuki Iwashima , Stanislav Fomichev , Xiao Liang , =?UTF-8?q?Linus=20L=C3=BCssing?= Subject: [PATCH net-next v2 01/14] net: bridge: mcast: export ip{4,6}_active state to netlink Date: Fri, 6 Feb 2026 03:52:07 +0100 Message-ID: <20260206030123.5430-2-linus.luessing@c0d3.blue> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260206030123.5430-1-linus.luessing@c0d3.blue> References: <20260206030123.5430-1-linus.luessing@c0d3.blue> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Export the new ip{4,6}_active variables to netlink, to be able to check from userspace that they are updated as intended. Signed-off-by: Linus L=C3=BCssing --- include/uapi/linux/if_bridge.h | 2 ++ include/uapi/linux/if_link.h | 12 ++++++++++++ net/bridge/br_netlink.c | 16 +++++++++++++++- net/bridge/br_private.h | 2 +- net/bridge/br_vlan_options.c | 22 ++++++++++++++++++++-- net/core/rtnetlink.c | 2 +- 6 files changed, 51 insertions(+), 5 deletions(-) diff --git a/include/uapi/linux/if_bridge.h b/include/uapi/linux/if_bridge.h index e52f8207ab27..910103b1ef03 100644 --- a/include/uapi/linux/if_bridge.h +++ b/include/uapi/linux/if_bridge.h @@ -584,6 +584,8 @@ enum { BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS, BRIDGE_VLANDB_GOPTS_MCAST_QUERIER_STATE, BRIDGE_VLANDB_GOPTS_MSTI, + BRIDGE_VLANDB_GOPTS_MCAST_ACTIVE_V4, + BRIDGE_VLANDB_GOPTS_MCAST_ACTIVE_V6, __BRIDGE_VLANDB_GOPTS_MAX }; #define BRIDGE_VLANDB_GOPTS_MAX (__BRIDGE_VLANDB_GOPTS_MAX - 1) diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index e9b5f79e1ee1..3cb040aaa8dc 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -744,6 +744,16 @@ enum in6_addr_gen_mode { * @IFLA_BR_FDB_MAX_LEARNED * Set the number of max dynamically learned FDB entries for the current * bridge. + * + * @IFLA_BR_MCAST_ACTIVE_V4 + * Bridge IPv4 mcast active state, read only. + * + * 1 if an IGMP querier is present, 0 otherwise. + * + * @IFLA_BR_MCAST_ACTIVE_V6 + * Bridge IPv6 mcast active state, read only. + * + * 1 if an MLD querier is present, 0 otherwise. */ enum { IFLA_BR_UNSPEC, @@ -796,6 +806,8 @@ enum { IFLA_BR_MCAST_QUERIER_STATE, IFLA_BR_FDB_N_LEARNED, IFLA_BR_FDB_MAX_LEARNED, + IFLA_BR_MCAST_ACTIVE_V4, + IFLA_BR_MCAST_ACTIVE_V6, __IFLA_BR_MAX, }; =20 diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c index 0264730938f4..1b5ab1fb4558 100644 --- a/net/bridge/br_netlink.c +++ b/net/bridge/br_netlink.c @@ -1264,7 +1264,9 @@ static const struct nla_policy br_policy[IFLA_BR_MAX = + 1] =3D { [IFLA_BR_VLAN_STATS_ENABLED] =3D { .type =3D NLA_U8 }, [IFLA_BR_MCAST_STATS_ENABLED] =3D { .type =3D NLA_U8 }, [IFLA_BR_MCAST_IGMP_VERSION] =3D { .type =3D NLA_U8 }, + [IFLA_BR_MCAST_ACTIVE_V4] =3D { .type =3D NLA_REJECT }, [IFLA_BR_MCAST_MLD_VERSION] =3D { .type =3D NLA_U8 }, + [IFLA_BR_MCAST_ACTIVE_V6] =3D { .type =3D NLA_REJECT }, [IFLA_BR_VLAN_STATS_PER_PORT] =3D { .type =3D NLA_U8 }, [IFLA_BR_MULTI_BOOLOPT] =3D NLA_POLICY_EXACT_LEN(sizeof(struct br_boolopt_multi)), @@ -1625,7 +1627,9 @@ static size_t br_get_size(const struct net_device *br= dev) nla_total_size_64bit(sizeof(u64)) + /* IFLA_BR_MCAST_QUERY_RESPONS= E_INTVL */ nla_total_size_64bit(sizeof(u64)) + /* IFLA_BR_MCAST_STARTUP_QUERY= _INTVL */ nla_total_size(sizeof(u8)) + /* IFLA_BR_MCAST_IGMP_VERSION */ + nla_total_size(sizeof(u8)) + /* IFLA_BR_MCAST_ACTIVE_V4 */ nla_total_size(sizeof(u8)) + /* IFLA_BR_MCAST_MLD_VERSION */ + nla_total_size(sizeof(u8)) + /* IFLA_BR_MCAST_ACTIVE_V6 */ br_multicast_querier_state_size() + /* IFLA_BR_MCAST_QUERIER_STATE= */ #endif #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER) @@ -1646,6 +1650,8 @@ static int br_fill_info(struct sk_buff *skb, const st= ruct net_device *brdev) u32 ageing_time =3D jiffies_to_clock_t(br->ageing_time); u32 stp_enabled =3D br->stp_enabled; u16 priority =3D (br->bridge_id.prio[0] << 8) | br->bridge_id.prio[1]; + struct ethhdr eth6 =3D { .h_proto =3D htons(ETH_P_IPV6) }; + struct ethhdr eth4 =3D { .h_proto =3D htons(ETH_P_IP) }; u8 vlan_enabled =3D br_vlan_enabled(br->dev); struct br_boolopt_multi bm; u64 clockval; @@ -1717,12 +1723,20 @@ static int br_fill_info(struct sk_buff *skb, const = struct net_device *brdev) br->multicast_ctx.multicast_startup_query_count) || nla_put_u8(skb, IFLA_BR_MCAST_IGMP_VERSION, br->multicast_ctx.multicast_igmp_version) || + nla_put_u8(skb, IFLA_BR_MCAST_ACTIVE_V4, + netif_running(brdev) && br_opt_get(br, BROPT_MULTICAST_ENABLED) && + !br_opt_get(br, BROPT_MCAST_VLAN_SNOOPING_ENABLED) && + br_multicast_querier_exists(&br->multicast_ctx, ð4, NULL)) || br_multicast_dump_querier_state(skb, &br->multicast_ctx, IFLA_BR_MCAST_QUERIER_STATE)) return -EMSGSIZE; #if IS_ENABLED(CONFIG_IPV6) if (nla_put_u8(skb, IFLA_BR_MCAST_MLD_VERSION, - br->multicast_ctx.multicast_mld_version)) + br->multicast_ctx.multicast_mld_version) || + nla_put_u8(skb, IFLA_BR_MCAST_ACTIVE_V6, + netif_running(brdev) && br_opt_get(br, BROPT_MULTICAST_ENABLED) && + !br_opt_get(br, BROPT_MCAST_VLAN_SNOOPING_ENABLED) && + br_multicast_querier_exists(&br->multicast_ctx, ð6, NULL))) return -EMSGSIZE; #endif clockval =3D jiffies_to_clock_t(br->multicast_ctx.multicast_last_member_i= nterval); diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index b9b2981c4841..4ab6a1f58116 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -1892,7 +1892,7 @@ int br_vlan_rtm_process_global_options(struct net_dev= ice *dev, bool br_vlan_global_opts_can_enter_range(const struct net_bridge_vlan *v_c= urr, const struct net_bridge_vlan *r_end); bool br_vlan_global_opts_fill(struct sk_buff *skb, u16 vid, u16 vid_range, - const struct net_bridge_vlan *v_opts); + struct net_bridge_vlan *v_opts); =20 /* vlan state manipulation helpers using *_ONCE to annotate lock-free acce= ss, * while br_vlan_set_state() may access data protected by multicast_lock. diff --git a/net/bridge/br_vlan_options.c b/net/bridge/br_vlan_options.c index 8fa89b04ee94..6425fa509b95 100644 --- a/net/bridge/br_vlan_options.c +++ b/net/bridge/br_vlan_options.c @@ -347,8 +347,10 @@ bool br_vlan_global_opts_can_enter_range(const struct = net_bridge_vlan *v_curr, } =20 bool br_vlan_global_opts_fill(struct sk_buff *skb, u16 vid, u16 vid_range, - const struct net_bridge_vlan *v_opts) + struct net_bridge_vlan *v_opts) { + struct ethhdr eth6 =3D { .h_proto =3D htons(ETH_P_IPV6) }; + struct ethhdr eth4 =3D { .h_proto =3D htons(ETH_P_IP) }; struct nlattr *nest2 __maybe_unused; u64 clockval __maybe_unused; struct nlattr *nest; @@ -369,6 +371,12 @@ bool br_vlan_global_opts_fill(struct sk_buff *skb, u16= vid, u16 vid_range, !!(v_opts->priv_flags & BR_VLFLAG_GLOBAL_MCAST_ENABLED)) || nla_put_u8(skb, BRIDGE_VLANDB_GOPTS_MCAST_IGMP_VERSION, v_opts->br_mcast_ctx.multicast_igmp_version) || + nla_put_u8(skb, BRIDGE_VLANDB_GOPTS_MCAST_ACTIVE_V4, + netif_running(v_opts->br->dev) && + br_opt_get(v_opts->br, BROPT_MULTICAST_ENABLED) && + br_opt_get(v_opts->br, BROPT_MCAST_VLAN_SNOOPING_ENABLED) && + !br_multicast_ctx_vlan_global_disabled(&v_opts->br_mcast_ctx) && + br_multicast_querier_exists(&v_opts->br_mcast_ctx, ð4, NULL)) = || nla_put_u32(skb, BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_CNT, v_opts->br_mcast_ctx.multicast_last_member_count) || nla_put_u32(skb, BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_CNT, @@ -423,7 +431,13 @@ bool br_vlan_global_opts_fill(struct sk_buff *skb, u16= vid, u16 vid_range, =20 #if IS_ENABLED(CONFIG_IPV6) if (nla_put_u8(skb, BRIDGE_VLANDB_GOPTS_MCAST_MLD_VERSION, - v_opts->br_mcast_ctx.multicast_mld_version)) + v_opts->br_mcast_ctx.multicast_mld_version) || + nla_put_u8(skb, BRIDGE_VLANDB_GOPTS_MCAST_ACTIVE_V6, + netif_running(v_opts->br->dev) && + br_opt_get(v_opts->br, BROPT_MULTICAST_ENABLED) && + br_opt_get(v_opts->br, BROPT_MCAST_VLAN_SNOOPING_ENABLED) && + !br_multicast_ctx_vlan_global_disabled(&v_opts->br_mcast_ctx) && + br_multicast_querier_exists(&v_opts->br_mcast_ctx, ð6, NULL))) goto out_err; #endif #endif @@ -448,7 +462,9 @@ static size_t rtnl_vlan_global_opts_nlmsg_size(const st= ruct net_bridge_vlan *v) #ifdef CONFIG_BRIDGE_IGMP_SNOOPING + nla_total_size(sizeof(u8)) /* BRIDGE_VLANDB_GOPTS_MCAST_SNOOPING */ + nla_total_size(sizeof(u8)) /* BRIDGE_VLANDB_GOPTS_MCAST_IGMP_VERSION */ + + nla_total_size(sizeof(u8)) /* BRIDGE_VLANDB_GOPTS_MCAST_ACTIVE_V4 */ + nla_total_size(sizeof(u8)) /* BRIDGE_VLANDB_GOPTS_MCAST_MLD_VERSION */ + + nla_total_size(sizeof(u8)) /* BRIDGE_VLANDB_GOPTS_MCAST_ACTIVE_V6 */ + nla_total_size(sizeof(u32)) /* BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_C= NT */ + nla_total_size(sizeof(u32)) /* BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY= _CNT */ + nla_total_size(sizeof(u64)) /* BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_I= NTVL */ @@ -630,9 +646,11 @@ static const struct nla_policy br_vlan_db_gpol[BRIDGE_= VLANDB_GOPTS_MAX + 1] =3D { [BRIDGE_VLANDB_GOPTS_RANGE] =3D { .type =3D NLA_U16 }, [BRIDGE_VLANDB_GOPTS_MCAST_SNOOPING] =3D { .type =3D NLA_U8 }, [BRIDGE_VLANDB_GOPTS_MCAST_MLD_VERSION] =3D { .type =3D NLA_U8 }, + [BRIDGE_VLANDB_GOPTS_MCAST_ACTIVE_V6] =3D { .type =3D NLA_REJECT }, [BRIDGE_VLANDB_GOPTS_MCAST_QUERY_INTVL] =3D { .type =3D NLA_U64 }, [BRIDGE_VLANDB_GOPTS_MCAST_QUERIER] =3D { .type =3D NLA_U8 }, [BRIDGE_VLANDB_GOPTS_MCAST_IGMP_VERSION] =3D { .type =3D NLA_U8 }, + [BRIDGE_VLANDB_GOPTS_MCAST_ACTIVE_V4] =3D { .type =3D NLA_REJECT }, [BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_CNT] =3D { .type =3D NLA_U32 }, [BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_CNT] =3D { .type =3D NLA_U32 }, [BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_INTVL] =3D { .type =3D NLA_U64 }, diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index b1ed55141d8a..7b29162e1f30 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -62,7 +62,7 @@ =20 #include "dev.h" =20 -#define RTNL_MAX_TYPE 50 +#define RTNL_MAX_TYPE 52 #define RTNL_SLAVE_MAX_TYPE 44 =20 struct rtnl_link { --=20 2.51.0 From nobody Sun Feb 8 04:34:22 2026 Received: from mail.aperture-lab.de (mail.aperture-lab.de [116.203.183.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 115EB29DB6C; Fri, 6 Feb 2026 03:01:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.183.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346900; cv=none; b=hLxSWA/2FxYaFpSw8qELfyBpo001TZ8hOZHetRVmsa7Y39gyTeKpXfEgJtcIhoMdv4c05pwwO3X6QzC9ukPx1y8SeIUqOGej/dNvKEyobKJhqfLIrvxW11cmD0BJqCXx33fw50dQzp8I86hqzIBpchCFFqmBqMofO4HroWseqmU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346900; c=relaxed/simple; bh=zNi6WJCvBCxooc/KHwwvYN+hskmIareGhxJgtaVUXks=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iM5TmiajpP2jP5KkJHpbEdx1+spEi2egPe+o9gkpmhHai69TfMLDbvnn4Dtsjbnc90saQXkKzkX49MTuttZ1fkIjtX7yl7xG3u6D4mCB8GFQmLEAB6K5Gxvhu3UmhirU1hZ4e/WXtjfA5Ssx1X1yRHE7h0IH4/sWyLojNjGd5l4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue; spf=pass smtp.mailfrom=c0d3.blue; arc=none smtp.client-ip=116.203.183.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c0d3.blue Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 7BCC254CD2B; Fri, 6 Feb 2026 04:01:37 +0100 (CET) From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: bridge@lists.linux.dev Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nikolay Aleksandrov , Ido Schimmel , Andrew Lunn , Simon Horman , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S . Miller" , Kuniyuki Iwashima , Stanislav Fomichev , Xiao Liang , =?UTF-8?q?Linus=20L=C3=BCssing?= Subject: [PATCH net-next v2 02/14] net: bridge: mcast: track active state, adding tests Date: Fri, 6 Feb 2026 03:52:08 +0100 Message-ID: <20260206030123.5430-3-linus.luessing@c0d3.blue> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260206030123.5430-1-linus.luessing@c0d3.blue> References: <20260206030123.5430-1-linus.luessing@c0d3.blue> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Before making any significant changes to the internals of the Linux bridge add some tests regarding the multicast activity. This is also to verify that we have the semantics of the new *_MCAST_ACTIVE_{V4,V6} netlink attributes as expected. Signed-off-by: Linus L=C3=BCssing --- .../net/forwarding/bridge_mdb_active.sh | 682 ++++++++++++++++++ 1 file changed, 682 insertions(+) create mode 100755 tools/testing/selftests/net/forwarding/bridge_mdb_activ= e.sh diff --git a/tools/testing/selftests/net/forwarding/bridge_mdb_active.sh b/= tools/testing/selftests/net/forwarding/bridge_mdb_active.sh new file mode 100755 index 000000000000..5b6e14d88bc2 --- /dev/null +++ b/tools/testing/selftests/net/forwarding/bridge_mdb_active.sh @@ -0,0 +1,682 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# +-------+ +---------+ +# | brq0 | | br0 | +# | + $h1 | | + $swp1 | +# +----|--+ +----|----+ +# | | +# \--------------/ +# +# +# This script checks if we have the expected mcast_active_v{4,6} state +# on br0 in a variety of scenarios. This state determines if ultimately +# multicast snooping is applied to multicast data packets +# (multicast snooping active) or if they are (by default) flooded instead +# (multicast snooping inactive). +# +# Notably, multicast snooping can be enabled but still be inactive if not = all +# requirements to safely apply multicast snooping to multicast data packets +# are met. +# +# Depending on the test case an IGMP/MLD querier might be on brq0, on br0 +# or neither. + + +ALL_TESTS=3D" + test_inactive + test_active_other_querier + test_active_own_querier + test_inactive_brdown + test_inactive_nov6 + test_inactive_snooping_off + test_inactive_querier_off + test_inactive_other_querier_norespdelay + test_inactive_own_querier_norespdelay + test_inactive + test_vlan_inactive + test_vlan_active_other_querier + test_vlan_active_own_querier + test_vlan_inactive_brdown + test_vlan_inactive_nov6 + test_vlan_inactive_snooping_off + test_vlan_inactive_vlans_snooping_off + test_vlan_inactive_vlan_snooping_off + test_vlan_inactive_other_querier_norespdelay + test_vlan_inactive_own_querier_norespdelay +" + +NUM_NETIFS=3D1 +MCAST_MAX_RESP_IVAL_SEC=3D1 +MCAST_VLAN_ID=3D42 +source lib.sh + +switch_create() +{ + ip link add dev br0 type bridge\ + vlan_filtering 0 \ + mcast_query_response_interval $((${MCAST_MAX_RESP_IVAL_SEC}*100))\ + mcast_snooping 0 \ + mcast_vlan_snooping 0 + ip link add dev brq0 type bridge\ + vlan_filtering 0 \ + mcast_query_response_interval $((${MCAST_MAX_RESP_IVAL_SEC}*100))\ + mcast_snooping 0 \ + mcast_vlan_snooping 0 + + echo 1 > /proc/sys/net/ipv6/conf/br0/disable_ipv6 + echo 1 > /proc/sys/net/ipv6/conf/brq0/disable_ipv6 + + ip link set dev $swp1 master br0 + ip link set dev $h1 master brq0 + + ip link set dev $h1 up + ip link set dev $swp1 up +} + +switch_destroy() +{ + ip link set dev $swp1 down + ip link set dev $h1 down + + ip link del dev brq0 + ip link del dev br0 +} + +setup_prepare() +{ + h1=3D${NETIFS[p1]} + swp1=3D${NETIFS[p2]} + + switch_create +} + +cleanup() +{ + pre_cleanup + switch_destroy +} + +mcast_active_check() +{ + local af=3D"$1" + local state=3D"$2" + + ip -d -j link show dev br0\ + | jq -e ".[] | select(.linkinfo.info_data.mcast_active_$af =3D=3D $state= )"\ + &> /dev/null + + check_err $? "Mcast active check failed" +} + +mcast_vlan_active_check() +{ + local af=3D"$1" + local state=3D"$2" + local vid=3D"${MCAST_VLAN_ID}" + local ret + + bridge -j vlan global show dev br0\ + | jq -e ".[].vlans.[] | select(.vlan =3D=3D $vid and .mcast_active_$af = =3D=3D 1)"\ + &> /dev/null + ret=3D"$?" + + if [ $ret -eq 0 -a $state -eq 0 ] || [ $ret -ne 0 -a $state -eq 1 ]; then + check_err 1 "Mcast VLAN active check failed" + fi +} + +mcast_assert_active_v4() +{ + mcast_active_check "v4" "1" +} + +mcast_assert_active_v6() +{ + mcast_active_check "v6" "1" +} + +mcast_assert_inactive_v4() +{ + mcast_active_check "v4" "0" +} + +mcast_assert_inactive_v6() +{ + mcast_active_check "v6" "0" +} + +mcast_vlan_assert_active_v4() +{ + mcast_vlan_active_check "v4" "1" +} + +mcast_vlan_assert_active_v6() +{ + mcast_vlan_active_check "v6" "1" +} + +mcast_vlan_assert_inactive_v4() +{ + mcast_vlan_active_check "v4" "0" +} + +mcast_vlan_assert_inactive_v6() +{ + mcast_vlan_active_check "v6" "0" +} + + +test_inactive_nolog() +{ + ip link set dev br0 down + ip link set dev brq0 down + ip link set dev br0 type bridge mcast_snooping 0 + ip link set dev brq0 type bridge mcast_snooping 0 + ip link set dev br0 type bridge mcast_querier 0 + ip link set dev brq0 type bridge mcast_querier 0 + ip link set dev br0 type bridge mcast_vlan_snooping 0 + ip link set dev br0 type bridge vlan_filtering 0 + + echo 1 > /proc/sys/net/ipv6/conf/br0/disable_ipv6 + echo 1 > /proc/sys/net/ipv6/conf/brq0/disable_ipv6 + + mcast_assert_inactive_v4 + mcast_assert_inactive_v6 +} + +test_inactive() +{ + RET=3D0 + + test_inactive_nolog + log_test "Mcast inactive test" +} + +wait_lladdr_dad() { + local check_tentative + + check_tentative=3D"map(select(.scope =3D=3D \"link\" and ((.tentative =3D= =3D true) | not))) | .[]" + + ip -6 -j a s dev "$1"\ + | jq -e ".[].addr_info | ${check_tentative}" &> /dev/null +} + +test_active_setup_bridge() +{ + [ -n "$1" ] && echo 0 > /proc/sys/net/ipv6/conf/br0/disable_ipv6 + [ -n "$2" ] && echo 0 > /proc/sys/net/ipv6/conf/brq0/disable_ipv6 + + [ -n "$3" ] && ip link set dev br0 up + [ -n "$4" ] && ip link set dev brq0 up + [ -n "$5" ] && slowwait 3 wait_lladdr_dad br0 + [ -n "$6" ] && slowwait 3 wait_lladdr_dad brq0 +} + +test_active_setup_config() +{ + [ -n "$1" ] && ip link set dev br0 type bridge mcast_snooping 1 + [ -n "$2" ] && ip link set dev brq0 type bridge mcast_snooping 1 + [ -n "$3" ] && ip link set dev br0 type bridge mcast_querier 1 + [ -n "$4" ] && ip link set dev brq0 type bridge mcast_querier 1 +} + +test_active_setup_wait() +{ + sleep $((${MCAST_MAX_RESP_IVAL_SEC} * 2)) +} + +test_active_setup_reset_own_querier() +{ + ip link set dev br0 type bridge mcast_querier 0 + ip link set dev br0 type bridge mcast_querier 1 + + test_active_setup_wait +} + +test_vlan_active_setup_config() +{ + [ -n "$1" ] && ip link set dev br0 type bridge vlan_filtering 1 + [ -n "$2" ] && ip link set dev brq0 type bridge vlan_filtering 1 + [ -n "$3" ] && ip link set dev br0 type bridge mcast_vlan_snooping 1 + [ -n "$4" ] && ip link set dev brq0 type bridge mcast_vlan_snooping 1 +} + +test_vlan_active_setup_add_vlan() +{ + bridge vlan add vid ${MCAST_VLAN_ID} dev $swp1 + bridge vlan add vid ${MCAST_VLAN_ID} dev $h1 + bridge vlan global set vid ${MCAST_VLAN_ID} dev br0\ + mcast_query_response_interval $((${MCAST_MAX_RESP_IVAL_SEC}*100)) + bridge vlan global set vid ${MCAST_VLAN_ID} dev brq0\ + mcast_query_response_interval $((${MCAST_MAX_RESP_IVAL_SEC}*100)) + bridge vlan global set vid ${MCAST_VLAN_ID} dev br0 mcast_snooping 0 + bridge vlan global set vid ${MCAST_VLAN_ID} dev brq0 mcast_snooping 0 + bridge vlan global set vid ${MCAST_VLAN_ID} dev br0 mcast_querier 0 + bridge vlan global set vid ${MCAST_VLAN_ID} dev brq0 mcast_querier 0 +} + +test_vlan_active_setup_config_vlan() +{ + [ -n "$1" ] && bridge vlan global set vid ${MCAST_VLAN_ID} dev br0 mcast_= snooping 1 + [ -n "$2" ] && bridge vlan global set vid ${MCAST_VLAN_ID} dev brq0 mcast= _snooping 1 + [ -n "$3" ] && bridge vlan global set vid ${MCAST_VLAN_ID} dev br0 mcast_= querier 1 + [ -n "$4" ] && bridge vlan global set vid ${MCAST_VLAN_ID} dev brq0 mcast= _querier 1 +} + +test_vlan_teardown() +{ + bridge vlan del vid ${MCAST_VLAN_ID} dev $swp1 + bridge vlan del vid ${MCAST_VLAN_ID} dev $h1 + mcast_assert_inactive_v4 + mcast_assert_inactive_v6 + mcast_vlan_assert_inactive_v4 + mcast_vlan_assert_inactive_v6 +} + +test_vlan_active_setup_reset_own_querier() +{ + bridge vlan global set vid ${MCAST_VLAN_ID} dev br0 mcast_querier 0 + bridge vlan global set vid ${MCAST_VLAN_ID} dev br0 mcast_querier 1 + + test_active_setup_wait +} + +test_active_other_querier_nolog() +{ + test_active_setup_bridge "1" "2" "3" "4" "5" "6" + test_active_setup_config "1" "2" "" "4" + test_active_setup_wait + + mcast_assert_active_v4 + mcast_assert_active_v6 +} + +test_active_other_querier() +{ + RET=3D0 + + test_active_other_querier_nolog + test_inactive_nolog + log_test "Mcast active with other querier test" +} + +test_active_own_querier_nolog() +{ + test_active_setup_bridge "1" "2" "3" "4" "5" "6" + test_active_setup_config "1" "2" "3" "" + test_active_setup_wait + + mcast_assert_active_v4 + mcast_assert_active_v6 +} + +test_active_own_querier() +{ + RET=3D0 + + test_active_own_querier_nolog + test_inactive_nolog + log_test "Mcast active with own querier test" +} + +test_active_final() +{ + mcast_assert_active_v4 + mcast_assert_active_v6 + + test_inactive_nolog +} + +test_inactive_brdown() +{ + RET=3D0 + + test_active_setup_bridge "1" "2" "" "4" "" "6" + test_active_setup_config "1" "2" "3" "" + test_active_setup_wait + + mcast_assert_inactive_v4 + mcast_assert_inactive_v6 + + test_active_setup_bridge "" "" "3" "" "" "" + mcast_assert_active_v4 + mcast_assert_inactive_v6 + + test_active_setup_bridge "" "" "" "" "5" "" + test_active_setup_reset_own_querier + test_active_final + + log_test "Mcast inactive, bridge down test" +} + +test_inactive_nov6() +{ + RET=3D0 + + test_active_setup_bridge "" "2" "3" "4" "5" "6" + test_active_setup_config "1" "2" "3" "" + test_active_setup_wait + + mcast_assert_active_v4 + mcast_assert_inactive_v6 + + test_active_setup_bridge "1" "" "" "" "5" "" + test_active_setup_reset_own_querier + test_active_final + + log_test "Mcast inactive, own querier, no IPv6 address test" +} + +test_inactive_snooping_off() +{ + RET=3D0 + + test_active_setup_bridge "1" "2" "3" "4" "5" "6" + test_active_setup_config "" "2" "3" "" + test_active_setup_wait + + mcast_assert_inactive_v4 + mcast_assert_inactive_v6 + + test_active_setup_config "1" "" "" "" + test_active_setup_reset_own_querier + test_active_final + + log_test "Mcast inactive, snooping disabled test" +} + +test_inactive_querier_off() +{ + RET=3D0 + + test_active_setup_bridge "1" "2" "3" "4" "5" "6" + test_active_setup_config "1" "2" "" "" + test_active_setup_wait + + mcast_assert_inactive_v4 + mcast_assert_inactive_v6 + + test_active_setup_config "" "" "3" "" + test_active_setup_wait + test_active_final + + log_test "Mcast inactive, no querier test" +} + +test_inactive_other_querier_norespdelay() +{ + RET=3D0 + + test_active_setup_bridge "1" "2" "3" "4" "5" "6" + test_active_setup_config "1" "2" "3" "" + #test_active_setup_wait + + mcast_assert_inactive_v4 + mcast_assert_inactive_v6 + + test_active_setup_wait + test_active_final + + log_test "Mcast inactive, other querier, no response delay test" +} + +test_inactive_own_querier_norespdelay() +{ + RET=3D0 + + test_active_setup_bridge "1" "2" "3" "4" "5" "6" + test_active_setup_config "1" "2" "" "4" + #test_active_setup_wait + + mcast_assert_inactive_v4 + mcast_assert_inactive_v6 + + test_active_setup_wait + test_active_final + + log_test "Mcast inactive, own querier, no response delay test" +} + +test_vlan_inactive() +{ + RET=3D0 + + test_inactive_nolog + mcast_vlan_assert_inactive_v4 + mcast_vlan_assert_inactive_v6 + + ip link set dev br0 type bridge vlan_filtering 1 + ip link set dev br0 type bridge mcast_vlan_snooping 1 + mcast_vlan_assert_inactive_v4 + mcast_vlan_assert_inactive_v6 + mcast_assert_inactive_v4 + mcast_assert_inactive_v6 + + ip link set dev br0 type bridge mcast_vlan_snooping 0 + ip link set dev br0 type bridge vlan_filtering 0 + test_active_own_querier_nolog + ip link set dev br0 type bridge vlan_filtering 1 + mcast_assert_active_v4 + mcast_assert_active_v6 + + ip link set dev br0 type bridge mcast_vlan_snooping 1 + mcast_assert_inactive_v4 + mcast_assert_inactive_v6 + + test_inactive_nolog + log_test "Mcast VLAN inactive test" +} + +test_vlan_active_final() +{ + mcast_assert_inactive_v4 + mcast_assert_inactive_v6 + mcast_vlan_assert_active_v4 + mcast_vlan_assert_active_v6 + + test_vlan_teardown + test_inactive_nolog +} + +test_vlan_active_other_querier() +{ + RET=3D0 + + test_active_setup_bridge "1" "2" "3" "4" "5" "6" + test_active_setup_config "1" "2" "" "" + test_vlan_active_setup_config "1" "2" "3" "4" + test_vlan_active_setup_add_vlan + test_vlan_active_setup_config_vlan "1" "2" "" "4" + test_active_setup_wait + test_vlan_active_final + + log_test "Mcast VLAN active, other querier test" +} + +test_vlan_active_own_querier() +{ + RET=3D0 + + test_active_setup_bridge "1" "2" "3" "4" "5" "6" + test_active_setup_config "1" "2" "" "" + test_vlan_active_setup_config "1" "2" "3" "4" + test_vlan_active_setup_add_vlan + test_vlan_active_setup_config_vlan "1" "2" "3" "" + test_active_setup_wait + test_vlan_active_final + + log_test "Mcast VLAN active, own querier test" +} + +test_vlan_inactive_brdown() +{ + RET=3D0 + + test_active_setup_bridge "1" "2" "" "4" "" "6" + test_active_setup_config "1" "2" "" "" + test_vlan_active_setup_config "1" "2" "3" "4" + test_vlan_active_setup_add_vlan + test_vlan_active_setup_config_vlan "1" "2" "3" "" + test_active_setup_wait + + mcast_assert_inactive_v4 + mcast_assert_inactive_v6 + mcast_vlan_assert_inactive_v4 + mcast_vlan_assert_inactive_v6 + + test_active_setup_bridge "" "" "3" "" "" "" + mcast_vlan_assert_active_v4 + mcast_assert_inactive_v6 + + test_active_setup_bridge "" "" "" "" "5" "" + test_vlan_active_setup_reset_own_querier + test_vlan_active_final + + log_test "Mcast VLAN inactive, bridge down test" +} + +test_vlan_inactive_nov6() +{ + RET=3D0 + + test_active_setup_bridge "" "2" "3" "4" "5" "6" + test_active_setup_config "1" "2" "" "" + test_vlan_active_setup_config "1" "2" "3" "4" + test_vlan_active_setup_add_vlan + test_vlan_active_setup_config_vlan "1" "2" "3" "" + test_active_setup_wait + + mcast_assert_inactive_v4 + mcast_assert_inactive_v6 + mcast_vlan_assert_active_v4 + mcast_vlan_assert_inactive_v6 + + test_active_setup_bridge "1" "" "" "" "5" "" + test_vlan_active_setup_reset_own_querier + test_vlan_active_final + + log_test "Mcast VLAN inactive, own querier, no IPv6 address test" +} + +test_vlan_inactive_snooping_off() +{ + RET=3D0 + + test_active_setup_bridge "1" "2" "3" "4" "5" "6" + test_active_setup_config "" "2" "" "" + test_vlan_active_setup_config "1" "2" "3" "4" + test_vlan_active_setup_add_vlan + test_vlan_active_setup_config_vlan "1" "2" "3" "" + test_active_setup_wait + + mcast_assert_inactive_v4 + mcast_assert_inactive_v6 + mcast_vlan_assert_inactive_v4 + mcast_vlan_assert_inactive_v6 + + test_active_setup_config "1" "" "" "" + test_vlan_active_setup_reset_own_querier + test_vlan_active_final + + log_test "Mcast VLAN inactive, snooping disabled test" +} + +test_vlan_inactive_vlans_snooping_off() +{ + RET=3D0 + + test_active_setup_bridge "1" "2" "3" "4" "5" "6" + test_active_setup_config "1" "2" "" "" + test_vlan_active_setup_config "1" "2" "" "4" + test_vlan_active_setup_add_vlan + test_vlan_active_setup_config_vlan "1" "2" "3" "" + test_active_setup_wait + + mcast_assert_inactive_v4 + mcast_assert_inactive_v6 + mcast_vlan_assert_inactive_v4 + mcast_vlan_assert_inactive_v6 + + test_vlan_active_setup_config "" "" "3" "" + test_vlan_active_setup_reset_own_querier + test_vlan_active_final + + log_test "Mcast VLAN inactive, snooping for VLANs disabled test" +} + +test_vlan_inactive_vlan_snooping_off() +{ + RET=3D0 + + test_active_setup_bridge "1" "2" "3" "4" "5" "6" + test_active_setup_config "1" "2" "" "" + test_vlan_active_setup_config "1" "2" "3" "4" + test_vlan_active_setup_add_vlan + test_vlan_active_setup_config_vlan "" "2" "3" "" + test_active_setup_wait + + mcast_assert_inactive_v4 + mcast_assert_inactive_v6 + mcast_vlan_assert_inactive_v4 + mcast_vlan_assert_inactive_v6 + + test_vlan_active_setup_config_vlan "1" "" "" "" + test_vlan_active_setup_reset_own_querier + test_vlan_active_final + + log_test "Mcast VLAN inactive, snooping for this VLAN disabled test" +} + +test_vlan_inactive_other_querier_norespdelay() +{ + RET=3D0 + + test_active_setup_bridge "1" "2" "3" "4" "5" "6" + test_active_setup_config "1" "2" "" "" + test_vlan_active_setup_config "1" "2" "3" "4" + test_vlan_active_setup_add_vlan + test_vlan_active_setup_config_vlan "1" "2" "" "4" + #test_active_setup_wait + + mcast_assert_inactive_v4 + mcast_assert_inactive_v6 + mcast_vlan_assert_inactive_v4 + mcast_vlan_assert_inactive_v6 + + test_active_setup_wait + test_vlan_active_final + + log_test "Mcast VLAN inactive, other querier, no response delay test" +} + +test_vlan_inactive_own_querier_norespdelay() +{ + RET=3D0 + + test_active_setup_bridge "1" "2" "3" "4" "5" "6" + test_active_setup_config "1" "2" "" "" + test_vlan_active_setup_config "1" "2" "3" "4" + test_vlan_active_setup_add_vlan + test_vlan_active_setup_config_vlan "1" "2" "3" "" + #test_active_setup_wait + + mcast_assert_inactive_v4 + mcast_assert_inactive_v6 + mcast_vlan_assert_inactive_v4 + mcast_vlan_assert_inactive_v6 + + test_active_setup_wait + test_vlan_active_final + + log_test "Mcast VLAN inactive, own querier, no response delay test" +} + +trap cleanup EXIT + +setup_prepare +setup_wait + +tests_run + +exit $EXIT_STATUS --=20 2.51.0 From nobody Sun Feb 8 04:34:22 2026 Received: from mail.aperture-lab.de (mail.aperture-lab.de [116.203.183.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF7102BDC03; Fri, 6 Feb 2026 03:01:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.183.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346901; cv=none; b=kkeQL4u5Ye5jJrwFCD0JCdMxzcnWV7fh95dzy77Om7PIyPJ4ePIkT4mRg5AUUeCSMPehUs7e6OPYjneFXug5x293bowaHnLGRqQJjvQabcXnzmInbvWwwRs3BuOAnHnVg2NMt8ytpctG4C44c82Z0Nde2o6qN/xv1CVVD/Vt92U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346901; c=relaxed/simple; bh=vaXBTLkB4Z2pRlYzMhVUcT8igRLyx9ydo/WCecReO9A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iLZtQf70CEplZEi9+oZfZMeos38oUWIVESWpNwBWo4GVYjuKcwSmwTI498yEO+ueblf+WiU47m2YXDj/0KspzfHZpwetJ+RsSXgYYlkeFBi6+jNd4mQZs9lNu8ZHXVOPCbQPQUBtlvbxnnZiQ/DV8yPz0rHVdbGt7lOycODH5a0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue; spf=pass smtp.mailfrom=c0d3.blue; arc=none smtp.client-ip=116.203.183.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c0d3.blue Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id C67D654CD34; Fri, 6 Feb 2026 04:01:38 +0100 (CET) From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: bridge@lists.linux.dev Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nikolay Aleksandrov , Ido Schimmel , Andrew Lunn , Simon Horman , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S . Miller" , Kuniyuki Iwashima , Stanislav Fomichev , Xiao Liang , =?UTF-8?q?Linus=20L=C3=BCssing?= Subject: [PATCH net-next v2 03/14] net: bridge: mcast: avoid sleeping on bridge-down Date: Fri, 6 Feb 2026 03:52:09 +0100 Message-ID: <20260206030123.5430-4-linus.luessing@c0d3.blue> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260206030123.5430-1-linus.luessing@c0d3.blue> References: <20260206030123.5430-1-linus.luessing@c0d3.blue> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 We later want to use the multicast lock when setting the bridge interface up or down, to be able to atomically both check all conditions to toggle the multicast active state and to subsequently toggle it. While most variables we check / contexts we check from are serialized (toggled variables through netlink/sysfs) the timer_pending() check is not and might run in parallel. However so far we are not allowed to spinlock __br_multicast_stop() as its call to timer_delete_sync() might sleep. Therefore replacing the sleeping variant with the non-sleeping one. It is sufficient to only wait for any timer callback to finish when we are freeing the multicast context. Using the timer_shutdown() instead of the timer_delete() variant also allows us to detect that we are stopping from within the according timer callbacks, to retain the promise of the previous timer_delete_sync() calls that no multicast state is changed after these timer_{delete,shutdown}*() calls. And more importantly that we are not inadvertently rearming timers. This new check also makes the netif_running() check redundant/obsolete in these contexts. Signed-off-by: Linus L=C3=BCssing --- net/bridge/br_device.c | 4 ++ net/bridge/br_multicast.c | 108 ++++++++++++++++++++++++++------------ net/bridge/br_private.h | 5 ++ net/bridge/br_vlan.c | 5 ++ 4 files changed, 87 insertions(+), 35 deletions(-) diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index a818fdc22da9..d9d1227d5708 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c @@ -168,7 +168,9 @@ static int br_dev_open(struct net_device *dev) netdev_update_features(dev); netif_start_queue(dev); br_stp_enable_bridge(br); + spin_lock_bh(&br->multicast_lock); br_multicast_open(br); + spin_unlock_bh(&br->multicast_lock); =20 if (br_opt_get(br, BROPT_MULTICAST_ENABLED)) br_multicast_join_snoopers(br); @@ -191,7 +193,9 @@ static int br_dev_stop(struct net_device *dev) struct net_bridge *br =3D netdev_priv(dev); =20 br_stp_disable_bridge(br); + spin_lock_bh(&br->multicast_lock); br_multicast_stop(br); + spin_unlock_bh(&br->multicast_lock); =20 if (br_opt_get(br, BROPT_MULTICAST_ENABLED)) br_multicast_leave_snoopers(br); diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index dccae08b4f4c..f5a368dd20a3 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -1665,6 +1665,14 @@ static void br_multicast_router_expired(struct net_b= ridge_mcast_port *pmctx, spin_unlock(&br->multicast_lock); } =20 +static bool br_multicast_stopping(struct net_bridge *br, + struct timer_list *timer) +{ + lockdep_assert_held_once(&br->multicast_lock); + + return !timer->function; +} + static void br_ip4_multicast_router_expired(struct timer_list *t) { struct net_bridge_mcast_port *pmctx =3D timer_container_of(pmctx, t, @@ -1700,7 +1708,8 @@ static void br_multicast_local_router_expired(struct = net_bridge_mcast *brmctx, struct timer_list *timer) { spin_lock(&brmctx->br->multicast_lock); - if (brmctx->multicast_router =3D=3D MDB_RTR_TYPE_DISABLED || + if (br_multicast_stopping(brmctx->br, timer) || + brmctx->multicast_router =3D=3D MDB_RTR_TYPE_DISABLED || brmctx->multicast_router =3D=3D MDB_RTR_TYPE_PERM || br_ip4_multicast_is_router(brmctx) || br_ip6_multicast_is_router(brmctx)) @@ -1730,10 +1739,11 @@ static void br_ip6_multicast_local_router_expired(s= truct timer_list *t) #endif =20 static void br_multicast_querier_expired(struct net_bridge_mcast *brmctx, - struct bridge_mcast_own_query *query) + struct bridge_mcast_own_query *query, + struct timer_list *timer) { spin_lock(&brmctx->br->multicast_lock); - if (!netif_running(brmctx->br->dev) || + if (br_multicast_stopping(brmctx->br, timer) || br_multicast_ctx_vlan_global_disabled(brmctx) || !br_opt_get(brmctx->br, BROPT_MULTICAST_ENABLED)) goto out; @@ -1749,7 +1759,7 @@ static void br_ip4_multicast_querier_expired(struct t= imer_list *t) struct net_bridge_mcast *brmctx =3D timer_container_of(brmctx, t, ip4_other_query.timer); =20 - br_multicast_querier_expired(brmctx, &brmctx->ip4_own_query); + br_multicast_querier_expired(brmctx, &brmctx->ip4_own_query, t); } =20 #if IS_ENABLED(CONFIG_IPV6) @@ -1758,7 +1768,7 @@ static void br_ip6_multicast_querier_expired(struct t= imer_list *t) struct net_bridge_mcast *brmctx =3D timer_container_of(brmctx, t, ip6_other_query.timer); =20 - br_multicast_querier_expired(brmctx, &brmctx->ip6_own_query); + br_multicast_querier_expired(brmctx, &brmctx->ip6_own_query, t); } #endif =20 @@ -4049,10 +4059,12 @@ int br_multicast_rcv(struct net_bridge_mcast **brmc= tx, } =20 static void br_multicast_query_expired(struct net_bridge_mcast *brmctx, - struct bridge_mcast_own_query *query) + struct bridge_mcast_own_query *query, + struct timer_list *timer) { spin_lock(&brmctx->br->multicast_lock); - if (br_multicast_ctx_vlan_disabled(brmctx)) + if (br_multicast_stopping(brmctx->br, timer) || + br_multicast_ctx_vlan_disabled(brmctx)) goto out; =20 if (query->startup_sent < brmctx->multicast_startup_query_count) @@ -4068,7 +4080,7 @@ static void br_ip4_multicast_query_expired(struct tim= er_list *t) struct net_bridge_mcast *brmctx =3D timer_container_of(brmctx, t, ip4_own_query.timer); =20 - br_multicast_query_expired(brmctx, &brmctx->ip4_own_query); + br_multicast_query_expired(brmctx, &brmctx->ip4_own_query, t); } =20 #if IS_ENABLED(CONFIG_IPV6) @@ -4077,7 +4089,7 @@ static void br_ip6_multicast_query_expired(struct tim= er_list *t) struct net_bridge_mcast *brmctx =3D timer_container_of(brmctx, t, ip6_own_query.timer); =20 - br_multicast_query_expired(brmctx, &brmctx->ip6_own_query); + br_multicast_query_expired(brmctx, &brmctx->ip6_own_query, t); } #endif =20 @@ -4120,29 +4132,30 @@ void br_multicast_ctx_init(struct net_bridge *br, seqcount_spinlock_init(&brmctx->ip6_querier.seq, &br->multicast_lock); #endif =20 - timer_setup(&brmctx->ip4_mc_router_timer, - br_ip4_multicast_local_router_expired, 0); - timer_setup(&brmctx->ip4_other_query.timer, - br_ip4_multicast_querier_expired, 0); - timer_setup(&brmctx->ip4_other_query.delay_timer, - br_multicast_query_delay_expired, 0); - timer_setup(&brmctx->ip4_own_query.timer, - br_ip4_multicast_query_expired, 0); + timer_setup(&brmctx->ip4_mc_router_timer, NULL, 0); + timer_setup(&brmctx->ip4_other_query.timer, NULL, 0); + timer_setup(&brmctx->ip4_other_query.delay_timer, NULL, 0); + timer_setup(&brmctx->ip4_own_query.timer, NULL, 0); #if IS_ENABLED(CONFIG_IPV6) - timer_setup(&brmctx->ip6_mc_router_timer, - br_ip6_multicast_local_router_expired, 0); - timer_setup(&brmctx->ip6_other_query.timer, - br_ip6_multicast_querier_expired, 0); - timer_setup(&brmctx->ip6_other_query.delay_timer, - br_multicast_query_delay_expired, 0); - timer_setup(&brmctx->ip6_own_query.timer, - br_ip6_multicast_query_expired, 0); + timer_setup(&brmctx->ip6_mc_router_timer, NULL, 0); + timer_setup(&brmctx->ip6_other_query.timer, NULL, 0); + timer_setup(&brmctx->ip6_other_query.delay_timer, NULL, 0); + timer_setup(&brmctx->ip6_own_query.timer, NULL, 0); #endif } =20 void br_multicast_ctx_deinit(struct net_bridge_mcast *brmctx) { - __br_multicast_stop(brmctx); + timer_shutdown_sync(&brmctx->ip4_mc_router_timer); + timer_shutdown_sync(&brmctx->ip4_other_query.timer); + timer_shutdown_sync(&brmctx->ip4_other_query.delay_timer); + timer_shutdown_sync(&brmctx->ip4_own_query.timer); +#if IS_ENABLED(CONFIG_IPV6) + timer_shutdown_sync(&brmctx->ip6_mc_router_timer); + timer_shutdown_sync(&brmctx->ip6_other_query.timer); + timer_shutdown_sync(&brmctx->ip6_other_query.delay_timer); + timer_shutdown_sync(&brmctx->ip6_own_query.timer); +#endif } =20 void br_multicast_init(struct net_bridge *br) @@ -4222,9 +4235,27 @@ void br_multicast_leave_snoopers(struct net_bridge *= br) br_ip6_multicast_leave_snoopers(br); } =20 +void br_multicast_reset_timer_cbs(struct net_bridge_mcast *brmctx) +{ + lockdep_assert_held_once(&brmctx->br->multicast_lock); + + brmctx->ip4_mc_router_timer.function =3D br_ip4_multicast_local_router_ex= pired; + brmctx->ip4_other_query.timer.function =3D br_ip4_multicast_querier_expir= ed; + brmctx->ip4_other_query.delay_timer.function =3D br_multicast_query_delay= _expired; + brmctx->ip4_own_query.timer.function =3D br_ip4_multicast_query_expired; +#if IS_ENABLED(CONFIG_IPV6) + brmctx->ip6_mc_router_timer.function =3D br_ip6_multicast_local_router_ex= pired; + brmctx->ip6_other_query.timer.function =3D br_ip6_multicast_querier_expir= ed; + brmctx->ip6_other_query.delay_timer.function =3D br_multicast_query_delay= _expired; + brmctx->ip6_own_query.timer.function =3D br_ip6_multicast_query_expired; +#endif +} + static void __br_multicast_open_query(struct net_bridge *br, struct bridge_mcast_own_query *query) { + lockdep_assert_held_once(&br->multicast_lock); + query->startup_sent =3D 0; =20 if (!br_opt_get(br, BROPT_MULTICAST_ENABLED)) @@ -4235,6 +4266,8 @@ static void __br_multicast_open_query(struct net_brid= ge *br, =20 static void __br_multicast_open(struct net_bridge_mcast *brmctx) { + br_multicast_reset_timer_cbs(brmctx); + __br_multicast_open_query(brmctx->br, &brmctx->ip4_own_query); #if IS_ENABLED(CONFIG_IPV6) __br_multicast_open_query(brmctx->br, &brmctx->ip6_own_query); @@ -4267,15 +4300,17 @@ void br_multicast_open(struct net_bridge *br) =20 static void __br_multicast_stop(struct net_bridge_mcast *brmctx) { - timer_delete_sync(&brmctx->ip4_mc_router_timer); - timer_delete_sync(&brmctx->ip4_other_query.timer); - timer_delete_sync(&brmctx->ip4_other_query.delay_timer); - timer_delete_sync(&brmctx->ip4_own_query.timer); + lockdep_assert_held_once(&brmctx->br->multicast_lock); + + timer_shutdown(&brmctx->ip4_mc_router_timer); + timer_shutdown(&brmctx->ip4_other_query.timer); + timer_shutdown(&brmctx->ip4_other_query.delay_timer); + timer_shutdown(&brmctx->ip4_own_query.timer); #if IS_ENABLED(CONFIG_IPV6) - timer_delete_sync(&brmctx->ip6_mc_router_timer); - timer_delete_sync(&brmctx->ip6_other_query.timer); - timer_delete_sync(&brmctx->ip6_other_query.delay_timer); - timer_delete_sync(&brmctx->ip6_own_query.timer); + timer_shutdown(&brmctx->ip6_mc_router_timer); + timer_shutdown(&brmctx->ip6_other_query.timer); + timer_shutdown(&brmctx->ip6_other_query.delay_timer); + timer_shutdown(&brmctx->ip6_own_query.timer); #endif } =20 @@ -4326,12 +4361,12 @@ void br_multicast_toggle_one_vlan(struct net_bridge= _vlan *vlan, bool on) =20 spin_lock_bh(&br->multicast_lock); vlan->priv_flags ^=3D BR_VLFLAG_MCAST_ENABLED; - spin_unlock_bh(&br->multicast_lock); =20 if (on) __br_multicast_open(&vlan->br_mcast_ctx); else __br_multicast_stop(&vlan->br_mcast_ctx); + spin_unlock_bh(&br->multicast_lock); } else { struct net_bridge_mcast *brmctx; =20 @@ -4389,6 +4424,7 @@ int br_multicast_toggle_vlan_snooping(struct net_brid= ge *br, bool on, if (!vg) return 0; =20 + spin_lock_bh(&br->multicast_lock); br_opt_toggle(br, BROPT_MCAST_VLAN_SNOOPING_ENABLED, on); =20 /* disable/enable non-vlan mcast contexts based on vlan snooping */ @@ -4396,6 +4432,8 @@ int br_multicast_toggle_vlan_snooping(struct net_brid= ge *br, bool on, __br_multicast_stop(&br->multicast_ctx); else __br_multicast_open(&br->multicast_ctx); + spin_unlock_bh(&br->multicast_lock); + list_for_each_entry(p, &br->port_list, list) { if (on) br_multicast_disable_port_ctx(&p->multicast_ctx); diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 4ab6a1f58116..a181a27aa559 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -976,6 +976,7 @@ void br_multicast_disable_port(struct net_bridge_port *= port); void br_multicast_init(struct net_bridge *br); void br_multicast_join_snoopers(struct net_bridge *br); void br_multicast_leave_snoopers(struct net_bridge *br); +void br_multicast_reset_timer_cbs(struct net_bridge_mcast *brmctx); void br_multicast_open(struct net_bridge *br); void br_multicast_stop(struct net_bridge *br); void br_multicast_dev_del(struct net_bridge *br); @@ -1416,6 +1417,10 @@ static inline void br_multicast_leave_snoopers(struc= t net_bridge *br) { } =20 +static inline void br_multicast_reset_timer_cbs(struct net_bridge_mcast *b= rmctx) +{ +} + static inline void br_multicast_open(struct net_bridge *br) { } diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c index ce72b837ff8e..7b46aa517c28 100644 --- a/net/bridge/br_vlan.c +++ b/net/bridge/br_vlan.c @@ -325,7 +325,12 @@ static int __vlan_add(struct net_bridge_vlan *v, u16 f= lags, if (err && err !=3D -EOPNOTSUPP) goto out; } + br_multicast_ctx_init(br, v, &v->br_mcast_ctx); + + spin_lock_bh(&br->multicast_lock); + br_multicast_reset_timer_cbs(&v->br_mcast_ctx); + spin_unlock_bh(&br->multicast_lock); v->priv_flags |=3D BR_VLFLAG_GLOBAL_MCAST_ENABLED; } =20 --=20 2.51.0 From nobody Sun Feb 8 04:34:22 2026 Received: from mail.aperture-lab.de (mail.aperture-lab.de [116.203.183.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F212B2C0296; Fri, 6 Feb 2026 03:01:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.183.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346902; cv=none; b=ah27GQaYHP3FLOBVNCb/FEYJ+0kyV4+CU+MgZUlGU5tNCd53NfhiCeSzOfLVvfTHGVodMggV2+bkzTTI3S1ZIpkE+dPiLbPgrVb9wLclpz+ZaYGRqIzT4X8NZoxMcPlf1uTQxh9LMKymZXWr80LsxGoMamYrsRFu2gwsyjDjiaU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346902; c=relaxed/simple; bh=kVnU6LvcqcZqte6YJ6dvQptVsfkAonGMRkCUq5g1HL8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KXQTZdV+8GyGOsXLc3DBcEdD9SqViqLncIYw46L2fQstuKMlJyh47uFme4fnS41NJwKwSlumfLvia4toTzfoJie9+Ua97ESuHLnDICZbyU7VFGuKKQlqBxffYmloAYJSNhypg26y3ehlDR3yUeLovO8J4vpAw3yC9fpY9YaphnI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue; spf=pass smtp.mailfrom=c0d3.blue; arc=none smtp.client-ip=116.203.183.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c0d3.blue Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id DCC4354CD37; Fri, 6 Feb 2026 04:01:39 +0100 (CET) From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: bridge@lists.linux.dev Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nikolay Aleksandrov , Ido Schimmel , Andrew Lunn , Simon Horman , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S . Miller" , Kuniyuki Iwashima , Stanislav Fomichev , Xiao Liang , =?UTF-8?q?Linus=20L=C3=BCssing?= Subject: [PATCH net-next v2 04/14] net: bridge: mcast: track active state, IGMP/MLD querier appearance Date: Fri, 6 Feb 2026 03:52:10 +0100 Message-ID: <20260206030123.5430-5-linus.luessing@c0d3.blue> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260206030123.5430-1-linus.luessing@c0d3.blue> References: <20260206030123.5430-1-linus.luessing@c0d3.blue> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 This is the first step to track in dedicated, per protocol family variables if we can actively and safely use multicast snooping. To later use these in the fast/data path instead of performing all these checks for every packet and to later notify DSA/switchdev about this state. This toggles these new variables to true after a Maximum Response Delay (default: 10 seconds) if a new IGMP or MLD querier has appeared. This can be triggered either through receiving an IGMP/MLD query from another host or by a user enabling our own IGMP/MLD querier. This is the first of several requirements, similar to what br_multicast_querier_exists() already checks so far, to be able to reliably receive IGMP/MLD reports, which in turn are needed to build a complete multicast database. No functional change for the fast/data path yet. Signed-off-by: Linus L=C3=BCssing --- net/bridge/br_multicast.c | 109 ++++++++++++++++++++++++++++++++++++-- net/bridge/br_private.h | 2 + 2 files changed, 108 insertions(+), 3 deletions(-) diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index f5a368dd20a3..d5c623dce7eb 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -1069,6 +1069,81 @@ static struct sk_buff *br_ip4_multicast_alloc_query(= struct net_bridge_mcast *brm return skb; } =20 +static bool br_ip4_multicast_querier_exists(struct net_bridge_mcast *brmct= x) +{ + return __br_multicast_querier_exists(brmctx, &brmctx->ip4_other_query, fa= lse); +} + +#if IS_ENABLED(CONFIG_IPV6) +static bool br_ip6_multicast_querier_exists(struct net_bridge_mcast *brmct= x) +{ + return __br_multicast_querier_exists(brmctx, &brmctx->ip6_other_query, tr= ue); +} +#endif + +static void br_ip4_multicast_update_active(struct net_bridge_mcast *brmctx, + bool force_inactive) +{ + if (force_inactive) + brmctx->ip4_active =3D false; + else + brmctx->ip4_active =3D br_ip4_multicast_querier_exists(brmctx); +} + +static void br_ip6_multicast_update_active(struct net_bridge_mcast *brmctx, + bool force_inactive) +{ +#if IS_ENABLED(CONFIG_IPV6) + if (force_inactive) + brmctx->ip6_active =3D false; + else + brmctx->ip6_active =3D br_ip6_multicast_querier_exists(brmctx); +#endif +} + +static void br_multicast_notify_active(struct net_bridge_mcast *brmctx, + bool ip4_active_old, bool ip6_active_old) +{ + if (brmctx->ip4_active =3D=3D ip4_active_old && + brmctx->ip6_active =3D=3D ip6_active_old) + return; + + br_info(brmctx->br, "mc_active changed, vid: %i: v4: %i->%i, v6: %i->%i\n= ", + brmctx->vlan ? brmctx->vlan->vid : -1, + ip4_active_old, brmctx->ip4_active, + ip6_active_old, brmctx->ip6_active); +} + +/** + * br_multicast_update_active() - update mcast active state + * @brmctx: the bridge multicast context to check + * + * This (potentially) updates the IPv4/IPv6 multicast active state. And by + * that enables or disables snooping of multicast payload traffic in fast + * path. + * + * The multicast active state is set, per protocol family, if: + * + * - an IGMP/MLD querier is present + * + * And is unset otherwise. + * + * This function should be called by anything that changes one of the + * above prerequisites. + */ +static void br_multicast_update_active(struct net_bridge_mcast *brmctx) +{ + bool ip4_active_old =3D brmctx->ip4_active, ip6_active_old =3D brmctx->ip= 6_active; + bool force_inactive =3D false; + + lockdep_assert_held_once(&brmctx->br->multicast_lock); + + br_ip4_multicast_update_active(brmctx, force_inactive); + br_ip6_multicast_update_active(brmctx, force_inactive); + + br_multicast_notify_active(brmctx, ip4_active_old, ip6_active_old); +} + #if IS_ENABLED(CONFIG_IPV6) static struct sk_buff *br_ip6_multicast_alloc_query(struct net_bridge_mcas= t *brmctx, struct net_bridge_mcast_port *pmctx, @@ -1772,10 +1847,36 @@ static void br_ip6_multicast_querier_expired(struct= timer_list *t) } #endif =20 -static void br_multicast_query_delay_expired(struct timer_list *t) +static void br_ip4_multicast_query_delay_expired(struct timer_list *t) { + struct net_bridge_mcast *brmctx =3D timer_container_of(brmctx, t, + ip4_other_query.delay_timer); + + spin_lock(&brmctx->br->multicast_lock); + if (!br_multicast_stopping(brmctx->br, t)) + /* an own or other IGMP querier appeared some seconds ago and all + * reports should have arrived by now, maybe set multicast state to acti= ve + */ + br_multicast_update_active(brmctx); + spin_unlock(&brmctx->br->multicast_lock); } =20 +#if IS_ENABLED(CONFIG_IPV6) +static void br_ip6_multicast_query_delay_expired(struct timer_list *t) +{ + struct net_bridge_mcast *brmctx =3D timer_container_of(brmctx, t, + ip6_other_query.delay_timer); + + spin_lock(&brmctx->br->multicast_lock); + if (!br_multicast_stopping(brmctx->br, t)) + /* an own or other MLD querier appeared some seconds ago and all + * reports should have arrived, maybe set multicast state to active + */ + br_multicast_update_active(brmctx); + spin_unlock(&brmctx->br->multicast_lock); +} +#endif + static void br_multicast_select_own_querier(struct net_bridge_mcast *brmct= x, struct br_ip *ip, struct sk_buff *skb) @@ -4124,11 +4225,13 @@ void br_multicast_ctx_init(struct net_bridge *br, brmctx->multicast_membership_interval =3D 260 * HZ; =20 brmctx->ip4_querier.port_ifidx =3D 0; + brmctx->ip4_active =3D 0; seqcount_spinlock_init(&brmctx->ip4_querier.seq, &br->multicast_lock); brmctx->multicast_igmp_version =3D 2; #if IS_ENABLED(CONFIG_IPV6) brmctx->multicast_mld_version =3D 1; brmctx->ip6_querier.port_ifidx =3D 0; + brmctx->ip6_active =3D 0; seqcount_spinlock_init(&brmctx->ip6_querier.seq, &br->multicast_lock); #endif =20 @@ -4241,12 +4344,12 @@ void br_multicast_reset_timer_cbs(struct net_bridge= _mcast *brmctx) =20 brmctx->ip4_mc_router_timer.function =3D br_ip4_multicast_local_router_ex= pired; brmctx->ip4_other_query.timer.function =3D br_ip4_multicast_querier_expir= ed; - brmctx->ip4_other_query.delay_timer.function =3D br_multicast_query_delay= _expired; + brmctx->ip4_other_query.delay_timer.function =3D br_ip4_multicast_query_d= elay_expired; brmctx->ip4_own_query.timer.function =3D br_ip4_multicast_query_expired; #if IS_ENABLED(CONFIG_IPV6) brmctx->ip6_mc_router_timer.function =3D br_ip6_multicast_local_router_ex= pired; brmctx->ip6_other_query.timer.function =3D br_ip6_multicast_querier_expir= ed; - brmctx->ip6_other_query.delay_timer.function =3D br_multicast_query_delay= _expired; + brmctx->ip6_other_query.delay_timer.function =3D br_ip6_multicast_query_d= elay_expired; brmctx->ip6_own_query.timer.function =3D br_ip6_multicast_query_expired; #endif } diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index a181a27aa559..4cc59abdb8e1 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -160,12 +160,14 @@ struct net_bridge_mcast { struct bridge_mcast_other_query ip4_other_query; struct bridge_mcast_own_query ip4_own_query; struct bridge_mcast_querier ip4_querier; + bool ip4_active; #if IS_ENABLED(CONFIG_IPV6) struct hlist_head ip6_mc_router_list; struct timer_list ip6_mc_router_timer; struct bridge_mcast_other_query ip6_other_query; struct bridge_mcast_own_query ip6_own_query; struct bridge_mcast_querier ip6_querier; + bool ip6_active; #endif /* IS_ENABLED(CONFIG_IPV6) */ #endif /* CONFIG_BRIDGE_IGMP_SNOOPING */ }; --=20 2.51.0 From nobody Sun Feb 8 04:34:22 2026 Received: from mail.aperture-lab.de (mail.aperture-lab.de [116.203.183.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA4B62C158D; Fri, 6 Feb 2026 03:01:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.183.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346903; cv=none; b=YqDMH4WcqfHvcR5BvkBy/heIfFwdrj8IdRKnlBAIrCJxgo/RPmS7jDyJ9Uof1pS82w+Uc617/b2ULZdxIdyngybTqOQHRl+oChfGBuBjzdk0XcQ1GdMDdG5LiD0pjah9g2tNTXOgAww58ixJiOXr8VUYxkIGY1Me6aROnBsB0z4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346903; c=relaxed/simple; bh=Vg1m8IVb3oIFf6NpWyEKT41GdiiGv/AuMj3dW4xUSvg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=j5+AdYeuc0lFWyE5bTwDccDpU9gqkTduAl1AliuQ9qnJXx2jvoucbRCh88v38vcXXnbAXLkvzl3EkQ3P7r75oew5NhY0LtzOiRfOaybglCp5KWIy3v+kKlVlYebqeh2m1GBwFvDkTA6xuwlQQuW4801IXW2Q+oVTecrAJnCPY7k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue; spf=pass smtp.mailfrom=c0d3.blue; arc=none smtp.client-ip=116.203.183.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c0d3.blue Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 0E13454C9F3; Fri, 6 Feb 2026 04:01:41 +0100 (CET) From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: bridge@lists.linux.dev Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nikolay Aleksandrov , Ido Schimmel , Andrew Lunn , Simon Horman , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S . Miller" , Kuniyuki Iwashima , Stanislav Fomichev , Xiao Liang , =?UTF-8?q?Linus=20L=C3=BCssing?= Subject: [PATCH net-next v2 05/14] net: bridge: mcast: track active state, foreign IGMP/MLD querier disappearance Date: Fri, 6 Feb 2026 03:52:11 +0100 Message-ID: <20260206030123.5430-6-linus.luessing@c0d3.blue> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260206030123.5430-1-linus.luessing@c0d3.blue> References: <20260206030123.5430-1-linus.luessing@c0d3.blue> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 This change ensures that the new multicast active state variable is unset again after a foreign IGMP/MLD querier has disappeared (default: 255 seconds). If no new, other IGMP/MLD querier took over then we can't reliably receive IGMP/MLD reports anymore and in turn can't ensure the completeness of our MDB anymore either. No functional change for the fast/data path yet. Signed-off-by: Linus L=C3=BCssing --- net/bridge/br_multicast.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index d5c623dce7eb..0fc29875db9c 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -1826,6 +1826,10 @@ static void br_multicast_querier_expired(struct net_= bridge_mcast *brmctx, br_multicast_start_querier(brmctx, query); =20 out: + /* another IGMP/MLD querier disappeared, set multicast state to inactive + * if our own querier is disabled, too + */ + br_multicast_update_active(brmctx); spin_unlock(&brmctx->br->multicast_lock); } =20 --=20 2.51.0 From nobody Sun Feb 8 04:34:22 2026 Received: from mail.aperture-lab.de (mail.aperture-lab.de [116.203.183.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DE0C2D0C7B; Fri, 6 Feb 2026 03:01:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.183.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346905; cv=none; b=IJ/WQgxXsQdUGlLuKDqXsanBq9BePZ4Ccg/UNJrVq3nOG7ehes0Nj8RLEKWpLYaSDn/OFBZuHZ/pxjL/VebU7O55+35fQKfaeZno66A6N4FP/HT8LdTlV8L7uzDV425QGOWyxplZ8hoEMb5eved2n01apuDS1j7c/VOurSlRgHo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346905; c=relaxed/simple; bh=wUKn8n14dinrn3FJum6dCEkusLQhrS5JLcrSjifh004=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AqOrYRNVp4K7aZ0Wo1OYnEvig80fK5G3epyctBLoR1xqYGzeqAn+RVHNpYFR41rEqanBU0lXZGliPI6tzFE7uH1s9405h4EjXtxNIZ9ZCnN5Lyfm8R5+HF5T9/R1tbi7M/Jo7IHuKQ9KmZZskO4LHxuF2KLR2A1Cy1HumgS7How= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue; spf=pass smtp.mailfrom=c0d3.blue; arc=none smtp.client-ip=116.203.183.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c0d3.blue Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1D17D54CCE1; Fri, 6 Feb 2026 04:01:42 +0100 (CET) From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: bridge@lists.linux.dev Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nikolay Aleksandrov , Ido Schimmel , Andrew Lunn , Simon Horman , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S . Miller" , Kuniyuki Iwashima , Stanislav Fomichev , Xiao Liang , =?UTF-8?q?Linus=20L=C3=BCssing?= Subject: [PATCH net-next v2 06/14] net: bridge: mcast: track active state, IPv6 address availability Date: Fri, 6 Feb 2026 03:52:12 +0100 Message-ID: <20260206030123.5430-7-linus.luessing@c0d3.blue> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260206030123.5430-1-linus.luessing@c0d3.blue> References: <20260206030123.5430-1-linus.luessing@c0d3.blue> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 If we are the only potential MLD querier but don't have an IPv6 link-local address configured on our bridge interface then we can't create a valid MLD query and in turn can't reliably receive MLD reports and can't build a complete MDB. Hence disable the new multicast active state variable then. Or reenable it if an IPv6 link-local address became available. No functional change for the fast/data path yet. Signed-off-by: Linus L=C3=BCssing --- net/bridge/br_multicast.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index 0fc29875db9c..a1cde2ba2a3e 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -1125,6 +1125,7 @@ static void br_multicast_notify_active(struct net_bri= dge_mcast *brmctx, * The multicast active state is set, per protocol family, if: * * - an IGMP/MLD querier is present + * - for own IPv6 MLD querier: an IPv6 address is configured on the bridge * * And is unset otherwise. * @@ -1222,10 +1223,12 @@ static struct sk_buff *br_ip6_multicast_alloc_query= (struct net_bridge_mcast *brm &ip6h->daddr, 0, &ip6h->saddr)) { kfree_skb(skb); br_opt_toggle(brmctx->br, BROPT_HAS_IPV6_ADDR, false); + br_multicast_update_active(brmctx); return NULL; } =20 br_opt_toggle(brmctx->br, BROPT_HAS_IPV6_ADDR, true); + br_multicast_update_active(brmctx); ipv6_eth_mc_map(&ip6h->daddr, eth->h_dest); =20 hopopt =3D (u8 *)(ip6h + 1); --=20 2.51.0 From nobody Sun Feb 8 04:34:22 2026 Received: from mail.aperture-lab.de (mail.aperture-lab.de [116.203.183.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8920527FD44; Fri, 6 Feb 2026 03:01:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.183.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346905; cv=none; b=dHGIk6ZEOZGruVL7eJCEgBmH1ANpxjMLcRq8s1eT+CjpWlZB6boEgT/2+fIQEPeVw4lAEdYJLvyu+BuqRzoNGyO6jwm8WsdLRMhln3fVVUcpfXfB6npprWy7Jd3/YIiISsZiShAt4Ot+IwPx6sqJzXiEt3+rzx55kMSGWl/15KU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346905; c=relaxed/simple; bh=qyLVb14+eW9VYQJVB33MvWCyVz0vC8NExEj1C4MBTTs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OmMPWW56MnS8+fuX90InbALmN1sKSNdgwBRoauMnqSXgj4m1/tUwhlBkUB+QLPD3bnkBLouVZy40aqPUQVZ5j1eCf8SaUqH1K18Caq8ar8CeZWSPf1E+dxfXj1TThHKlxc2ZRdJa/Ya8TooBDOmYN/nb8gqgtYnO54E4N+rphe8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue; spf=pass smtp.mailfrom=c0d3.blue; arc=none smtp.client-ip=116.203.183.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c0d3.blue Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 57B3354CD2B; Fri, 6 Feb 2026 04:01:43 +0100 (CET) From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: bridge@lists.linux.dev Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nikolay Aleksandrov , Ido Schimmel , Andrew Lunn , Simon Horman , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S . Miller" , Kuniyuki Iwashima , Stanislav Fomichev , Xiao Liang , =?UTF-8?q?Linus=20L=C3=BCssing?= Subject: [PATCH net-next v2 07/14] net: bridge: mcast: track active state, own MLD querier disappearance Date: Fri, 6 Feb 2026 03:52:13 +0100 Message-ID: <20260206030123.5430-8-linus.luessing@c0d3.blue> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260206030123.5430-1-linus.luessing@c0d3.blue> References: <20260206030123.5430-1-linus.luessing@c0d3.blue> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 This change ensures that the new multicast active state variable is immediately unset if our internal IGMP/MLD querier was elected and now disabled. If no IGMP/MLD querier exists on the link then we can't reliably receive IGMP/MLD reports and in turn can't ensure the completeness of our MDB anymore either. No functional change for the fast/data path yet. This is the last necessary check before using the new multicast active state variable in the fast/data path, too. Signed-off-by: Linus L=C3=BCssing --- net/bridge/br_multicast.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index a1cde2ba2a3e..2710c21daef5 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -4914,6 +4914,7 @@ int br_multicast_set_querier(struct net_bridge_mcast = *brmctx, unsigned long val) #endif =20 unlock: + br_multicast_update_active(brmctx); spin_unlock_bh(&brmctx->br->multicast_lock); =20 return 0; --=20 2.51.0 From nobody Sun Feb 8 04:34:22 2026 Received: from mail.aperture-lab.de (mail.aperture-lab.de [116.203.183.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E0102BE7AC; Fri, 6 Feb 2026 03:01:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.183.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346908; cv=none; b=Jjd0RGx5+FPm3f3k5Roq7XHpe2FoGdqDxsV4eJZ3KIDHK2d6XmqLRXVYXJeg0tXvqCGC2lYBusBL6PiVpdZOp5nQ/7zw9CRySSzWV0yAtPo1eikmUevBffHTGDUlyiQIuyvdmqm0K9Lg49/BbqZd+htdmUmFD7UMIS5+MzEHNBA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346908; c=relaxed/simple; bh=2RMhajnyurKwqlBINWP8s5UjZfkATxl4gAuPdZInAzU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GNgLafZqeHEROP2nKmNwfQgiy3qKKoQFE8Knrhq9JtICB/Xmm01n1Oz4VoHEitdAEkmma/DR6pjsw9MpVFPX5pGTsItukpGoAXuZ6PDP6uFIiDcURrwkScpv572fKn0N08vvLtJCQCfUtFhzxrcnIESbDr6nfu6DYKJfdzpdY7I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue; spf=pass smtp.mailfrom=c0d3.blue; arc=none smtp.client-ip=116.203.183.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c0d3.blue Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 8354454CD34; Fri, 6 Feb 2026 04:01:44 +0100 (CET) From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: bridge@lists.linux.dev Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nikolay Aleksandrov , Ido Schimmel , Andrew Lunn , Simon Horman , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S . Miller" , Kuniyuki Iwashima , Stanislav Fomichev , Xiao Liang , =?UTF-8?q?Linus=20L=C3=BCssing?= Subject: [PATCH net-next v2 08/14] net: bridge: mcast: track active state, if snooping is enabled Date: Fri, 6 Feb 2026 03:52:14 +0100 Message-ID: <20260206030123.5430-9-linus.luessing@c0d3.blue> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260206030123.5430-1-linus.luessing@c0d3.blue> References: <20260206030123.5430-1-linus.luessing@c0d3.blue> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 To be able to use the upcoming SWITCHDEV_ATTR_ID_BRIDGE_MC_ACTIVE as a potential replacement for SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED also check and toggle the active state if multicast snooping is enabled or disabled. So that MC_ACTIVE not only checks the querier state, but also if multicast snooping is enabled in general. No functional change for the fast/data path yet. Signed-off-by: Linus L=C3=BCssing --- include/uapi/linux/if_link.h | 6 ++++-- net/bridge/br_multicast.c | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index 3cb040aaa8dc..d68eeff21b73 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -748,12 +748,14 @@ enum in6_addr_gen_mode { * @IFLA_BR_MCAST_ACTIVE_V4 * Bridge IPv4 mcast active state, read only. * - * 1 if an IGMP querier is present, 0 otherwise. + * 1 if *IFLA_BR_MCAST_SNOOPING* is enabled and an IGMP querier is prese= nt, + * 0 otherwise. * * @IFLA_BR_MCAST_ACTIVE_V6 * Bridge IPv6 mcast active state, read only. * - * 1 if an MLD querier is present, 0 otherwise. + * 1 if *IFLA_BR_MCAST_SNOOPING* is enabled and an MLD querier is presen= t, + * 0 otherwise. */ enum { IFLA_BR_UNSPEC, diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index 2710c21daef5..4bdc3838c3dc 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -1124,6 +1124,7 @@ static void br_multicast_notify_active(struct net_bri= dge_mcast *brmctx, * * The multicast active state is set, per protocol family, if: * + * - multicast snooping is enabled * - an IGMP/MLD querier is present * - for own IPv6 MLD querier: an IPv6 address is configured on the bridge * @@ -1139,6 +1140,9 @@ static void br_multicast_update_active(struct net_bri= dge_mcast *brmctx) =20 lockdep_assert_held_once(&brmctx->br->multicast_lock); =20 + if (!br_opt_get(brmctx->br, BROPT_MULTICAST_ENABLED)) + force_inactive =3D true; + br_ip4_multicast_update_active(brmctx, force_inactive); br_ip6_multicast_update_active(brmctx, force_inactive); =20 @@ -1353,6 +1357,12 @@ static struct sk_buff *br_multicast_alloc_query(stru= ct net_bridge_mcast *brmctx, return NULL; } =20 +static void br_multicast_toggle_enabled(struct net_bridge *br, bool on) +{ + br_opt_toggle(br, BROPT_MULTICAST_ENABLED, on); + br_multicast_update_active(&br->multicast_ctx); +} + struct net_bridge_mdb_entry *br_multicast_new_group(struct net_bridge *br, struct br_ip *group) { @@ -1366,7 +1376,7 @@ struct net_bridge_mdb_entry *br_multicast_new_group(s= truct net_bridge *br, if (atomic_read(&br->mdb_hash_tbl.nelems) >=3D br->hash_max) { trace_br_mdb_full(br->dev, group); br_mc_disabled_update(br->dev, false, NULL); - br_opt_toggle(br, BROPT_MULTICAST_ENABLED, false); + br_multicast_toggle_enabled(br, false); return ERR_PTR(-E2BIG); } =20 @@ -4471,6 +4481,7 @@ void br_multicast_toggle_one_vlan(struct net_bridge_v= lan *vlan, bool on) =20 spin_lock_bh(&br->multicast_lock); vlan->priv_flags ^=3D BR_VLFLAG_MCAST_ENABLED; + br_multicast_update_active(&vlan->br_mcast_ctx); =20 if (on) __br_multicast_open(&vlan->br_mcast_ctx); @@ -4822,7 +4833,8 @@ int br_multicast_toggle(struct net_bridge *br, unsign= ed long val, if (err) goto unlock; =20 - br_opt_toggle(br, BROPT_MULTICAST_ENABLED, !!val); + br_multicast_toggle_enabled(br, !!val); + if (!br_opt_get(br, BROPT_MULTICAST_ENABLED)) { change_snoopers =3D true; br_multicast_del_grps(br); --=20 2.51.0 From nobody Sun Feb 8 04:34:22 2026 Received: from mail.aperture-lab.de (mail.aperture-lab.de [116.203.183.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0B2927FD44; Fri, 6 Feb 2026 03:01:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.183.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346909; cv=none; b=M3WA/+9BiDNczGo/dT1kEYq3F03+uC+DKGeMHmSm/qDN7zIfj9Yuxvo9varuR36AJlTGXH0BehVWomeoc0SvHRq8sj7z8nJEQI7PW00ATigXIIlq+J7eb6PYpJuy09IlXZwjxlb5vmXCU+loXkzaaN+gh0U13qzD93vG8OinzCI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346909; c=relaxed/simple; bh=Zr2wUGGxgg6vS/lNV+TUD6L8XZl3ijC1cFwiZ/BlnWk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jq53+dfjSS9uTwx46/4RRhTqQdJHi0GygqtAx5smcXqD8QGUO4VKMKJ5tTsfIHhWpxTdj9oiuknO4n0COliRRCg9RbNueX/PTKHiK5riRPFs+7Z+NLGmfdsYlK+fICF5MjIGiAm6TK6ir3QBKMke6F5ebe10MCzO7ApmKAfMZeQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue; spf=pass smtp.mailfrom=c0d3.blue; arc=none smtp.client-ip=116.203.183.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c0d3.blue Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 9EDE154C9F3; Fri, 6 Feb 2026 04:01:45 +0100 (CET) From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: bridge@lists.linux.dev Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nikolay Aleksandrov , Ido Schimmel , Andrew Lunn , Simon Horman , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S . Miller" , Kuniyuki Iwashima , Stanislav Fomichev , Xiao Liang , =?UTF-8?q?Linus=20L=C3=BCssing?= Subject: [PATCH net-next v2 09/14] net: bridge: mcast: track active state, VLAN snooping Date: Fri, 6 Feb 2026 03:52:15 +0100 Message-ID: <20260206030123.5430-10-linus.luessing@c0d3.blue> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260206030123.5430-1-linus.luessing@c0d3.blue> References: <20260206030123.5430-1-linus.luessing@c0d3.blue> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 If VLAN aware multicast snooping is enabled then we need to perform a few extra checks to figure out if multicast snooping is actually enabled for a specific VLAN, as there is then an additional per VLAN multicast snooping toggle. Signed-off-by: Linus L=C3=BCssing --- net/bridge/br_multicast.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index 4bdc3838c3dc..2a2f54009e0f 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -1143,6 +1143,26 @@ static void br_multicast_update_active(struct net_br= idge_mcast *brmctx) if (!br_opt_get(brmctx->br, BROPT_MULTICAST_ENABLED)) force_inactive =3D true; =20 + if (br_opt_get(brmctx->br, BROPT_MCAST_VLAN_SNOOPING_ENABLED)) { + /* with per-vlan snooping enabled there is an extra per-vlan + * toggle to enable/disable snooping which we must check + */ + if (br_multicast_ctx_vlan_global_disabled(brmctx)) + force_inactive =3D true; + + /* with per-vlan snooping enabled the non-vlan multicast + * snooping context is inactive + */ + if (!br_multicast_ctx_is_vlan(brmctx)) + force_inactive =3D true; + } else { + /* with per-vlan snooping disabled a vlan multicast + * snooping context is inactive + */ + if (br_multicast_ctx_is_vlan(brmctx)) + force_inactive =3D true; + } + br_ip4_multicast_update_active(brmctx, force_inactive); br_ip6_multicast_update_active(brmctx, force_inactive); =20 --=20 2.51.0 From nobody Sun Feb 8 04:34:22 2026 Received: from mail.aperture-lab.de (mail.aperture-lab.de [116.203.183.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E19BA29AAF7; Fri, 6 Feb 2026 03:01:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.183.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346909; cv=none; b=oDYlBe0DxDbtV8B40NRXPHzctL2rLUhyKB80xYQ0a57aQoq+enKrnAjCF9BoRmihT4TU6owj0EfabNBRAPxwkFcShWNmhZZktolXLf9hQO2P639W6SZeIeKbNod/zGxKYQPQX9JEO6264RoiAF0cVXyr595PlHUnqll4k8wloQY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346909; c=relaxed/simple; bh=WzOgRDEzXCAKgOdpd60w+Khy3HRoAi+tyKqU3rOIVqc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MqmkU7lkz+AApDiM+iFf1C6JjPJcTg80kgB0uyQrtqxC2fyaHtIgbqvlSMXE9/XFX82a6YbaoNoLEwFBBXuqao90hXRUovpZYF3Ama4F4JZxMRtNGaYNuEBzZGsrK3Xs67Hf5dK68cW1LtGlBB/xn3YdsavQVfgXU89r9EIw5o4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue; spf=pass smtp.mailfrom=c0d3.blue; arc=none smtp.client-ip=116.203.183.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c0d3.blue Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id EFB5E54CCE1; Fri, 6 Feb 2026 04:01:46 +0100 (CET) From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: bridge@lists.linux.dev Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nikolay Aleksandrov , Ido Schimmel , Andrew Lunn , Simon Horman , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S . Miller" , Kuniyuki Iwashima , Stanislav Fomichev , Xiao Liang , =?UTF-8?q?Linus=20L=C3=BCssing?= Subject: [PATCH net-next v2 10/14] net: bridge: mcast: track active state, bridge up/down Date: Fri, 6 Feb 2026 03:52:16 +0100 Message-ID: <20260206030123.5430-11-linus.luessing@c0d3.blue> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260206030123.5430-1-linus.luessing@c0d3.blue> References: <20260206030123.5430-1-linus.luessing@c0d3.blue> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 This is mainly for switchdev and DSA later: To ensure that we switch to inactive before destroying a bridge interface. A switchdev/DSA driver might have allocated resources after we switched to an enabled multicast active state. This gives switchdev/DSA drivers a chance to free these resources again when we destroy the bridge (later). Putting it into the ndo_stop / bridge interface down part instead of the ndo_uninit / bridge destroy part though for a better semantic match. If the bridge interface is down / stopped then it is also inactive. No functional change for the fast/data path. Signed-off-by: Linus L=C3=BCssing --- include/uapi/linux/if_link.h | 8 ++++---- net/bridge/br_multicast.c | 10 ++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index d68eeff21b73..4ce9ddee94e8 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -748,14 +748,14 @@ enum in6_addr_gen_mode { * @IFLA_BR_MCAST_ACTIVE_V4 * Bridge IPv4 mcast active state, read only. * - * 1 if *IFLA_BR_MCAST_SNOOPING* is enabled and an IGMP querier is prese= nt, - * 0 otherwise. + * 1 if *IFLA_BR_MCAST_SNOOPING* is enabled, an IGMP querier is present + * and the bridge interface is up, 0 otherwise. * * @IFLA_BR_MCAST_ACTIVE_V6 * Bridge IPv6 mcast active state, read only. * - * 1 if *IFLA_BR_MCAST_SNOOPING* is enabled and an MLD querier is presen= t, - * 0 otherwise. + * 1 if *IFLA_BR_MCAST_SNOOPING* is enabled, an MLD querier is present + * and the bridge interface is up, 0 otherwise. */ enum { IFLA_BR_UNSPEC, diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index 2a2f54009e0f..7a32c6bed111 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -1124,6 +1124,7 @@ static void br_multicast_notify_active(struct net_bri= dge_mcast *brmctx, * * The multicast active state is set, per protocol family, if: * + * - the bridge interface is up * - multicast snooping is enabled * - an IGMP/MLD querier is present * - for own IPv6 MLD querier: an IPv6 address is configured on the bridge @@ -1140,6 +1141,9 @@ static void br_multicast_update_active(struct net_bri= dge_mcast *brmctx) =20 lockdep_assert_held_once(&brmctx->br->multicast_lock); =20 + if (!netif_running(brmctx->br->dev)) + force_inactive =3D true; + if (!br_opt_get(brmctx->br, BROPT_MULTICAST_ENABLED)) force_inactive =3D true; =20 @@ -4412,6 +4416,9 @@ static void __br_multicast_open(struct net_bridge_mca= st *brmctx) #if IS_ENABLED(CONFIG_IPV6) __br_multicast_open_query(brmctx->br, &brmctx->ip6_own_query); #endif + + /* bridge interface is up, maybe set multicast state to active */ + br_multicast_update_active(brmctx); } =20 void br_multicast_open(struct net_bridge *br) @@ -4452,6 +4459,9 @@ static void __br_multicast_stop(struct net_bridge_mca= st *brmctx) timer_shutdown(&brmctx->ip6_other_query.delay_timer); timer_shutdown(&brmctx->ip6_own_query.timer); #endif + + /* bridge interface is down, set multicast state to inactive */ + br_multicast_update_active(brmctx); } =20 void br_multicast_update_vlan_mcast_ctx(struct net_bridge_vlan *v, u8 stat= e) --=20 2.51.0 From nobody Sun Feb 8 04:34:22 2026 Received: from mail.aperture-lab.de (mail.aperture-lab.de [116.203.183.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21D572DCC1C; Fri, 6 Feb 2026 03:01:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.183.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346911; cv=none; b=M7cl573cqzYKwJLlZGe3JG6cux81oyHJkIF/gbAsw2SJWBx/nqxU22Dnsj+hugK02xQTlliahnyL6B4lqEN6rdiSTS/y4zTd/NPDOhqcfGoExzOxoAL4ucfX0n5RKREHrJo1Wq6o6qrHB/S1dhraApx7rVryJWZcJeCnK0XE6xw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346911; c=relaxed/simple; bh=4fl1V0CGDvMUNrGqV03Fu0NDWvm5RDAtj7uzXrw/22U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LBjWG0nFIeK57qIa8nQgkI0oOADBXsyrdhbJSFPbMW632hMkKE6y5i7TX7VZKxXBlX/KTS1J+5EHZedjPPOONHujCmFSAGdIOj/Nk459o9ZURisC8P2nM7qh7xFFOJZbi1ETwlk4Cnk2S+YUtez9SBYqI+XvNU1YuMqbP5fuMQE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue; spf=pass smtp.mailfrom=c0d3.blue; arc=none smtp.client-ip=116.203.183.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c0d3.blue Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 170B054CD2B; Fri, 6 Feb 2026 04:01:48 +0100 (CET) From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: bridge@lists.linux.dev Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nikolay Aleksandrov , Ido Schimmel , Andrew Lunn , Simon Horman , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S . Miller" , Kuniyuki Iwashima , Stanislav Fomichev , Xiao Liang , =?UTF-8?q?Linus=20L=C3=BCssing?= Subject: [PATCH net-next v2 11/14] net: bridge: mcast: track active state, prepare for outside lock reads Date: Fri, 6 Feb 2026 03:52:17 +0100 Message-ID: <20260206030123.5430-12-linus.luessing@c0d3.blue> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260206030123.5430-1-linus.luessing@c0d3.blue> References: <20260206030123.5430-1-linus.luessing@c0d3.blue> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 We are updating ip{4,6}_active and check all variables their state relies on while holding the bridge multicast spinlock. However we are going to read it without this lock in a follow-up commit on fast/data path, too. As these variables are only booleans this shouldn't be a problem, ip{4,6}_active will be loaded and stored atomically. And those read sides should converge eventually. But to allow tooling to verify this use the READ_ONCE() and WRITE_ONCE macros. Signed-off-by: Linus L=C3=BCssing --- net/bridge/br_multicast.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index 7a32c6bed111..48552720bcea 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -1085,9 +1085,9 @@ static void br_ip4_multicast_update_active(struct net= _bridge_mcast *brmctx, bool force_inactive) { if (force_inactive) - brmctx->ip4_active =3D false; + WRITE_ONCE(brmctx->ip4_active, false); else - brmctx->ip4_active =3D br_ip4_multicast_querier_exists(brmctx); + WRITE_ONCE(brmctx->ip4_active, br_ip4_multicast_querier_exists(brmctx)); } =20 static void br_ip6_multicast_update_active(struct net_bridge_mcast *brmctx, @@ -1095,23 +1095,25 @@ static void br_ip6_multicast_update_active(struct n= et_bridge_mcast *brmctx, { #if IS_ENABLED(CONFIG_IPV6) if (force_inactive) - brmctx->ip6_active =3D false; + WRITE_ONCE(brmctx->ip6_active, false); else - brmctx->ip6_active =3D br_ip6_multicast_querier_exists(brmctx); + WRITE_ONCE(brmctx->ip6_active, br_ip6_multicast_querier_exists(brmctx)); #endif } =20 static void br_multicast_notify_active(struct net_bridge_mcast *brmctx, bool ip4_active_old, bool ip6_active_old) { - if (brmctx->ip4_active =3D=3D ip4_active_old && - brmctx->ip6_active =3D=3D ip6_active_old) + int ip4_active =3D READ_ONCE(brmctx->ip4_active); + int ip6_active =3D READ_ONCE(brmctx->ip6_active); + + if (ip4_active =3D=3D ip4_active_old && + ip6_active =3D=3D ip6_active_old) return; =20 br_info(brmctx->br, "mc_active changed, vid: %i: v4: %i->%i, v6: %i->%i\n= ", brmctx->vlan ? brmctx->vlan->vid : -1, - ip4_active_old, brmctx->ip4_active, - ip6_active_old, brmctx->ip6_active); + ip4_active_old, ip4_active, ip6_active_old, ip6_active); } =20 /** @@ -1136,7 +1138,8 @@ static void br_multicast_notify_active(struct net_bri= dge_mcast *brmctx, */ static void br_multicast_update_active(struct net_bridge_mcast *brmctx) { - bool ip4_active_old =3D brmctx->ip4_active, ip6_active_old =3D brmctx->ip= 6_active; + bool ip4_active_old =3D READ_ONCE(brmctx->ip4_active); + bool ip6_active_old =3D READ_ONCE(brmctx->ip6_active); bool force_inactive =3D false; =20 lockdep_assert_held_once(&brmctx->br->multicast_lock); @@ -4266,13 +4269,13 @@ void br_multicast_ctx_init(struct net_bridge *br, brmctx->multicast_membership_interval =3D 260 * HZ; =20 brmctx->ip4_querier.port_ifidx =3D 0; - brmctx->ip4_active =3D 0; + WRITE_ONCE(brmctx->ip4_active, 0); seqcount_spinlock_init(&brmctx->ip4_querier.seq, &br->multicast_lock); brmctx->multicast_igmp_version =3D 2; #if IS_ENABLED(CONFIG_IPV6) brmctx->multicast_mld_version =3D 1; brmctx->ip6_querier.port_ifidx =3D 0; - brmctx->ip6_active =3D 0; + WRITE_ONCE(brmctx->ip6_active, 0); seqcount_spinlock_init(&brmctx->ip6_querier.seq, &br->multicast_lock); #endif =20 --=20 2.51.0 From nobody Sun Feb 8 04:34:22 2026 Received: from mail.aperture-lab.de (mail.aperture-lab.de [116.203.183.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4408321CFE0; Fri, 6 Feb 2026 03:01:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.183.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346911; cv=none; b=QIcb56XcX40ctlosYxqqXFQMR2irJRglxqlmhx14wfMKd4BAVg2BlP13niPrb2rSlY8ZiCpiqs3ZIhJfHdezimOYhhgm6bMK9E2WcjIEYenduGgqctNl4E/F36jdah7MEi85Te90sHmBEl9fL6LC5IZiS3Wohdc+7cuKhDRLPtg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346911; c=relaxed/simple; bh=e7gYPxwjXSvowlpp+bHbVcMmnV+svvWXurup9/rR6Ro=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AZS2tfytnfG5Y7z5VRlLGJzqm/ocQ3ud0LmHRimm8eDS4y8FmaRtJH2gh94YVczYx18JDrVvmryf6QDE6wBcMDFWI0BK70VWi5PYEfur+zuoRhrfruxyoxMnWp8fYtMjmyksBYZf/xcc1AK8QbzVybi79XmKQRV6sGvkOjz9znE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue; spf=pass smtp.mailfrom=c0d3.blue; arc=none smtp.client-ip=116.203.183.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c0d3.blue Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 4FBE754CD34; Fri, 6 Feb 2026 04:01:49 +0100 (CET) From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: bridge@lists.linux.dev Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nikolay Aleksandrov , Ido Schimmel , Andrew Lunn , Simon Horman , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S . Miller" , Kuniyuki Iwashima , Stanislav Fomichev , Xiao Liang , =?UTF-8?q?Linus=20L=C3=BCssing?= Subject: [PATCH net-next v2 12/14] net: bridge: mcast: use combined active state in netlink Date: Fri, 6 Feb 2026 03:52:18 +0100 Message-ID: <20260206030123.5430-13-linus.luessing@c0d3.blue> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260206030123.5430-1-linus.luessing@c0d3.blue> References: <20260206030123.5430-1-linus.luessing@c0d3.blue> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Use the new multicast ip{4,6}_active variables for the netlink output. The result for the user should be the same. But this allows us to check that from userspace tests, to ensure that ip{4,6}_active behave as intended for the upcoming fast/data path changes. Signed-off-by: Linus L=C3=BCssing --- net/bridge/br_netlink.c | 10 ++-------- net/bridge/br_private.h | 2 +- net/bridge/br_vlan_options.c | 16 +++------------- 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c index 1b5ab1fb4558..e79fddf747f8 100644 --- a/net/bridge/br_netlink.c +++ b/net/bridge/br_netlink.c @@ -1650,8 +1650,6 @@ static int br_fill_info(struct sk_buff *skb, const st= ruct net_device *brdev) u32 ageing_time =3D jiffies_to_clock_t(br->ageing_time); u32 stp_enabled =3D br->stp_enabled; u16 priority =3D (br->bridge_id.prio[0] << 8) | br->bridge_id.prio[1]; - struct ethhdr eth6 =3D { .h_proto =3D htons(ETH_P_IPV6) }; - struct ethhdr eth4 =3D { .h_proto =3D htons(ETH_P_IP) }; u8 vlan_enabled =3D br_vlan_enabled(br->dev); struct br_boolopt_multi bm; u64 clockval; @@ -1724,9 +1722,7 @@ static int br_fill_info(struct sk_buff *skb, const st= ruct net_device *brdev) nla_put_u8(skb, IFLA_BR_MCAST_IGMP_VERSION, br->multicast_ctx.multicast_igmp_version) || nla_put_u8(skb, IFLA_BR_MCAST_ACTIVE_V4, - netif_running(brdev) && br_opt_get(br, BROPT_MULTICAST_ENABLED) && - !br_opt_get(br, BROPT_MCAST_VLAN_SNOOPING_ENABLED) && - br_multicast_querier_exists(&br->multicast_ctx, ð4, NULL)) || + READ_ONCE(br->multicast_ctx.ip4_active)) || br_multicast_dump_querier_state(skb, &br->multicast_ctx, IFLA_BR_MCAST_QUERIER_STATE)) return -EMSGSIZE; @@ -1734,9 +1730,7 @@ static int br_fill_info(struct sk_buff *skb, const st= ruct net_device *brdev) if (nla_put_u8(skb, IFLA_BR_MCAST_MLD_VERSION, br->multicast_ctx.multicast_mld_version) || nla_put_u8(skb, IFLA_BR_MCAST_ACTIVE_V6, - netif_running(brdev) && br_opt_get(br, BROPT_MULTICAST_ENABLED) && - !br_opt_get(br, BROPT_MCAST_VLAN_SNOOPING_ENABLED) && - br_multicast_querier_exists(&br->multicast_ctx, ð6, NULL))) + READ_ONCE(br->multicast_ctx.ip6_active))) return -EMSGSIZE; #endif clockval =3D jiffies_to_clock_t(br->multicast_ctx.multicast_last_member_i= nterval); diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 4cc59abdb8e1..8150ecc2c919 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -1899,7 +1899,7 @@ int br_vlan_rtm_process_global_options(struct net_dev= ice *dev, bool br_vlan_global_opts_can_enter_range(const struct net_bridge_vlan *v_c= urr, const struct net_bridge_vlan *r_end); bool br_vlan_global_opts_fill(struct sk_buff *skb, u16 vid, u16 vid_range, - struct net_bridge_vlan *v_opts); + const struct net_bridge_vlan *v_opts); =20 /* vlan state manipulation helpers using *_ONCE to annotate lock-free acce= ss, * while br_vlan_set_state() may access data protected by multicast_lock. diff --git a/net/bridge/br_vlan_options.c b/net/bridge/br_vlan_options.c index 6425fa509b95..dcb214b5507d 100644 --- a/net/bridge/br_vlan_options.c +++ b/net/bridge/br_vlan_options.c @@ -347,10 +347,8 @@ bool br_vlan_global_opts_can_enter_range(const struct = net_bridge_vlan *v_curr, } =20 bool br_vlan_global_opts_fill(struct sk_buff *skb, u16 vid, u16 vid_range, - struct net_bridge_vlan *v_opts) + const struct net_bridge_vlan *v_opts) { - struct ethhdr eth6 =3D { .h_proto =3D htons(ETH_P_IPV6) }; - struct ethhdr eth4 =3D { .h_proto =3D htons(ETH_P_IP) }; struct nlattr *nest2 __maybe_unused; u64 clockval __maybe_unused; struct nlattr *nest; @@ -372,11 +370,7 @@ bool br_vlan_global_opts_fill(struct sk_buff *skb, u16= vid, u16 vid_range, nla_put_u8(skb, BRIDGE_VLANDB_GOPTS_MCAST_IGMP_VERSION, v_opts->br_mcast_ctx.multicast_igmp_version) || nla_put_u8(skb, BRIDGE_VLANDB_GOPTS_MCAST_ACTIVE_V4, - netif_running(v_opts->br->dev) && - br_opt_get(v_opts->br, BROPT_MULTICAST_ENABLED) && - br_opt_get(v_opts->br, BROPT_MCAST_VLAN_SNOOPING_ENABLED) && - !br_multicast_ctx_vlan_global_disabled(&v_opts->br_mcast_ctx) && - br_multicast_querier_exists(&v_opts->br_mcast_ctx, ð4, NULL)) = || + READ_ONCE(v_opts->br_mcast_ctx.ip4_active)) || nla_put_u32(skb, BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_CNT, v_opts->br_mcast_ctx.multicast_last_member_count) || nla_put_u32(skb, BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_CNT, @@ -433,11 +427,7 @@ bool br_vlan_global_opts_fill(struct sk_buff *skb, u16= vid, u16 vid_range, if (nla_put_u8(skb, BRIDGE_VLANDB_GOPTS_MCAST_MLD_VERSION, v_opts->br_mcast_ctx.multicast_mld_version) || nla_put_u8(skb, BRIDGE_VLANDB_GOPTS_MCAST_ACTIVE_V6, - netif_running(v_opts->br->dev) && - br_opt_get(v_opts->br, BROPT_MULTICAST_ENABLED) && - br_opt_get(v_opts->br, BROPT_MCAST_VLAN_SNOOPING_ENABLED) && - !br_multicast_ctx_vlan_global_disabled(&v_opts->br_mcast_ctx) && - br_multicast_querier_exists(&v_opts->br_mcast_ctx, ð6, NULL))) + READ_ONCE(v_opts->br_mcast_ctx.ip6_active))) goto out_err; #endif #endif --=20 2.51.0 From nobody Sun Feb 8 04:34:22 2026 Received: from mail.aperture-lab.de (mail.aperture-lab.de [116.203.183.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 874AD2D0635; Fri, 6 Feb 2026 03:01:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.183.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346914; cv=none; b=EClFNG2m2aS2meDVBI1/ICzE2NKHXPUn7Uack9Q/EKG4EyBb8tGCQ8CoF2dWsFd0BVObdiJDzv/0UwTbKMDUsoQCxZzcbKYMA29wmIGpmnD4OurVfW+9ql7tSLPCpyRDKymBCHu/KBFTzye4RSQaOW/qXMpsvGwxRK7/Uy2rsek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346914; c=relaxed/simple; bh=vf9e3Znt6irBz3urKBHCRKewIFWmdkO2QBi75X3aqdQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WL4ql5RpAcWgOa3y0S5LegSfQ3Jsr6PiwSWm7d01wai5A+BQYy05Cu9rtcMAwKlTh0dxVZ0+Jr96mZAG5hADJbbKg/udcnxud+hqqNaolVfCiQliKhYWAWuD3nz57q2IpDyG1V3ZRgNJLb1EMqEYu4LQIp1XbknSKTuNnhuge+M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue; spf=pass smtp.mailfrom=c0d3.blue; arc=none smtp.client-ip=116.203.183.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c0d3.blue Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 6683854CD38; Fri, 6 Feb 2026 04:01:50 +0100 (CET) From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: bridge@lists.linux.dev Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nikolay Aleksandrov , Ido Schimmel , Andrew Lunn , Simon Horman , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S . Miller" , Kuniyuki Iwashima , Stanislav Fomichev , Xiao Liang , =?UTF-8?q?Linus=20L=C3=BCssing?= Subject: [PATCH net-next v2 13/14] net: bridge: mcast: use combined active state in fast/data path Date: Fri, 6 Feb 2026 03:52:19 +0100 Message-ID: <20260206030123.5430-14-linus.luessing@c0d3.blue> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260206030123.5430-1-linus.luessing@c0d3.blue> References: <20260206030123.5430-1-linus.luessing@c0d3.blue> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 As the multicast active state variable is now always up to date and functionally equivalent to our manual, extensive checks in fast path we can just use this state variable in fast path, too. This allows to save some CPU cycles for every multicast packet in the fast/data path. Next to using brmctx->ip4_active / brmctx->ip6_active in fast path this mostly just moves some code around to not expose it via br_private.h anymore. While at it now also passing the ethernet protocol number directly, instead of a pointer into the ethernet header. Signed-off-by: Linus L=C3=BCssing --- net/bridge/br_device.c | 2 +- net/bridge/br_input.c | 2 +- net/bridge/br_multicast.c | 40 ++++++++++++++++++++++++++++++++++----- net/bridge/br_private.h | 38 ++++++++----------------------------- 4 files changed, 45 insertions(+), 37 deletions(-) diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index d9d1227d5708..ab7b54eb646e 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c @@ -102,7 +102,7 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net= _device *dev) =20 mdst =3D br_mdb_entry_skb_get(brmctx, skb, vid); if ((mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb)) && - br_multicast_querier_exists(brmctx, eth_hdr(skb), mdst)) + br_multicast_snooping_active(brmctx, eth_hdr(skb)->h_proto, mdst)) br_multicast_flood(mdst, skb, brmctx, false, true); else br_flood(br, skb, BR_PKT_MULTICAST, false, true, vid); diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c index 1405f1061a54..c3dd8781a1b5 100644 --- a/net/bridge/br_input.c +++ b/net/bridge/br_input.c @@ -187,7 +187,7 @@ int br_handle_frame_finish(struct net *net, struct sock= *sk, struct sk_buff *skb case BR_PKT_MULTICAST: mdst =3D br_mdb_entry_skb_get(brmctx, skb, vid); if ((mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb)) && - br_multicast_querier_exists(brmctx, eth_hdr(skb), mdst)) { + br_multicast_snooping_active(brmctx, eth_hdr(skb)->h_proto, mdst)) { if ((mdst && mdst->host_joined) || br_multicast_is_router(brmctx, skb) || br->dev->flags & IFF_ALLMULTI) { diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index 48552720bcea..8ad1b8fec3c5 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -1069,6 +1069,26 @@ static struct sk_buff *br_ip4_multicast_alloc_query(= struct net_bridge_mcast *brm return skb; } =20 +static bool +__br_multicast_querier_exists(struct net_bridge_mcast *brmctx, + struct bridge_mcast_other_query *querier, + bool is_ipv6) +{ + bool own_querier_enabled; + + if (brmctx->multicast_querier) { + if (is_ipv6 && !br_opt_get(brmctx->br, BROPT_HAS_IPV6_ADDR)) + own_querier_enabled =3D false; + else + own_querier_enabled =3D true; + } else { + own_querier_enabled =3D false; + } + + return !timer_pending(&querier->delay_timer) && + (own_querier_enabled || timer_pending(&querier->timer)); +} + static bool br_ip4_multicast_querier_exists(struct net_bridge_mcast *brmct= x) { return __br_multicast_querier_exists(brmctx, &brmctx->ip4_other_query, fa= lse); @@ -1081,6 +1101,20 @@ static bool br_ip6_multicast_querier_exists(struct n= et_bridge_mcast *brmctx) } #endif =20 +static bool br_multicast_querier_exists(struct net_bridge_mcast *brmctx, i= nt proto) +{ + switch (proto) { + case (ETH_P_IP): + return br_ip4_multicast_querier_exists(brmctx); +#if IS_ENABLED(CONFIG_IPV6) + case (ETH_P_IPV6): + return br_ip6_multicast_querier_exists(brmctx); +#endif + default: + return false; + } +} + static void br_ip4_multicast_update_active(struct net_bridge_mcast *brmctx, bool force_inactive) { @@ -5123,7 +5157,6 @@ bool br_multicast_has_querier_anywhere(struct net_dev= ice *dev, int proto) { struct net_bridge *br; struct net_bridge_port *port; - struct ethhdr eth; bool ret =3D false; =20 rcu_read_lock(); @@ -5136,10 +5169,7 @@ bool br_multicast_has_querier_anywhere(struct net_de= vice *dev, int proto) =20 br =3D port->br; =20 - memset(ð, 0, sizeof(eth)); - eth.h_proto =3D htons(proto); - - ret =3D br_multicast_querier_exists(&br->multicast_ctx, ð, NULL); + ret =3D br_multicast_querier_exists(&br->multicast_ctx, proto); =20 unlock: rcu_read_unlock(); diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 8150ecc2c919..75684f8079f2 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -1159,37 +1159,15 @@ br_multicast_is_router(struct net_bridge_mcast *brm= ctx, struct sk_buff *skb) } =20 static inline bool -__br_multicast_querier_exists(struct net_bridge_mcast *brmctx, - struct bridge_mcast_other_query *querier, - const bool is_ipv6) +br_multicast_snooping_active(struct net_bridge_mcast *brmctx, __be16 eth_p= roto, + const struct net_bridge_mdb_entry *mdb) { - bool own_querier_enabled; - - if (brmctx->multicast_querier) { - if (is_ipv6 && !br_opt_get(brmctx->br, BROPT_HAS_IPV6_ADDR)) - own_querier_enabled =3D false; - else - own_querier_enabled =3D true; - } else { - own_querier_enabled =3D false; - } - - return !timer_pending(&querier->delay_timer) && - (own_querier_enabled || timer_pending(&querier->timer)); -} - -static inline bool br_multicast_querier_exists(struct net_bridge_mcast *br= mctx, - struct ethhdr *eth, - const struct net_bridge_mdb_entry *mdb) -{ - switch (eth->h_proto) { + switch (eth_proto) { case (htons(ETH_P_IP)): - return __br_multicast_querier_exists(brmctx, - &brmctx->ip4_other_query, false); + return READ_ONCE(brmctx->ip4_active); #if IS_ENABLED(CONFIG_IPV6) case (htons(ETH_P_IPV6)): - return __br_multicast_querier_exists(brmctx, - &brmctx->ip6_other_query, true); + return READ_ONCE(brmctx->ip6_active); #endif default: return !!mdb && br_group_is_l2(&mdb->addr); @@ -1448,9 +1426,9 @@ static inline bool br_multicast_is_router(struct net_= bridge_mcast *brmctx, return false; } =20 -static inline bool br_multicast_querier_exists(struct net_bridge_mcast *br= mctx, - struct ethhdr *eth, - const struct net_bridge_mdb_entry *mdb) +static inline bool +br_multicast_snooping_active(struct net_bridge_mcast *brmctx, __be16 eth_p= roto, + const struct net_bridge_mdb_entry *mdb) { return false; } --=20 2.51.0 From nobody Sun Feb 8 04:34:22 2026 Received: from mail.aperture-lab.de (mail.aperture-lab.de [116.203.183.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BC1B2D0602; Fri, 6 Feb 2026 03:01:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.183.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346913; cv=none; b=vBaGRhTDljIjJyNpmas5VPVdDLsZdRChLinfQqkm9DavV2Su155JG6AD4XG4XqDLAmgi/6hDV57dKMsBOUdvh3lhwf0X8Mnu7+WHAC/85IbC3VX21y9JZP5tQeG+5Ump6BYznM1OkbccAPESWWArvpArVv57bZysuwP6lz+C0uE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770346913; c=relaxed/simple; bh=frhcBkgkTFKwzX3pWSel+U+buO3DsSct1uWmviR1Bsk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=e/qPDvj7aOJtQ0AColteGhb5crVvfTfV3+O7H5sJG1w+wXPlOvuLR40HE0V9NU9CEDIDshTAOTaQX4h9pr77V0dyhjH6eOmSEud5EZseS3k5EstCy7zf70ReuoAw4OVoDRgdVtgEojY1Deh4Q6ZhdAUO8tX5xEV+wN2tk+FMiBs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue; spf=pass smtp.mailfrom=c0d3.blue; arc=none smtp.client-ip=116.203.183.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c0d3.blue Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c0d3.blue Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 9AC6554C9F3; Fri, 6 Feb 2026 04:01:51 +0100 (CET) From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: bridge@lists.linux.dev Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nikolay Aleksandrov , Ido Schimmel , Andrew Lunn , Simon Horman , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S . Miller" , Kuniyuki Iwashima , Stanislav Fomichev , Xiao Liang , =?UTF-8?q?Linus=20L=C3=BCssing?= Subject: [PATCH net-next v2 14/14] net: bridge: mcast: add inactive state assertions Date: Fri, 6 Feb 2026 03:52:20 +0100 Message-ID: <20260206030123.5430-15-linus.luessing@c0d3.blue> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260206030123.5430-1-linus.luessing@c0d3.blue> References: <20260206030123.5430-1-linus.luessing@c0d3.blue> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 To avoid packetloss and as it is very hard from a user's perspective to debug multicast snooping related issues it is even more crucial to properly switch from an active to an inactive multicast snooping state than the other way around. Therefore adding a few kernel warnings if any of our assertions to be in an inactive state would fail. Signed-off-by: Linus L=C3=BCssing --- net/bridge/br_multicast.c | 43 +++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index 8ad1b8fec3c5..5c6c00776dee 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -1418,10 +1418,29 @@ static struct sk_buff *br_multicast_alloc_query(str= uct net_bridge_mcast *brmctx, return NULL; } =20 +static void br_ip4_multicast_assert_inactive(struct net_bridge_mcast *brmc= tx) +{ + WARN_ON(br_multicast_snooping_active(brmctx, htons(ETH_P_IP), NULL)); +} + +static void br_ip6_multicast_assert_inactive(struct net_bridge_mcast *brmc= tx) +{ + WARN_ON(br_multicast_snooping_active(brmctx, htons(ETH_P_IPV6), NULL)); +} + +static void br_multicast_assert_inactive(struct net_bridge_mcast *brmctx) +{ + br_ip4_multicast_assert_inactive(brmctx); + br_ip6_multicast_assert_inactive(brmctx); +} + static void br_multicast_toggle_enabled(struct net_bridge *br, bool on) { br_opt_toggle(br, BROPT_MULTICAST_ENABLED, on); br_multicast_update_active(&br->multicast_ctx); + + if (!on) + br_multicast_assert_inactive(&br->multicast_ctx); } =20 struct net_bridge_mdb_entry *br_multicast_new_group(struct net_bridge *br, @@ -1891,9 +1910,7 @@ static void br_multicast_querier_expired(struct net_b= ridge_mcast *brmctx, struct bridge_mcast_own_query *query, struct timer_list *timer) { - spin_lock(&brmctx->br->multicast_lock); - if (br_multicast_stopping(brmctx->br, timer) || - br_multicast_ctx_vlan_global_disabled(brmctx) || + if (br_multicast_ctx_vlan_global_disabled(brmctx) || !br_opt_get(brmctx->br, BROPT_MULTICAST_ENABLED)) goto out; =20 @@ -1904,7 +1921,6 @@ static void br_multicast_querier_expired(struct net_b= ridge_mcast *brmctx, * if our own querier is disabled, too */ br_multicast_update_active(brmctx); - spin_unlock(&brmctx->br->multicast_lock); } =20 static void br_ip4_multicast_querier_expired(struct timer_list *t) @@ -1912,7 +1928,16 @@ static void br_ip4_multicast_querier_expired(struct = timer_list *t) struct net_bridge_mcast *brmctx =3D timer_container_of(brmctx, t, ip4_other_query.timer); =20 + spin_lock(&brmctx->br->multicast_lock); + if (br_multicast_stopping(brmctx->br, t)) + goto out; + br_multicast_querier_expired(brmctx, &brmctx->ip4_own_query, t); + + if (!brmctx->multicast_querier) + br_ip4_multicast_assert_inactive(brmctx); +out: + spin_unlock(&brmctx->br->multicast_lock); } =20 #if IS_ENABLED(CONFIG_IPV6) @@ -1921,7 +1946,16 @@ static void br_ip6_multicast_querier_expired(struct = timer_list *t) struct net_bridge_mcast *brmctx =3D timer_container_of(brmctx, t, ip6_other_query.timer); =20 + spin_lock(&brmctx->br->multicast_lock); + if (br_multicast_stopping(brmctx->br, t)) + goto out; + br_multicast_querier_expired(brmctx, &brmctx->ip6_own_query, t); + + if (!brmctx->multicast_querier) + br_ip6_multicast_assert_inactive(brmctx); +out: + spin_unlock(&brmctx->br->multicast_lock); } #endif =20 @@ -4499,6 +4533,7 @@ static void __br_multicast_stop(struct net_bridge_mca= st *brmctx) =20 /* bridge interface is down, set multicast state to inactive */ br_multicast_update_active(brmctx); + br_multicast_assert_inactive(brmctx); } =20 void br_multicast_update_vlan_mcast_ctx(struct net_bridge_vlan *v, u8 stat= e) --=20 2.51.0