浏览代码

[netdevice] Refuse to create duplicate network device names

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 年前
父节点
当前提交
fcf3b03544
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8
    0
      src/net/netdevice.c

+ 8
- 0
src/net/netdevice.c 查看文件

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

正在加载...
取消
保存