2013-04-23 11:39:56 +02:00
|
|
|
From: Robert Milasan <rmilasan@suse.com>
|
2014-03-11 09:24:11 +01:00
|
|
|
Cc: Werner Fink <werner@suse.de>
|
2013-04-23 11:39:56 +02:00
|
|
|
Subject: udev always rename network
|
|
|
|
|
2014-03-11 09:24:11 +01:00
|
|
|
Date: Thu, 28 Mar 2013 09:24:43 +0000
|
|
|
|
udev: ensure that the network interfaces are renamed even if they exist (bnc#809843).
|
|
|
|
|
|
|
|
Date: Tue, 4 Mar 2014 10:29:21 +0000
|
|
|
|
Port the patch of Robert to systemd v210 and test it out.
|
|
|
|
|
2013-04-23 11:39:56 +02:00
|
|
|
---
|
2014-03-11 09:24:11 +01:00
|
|
|
udev-event.c | 40 ++++++++++++++++++++++++++++++++++++----
|
|
|
|
1 file changed, 36 insertions(+), 4 deletions(-)
|
2013-04-23 11:39:56 +02:00
|
|
|
|
2014-03-11 09:24:11 +01:00
|
|
|
--- systemd-210/src/udev/udev-event.c
|
|
|
|
+++ systemd-210/src/udev/udev-event.c 2014-03-04 11:19:50.583710411 +0100
|
|
|
|
@@ -765,10 +765,42 @@ static int rename_netif(struct udev_even
|
|
|
|
return r;
|
2013-04-23 11:39:56 +02:00
|
|
|
|
2014-03-11 09:24:11 +01:00
|
|
|
r = rtnl_set_link_name(rtnl, udev_device_get_ifindex(dev), name);
|
|
|
|
- if (r < 0)
|
|
|
|
- log_error("error changing net interface name %s to %s: %s",
|
|
|
|
- oldname, name, strerror(-r));
|
|
|
|
- else
|
|
|
|
+ if (r < 0) {
|
|
|
|
+ char interim[IFNAMSIZ], *ptr = &interim[0];
|
|
|
|
+ int loop = 90;
|
2013-04-23 11:39:56 +02:00
|
|
|
+
|
2014-03-11 09:24:11 +01:00
|
|
|
+ /* keep trying if the destination interface name already exists */
|
|
|
|
+ if (r != -EEXIST) {
|
|
|
|
+ log_error("error changing net interface name %s to %s: %s",
|
|
|
|
+ oldname, name, strerror(-r));
|
|
|
|
+ return r;
|
|
|
|
+ }
|
2013-04-23 11:39:56 +02:00
|
|
|
+
|
2014-03-11 09:24:11 +01:00
|
|
|
+ /* free our own name, another process may wait for us */
|
|
|
|
+ strpcpyf(&ptr, IFNAMSIZ, "rename%u", udev_device_get_ifindex(dev));
|
2013-04-23 11:39:56 +02:00
|
|
|
+
|
2014-03-11 09:24:11 +01:00
|
|
|
+ r = rtnl_set_link_name(rtnl, udev_device_get_ifindex(dev), interim);
|
|
|
|
+ if (r < 0) {
|
|
|
|
+ log_error("error changing net interface name %s to %s: %s",
|
|
|
|
+ oldname, name, strerror(-r));
|
|
|
|
+ return r;
|
|
|
|
+ }
|
2013-04-23 11:39:56 +02:00
|
|
|
+
|
2014-03-11 09:24:11 +01:00
|
|
|
+ /* log temporary name */
|
|
|
|
+ print_kmsg("renamed network interface %s to %s", oldname, interim);
|
|
|
|
+ do {
|
|
|
|
+ r = rtnl_set_link_name(rtnl, udev_device_get_ifindex(dev), name);
|
|
|
|
+ if (r == 0) {
|
|
|
|
+ print_kmsg("renamed network interface %s to %s", oldname, name);
|
|
|
|
+ return r;
|
|
|
|
+ }
|
|
|
|
+ if (r != -EEXIST) {
|
|
|
|
+ log_error("error changing net interface name %s to %s: %s",
|
|
|
|
+ oldname, name, strerror(-r));
|
|
|
|
+ return r;
|
|
|
|
+ }
|
|
|
|
+ } while (loop-- > 0);
|
|
|
|
+ } else
|
|
|
|
print_kmsg("renamed network interface %s to %s", oldname, name);
|
|
|
|
|
|
|
|
return r;
|