From patchwork Wed Feb 28 08:48:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 776847 Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 407F92D03C for ; Wed, 28 Feb 2024 08:49:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709110149; cv=none; b=K+bbCVG/ZoeAP5BjlLEQkQ5Uxb6jLHI41KDBfWX1GeALA1o8JxwSkV1zguV6qEHUsInBVeYywgTmQzx9ARkoMSOFzPBdjtwgbqaU3COMHxu5BSDnwSn70UoBBoAYAb/YkFFZ9Sn50gogvAoZ7PQrT1R3M7/Ixuo5uNKglFUnWG8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709110149; c=relaxed/simple; bh=5KKFBh1tF2E4tKXxGF/UOVMJYzRymGqFBgy5BlghBAw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ecFYyWNgEshJ9fv80PrqKRu+yAAzr6kgz+8uMcDBjvKqh0SlgNTec1lGEjTHX+YyYfn15SaqHQO//F/X5ntVShAXLdaGkI85vGRaDWd0bc1fee3Y+hwxiBVQ/msCwceIdtYr1EnbMACMvZIyxq0gbVERsFRIeIs0DtHOMwzGJHw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=CngXkI+2; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="CngXkI+2" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=H+XwrbdiD4rnC/9MUfRE3p0qdR70VLvZQpYrE5v3SSo=; t=1709110148; x=1710319748; b=CngXkI+2Ewr0LQH6e5SZhuQzRUlRj/lAUnlOwmd6g+RTPLT yEdFsbMN2w6g06ast0c850ia2OZpx2sAqvHKiZwEJcQLQJCDZmK1nIwTPxwUza12RWbcBEArGl6n8 XH+5MgYuBMeEJJyiq1xvMCjodh0q6ENjHT4BFfkYcGx/gj0e4U4Sg4JHbdCzp9tpKXZRyouNTEjuD qWNV64qCBF7jtsbw0eOD/QmAdpmS06MgjlpJw84r3Xuz4gvnkWB9WQ9iCe1y2gUG6H3RiouMe9vh2 /a0FqEersaAtd+9XADWG8wYcrMZI05Hmdu269pCSOquL8lYW8OMPxZC/BIlLNi5w==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rfFcf-0000000C0BC-0m26; Wed, 28 Feb 2024 09:49:05 +0100 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg , Benjamin Berg , Ilan Peer , Miriam Rachel Korenblit Subject: [PATCH 1/8] wifi: mac80211: update scratch_pos after defrag Date: Wed, 28 Feb 2024 09:48:09 +0100 Message-ID: <20240228094901.9da35f39eeb7.I7127f2918ec4cba416fcbc35eacaea10262c1268@changeid> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240228084901.18661-10-johannes@sipsolutions.net> References: <20240228084901.18661-10-johannes@sipsolutions.net> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Johannes Berg The scratch_pos update here was lost after defrag, so any other uses of the scratch buffer might overwrite it. Fixes: a286de1aa38f ("wifi: mac80211: Rename multi_link") Reviewed-by: Benjamin Berg Reviewed-by: Ilan Peer Reviewed-by: Miriam Rachel Korenblit Signed-off-by: Johannes Berg --- net/mac80211/parse.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/mac80211/parse.c b/net/mac80211/parse.c index 196a882e4c19..233c761823d3 100644 --- a/net/mac80211/parse.c +++ b/net/mac80211/parse.c @@ -800,6 +800,7 @@ static void ieee80211_mle_parse_link(struct ieee802_11_elems *elems, elems->ml_basic = (const void *)elems->scratch_pos; elems->ml_basic_len = ml_len; + elems->scratch_pos += ml_len; ieee80211_mle_get_sta_prof(elems, params->link_id); prof = elems->prof; From patchwork Wed Feb 28 08:48:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 777446 Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC5662D05C for ; Wed, 28 Feb 2024 08:49:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709110150; cv=none; b=Xbw98WM/3fbf8KpqgYG4Afj6U0/Enlb/dD1CJFrsLXLwQ0lsL9+ThewRJKxu9464qLv7XiYT5qjLyAJroYhAtD7v+0QzabPChj0IPw5ByxZFffdsvyfEgtKXbTq/WREL92Ekr8CxvgKGFZDQ1RdjkrM28W0BrB76qn+jxuzl5Ww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709110150; c=relaxed/simple; bh=Xsnnez6zvL++vwTf44cbUFTOtmrSWuGSTWfS/o7S7tg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NHbSoRhSJUWj8bzJjx3IQaGZeEj7U7f6dPV6/nk5JPf1Hon5tL/TdopiRQTVnpI5clJ6MFlwP2H/yt+/4nbJhp8/dMmaCkqIAWrtr18+AUJl7wMCo+o+VHuqMVW/E4yHvHjy3eHrucdR9jBGpEp8x+y/XVeTf/rwx2yObhNGtU0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=HWvUwiAe; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="HWvUwiAe" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=fn/+YyW+0dDZ2Tyij3BZ+Ds0KcAJWYAvLwT1/MyHQP0=; t=1709110148; x=1710319748; b=HWvUwiAeLAK/i6bBA6vKuuoTfPZhm6MhN5yleGw7hi1rYsr iM19BbORwW6uy0IhAc4T1POHO0D/jDfd4bVlHDESC/y+4Rc96uukRfcG6aooUCeP4skN5l4FCr5Wo hO5qm6Y11GPIxFzPqsjlU2R996ij+3NfmlY5uBFz599yWYidagUoFsjEFScP2/8dLbNPqmApPVtt2 SlQtLkDw0MOP55XAhBHNbkXs0g3c90+9cyz25LUfeDD8Jo6uZ7RhvpdxhgMIpDQrIagq2RwO8lkbh ipaNX0HEgUCWzEN4abE5vEXXbsEDTW/ZoJbDHq3T8xW0Sb/1v8VpyW/ph+ajn+xw==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rfFcf-0000000C0BC-3sMy; Wed, 28 Feb 2024 09:49:06 +0100 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg , Ilan Peer , Miriam Rachel Korenblit Subject: [PATCH 2/8] wifi: mac80211: remove unnecessary ML element type check Date: Wed, 28 Feb 2024 09:48:10 +0100 Message-ID: <20240228094901.ad1d4a09a6eb.Ib96fa75b1a6db21dd4182dcfa11fe9aff78fa3ed@changeid> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240228084901.18661-10-johannes@sipsolutions.net> References: <20240228084901.18661-10-johannes@sipsolutions.net> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Johannes Berg At this point, since it's taken from elems->ml_basic which is stored only if it's of type basic, we don't really need to check again if it's basic. Reviewed-by: Ilan Peer Reviewed-by: Miriam Rachel Korenblit Signed-off-by: Johannes Berg --- net/mac80211/parse.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/net/mac80211/parse.c b/net/mac80211/parse.c index 233c761823d3..ae0f14bd952a 100644 --- a/net/mac80211/parse.c +++ b/net/mac80211/parse.c @@ -723,10 +723,6 @@ static void ieee80211_mle_get_sta_prof(struct ieee802_11_elems *elems, if (!ml || !ml_len) return; - if (le16_get_bits(ml->control, IEEE80211_ML_CONTROL_TYPE) != - IEEE80211_ML_CONTROL_TYPE_BASIC) - return; - for_each_mle_subelement(sub, (u8 *)ml, ml_len) { struct ieee80211_mle_per_sta_profile *prof = (void *)sub->data; ssize_t sta_prof_len; From patchwork Wed Feb 28 08:48:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 777444 Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE1C72D60C for ; Wed, 28 Feb 2024 08:49:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709110153; cv=none; b=a2Gxxhm0A+IcbKWAEcrh+Wj93bY81V1PDScqLc1vpyuUb/N9kIYbIQUMR8Hoyqr3xQnBFjqlit3Ilhw6BjCiVy3Z24nWC03LFw6+WQW6N/hR1DtJ1wvjGJGdDfEHxxgJ+kCni8cKROUtT9JYQntb66asprhPerDqkFFGxhiv6oI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709110153; c=relaxed/simple; bh=GH234ThYK/CbslSPidh7qj8r735EKZZt1K4fDgj9EC8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p3otugpKkmGPR+efmPFnWJdaa0GoCDea9RA5awp9hzuHor82VARXauJZKdv3XZdyo8ZFuSgSVlej1GJ1Ff1QNS1SSgkqqX1r+5E0AR17Zm3dvUOsaD6zqVgwD3GyL1BRCsHLgcoHF/IRhgKhXKt9f7zCT2Fbg241tkinVp6Lt24= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=tDIrKspl; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="tDIrKspl" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=nV1zAS4CHCd9wjj2/NVlwm3qWhQlkoLk80Lq09ojcrw=; t=1709110150; x=1710319750; b=tDIrKsplyfYiRDBI/LYWdG/RsF7TkHCaoXUOw+MEmliNykk /7/kDAYRs578lEMTQAWyF1BN/uwlTnB485UfXBqqfxeXsqMChOfAPKqa/0yTypjbE2ddsl+Dz9Y5w ySY32jumjepZAEvnkudZyC0YQABFn95Xti2gH2auq6gKXcmmxALyI8urkX1AcNgLk59cHPk3yCxjJ h7L0ry0gE0MeuIXbFP0bbhwyhd8/DapAgq+wqroFo9gjHGVmxRa5ooJPAGdhe+jtaKVmpYzYVGRw7 rj3RtCHmq6VegrghPsHWTNGh+FabF5C4mrTWCPGOmjoqFtf4a7x/CNxOIwwHdCPw==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rfFcg-0000000C0BC-2qTz; Wed, 28 Feb 2024 09:49:06 +0100 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg , Ilan Peer , Emmanuel Grumbach , Miriam Rachel Korenblit Subject: [PATCH 3/8] wifi: mac80211: add ieee80211_vif_link_active() helper Date: Wed, 28 Feb 2024 09:48:11 +0100 Message-ID: <20240228094901.688760aff5f7.I06892a503f5ecb9563fbd678d35d08daf7a044b0@changeid> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240228084901.18661-10-johannes@sipsolutions.net> References: <20240228084901.18661-10-johannes@sipsolutions.net> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Johannes Berg We sometimes need to check if a link is active, and this is complicated by the fact that active_links has no bits set when the vif isn't (acting as) an MLD. Add a small new helper ieee80211_vif_link_active() to make that a bit easier, and use it in a few places. Reviewed-by: Ilan Peer Reviewed-by: Emmanuel Grumbach Reviewed-by: Miriam Rachel Korenblit Signed-off-by: Johannes Berg --- include/net/mac80211.h | 15 +++++++++++++++ net/mac80211/cfg.c | 3 +-- net/mac80211/chan.c | 3 +-- net/mac80211/driver-ops.c | 14 +++++--------- net/mac80211/util.c | 3 +-- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 34d66d0a24b1..6c6d8210d637 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -2011,6 +2011,21 @@ static inline bool ieee80211_vif_is_mld(const struct ieee80211_vif *vif) return vif->valid_links != 0; } +/** + * ieee80211_vif_link_active - check if a given link is active + * @vif: the vif + * @link_id: the link ID to check + * Return: %true if the vif is an MLD and the link is active, or if + * the vif is not an MLD and the link ID is 0; %false otherwise. + */ +static inline bool ieee80211_vif_link_active(const struct ieee80211_vif *vif, + unsigned int link_id) +{ + if (!ieee80211_vif_is_mld(vif)) + return link_id == 0; + return vif->active_links & BIT(link_id); +} + #define for_each_vif_active_link(vif, link, link_id) \ for (link_id = 0; link_id < ARRAY_SIZE((vif)->link_conf); link_id++) \ if ((!(vif)->active_links || \ diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index e57ba4f7a589..821a83e487df 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -3155,8 +3155,7 @@ int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata, if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION)) return -EINVAL; - if (ieee80211_vif_is_mld(&sdata->vif) && - !(sdata->vif.active_links & BIT(link->link_id))) + if (!ieee80211_vif_link_active(&sdata->vif, link->link_id)) return 0; old_req = link->u.mgd.req_smps; diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index 38acdc458c7c..80e4b9784131 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -1701,8 +1701,7 @@ int ieee80211_link_use_channel(struct ieee80211_link_data *link, lockdep_assert_wiphy(local->hw.wiphy); - if (sdata->vif.active_links && - !(sdata->vif.active_links & BIT(link->link_id))) { + if (!ieee80211_vif_link_active(&sdata->vif, link->link_id)) { ieee80211_link_update_chanreq(link, chanreq); return 0; } diff --git a/net/mac80211/driver-ops.c b/net/mac80211/driver-ops.c index 3b7f70073fc3..dce37ba8ebe3 100644 --- a/net/mac80211/driver-ops.c +++ b/net/mac80211/driver-ops.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright 2015 Intel Deutschland GmbH - * Copyright (C) 2022-2023 Intel Corporation + * Copyright (C) 2022-2024 Intel Corporation */ #include #include "ieee80211_i.h" @@ -214,8 +214,7 @@ int drv_conf_tx(struct ieee80211_local *local, if (!check_sdata_in_driver(sdata)) return -EIO; - if (sdata->vif.active_links && - !(sdata->vif.active_links & BIT(link->link_id))) + if (!ieee80211_vif_link_active(&sdata->vif, link->link_id)) return 0; if (params->cw_min == 0 || params->cw_min > params->cw_max) { @@ -315,8 +314,7 @@ int drv_assign_vif_chanctx(struct ieee80211_local *local, if (!check_sdata_in_driver(sdata)) return -EIO; - if (sdata->vif.active_links && - !(sdata->vif.active_links & BIT(link_conf->link_id))) + if (!ieee80211_vif_link_active(&sdata->vif, link_conf->link_id)) return 0; trace_drv_assign_vif_chanctx(local, sdata, link_conf, ctx); @@ -343,8 +341,7 @@ void drv_unassign_vif_chanctx(struct ieee80211_local *local, if (!check_sdata_in_driver(sdata)) return; - if (sdata->vif.active_links && - !(sdata->vif.active_links & BIT(link_conf->link_id))) + if (!ieee80211_vif_link_active(&sdata->vif, link_conf->link_id)) return; trace_drv_unassign_vif_chanctx(local, sdata, link_conf, ctx); @@ -461,8 +458,7 @@ void drv_link_info_changed(struct ieee80211_local *local, if (!check_sdata_in_driver(sdata)) return; - if (sdata->vif.active_links && - !(sdata->vif.active_links & BIT(link_id))) + if (!ieee80211_vif_link_active(&sdata->vif, link_id)) return; trace_drv_link_info_changed(local, sdata, info, changed); diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 627bd5a8bda5..d7c4d162321f 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -1935,8 +1935,7 @@ int ieee80211_reconfig(struct ieee80211_local *local) for (link_id = 0; link_id < ARRAY_SIZE(sdata->vif.link_conf); link_id++) { - if (ieee80211_vif_is_mld(&sdata->vif) && - !(sdata->vif.active_links & BIT(link_id))) + if (!ieee80211_vif_link_active(&sdata->vif, link_id)) continue; link = sdata_dereference(sdata->link[link_id], sdata); From patchwork Wed Feb 28 08:48:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 776846 Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 173B32D61A for ; Wed, 28 Feb 2024 08:49:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709110151; cv=none; b=Z+mF8V9QnVVqpodnYvxZuNaAuA5vBdvgnAeuUrzTzHMb+bJ04Lc24MS5IkYoGEYoWl4RbAaj3EcLgRJTdGlCtHNKx6FWB9m1GA8eT5EBbtmlmfYpmX78ZboYOZYoZXhFC0Rz1+ER3FfCthEZS6yWUugfrkx1NlPayoIOVUi92So= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709110151; c=relaxed/simple; bh=hOinKWtUg5W4CrkwaEyr458E8imU8uIRCSZhyha97rM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=izPkyz8bpCr5zJQL6TUak25rd84TBfoYJqi1U1Fpq7RmgDUCoOOZ+QSTDqaNL7kATGMeqtt6PlKd6uoeNYjfKEyjRmCB54hXLi8+3d0eSPCibh6UX5Eq4g9qeTWittkhEA//98MQvzPm/eietCnNwTDI+Mp6dGZdk7G6lVAF8hY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=h7wdCHUj; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="h7wdCHUj" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=j5oxcJP2A8Odjp+ntNsOu7pyOW3a2wG4g7laIEkEmao=; t=1709110150; x=1710319750; b=h7wdCHUjj4Otbd6jlKOGe9yhZCOA77ZPFlTd8yxJ5clNKOl olX6CwSB8dl5oTv6qrhjY0JUKS0+QmpDVihWesl/xdqCKxq9xSdWynbXkfAM6duACLzoH9rEE4Lb9 rP9ZBfcENw0D2aM3uyMPF0BnZugoUjgecvoL8aaV8xMs9QcBd0dehJ32pM6vzeIsW52dEgIvKGUuE YgsuD4l3b6iDcI5grbdzAMoyGxshAexqWs6NNs2V7/8qAF9tVLGW4EREVALz/IOsHH7QjVpdTYghU yosOVk0ZcOIaUPyi5ju2IT+h6h594p/T35du51GSOgieH/aEjv13vBWzr3+BriwA==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rfFch-0000000C0BC-1RZf; Wed, 28 Feb 2024 09:49:07 +0100 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg , Miriam Rachel Korenblit Subject: [PATCH 4/8] wifi: mac80211: remove unnecessary ML element checks Date: Wed, 28 Feb 2024 09:48:12 +0100 Message-ID: <20240228094901.9e32c4b63875.Ia2ee0aafdc8a48bd21b485cc36a9866f950d781b@changeid> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240228084901.18661-10-johannes@sipsolutions.net> References: <20240228084901.18661-10-johannes@sipsolutions.net> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Johannes Berg Given the prior changes to ieee80211_mle_size_ok(), we can now pass NULL to for_each_mle_subelement(), so no longer need to check for that here explicitly. Reviewed-by: Miriam Rachel Korenblit Signed-off-by: Johannes Berg --- net/mac80211/parse.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/net/mac80211/parse.c b/net/mac80211/parse.c index ae0f14bd952a..d231aaecc219 100644 --- a/net/mac80211/parse.c +++ b/net/mac80211/parse.c @@ -720,9 +720,6 @@ static void ieee80211_mle_get_sta_prof(struct ieee802_11_elems *elems, ssize_t ml_len = elems->ml_basic_len; const struct element *sub; - if (!ml || !ml_len) - return; - for_each_mle_subelement(sub, (u8 *)ml, ml_len) { struct ieee80211_mle_per_sta_profile *prof = (void *)sub->data; ssize_t sta_prof_len; From patchwork Wed Feb 28 08:48:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 777445 Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A651B2DF9C for ; Wed, 28 Feb 2024 08:49:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709110152; cv=none; b=Hecm75qrdCJ4F7hAjQ5Yq5VTlbsUu4JEeUKrTtJJqNNopHHY6UvfGj/0mZbNPjlqmeSLJA/jGtT6F1MgqaEQ9jDHlKbIOOOzJT9uVKCgl57mRlb3stfXcFXsGAuiV5fjfBnVXHHQU52iyjt1fJu/KpseXP9vlWeHl8ih/7Lku0U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709110152; c=relaxed/simple; bh=rTb15V8rDc7LSAzYJ0GUzTKgUwcZMpOmZl5oHUesEJg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CVarmno/pLor4eV8kMaT2nyy9P/alRxhNTfQQ887O0tKJCaW2hXFnqB3O03JSxYYW1/j/xZOpGHeyc6hSm1uakKxeKy24tNJyFo5CuhljvZWBS+dTmA3pP1afmcZRqy0B8F9/Iznbt+tokXeigTkcmRobJZ62E9Y1iFexbvZrMk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=oq2/VRqt; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="oq2/VRqt" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=ajKgSRWet0ej2y15vhBrgm2GY6PdeKA0gehcuNwkqiM=; t=1709110150; x=1710319750; b=oq2/VRqtWsTvmX1UkIKuHgoHkIzSIT6fNvH2l3ndTg8Zb16 68lmPtMfoqTeRk7mAs/k0oQrzNKdk4YhAJKJjPLkWc4Le/9QimC4ma4fWIYJxTVcfVoZi0W6FKs0M Pwxo5tJFzb4Vnp+9CTKgegE+Ar6H5KI7yUV4RqPJgBHbEgnHtG8n0e/PuCgmUbJRNOeQG33ifXEAB AsQfZQpByX6qzLEw0nqQLmKefss42dBxfw7o7tgDw6pGTMAF0c4v//e4kK4q4cRAW42Dpr7FK+Zpv Csfr6GrWO+a6iYIiLSWT44fCip97Szjv8MJ5lmeOE+iOyHDg6+JnNFQhALFqUsvw==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rfFch-0000000C0BC-46t8; Wed, 28 Feb 2024 09:49:08 +0100 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg , Ilan Peer , Miriam Rachel Korenblit Subject: [PATCH 5/8] wifi: mac80211: simplify multi-link element parsing Date: Wed, 28 Feb 2024 09:48:13 +0100 Message-ID: <20240228094902.e0115da4d2a6.I89a80f7387eabef8df3955485d4a583ed024c5b1@changeid> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240228084901.18661-10-johannes@sipsolutions.net> References: <20240228084901.18661-10-johannes@sipsolutions.net> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Johannes Berg We shouldn't assign elems->ml_basic{,len} before defragmentation, and we don't need elems->ml_reconf{,len} at all since we don't do defragmentation. Clean that up a bit. This does require always defragmention even when it may not be needed, but that's easier to reason about. Reviewed-by: Ilan Peer Reviewed-by: Miriam Rachel Korenblit Signed-off-by: Johannes Berg --- net/mac80211/ieee80211_i.h | 6 ++---- net/mac80211/mlme.c | 6 ++---- net/mac80211/parse.c | 12 ++++-------- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 4bec625a84d1..e8ca9ad12e62 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1736,7 +1736,6 @@ struct ieee802_11_elems { const struct ieee80211_eht_cap_elem *eht_cap; const struct ieee80211_eht_operation *eht_operation; const struct ieee80211_multi_link_elem *ml_basic; - const struct ieee80211_multi_link_elem *ml_reconf; const struct ieee80211_bandwidth_indication *bandwidth_indication; const struct ieee80211_ttlm_elem *ttlm[IEEE80211_TTLM_MAX_CNT]; @@ -1764,12 +1763,11 @@ struct ieee802_11_elems { /* mult-link element can be de-fragmented and thus u8 is not sufficient */ size_t ml_basic_len; - size_t ml_reconf_len; - /* The basic Multi-Link element in the original IEs */ + /* The basic Multi-Link element in the original elements */ const struct element *ml_basic_elem; - /* The reconfiguration Multi-Link element in the original IEs */ + /* The reconfiguration Multi-Link element in the original elements */ const struct element *ml_reconf_elem; u8 ttlm_num; diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index d5678a817771..f4544f167005 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -5760,7 +5760,7 @@ static void ieee80211_ml_reconfiguration(struct ieee80211_sub_if_data *sdata, u8 link_id; u32 delay; - if (!ieee80211_vif_is_mld(&sdata->vif) || !elems->ml_reconf) + if (!ieee80211_vif_is_mld(&sdata->vif) || !elems->ml_reconf_elem) return; ml_len = cfg80211_defragment_element(elems->ml_reconf_elem, @@ -5773,9 +5773,7 @@ static void ieee80211_ml_reconfiguration(struct ieee80211_sub_if_data *sdata, if (ml_len < 0) return; - elems->ml_reconf = (const void *)elems->scratch_pos; - elems->ml_reconf_len = ml_len; - ml = elems->ml_reconf; + ml = (const void *)elems->scratch_pos; /* Directly parse the sub elements as the common information doesn't * hold any useful information. diff --git a/net/mac80211/parse.c b/net/mac80211/parse.c index d231aaecc219..8bdf6e7efa58 100644 --- a/net/mac80211/parse.c +++ b/net/mac80211/parse.c @@ -129,19 +129,15 @@ ieee80211_parse_extension_element(u32 *crc, switch (le16_get_bits(mle->control, IEEE80211_ML_CONTROL_TYPE)) { case IEEE80211_ML_CONTROL_TYPE_BASIC: - if (elems->ml_basic) { + if (elems->ml_basic_elem) { elems->parse_error |= IEEE80211_PARSE_ERR_DUP_NEST_ML_BASIC; break; } elems->ml_basic_elem = (void *)elem; - elems->ml_basic = data; - elems->ml_basic_len = len; break; case IEEE80211_ML_CONTROL_TYPE_RECONF: elems->ml_reconf_elem = (void *)elem; - elems->ml_reconf = data; - elems->ml_reconf_len = len; break; default: break; @@ -776,9 +772,6 @@ static void ieee80211_mle_parse_link(struct ieee802_11_elems *elems, const struct element *non_inherit = NULL; const u8 *end; - if (params->link_id == -1) - return; - ml_len = cfg80211_defragment_element(elems->ml_basic_elem, elems->ie_start, elems->total_len, @@ -795,6 +788,9 @@ static void ieee80211_mle_parse_link(struct ieee802_11_elems *elems, elems->ml_basic_len = ml_len; elems->scratch_pos += ml_len; + if (params->link_id == -1) + return; + ieee80211_mle_get_sta_prof(elems, params->link_id); prof = elems->prof; From patchwork Wed Feb 28 08:48:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 776845 Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D72B02E645 for ; Wed, 28 Feb 2024 08:49:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709110153; cv=none; b=Md0DUAYgw9cpJlum8BaM0fOUV35miR8plY4Plc3MeeMJaYgwqBX7AhBxcM1IlZ2AeW8rq3D6FsxV4BoGcCzBF9SMpoehPsyXMVDl5oSYM5FAuDNMtB5+QqqtYFHfx7LXZJEtsdGiqvLVNbGfuG5csas3V4WA1Haym44Jw29FRKo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709110153; c=relaxed/simple; bh=5GLVSC06hdTgmKYD7ptGjvB2NStnUMElXHaKdFIjb68=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e1D0APNR40smIx0zergWIv5jo5W9QIOcC097DmdrI5ITExEHCnofgOCMsEso6LGCof4Yr5ohu0aXr74KxobmthCFZaF1eZyr5iMircW4FlWvnBI8Kwi+OU8XhixJ3nukobdUr3YdBcThVW1FR3IhPp/bq2iCgY+A3MnJpFOyFtQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=ECnj++LN; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="ECnj++LN" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=t/w5p9Ddd7KWaBeviRr03DEa6DuT8tU/8RU+wi9yKDQ=; t=1709110151; x=1710319751; b=ECnj++LNeJ3gUvqJKrcDRvQhvkWSaFi0mW8YXbS92muxibT WIO7Emw+7jcEfMvRLbpF/AWDZenVaCfUcrCNvp64+BFHZwp8mS/o8Dut/wpacDImnHgEqROw0cH8R bapDpYBCehhoMrafQe9/H0Rluj4WX4f2TMeYD7OL0eRS/bGEPW/ZEGqHYz0iyVS7UiGaexgEeZE7n +2NtRNXY8bWvzxFeyEpi0cyIYEyb14xiqAD5xtilIbPgRp32t0PHxeqieU7vnGnS9iJCZCBntESwL 08p1P+1FoEI4BoU1gAp35gpVCAP9QPVO8cgWN0emRnm6GTTWx/w0zp/XJOERJyMw==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rfFci-0000000C0BC-3tq1; Wed, 28 Feb 2024 09:49:09 +0100 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg , Miriam Rachel Korenblit Subject: [PATCH 6/8] wifi: mac80211: defragment reconfiguration MLE when parsing Date: Wed, 28 Feb 2024 09:48:14 +0100 Message-ID: <20240228094902.92936a3ce216.I4b736ce4fdc199fa1d6b00d00032f448c873a8b4@changeid> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240228084901.18661-10-johannes@sipsolutions.net> References: <20240228084901.18661-10-johannes@sipsolutions.net> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Johannes Berg Using the scratch buffer (without advancing it) here in the mlme.c code seems somewhat wrong, defragment the reconfig multi-link element already when parsing. This might be a bit more work in certain cases, but makes the whole thing more regular. Reviewed-by: Miriam Rachel Korenblit Signed-off-by: Johannes Berg --- net/mac80211/ieee80211_i.h | 2 ++ net/mac80211/mlme.c | 19 +++---------------- net/mac80211/parse.c | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index e8ca9ad12e62..768f614731a7 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1736,6 +1736,7 @@ struct ieee802_11_elems { const struct ieee80211_eht_cap_elem *eht_cap; const struct ieee80211_eht_operation *eht_operation; const struct ieee80211_multi_link_elem *ml_basic; + const struct ieee80211_multi_link_elem *ml_reconf; const struct ieee80211_bandwidth_indication *bandwidth_indication; const struct ieee80211_ttlm_elem *ttlm[IEEE80211_TTLM_MAX_CNT]; @@ -1763,6 +1764,7 @@ struct ieee802_11_elems { /* mult-link element can be de-fragmented and thus u8 is not sufficient */ size_t ml_basic_len; + size_t ml_reconf_len; /* The basic Multi-Link element in the original elements */ const struct element *ml_basic_elem; diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index f4544f167005..e6a82f28a7c6 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -5752,33 +5752,20 @@ static void ieee80211_ml_reconf_work(struct wiphy *wiphy, static void ieee80211_ml_reconfiguration(struct ieee80211_sub_if_data *sdata, struct ieee802_11_elems *elems) { - const struct ieee80211_multi_link_elem *ml; const struct element *sub; - ssize_t ml_len; unsigned long removed_links = 0; u16 link_removal_timeout[IEEE80211_MLD_MAX_NUM_LINKS] = {}; u8 link_id; u32 delay; - if (!ieee80211_vif_is_mld(&sdata->vif) || !elems->ml_reconf_elem) + if (!ieee80211_vif_is_mld(&sdata->vif) || !elems->ml_reconf) return; - ml_len = cfg80211_defragment_element(elems->ml_reconf_elem, - elems->ie_start, - elems->total_len, - elems->scratch_pos, - elems->scratch + elems->scratch_len - - elems->scratch_pos, - WLAN_EID_FRAGMENT); - if (ml_len < 0) - return; - - ml = (const void *)elems->scratch_pos; - /* Directly parse the sub elements as the common information doesn't * hold any useful information. */ - for_each_mle_subelement(sub, (u8 *)ml, ml_len) { + for_each_mle_subelement(sub, (const u8 *)elems->ml_reconf, + elems->ml_reconf_len) { struct ieee80211_mle_per_sta_profile *prof = (void *)sub->data; u8 *pos = prof->variable; u16 control; diff --git a/net/mac80211/parse.c b/net/mac80211/parse.c index 8bdf6e7efa58..804323858977 100644 --- a/net/mac80211/parse.c +++ b/net/mac80211/parse.c @@ -819,6 +819,26 @@ static void ieee80211_mle_parse_link(struct ieee802_11_elems *elems, _ieee802_11_parse_elems_full(&sub, elems, non_inherit); } +static void +ieee80211_mle_defrag_reconf(struct ieee802_11_elems *elems) +{ + ssize_t ml_len; + + ml_len = cfg80211_defragment_element(elems->ml_reconf_elem, + elems->ie_start, + elems->total_len, + elems->scratch_pos, + elems->scratch + + elems->scratch_len - + elems->scratch_pos, + WLAN_EID_FRAGMENT); + if (ml_len < 0) + return; + elems->ml_reconf = (void *)elems->scratch_pos; + elems->ml_reconf_len = ml_len; + elems->scratch_pos += ml_len; +} + struct ieee802_11_elems * ieee802_11_parse_elems_full(struct ieee80211_elems_parse_params *params) { @@ -864,6 +884,8 @@ ieee802_11_parse_elems_full(struct ieee80211_elems_parse_params *params) ieee80211_mle_parse_link(elems, params); + ieee80211_mle_defrag_reconf(elems); + if (elems->tim && !elems->parse_error) { const struct ieee80211_tim_ie *tim_ie = elems->tim; From patchwork Wed Feb 28 08:48:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 776844 Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBBEF2E852 for ; Wed, 28 Feb 2024 08:49:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709110154; cv=none; b=VAlcbuVnwOJ8/9C9lHjMflCYuwSnuAHisMbrdNJeG3alVL/rbFI0CNdvXb8GULA9sUyK2O48Ll8EtqkhCgLeGAs5dqTR8DRTLhUtx/sEj6UoSGOjOgKn+4k1GBu2iVFuLilEnjeR65Ibm8rWXkE0FIPNT2UZb1yocOtFh5X/ZVY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709110154; c=relaxed/simple; bh=6qsFQwGKR7PDtIFw/0jhbaNki1V6r/CkU0vKb0uBeBo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AMqYBMFguUzVCh8YgnC3+DIIg7c3BPrG30fVjOm2c4yFzZfORcVAn2aZBDnYCnR9rCx6uOZEccatjMIaHS5FuFVkFnM4I6WZInClRQmUT8CUAPIZaFzZE25+/pi/XV5uiikqMScoAu2XsW/MyPqo/pobAiFsDAolOZzW17evhqw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=C9MSgolM; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="C9MSgolM" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=L/QMi87Nm5EYaVKhY/t/4j9baOhGOCRe35/W+r2riLU=; t=1709110152; x=1710319752; b=C9MSgolMsS/pFtgFyvgKzyGX6jhQo83taJbOkOuCDt/MdH7 dJeNVjzmIVDa8wJwQTYXo3lODtW/w4huISLHtAqe/KSM27exjAzGZe0KiUrDE2aY1UZu8sDj27fWF xznoqn04wpQdGOblNw3yzrUYnR3daj9Nor/A41pIFJBDvg9MGY7ExijJuI6niyx1kJ8g6BraMZdQu ZwnKhelc0LRluUsto+9+r9Y3D+N3lwrovVLwIFtZMbmLh727OYmSZB+sY/OX0Gel2IPWPKKhy/xyo oDx8if5I2OKyp/geXlal7MRHITLmFtQkLcNT6xQViP/pwTCUjC6y3FWOJkLiCyHQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rfFcj-0000000C0BC-2jEm; Wed, 28 Feb 2024 09:49:09 +0100 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg , Miriam Rachel Korenblit , Ilan Peer Subject: [PATCH 7/8] wifi: mac80211: remove unneeded scratch_len subtraction Date: Wed, 28 Feb 2024 09:48:15 +0100 Message-ID: <20240228094902.44e07cfa9e63.I7a9758fb9bc6b726aac49804f2f05cd521bc4128@changeid> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240228084901.18661-10-johannes@sipsolutions.net> References: <20240228084901.18661-10-johannes@sipsolutions.net> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Johannes Berg We're always using "scratch + len - pos", so we don't need to subtract here to calculate the remaining length. Remove the unnecessary subtraction. Reviewed-by: Miriam Rachel Korenblit Reviewed-by: Ilan Peer Signed-off-by: Johannes Berg --- net/mac80211/parse.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/mac80211/parse.c b/net/mac80211/parse.c index 804323858977..73e52504ed97 100644 --- a/net/mac80211/parse.c +++ b/net/mac80211/parse.c @@ -862,7 +862,6 @@ ieee802_11_parse_elems_full(struct ieee80211_elems_parse_params *params) elems, params->bss, nontransmitted_profile); elems->scratch_pos += nontransmitted_profile_len; - elems->scratch_len -= nontransmitted_profile_len; non_inherit = cfg80211_find_ext_elem(WLAN_EID_EXT_NON_INHERITANCE, nontransmitted_profile, nontransmitted_profile_len); From patchwork Wed Feb 28 08:48:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 777443 Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF1D52E85A for ; Wed, 28 Feb 2024 08:49:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709110154; cv=none; b=qECkWDsDeeG0E9rG3SYkwxoXDAz0YDWwfKHKrkjHwAv7KsgrsR+84LzRyChx6PPjOjAthspbxE1JP1eFFacvCGGU38XKrrJ3smyAlAq0GRBkrlR5CrxZsEDsOLFunLh7rDKLMEqvko0QVSccV41p5Ze91mk0EZKqzUH5qEWD74M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709110154; c=relaxed/simple; bh=w5OJ7SG6m+y+ja+YxEgUDb3vB1FygnVhTTn9pf54x8g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iTRDQ1gZk6gWcfwm4L4uCthBo3m0egQgXkXseU/kDfr3bhUu9x9mRfM5KGBTl4/xweLQWoqTyo0QGbfFKb4UNKWXtp5xenPi9QVk6rXgEEfLuzU9Jq020FXm7QWt1T/XXeQIPt7ofvH/3dtk1B0Lh9eU1QO17Tz3OvxJbBwHDpk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=TqMN7+1U; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="TqMN7+1U" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=fKy7hk9Gzp/aoBu5vFcT58jI969LD0613pV0ktQXC7Y=; t=1709110152; x=1710319752; b=TqMN7+1UaiwhEYl8dB3k7yS0RYNRA7+rZcIWY0DgPa339D/ bvHDf2037/xvtJ1B5SgRsjGNeKm9nJy90NnOePASu4GFbA8bvzp2J4f1O4hdAUnbSYMEhet0ZdgVC wZVbIVs2ejx5PL8Mu2t0Rv33uj7PAxoydaLZuDIa4De9RxnaOTAZ0PN3mQGTzl/3r4RvEpQ1Sb/gl J2UcT1bK8ccmoa1naZCRNN16JlIse52ndn+4Gs9fc6cOx39G8sLQIhqevN9mSxjR9Txr3+kaPafBK 2xq6+IwY4wxxuMIRryobuq8eapVDDiE9NCDWRPe71YFSc5Q8Z6xMREo9FD9MEKQA==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rfFck-0000000C0BC-1QK0; Wed, 28 Feb 2024 09:49:10 +0100 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg , Miriam Rachel Korenblit Subject: [PATCH 8/8] wifi: mac80211: hide element parsing internals Date: Wed, 28 Feb 2024 09:48:16 +0100 Message-ID: <20240228094902.19c610b529e2.Ie7ea2dcb6713911590ace6583a4748f32dc37df2@changeid> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240228084901.18661-10-johannes@sipsolutions.net> References: <20240228084901.18661-10-johannes@sipsolutions.net> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Johannes Berg Rework the data structures to hide element parsing internals from the users. Reviewed-by: Miriam Rachel Korenblit Signed-off-by: Johannes Berg --- net/mac80211/ieee80211_i.h | 14 ----- net/mac80211/parse.c | 118 ++++++++++++++++++++++++------------- net/mac80211/tests/elems.c | 4 +- 3 files changed, 78 insertions(+), 58 deletions(-) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 768f614731a7..a8ac238bd197 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1766,12 +1766,6 @@ struct ieee802_11_elems { size_t ml_basic_len; size_t ml_reconf_len; - /* The basic Multi-Link element in the original elements */ - const struct element *ml_basic_elem; - - /* The reconfiguration Multi-Link element in the original elements */ - const struct element *ml_reconf_elem; - u8 ttlm_num; /* @@ -1784,14 +1778,6 @@ struct ieee802_11_elems { /* whether/which parse error occurred while retrieving these elements */ u8 parse_error; - - /* - * scratch buffer that can be used for various element parsing related - * tasks, e.g., element de-fragmentation etc. - */ - size_t scratch_len; - u8 *scratch_pos; - u8 scratch[] __counted_by(scratch_len); }; static inline struct ieee80211_local *hw_to_local( diff --git a/net/mac80211/parse.c b/net/mac80211/parse.c index 73e52504ed97..55e5497f8978 100644 --- a/net/mac80211/parse.c +++ b/net/mac80211/parse.c @@ -34,12 +34,32 @@ #include "led.h" #include "wep.h" +struct ieee80211_elems_parse { + /* must be first for kfree to work */ + struct ieee802_11_elems elems; + + /* The basic Multi-Link element in the original elements */ + const struct element *ml_basic_elem; + + /* The reconfiguration Multi-Link element in the original elements */ + const struct element *ml_reconf_elem; + + /* + * scratch buffer that can be used for various element parsing related + * tasks, e.g., element de-fragmentation etc. + */ + size_t scratch_len; + u8 *scratch_pos; + u8 scratch[] __counted_by(scratch_len); +}; + static void ieee80211_parse_extension_element(u32 *crc, const struct element *elem, - struct ieee802_11_elems *elems, + struct ieee80211_elems_parse *elems_parse, struct ieee80211_elems_parse_params *params) { + struct ieee802_11_elems *elems = &elems_parse->elems; const void *data = elem->data + 1; bool calc_crc = false; u8 len; @@ -129,15 +149,15 @@ ieee80211_parse_extension_element(u32 *crc, switch (le16_get_bits(mle->control, IEEE80211_ML_CONTROL_TYPE)) { case IEEE80211_ML_CONTROL_TYPE_BASIC: - if (elems->ml_basic_elem) { + if (elems_parse->ml_basic_elem) { elems->parse_error |= IEEE80211_PARSE_ERR_DUP_NEST_ML_BASIC; break; } - elems->ml_basic_elem = (void *)elem; + elems_parse->ml_basic_elem = elem; break; case IEEE80211_ML_CONTROL_TYPE_RECONF: - elems->ml_reconf_elem = (void *)elem; + elems_parse->ml_reconf_elem = elem; break; default: break; @@ -169,9 +189,10 @@ ieee80211_parse_extension_element(u32 *crc, static u32 _ieee802_11_parse_elems_full(struct ieee80211_elems_parse_params *params, - struct ieee802_11_elems *elems, + struct ieee80211_elems_parse *elems_parse, const struct element *check_inherit) { + struct ieee802_11_elems *elems = &elems_parse->elems; const struct element *elem; bool calc_crc = params->filter != 0; DECLARE_BITMAP(seen_elems, 256); @@ -586,7 +607,8 @@ _ieee802_11_parse_elems_full(struct ieee80211_elems_parse_params *params, case WLAN_EID_EXTENSION: ieee80211_parse_extension_element(calc_crc ? &crc : NULL, - elem, elems, params); + elem, elems_parse, + params); break; case WLAN_EID_S1G_CAPABILITIES: if (params->mode != IEEE80211_CONN_MODE_S1G) @@ -709,9 +731,11 @@ static size_t ieee802_11_find_bssid_profile(const u8 *start, size_t len, return found ? profile_len : 0; } -static void ieee80211_mle_get_sta_prof(struct ieee802_11_elems *elems, - u8 link_id) +static void +ieee80211_mle_get_sta_prof(struct ieee80211_elems_parse *elems_parse, + u8 link_id) { + struct ieee802_11_elems *elems = &elems_parse->elems; const struct ieee80211_multi_link_elem *ml = elems->ml_basic; ssize_t ml_len = elems->ml_basic_len; const struct element *sub; @@ -741,26 +765,27 @@ static void ieee80211_mle_get_sta_prof(struct ieee802_11_elems *elems, sta_prof_len = cfg80211_defragment_element(sub, (u8 *)ml, ml_len, - elems->scratch_pos, - elems->scratch + - elems->scratch_len - - elems->scratch_pos, + elems_parse->scratch_pos, + elems_parse->scratch + + elems_parse->scratch_len - + elems_parse->scratch_pos, IEEE80211_MLE_SUBELEM_FRAGMENT); if (sta_prof_len < 0) return; - elems->prof = (void *)elems->scratch_pos; + elems->prof = (void *)elems_parse->scratch_pos; elems->sta_prof_len = sta_prof_len; - elems->scratch_pos += sta_prof_len; + elems_parse->scratch_pos += sta_prof_len; return; } } -static void ieee80211_mle_parse_link(struct ieee802_11_elems *elems, +static void ieee80211_mle_parse_link(struct ieee80211_elems_parse *elems_parse, struct ieee80211_elems_parse_params *params) { + struct ieee802_11_elems *elems = &elems_parse->elems; struct ieee80211_mle_per_sta_profile *prof; struct ieee80211_elems_parse_params sub = { .mode = params->mode, @@ -772,26 +797,26 @@ static void ieee80211_mle_parse_link(struct ieee802_11_elems *elems, const struct element *non_inherit = NULL; const u8 *end; - ml_len = cfg80211_defragment_element(elems->ml_basic_elem, + ml_len = cfg80211_defragment_element(elems_parse->ml_basic_elem, elems->ie_start, elems->total_len, - elems->scratch_pos, - elems->scratch + - elems->scratch_len - - elems->scratch_pos, + elems_parse->scratch_pos, + elems_parse->scratch + + elems_parse->scratch_len - + elems_parse->scratch_pos, WLAN_EID_FRAGMENT); if (ml_len < 0) return; - elems->ml_basic = (const void *)elems->scratch_pos; + elems->ml_basic = (const void *)elems_parse->scratch_pos; elems->ml_basic_len = ml_len; - elems->scratch_pos += ml_len; + elems_parse->scratch_pos += ml_len; if (params->link_id == -1) return; - ieee80211_mle_get_sta_prof(elems, params->link_id); + ieee80211_mle_get_sta_prof(elems_parse, params->link_id); prof = elems->prof; if (!prof) @@ -816,57 +841,66 @@ static void ieee80211_mle_parse_link(struct ieee802_11_elems *elems, non_inherit = cfg80211_find_ext_elem(WLAN_EID_EXT_NON_INHERITANCE, sub.start, sub.len); - _ieee802_11_parse_elems_full(&sub, elems, non_inherit); + _ieee802_11_parse_elems_full(&sub, elems_parse, non_inherit); } static void -ieee80211_mle_defrag_reconf(struct ieee802_11_elems *elems) +ieee80211_mle_defrag_reconf(struct ieee80211_elems_parse *elems_parse) { + struct ieee802_11_elems *elems = &elems_parse->elems; ssize_t ml_len; - ml_len = cfg80211_defragment_element(elems->ml_reconf_elem, + ml_len = cfg80211_defragment_element(elems_parse->ml_reconf_elem, elems->ie_start, elems->total_len, - elems->scratch_pos, - elems->scratch + - elems->scratch_len - - elems->scratch_pos, + elems_parse->scratch_pos, + elems_parse->scratch + + elems_parse->scratch_len - + elems_parse->scratch_pos, WLAN_EID_FRAGMENT); if (ml_len < 0) return; - elems->ml_reconf = (void *)elems->scratch_pos; + elems->ml_reconf = (void *)elems_parse->scratch_pos; elems->ml_reconf_len = ml_len; - elems->scratch_pos += ml_len; + elems_parse->scratch_pos += ml_len; } struct ieee802_11_elems * ieee802_11_parse_elems_full(struct ieee80211_elems_parse_params *params) { + struct ieee80211_elems_parse *elems_parse; struct ieee802_11_elems *elems; const struct element *non_inherit = NULL; u8 *nontransmitted_profile; int nontransmitted_profile_len = 0; size_t scratch_len = 3 * params->len; - elems = kzalloc(struct_size(elems, scratch, scratch_len), GFP_ATOMIC); - if (!elems) + BUILD_BUG_ON(offsetof(typeof(*elems_parse), elems) != 0); + + elems_parse = kzalloc(struct_size(elems_parse, scratch, scratch_len), + GFP_ATOMIC); + if (!elems_parse) return NULL; + + elems_parse->scratch_len = scratch_len; + elems_parse->scratch_pos = elems_parse->scratch; + + elems = &elems_parse->elems; elems->ie_start = params->start; elems->total_len = params->len; - elems->scratch_len = scratch_len; - elems->scratch_pos = elems->scratch; - nontransmitted_profile = elems->scratch_pos; + nontransmitted_profile = elems_parse->scratch_pos; nontransmitted_profile_len = ieee802_11_find_bssid_profile(params->start, params->len, elems, params->bss, nontransmitted_profile); - elems->scratch_pos += nontransmitted_profile_len; + elems_parse->scratch_pos += nontransmitted_profile_len; non_inherit = cfg80211_find_ext_elem(WLAN_EID_EXT_NON_INHERITANCE, nontransmitted_profile, nontransmitted_profile_len); - elems->crc = _ieee802_11_parse_elems_full(params, elems, non_inherit); + elems->crc = _ieee802_11_parse_elems_full(params, elems_parse, + non_inherit); /* Override with nontransmitted profile, if found */ if (nontransmitted_profile_len) { @@ -878,12 +912,12 @@ ieee802_11_parse_elems_full(struct ieee80211_elems_parse_params *params) .link_id = params->link_id, }; - _ieee802_11_parse_elems_full(&sub, elems, NULL); + _ieee802_11_parse_elems_full(&sub, elems_parse, NULL); } - ieee80211_mle_parse_link(elems, params); + ieee80211_mle_parse_link(elems_parse, params); - ieee80211_mle_defrag_reconf(elems); + ieee80211_mle_defrag_reconf(elems_parse); if (elems->tim && !elems->parse_error) { const struct ieee80211_tim_ie *tim_ie = elems->tim; diff --git a/net/mac80211/tests/elems.c b/net/mac80211/tests/elems.c index 30fc0acb7ac2..a413ba29f759 100644 --- a/net/mac80211/tests/elems.c +++ b/net/mac80211/tests/elems.c @@ -2,7 +2,7 @@ /* * KUnit tests for element parsing * - * Copyright (C) 2023 Intel Corporation + * Copyright (C) 2023-2024 Intel Corporation */ #include #include "../ieee80211_i.h" @@ -69,7 +69,7 @@ static void mle_defrag(struct kunit *test) if (IS_ERR_OR_NULL(parsed)) goto free_skb; - KUNIT_EXPECT_NOT_NULL(test, parsed->ml_basic_elem); + KUNIT_EXPECT_NOT_NULL(test, parsed->ml_basic); KUNIT_EXPECT_EQ(test, parsed->ml_basic_len, 2 /* control */ +