1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-12 13:18:14 +03:00

network: introduce LINK_RECONFIGURE_CLEANLY flag

And use it when explicit reconfiguration is requested by Reconfigure() DBus method
or networkd certainly detects that connected network is changed.
Otherwise do not use the flag especially when we come back from sleep mode.
This commit is contained in:
Yu Watanabe 2024-11-05 11:41:31 +09:00
parent 451c2baf30
commit 6e0c9b7dac
3 changed files with 4 additions and 3 deletions

View File

@ -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. */

View File

@ -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

View File

@ -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;