From 09c03103028011935044bbade29a602925898f27 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Tue, 10 Aug 2010 16:41:24 +0200 Subject: [PATCH] udev-event.c: rename interface to -, if taken e.g. if eth0 should be eth3 and eth3 is waiting to be renamed, eth0 was renamed to eth0_rename. The kernel would take eth0 as the name for a new interface and this new eth0 could also become eth0_rename, if the target name is also taken. To prevent this name clash, the interfaces are now renamed to - and the rename is logged. --- udev/udev-event.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/udev/udev-event.c b/udev/udev-event.c index 7591d5e3..7785ad89 100644 --- a/udev/udev-event.c +++ b/udev/udev-event.c @@ -465,6 +465,7 @@ static int rename_netif(struct udev_event *event) int sk; struct ifreq ifr; int err; + char *newdup; info(event->udev, "changing net interface name from '%s' to '%s'\n", udev_device_get_sysname(dev), event->name); @@ -492,13 +493,16 @@ static int rename_netif(struct udev_event *event) } /* free our own name, another process may wait for us */ - util_strscpyl(ifr.ifr_newname, IFNAMSIZ, udev_device_get_sysname(dev), "_rename", NULL); + newdup = strdup(ifr.ifr_newname); + util_strscpyl(ifr.ifr_newname, IFNAMSIZ, udev_device_get_sysname(dev), "-", newdup, NULL); + free(newdup); err = ioctl(sk, SIOCSIFNAME, &ifr); if (err != 0) { err(event->udev, "error changing netif name %s to %s: %m\n", ifr.ifr_name, ifr.ifr_newname); goto exit; } + rename_netif_kernel_log(ifr); /* wait 90 seconds for our target to become available */ util_strscpy(ifr.ifr_name, IFNAMSIZ, ifr.ifr_newname); -- 2.39.5