]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: bridge: mst: Add helper to map an MSTI to a VID set
authorTobias Waldekranz <tobias@waldekranz.com>
Wed, 16 Mar 2022 15:08:49 +0000 (16:08 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 17 Mar 2022 23:49:58 +0000 (16:49 -0700)
br_mst_get_info answers the question: "On this bridge, which VIDs are
mapped to the given MSTI?"

This is useful in switchdev drivers, which might have to fan-out
operations, relating to an MSTI, per VLAN.

An example: When a port's MST state changes from forwarding to
blocking, a driver may choose to flush the dynamic FDB entries on that
port to get faster reconvergence of the network, but this should only
be done in the VLANs that are managed by the MSTI in question.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/if_bridge.h
net/bridge/br_mst.c

index 3aae023a9353ffc52ccc5de9e11c178c58c37a2e..1cf0cc46d90d97bf31dea5db9c412ba0afc9ddad 100644 (file)
@@ -119,6 +119,7 @@ int br_vlan_get_info(const struct net_device *dev, u16 vid,
                     struct bridge_vlan_info *p_vinfo);
 int br_vlan_get_info_rcu(const struct net_device *dev, u16 vid,
                         struct bridge_vlan_info *p_vinfo);
+int br_mst_get_info(const struct net_device *dev, u16 msti, unsigned long *vids);
 #else
 static inline bool br_vlan_enabled(const struct net_device *dev)
 {
@@ -151,6 +152,12 @@ static inline int br_vlan_get_info_rcu(const struct net_device *dev, u16 vid,
 {
        return -EINVAL;
 }
+
+static inline int br_mst_get_info(const struct net_device *dev, u16 msti,
+                                 unsigned long *vids)
+{
+       return -EINVAL;
+}
 #endif
 
 #if IS_ENABLED(CONFIG_BRIDGE)
index 00935a19afcc9d2f627d6739df718d0440ee67e1..00b36e62922438e9d44995ae9c08847a9788e4bc 100644 (file)
 
 DEFINE_STATIC_KEY_FALSE(br_mst_used);
 
+int br_mst_get_info(const struct net_device *dev, u16 msti, unsigned long *vids)
+{
+       const struct net_bridge_vlan_group *vg;
+       const struct net_bridge_vlan *v;
+       const struct net_bridge *br;
+
+       ASSERT_RTNL();
+
+       if (!netif_is_bridge_master(dev))
+               return -EINVAL;
+
+       br = netdev_priv(dev);
+       if (!br_opt_get(br, BROPT_MST_ENABLED))
+               return -EINVAL;
+
+       vg = br_vlan_group(br);
+
+       list_for_each_entry(v, &vg->vlan_list, vlist) {
+               if (v->msti == msti)
+                       __set_bit(v->vid, vids);
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(br_mst_get_info);
+
 static void br_mst_vlan_set_state(struct net_bridge_port *p, struct net_bridge_vlan *v,
                                  u8 state)
 {