]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Prefer 5/60 GHz band over 2.4 GHz during GO configuration
authorSunil Dutt <usdutt@qti.qualcomm.com>
Sun, 8 Oct 2017 05:33:21 +0000 (11:03 +0530)
committerJouni Malinen <j@w1.fi>
Wed, 11 Oct 2017 14:01:10 +0000 (17:01 +0300)
Previously, wpas_p2p_select_go_freq_no_pref() ended up selecting a 2.4
GHz band channel first before even considering 5 or 60 GHz channels.
This was likely done more or less by accident rather than by design when
the 5 GHz and 60 GHz band extensions were added. It seems reasonable to
enhance this by reordering the code to start with 5 and 60 GHz operating
classes and move to 2.4 GHz band only if no channel was available in 5
or 60 GHz bands for P2P GO use.

This does have some potential interop issues with 2.4 GHz only peer
devices when starting up an autonomous GO (i.e., without there being
prior knowledge of channels that the peers support). Upper layers are
expected to enforce 2.4 GHz selection if that is needed for some use
cases.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
wpa_supplicant/p2p_supplicant.c

index d4bd19a3bc72a986067a8714787be3233fe35fa7..fd6a1a2afe1bf7a1518f81e1e2a0ff193a160b88 100644 (file)
@@ -5730,30 +5730,6 @@ static void wpas_p2p_select_go_freq_no_pref(struct wpa_supplicant *wpa_s,
 {
        unsigned int i, r;
 
-       /* first try some random selection of the social channels */
-       if (os_get_random((u8 *) &r, sizeof(r)) < 0)
-               return;
-
-       for (i = 0; i < 3; i++) {
-               params->freq = 2412 + ((r + i) % 3) * 25;
-               if (wpas_p2p_supported_freq_go(wpa_s, channels, params->freq))
-                       goto out;
-       }
-
-       /* try all other channels in operating class 81 */
-       for (i = 0; i < 11; i++) {
-               params->freq = 2412 + i * 5;
-
-               /* skip social channels; covered in the previous loop */
-               if (params->freq == 2412 ||
-                   params->freq == 2437 ||
-                   params->freq == 2462)
-                       continue;
-
-               if (wpas_p2p_supported_freq_go(wpa_s, channels, params->freq))
-                       goto out;
-       }
-
        /* try all channels in operating class 115 */
        for (i = 0; i < 4; i++) {
                params->freq = 5180 + i * 20;
@@ -5788,6 +5764,30 @@ static void wpas_p2p_select_go_freq_no_pref(struct wpa_supplicant *wpa_s,
                        goto out;
        }
 
+       /* try some random selection of the social channels */
+       if (os_get_random((u8 *) &r, sizeof(r)) < 0)
+               return;
+
+       for (i = 0; i < 3; i++) {
+               params->freq = 2412 + ((r + i) % 3) * 25;
+               if (wpas_p2p_supported_freq_go(wpa_s, channels, params->freq))
+                       goto out;
+       }
+
+       /* try all other channels in operating class 81 */
+       for (i = 0; i < 11; i++) {
+               params->freq = 2412 + i * 5;
+
+               /* skip social channels; covered in the previous loop */
+               if (params->freq == 2412 ||
+                   params->freq == 2437 ||
+                   params->freq == 2462)
+                       continue;
+
+               if (wpas_p2p_supported_freq_go(wpa_s, channels, params->freq))
+                       goto out;
+       }
+
        params->freq = 0;
        wpa_printf(MSG_DEBUG, "P2P: No 2.4, 5, or 60 GHz channel allowed");
        return;