]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: reconfigure interface when wifi iftype is updated
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 12 Jan 2021 14:35:01 +0000 (23:35 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 12 Jan 2021 21:42:02 +0000 (06:42 +0900)
Follow-up for a66a402da471f6230ab8674fd2c1df6d918773b5.

Fixes #18059.

src/network/networkd-wifi.c

index 0f2def7a16b635601f32c2f0f092889ca986caab..57e8a0e9b5db21adefa025db29ad677c6069238b 100644 (file)
@@ -16,6 +16,8 @@
 #include "wifi-util.h"
 
 int wifi_get_info(Link *link) {
+        _cleanup_free_ char *ssid = NULL;
+        enum nl80211_iftype iftype;
         const char *type;
         int r, s = 0;
 
@@ -33,16 +35,18 @@ int wifi_get_info(Link *link) {
         if (!streq(type, "wlan"))
                 return 0;
 
-        _cleanup_free_ char *ssid = NULL;
-        r = wifi_get_interface(link->manager->genl, link->ifindex, &link->wlan_iftype, &ssid);
+        r = wifi_get_interface(link->manager->genl, link->ifindex, &iftype, &ssid);
         if (r < 0)
                 return r;
-        if (r > 0 && streq_ptr(link->ssid, ssid))
+        if (r > 0 && link->wlan_iftype == iftype && streq_ptr(link->ssid, ssid))
                 r = 0;
+
+        link->wlan_iftype = iftype;
         free_and_replace(link->ssid, ssid);
 
         if (link->wlan_iftype == NL80211_IFTYPE_STATION) {
                 struct ether_addr old_bssid = link->bssid;
+
                 s = wifi_get_station(link->manager->genl, link->ifindex, &link->bssid);
                 if (s < 0)
                         return s;
@@ -56,7 +60,9 @@ int wifi_get_info(Link *link) {
                 if (link->wlan_iftype == NL80211_IFTYPE_STATION && link->ssid)
                         log_link_info(link, "Connected WiFi access point: %s (%s)",
                                       link->ssid, ether_addr_to_string(&link->bssid, buf));
-                return 1;
+
+                return 1; /* Some information is updated. */
         }
-        return 0;
+
+        return 0; /* No new information. */
 }