From a5330078158cbd5070e42fd3f91ecb570e210359 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 11 Jan 2021 23:26:54 +0900 Subject: [PATCH 1/2] wifi-util: cleanup header inclusion --- src/shared/wifi-util.c | 6 ------ src/shared/wifi-util.h | 3 ++- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/shared/wifi-util.c b/src/shared/wifi-util.c index ae5cecc25d..c83e817dbc 100644 --- a/src/shared/wifi-util.c +++ b/src/shared/wifi-util.c @@ -1,12 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include - -#include "sd-bus.h" - #include "log.h" -#include "netlink-util.h" #include "wifi-util.h" int wifi_get_interface(sd_netlink *genl, int ifindex, enum nl80211_iftype *iftype, char **ssid) { diff --git a/src/shared/wifi-util.h b/src/shared/wifi-util.h index 01b0c3c635..0ce41372e2 100644 --- a/src/shared/wifi-util.h +++ b/src/shared/wifi-util.h @@ -3,8 +3,9 @@ #pragma once #include +#include -#include "netlink-util.h" +#include "sd-netlink.h" int wifi_get_interface(sd_netlink *genl, int ifindex, enum nl80211_iftype *iftype, char **ssid); int wifi_get_station(sd_netlink *genl, int ifindex, struct ether_addr *bssid); From a66a402da471f6230ab8674fd2c1df6d918773b5 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 11 Jan 2021 23:36:42 +0900 Subject: [PATCH 2/2] wifi-util: do not ignore wifi iftype when SSID is not set 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. --- src/shared/wifi-util.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/shared/wifi-util.c b/src/shared/wifi-util.c index c83e817dbc..2ac8846004 100644 --- a/src/shared/wifi-util.c +++ b/src/shared/wifi-util.c @@ -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)