net: network device name ifalias support
This patch add support for keeping an additional character alias associated with an network interface. This is useful for maintaining the SNMP ifAlias value which is a user defined value. Routers use this to hold information like which circuit or line it is connected to. It is just an arbitrary text label on the network device. There are two exposed interfaces with this patch, the value can be read/written either via netlink or sysfs. This could be maintained just by the snmp daemon, but it is more generally useful for other management tools, and the kernel is good place to act as an agreed upon interface to store it. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
83bfba5fca
commit
0b815a1a6d
@ -953,6 +953,29 @@ rollback:
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
* dev_set_alias - change ifalias of a device
|
||||
* @dev: device
|
||||
* @alias: name up to IFALIASZ
|
||||
*
|
||||
* Set ifalias for a device,
|
||||
*/
|
||||
int dev_set_alias(struct net_device *dev, const char *alias, size_t len)
|
||||
{
|
||||
ASSERT_RTNL();
|
||||
|
||||
if (len >= IFALIASZ)
|
||||
return -EINVAL;
|
||||
|
||||
dev->ifalias = krealloc(dev->ifalias, len+1, GFP_KERNEL);
|
||||
if (!dev->ifalias)
|
||||
return -ENOMEM;
|
||||
|
||||
strlcpy(dev->ifalias, alias, len+1);
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* netdev_features_change - device changes features
|
||||
* @dev: device to cause notification
|
||||
|
Reference in New Issue
Block a user