net: bridge: mst: Allow changing a VLAN's MSTI
Allow a VLAN to move out of the CST (MSTI 0), to an independent tree.
The user manages the VID to MSTI mappings via a global VLAN
setting. The proposed iproute2 interface would be:
bridge vlan global set dev br0 vid <VID> msti <MSTI>
Changing the state in non-zero MSTIs is still not supported, but will
be addressed in upcoming changes.
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
ec7328b591
commit
8c678d6056
@@ -46,6 +46,48 @@ int br_mst_set_state(struct net_bridge_port *p, u16 msti, u8 state,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void br_mst_vlan_sync_state(struct net_bridge_vlan *pv, u16 msti)
|
||||
{
|
||||
struct net_bridge_vlan_group *vg = nbp_vlan_group(pv->port);
|
||||
struct net_bridge_vlan *v;
|
||||
|
||||
list_for_each_entry(v, &vg->vlan_list, vlist) {
|
||||
/* If this port already has a defined state in this
|
||||
* MSTI (through some other VLAN membership), inherit
|
||||
* it.
|
||||
*/
|
||||
if (v != pv && v->brvlan->msti == msti) {
|
||||
br_mst_vlan_set_state(pv->port, pv, v->state);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Otherwise, start out in a new MSTI with all ports disabled. */
|
||||
return br_mst_vlan_set_state(pv->port, pv, BR_STATE_DISABLED);
|
||||
}
|
||||
|
||||
int br_mst_vlan_set_msti(struct net_bridge_vlan *mv, u16 msti)
|
||||
{
|
||||
struct net_bridge_vlan_group *vg;
|
||||
struct net_bridge_vlan *pv;
|
||||
struct net_bridge_port *p;
|
||||
|
||||
if (mv->msti == msti)
|
||||
return 0;
|
||||
|
||||
mv->msti = msti;
|
||||
|
||||
list_for_each_entry(p, &mv->br->port_list, list) {
|
||||
vg = nbp_vlan_group(p);
|
||||
|
||||
pv = br_vlan_find(vg, mv->vid);
|
||||
if (pv)
|
||||
br_mst_vlan_sync_state(pv, msti);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void br_mst_vlan_init_state(struct net_bridge_vlan *v)
|
||||
{
|
||||
/* VLANs always start out in MSTI 0 (CST) */
|
||||
|
||||
Reference in New Issue
Block a user