From 388444e8d6672fca3da6d5834655d3dab3524deb Mon Sep 17 00:00:00 2001 From: Rashmi Ramanna Date: Wed, 14 May 2014 14:35:02 +0530 Subject: [PATCH] P2P: Modify the timeout for GO Negotiation on no concurrent session Peer should handle a GO Negotiation exchange correctly when the responding device does not have WSC credentials available at the time of receiving the GO Negotiation Request. WSC Credentials (e.g., Pushbutton) can be entered within the 120 second timeout. Presently, if concurrent session is not active, the peer would wait for GO Negotiation Request frame from the other device for approximately one minute due to the earlier optimization change in commit a2d63657603b8f0714274f34bea45cb5d0c0a7b9. To meet the two minute requirement, replace this design based on number of iterations with a more appropriate wait for the required number of seconds. Signed-off-by: Jouni Malinen --- src/p2p/p2p.c | 7 +++---- src/p2p/p2p_go_neg.c | 2 +- src/p2p/p2p_i.h | 1 + 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index 442e47357..c2f8d9b10 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -3238,14 +3238,15 @@ static void p2p_timeout_wait_peer_connect(struct p2p_data *p2p) static void p2p_timeout_wait_peer_idle(struct p2p_data *p2p) { struct p2p_device *dev = p2p->go_neg_peer; + struct os_reltime now; if (dev == NULL) { p2p_dbg(p2p, "Unknown GO Neg peer - stop GO Neg wait"); return; } - dev->wait_count++; - if (dev->wait_count >= 120) { + os_get_reltime(&now); + if (os_reltime_expired(&now, &dev->go_neg_wait_started, 120)) { p2p_dbg(p2p, "Timeout on waiting peer to become ready for GO Negotiation"); p2p_go_neg_failed(p2p, dev, -1); return; @@ -3534,7 +3535,6 @@ int p2p_get_peer_info_txt(const struct p2p_peer_info *info, "req_config_methods=0x%x\n" "flags=%s%s%s%s%s%s%s%s%s%s%s%s%s\n" "status=%d\n" - "wait_count=%u\n" "invitation_reqs=%u\n", (int) (now.sec - dev->last_seen.sec), dev->listen_freq, @@ -3576,7 +3576,6 @@ int p2p_get_peer_info_txt(const struct p2p_peer_info *info, dev->flags & P2P_DEV_PD_FOR_JOIN ? "[PD_FOR_JOIN]" : "", dev->status, - dev->wait_count, dev->invitation_reqs); if (res < 0 || res >= end - pos) return pos - buf; diff --git a/src/p2p/p2p_go_neg.c b/src/p2p/p2p_go_neg.c index ac9390263..f24fe2365 100644 --- a/src/p2p/p2p_go_neg.c +++ b/src/p2p/p2p_go_neg.c @@ -939,7 +939,7 @@ void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa, if (*msg.status == P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE) { p2p_dbg(p2p, "Wait for the peer to become ready for GO Negotiation"); dev->flags |= P2P_DEV_NOT_YET_READY; - dev->wait_count = 0; + os_get_reltime(&dev->go_neg_wait_started); p2p_set_state(p2p, P2P_WAIT_PEER_IDLE); p2p_set_timeout(p2p, 0, 0); } else { diff --git a/src/p2p/p2p_i.h b/src/p2p/p2p_i.h index 44b66c4a1..65ff9ef41 100644 --- a/src/p2p/p2p_i.h +++ b/src/p2p/p2p_i.h @@ -101,6 +101,7 @@ struct p2p_device { unsigned int flags; int status; /* enum p2p_status_code */ + struct os_reltime go_neg_wait_started; unsigned int wait_count; unsigned int connect_reqs; unsigned int invitation_reqs;