mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-05 21:57:27 +03:00
network: recreate link if its interface name is changed (#8795)
If an interface name is changed, then the link state, especially managed or not, may need to be updated, as its corresponding .link or .network files may be different. So, let's once drop the link and recreate a new link object. Fixes #8794.
This commit is contained in:
parent
cd81a8fc82
commit
587c458665
@ -3215,15 +3215,18 @@ int link_update(Link *link, sd_netlink_message *m) {
|
||||
if (r >= 0 && !streq(ifname, link->ifname)) {
|
||||
log_link_info(link, "Interface name change detected, %s has been renamed to %s.", link->ifname, ifname);
|
||||
|
||||
link_free_carrier_maps(link);
|
||||
if (link->state == LINK_STATE_PENDING) {
|
||||
r = free_and_strdup(&link->ifname, ifname);
|
||||
if (r < 0)
|
||||
return r;
|
||||
} else {
|
||||
Manager *manager = link->manager;
|
||||
|
||||
r = free_and_strdup(&link->ifname, ifname);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = link_new_carrier_maps(link);
|
||||
if (r < 0)
|
||||
return r;
|
||||
link_drop(link);
|
||||
r = link_add(manager, m, &link);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
r = sd_netlink_message_read_u32(m, IFLA_MTU, &mtu);
|
||||
|
Loading…
x
Reference in New Issue
Block a user