switchdev: convert parent_id_get to switchdev attr get
Switch ID is just a gettable port attribute. Convert switchdev op switchdev_parent_id_get to a switchdev attr. Note: for sysfs and netlink interfaces, SWITCHDEV_ATTR_PORT_PARENT_ID is called with SWITCHDEV_F_NO_RECUSE to limit switch ID user-visiblity to only port netdevs. So when a port is stacked under bond/bridge, the user can only query switch id via the switch ports, but not via the upper devices Signed-off-by: Scott Feldman <sfeldma@gmail.com> Acked-by: Jiri Pirko <jiri@resnulli.us> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
3094333d90
commit
f8e20a9f87
6 changed files with 51 additions and 57 deletions
|
@ -382,14 +382,20 @@ static int dsa_slave_bridge_port_leave(struct net_device *dev)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int dsa_slave_parent_id_get(struct net_device *dev,
|
||||
struct netdev_phys_item_id *psid)
|
||||
static int dsa_slave_port_attr_get(struct net_device *dev,
|
||||
struct switchdev_attr *attr)
|
||||
{
|
||||
struct dsa_slave_priv *p = netdev_priv(dev);
|
||||
struct dsa_switch *ds = p->parent;
|
||||
|
||||
psid->id_len = sizeof(ds->index);
|
||||
memcpy(&psid->id, &ds->index, psid->id_len);
|
||||
switch (attr->id) {
|
||||
case SWITCHDEV_ATTR_PORT_PARENT_ID:
|
||||
attr->ppid.id_len = sizeof(ds->index);
|
||||
memcpy(&attr->ppid.id, &ds->index, attr->ppid.id_len);
|
||||
break;
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -676,7 +682,7 @@ static const struct net_device_ops dsa_slave_netdev_ops = {
|
|||
};
|
||||
|
||||
static const struct switchdev_ops dsa_slave_switchdev_ops = {
|
||||
.switchdev_parent_id_get = dsa_slave_parent_id_get,
|
||||
.switchdev_port_attr_get = dsa_slave_port_attr_get,
|
||||
.switchdev_port_stp_update = dsa_slave_stp_update,
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue