[PATCH] Limit the retransmission of GO Negotiation request to 120

Fabien Marotte fabienx.marotte at linux.intel.com
Fri Dec 3 05:13:33 EST 2010


If the peer you want to connect to is no longer available (dead) when
wpa_supplicant sends GO Negotition request, retransmission of this
frame is done until the associated p2p_device structure is removed
on timeout. In that case, no signal is emitted to inform the
GO Negotiation has failed.

When sending an Invite request, the same retransmission mechanism is
in place but limit the transmission to 120 and generates a signal.

This patch adds the same mechanism as the one in place for Invite
request.
---
 src/p2p/p2p.c        |   10 ++++++++++
 src/p2p/p2p_go_neg.c |    1 +
 src/p2p/p2p_i.h      |    1 +
 3 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index a088826..636f39a 100644
--- a/src/p2p/p2p.c
+++ b/src/p2p/p2p.c
@@ -958,6 +958,7 @@ int p2p_connect(struct p2p_data *p2p, const u8 *peer_addr,
 	dev->flags &= ~P2P_DEV_USER_REJECTED;
 	dev->flags &= ~P2P_DEV_WAIT_GO_NEG_RESPONSE;
 	dev->flags &= ~P2P_DEV_WAIT_GO_NEG_CONFIRM;
+	dev->connect_reqs = 0;
 	dev->go_neg_req_sent = 0;
 	dev->go_state = UNKNOWN_GO;
 	if (persistent_group)
@@ -2365,6 +2366,15 @@ static void p2p_timeout_connect_listen(struct p2p_data *p2p)
 				"complete");
 			return;
 		}
+
+		if (p2p->go_neg_peer->connect_reqs >= 120) {
+			wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
+				"P2P: Timeout on sending GO Negotiation request"
+				"without getting response");
+			p2p_go_neg_failed(p2p, p2p->go_neg_peer, -1);
+			return;
+		}
+
 		p2p_set_state(p2p, P2P_CONNECT);
 		p2p_connect_send(p2p, p2p->go_neg_peer);
 	} else
diff --git a/src/p2p/p2p_go_neg.c b/src/p2p/p2p_go_neg.c
index 4db0f8b..d5e3f1c 100644
--- a/src/p2p/p2p_go_neg.c
+++ b/src/p2p/p2p_go_neg.c
@@ -209,6 +209,7 @@ int p2p_connect_send(struct p2p_data *p2p, struct p2p_device *dev)
 	p2p->pending_action_state = P2P_PENDING_GO_NEG_REQUEST;
 	p2p->go_neg_peer = dev;
 	dev->flags |= P2P_DEV_WAIT_GO_NEG_RESPONSE;
+	dev->connect_reqs++;
 	if (p2p_send_action(p2p, freq, dev->p2p_device_addr,
 			    p2p->cfg->dev_addr, dev->p2p_device_addr,
 			    wpabuf_head(req), wpabuf_len(req), 200) < 0) {
diff --git a/src/p2p/p2p_i.h b/src/p2p/p2p_i.h
index c31f23a..4dc3c78 100644
--- a/src/p2p/p2p_i.h
+++ b/src/p2p/p2p_i.h
@@ -98,6 +98,7 @@ struct p2p_device {
 
 	int status; /* enum p2p_status_code */
 	unsigned int wait_count;
+	unsigned int connect_reqs;
 	unsigned int invitation_reqs;
 
 	u16 ext_listen_period;
-- 
1.7.0.4



More information about the HostAP mailing list