]> git.pld-linux.org Git - packages/systemd.git/blame - net-rename-revert.patch
- updated net-rename-revert.patch (tested, works)
[packages/systemd.git] / net-rename-revert.patch
CommitLineData
f2dcae89
JR
1This is updated patch that fixes interface renaming broken by
2systemd commit 97595710b77aa162ca5e20da57d0a1ed7355eaad.
5112024c 3
f2dcae89 4udev: network device renaming - immediately give up if the target name isn't available
5112024c 5
f2dcae89
JR
6We want to to keep supporting systems with 75-persistent-net-generator.rules
7generated names. Re-apply this old hack to make the renaming less likely to fail.
8
9--- systemd-stable-246.1/src/udev/udev-event.c.orig 2020-08-07 17:09:53.000000000 +0200
10+++ systemd-stable-246.1/src/udev/udev-event.c 2020-08-15 11:04:10.263428290 +0200
11@@ -820,6 +820,8 @@
7cd4982d
JP
12 sd_device *dev = event->dev;
13 const char *oldname;
a919bc1d 14 int ifindex, r;
7cd4982d 15+ char name[IFNAMSIZ];
5112024c 16+ int loop;
5112024c 17
a919bc1d
JP
18 if (!event->name)
19 return 0; /* No new name is requested. */
f2dcae89
JR
20@@ -861,6 +863,32 @@
21 return log_device_debug_errno(event->dev_db_clone, r, "Failed to update database under /run/udev/data/: %m");
d3c9da06 22
7cd4982d 23 r = rtnl_set_link_name(&event->rtnl, ifindex, event->name);
5112024c 24+ /* keep trying if the destination interface name already exists */
d3c9da06 25+ if (r != -EEXIST)
5112024c 26+ goto out;
7cd4982d 27+
5112024c 28+ /* free our own name, another process may wait for us */
a919bc1d
JP
29+ snprintf(name, IFNAMSIZ, "rename%u", ifindex);
30+ r = rtnl_set_link_name(&event->rtnl, ifindex, name);
f2dcae89 31+ if (r < 0)
a919bc1d 32+ goto out;
f2dcae89 33+
5112024c 34+ /* log temporary name */
7cd4982d 35+ log_device_debug(dev, "Network interface %i is renamed from '%s' to '%s'", ifindex, oldname, event->name);
f2dcae89 36+
5112024c 37+ /* wait a maximum of 90 seconds for our target to become available */
d3c9da06 38+ strscpy(name, IFNAMSIZ, event->name);
5112024c
JR
39+ loop = 90 * 20;
40+ while (loop--) {
41+ const struct timespec duration = { 0, 1000 * 1000 * 1000 / 20 };
42+
43+ nanosleep(&duration, NULL);
44+
a919bc1d 45+ r = rtnl_set_link_name(&event->rtnl, ifindex, name);
d3c9da06 46+ if (r != -EEXIST)
a919bc1d 47+ goto out;
d3c9da06 48+ }
5112024c 49+out:
7cd4982d 50 if (r < 0)
f2dcae89
JR
51 return log_device_error_errno(dev, r, "Failed to rename network interface %i from '%s' to '%s': %m",
52 ifindex, oldname, event->name);
This page took 0.052491 seconds and 4 git commands to generate.