[PATCH 22/24] P2P: Disallow GO CS immediately after GoN or invitation

Ilan Peer ilan.peer
Mon May 19 00:06:19 PDT 2014


A newly created GO might move to another channel before the
client was able to connect to it. This creates a situation
where the client searches the GO on the channel agreed upon
during GON or invitation signaling, while the GO is on another
channel. This in turn might lead to a connection failure and
group removal.

Fix this by disallowing a GO CS as long as there is some activity
that should delay the switch. If a GO move is not allowed, set
a timeout to re-attempt the move.

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 wpa_supplicant/p2p_supplicant.c |   44 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index 4e597dc..1488d7c 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -94,6 +94,12 @@
 
 #define P2P_MGMT_DEVICE_PREFIX		"p2p0"
 
+/*
+ * How many seconds to wait to re attempt to move GOs, in case previous attempt
+ * was not possible.
+ */
+#define P2P_RECONSIDER_GO_MOVE_DELAY 30
+
 enum p2p_group_removal_reason {
 	P2P_GROUP_REMOVAL_UNKNOWN,
 	P2P_GROUP_REMOVAL_SILENT,
@@ -139,6 +145,7 @@ static void wpas_p2p_optimize_listen_channel(struct wpa_supplicant *wpa_s,
 					     struct wpa_used_freq_data *freqs,
 					     unsigned int num);
 static void wpas_p2p_move_go(void *eloop_ctx, void *timeout_ctx);
+static void wpas_p2p_reconsider_moving_go(void *eloop_ctx, void *timeout_ctx);
 static void wpas_p2p_consider_moving_gos(struct wpa_supplicant *wpa_s,
 					 struct wpa_used_freq_data *freqs,
 					 unsigned int num);
@@ -522,6 +529,7 @@ static int wpas_p2p_group_delete(struct wpa_supplicant *wpa_s,
 
 	wpa_s->p2p_in_invitation = 0;
 	eloop_cancel_timeout(wpas_p2p_move_go, wpa_s, NULL);
+	eloop_cancel_timeout(wpas_p2p_reconsider_moving_go, wpa_s, NULL);
 
 	/*
 	 * Make sure wait for the first client does not remain active after the
@@ -8166,6 +8174,26 @@ static void wpas_p2p_move_go(void *eloop_ctx, void *timeout_ctx)
 		wpas_p2p_move_go_no_csa(wpa_s);
 }
 
+
+static void wpas_p2p_reconsider_moving_go(void *eloop_ctx, void *timeout_ctx)
+{
+	struct wpa_supplicant *wpa_s = eloop_ctx;
+	struct wpa_used_freq_data *freqs = NULL;
+	unsigned int num = wpa_s->num_multichan_concurrent;
+
+	freqs = os_calloc(num, sizeof(struct wpa_used_freq_data));
+	if (!freqs)
+		return;
+
+	num = get_shared_radio_freqs_data(wpa_s, freqs, num);
+
+	/* previous attempt to move a GO was not possible try again. */
+	wpas_p2p_consider_moving_gos(wpa_s, freqs, num);
+
+	os_free(freqs);
+}
+
+
 /*
  * Consider moving a GO from its currently used frequency:
  * 1. It is possible that due to regulatory consideration the frequency
@@ -8226,6 +8254,12 @@ static void wpas_p2p_consider_moving_one_go(struct wpa_supplicant *wpa_s,
 		wpa_dbg(wpa_s, MSG_DEBUG, "Cancel a GO move from freq=%dMHz",
 			freq);
 		eloop_cancel_timeout(wpas_p2p_move_go, wpa_s, NULL);
+
+		if (wpas_p2p_in_progress(wpa_s)) {
+			wpa_dbg(wpa_s, MSG_DEBUG,
+				"Go move: policy CS is not allowed");
+			goto reschedule;
+		}
 	}
 
 	if (invalid_freq == 0 && (policy_move == 0 || flags != 0)) {
@@ -8243,14 +8277,24 @@ static void wpas_p2p_consider_moving_one_go(struct wpa_supplicant *wpa_s,
 		freq, timeout);
 	eloop_register_timeout(timeout, 0, wpas_p2p_move_go, wpa_s, NULL);
 	return;
+
+reschedule:
+	wpa_dbg(wpa_s, MSG_DEBUG, "Setting timeout to re-consider GO move");
+	eloop_register_timeout(P2P_RECONSIDER_GO_MOVE_DELAY, 0,
+			       wpas_p2p_reconsider_moving_go,
+			       wpa_s, NULL);
 }
 
+
 static void wpas_p2p_consider_moving_gos(struct wpa_supplicant *wpa_s,
 					 struct wpa_used_freq_data *freqs,
 					 unsigned int num)
 {
 	struct wpa_supplicant *ifs;
 
+	eloop_cancel_timeout(wpas_p2p_reconsider_moving_go, ELOOP_ALL_CTX,
+			     NULL);
+
 	/*
 	 * Travers all the radio interfaces, and for each GO interface, check
 	 * if there is a need to  move the GO from the frequency it is using,
-- 
1.7.10.4




More information about the Hostap mailing list