[netdevice] Refuse to create duplicate network device names
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
parent
99b5216b1c
commit
fcf3b03544
|
@ -675,6 +675,14 @@ int register_netdev ( struct net_device *netdev ) {
|
|||
goto err_duplicate;
|
||||
}
|
||||
|
||||
/* Reject named network devices that already exist */
|
||||
if ( netdev->name[0] && ( duplicate = find_netdev ( netdev->name ) ) ) {
|
||||
DBGC ( netdev, "NETDEV rejecting duplicate name %s\n",
|
||||
duplicate->name );
|
||||
rc = -EEXIST;
|
||||
goto err_duplicate;
|
||||
}
|
||||
|
||||
/* Record device index and create device name */
|
||||
if ( netdev->name[0] == '\0' ) {
|
||||
snprintf ( netdev->name, sizeof ( netdev->name ), "net%d",
|
||||
|
|
Reference in New Issue