From 7b75c30109e4e15a5bdb3e46eba8521999c683a6 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 29 Nov 2013 16:52:44 +0200 Subject: [PATCH] WPS: Reschedule AP configuration reload on EAP completion Reduce race condition of the station trying to reconnect immediately after AP reconfiguration through WPS by rescheduling the reload timeout to happen after EAP completion rather than the originally scheduled 100 ms after new configuration became known. Signed-hostap: Jouni Malinen --- src/ap/ieee802_1x.c | 2 ++ src/ap/wps_hostapd.c | 13 +++++++++++++ src/ap/wps_hostapd.h | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/src/ap/ieee802_1x.c b/src/ap/ieee802_1x.c index 2ce2ed994..98bd104ce 100644 --- a/src/ap/ieee802_1x.c +++ b/src/ap/ieee802_1x.c @@ -29,6 +29,7 @@ #include "pmksa_cache_auth.h" #include "ap_config.h" #include "ap_drv_ops.h" +#include "wps_hostapd.h" #include "ieee802_1x.h" @@ -2128,5 +2129,6 @@ static void ieee802_1x_finished(struct hostapd_data *hapd, os_sleep(0, 10000); ap_sta_disconnect(hapd, sta, sta->addr, WLAN_REASON_IEEE_802_1X_AUTH_FAILED); + hostapd_wps_eap_completed(hapd); } } diff --git a/src/ap/wps_hostapd.c b/src/ap/wps_hostapd.c index 294a39d6f..dd97b1240 100644 --- a/src/ap/wps_hostapd.c +++ b/src/ap/wps_hostapd.c @@ -287,6 +287,19 @@ static void wps_reload_config(void *eloop_data, void *user_ctx) } +void hostapd_wps_eap_completed(struct hostapd_data *hapd) +{ + /* + * Reduce race condition of the station trying to reconnect immediately + * after AP reconfiguration through WPS by rescheduling the reload + * timeout to happen after EAP completion rather than the originally + * scheduled 100 ms after new configuration became known. + */ + if (eloop_deplete_timeout(0, 0, wps_reload_config, hapd->iface, NULL)) + wpa_printf(MSG_DEBUG, "WPS: Reschedule immediate configuration reload"); +} + + static void hapd_new_ap_event(struct hostapd_data *hapd, const u8 *attr, size_t attr_len) { diff --git a/src/ap/wps_hostapd.h b/src/ap/wps_hostapd.h index a2c2cf021..a292598be 100644 --- a/src/ap/wps_hostapd.h +++ b/src/ap/wps_hostapd.h @@ -16,6 +16,7 @@ int hostapd_init_wps(struct hostapd_data *hapd, int hostapd_init_wps_complete(struct hostapd_data *hapd); void hostapd_deinit_wps(struct hostapd_data *hapd); void hostapd_update_wps(struct hostapd_data *hapd); +void hostapd_wps_eap_completed(struct hostapd_data *hapd); int hostapd_wps_add_pin(struct hostapd_data *hapd, const u8 *addr, const char *uuid, const char *pin, int timeout); int hostapd_wps_button_pushed(struct hostapd_data *hapd, @@ -61,6 +62,10 @@ static inline void hostapd_update_wps(struct hostapd_data *hapd) { } +static inline void hostapd_wps_eap_completed(struct hostapd_data *hapd) +{ +} + static inline int hostapd_wps_get_mib_sta(struct hostapd_data *hapd, const u8 *addr, char *buf, size_t buflen)