]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[netdevice] Refuse to create duplicate network device names
authorMichael Brown <mcb30@ipxe.org>
Mon, 7 Mar 2016 21:03:25 +0000 (21:03 +0000)
committerMichael Brown <mcb30@ipxe.org>
Mon, 7 Mar 2016 21:04:40 +0000 (21:04 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/net/netdevice.c

index 7c40a2ac87d247c860efcce21be49fefe6ecb13d..b834c3cd93fba2408d1f0c2c4720d442ea0ed048 100644 (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",