diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index 0bf99275c..1b7225efb 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -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; diff --git a/src/p2p/p2p_i.h b/src/p2p/p2p_i.h index c4838d255..005f73b08 100644 --- a/src/p2p/p2p_i.h +++ b/src/p2p/p2p_i.h @@ -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;