Pārlūkot izejas kodu

[netdevice] Refuse to create duplicate network device names

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 gadus atpakaļ
vecāks
revīzija
fcf3b03544
1 mainītis faili ar 8 papildinājumiem un 0 dzēšanām
  1. 8
    0
      src/net/netdevice.c

+ 8
- 0
src/net/netdevice.c Parādīt failu

@@ -675,6 +675,14 @@ int register_netdev ( struct net_device *netdev ) {
675 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 686
 	/* Record device index and create device name */
679 687
 	if ( netdev->name[0] == '\0' ) {
680 688
 		snprintf ( netdev->name, sizeof ( netdev->name ), "net%d",

Notiek ielāde…
Atcelt
Saglabāt