wifi-util: do not ignore wifi iftype when SSID is not set
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 11 Jan 2021 14:36:42 +0000 (23:36 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 2 Feb 2021 16:35:40 +0000 (17:35 +0100)
Previously, if an interface does not have SSID, e.g. run in mesh-point
type, then the wifi iftype obtained by the netlink call was ignored.

Fixes #18059.

(cherry picked from commit a66a402da471f6230ab8674fd2c1df6d918773b5)
(cherry picked from commit fc4eae72f8dd34a334b2707614d9c07974d4d604)

src/shared/wifi-util.c

index e245014706225ea428678dea94b573dabf74a2c7..01785e3d7f38b33899d6f15bf8968e178fcd0134 100644 (file)
@@ -29,8 +29,10 @@ int wifi_get_interface(sd_netlink *genl, int ifindex, enum nl80211_iftype *iftyp
         }
         if (r < 0)
                 return log_debug_errno(r, "Failed to request information about wifi interface %d: %m", ifindex);
-        if (!reply)
+        if (!reply) {
+                log_debug_errno(r, "No reply received to request for information about wifi interface %d, ignoring.", ifindex);
                 goto nodata;
+        }
 
         r = sd_netlink_message_get_errno(reply);
         if (r < 0)
@@ -56,8 +58,8 @@ int wifi_get_interface(sd_netlink *genl, int ifindex, enum nl80211_iftype *iftyp
         if (ssid) {
                 r = sd_netlink_message_read_string_strdup(reply, NL80211_ATTR_SSID, ssid);
                 if (r == -ENODATA)
-                        goto nodata;
-                if (r < 0)
+                        *ssid = NULL;
+                else if (r < 0)
                         return log_debug_errno(r, "Failed to get NL80211_ATTR_SSID attribute: %m");
         }
 
@@ -95,8 +97,10 @@ int wifi_get_station(sd_netlink *genl, int ifindex, struct ether_addr *bssid) {
         r = sd_netlink_call(genl, m, 0, &reply);
         if (r < 0)
                 return log_debug_errno(r, "Failed to request information about wifi station: %m");
-        if (!reply)
+        if (!reply) {
+                log_debug_errno(r, "No reply received to request for information about wifi station, ignoring.");
                 goto nodata;
+        }
 
         r = sd_netlink_message_get_errno(reply);
         if (r < 0)