summaryrefslogtreecommitdiff
path: root/udev
diff options
context:
space:
mode:
authorHarald Hoyer <harald@redhat.com>2010-08-10 16:41:24 +0200
committerHarald Hoyer <harald@redhat.com>2010-08-10 16:46:48 +0200
commit09c03103028011935044bbade29a602925898f27 (patch)
tree0ca6abfe731ab2389fb6a5446aaf24342c09a976 /udev
parentc11f89b61a7872f640a15292a21c43504ce664da (diff)
udev-event.c: rename interface to <src>-<dest>, if <dest> 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 <src>-<dest> and the rename is logged.
Diffstat (limited to 'udev')
-rw-r--r--udev/udev-event.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/udev/udev-event.c b/udev/udev-event.c
index 7591d5e314..7785ad892c 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);