]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Run full P2P_FIND scan after pending scan completes
authorJouni Malinen <jouni@qca.qualcomm.com>
Mon, 13 Mar 2017 15:05:55 +0000 (17:05 +0200)
committerJouni Malinen <j@w1.fi>
Tue, 14 Mar 2017 18:41:08 +0000 (20:41 +0200)
If a P2P_FIND command is issued for running the initial full scan and
the attempt to start that full scan fails, the previous behavior was to
wait for the ongoing scan to complete and then continue p2p_find scan
iterations. However, this continued with the social channels scan
instead of the initial full scan. This could end up missing the full
scan completely.

Fix this by marking the full scan pending if the new scan cannot be
started immediately. Then start the initial full scan after the ongoing
scan completes before moving to social channel only scan iterations.
This applies both for the P2P_FIND_START_WITH_FULL (no specific
frequency set) and P2P_FIND_PROGRESSIVE cases since both of them start
with a single full scan round.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/p2p/p2p.c
src/p2p/p2p_i.h

index 047e59a7f9c3b809e828fe68e1650df309a75ba2..1a31ef2c813d620804ebb7090cb92d077bb83320 100644 (file)
@@ -1010,7 +1010,13 @@ static void p2p_search(struct p2p_data *p2p)
        }
        p2p->cfg->stop_listen(p2p->cfg->cb_ctx);
 
-       if ((p2p->find_type == P2P_FIND_PROGRESSIVE &&
+       if (p2p->find_pending_full &&
+           (p2p->find_type == P2P_FIND_PROGRESSIVE ||
+            p2p->find_type == P2P_FIND_START_WITH_FULL)) {
+               type = P2P_SCAN_FULL;
+               p2p_dbg(p2p, "Starting search (pending full scan)");
+               p2p->find_pending_full = 0;
+       } else if ((p2p->find_type == P2P_FIND_PROGRESSIVE &&
            (freq = p2p_get_next_prog_freq(p2p)) > 0) ||
            (p2p->find_type == P2P_FIND_START_WITH_FULL &&
             (freq = p2p->find_specified_freq) > 0)) {
@@ -1236,6 +1242,7 @@ int p2p_find(struct p2p_data *p2p, unsigned int timeout,
                p2p->pending_listen_freq = 0;
        }
        p2p->cfg->stop_listen(p2p->cfg->cb_ctx);
+       p2p->find_pending_full = 0;
        p2p->find_type = type;
        if (freq != 2412 && freq != 2437 && freq != 2462 && freq != 60480)
                p2p->find_specified_freq = freq;
@@ -1285,6 +1292,9 @@ int p2p_find(struct p2p_data *p2p, unsigned int timeout,
        if (res != 0 && p2p->p2p_scan_running) {
                p2p_dbg(p2p, "Failed to start p2p_scan - another p2p_scan was already running");
                /* wait for the previous p2p_scan to complete */
+               if (type == P2P_FIND_PROGRESSIVE ||
+                   (type == P2P_FIND_START_WITH_FULL && freq == 0))
+                       p2p->find_pending_full = 1;
                res = 0; /* do not report failure */
        } else if (res != 0) {
                p2p_dbg(p2p, "Failed to start p2p_scan");
index e995c6d94938284f6989c148e76e33b4c6a20795..6a4d751c090ab3c452129bbcfbc36044052bf8ef 100644 (file)
@@ -441,6 +441,7 @@ struct p2p_data {
        unsigned int last_p2p_find_timeout;
        u8 last_prog_scan_class;
        u8 last_prog_scan_chan;
+       unsigned int find_pending_full:1;
        int p2p_scan_running;
        enum p2p_after_scan {
                P2P_AFTER_SCAN_NOTHING,