Skip to content

Commit

Permalink
net: dsa: check bridge VLAN in slave operations
Browse files Browse the repository at this point in the history
The bridge VLANs are not offloaded by dsa_port_vlan_* if the port is
not bridged or if its bridge is not VLAN aware.

This is a good thing but other corners of DSA, such as the tag_8021q
driver, may need to program VLANs regardless the bridge state.

And also because bridge_dev is specific to user ports anyway, move
these checks were it belongs, one layer up in the slave code.

Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com>
Suggested-by: Vladimir Oltean <olteanv@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 bdcff08 commit c5335d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
10 changes: 2 additions & 8 deletions net/dsa/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,7 @@ int dsa_port_vlan_add(struct dsa_port *dp,
.vlan = vlan,
};

if (!dp->bridge_dev || br_vlan_enabled(dp->bridge_dev))
return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_ADD, &info);

return 0;
return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_ADD, &info);
}

int dsa_port_vlan_del(struct dsa_port *dp,
Expand All @@ -363,10 +360,7 @@ int dsa_port_vlan_del(struct dsa_port *dp,
.vlan = vlan,
};

if (!dp->bridge_dev || br_vlan_enabled(dp->bridge_dev))
return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_DEL, &info);

return 0;
return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_DEL, &info);
}

int dsa_port_vid_add(struct dsa_port *dp, u16 vid, u16 flags)
Expand Down
12 changes: 12 additions & 0 deletions net/dsa/slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ static int dsa_slave_vlan_add(struct net_device *dev,
if (obj->orig_dev != dev)
return -EOPNOTSUPP;

if (dp->bridge_dev && !br_vlan_enabled(dp->bridge_dev))
return 0;

vlan = *SWITCHDEV_OBJ_PORT_VLAN(obj);

err = dsa_port_vlan_add(dp, &vlan, trans);
Expand Down Expand Up @@ -377,6 +380,9 @@ static int dsa_slave_vlan_del(struct net_device *dev,
if (obj->orig_dev != dev)
return -EOPNOTSUPP;

if (dp->bridge_dev && !br_vlan_enabled(dp->bridge_dev))
return 0;

return dsa_port_vlan_del(dp, SWITCHDEV_OBJ_PORT_VLAN(obj));
}

Expand Down Expand Up @@ -1099,6 +1105,9 @@ static int dsa_slave_vlan_rx_add_vid(struct net_device *dev, __be16 proto,
* need to emulate the switchdev prepare + commit phase.
*/
if (dp->bridge_dev) {
if (!br_vlan_enabled(dp->bridge_dev))
return 0;

/* br_vlan_get_info() returns -EINVAL or -ENOENT if the
* device, respectively the VID is not found, returning
* 0 means success, which is a failure for us here.
Expand Down Expand Up @@ -1126,6 +1135,9 @@ static int dsa_slave_vlan_rx_kill_vid(struct net_device *dev, __be16 proto,
* need to emulate the switchdev prepare + commit phase.
*/
if (dp->bridge_dev) {
if (!br_vlan_enabled(dp->bridge_dev))
return 0;

/* br_vlan_get_info() returns -EINVAL or -ENOENT if the
* device, respectively the VID is not found, returning
* 0 means success, which is a failure for us here.
Expand Down

0 comments on commit c5335d7

Please sign in to comment.