From patchwork Mon Jul 7 11:21:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peer, Ilan" X-Patchwork-Id: 367524 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 00AF4140097 for ; Mon, 7 Jul 2014 22:23:09 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 988789D1FC; Mon, 7 Jul 2014 08:23:01 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9t0TS0Lg7PTK; Mon, 7 Jul 2014 08:23:01 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 2C7AE9D257; Mon, 7 Jul 2014 08:20:19 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 842359C1FB for ; Mon, 7 Jul 2014 08:20:15 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DRT43hxPPL9c for ; Mon, 7 Jul 2014 08:20:07 -0400 (EDT) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 2E0089D0C4 for ; Mon, 7 Jul 2014 08:17:53 -0400 (EDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 07 Jul 2014 05:12:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,617,1400050800"; d="scan'208";a="539687273" Received: from unknown (HELO ipeer-e6430-1.jer.intel.com) ([10.12.217.176]) by orsmga001.jf.intel.com with ESMTP; 07 Jul 2014 05:17:23 -0700 From: Ilan Peer To: hostap@lists.shmoo.com Subject: [PATCH 21/23] P2P: Disallow GO CS immediately after GoN or invitation Date: Mon, 7 Jul 2014 14:21:14 +0300 Message-Id: <1404732076-32252-22-git-send-email-ilan.peer@intel.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1404732076-32252-1-git-send-email-ilan.peer@intel.com> References: <1404732076-32252-1-git-send-email-ilan.peer@intel.com> X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com 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. Change-Id: Iaac924e1b2573e7b66693b163d0ed9fcabe944b9 Signed-off-by: Ilan Peer --- wpa_supplicant/p2p_supplicant.c | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index ece5f34..c043950 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -90,6 +90,12 @@ #define P2P_MGMT_DEVICE_PREFIX "p2p-dev-" +/* + * 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, @@ -134,6 +140,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); @@ -518,6 +525,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 @@ -8213,6 +8221,25 @@ 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) +{ + 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 @@ -8273,6 +8300,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)) { @@ -8290,6 +8323,12 @@ 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); } @@ -8299,6 +8338,9 @@ static void wpas_p2p_consider_moving_gos(struct wpa_supplicant *wpa_s, { 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,