From 36b9883d84c9b9af35999fa7edd464b97c7a4e68 Mon Sep 17 00:00:00 2001 From: Deepthi Gowri Date: Fri, 10 May 2013 16:10:50 +0300 Subject: [PATCH] Defer scan if connection is in progress on any of the shared interfaces Scanning can delay concurrent operations considerably, so it is better to avoid that while trying to connect on any of the virtual interfaces that share the same radio. Signed-hostap: Jouni Malinen --- wpa_supplicant/scan.c | 2 +- wpa_supplicant/wpa_supplicant.c | 39 +++++++++++++++++++++++++++++++ wpa_supplicant/wpa_supplicant_i.h | 1 + 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index 682e1be70..16e0bd7cb 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -569,7 +569,7 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx) } #ifdef CONFIG_P2P - if (wpas_p2p_in_progress(wpa_s)) { + if (wpas_p2p_in_progress(wpa_s) || wpas_wpa_is_in_progress(wpa_s)) { if (wpa_s->sta_scan_pending && wpas_p2p_in_progress(wpa_s) == 2 && wpa_s->global->p2p_cb_on_scan_complete) { diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 4b8d0d0f3..c9ad4caf8 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -3843,3 +3843,42 @@ void wpas_request_connection(struct wpa_supplicant *wpa_s) if (wpa_supplicant_fast_associate(wpa_s) != 1) wpa_supplicant_req_scan(wpa_s, 0, 0); } + + +/** + * wpas_wpa_is_in_progress - Check whether a connection is in progress + * @wpa_s: Pointer to wpa_supplicant data + * + * This function is to check if the wpa state is in beginning of the connection + * during 4-way handshake or group key handshake with WPA on any shared + * interface. + */ +int wpas_wpa_is_in_progress(struct wpa_supplicant *wpa_s) +{ + const char *rn, *rn2; + struct wpa_supplicant *ifs; + + if (!wpa_s->driver->get_radio_name) + return 0; + + rn = wpa_s->driver->get_radio_name(wpa_s->drv_priv); + if (rn == NULL || rn[0] == '\0') + return 0; + + for (ifs = wpa_s->global->ifaces; ifs; ifs = ifs->next) { + if (ifs == wpa_s || !ifs->driver->get_radio_name) + continue; + + rn2 = ifs->driver->get_radio_name(ifs->drv_priv); + if (!rn2 || os_strcmp(rn, rn2) != 0) + continue; + if (ifs->wpa_state >= WPA_AUTHENTICATING && + ifs->wpa_state != WPA_COMPLETED) { + wpa_dbg(wpa_s, MSG_DEBUG, "Connection is in progress " + "on interface %s - defer scan", ifs->ifname); + return 1; + } + } + + return 0; +} diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index c53421de8..7559a756e 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -782,6 +782,7 @@ int disallowed_ssid(struct wpa_supplicant *wpa_s, const u8 *ssid, size_t ssid_len); void wpas_request_connection(struct wpa_supplicant *wpa_s); int wpas_build_ext_capab(struct wpa_supplicant *wpa_s, u8 *buf); +int wpas_wpa_is_in_progress(struct wpa_supplicant *wpa_s); /** * wpa_supplicant_ctrl_iface_ctrl_rsp_handle - Handle a control response