Whenever a VLAN moves to a new MSTID, send a switchdev notification so
that switchdevs can track a bridge's VID to MSTID mapping.
Signed-off-by: Tobias Waldekranz <[email protected]>
---
include/net/switchdev.h | 10 ++++++++++
net/bridge/br_vlan.c | 20 ++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index d353793dfeb5..ee4a7bd1e540 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -28,6 +28,7 @@ enum switchdev_attr_id {
SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED,
SWITCHDEV_ATTR_ID_BRIDGE_MROUTER,
SWITCHDEV_ATTR_ID_MRP_PORT_ROLE,
+ SWITCHDEV_ATTR_ID_VLAN_MSTID,
};
struct switchdev_brport_flags {
@@ -35,6 +36,14 @@ struct switchdev_brport_flags {
unsigned long mask;
};
+struct switchdev_vlan_attr {
+ u16 vid;
+
+ union {
+ u16 mstid;
+ };
+};
+
struct switchdev_attr {
struct net_device *orig_dev;
enum switchdev_attr_id id;
@@ -50,6 +59,7 @@ struct switchdev_attr {
u16 vlan_protocol; /* BRIDGE_VLAN_PROTOCOL */
bool mc_disabled; /* MC_DISABLED */
u8 mrp_port_role; /* MRP_PORT_ROLE */
+ struct switchdev_vlan_attr vlan_attr; /* VLAN_* */
} u;
};
diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index 459e84a7354d..c45a34c14e10 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -173,6 +173,26 @@ static int br_vlan_mst_migrate(struct net_bridge_vlan *v, u16 mstid)
old_mst = rtnl_dereference(v->mst);
rcu_assign_pointer(v->mst, mst);
+ if (br_vlan_is_master(v)) {
+ struct switchdev_attr attr = {
+ .id = SWITCHDEV_ATTR_ID_VLAN_MSTID,
+ .flags = SWITCHDEV_F_DEFER,
+ .orig_dev = br->dev,
+ .u.vlan_attr = {
+ .vid = v->vid,
+ .mstid = mstid,
+ },
+ };
+ int err;
+
+ err = switchdev_port_attr_set(br->dev, &attr, NULL);
+ if (err && err != -EOPNOTSUPP) {
+ rcu_assign_pointer(v->mst, old_mst);
+ br_vlan_mst_put(mst);
+ return err;
+ }
+ }
+
if (old_mst)
br_vlan_mst_put(old_mst);
--
2.25.1