提交 aecbe01e 编写于 作者: J Jiri Pirko 提交者: David S. Miller

net-sysfs: expose physical switch id for particular device

Signed-off-by: NJiri Pirko <jiri@resnulli.us>
Reviewed-by: NThomas Graf <tgraf@suug.ch>
Acked-by: NJohn Fastabend <john.r.fastabend@intel.com>
Acked-by: NAndy Gospodarek <gospo@cumulusnetworks.com>
Acked-by: NFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 82f28412
...@@ -216,3 +216,11 @@ Contact: netdev@vger.kernel.org ...@@ -216,3 +216,11 @@ Contact: netdev@vger.kernel.org
Description: Description:
Indicates the interface protocol type as a decimal value. See Indicates the interface protocol type as a decimal value. See
include/uapi/linux/if_arp.h for all possible values. include/uapi/linux/if_arp.h for all possible values.
What: /sys/class/net/<iface>/phys_switch_id
Date: November 2014
KernelVersion: 3.19
Contact: netdev@vger.kernel.org
Description:
Indicates the unique physical switch identifier of a switch this
port belongs to, as a string.
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <linux/capability.h> #include <linux/capability.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <net/switchdev.h>
#include <linux/if_arp.h> #include <linux/if_arp.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/nsproxy.h> #include <linux/nsproxy.h>
...@@ -416,6 +417,28 @@ static ssize_t phys_port_id_show(struct device *dev, ...@@ -416,6 +417,28 @@ static ssize_t phys_port_id_show(struct device *dev,
} }
static DEVICE_ATTR_RO(phys_port_id); static DEVICE_ATTR_RO(phys_port_id);
static ssize_t phys_switch_id_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct net_device *netdev = to_net_dev(dev);
ssize_t ret = -EINVAL;
if (!rtnl_trylock())
return restart_syscall();
if (dev_isalive(netdev)) {
struct netdev_phys_item_id ppid;
ret = netdev_switch_parent_id_get(netdev, &ppid);
if (!ret)
ret = sprintf(buf, "%*phN\n", ppid.id_len, ppid.id);
}
rtnl_unlock();
return ret;
}
static DEVICE_ATTR_RO(phys_switch_id);
static struct attribute *net_class_attrs[] = { static struct attribute *net_class_attrs[] = {
&dev_attr_netdev_group.attr, &dev_attr_netdev_group.attr,
&dev_attr_type.attr, &dev_attr_type.attr,
...@@ -441,6 +464,7 @@ static struct attribute *net_class_attrs[] = { ...@@ -441,6 +464,7 @@ static struct attribute *net_class_attrs[] = {
&dev_attr_tx_queue_len.attr, &dev_attr_tx_queue_len.attr,
&dev_attr_gro_flush_timeout.attr, &dev_attr_gro_flush_timeout.attr,
&dev_attr_phys_port_id.attr, &dev_attr_phys_port_id.attr,
&dev_attr_phys_switch_id.attr,
NULL, NULL,
}; };
ATTRIBUTE_GROUPS(net_class); ATTRIBUTE_GROUPS(net_class);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册