P2P: Do not use old scan result data for peer discovery
authorJouni Malinen <jouni@qca.qualcomm.com>
Tue, 12 Feb 2013 17:25:18 +0000 (19:25 +0200)
committerJouni Malinen <j@w1.fi>
Tue, 12 Feb 2013 17:25:18 +0000 (19:25 +0200)
The driver may have cached (e.g., in cfg80211 BSS table) the scan
results for relatively long time. To avoid reporting stale information,
update P2P peers only based on results that have based on frames
received after the last p2p_find operation was started.

This helps especially in detecting when a previously operating GO stops
the group since the BSS entry for that could live for 30 seconds in the
cfg80211 cache. Running p2p_flush followed by p2p_find will now allow
wpa_supplicant to not add a P2P peer entry for that GO if the group had
been terminated just before that p2p_flush command. Previously, that GO
could have been indicated as a newly found device for up to 30 seconds
after it had stopped the group.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

src/p2p/p2p.c
src/p2p/p2p_i.h

index 0bf9927..1b7225e 100644 (file)
@@ -1017,6 +1017,7 @@ int p2p_find(struct p2p_data *p2p, unsigned int timeout,
 
        wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Starting find (type=%d)",
                type);
+       os_get_time(&p2p->find_start);
        if (p2p->p2p_scan_running) {
                wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: p2p_scan is "
                        "already running");
@@ -2816,6 +2817,21 @@ int p2p_scan_res_handler(struct p2p_data *p2p, const u8 *bssid, int freq,
                         struct os_time *rx_time, int level, const u8 *ies,
                         size_t ies_len)
 {
+       if (os_time_before(rx_time, &p2p->find_start)) {
+               /*
+                * The driver may have cached (e.g., in cfg80211 BSS table) the
+                * scan results for relatively long time. To avoid reporting
+                * stale information, update P2P peers only based on results
+                * that have based on frames received after the last p2p_find
+                * operation was started.
+                */
+               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Ignore old scan "
+                       "result for " MACSTR " (rx_time=%u.%06u)",
+                       MAC2STR(bssid), (unsigned int) rx_time->sec,
+                       (unsigned int) rx_time->usec);
+               return 0;
+       }
+
        p2p_add_device(p2p, bssid, freq, rx_time, level, ies, ies_len, 1);
 
        return 0;
index c4838d2..005f73b 100644 (file)
@@ -390,6 +390,8 @@ struct p2p_data {
        u8 *find_dev_id;
        u8 find_dev_id_buf[ETH_ALEN];
 
+       struct os_time find_start; /* time of last p2p_find start */
+
        struct p2p_group **groups;
        size_t num_groups;