From f05cee9714ae87d315d893699a536b60a5aa73a9 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 7 Apr 2014 12:26:04 +0300 Subject: [PATCH] P2P: Clear p2p_in_invitation on cancel Commit 41d5ce9e0b7b37dd84fbf3c1aa5ed571c32321d4 added scan optimizations for P2P invitation cases. However, it left a path where the invitation state was not cleared and as such, introduced potential issues for following scans that ended up getting incorrectly optimized for a single channel regardless of parameters. Fix this by clearing p2p_in_invitation more carefully, especially on p2p_cancel command. p2p_cancel is now also run from the FLUSH command to avoid issues with hwsim test cases (e.g., persistent_group_per_sta_psk followed by ap_open_tdls resulted in an error due to p2p_in_invitation remaining set after FLUSH). Signed-off-by: Jouni Malinen --- wpa_supplicant/ctrl_iface.c | 1 + wpa_supplicant/p2p_supplicant.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 0f6015217..f50154e14 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -5569,6 +5569,7 @@ static void wpa_supplicant_ctrl_iface_flush(struct wpa_supplicant *wpa_s) wpa_dbg(wpa_s, MSG_DEBUG, "Flush all wpa_supplicant state"); #ifdef CONFIG_P2P + wpas_p2p_cancel(wpa_s); wpas_p2p_stop_find(wpa_s); p2p_ctrl_flush(wpa_s); wpas_p2p_group_remove(wpa_s, "*"); diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 303b7febe..49b2cd28a 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -823,6 +823,7 @@ static void wpas_group_formation_completed(struct wpa_supplicant *wpa_s, wpa_s->global->p2p_group_formation = NULL; wpa_s->p2p_in_provisioning = 0; } + wpa_s->p2p_in_invitation = 0; if (!success) { wpa_msg_global(wpa_s->parent, MSG_INFO, @@ -6480,6 +6481,11 @@ int wpas_p2p_cancel(struct wpa_supplicant *wpa_s) wpas_p2p_group_delete(wpa_s, P2P_GROUP_REMOVAL_REQUESTED); break; + } else if (wpa_s->p2p_in_invitation) { + wpa_printf(MSG_DEBUG, "P2P: Interface %s in invitation found - cancelling", + wpa_s->ifname); + found = 1; + wpas_p2p_group_formation_failed(wpa_s); } } @@ -6669,6 +6675,7 @@ void wpas_p2p_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s, wpa_s->p2p_go_group_formation_completed = 1; wpa_s->global->p2p_group_formation = NULL; wpa_s->p2p_in_provisioning = 0; + wpa_s->p2p_in_invitation = 0; } wpa_s->global->p2p_go_wait_client.sec = 0; if (addr == NULL)