david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[netdevice] Refuse to create duplicate network device names

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2016-03-07 21:03:25 +00:00
parent 99b5216b1c
commit fcf3b03544
1 changed files with 8 additions and 0 deletions

View File

@ -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",