From: Deepthi Gowri Date: Fri, 10 May 2013 13:10:50 +0000 (+0300) Subject: Defer scan if connection is in progress on any of the shared interfaces X-Git-Tag: aosp-kk-from-upstream~272 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=mech_eap.git;a=commitdiff_plain;h=36b9883d84c9b9af35999fa7edd464b97c7a4e68 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 --- diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index 682e1be..16e0bd7 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 4b8d0d0..c9ad4ca 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 c53421d..7559a75 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