Re: [PATCH net-next v4 13/14] net: bridge: mcast: use combined active state in fast/data path

Ido Schimmel
2026-03-09T16:51:47Z

On Sat, Mar 07, 2026 at 05:45:47AM +0100, Linus Lüssing wrote:
> diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
> index 6faa484dede7..aa2edb63a97b 100644
> --- a/net/bridge/br_multicast.c
> +++ b/net/bridge/br_multicast.c
> @@ -1067,6 +1067,26 @@ static struct sk_buff *br_ip4_multicast_alloc_query(struct net_bridge_mcast *brm
> return skb;
> }
>
> +static bool
> +__br_multicast_querier_exists(struct net_bridge_mcast *brmctx,
> + struct bridge_mcast_other_query *querier,

Both can be const

> + 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 = false;
> + else
> + own_querier_enabled = true;
> + } else {
> + own_querier_enabled = 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 *brmctx)

Same (br_ip6_multicast_querier_exists() as well)

> {
> return __br_multicast_querier_exists(brmctx, &brmctx->ip4_other_query,
> @@ -1081,6 +1101,21 @@ static bool br_ip6_multicast_querier_exists(struct net_bridge_mcast *brmctx)
> }
> #endif
>
> +static bool
> +br_multicast_querier_exists(struct net_bridge_mcast *brmctx, u16 proto)

Same

> +{
> + 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;
> + }
> +}

[...]

> +br_multicast_snooping_active(const struct net_bridge_mcast *brmctx,
> + __be16 eth_proto,
> + 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 = false;
> - else
> - own_querier_enabled = true;
> - } else {
> - own_querier_enabled = 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 *brmctx,
> - struct ethhdr *eth,
> - const struct net_bridge_mdb_entry *mdb)
> -{
> - switch (eth->h_proto) {
> - case (htons(ETH_P_IP)):
> - return __br_multicast_querier_exists(brmctx,
> - &brmctx->ip4_other_query, false);
> + switch (eth_proto) {
> + case htons(ETH_P_IP):
> + return READ_ONCE(brmctx->ip4_active);
> #if IS_ENABLED(CONFIG_IPV6)

This can be removed given that 'ipv6_active' is always available

> - case (htons(ETH_P_IPV6)):
> - return __br_multicast_querier_exists(brmctx,
> - &brmctx->ip6_other_query, true);
> + case htons(ETH_P_IPV6):
> + return READ_ONCE(brmctx->ip6_active);
> #endif
> default:
> return !!mdb && br_group_is_l2(&mdb->addr);
> @@ -1458,9 +1437,10 @@ static inline bool br_multicast_is_router(struct net_bridge_mcast *brmctx,
> return false;
> }