From 0776c51ed7cad4ebf0b28ddfd14b451d4cd48a3c Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 4 Nov 2023 11:58:14 +0200 Subject: [PATCH] DPP: Handle wpas_dpp_connected() processing in eloop callback wpas_dpp_connected() is called from wpa_supplicant_set_state(), i.e., from the middle of processing of the post 4-way handshake steps. Sending a DPP Public Action frame at that point can delay other operations, so allow those steps to be completed first before sending out the DPP connection status result. Signed-off-by: Jouni Malinen --- wpa_supplicant/dpp_supplicant.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/wpa_supplicant/dpp_supplicant.c b/wpa_supplicant/dpp_supplicant.c index 627e4bda9..b1a1e0ee0 100644 --- a/wpa_supplicant/dpp_supplicant.c +++ b/wpa_supplicant/dpp_supplicant.c @@ -431,8 +431,9 @@ void wpas_dpp_send_conn_status_result(struct wpa_supplicant *wpa_s, } -void wpas_dpp_connected(struct wpa_supplicant *wpa_s) +static void wpas_dpp_connected_timeout(void *eloop_ctx, void *timeout_ctx) { + struct wpa_supplicant *wpa_s = eloop_ctx; struct dpp_authentication *auth = wpa_s->dpp_auth; if ((auth && auth->conn_status_requested) || @@ -440,6 +441,22 @@ void wpas_dpp_connected(struct wpa_supplicant *wpa_s) wpas_dpp_send_conn_status_result(wpa_s, DPP_STATUS_OK); } + +void wpas_dpp_connected(struct wpa_supplicant *wpa_s) +{ + struct dpp_authentication *auth = wpa_s->dpp_auth; + + if ((auth && auth->conn_status_requested) || + dpp_tcp_conn_status_requested(wpa_s->dpp)) { + /* Report connection result from an eloop timeout to avoid delay + * to completing all connection completion steps since this + * function is called in a middle of the post 4-way handshake + * processing. */ + eloop_register_timeout(0, 0, wpas_dpp_connected_timeout, + wpa_s, NULL); + } +} + #endif /* CONFIG_DPP2 */ @@ -4758,6 +4775,7 @@ void wpas_dpp_deinit(struct wpa_supplicant *wpa_s) eloop_cancel_timeout(wpas_dpp_reconfig_reply_wait_timeout, wpa_s, NULL); eloop_cancel_timeout(wpas_dpp_build_csr, wpa_s, NULL); + eloop_cancel_timeout(wpas_dpp_connected_timeout, wpa_s, NULL); dpp_pfs_free(wpa_s->dpp_pfs); wpa_s->dpp_pfs = NULL; wpas_dpp_chirp_stop(wpa_s);