]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Do not select APs found on disabled channels for connection
authorVamsi Krishna <vamsin@codeaurora.org>
Wed, 11 Dec 2019 12:57:47 +0000 (18:27 +0530)
committerJouni Malinen <j@w1.fi>
Wed, 8 Jan 2020 14:19:47 +0000 (16:19 +0200)
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 <jouni@codeaurora.org>
wpa_supplicant/events.c

index d75a50eafe608d8a12f53990b0eb408dc18fc725..854b9cf935d877e529025a4ebcf1916ba83b47f1 100644 (file)
@@ -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) {