REGISTER_NETDEVICE(9) Network device support REGISTER_NETDEVICE(9)NAME
register_netdevice - register a network device
SYNOPSIS
int register_netdevice(struct net_device * dev);
ARGUMENTS
dev
device to register
DESCRIPTION
Take a completed network device structure and add it to the kernel interfaces. A NETDEV_REGISTER message is sent to the netdev notifier
chain. 0 is returned on success. A negative errno code is returned on a failure to set up the device, or if the name is a duplicate.
Callers must hold the rtnl semaphore. You may want register_netdev instead of this.
BUGS
The locking appears insufficient to guarantee two parallel registers will not get the same name.
COPYRIGHT Kernel Hackers Manual 3.10 June 2014 REGISTER_NETDEVICE(9)
Check Out this Related Man Page
DEVICE_RENAME(9) Device drivers infrastructure DEVICE_RENAME(9)NAME
device_rename - renames a device
SYNOPSIS
int device_rename(struct device * dev, const char * new_name);
ARGUMENTS
dev
the pointer to the struct device to be renamed
new_name
the new name of the device
DESCRIPTION
It is the responsibility of the caller to provide mutual exclusion between two different calls of device_rename on the same device to
ensure that new_name is valid and won't conflict with other devices.
NOTE
Don't call this function. Currently, the networking layer calls this function, but that will change. The following text from Kay Sievers
offers
SOME INSIGHT
Renaming devices is racy at many levels, symlinks and other stuff are not replaced atomically, and you get a "move" uevent, but it's not
easy to connect the event to the old and new device. Device nodes are not renamed at all, there isn't even support for that in the kernel
now.
In the meantime, during renaming, your target name might be taken by another driver, creating conflicts. Or the old name is taken directly
after you renamed it -- then you get events for the same DEVPATH, before you even see the "move" event. It's just a mess, and nothing new
should ever rely on kernel device renaming. Besides that, it's not even implemented now for other things than (driver-core wise very
simple) network devices.
We are currently about to change network renaming in udev to completely disallow renaming of devices in the same namespace as the kernel
uses, because we can't solve the problems properly, that arise with swapping names of multiple interfaces without races. Means, renaming of
eth[0-9]* will only be allowed to some other name than eth[0-9]*, for the aforementioned reasons.
Make up a "real" name in the driver before you register anything, or add some other attributes for userspace to find the device, or use
udev to add symlinks -- but never rename kernel devices later, it's a complete mess. We don't even want to get into that and try to
implement the missing pieces in the core. We really have other pieces to fix in the driver core mess. :)
COPYRIGHT Kernel Hackers Manual 3.10 June 2014 DEVICE_RENAME(9)