[PATCH 51/97] NAN: Remove stale sec entry on NDP termination
Andrei Otcheretianski
andrei.otcheretianski at intel.com
Tue Apr 28 13:05:52 PDT 2026
When an NDP terminates, remove the corresponding sec entry from the
peer's sec list if no other NDP is using the same peer NDI. Without
this fix, stale sec entries cause subsequent NDP setup to use wrong
NDI addresses for NAF transmission.
Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
---
src/nan/nan.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/src/nan/nan.c b/src/nan/nan.c
index 0d9b443eb7..4f69f85c01 100644
--- a/src/nan/nan.c
+++ b/src/nan/nan.c
@@ -123,6 +123,26 @@ static void nan_peer_flush_sec(struct nan_peer_info *info)
}
+static void nan_peer_del_sec_entry(struct nan_peer_info *info, const u8 *peer_ndi)
+{
+ struct nan_peer_sec_info_entry *cur, *next;
+
+ dl_list_for_each_safe(cur, next, &info->sec,
+ struct nan_peer_sec_info_entry, list) {
+ if (!ether_addr_equal(cur->peer_ndi, peer_ndi))
+ continue;
+
+ wpa_printf(MSG_DEBUG,
+ "NAN: Removing sec entry for peer_ndi=" MACSTR
+ " local_ndi=" MACSTR,
+ MAC2STR(peer_ndi), MAC2STR(cur->local_ndi));
+ dl_list_del(&cur->list);
+ os_memset(cur, 0, sizeof(*cur));
+ os_free(cur);
+ }
+}
+
+
static void nan_remove_group_keys(struct nan_data *nan, struct nan_peer *peer)
{
if (peer->igtk_id) {
@@ -1714,6 +1734,10 @@ static void nan_ndp_disconnected(struct nan_data *nan, struct nan_peer *peer,
*/
remove_sta = !nan_peer_ndi_in_use(peer, peer_ndi);
+ /* Remove sec entry if no other NDP is using this peer NDI */
+ if (remove_sta)
+ nan_peer_del_sec_entry(&peer->info, peer_ndi);
+
/*
* NAN_NDP_STATE_NONE means the NDP was not in progress, thus
* the failure flag should be false.
@@ -2304,6 +2328,10 @@ void nan_ndp_terminated(struct nan_data *nan, struct nan_peer *peer,
*/
bool remove_sta = !nan_peer_ndi_in_use(peer, peer_ndi);
+ /* Remove sec entry if no other NDP is using this peer NDI */
+ if (remove_sta)
+ nan_peer_del_sec_entry(&peer->info, peer_ndi);
+
if (nan->cfg->ndp_disconnected)
nan->cfg->ndp_disconnected(nan->cfg->cb_ctx, ndp_id, local_ndi,
peer_ndi, reason, false,
--
2.53.0
More information about the Hostap
mailing list