diff --git a/src/network/networkd-link-bus.c b/src/network/networkd-link-bus.c index 654aea36a2..27ee855181 100644 --- a/src/network/networkd-link-bus.c +++ b/src/network/networkd-link-bus.c @@ -665,7 +665,7 @@ int bus_link_method_reconfigure(sd_bus_message *message, void *userdata, sd_bus_ if (r == 0) return 1; /* Polkit will call us back */ - r = link_reconfigure_full(l, LINK_RECONFIGURE_UNCONDITIONALLY, message, /* counter = */ NULL); + r = link_reconfigure_full(l, LINK_RECONFIGURE_UNCONDITIONALLY | LINK_RECONFIGURE_CLEANLY, message, /* counter = */ NULL); if (r != 0) return r; /* Will reply later when r > 0. */ diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 8f925f895e..080e6beff3 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1387,7 +1387,7 @@ int link_reconfigure_impl(Link *link, LinkReconfigurationFlag flags) { /* Dropping old .network file */ - if (FLAGS_SET(flags, LINK_RECONFIGURE_UNCONDITIONALLY)) { + if (FLAGS_SET(flags, LINK_RECONFIGURE_CLEANLY)) { /* Remove all static configurations. Note, dynamic configurations are dropped by * link_stop_engines(), and foreign configurations will be removed later by * link_configure() -> link_drop_unmanaged_config(). */ @@ -1741,7 +1741,7 @@ static int link_carrier_gained(Link *link) { * For non-wireless interfaces, we have no way to detect the connected network change. So, * we do not set any flags here. Note, both ssid and previous_ssid are NULL in that case. */ if (link->previous_ssid && !streq_ptr(link->previous_ssid, link->ssid)) - flags |= LINK_RECONFIGURE_UNCONDITIONALLY; + flags |= LINK_RECONFIGURE_UNCONDITIONALLY | LINK_RECONFIGURE_CLEANLY; link->previous_ssid = mfree(link->previous_ssid); /* AP and P2P-GO interfaces may have a new SSID - update the link properties in case a new .network diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h index 9ae7e1c8da..ad8bac7ad6 100644 --- a/src/network/networkd-link.h +++ b/src/network/networkd-link.h @@ -44,6 +44,7 @@ typedef enum LinkState { typedef enum LinkReconfigurationFlag { LINK_RECONFIGURE_UNCONDITIONALLY = 1 << 0, /* Reconfigure an interface even if .network file is unchanged. */ + LINK_RECONFIGURE_CLEANLY = 1 << 1, /* Drop all existing configs before reconfiguring. Otherwise, reuse existing configs as possible as we can. */ } LinkReconfigurationFlag; typedef struct Manager Manager;