]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Set ap_configured_cb during group reform process
authorJimmy Chen <jimmycmchen@google.com>
Wed, 26 Aug 2020 10:55:45 +0000 (18:55 +0800)
committerJouni Malinen <j@w1.fi>
Sun, 11 Oct 2020 17:08:37 +0000 (20:08 +0300)
We found that if REMOVE-AND-REFORM occurs before a group is started,
it would not send out GROUP-STARTED-EVENT after AP is enabled.

In the remove-and-reform process, ap_configured_cb is cleared. If a
group is not started, p2p_go_configured() will not be called after
completing AP setup. Fix this by preserving the callback parameters.

Signed-off-by: Jimmy Chen <jimmycmchen@google.com>
wpa_supplicant/p2p_supplicant.c

index 78798151fc335da15639aab9f548c56479e38579..4c083f865a07f0f0cf20e913a5f27e131a05cbe1 100644 (file)
@@ -9463,6 +9463,8 @@ static void wpas_p2p_move_go_no_csa(struct wpa_supplicant *wpa_s)
 {
        struct p2p_go_neg_results params;
        struct wpa_ssid *current_ssid = wpa_s->current_ssid;
+       void (*ap_configured_cb)(void *ctx, void *data);
+       void *ap_configured_cb_ctx, *ap_configured_cb_data;
 
        wpa_msg_global(wpa_s, MSG_INFO, P2P_EVENT_REMOVE_AND_REFORM_GROUP);
 
@@ -9472,6 +9474,13 @@ static void wpas_p2p_move_go_no_csa(struct wpa_supplicant *wpa_s)
        /* Stop the AP functionality */
        /* TODO: Should do this in a way that does not indicated to possible
         * P2P Clients in the group that the group is terminated. */
+       /* If this action occurs before a group is started, the callback should
+        * be preserved, or GROUP-STARTED event would be lost. If this action
+        * occurs after a group is started, these pointers are all NULL and
+        * harmless. */
+       ap_configured_cb = wpa_s->ap_configured_cb;
+       ap_configured_cb_ctx = wpa_s->ap_configured_cb_ctx;
+       ap_configured_cb_data = wpa_s->ap_configured_cb_data;
        wpa_supplicant_ap_deinit(wpa_s);
 
        /* Reselect the GO frequency */
@@ -9495,6 +9504,11 @@ static void wpas_p2p_move_go_no_csa(struct wpa_supplicant *wpa_s)
                return;
        }
 
+       /* Restore preserved callback parameters */
+       wpa_s->ap_configured_cb = ap_configured_cb;
+       wpa_s->ap_configured_cb_ctx = ap_configured_cb_ctx;
+       wpa_s->ap_configured_cb_data = ap_configured_cb_data;
+
        /* Update the frequency */
        current_ssid->frequency = params.freq;
        wpa_s->connect_without_scan = current_ssid;