P2P: Do not request station mode scans during P2P operations
authorJouni Malinen <jouni@qca.qualcomm.com>
Thu, 29 Sep 2011 13:53:55 +0000 (16:53 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 29 Sep 2011 13:53:55 +0000 (16:53 +0300)
The P2P search mechanism depends on the same scan functionality that
is used for station mode scans. If these operations are being used
at the same time, scan result processing is not handled properly.
Avoid unexpected behavior by delaying station mode scan requests
if a P2P operation is in progress.

Among other things, this allows the station mode connection attempt
to be continued after a P2P find or group formation has been completed
if the interface is available (i.e., when the P2P group uses a
separate virtual interface).

src/p2p/p2p.c
src/p2p/p2p.h
wpa_supplicant/p2p_supplicant.c
wpa_supplicant/p2p_supplicant.h
wpa_supplicant/scan.c

index c0c59a6..62926b5 100644 (file)
@@ -3681,3 +3681,11 @@ p2p_get_peer_found(struct p2p_data *p2p, const u8 *addr, int next)
 
        return &dev->info;
 }
+
+
+int p2p_in_progress(struct p2p_data *p2p)
+{
+       if (p2p == NULL)
+               return 0;
+       return p2p->state != P2P_IDLE;
+}
index d01f574..4cab3da 100644 (file)
@@ -1509,4 +1509,11 @@ int p2p_add_wps_vendor_extension(struct p2p_data *p2p,
 int p2p_set_oper_channel(struct p2p_data *p2p, u8 op_reg_class, u8 op_channel,
                         int cfg_op_channel);
 
+/**
+ * p2p_in_progress - Check whether a P2P operation is progress
+ * @p2p: P2P module context from p2p_init()
+ * Returns: 0 if P2P module is idle or 1 if an operation is in progress
+ */
+int p2p_in_progress(struct p2p_data *p2p);
+
 #endif /* P2P_H */
index 9894bfe..f1912f3 100644 (file)
@@ -4365,3 +4365,12 @@ int wpas_p2p_disconnect(struct wpa_supplicant *wpa_s)
 
        return 0;
 }
+
+
+int wpas_p2p_in_progress(struct wpa_supplicant *wpa_s)
+{
+       if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
+               return 0;
+
+       return p2p_in_progress(wpa_s->global->p2p);
+}
index ad74217..9a13f9f 100644 (file)
@@ -127,5 +127,6 @@ int wpas_p2p_unauthorize(struct wpa_supplicant *wpa_s, const char *addr);
 int wpas_p2p_disconnect(struct wpa_supplicant *wpa_s);
 void wpas_p2p_wps_failed(struct wpa_supplicant *wpa_s,
                         struct wps_event_fail *fail);
+int wpas_p2p_in_progress(struct wpa_supplicant *wpa_s);
 
 #endif /* P2P_SUPPLICANT_H */
index 7689ff6..5be661a 100644 (file)
@@ -284,6 +284,20 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
                return;
        }
 
+#ifdef CONFIG_P2P
+       if (wpas_p2p_in_progress(wpa_s)) {
+               if (wpa_s->wpa_state == WPA_SCANNING) {
+                       wpa_dbg(wpa_s, MSG_DEBUG, "Delay station mode scan "
+                               "while P2P operation is in progress");
+                       wpa_supplicant_req_scan(wpa_s, 5, 0);
+               } else {
+                       wpa_dbg(wpa_s, MSG_DEBUG, "Do not request scan while "
+                               "P2P operation is in progress");
+               }
+               return;
+       }
+#endif /* CONFIG_P2P */
+
        if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME) ||
            wpa_s->conf->ap_scan == 2)
                max_ssids = 1;