.
OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=576
This commit is contained in:
parent
e23319dfac
commit
700eb548c2
@ -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.
|
Port the patch of Robert to systemd v210 and test it out.
|
||||||
|
|
||||||
---
|
---
|
||||||
udev-event.c | 40 ++++++++++++++++++++++++++++++++++++----
|
udev-event.c | 43 +++++++++++++++++++++++++++++++++++++++----
|
||||||
1 file changed, 36 insertions(+), 4 deletions(-)
|
1 file changed, 39 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
--- systemd-210/src/udev/udev-event.c
|
--- src/udev/udev-event.c
|
||||||
+++ systemd-210/src/udev/udev-event.c 2014-03-04 11:19:50.583710411 +0100
|
+++ src/udev/udev-event.c 2014-03-27 13:19:06.727748307 +0000
|
||||||
@@ -765,10 +765,42 @@ static int rename_netif(struct udev_even
|
@@ -30,6 +30,7 @@
|
||||||
|
#include <sys/epoll.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <sys/signalfd.h>
|
||||||
|
+#include <sys/inotify.h>
|
||||||
|
|
||||||
|
#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;
|
return r;
|
||||||
|
|
||||||
r = rtnl_set_link_name(rtnl, udev_device_get_ifindex(dev), name);
|
r = rtnl_set_link_name(rtnl, udev_device_get_ifindex(dev), name);
|
||||||
- if (r < 0)
|
- if (r < 0)
|
||||||
- log_error("error changing net interface name %s to %s: %s",
|
+ if (r == 0) {
|
||||||
- oldname, name, strerror(-r));
|
+ 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
|
- else
|
||||||
+ if (r < 0) {
|
- print_kmsg("renamed network interface %s to %s", oldname, name);
|
||||||
+ char interim[IFNAMSIZ], *ptr = &interim[0];
|
+ return r;
|
||||||
+ int loop = 90;
|
+ }
|
||||||
|
+
|
||||||
|
+ /* 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) {
|
+ if (r != -EEXIST) {
|
||||||
+ log_error("error changing net interface name %s to %s: %s",
|
+ log_error("error changing net interface name %s to %s: %s",
|
||||||
+ oldname, name, strerror(-r));
|
+ interim, name, strerror(-r));
|
||||||
+ return 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;
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -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
|
Tue Mar 25 17:28:18 UTC 2014 - werner@suse.de
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user