diff --git a/1006-udev-always-rename-network.patch b/1006-udev-always-rename-network.patch index 1cbbda7..2187203 100644 --- a/1006-udev-always-rename-network.patch +++ b/1006-udev-always-rename-network.patch @@ -9,55 +9,76 @@ Date: Tue, 4 Mar 2014 10:29:21 +0000 Port the patch of Robert to systemd v210 and test it out. --- - udev-event.c | 40 ++++++++++++++++++++++++++++++++++++---- - 1 file changed, 36 insertions(+), 4 deletions(-) + udev-event.c | 43 +++++++++++++++++++++++++++++++++++++++---- + 1 file changed, 39 insertions(+), 4 deletions(-) ---- 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 +--- src/udev/udev-event.c ++++ src/udev/udev-event.c 2014-03-27 13:19:06.727748307 +0000 +@@ -30,6 +30,7 @@ + #include + #include + #include ++#include + + #include "udev.h" + #include "rtnl-util.h" +@@ -750,8 +751,9 @@ static int rename_netif(struct udev_even + struct udev_device *dev = event->dev; + _cleanup_rtnl_unref_ sd_rtnl *rtnl = NULL; + char name[IFNAMSIZ]; ++ char interim[IFNAMSIZ], *ptr = &interim[0]; + const char *oldname; +- int r; ++ int r, loop; + + oldname = udev_device_get_sysname(dev); + +@@ -765,12 +767,45 @@ static int rename_netif(struct udev_even return r; 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)); ++ if (r == 0) { ++ print_kmsg("renamed network interface %s to %s\n", oldname, name); ++ return r; ++ } else if (r != -EEXIST) { + 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; +- print_kmsg("renamed network interface %s to %s", oldname, name); ++ return r; ++ } ++ ++ /* free our own name, another process may wait for us */ ++ strpcpyf(&ptr, IFNAMSIZ, "rename%u", udev_device_get_ifindex(dev)); ++ ++ 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, interim, strerror(-r)); ++ return r; ++ } + ++ /* log temporary name */ ++ print_kmsg("renamed network interface %s to %s\n", oldname, interim); ++ ++ loop = 90 * 20; ++ while (loop--) { ++ const struct timespec duration = { 0, 1000 * 1000 * 1000 / 20 }; ++ nanosleep(&duration, NULL); ++ ++ r = rtnl_set_link_name(rtnl, udev_device_get_ifindex(dev), name); ++ if (r == 0) { ++ print_kmsg("renamed network interface %s to %s\n", interim, name); ++ break; ++ } + -+ /* 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; ++ interim, name, strerror(-r)); ++ break; + } -+ -+ /* free our own name, another process may wait for us */ -+ strpcpyf(&ptr, IFNAMSIZ, "rename%u", udev_device_get_ifindex(dev)); -+ -+ 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; -+ } -+ -+ /* 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; + } + diff --git a/systemd.changes b/systemd.changes index 0d51ff1..294911d 100644 --- a/systemd.changes +++ b/systemd.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri Mar 28 08:10:13 UTC 2014 - werner@suse.de + +- Use Robert's revised 1006-udev-always-rename-network.patch + ------------------------------------------------------------------- Tue Mar 25 17:28:18 UTC 2014 - werner@suse.de