Skip to content

Commit

Permalink
net: dsa: program VLAN on CPU port from slave
Browse files Browse the repository at this point in the history
DSA currently programs a VLAN on the CPU port implicitly after the
related notifier is received by a switch.

While we still need to do this transparent programmation of the DSA
links in the fabric, programming the CPU port this way may cause
problems in some corners such as the tag_8021q driver.

Because the dedicated CPU port is specific to a slave, make their
programmation explicit a few layers up, in the slave code.

Note that technically, DSA links have a dedicated CPU port as well,
but since they are only used as conduit between interconnected switches
of a fabric, programming them transparently this way is what we want.

Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vivien Didelot authored and David S. Miller committed Aug 28, 2019
1 parent c5335d7 commit 7e1741b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
14 changes: 14 additions & 0 deletions net/dsa/slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ static int dsa_slave_vlan_add(struct net_device *dev,
if (err)
return err;

err = dsa_port_vlan_add(dp->cpu_dp, &vlan, trans);
if (err)
return err;

return 0;
}

Expand Down Expand Up @@ -383,6 +387,9 @@ static int dsa_slave_vlan_del(struct net_device *dev,
if (dp->bridge_dev && !br_vlan_enabled(dp->bridge_dev))
return 0;

/* Do not deprogram the CPU port as it may be shared with other user
* ports which can be members of this VLAN as well.
*/
return dsa_port_vlan_del(dp, SWITCHDEV_OBJ_PORT_VLAN(obj));
}

Expand Down Expand Up @@ -1121,6 +1128,10 @@ static int dsa_slave_vlan_rx_add_vid(struct net_device *dev, __be16 proto,
if (ret && ret != -EOPNOTSUPP)
return ret;

ret = dsa_port_vid_add(dp->cpu_dp, vid, 0);
if (ret && ret != -EOPNOTSUPP)
return ret;

return 0;
}

Expand Down Expand Up @@ -1151,6 +1162,9 @@ static int dsa_slave_vlan_rx_kill_vid(struct net_device *dev, __be16 proto,
if (ret == -EOPNOTSUPP)
ret = 0;

/* Do not deprogram the CPU port as it may be shared with other user
* ports which can be members of this VLAN as well.
*/
return ret;
}

Expand Down
5 changes: 4 additions & 1 deletion net/dsa/switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ static bool dsa_switch_vlan_match(struct dsa_switch *ds, int port,
if (ds->index == info->sw_index && port == info->port)
return true;

if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
if (dsa_is_dsa_port(ds, port))
return true;

return false;
Expand Down Expand Up @@ -288,6 +288,9 @@ static int dsa_switch_vlan_del(struct dsa_switch *ds,
if (ds->index == info->sw_index)
return ds->ops->port_vlan_del(ds, info->port, info->vlan);

/* Do not deprogram the DSA links as they may be used as conduit
* for other VLAN members in the fabric.
*/
return 0;
}

Expand Down

0 comments on commit 7e1741b

Please sign in to comment.