P2P: Do not use old scan result data for peer discovery

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>
This commit is contained in:
Jouni Malinen 2013-02-12 19:25:18 +02:00 committed by Jouni Malinen
parent c5f10e804a
commit a5b5e830a0
2 changed files with 18 additions and 0 deletions

View 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)", wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Starting find (type=%d)",
type); type);
os_get_time(&p2p->find_start);
if (p2p->p2p_scan_running) { if (p2p->p2p_scan_running) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: p2p_scan is " wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: p2p_scan is "
"already running"); "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, struct os_time *rx_time, int level, const u8 *ies,
size_t ies_len) 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); p2p_add_device(p2p, bssid, freq, rx_time, level, ies, ies_len, 1);
return 0; return 0;

View file

@ -390,6 +390,8 @@ struct p2p_data {
u8 *find_dev_id; u8 *find_dev_id;
u8 find_dev_id_buf[ETH_ALEN]; u8 find_dev_id_buf[ETH_ALEN];
struct os_time find_start; /* time of last p2p_find start */
struct p2p_group **groups; struct p2p_group **groups;
size_t num_groups; size_t num_groups;