]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: wifi: try to reconfigure when connected 25477/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 22 Nov 2022 05:24:32 +0000 (14:24 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 22 Nov 2022 05:44:26 +0000 (14:44 +0900)
Sometimes, RTM_NEWLINK message with carrier is received earlier than
NL80211_CMD_CONNECT. To make SSID= or other WiFi related settings in
[Match] section work, let's try to reconfigure the interface.

Fixes a bug introduced by 96f5f9ef9a1ba5146d3357c1548fb675d3bd5b68.

Fixes #25384.

src/network/networkd-link.c
src/network/networkd-link.h
src/network/networkd-wifi.c

index 4ed622cfe669a859181629157967c4d99b68c185..c46b8f5b2e8f50862c14c2dff997f41427fa4814 100644 (file)
@@ -1178,7 +1178,7 @@ static int link_get_network(Link *link, Network **ret) {
         return -ENOENT;
 }
 
-static int link_reconfigure_impl(Link *link, bool force) {
+int link_reconfigure_impl(Link *link, bool force) {
         Network *network = NULL;
         NetDev *netdev = NULL;
         int r;
index 5838eb16b0458b08d2a0fcf13315f94f0ce72eb0..0d601ab5482a7b1cbcbf108ee1520f05650848e3 100644 (file)
@@ -238,6 +238,7 @@ int link_stop_engines(Link *link, bool may_keep_dhcp);
 const char* link_state_to_string(LinkState s) _const_;
 LinkState link_state_from_string(const char *s) _pure_;
 
+int link_reconfigure_impl(Link *link, bool force);
 int link_reconfigure(Link *link, bool force);
 
 int manager_udev_process_link(Manager *m, sd_device *device, sd_device_action_t action);
index 4bf798a9eb01162b71dc837655a01f2882c29cb6..62cbca0cf99d20276448e52b171f55d360f0b233 100644 (file)
@@ -269,6 +269,18 @@ int manager_genl_process_nl80211_mlme(sd_netlink *genl, sd_netlink_message *mess
                 if (link->wlan_iftype == NL80211_IFTYPE_STATION && link->ssid)
                         log_link_info(link, "Connected WiFi access point: %s (%s)",
                                       link->ssid, ETHER_ADDR_TO_STR(&link->bssid));
+
+                /* Sometimes, RTM_NEWLINK message with carrier is received earlier than NL80211_CMD_CONNECT.
+                 * To make SSID= or other WiFi related settings in [Match] section work, let's try to
+                 * reconfigure the interface. */
+                if (link->ssid && link_has_carrier(link)) {
+                        r = link_reconfigure_impl(link, /* force = */ false);
+                        if (r < 0) {
+                                log_link_warning_errno(link, r, "Failed to reconfigure interface: %m");
+                                link_enter_failed(link);
+                                return 0;
+                        }
+                }
                 break;
         }
         case NL80211_CMD_DISCONNECT: