summaryrefslogtreecommitdiff
path: root/net/bridge
diff options
context:
space:
mode:
authorTobias Waldekranz <tobias@waldekranz.com>2022-03-16 18:08:51 +0300
committerJakub Kicinski <kuba@kernel.org>2022-03-18 02:49:58 +0300
commitf54fd0e163068ced4d0d27db64cd3cbda95b74e4 (patch)
tree2af3ed1301b1f3b68ff513ff33f441f9a47dd09a /net/bridge
parent48d57b2e5f439246c4e12ed7705a5e3241294b03 (diff)
downloadlinux-f54fd0e163068ced4d0d27db64cd3cbda95b74e4.tar.xz
net: bridge: mst: Add helper to query a port's MST state
This is useful for switchdev drivers who are offloading MST states into hardware. As an example, a driver may wish to flush the FDB for a port when it transitions from forwarding to blocking - which means that the previous state must be discoverable. 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>
Diffstat (limited to 'net/bridge')
-rw-r--r--net/bridge/br_mst.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/net/bridge/br_mst.c b/net/bridge/br_mst.c
index 830a5746479f..ee680adcee17 100644
--- a/net/bridge/br_mst.c
+++ b/net/bridge/br_mst.c
@@ -48,6 +48,31 @@ int br_mst_get_info(const struct net_device *dev, u16 msti, unsigned long *vids)
}
EXPORT_SYMBOL_GPL(br_mst_get_info);
+int br_mst_get_state(const struct net_device *dev, u16 msti, u8 *state)
+{
+ const struct net_bridge_port *p = NULL;
+ const struct net_bridge_vlan_group *vg;
+ const struct net_bridge_vlan *v;
+
+ ASSERT_RTNL();
+
+ p = br_port_get_check_rtnl(dev);
+ if (!p || !br_opt_get(p->br, BROPT_MST_ENABLED))
+ return -EINVAL;
+
+ vg = nbp_vlan_group(p);
+
+ list_for_each_entry(v, &vg->vlan_list, vlist) {
+ if (v->brvlan->msti == msti) {
+ *state = v->state;
+ return 0;
+ }
+ }
+
+ return -ENOENT;
+}
+EXPORT_SYMBOL_GPL(br_mst_get_state);
+
static void br_mst_vlan_set_state(struct net_bridge_port *p, struct net_bridge_vlan *v,
u8 state)
{