Skip to content

Commit d991094

Browse files
committed
network: do not reconfigure wireless interface when previously not connected to any APs
Follow-up for 6706ce2. Fixes systemd#21685.
1 parent da94e4d commit d991094

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/network/networkd-link.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,13 +1602,21 @@ static int link_carrier_gained(Link *link) {
16021602
if (r < 0)
16031603
log_link_warning_errno(link, r, "Failed to disable carrier lost timer, ignoring: %m");
16041604

1605-
/* If the SSID is changed, then the connected wireless network could be changed. So, always
1606-
* reconfigure the link. Which means e.g. the DHCP client will be restarted, and the correct
1607-
* network information will be gained.
1605+
/* If a wireless interface was connected to an access point, and the SSID is changed (that is,
1606+
* both previous_ssid and ssid are non-NULL), then the connected wireless network could be
1607+
* changed. So, always reconfigure the link. Which means e.g. the DHCP client will be
1608+
* restarted, and the correct network information will be gained.
1609+
*
1610+
* However, do not reconfigure the wireless interface forcibly if it was not connected to any
1611+
* access points previously (previous_ssid is NULL in this case). As, a .network file may be
1612+
* already assigned to the interface (in that case, the .network file does not have the SSID=
1613+
* setting in the [Match] section), and the interface is already being configured. Of course,
1614+
* there may exist another .network file with higher priority and a matching SSID= setting. But
1615+
* in that case, link_reconfigure_impl() can handle that without the force_reconfigure flag.
1616+
*
16081617
* For non-wireless interfaces, we have no way to detect the connected network change. So,
1609-
* setting force_reconfigure = false. Note, both ssid and previous_ssid should be NULL for
1610-
* non-wireless interfaces, and streq_ptr() returns true. */
1611-
force_reconfigure = !streq_ptr(link->previous_ssid, link->ssid);
1618+
* setting force_reconfigure = false. Note, both ssid and previous_ssid are NULL in that case. */
1619+
force_reconfigure = link->previous_ssid && !streq_ptr(link->previous_ssid, link->ssid);
16121620
link->previous_ssid = mfree(link->previous_ssid);
16131621

16141622
if (!IN_SET(link->state, LINK_STATE_PENDING, LINK_STATE_FAILED, LINK_STATE_LINGER)) {

0 commit comments

Comments
 (0)