From patchwork Wed Mar 6 17:39:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Kumar Singh X-Patchwork-Id: 1908966 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=Jmyr+2q9; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=quicinc.com header.i=@quicinc.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=E2Z+wymH; 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 4Tqfr21YyYz1yX4 for ; Thu, 7 Mar 2024 04:41:38 +1100 (AEDT) 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:References:In-Reply-To: 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: List-Owner; bh=AxC5XUbtDyouwC0T9lqlR1tQjscKLR4QfCEw6c25a7w=; b=Jmyr+2q9seyOkt hg93vZ1HMOJwtKwLv1+uetxdz85ydyUouHL5vmBwY3YTiCgdPZCxWLyti4S7PHpDqWGLLGG59jx31 BC1Z3F9j4A7r3N/0wpFpq8LiTJxrMfCuqr8ITPhFc2DyNyuqSDctmf5lk6HOO3j16V1GeP4FEyuk7 CDMWR2WcRk22I0oQ2ByQoBYeS9QOtppk0mP3MIjfxDUkGLcIHMaVobqoGUIIQxDj91Ipr3tva3AtX VE7LGlrcvZ85e9LPJsA9fkh5mY7clrRYCQ1bg+X2r+sBO8pjMtdO6HxMxbGJ0v+ufMrw+t3xvo3y3 JmofuSynanA0UBD53J1w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhvGO-00000001EDZ-08mU; Wed, 06 Mar 2024 17:41:08 +0000 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhvFv-00000001Dqu-0xzQ for hostap@lists.infradead.org; Wed, 06 Mar 2024 17:40:41 +0000 Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 426BPY8e029850 for ; Wed, 6 Mar 2024 17:40:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= qcppdkim1; bh=MFIAGZ7ZiFogmpl2ow77ILaTVrpQuw0ZrWMCTd6I7Ow=; b=E2 Z+wymHPD2i2LGsluyCt1WoY7zXFne7vo+dePmfxK7J4eTtobe/VVm5vut1RQvCuY 1ULG1PCjNFd3Pmc2cHYHpHK/3CoTIbw9WHazsz8tFgrtYXu9cUHBa65+dY98OSJt Iyg93qKq1g0d+3LZY3e2OyTHzvCO4QQAWNcEWZ3bYGMI4XiA/PLaIpkY81ncv/eR Jp+keDaA9e0enatPltlbEbpc7EY7frbxuRJcyJWhqWwxn9MAkcQMlLNMyrvG01Ai nvbLJctZksww3xeYUKjLtHBfY0bjovtZh8dudXvS14QxqwxPislMdmOvxuCg5hXw SDy17BSrxuM8k407z+2w== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3wpkkase5g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 06 Mar 2024 17:40:38 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 426Hebav032642 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 6 Mar 2024 17:40:37 GMT Received: from cdcwlex322514-lin.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Wed, 6 Mar 2024 09:40:35 -0800 From: Aditya Kumar Singh To: CC: Aditya Kumar Singh Subject: [PATCH 14/16] hostapd: MLO: de-initialize/disable link BSS properly Date: Wed, 6 Mar 2024 23:09:45 +0530 Message-ID: <20240306173947.2611965-15-quic_adisi@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240306173947.2611965-1-quic_adisi@quicinc.com> References: <20240306173947.2611965-1-quic_adisi@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 6xRkK7OYVyeJ6tiazqZ6fAh5BhV6YaYE X-Proofpoint-GUID: 6xRkK7OYVyeJ6tiazqZ6fAh5BhV6YaYE X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-06_11,2024-03-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 bulkscore=0 spamscore=0 malwarescore=0 impostorscore=0 suspectscore=0 mlxlogscore=999 clxscore=1015 lowpriorityscore=0 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2403060143 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240306_094039_682477_14FA9047 X-CRM114-Status: GOOD ( 31.63 ) X-Spam-Score: -0.2 (/) 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: Currently, if first link BSS of an interface is getting de-initialized/ disabled, then whole MLD is brought down. All other links are made to stop beaconing and links are removed. And if, non-first li [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 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_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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_AU Message has a valid DKIM or DK signature from author's domain -0.0 T_SCC_BODY_TEXT_LINE No description available. 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 Currently, if first link BSS of an interface is getting de-initialized/ disabled, then whole MLD is brought down. All other links are made to stop beaconing and links are removed. And if, non-first link BSS is de-initialized/disabled, nothing happens. Even beaconing is not stopped which is wrong. Fix the above by properly bringing down the intended link alone from the interface. Signed-off-by: Aditya Kumar Singh --- hostapd/main.c | 1 + src/ap/hostapd.c | 100 +++++++++++++++++++++-------------- src/drivers/driver.h | 13 +++++ src/drivers/driver_nl80211.c | 33 ++++++++++++ 4 files changed, 107 insertions(+), 40 deletions(-) diff --git a/hostapd/main.c b/hostapd/main.c index 97e9704c7046..1ac9b4be30fc 100644 --- a/hostapd/main.c +++ b/hostapd/main.c @@ -195,6 +195,7 @@ static int hostapd_driver_init(struct hostapd_iface *iface) } hapd->drv_priv = h_hapd->drv_priv; + hapd->interface_added = h_hapd->interface_added; /* * All interfaces participating in the AP MLD would have diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c index 0171649b21cc..9dd9e6c3fd8d 100644 --- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -401,28 +401,6 @@ static int hostapd_broadcast_wep_set(struct hostapd_data *hapd) #endif /* CONFIG_WEP */ - -static void hostapd_clear_drv_priv(struct hostapd_data *hapd) -{ -#ifdef CONFIG_IEEE80211BE - unsigned int i; - - for (i = 0; i < hapd->iface->interfaces->count; i++) { - struct hostapd_iface *iface = hapd->iface->interfaces->iface[i]; - - if (hapd->iface == iface || !iface) - continue; - - if (iface->bss && iface->bss[0] && - hostapd_mld_get_first_bss(iface->bss[0]) == hapd) - iface->bss[0]->drv_priv = NULL; - } -#endif /* CONFIG_IEEE80211BE */ - - hapd->drv_priv = NULL; -} - - #ifdef CONFIG_IEEE80211BE #ifdef CONFIG_TESTING_OPTIONS @@ -561,10 +539,22 @@ void hostapd_free_hapd_data(struct hostapd_data *hapd) * driver wrapper may have removed its internal instance * and hapd->drv_priv is not valid anymore. */ - hostapd_clear_drv_priv(hapd); + hapd->drv_priv = NULL; } } +#ifdef CONFIG_IEEE80211BE + /* If interface was not added as well as it is not the first bss, then + * at least link should be removed here since deinit will take care only + * for the first bss. + */ + if (hapd->conf->mld_ap && !hapd->interface_added && + hapd->iface->bss[0] != hapd) { + hostapd_if_link_remove(hapd, WPA_IF_AP_BSS, hapd->conf->iface, + hapd->mld_link_id); + } +#endif /* CONFIG_IEEE80211BE */ + wpabuf_free(hapd->time_adv); hapd->time_adv = NULL; @@ -3305,6 +3295,41 @@ hostapd_interface_init_bss(struct hapd_interfaces *interfaces, const char *phy, return iface; } +static void hostapd_cleanup_driver(const struct wpa_driver_ops *driver, + void *drv_priv, + struct hostapd_iface *iface) +{ + bool ap_mld = false; + + if (!driver || !driver->hapd_deinit || !drv_priv) + return; + +#ifdef CONFIG_IEEE80211BE + ap_mld = !!iface->bss[0]->conf->mld_ap; +#endif /* CONFIG_IEEE80211BE */ + + /* In case of non-ML operation, de-init. But, if ML operation exist, then + * even if thats the last BSS in the interface, the driver (drv) could + * be in use for a different MLD. Hence, need to check if drv is still + * being used by some other bss before de-initiallizing + */ + if (!ap_mld) + driver->hapd_deinit(drv_priv); +#ifdef CONFIG_IEEE80211BE + else if (hostapd_mld_is_first_bss(iface->bss[0]) && + driver->get_drv_shared_status && + !driver->get_drv_shared_status(drv_priv, iface->bss[0])) { + driver->hapd_deinit(drv_priv); + } else if (hostapd_if_link_remove(iface->bss[0], + WPA_IF_AP_BSS, + iface->bss[0]->conf->iface, + iface->bss[0]->mld_link_id)) { + wpa_printf(MSG_WARNING, "Failed to remove BSS interface %s", + iface->bss[0]->conf->iface); + } +#endif /* CONFIG_IEEE80211BE */ + iface->bss[0]->drv_priv = NULL; +} void hostapd_interface_deinit_free(struct hostapd_iface *iface) { @@ -3322,13 +3347,7 @@ void hostapd_interface_deinit_free(struct hostapd_iface *iface) hostapd_interface_deinit(iface); wpa_printf(MSG_DEBUG, "%s: driver=%p drv_priv=%p -> hapd_deinit", __func__, driver, drv_priv); - if (driver && driver->hapd_deinit && drv_priv) { -#ifdef CONFIG_IEEE80211BE - if (hostapd_mld_is_first_bss(iface->bss[0])) -#endif /* CONFIG_IEEE80211BE */ - driver->hapd_deinit(drv_priv); - hostapd_clear_drv_priv(iface->bss[0]); - } + hostapd_cleanup_driver(driver, drv_priv, iface); hostapd_interface_free(iface); } @@ -3341,21 +3360,22 @@ static void hostapd_deinit_driver(const struct wpa_driver_ops *driver, wpa_printf(MSG_DEBUG, "%s: driver=%p drv_priv=%p -> hapd_deinit", __func__, driver, drv_priv); + + hostapd_cleanup_driver(driver, drv_priv, hapd_iface); + if (driver && driver->hapd_deinit && drv_priv) { -#ifdef CONFIG_IEEE80211BE - if (hostapd_mld_is_first_bss(hapd_iface->bss[0])) -#endif /* CONFIG_IEEE80211BE */ - driver->hapd_deinit(drv_priv); for (j = 0; j < hapd_iface->num_bss; j++) { wpa_printf(MSG_DEBUG, "%s:bss[%d]->drv_priv=%p", __func__, (int) j, hapd_iface->bss[j]->drv_priv); - if (hapd_iface->bss[j]->drv_priv == drv_priv) { - hostapd_clear_drv_priv(hapd_iface->bss[j]); - hapd_iface->extended_capa = NULL; - hapd_iface->extended_capa_mask = NULL; - hapd_iface->extended_capa_len = 0; - } + + if (hapd_iface->bss[j]->drv_priv != drv_priv) + continue; + + hapd_iface->bss[j]->drv_priv = NULL; + hapd_iface->extended_capa = NULL; + hapd_iface->extended_capa_mask = NULL; + hapd_iface->extended_capa_len = 0; } } } diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 6616397fb5d9..d50cbcdb26d1 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -5154,6 +5154,19 @@ struct wpa_driver_ops { */ int (*if_link_remove)(void *priv, enum wpa_driver_if_type type, const char *ifname, s8 link_id); + + /** + * get_drv_shared_status - Get shared status of driver interface + * @priv: private driver interface data from init() + * @bss_ctx: BSS context for %WPA_IF_AP_BSS interfaces + * + * Checks whether driver interface is being used by other partner + * BSS(s) or not. This is used to decide whether driver interface + * needs to be deinitilized when one iface is getting deinitialized. + * + * Returns: True if it is being used or else False. + */ + bool (*get_drv_shared_status)(void *priv, void *bss_ctx); #endif /* CONFIG_IEEE80211BE */ #ifdef CONFIG_TESTING_OPTIONS diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index d5f7cc7d041c..a0616ce39192 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -10755,6 +10755,38 @@ static int driver_nl80211_if_link_remove(void *priv, enum wpa_driver_if_type typ return wpa_driver_nl80211_if_link_remove(bss, type, ifname, link_id); } + +static bool wpa_driver_get_shared_status(void *priv, void *bss_ctx) +{ + struct i802_bss *bss = priv; + struct wpa_driver_nl80211_data *drv = bss->drv; + int num_bss = 0; + + /* If any other bss exist, means someone else is using since at this + * time, we would have removed all bss created by this driver and only + * this bss should be remaining if driver is not shared by anyone + */ + for (bss = drv->first_bss; bss; bss = bss->next) + num_bss++; + + if (num_bss > 1) + return true; + + /* This is the only bss present */ + bss = priv; + + /* If only one/no link is there then no one is sharing */ + if (bss->valid_links <= 1) + return false; + + /* More than one links means some one is still using. To check if + * only 1 bit is set, power of 2 condition can be checked + */ + if (!(bss->valid_links & (bss->valid_links - 1))) + return false; + + return true; +} #endif /* CONFIG_IEEE80211BE */ static int driver_nl80211_send_mlme(void *priv, const u8 *data, @@ -14087,6 +14119,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = { .link_add = nl80211_link_add, #ifdef CONFIG_IEEE80211BE .if_link_remove = driver_nl80211_if_link_remove, + .get_drv_shared_status = wpa_driver_get_shared_status, #endif /* CONFIG_IEEE80211BE */ #ifdef CONFIG_TESTING_OPTIONS .register_frame = testing_nl80211_register_frame,