From: Sunil Dutt Date: Tue, 5 Feb 2013 11:10:34 +0000 (+0200) Subject: TDLS: Use existing peer entry if available when processing discovery X-Git-Tag: aosp-kk-from-upstream~601 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd22fbf85cef7af73a6f5e0e12dceb9e54e24063;p=thirdparty%2Fhostap.git TDLS: Use existing peer entry if available when processing discovery Peer entries were getting added on every discover request from the peer, thus resulting in multiple entries with the same MAC address. Ensures that a check is done for the presence of the peer entry and reuse the existing entry instead of adding a new one. Signed-hostap: Jouni Malinen --- diff --git a/src/rsn_supp/tdls.c b/src/rsn_supp/tdls.c index c38fadaff..8c7b7b0c8 100644 --- a/src/rsn_supp/tdls.c +++ b/src/rsn_supp/tdls.c @@ -1281,10 +1281,17 @@ wpa_tdls_process_discovery_request(struct wpa_sm *sm, const u8 *addr, " BSS " MACSTR, MAC2STR(lnkid->bssid)); return -1; } - - peer = wpa_tdls_add_peer(sm, addr); - if (peer == NULL) - return -1; + /* Find existing entry and if found, use that instead of adding + * a new one */ + for (peer = sm->tdls; peer; peer = peer->next) { + if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) + break; + } + if (peer == NULL) { + peer = wpa_tdls_add_peer(sm, addr); + if (peer == NULL) + return -1; + } return wpa_tdls_send_discovery_response(sm, peer, dialog_token); }