summaryrefslogtreecommitdiffstats
path: root/src/net/netdevice.c
diff options
context:
space:
mode:
authorMichael Brown2016-03-07 22:03:25 +0100
committerMichael Brown2016-03-07 22:04:40 +0100
commitfcf3b0354428df2e8237b7d0fca2457ff7d87fac (patch)
tree153de6f7283d9071c2914158219954ec6cf2996c /src/net/netdevice.c
parent[librm] Support ioremap() for addresses above 4GB in a 64-bit build (diff)
downloadipxe-fcf3b0354428df2e8237b7d0fca2457ff7d87fac.tar.gz
ipxe-fcf3b0354428df2e8237b7d0fca2457ff7d87fac.tar.xz
ipxe-fcf3b0354428df2e8237b7d0fca2457ff7d87fac.zip
[netdevice] Refuse to create duplicate network device names
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net/netdevice.c')
-rw-r--r--src/net/netdevice.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/net/netdevice.c b/src/net/netdevice.c
index 7c40a2ac..b834c3cd 100644
--- a/src/net/netdevice.c
+++ b/src/net/netdevice.c
@@ -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",