From 3887878e536525ec7ffb8ab4c8110d01bea13308 Mon Sep 17 00:00:00 2001 From: Sunil Dutt Date: Tue, 5 Feb 2013 13:27:56 +0200 Subject: [PATCH] TDLS: Remove link, if any, on an implicit set up request If an implicit TDLS set up request is obtained on an existing link or an to be established link, the previous link was not removed. This commit disables the existing link on a new set up request. Also, wpa_tdls_reneg() function was invoking wpa_tdls_start() on an already existing peer for the case of internal setup, which is incorrect. Thus the invocation of wpa_tdls_start() is removed in wpa_tdls_reneg() and also this function is renamed to wps_tdls_remove() as it does not renegotiation rather shall remove the link (if any) for the case of external setup. Signed-hostap: Jouni Malinen --- src/rsn_supp/tdls.c | 8 +++----- src/rsn_supp/wpa.h | 2 +- wpa_supplicant/ctrl_iface.c | 13 ++++++------- wpa_supplicant/events.c | 6 +++++- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/rsn_supp/tdls.c b/src/rsn_supp/tdls.c index cc84e781a..4373801ba 100644 --- a/src/rsn_supp/tdls.c +++ b/src/rsn_supp/tdls.c @@ -2071,12 +2071,12 @@ int wpa_tdls_start(struct wpa_sm *sm, const u8 *addr) } -int wpa_tdls_reneg(struct wpa_sm *sm, const u8 *addr) +void wpa_tdls_remove(struct wpa_sm *sm, const u8 *addr) { struct wpa_tdls_peer *peer; if (sm->tdls_disabled || !sm->tdls_supported) - return -1; + return; for (peer = sm->tdls; peer; peer = peer->next) { if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) @@ -2084,7 +2084,7 @@ int wpa_tdls_reneg(struct wpa_sm *sm, const u8 *addr) } if (peer == NULL || !peer->tpk_success) - return -1; + return; if (sm->tdls_external_setup) { /* @@ -2093,8 +2093,6 @@ int wpa_tdls_reneg(struct wpa_sm *sm, const u8 *addr) */ wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr); } - - return wpa_tdls_start(sm, addr); } diff --git a/src/rsn_supp/wpa.h b/src/rsn_supp/wpa.h index 791974c2b..2c989b72f 100644 --- a/src/rsn_supp/wpa.h +++ b/src/rsn_supp/wpa.h @@ -355,7 +355,7 @@ wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies, size_t ies_len, void wpa_tdls_ap_ies(struct wpa_sm *sm, const u8 *ies, size_t len); void wpa_tdls_assoc_resp_ies(struct wpa_sm *sm, const u8 *ies, size_t len); int wpa_tdls_start(struct wpa_sm *sm, const u8 *addr); -int wpa_tdls_reneg(struct wpa_sm *sm, const u8 *addr); +void wpa_tdls_remove(struct wpa_sm *sm, const u8 *addr); int wpa_tdls_send_teardown(struct wpa_sm *sm, const u8 *addr, u16 reason_code); int wpa_tdls_teardown_link(struct wpa_sm *sm, const u8 *addr, u16 reason_code); int wpa_tdls_send_discovery_request(struct wpa_sm *sm, const u8 *addr); diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index a5db76858..2f2676c1a 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -554,13 +554,12 @@ static int wpa_supplicant_ctrl_iface_tdls_setup( wpa_printf(MSG_DEBUG, "CTRL_IFACE TDLS_SETUP " MACSTR, MAC2STR(peer)); - ret = wpa_tdls_reneg(wpa_s->wpa, peer); - if (ret) { - if (wpa_tdls_is_external_setup(wpa_s->wpa)) - ret = wpa_tdls_start(wpa_s->wpa, peer); - else - ret = wpa_drv_tdls_oper(wpa_s, TDLS_SETUP, peer); - } + wpa_tdls_remove(wpa_s->wpa, peer); + + if (wpa_tdls_is_external_setup(wpa_s->wpa)) + ret = wpa_tdls_start(wpa_s->wpa, peer); + else + ret = wpa_drv_tdls_oper(wpa_s, TDLS_SETUP, peer); return ret; } diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 13b54c2db..3196352bd 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -2157,7 +2157,11 @@ static void wpa_supplicant_event_tdls(struct wpa_supplicant *wpa_s, return; switch (data->tdls.oper) { case TDLS_REQUEST_SETUP: - wpa_tdls_start(wpa_s->wpa, data->tdls.peer); + wpa_tdls_remove(wpa_s->wpa, data->tdls.peer); + if (wpa_tdls_is_external_setup(wpa_s->wpa)) + wpa_tdls_start(wpa_s->wpa, data->tdls.peer); + else + wpa_drv_tdls_oper(wpa_s, TDLS_SETUP, data->tdls.peer); break; case TDLS_REQUEST_TEARDOWN: wpa_tdls_teardown_link(wpa_s->wpa, data->tdls.peer,