From patchwork Thu Nov 3 08:08:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Veerendranath Jakkam X-Patchwork-Id: 1698750 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=d0KJx8aC; 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=V9P0v4/b; dkim-atps=neutral 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4N2xJj6hf3z23lV for ; Thu, 3 Nov 2022 19:10:28 +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=Fad+6Xdf90Rx3EeuA6MkE/B45SJS3dfMip2BubN5hpg=; b=d0KJx8aCrxjiFI lpT128PJofZNkgvE0ehXUOG6X4mZuXtUWrstHIKDcyD9nEOC/8OeAJruUe3A5ieEP4E5Pc6kRRXkp LLxWV8Co2uUUTRLvRGtjyko7JJMNjmqVMw4G0zyHeWySk4IlF9ntyXHvzDX882xL+MT4BCnO4suT6 PSdCgg+2ro7Qeb399/aMO2tOrZrrJlWI1vcGcHvC1p+PoLum87cZIJCYrS63rzPtLonnW8A4kI+1A zcn46Yuqn4SNShRsWrY72VmM4fgu1UBlhGp/RUuINvWo5+tuMP83Mhl741Yi3t+blKSA7alBt88KQ 4DqA+l/xpbw4Hvt0hUiQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqVI3-00GaU1-U4; Thu, 03 Nov 2022 08:09:32 +0000 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqVHp-00GaMe-Oq for hostap@lists.infradead.org; Thu, 03 Nov 2022 08:09:20 +0000 Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2A35HDdE002363 for ; Thu, 3 Nov 2022 08:09:13 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=UfQ/df6nXLOxRqp4m+48Uu5WUUSDxtTqkOEXhQ/pikM=; b=V9P0v4/bzaPccKT1AoImMaM7cPz1m/HiLPDwGwdxm87tgxtN6mmHXtgx4s4yCxbqRAdd Dj8wk8XvzuUkeoUNzh7qiWknUDNfgD0PG+YSTf4yKqIDbCzrpuXtbIW/IqgI6nvM5EoG N9+5V9uAJORPMZz5GXBG5GzLRSmz67K6tGFjV7ZeIcUcspowkZp0yg/Qc1ClROP+WM6+ Ji4WqRHhffbzgj/jjGZSel/mYgpigBp3GPk6Lz3YdB8Gqzn8i1zhKR5ZcoiWuga/DpP3 7WoHeDls3yiJ9BJ7eU06y2j9yb6s7CFUT+VrZ4KK7EGbbFSZBzpyI7jnFwdDYerV19gK Pw== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3km72g8nv0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 03 Nov 2022 08:09:13 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2A389Cqd032111 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 3 Nov 2022 08:09:12 GMT Received: from cnss-mw-linux.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.986.29; Thu, 3 Nov 2022 01:09:10 -0700 From: Veerendranath Jakkam To: CC: Subject: [PATCH v4 01/13] nl80211: Get all requested MLO links information from (re)association events Date: Thu, 3 Nov 2022 13:38:44 +0530 Message-ID: <20221103080856.1430462-2-quic_vjakkam@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221103080856.1430462-1-quic_vjakkam@quicinc.com> References: <20221103080856.1430462-1-quic_vjakkam@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: -emHZ2bNwKLYi6AI6wmN69DVqOHV9RxR X-Proofpoint-ORIG-GUID: -emHZ2bNwKLYi6AI6wmN69DVqOHV9RxR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-02_15,2022-11-02_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 phishscore=0 mlxscore=0 suspectscore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 bulkscore=0 priorityscore=1501 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211030057 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221103_010917_942311_C6C2D1F0 X-CRM114-Status: GOOD ( 26.40 ) 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 only accepted MLO links information is getting parsed from (re)association events. Add support to parse all the requested MLO links information including rejected links. Get the rejected MLO [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.220.180.131 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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 only accepted MLO links information is getting parsed from (re)association events. Add support to parse all the requested MLO links information including rejected links. Get the rejected MLO links information from netlink attributes if kernel supports indicating per link status. Otherwise get the rejected MLO links information by parsing (re)association request and response IEs. Signed-off-by: Veerendranath Jakkam --- src/drivers/driver.h | 3 +- src/drivers/driver_nl80211_event.c | 156 +++++++++++++++++++++++++++-- 2 files changed, 149 insertions(+), 10 deletions(-) diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 9132409c1..82fec2174 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -2741,7 +2741,8 @@ struct weighted_pcl { }; struct driver_sta_mlo_info { - u16 valid_links; /* bitmap of valid link IDs */ + u16 req_links; /* bitmap of requested link IDs */ + u16 valid_links; /* bitmap of accepted link IDs */ u8 assoc_link_id; u8 ap_mld_addr[ETH_ALEN]; struct { diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c index db3c9c180..2e199c49a 100644 --- a/src/drivers/driver_nl80211_event.c +++ b/src/drivers/driver_nl80211_event.c @@ -482,12 +482,16 @@ static void nl80211_parse_mlo_link_info(struct driver_sta_mlo_info *mlo, if (link_id >= MAX_NUM_MLD_LINKS) continue; - if (tb[NL80211_ATTR_STATUS_CODE] && - nla_get_u16(tb[NL80211_ATTR_STATUS_CODE]) != - WLAN_STATUS_SUCCESS) - continue; + if (tb[NL80211_ATTR_STATUS_CODE]) { + /* Set requested links only when status indicated */ + mlo->req_links |= BIT(link_id); + if (nla_get_u16(tb[NL80211_ATTR_STATUS_CODE]) == + WLAN_STATUS_SUCCESS) + mlo->valid_links |= BIT(link_id); + } else { + mlo->valid_links |= BIT(link_id); + } - mlo->valid_links |= BIT(link_id); os_memcpy(mlo->links[link_id].addr, nla_data(tb[NL80211_ATTR_MAC]), ETH_ALEN); os_memcpy(mlo->links[link_id].bssid, @@ -500,6 +504,137 @@ static void nl80211_parse_mlo_link_info(struct driver_sta_mlo_info *mlo, } +struct links_info { + /* bitmap of link IDs in Per-STA profile subelements*/ + u16 non_assoc_links; + u8 addr[MAX_NUM_MLD_LINKS][ETH_ALEN]; +}; + + +static void nl80211_get_basic_mle_links_info(const u8 *mle, size_t mle_len, + struct links_info *info) +{ + size_t rem_len; + const u8 *pos; + + if (mle_len < (MULTI_LINK_CONTROL_LEN + 1) || + (mle_len - MULTI_LINK_CONTROL_LEN) < mle[MULTI_LINK_CONTROL_LEN]) + return; + + // Skip Common Info + pos = mle + MULTI_LINK_CONTROL_LEN + mle[MULTI_LINK_CONTROL_LEN]; + rem_len = mle_len - + (MULTI_LINK_CONTROL_LEN + mle[MULTI_LINK_CONTROL_LEN]); + + // Parse Subelements + while (rem_len > 2) { + int ie_len = 2 + pos[1]; + + if (rem_len < ie_len) + return; + + if (pos[0] == MULTI_LINK_SUB_ELEM_ID_PER_STA_PROFILE) { + u8 link_id; + const u8 *sta_profile; + + if (pos[1] < + (BASIC_MLE_STA_PROF_STA_MAC_IDX + ETH_ALEN)) + goto next_subelem; + + sta_profile = &pos[2]; + link_id = sta_profile[0] & + BASIC_MLE_STA_CTRL0_LINK_ID_MASK; + if (link_id >= MAX_NUM_MLD_LINKS) + goto next_subelem; + + if (!(sta_profile[0] & + BASIC_MLE_STA_CTRL0_PRES_STA_MAC)) + goto next_subelem; + + info->non_assoc_links |= BIT(link_id); + os_memcpy(info->addr[link_id], + &sta_profile[BASIC_MLE_STA_PROF_STA_MAC_IDX], + ETH_ALEN); + } +next_subelem: + pos += ie_len; + rem_len -= ie_len; + } +} + + +static int nl80211_update_rejected_links_info(struct driver_sta_mlo_info *mlo, + struct nlattr *req_ie, + struct nlattr *resp_ie) +{ + int i; + struct wpabuf *mle; + struct ieee802_11_elems req_elems, resp_elems; + struct links_info req_info, resp_info; + + if (!req_ie || !resp_ie) { + wpa_printf(MSG_ERROR, + "MLO: (Re)association request/response IEs not available"); + return -1; + } + + if (ieee802_11_parse_elems(nla_data(req_ie), nla_len(req_ie), + &req_elems, 0) == ParseFailed || + ieee802_11_parse_elems(nla_data(resp_ie), nla_len(resp_ie), + &resp_elems, 0) == ParseFailed) { + wpa_printf(MSG_ERROR, + "MLO: Failed to parse (re)association request/response IEs"); + return -1; + } + + mle = ieee802_11_defrag_mle(&req_elems, MULTI_LINK_CONTROL_TYPE_BASIC); + if (!mle) { + wpa_printf(MSG_ERROR, + "MLO: Basic Multi-Link element not found in Association request"); + return -1; + } + os_memset(&req_info, 0, sizeof(req_info)); + nl80211_get_basic_mle_links_info((const u8 *) wpabuf_head(mle), + wpabuf_len(mle), &req_info); + wpabuf_free(mle); + + mle = ieee802_11_defrag_mle(&resp_elems, MULTI_LINK_CONTROL_TYPE_BASIC); + if (!mle) { + wpa_printf(MSG_ERROR, + "MLO: Basic Multi-Link element not found in Association response"); + return -1; + } + os_memset(&resp_info, 0, sizeof(resp_info)); + nl80211_get_basic_mle_links_info((const u8 *) wpabuf_head(mle), + wpabuf_len(mle), &resp_info); + wpabuf_free(mle); + + if (req_info.non_assoc_links != resp_info.non_assoc_links) { + wpa_printf(MSG_ERROR, + "MLO: Association request and response links bitmap not equal"); + return -1; + } + + mlo->req_links = BIT(mlo->assoc_link_id) | req_info.non_assoc_links; + if ((mlo->req_links & mlo->valid_links) != mlo->valid_links) { + wpa_printf(MSG_ERROR, + "MLO: accepted links are not subset of requested links"); + return -1; + } + + /* Get MLO links info for rejected links */ + for (i = 0; i < MAX_NUM_MLD_LINKS; i++) { + if (!((mlo->req_links & ~mlo->valid_links) & BIT(i))) + continue; + + os_memcpy(mlo->links[i].bssid, resp_info.addr[i], ETH_ALEN); + os_memcpy(mlo->links[i].addr, req_info.addr[i], ETH_ALEN); + } + + return 0; +} + + static int nl80211_get_assoc_link_id(const u8 *data, u8 len) { if (!(data[0] & BASIC_MULTI_LINK_CTRL0_PRES_LINK_ID)) @@ -520,6 +655,7 @@ static void nl80211_parse_mlo_info(struct wpa_driver_nl80211_data *drv, bool qca_roam_auth, struct nlattr *addr, struct nlattr *mlo_links, + struct nlattr *req_ie, struct nlattr *resp_ie) { const u8 *ml_ie; @@ -554,9 +690,10 @@ static void nl80211_parse_mlo_info(struct wpa_driver_nl80211_data *drv, nl80211_parse_qca_vendor_mlo_link_info(mlo, mlo_links); #endif /* CONFIG_DRIVER_NL80211_QCA */ - if (!(mlo->valid_links & BIT(drv->sta_mlo_info.assoc_link_id))) { - wpa_printf(MSG_ERROR, "nl80211: Invalid MLO assoc link ID %d", - drv->sta_mlo_info.assoc_link_id); + if (!(mlo->valid_links & BIT(mlo->assoc_link_id)) || + (!mlo->req_links && + nl80211_update_rejected_links_info(mlo, req_ie, resp_ie))) { + wpa_printf(MSG_ERROR, "nl80211: Invalid MLO connection info"); mlo->valid_links = 0; return; } @@ -675,7 +812,8 @@ static void mlme_event_connect(struct wpa_driver_nl80211_data *drv, drv->associated = 1; drv->sta_mlo_info.valid_links = 0; - nl80211_parse_mlo_info(drv, qca_roam_auth, addr, mlo_links, resp_ie); + nl80211_parse_mlo_info(drv, qca_roam_auth, addr, mlo_links, req_ie, + resp_ie); if (!drv->sta_mlo_info.valid_links && addr) { os_memcpy(drv->bssid, nla_data(addr), ETH_ALEN); os_memcpy(drv->prev_bssid, drv->bssid, ETH_ALEN);