aboutsummaryrefslogtreecommitdiff
path: root/net/switchdev
diff options
context:
space:
mode:
authorScott Feldman2015-05-10 09:47:49 -0700
committerDavid S. Miller2015-05-12 18:43:53 -0400
commitf8e20a9f87d33865cc1d67f13da0db8d457fc3c9 (patch)
tree0072db71330af1215e78c1def9033d62156a4183 /net/switchdev
parent3094333d9089d43e8b8f0418676fa6ae06c27b51 (diff)
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>
Diffstat (limited to 'net/switchdev')
-rw-r--r--net/switchdev/switchdev.c38
1 files changed, 11 insertions, 27 deletions
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index 8f47187dc185..117fd0797abd 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -19,24 +19,6 @@
#include <net/switchdev.h>
/**
- * switchdev_parent_id_get - Get ID of a switch
- * @dev: port device
- * @psid: switch ID
- *
- * Get ID of a switch this port is part of.
- */
-int switchdev_parent_id_get(struct net_device *dev,
- struct netdev_phys_item_id *psid)
-{
- const struct switchdev_ops *ops = dev->switchdev_ops;
-
- if (!ops || !ops->switchdev_parent_id_get)
- return -EOPNOTSUPP;
- return ops->switchdev_parent_id_get(dev, psid);
-}
-EXPORT_SYMBOL_GPL(switchdev_parent_id_get);
-
-/**
* switchdev_port_attr_get - Get port attribute
*
* @dev: port device
@@ -414,11 +396,10 @@ static struct net_device *switchdev_get_lowest_dev(struct net_device *dev)
struct list_head *iter;
/* Recusively search down until we find a sw port dev.
- * (A sw port dev supports switchdev_parent_id_get).
+ * (A sw port dev supports switchdev_port_attr_get).
*/
- if (dev->features & NETIF_F_HW_SWITCH_OFFLOAD &&
- ops && ops->switchdev_parent_id_get)
+ if (ops && ops->switchdev_port_attr_get)
return dev;
netdev_for_each_lower_dev(dev, lower_dev, iter) {
@@ -432,8 +413,10 @@ static struct net_device *switchdev_get_lowest_dev(struct net_device *dev)
static struct net_device *switchdev_get_dev_by_nhs(struct fib_info *fi)
{
- struct netdev_phys_item_id psid;
- struct netdev_phys_item_id prev_psid;
+ struct switchdev_attr attr = {
+ .id = SWITCHDEV_ATTR_PORT_PARENT_ID,
+ };
+ struct switchdev_attr prev_attr;
struct net_device *dev = NULL;
int nhsel;
@@ -449,17 +432,18 @@ static struct net_device *switchdev_get_dev_by_nhs(struct fib_info *fi)
if (!dev)
return NULL;
- if (switchdev_parent_id_get(dev, &psid))
+ if (switchdev_port_attr_get(dev, &attr))
return NULL;
if (nhsel > 0) {
- if (prev_psid.id_len != psid.id_len)
+ if (prev_attr.ppid.id_len != attr.ppid.id_len)
return NULL;
- if (memcmp(prev_psid.id, psid.id, psid.id_len))
+ if (memcmp(prev_attr.ppid.id, attr.ppid.id,
+ attr.ppid.id_len))
return NULL;
}
- prev_psid = psid;
+ prev_attr = attr;
}
return dev;