mirror of
https://github.com/ipxe/ipxe
synced 2025-12-15 17:12:54 +03:00
[netdevice] Refuse to create duplicate network device names
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -675,6 +675,14 @@ int register_netdev ( struct net_device *netdev ) {
|
|||||||
goto err_duplicate;
|
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 */
|
/* Record device index and create device name */
|
||||||
if ( netdev->name[0] == '\0' ) {
|
if ( netdev->name[0] == '\0' ) {
|
||||||
snprintf ( netdev->name, sizeof ( netdev->name ), "net%d",
|
snprintf ( netdev->name, sizeof ( netdev->name ), "net%d",
|
||||||
|
|||||||
Reference in New Issue
Block a user