From 33c8a10498c12624bb7418938669994213a82000 Mon Sep 17 00:00:00 2001 From: Vamsi Krishna Date: Wed, 11 Dec 2019 18:27:47 +0530 Subject: [PATCH] Do not select APs found on disabled channels for connection If a channel list changed event is received after a scan and before selecting a BSS for connection, a BSS found on a now disabled channel may get selected for connection. The connect request issued with the BSS found on a disabled channel is rejected by cfg80211. Filter out the BSSs found on disabled channels and select from the other BSSs found on enabled channels to avoid unnecessary connection attempts that are bound to fail. The channel list information will be updated by the driver in cases like country code update, disabling/enabling specific bands, etc. which can occur between the scan and connection attempt. Signed-off-by: Jouni Malinen --- wpa_supplicant/events.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index d75a50eaf..854b9cf93 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1015,6 +1015,28 @@ static void owe_trans_ssid(struct wpa_supplicant *wpa_s, struct wpa_bss *bss, } +static int disabled_freq(struct wpa_supplicant *wpa_s, int freq) +{ + int i, j; + + if (!wpa_s->hw.modes || !wpa_s->hw.num_modes) + return 0; + + for (j = 0; j < wpa_s->hw.num_modes; j++) { + struct hostapd_hw_modes *mode = &wpa_s->hw.modes[j]; + + for (i = 0; i < mode->num_channels; i++) { + struct hostapd_channel_data *chan = &mode->channels[i]; + + if (chan->freq == freq) + return !!(chan->flag & HOSTAPD_CHAN_DISABLED); + } + } + + return 1; +} + + struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s, int i, struct wpa_bss *bss, struct wpa_ssid *group, @@ -1106,6 +1128,12 @@ struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s, return NULL; } + if (disabled_freq(wpa_s, bss->freq)) { + if (debug_print) + wpa_dbg(wpa_s, MSG_DEBUG, " skip - channel disabled"); + return NULL; + } + wpa = wpa_ie_len > 0 || rsn_ie_len > 0; for (ssid = group; ssid; ssid = only_first_ssid ? NULL : ssid->pnext) {