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üssing <[email protected]>
Reviewed-by: Ido Schimmel <[email protected]>
---
 net/bridge/br_netlink.c      | 14 ++------------
 net/bridge/br_private.h      |  2 +-
 net/bridge/br_vlan_options.c | 23 +++++------------------
 3 files changed, 8 insertions(+), 31 deletions(-)

diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 7fff59c3bf76..e79fddf747f8 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -1643,8 +1643,6 @@ static size_t br_get_size(const struct net_device *brdev)
 
 static int br_fill_info(struct sk_buff *skb, const struct net_device *brdev)
 {
-       struct ethhdr eth6 __maybe_unused = { .h_proto = htons(ETH_P_IPV6) };
-       struct ethhdr eth4 __maybe_unused = { .h_proto = htons(ETH_P_IP) };
        struct net_bridge *br = netdev_priv(brdev);
        u32 forward_delay = jiffies_to_clock_t(br->forward_delay);
        u32 hello_time = jiffies_to_clock_t(br->hello_time);
@@ -1724,11 +1722,7 @@ static int br_fill_info(struct sk_buff *skb, const 
struct 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, &eth4,
-                                                  NULL)) ||
+                      READ_ONCE(br->multicast_ctx.ip4_active)) ||
            br_multicast_dump_querier_state(skb, &br->multicast_ctx,
                                            IFLA_BR_MCAST_QUERIER_STATE))
                return -EMSGSIZE;
@@ -1736,11 +1730,7 @@ static int br_fill_info(struct sk_buff *skb, const 
struct 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, &eth6,
-                                                  NULL)))
+                      READ_ONCE(br->multicast_ctx.ip6_active)))
                return -EMSGSIZE;
 #endif
        clockval = 
jiffies_to_clock_t(br->multicast_ctx.multicast_last_member_interval);
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 8d1c869eb522..2bdfc93499fc 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -1909,7 +1909,7 @@ int br_vlan_rtm_process_global_options(struct net_device 
*dev,
 bool br_vlan_global_opts_can_enter_range(const struct net_bridge_vlan *v_curr,
                                         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);
 
 /* vlan state manipulation helpers using *_ONCE to annotate lock-free access,
  * 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 06045d68a2d1..47ad35583a3f 100644
--- a/net/bridge/br_vlan_options.c
+++ b/net/bridge/br_vlan_options.c
@@ -367,13 +367,10 @@ bool br_vlan_global_opts_can_enter_range(const struct 
net_bridge_vlan *v_curr,
 }
 
 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 __maybe_unused = { .h_proto = htons(ETH_P_IPV6) };
-       struct ethhdr eth4 __maybe_unused = { .h_proto = htons(ETH_P_IP) };
        struct nlattr *nest2 __maybe_unused;
        u64 clockval __maybe_unused;
-       bool mcact __maybe_unused;
        struct nlattr *nest;
 
        nest = nla_nest_start(skb, BRIDGE_VLANDB_GLOBAL_OPTIONS);
@@ -388,17 +385,12 @@ bool br_vlan_global_opts_fill(struct sk_buff *skb, u16 
vid, u16 vid_range,
                goto out_err;
 
 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
-       mcact = 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, &eth4, NULL);
-
        if (nla_put_u8(skb, BRIDGE_VLANDB_GOPTS_MCAST_SNOOPING,
                       !!(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, mcact) ||
+           nla_put_u8(skb, BRIDGE_VLANDB_GOPTS_MCAST_ACTIVE_V4,
+                      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,
@@ -452,15 +444,10 @@ bool br_vlan_global_opts_fill(struct sk_buff *skb, u16 
vid, u16 vid_range,
        }
 
 #if IS_ENABLED(CONFIG_IPV6)
-       mcact = 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, &eth6, NULL);
-
        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, mcact))
+           nla_put_u8(skb, BRIDGE_VLANDB_GOPTS_MCAST_ACTIVE_V6,
+                      READ_ONCE(v_opts->br_mcast_ctx.ip6_active)))
                goto out_err;
 #endif
 #endif
-- 
2.53.0


Reply via email to