net: add support for phys_port_name
Similar to port id allow netdevices to specify port names and export
the name via sysfs. Drivers can implement the netdevice operation to
assist udev in having sane default names for the devices using the
rule:
$ cat /etc/udev/rules.d/80-net-setup-link.rules
SUBSYSTEM=="net", ACTION=="add", ATTR{phys_port_name}!="",
NAME="$attr{phys_port_name}"
Use of phys_name versus phys_id was suggested-by Jiri Pirko.
Signed-off-by: David Ahern <dsahern@gmail.com>
Acked-by: Jiri Pirko <jiri@resnulli.us>
Acked-by: Scott Feldman <sfeldma@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
56ef9c909b
commit
db24a9044e
6 changed files with 75 additions and 0 deletions
|
|
@ -5911,6 +5911,24 @@ int dev_get_phys_port_id(struct net_device *dev,
|
|||
}
|
||||
EXPORT_SYMBOL(dev_get_phys_port_id);
|
||||
|
||||
/**
|
||||
* dev_get_phys_port_name - Get device physical port name
|
||||
* @dev: device
|
||||
* @name: port name
|
||||
*
|
||||
* Get device physical port name
|
||||
*/
|
||||
int dev_get_phys_port_name(struct net_device *dev,
|
||||
char *name, size_t len)
|
||||
{
|
||||
const struct net_device_ops *ops = dev->netdev_ops;
|
||||
|
||||
if (!ops->ndo_get_phys_port_name)
|
||||
return -EOPNOTSUPP;
|
||||
return ops->ndo_get_phys_port_name(dev, name, len);
|
||||
}
|
||||
EXPORT_SYMBOL(dev_get_phys_port_name);
|
||||
|
||||
/**
|
||||
* dev_new_index - allocate an ifindex
|
||||
* @net: the applicable net namespace
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue