P2P: Clear p2p_in_invitation on cancel
authorJouni Malinen <jouni@qca.qualcomm.com>
Mon, 7 Apr 2014 09:26:04 +0000 (12:26 +0300)
committerJouni Malinen <j@w1.fi>
Mon, 7 Apr 2014 10:40:58 +0000 (13:40 +0300)
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 <jouni@qca.qualcomm.com>
wpa_supplicant/ctrl_iface.c
wpa_supplicant/p2p_supplicant.c

index 0f60152..f50154e 100644 (file)
@@ -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, "*");
index 303b7fe..49b2cd2 100644 (file)
@@ -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)