diff options
-rw-r--r-- | Documentation/ABI/testing/sysfs-class-net | 11 | ||||
-rw-r--r-- | include/linux/netdevice.h | 2 | ||||
-rw-r--r-- | include/uapi/linux/netdevice.h | 6 | ||||
-rw-r--r-- | net/core/net-sysfs.c | 20 |
4 files changed, 39 insertions, 0 deletions
diff --git a/Documentation/ABI/testing/sysfs-class-net b/Documentation/ABI/testing/sysfs-class-net index 416c5d59f52e..d322b0581194 100644 --- a/Documentation/ABI/testing/sysfs-class-net +++ b/Documentation/ABI/testing/sysfs-class-net | |||
@@ -1,3 +1,14 @@ | |||
1 | What: /sys/class/net/<iface>/name_assign_type | ||
2 | Date: July 2014 | ||
3 | KernelVersion: 3.17 | ||
4 | Contact: netdev@vger.kernel.org | ||
5 | Description: | ||
6 | Indicates the name assignment type. Possible values are: | ||
7 | 1: enumerated by the kernel, possibly in an unpredictable way | ||
8 | 2: predictably named by the kernel | ||
9 | 3: named by userspace | ||
10 | 4: renamed | ||
11 | |||
1 | What: /sys/class/net/<iface>/addr_assign_type | 12 | What: /sys/class/net/<iface>/addr_assign_type |
2 | Date: July 2010 | 13 | Date: July 2010 |
3 | KernelVersion: 3.2 | 14 | KernelVersion: 3.2 |
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 3a320db96180..9be34732142f 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -1381,6 +1381,8 @@ struct net_device { | |||
1381 | struct kset *queues_kset; | 1381 | struct kset *queues_kset; |
1382 | #endif | 1382 | #endif |
1383 | 1383 | ||
1384 | unsigned char name_assign_type; | ||
1385 | |||
1384 | bool uc_promisc; | 1386 | bool uc_promisc; |
1385 | unsigned int promiscuity; | 1387 | unsigned int promiscuity; |
1386 | unsigned int allmulti; | 1388 | unsigned int allmulti; |
diff --git a/include/uapi/linux/netdevice.h b/include/uapi/linux/netdevice.h index fdfbd1c17065..55818543342d 100644 --- a/include/uapi/linux/netdevice.h +++ b/include/uapi/linux/netdevice.h | |||
@@ -37,6 +37,12 @@ | |||
37 | #define INIT_NETDEV_GROUP 0 | 37 | #define INIT_NETDEV_GROUP 0 |
38 | 38 | ||
39 | 39 | ||
40 | /* interface name assignment types (sysfs name_assign_type attribute) */ | ||
41 | #define NET_NAME_UNKNOWN 0 /* unknown origin (not exposed to userspace) */ | ||
42 | #define NET_NAME_ENUM 1 /* enumerated by kernel */ | ||
43 | #define NET_NAME_PREDICTABLE 2 /* predictably named by the kernel */ | ||
44 | #define NET_NAME_USER 3 /* provided by user-space */ | ||
45 | #define NET_NAME_RENAMED 4 /* renamed by user-space */ | ||
40 | 46 | ||
41 | /* Media selection options. */ | 47 | /* Media selection options. */ |
42 | enum { | 48 | enum { |
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 1cac29ebb05b..7752f2ad49a5 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c | |||
@@ -112,6 +112,25 @@ NETDEVICE_SHOW_RO(ifindex, fmt_dec); | |||
112 | NETDEVICE_SHOW_RO(type, fmt_dec); | 112 | NETDEVICE_SHOW_RO(type, fmt_dec); |
113 | NETDEVICE_SHOW_RO(link_mode, fmt_dec); | 113 | NETDEVICE_SHOW_RO(link_mode, fmt_dec); |
114 | 114 | ||
115 | static ssize_t format_name_assign_type(const struct net_device *net, char *buf) | ||
116 | { | ||
117 | return sprintf(buf, fmt_dec, net->name_assign_type); | ||
118 | } | ||
119 | |||
120 | static ssize_t name_assign_type_show(struct device *dev, | ||
121 | struct device_attribute *attr, | ||
122 | char *buf) | ||
123 | { | ||
124 | struct net_device *net = to_net_dev(dev); | ||
125 | ssize_t ret = -EINVAL; | ||
126 | |||
127 | if (net->name_assign_type != NET_NAME_UNKNOWN) | ||
128 | ret = netdev_show(dev, attr, buf, format_name_assign_type); | ||
129 | |||
130 | return ret; | ||
131 | } | ||
132 | static DEVICE_ATTR_RO(name_assign_type); | ||
133 | |||
115 | /* use same locking rules as GIFHWADDR ioctl's */ | 134 | /* use same locking rules as GIFHWADDR ioctl's */ |
116 | static ssize_t address_show(struct device *dev, struct device_attribute *attr, | 135 | static ssize_t address_show(struct device *dev, struct device_attribute *attr, |
117 | char *buf) | 136 | char *buf) |
@@ -387,6 +406,7 @@ static struct attribute *net_class_attrs[] = { | |||
387 | &dev_attr_dev_port.attr, | 406 | &dev_attr_dev_port.attr, |
388 | &dev_attr_iflink.attr, | 407 | &dev_attr_iflink.attr, |
389 | &dev_attr_ifindex.attr, | 408 | &dev_attr_ifindex.attr, |
409 | &dev_attr_name_assign_type.attr, | ||
390 | &dev_attr_addr_assign_type.attr, | 410 | &dev_attr_addr_assign_type.attr, |
391 | &dev_attr_addr_len.attr, | 411 | &dev_attr_addr_len.attr, |
392 | &dev_attr_link_mode.attr, | 412 | &dev_attr_link_mode.attr, |