Browse Source

[netdevice] Refuse to create duplicate network device names

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
fcf3b03544
1 changed files with 8 additions and 0 deletions
  1. 8
    0
      src/net/netdevice.c

+ 8
- 0
src/net/netdevice.c View File

675
 		goto err_duplicate;
675
 		goto err_duplicate;
676
 	}
676
 	}
677
 
677
 
678
+	/* Reject named network devices that already exist */
679
+	if ( netdev->name[0] && ( duplicate = find_netdev ( netdev->name ) ) ) {
680
+		DBGC ( netdev, "NETDEV rejecting duplicate name %s\n",
681
+		       duplicate->name );
682
+		rc = -EEXIST;
683
+		goto err_duplicate;
684
+	}
685
+
678
 	/* Record device index and create device name */
686
 	/* Record device index and create device name */
679
 	if ( netdev->name[0] == '\0' ) {
687
 	if ( netdev->name[0] == '\0' ) {
680
 		snprintf ( netdev->name, sizeof ( netdev->name ), "net%d",
688
 		snprintf ( netdev->name, sizeof ( netdev->name ), "net%d",

Loading…
Cancel
Save