From patchwork Wed Mar 6 17:39:42 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: 1908963 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=gc01PRWt; 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=TKwyHSFh; 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 4Tqfqn5kRJz1yX4 for ; Thu, 7 Mar 2024 04:41:25 +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=hZzbfqIb1kKr8hQAHKoKurqQICsiDAqhq1vuht7jD7k=; b=gc01PRWt0sJobw bqjNc0PhLdrK1CzcuY8eiFPqLc5iCoUI7RMhUHwZOSkZI/pqwkmlynYyS6GZCaIFdse2+VIE98L6b pIVu8fvJo3ytUIHUUuh5knj117hbQ8QwRzWzzI720opoJ3IvmfckO98sm7HWm8V1sBgN4w+hTBBKG nL7kD2T+taEnl5o3JC4QdizGBbbq68AdHlfA/MXxtBNe36SBXjcsPiDo3Mqs8y4CXwgKSS2ZC1hhI EKY2swrM2HdioW5cNZsYPIC96f/Sz2aZa+cVDILFBi1ccvU4JIIf/mHsAug3sDSJDUe74jQBr7ECu 7tpu3ByIoRpuwVW0CvvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhvGB-00000001E3G-1kok; Wed, 06 Mar 2024 17:40:55 +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 1rhvFq-00000001Dmr-1M9X for hostap@lists.infradead.org; Wed, 06 Mar 2024 17:40:37 +0000 Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 426D0Pev030322 for ; Wed, 6 Mar 2024 17:40:33 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=HuWpTAgCYCZZIIVF/k3bHQXKKhd+8CJvIXKmFqqnmzY=; b=TK wyHSFhqd6NPwlSXG7m+conUwfqLAG40229E5ICYp2K6kgMoPpdp1az/HAp08qphw yZLF2AMFgoA8e3pmYBejYpeqk/3txIgIjM+lBHs0v7niKIgxRR+nQX6NHOWxidWp oWOianxt2YAdTBL3q8msVYyk8oVN+wj0MB2k2APL0sILjnHf3kStNyosmHEl8tXn Loy9Z4QaXVOs4r7brpX2yOyiyb8TfFmeqOe8VSlpVTi5WDRl+ZBt7ZYRR6Lf5IRQ NXpl+qP+3D38tWvb9GN1fD19cEMOv2SRqRCp/I8K/C1MksJsahPL6Qi7NCrYqIR2 Een2HRfGZetaK1OIeCsw== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3wpktpsd6n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 06 Mar 2024 17:40:33 +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 426HeWKT032609 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 6 Mar 2024 17:40:32 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:30 -0800 From: Aditya Kumar Singh To: CC: Aditya Kumar Singh Subject: [PATCH 11/16] hostapd: MLO: add support to remove the link before removing interface Date: Wed, 6 Mar 2024 23:09:42 +0530 Message-ID: <20240306173947.2611965-12-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-GUID: qEtlLVpOHuMCcDmYm6iSQ8eZCxgCRwVb X-Proofpoint-ORIG-GUID: qEtlLVpOHuMCcDmYm6iSQ8eZCxgCRwVb 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 priorityscore=1501 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 spamscore=0 clxscore=1015 mlxlogscore=999 mlxscore=0 suspectscore=0 impostorscore=0 lowpriorityscore=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_094034_679792_CFB70FB0 X-CRM114-Status: GOOD ( 22.83 ) 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 whenever if_remove() is called, whole interface is deleted. In MLO, all partner BSS uses the same driver private hence removing the interface when only one the link goes down should be avoid [...] 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 whenever if_remove() is called, whole interface is deleted. In MLO, all partner BSS uses the same driver private hence removing the interface when only one the link goes down should be avoided. Add helper function to remove link first whenever if_remove() is called. Later while handling it, if number of links active goes to 0, then the if_remove() would be called in order to clean up the interface. This helper would be used later when co-hosted MLD support is added as well later during ML reconfiguration support. Signed-off-by: Aditya Kumar Singh --- src/ap/ap_drv_ops.c | 18 +++++++++++++ src/ap/ap_drv_ops.h | 3 +++ src/drivers/driver.h | 14 ++++++++++ src/drivers/driver_nl80211.c | 50 ++++++++++++++++++++++++++++++++++++ src/drivers/driver_nl80211.h | 1 + 5 files changed, 86 insertions(+) diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c index a6f53fd8cbb1..5dfcdac3a137 100644 --- a/src/ap/ap_drv_ops.c +++ b/src/ap/ap_drv_ops.c @@ -571,6 +571,18 @@ int hostapd_if_add(struct hostapd_data *hapd, enum wpa_driver_if_type type, bridge, use_existing, 1); } +#ifdef CONFIG_IEEE80211BE +int hostapd_if_link_remove(struct hostapd_data *hapd, enum wpa_driver_if_type type, + const char *ifname, u8 link_id) +{ + if (hapd->driver == NULL || hapd->drv_priv == NULL || + hapd->driver->if_link_remove == NULL) + return -1; + + return hapd->driver->if_link_remove(hapd->drv_priv, type, ifname, + hapd->mld_link_id); +} +#endif /* CONFIG_IEEE80211BE */ int hostapd_if_remove(struct hostapd_data *hapd, enum wpa_driver_if_type type, const char *ifname) @@ -578,6 +590,12 @@ int hostapd_if_remove(struct hostapd_data *hapd, enum wpa_driver_if_type type, if (hapd->driver == NULL || hapd->drv_priv == NULL || hapd->driver->if_remove == NULL) return -1; + +#ifdef CONFIG_IEEE80211BE + if (hapd->conf->mld_ap) + return hostapd_if_link_remove(hapd, type, ifname, hapd->mld_link_id); +#endif /* CONFIG_IEEE80211BE */ + return hapd->driver->if_remove(hapd->drv_priv, type, ifname); } diff --git a/src/ap/ap_drv_ops.h b/src/ap/ap_drv_ops.h index b3a96447947a..9c74ef579b2f 100644 --- a/src/ap/ap_drv_ops.h +++ b/src/ap/ap_drv_ops.h @@ -458,6 +458,9 @@ static inline int hostapd_drv_link_add(struct hostapd_data *hapd, return hapd->driver->link_add(hapd->drv_priv, link_id, addr, hapd); } + +int hostapd_if_link_remove(struct hostapd_data *hapd, enum wpa_driver_if_type type, + const char *ifname, u8 link_id); #endif /* CONFIG_IEEE80211BE */ #endif /* AP_DRV_OPS */ diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 8ffe487ae1c7..6616397fb5d9 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -5142,6 +5142,20 @@ struct wpa_driver_ops { */ int (*link_add)(void *priv, u8 link_id, const u8 *addr, void *bss_ctx); +#ifdef CONFIG_IEEE80211BE + /** + * if_link_remove - Remove a link alone from virtual interface + * @priv: Private driver interface data + * @type: Interface type + * @ifname: Interface name of the virtual interface from where link is + * to be removed + * @link_id: Valid link ID to remove + * Returns: 0 on success, -1 on failure + */ + int (*if_link_remove)(void *priv, enum wpa_driver_if_type type, + const char *ifname, s8 link_id); +#endif /* CONFIG_IEEE80211BE */ + #ifdef CONFIG_TESTING_OPTIONS int (*register_frame)(void *priv, u16 type, const u8 *match, size_t match_len, diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index ef9a513b663b..d5f7cc7d041c 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -196,6 +196,7 @@ static int nl80211_leave_ibss(struct wpa_driver_nl80211_data *drv, static int i802_set_iface_flags(struct i802_bss *bss, int up); static int nl80211_set_param(void *priv, const char *param); static void nl80211_remove_links(struct i802_bss *bss); +static int nl80211_remove_link(struct i802_bss *bss, int link_id); #ifdef CONFIG_MESH static int nl80211_put_mesh_config(struct nl_msg *msg, struct wpa_driver_mesh_bss_params *params); @@ -10709,6 +10710,52 @@ static int driver_nl80211_if_remove(void *priv, enum wpa_driver_if_type type, return wpa_driver_nl80211_if_remove(bss, type, ifname); } +#ifdef CONFIG_IEEE80211BE +static int wpa_driver_nl80211_if_link_remove(struct i802_bss *bss, + enum wpa_driver_if_type type, + const char *ifname, + s8 link_id) +{ + struct wpa_driver_nl80211_data *drv = bss->drv; + + wpa_printf(MSG_DEBUG, "nl80211: %s(type=%d ifname=%s links=0x%x) link_id=%d", + __func__, type, ifname, bss->valid_links, link_id); + wpa_printf(MSG_DEBUG, "nl80211: Teardown AP(%s) link %d", bss->ifname, + link_id); + + nl80211_remove_link(bss, link_id); + + bss->ctx = bss->flink->ctx; + + if (drv->first_bss == bss && !bss->valid_links) + drv->ctx = bss->ctx; + + if (!bss->valid_links) { + wpa_printf(MSG_DEBUG, + "nl80211: Only 1 link was there hence remove interface"); + return wpa_driver_nl80211_if_remove(bss, type, ifname); + } + + return 0; +} + +static int driver_nl80211_if_link_remove(void *priv, enum wpa_driver_if_type type, + const char *ifname, s8 link_id) +{ + struct i802_bss *bss = priv; + + if (link_id < 0 || link_id >= MAX_NUM_MLD_LINKS) + return -1; + + if (type != WPA_IF_AP_BSS) + return -1; + + if (!(bss->valid_links & BIT(link_id))) + return -1; + + return wpa_driver_nl80211_if_link_remove(bss, type, ifname, link_id); +} +#endif /* CONFIG_IEEE80211BE */ static int driver_nl80211_send_mlme(void *priv, const u8 *data, size_t data_len, int noack, @@ -14038,6 +14085,9 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = { #endif /* CONFIG_DPP */ .get_sta_mlo_info = nl80211_get_sta_mlo_info, .link_add = nl80211_link_add, +#ifdef CONFIG_IEEE80211BE + .if_link_remove = driver_nl80211_if_link_remove, +#endif /* CONFIG_IEEE80211BE */ #ifdef CONFIG_TESTING_OPTIONS .register_frame = testing_nl80211_register_frame, .radio_disable = testing_nl80211_radio_disable, diff --git a/src/drivers/driver_nl80211.h b/src/drivers/driver_nl80211.h index 03d3c333b3d1..3e5a53452f00 100644 --- a/src/drivers/driver_nl80211.h +++ b/src/drivers/driver_nl80211.h @@ -352,6 +352,7 @@ const char * nl80211_iftype_str(enum nl80211_iftype mode); void nl80211_restore_ap_mode(struct i802_bss *bss); struct i802_link * nl80211_get_link(struct i802_bss *bss, s8 link_id); +int nl80211_is_valid_link(struct i802_bss *bss, s8 link_id); static inline bool nl80211_link_valid(u16 links, s8 link_id) {