]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add support to abort vendor scan
authorSunil Dutt <usdutt@qti.qualcomm.com>
Wed, 30 Nov 2016 04:39:38 +0000 (10:09 +0530)
committerJouni Malinen <j@w1.fi>
Wed, 30 Nov 2016 17:33:43 +0000 (19:33 +0200)
This commit enhances the existing implementation of abort scan to also
abort concurrent active vendor scans. This is achieved by passing the
the scan_cookie to the driver interface with the intention to abort
the specific scan request. This scan_cookie is returned from the driver
interface when the scan request is scheduled.

This scan_cookie is 0 if the scan is triggered through the upstream
cfg80211 interface. Thus, the scan_cookie is used to determine whether
to abort the cfg80211 or vendor scan request.

Also, the previous implementation of relying on scan_work/p2p_scan_work
for the active work to trigger the abort scan is enhanced to check for
the started state of either of these work operations. This should also
help to abort the concurrent active scan/p2p-scan operations.

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

index 25e7419b1593783c498242bc429ba2a46dcc8712..2da92bf460e29cadfc48b019ec03f40743179d2f 100644 (file)
@@ -308,6 +308,8 @@ static void wpas_p2p_trigger_scan_cb(struct wpa_radio_work *work, int deinit)
        }
 
        ret = wpa_drv_scan(wpa_s, params);
+       if (ret == 0)
+               wpa_s->curr_scan_cookie = params->scan_cookie;
        wpa_scan_free_params(params);
        work->ctx = NULL;
        if (ret) {
index 8d0986cb75246b6610cc8e0a16e4063a3bf6b00f..dafd8b500197fcc13d2a4bba42d72b857dfee500 100644 (file)
@@ -176,6 +176,17 @@ static void wpas_trigger_scan_cb(struct wpa_radio_work *work, int deinit)
                params->only_new_results = 1;
        }
        ret = wpa_drv_scan(wpa_s, params);
+       /*
+        * Store the obtained vendor scan cookie (if any) in wpa_s context.
+        * The current design is to allow only one scan request on each
+        * interface, hence having this scan cookie stored in wpa_s context is
+        * fine for now.
+        *
+        * Revisit this logic if concurrent scan operations per interface
+        * is supported.
+        */
+       if (ret == 0)
+               wpa_s->curr_scan_cookie = params->scan_cookie;
        wpa_scan_free_params(params);
        work->ctx = NULL;
        if (ret) {
@@ -2625,18 +2636,20 @@ int wpas_mac_addr_rand_scan_set(struct wpa_supplicant *wpa_s,
 
 int wpas_abort_ongoing_scan(struct wpa_supplicant *wpa_s)
 {
-       int scan_work = !!wpa_s->scan_work;
+       struct wpa_radio_work *work;
+       struct wpa_radio *radio = wpa_s->radio;
 
-#ifdef CONFIG_P2P
-       scan_work |= !!wpa_s->p2p_scan_work;
-#endif /* CONFIG_P2P */
-
-       if (scan_work && wpa_s->own_scan_running) {
+       dl_list_for_each(work, &radio->work, struct wpa_radio_work, list) {
+               if (work->wpa_s != wpa_s || !work->started ||
+                   (os_strcmp(work->type, "scan") != 0 &&
+                    os_strcmp(work->type, "p2p-scan") != 0))
+                       continue;
                wpa_dbg(wpa_s, MSG_DEBUG, "Abort an ongoing scan");
-               return wpa_drv_abort_scan(wpa_s, 0);
+               return wpa_drv_abort_scan(wpa_s, wpa_s->curr_scan_cookie);
        }
 
-       return 0;
+       wpa_dbg(wpa_s, MSG_DEBUG, "No ongoing scan/p2p-scan found to abort");
+       return -1;
 }
 
 
index 6853609fe7128815dc53e602d971006756e7d5b9..ec6917a7d32f165fdbe8d8b5354bcb750f6a955a 100644 (file)
@@ -652,6 +652,12 @@ struct wpa_supplicant {
        int normal_scans; /* normal scans run before sched_scan */
        int scan_for_connection; /* whether the scan request was triggered for
                                  * finding a connection */
+       /*
+        * A unique cookie representing the vendor scan request. This cookie is
+        * returned from the driver interface. 0 indicates that there is no
+        * pending vendor scan request.
+        */
+       u64 curr_scan_cookie;
 #define MAX_SCAN_ID 16
        int scan_id[MAX_SCAN_ID];
        unsigned int scan_id_count;