diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-12-09 05:57:12 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-09 05:57:12 +0900 |
commit | 0264c60d44eecd3e8369c9d013f6f3f7f23ddabc (patch) | |
tree | f82fb2102d89b3853337b111d001f448eb76902c | |
parent | 8097f805004004d6db4e4f33132a879fd6f8fd8b (diff) | |
parent | d9910948ebeedc134d4da7efce331d5b27e88bcf (diff) | |
download | systemd-0264c60d44eecd3e8369c9d013f6f3f7f23ddabc.tar.gz |
Merge pull request #21686 from yuwata/network-wlan-fix-reconfigure
network: do not reconfigure wireless interface when previously not connected to any APs
-rw-r--r-- | src/network/networkd-link.c | 20 | ||||
-rw-r--r-- | src/network/networkd-wifi.c | 2 |
2 files changed, 15 insertions, 7 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 8ca6dc56e0..9a2061baec 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1602,13 +1602,21 @@ static int link_carrier_gained(Link *link) { if (r < 0) log_link_warning_errno(link, r, "Failed to disable carrier lost timer, ignoring: %m"); - /* If the SSID is changed, then the connected wireless network could be changed. So, always - * reconfigure the link. Which means e.g. the DHCP client will be restarted, and the correct - * network information will be gained. + /* If a wireless interface was connected to an access point, and the SSID is changed (that is, + * both previous_ssid and ssid are non-NULL), then the connected wireless network could be + * changed. So, always reconfigure the link. Which means e.g. the DHCP client will be + * restarted, and the correct network information will be gained. + * + * However, do not reconfigure the wireless interface forcibly if it was not connected to any + * access points previously (previous_ssid is NULL in this case). As, a .network file may be + * already assigned to the interface (in that case, the .network file does not have the SSID= + * setting in the [Match] section), and the interface is already being configured. Of course, + * there may exist another .network file with higher priority and a matching SSID= setting. But + * in that case, link_reconfigure_impl() can handle that without the force_reconfigure flag. + * * For non-wireless interfaces, we have no way to detect the connected network change. So, - * setting force_reconfigure = false. Note, both ssid and previous_ssid should be NULL for - * non-wireless interfaces, and streq_ptr() returns true. */ - force_reconfigure = !streq_ptr(link->previous_ssid, link->ssid); + * setting force_reconfigure = false. Note, both ssid and previous_ssid are NULL in that case. */ + force_reconfigure = link->previous_ssid && !streq_ptr(link->previous_ssid, link->ssid); link->previous_ssid = mfree(link->previous_ssid); if (!IN_SET(link->state, LINK_STATE_PENDING, LINK_STATE_FAILED, LINK_STATE_LINGER)) { diff --git a/src/network/networkd-wifi.c b/src/network/networkd-wifi.c index f1d5c7d8d4..8fd1cf5039 100644 --- a/src/network/networkd-wifi.c +++ b/src/network/networkd-wifi.c @@ -130,7 +130,7 @@ int manager_genl_process_nl80211_config(sd_netlink *genl, sd_netlink_message *me log_link_debug(link, "nl80211: received %s(%u) message: iftype=%s, ssid=%s", strna(nl80211_cmd_to_string(cmd)), cmd, - strna(nl80211_iftype_to_string(wlan_iftype)), ssid); + strna(nl80211_iftype_to_string(wlan_iftype)), strna(ssid)); switch(cmd) { case NL80211_CMD_SET_INTERFACE: |