From patchwork Wed May 13 06:59:05 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Otcheretianski X-Patchwork-Id: 2237505 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=EB+5algA; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=YdFKtr31; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4gFkrp2L7Cz1yJ5 for ; Wed, 13 May 2026 17:01:12 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=nhiZslhOS9wJKxblytQzHplgIYAYkYiwpFhBgIwTywc=; b=EB+5algArfsUn0 5JWe9apPr7QJcSYI1rQSnkRRebd5XJYHe41I7b64LTP2let0MTjd0cwPxqvxkasIP6aEa1tpNDQlC Gh1LSQdBVYj5VJVoS0ClBgtB/mZKI+rGMXX8U9KAEzpMOKz3G4uZ6RgWzvuSoFz/VXECLXhpg8RwS awjwOUIthcysMpqcVdBQ6pLaYFKou7FzZmRFn74x7QfFj52VA89q8h9OuSPGx7AXYGH3M5W1IlgWf uZIJ/9r+GU1biN5K2++zYqrjyPoC/+NsY/7iFP9196mvNPGsOaIJ5feT1Is2BsH2S94I01VMbb4+H Q18IdKQ4O2fpf/TpzP3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wN3ZB-00000001Ucj-1FIs; Wed, 13 May 2026 06:59:37 +0000 Received: from mgamail.intel.com ([198.175.65.10]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wN3Z8-00000001UZY-2Adq for hostap@lists.infradead.org; Wed, 13 May 2026 06:59:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1778655575; x=1810191575; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=OJ32asj88RoK8yb4/5HgaIK5a+dD9KHCes7pA72Wbkg=; b=YdFKtr31gOoIRh9ZiH+5eUb+LbNFj9plGi0h4m8ZvnYlmR25nO7Xzt6T fkJP/jKhagsDyTi7TIJqzebPcBvXotuQICWcIa0rv/d9JpvE4tvTB+OiP jrYaHoV59j82YT5D+LK7KPHHPy7mQLxQ6TwDZWUMOl73UG+FrAC/7RuwV noGqNBY8+6cpLAnZg9ZpZgqtrJrmc1rmUMnbMNk3IF2dFUwWjfmfp6aHt 7gUGHwObFor2GYsWbLwCpYGHVOjRxCQ/V6aM82K8YmSrRPHjEfRb/Nmlq b83iXA1zlRJm7VgKV7Mt6l1gxMG0yO9Wsm6klWJOhgVGOtM/YZw6q71ce g==; X-CSE-ConnectionGUID: abBkL0n5TMenPNO6uu4WbQ== X-CSE-MsgGUID: yRk/ws+5S4CGCJLukkS39w== X-IronPort-AV: E=McAfee;i="6800,10657,11784"; a="97001315" X-IronPort-AV: E=Sophos;i="6.23,232,1770624000"; d="scan'208";a="97001315" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2026 23:59:35 -0700 X-CSE-ConnectionGUID: Ar701G3LTOyjqBtm9tUiow== X-CSE-MsgGUID: 13aNqoa/RNKaY3J/DCNNpw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,232,1770624000"; d="scan'208";a="233721923" Received: from iapp347.iil.intel.com (HELO 87c02287900a.iil.intel.com) ([10.167.28.6]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2026 23:59:32 -0700 From: Andrei Otcheretianski To: hostap@lists.infradead.org Cc: maheshkkv@google.com, vamsin@qti.qualcomm.com, Ilan Peer Subject: [PATCH 3/5] NAN: Handle removal of NAN interfaces Date: Wed, 13 May 2026 09:59:05 +0300 Message-ID: <20260513065909.12048-7-andrei.otcheretianski@intel.com> X-Mailer: git-send-email 2.53.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260512_235934_598001_CAF0FFB9 X-CRM114-Status: GOOD ( 14.82 ) X-Spam-Score: -4.8 (----) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Ilan Peer When the driver notifies that a NAN Data interface is removed, terminate all the NDPs which are associated with the interface. If the interface was dynamically added by upper layers, remove it. Content analysis details: (-4.8 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [198.175.65.10 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.4 DKIMWL_WL_HIGH DKIMwl.org - High trust sender -0.0 DMARC_PASS DMARC pass policy X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Ilan Peer When the driver notifies that a NAN Data interface is removed, terminate all the NDPs which are associated with the interface. If the interface was dynamically added by upper layers, remove it. If a NAN management interface that was dynamically added is removed, remove it (NAN functionality is stopped when the interface is disabled). Signed-off-by: Ilan Peer --- src/nan/nan.c | 28 ++++++++++++++++++++++++++++ src/nan/nan.h | 2 ++ wpa_supplicant/events.c | 24 ++++++++++++++++++++++++ wpa_supplicant/nan_supplicant.c | 15 +++++++++++++++ wpa_supplicant/nan_supplicant.h | 1 + 5 files changed, 70 insertions(+) diff --git a/src/nan/nan.c b/src/nan/nan.c index 29c6eed457..cacbb2c869 100644 --- a/src/nan/nan.c +++ b/src/nan/nan.c @@ -3622,3 +3622,31 @@ int nan_peer_dump_ndps_to_buf(struct nan_data *nan, const u8 *addr, return pos - buf; } + + +/** + * nan_terminate_ndi_ndps - Terminate all NDPs with a given NDI address + * @nan: NAN module context from nan_init() + * @ndi_addr: NDI address for which all NDPs should be terminated + * + * This function terminates all NDPs that have the given NDI address as either + * initiator or responder NDI. + */ +void nan_terminate_ndi_ndps(struct nan_data *nan, const u8 *ndi_addr) +{ + struct nan_peer *peer; + + if (!nan) + return; + + dl_list_for_each(peer, &nan->peer_list, struct nan_peer, list) { + /* + * It is possible that an NDP setup in progress + * is not on the NDI that is being removed. However, + * to simplify things, stop the setup, so the other + * NDPs could be cleanly removed. + */ + nan_ndp_setup_stop(nan, peer); + nan_terminate_ndps_for_ndi(nan, peer, ndi_addr); + } +} diff --git a/src/nan/nan.h b/src/nan/nan.h index 4d5f6fc0ef..ae3c3032ab 100644 --- a/src/nan/nan.h +++ b/src/nan/nan.h @@ -876,6 +876,8 @@ bool nan_has_active_ndp(struct nan_data *nan); int nan_get_status(struct nan_data *nan, char *buf, size_t buflen); int nan_peer_dump_ndps_to_buf(struct nan_data *nan, const u8 *addr, char *buf, size_t buflen); +void nan_terminate_ndi_ndps(struct nan_data *nan, const u8 *ndi_addr); + #ifdef CONFIG_PASN int nan_pairing_add_attrs(struct nan_data *nan_data, struct wpabuf *buf); int nan_pairing_initiate_pasn_auth(struct nan_data *nan_data, const u8 *addr, diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 0684ada719..4bac52dc01 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -5344,6 +5344,30 @@ wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s, } #endif /* CONFIG_P2P */ +#ifdef CONFIG_NAN + if (wpa_s->nan_data) { + wpa_printf(MSG_DEBUG, "%s: NAN data interface removed", + wpa_s->ifname); + + wpas_nan_data_interface_removed(wpa_s); + wpa_supplicant_remove_iface(wpa_s->global, wpa_s, 0); + break; + } + + if (wpa_s->nan_mgmt) { + wpa_printf(MSG_DEBUG, + "%s: NAN management interface removed", + wpa_s->ifname); + + /* + * Note: NAN is stopped when the interface is + * disabled + */ + wpa_supplicant_remove_iface(wpa_s->global, wpa_s, 0); + break; + } + +#endif /* CONFIG_NAN */ #ifdef CONFIG_MATCH_IFACE if (wpa_s->matched) { wpa_supplicant_remove_iface(wpa_s->global, wpa_s, 0); diff --git a/wpa_supplicant/nan_supplicant.c b/wpa_supplicant/nan_supplicant.c index bc9baa4b7f..1f0de12e1b 100644 --- a/wpa_supplicant/nan_supplicant.c +++ b/wpa_supplicant/nan_supplicant.c @@ -4916,3 +4916,18 @@ void wpas_nan_rx_naf(struct wpa_supplicant *wpa_s, nan_action_rx(wpa_s->nan, mgmt, len); } #endif /* CONFIG_NAN */ + + +void wpas_nan_data_interface_removed(struct wpa_supplicant *wpa_s) +{ + struct wpa_supplicant *nan_dev_wpas = wpas_nan_get_mgmt_iface(wpa_s); + + wpa_printf(MSG_DEBUG, + "NAN: Data interface removed (%s) terminate NDPs on " MACSTR, + wpa_s->ifname, MAC2STR(wpa_s->own_addr)); + + if (!nan_dev_wpas) + return; + + nan_terminate_ndi_ndps(nan_dev_wpas->nan, wpa_s->own_addr); +} diff --git a/wpa_supplicant/nan_supplicant.h b/wpa_supplicant/nan_supplicant.h index b8676a86c1..492ac7f58f 100644 --- a/wpa_supplicant/nan_supplicant.h +++ b/wpa_supplicant/nan_supplicant.h @@ -43,6 +43,7 @@ int wpas_nan_status(struct wpa_supplicant *wpa_s, char *reply, int wpas_nan_bootstrap_request(struct wpa_supplicant *wpa_s, char *cmd); int wpas_nan_bootstrap_reset(struct wpa_supplicant *wpa_s, char *cmd); bool wpas_nan_is_peer_paired(struct wpa_supplicant *wpa_s, const u8 *peer_addr); +void wpas_nan_data_interface_removed(struct wpa_supplicant *wpa_s); int wpas_nan_pair(struct wpa_supplicant *wpa_s, const u8 *peer_addr, u8 auth_mode, int cipher, int handle, u8 peer_instance_id,