]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Remove 6 GHz channels from full scan if 6 GHz not enabled for P2P
authorSreeramya Soratkal <ssramya@codeaurora.org>
Tue, 28 Sep 2021 15:33:15 +0000 (21:03 +0530)
committerJouni Malinen <j@w1.fi>
Fri, 26 Nov 2021 21:45:54 +0000 (23:45 +0200)
The channels included for the scan to connect to a P2P GO are optimized
such that the P2P GO preferred channel and the common channels are
included for the first few scans followed by a full scan in which all
the channels supported by the local device are included. This results in
P2P client including the 6 GHz channels for the full scan after GO
Negotiation even when 6 GHz channels are not used for the P2P
connection.

Exclude the 6 GHz channels from the full scan if 6 GHz channels are
supported but are not used for P2P connection.

Signed-off-by: Sreeramya Soratkal <ssramya@codeaurora.org>
wpa_supplicant/scan.c

index 97a8d9a638d6af31bf1d5176f341f8d5d1da82da..b8cba2ee95402bef07603c953d399770784de0a1 100644 (file)
@@ -392,6 +392,29 @@ wpa_supplicant_build_filter_ssids(struct wpa_config *conf, size_t *num_ssids)
 }
 
 
+#ifdef CONFIG_P2P
+static bool is_6ghz_supported(struct wpa_supplicant *wpa_s)
+{
+       struct hostapd_channel_data *chnl;
+       int i, j;
+
+       for (i = 0; i < wpa_s->hw.num_modes; i++) {
+               if (wpa_s->hw.modes[i].mode == HOSTAPD_MODE_IEEE80211A) {
+                       chnl = wpa_s->hw.modes[i].channels;
+                       for (j = 0; j < wpa_s->hw.modes[i].num_channels; j++) {
+                               if (chnl[j].flag & HOSTAPD_CHAN_DISABLED)
+                                       continue;
+                               if (is_6ghz_freq(chnl[j].freq))
+                                       return true;
+                       }
+               }
+       }
+
+       return false;
+}
+#endif /* CONFIG_P2P */
+
+
 static void wpa_supplicant_optimize_freqs(
        struct wpa_supplicant *wpa_s, struct wpa_driver_scan_params *params)
 {
@@ -1337,6 +1360,34 @@ scan:
                        }
                }
        }
+
+       if (!params.freqs &&
+           (wpa_s->p2p_in_invitation || wpa_s->p2p_in_provisioning) &&
+           !is_p2p_allow_6ghz(wpa_s->global->p2p) &&
+           is_6ghz_supported(wpa_s)) {
+               int i;
+
+               /* Exclude 5 GHz channels from the full scan for P2P connection
+                * since the 6 GHz band is disabled for P2P uses. */
+               wpa_printf(MSG_DEBUG,
+                          "P2P: 6 GHz disabled - update the scan frequency list");
+               for (i = 0; i < wpa_s->hw.num_modes; i++) {
+                       if (wpa_s->hw.modes[i].num_channels == 0)
+                               continue;
+                       if (wpa_s->hw.modes[i].mode == HOSTAPD_MODE_IEEE80211G)
+                               wpa_add_scan_freqs_list(
+                                       wpa_s, HOSTAPD_MODE_IEEE80211G,
+                                       &params, false);
+                       if (wpa_s->hw.modes[i].mode == HOSTAPD_MODE_IEEE80211A)
+                               wpa_add_scan_freqs_list(
+                                       wpa_s, HOSTAPD_MODE_IEEE80211A,
+                                       &params, false);
+                       if (wpa_s->hw.modes[i].mode == HOSTAPD_MODE_IEEE80211AD)
+                               wpa_add_scan_freqs_list(
+                                       wpa_s, HOSTAPD_MODE_IEEE80211AD,
+                                       &params, false);
+               }
+       }
 #endif /* CONFIG_P2P */
 
        ret = wpa_supplicant_trigger_scan(wpa_s, scan_params);