]>
Commit | Line | Data |
---|---|---|
f2dcae89 JR |
1 | This is updated patch that fixes interface renaming broken by |
2 | systemd commit 97595710b77aa162ca5e20da57d0a1ed7355eaad. | |
5112024c | 3 | |
f2dcae89 | 4 | udev: network device renaming - immediately give up if the target name isn't available |
5112024c | 5 | |
f2dcae89 JR |
6 | We want to to keep supporting systems with 75-persistent-net-generator.rules |
7 | generated 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 @@ | |
65813442 | 12 | const char *s; |
ece69e3e | 13 | sd_device *dev; |
a919bc1d | 14 | int ifindex, r; |
7cd4982d | 15 | + char name[IFNAMSIZ]; |
5112024c | 16 | + int loop; |
5112024c | 17 | |
ece69e3e JP |
18 | assert(event); |
19 | ||
f2dcae89 | 20 | @@ -861,6 +863,32 @@ |
65813442 | 21 | } |
d3c9da06 | 22 | |
5003d836 | 23 | r = rtnl_set_link_name(&event->rtnl, ifindex, event->name, event->altnames); |
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 */ |
51186fee | 29 | + snprintf(name, IFNAMSIZ, "rename%d", ifindex); |
5003d836 | 30 | + r = rtnl_set_link_name(&event->rtnl, ifindex, name, NULL); |
f2dcae89 | 31 | + if (r < 0) |
a919bc1d | 32 | + goto out; |
f2dcae89 | 33 | + |
5112024c | 34 | + /* log temporary name */ |
65813442 | 35 | + log_device_debug(dev, "Network interface %i is renamed from '%s' to '%s'", ifindex, old_sysname, 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 | + | |
5003d836 | 45 | + r = rtnl_set_link_name(&event->rtnl, ifindex, name, NULL); |
d3c9da06 | 46 | + if (r != -EEXIST) |
a919bc1d | 47 | + goto out; |
d3c9da06 | 48 | + } |
5112024c | 49 | +out: |
65813442 JP |
50 | if (r < 0) { |
51 | if (r == -EBUSY) { | |
3d6ad35d | 52 | log_device_info(event->dev_db_clone, |