From: Nikolay Aleksandrov <nikolay@nvidia.com>
To: "Linus Lüssing" <linus.luessing@c0d3.blue>
Cc: bridge@lists.linux.dev, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
Ido Schimmel <idosch@nvidia.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Simon Horman <horms@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Jakub Kicinski <kuba@kernel.org>,
Eric Dumazet <edumazet@google.com>,
"David S . Miller" <davem@davemloft.net>,
Kuniyuki Iwashima <kuniyu@google.com>,
Stanislav Fomichev <sdf@fomichev.me>,
Xiao Liang <shaw.leon@gmail.com>,
shuah@kernel.org
Subject: Re: [PATCH net-next v3 14/14] net: bridge: mcast: add inactive state assertions
Date: Mon, 2 Mar 2026 15:23:29 +0200 [thread overview]
Message-ID: <aaWPUbG3_X4s8T0R@penguin> (raw)
In-Reply-To: <20260302054008.21638-15-linus.luessing@c0d3.blue>
On Mon, Mar 02, 2026 at 06:40:08AM +0100, Linus Lüssing wrote:
> 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üssing <linus.luessing@c0d3.blue>
> ---
> 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 4a1005bb68f1..106d6dd78328 100644
> --- a/net/bridge/br_multicast.c
> +++ b/net/bridge/br_multicast.c
> @@ -1421,10 +1421,29 @@ static struct sk_buff *br_multicast_alloc_query(struct net_bridge_mcast *brmctx,
> return NULL;
> }
>
> +static void br_ip4_multicast_assert_inactive(struct net_bridge_mcast *brmctx)
> +{
> + WARN_ON_ONCE(br_multicast_snooping_active(brmctx, htons(ETH_P_IP), NULL));
> +}
> +
> +static void br_ip6_multicast_assert_inactive(struct net_bridge_mcast *brmctx)
> +{
> + WARN_ON_ONCE(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);
> +}
> +
since brmctx can be const in br_multicast_snooping_active(), you can constify
it in all these helpers as well
> 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);
> }
>
> struct net_bridge_mdb_entry *br_multicast_new_group(struct net_bridge *br,
> @@ -1894,9 +1913,7 @@ static void br_multicast_querier_expired(struct net_bridge_mcast *brmctx,
> struct bridge_mcast_own_query *query,
> struct timer_list *timer)
> {
> - spin_lock(&brmctx->br->multicast_lock);
> - if (br_multicast_is_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;
>
> @@ -1907,7 +1924,6 @@ static void br_multicast_querier_expired(struct net_bridge_mcast *brmctx,
> * if our own querier is disabled, too
> */
> br_multicast_update_active(brmctx);
> - spin_unlock(&brmctx->br->multicast_lock);
> }
>
> static void br_ip4_multicast_querier_expired(struct timer_list *t)
> @@ -1915,7 +1931,16 @@ static void br_ip4_multicast_querier_expired(struct timer_list *t)
> struct net_bridge_mcast *brmctx = timer_container_of(brmctx, t,
> ip4_other_query.timer);
>
> + spin_lock(&brmctx->br->multicast_lock);
> + if (br_multicast_is_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);
> }
>
> #if IS_ENABLED(CONFIG_IPV6)
> @@ -1924,7 +1949,16 @@ static void br_ip6_multicast_querier_expired(struct timer_list *t)
> struct net_bridge_mcast *brmctx = timer_container_of(brmctx, t,
> ip6_other_query.timer);
>
> + spin_lock(&brmctx->br->multicast_lock);
> + if (br_multicast_is_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
>
> @@ -4502,6 +4536,7 @@ static void __br_multicast_stop(struct net_bridge_mcast *brmctx)
>
> /* bridge interface is down, set multicast state to inactive */
> br_multicast_update_active(brmctx);
> + br_multicast_assert_inactive(brmctx);
> }
>
> void br_multicast_update_vlan_mcast_ctx(struct net_bridge_vlan *v, u8 state)
> --
> 2.51.0
>
next prev parent reply other threads:[~2026-03-02 13:23 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-02 5:39 [PATCH net-next v3 00/14] net: bridge: reduce multicast checks in fast path Linus Lüssing
2026-03-02 5:39 ` [PATCH net-next v3 01/14] net: bridge: mcast: export ip{4,6}_active state to netlink Linus Lüssing
2026-03-02 5:39 ` [PATCH net-next v3 02/14] net: bridge: mcast: track active state, adding tests Linus Lüssing
2026-03-02 8:08 ` Linus Lüssing
2026-03-02 14:32 ` Jakub Kicinski
2026-03-02 5:39 ` [PATCH net-next v3 03/14] net: bridge: mcast: avoid sleeping on bridge-down Linus Lüssing
2026-03-02 12:58 ` Nikolay Aleksandrov
2026-03-02 5:39 ` [PATCH net-next v3 04/14] net: bridge: mcast: track active state, IGMP/MLD querier appearance Linus Lüssing
2026-03-02 5:39 ` [PATCH net-next v3 05/14] net: bridge: mcast: track active state, foreign IGMP/MLD querier disappearance Linus Lüssing
2026-03-02 5:40 ` [PATCH net-next v3 06/14] net: bridge: mcast: track active state, IPv6 address availability Linus Lüssing
2026-03-02 5:40 ` [PATCH net-next v3 07/14] net: bridge: mcast: track active state, own MLD querier disappearance Linus Lüssing
2026-03-02 5:40 ` [PATCH net-next v3 08/14] net: bridge: mcast: track active state, if snooping is enabled Linus Lüssing
2026-03-02 5:40 ` [PATCH net-next v3 09/14] net: bridge: mcast: track active state, VLAN snooping Linus Lüssing
2026-03-02 5:40 ` [PATCH net-next v3 10/14] net: bridge: mcast: track active state, bridge up/down Linus Lüssing
2026-03-02 5:40 ` [PATCH net-next v3 11/14] net: bridge: mcast: track active state, prepare for outside lock reads Linus Lüssing
2026-03-02 5:40 ` [PATCH net-next v3 12/14] net: bridge: mcast: use combined active state in netlink Linus Lüssing
2026-03-02 5:40 ` [PATCH net-next v3 13/14] net: bridge: mcast: use combined active state in fast/data path Linus Lüssing
2026-03-02 13:02 ` Nikolay Aleksandrov
2026-03-02 5:40 ` [PATCH net-next v3 14/14] net: bridge: mcast: add inactive state assertions Linus Lüssing
2026-03-02 13:23 ` Nikolay Aleksandrov [this message]
2026-03-03 12:14 ` [PATCH net-next v3 00/14] net: bridge: reduce multicast checks in fast path Simon Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aaWPUbG3_X4s8T0R@penguin \
--to=nikolay@nvidia.com \
--cc=andrew+netdev@lunn.ch \
--cc=bridge@lists.linux.dev \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linus.luessing@c0d3.blue \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=shaw.leon@gmail.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.