aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <jouni@qca.qualcomm.com>2014-10-23 21:49:42 +0300
committerLinux Build Service Account <lnxbuild@localhost>2014-11-04 08:24:47 -0700
commitabe94ec8400dd6db8a979473c6290c0423883d7c (patch)
treeb8c003bf903368ef0b68d72280799b7b94a2f9ef
parent1d30dac41b90317225c75500b45fae6f7cf39a6f (diff)
downloadandroid_external_wpa_supplicant_8-abe94ec8400dd6db8a979473c6290c0423883d7c.tar.gz
android_external_wpa_supplicant_8-abe94ec8400dd6db8a979473c6290c0423883d7c.tar.bz2
android_external_wpa_supplicant_8-abe94ec8400dd6db8a979473c6290c0423883d7c.zip
P2P: Limit number of SD retries during find
Commit 7139cf4a4f1fecfd03d0daff9bb33adb80cc3530 ('P2P: Decrement sd_pending_bcast_queries when sd returns success') added support for retrying P2P SD queries. However, it did this without limiting how many retries are allowed. This can result in excessive number of retries if a peer device does not show up on its Listen channel and there is a pending SD query to it. Limit the maximum number of SD retries to 100 per p2p_find operation for each peer to avoid unlimited retries. CRs-fixed: 746126 Git-commit: 44abecbf0256c78f33bd0e87a7ce264ebbc70cf8 Git-repo : git://w1.fi/srv/git/hostap.git Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com> Change-Id: Id3abd323ea1214d0c5377f9c5875d900af741fbb
-rw-r--r--src/p2p/p2p.c4
-rw-r--r--src/p2p/p2p_i.h1
-rw-r--r--src/p2p/p2p_sd.c14
3 files changed, 16 insertions, 3 deletions
diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index e3d39e0a..41ccc470 100644
--- a/src/p2p/p2p.c
+++ b/src/p2p/p2p.c
@@ -347,8 +347,10 @@ int p2p_listen(struct p2p_data *p2p, unsigned int timeout)
static void p2p_device_clear_reported(struct p2p_data *p2p)
{
struct p2p_device *dev;
- dl_list_for_each(dev, &p2p->devices, struct p2p_device, list)
+ dl_list_for_each(dev, &p2p->devices, struct p2p_device, list) {
dev->flags &= ~P2P_DEV_REPORTED;
+ dev->sd_reqs = 0;
+ }
}
diff --git a/src/p2p/p2p_i.h b/src/p2p/p2p_i.h
index 75ae8dcd..bb8952d1 100644
--- a/src/p2p/p2p_i.h
+++ b/src/p2p/p2p_i.h
@@ -105,6 +105,7 @@ struct p2p_device {
unsigned int wait_count;
unsigned int connect_reqs;
unsigned int invitation_reqs;
+ unsigned int sd_reqs;
u16 ext_listen_period;
u16 ext_listen_interval;
diff --git a/src/p2p/p2p_sd.c b/src/p2p/p2p_sd.c
index 13119c20..1a2af04b 100644
--- a/src/p2p/p2p_sd.c
+++ b/src/p2p/p2p_sd.c
@@ -75,16 +75,25 @@ struct p2p_sd_query * p2p_pending_sd_req(struct p2p_data *p2p,
return NULL;
/* query number that needs to be send to the device */
if (count == dev->sd_pending_bcast_queries - 1)
- return q;
+ goto found;
count++;
}
if (!q->for_all_peers &&
os_memcmp(q->peer, dev->info.p2p_device_addr, ETH_ALEN) ==
0)
- return q;
+ goto found;
}
return NULL;
+
+found:
+ if (dev->sd_reqs > 100) {
+ p2p_dbg(p2p, "Too many SD request attempts to " MACSTR
+ " - skip remaining queries",
+ MAC2STR(dev->info.p2p_device_addr));
+ return NULL;
+ }
+ return q;
}
@@ -287,6 +296,7 @@ int p2p_start_sd(struct p2p_data *p2p, struct p2p_device *dev)
if (req == NULL)
return -1;
+ dev->sd_reqs++;
p2p->sd_peer = dev;
p2p->sd_query = query;
p2p->pending_action_state = P2P_PENDING_SD;