From patchwork Tue Feb 20 13:18:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1901467 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=tpXwR77B; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=Qqj9HAsE; 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 4TfKkT5cXMz23cy for ; Wed, 21 Feb 2024 00:19:29 +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=SitSo0EHa2ruI0T3J47ZQofO9/BP8t2EJ73gogXn9T0=; b=tpXwR77BOpnfLo OiYaxnKHeHtdGRiNmqSbxL6BZR2XoUkRjrhDiZRUiVLxX6qkHWgSg7MU5n4mCLKM0vy3mw/n+d+sn bdzbglziU3yRr7dH+5Wmi3KznCbzyHkZKQQndWVwfWOnfabj6d4RdDPcc1e7FcGIFIoyirwxIlC0Q pYcuy+T2TcJjTigq+rY/yY1J7JLKewObzZHaNJ1SOL3pVRkSaRTyvKlde7JNw01zU3+LIitMif1a/ r5yxjzG0wZEzYcD1AMPZF5kOgcUYueAHhCK37DRze/AXYLs8B9inR1BSlId/EVa5nNBQVvp29XCiD bKAOZMvEMiY7X+ZrnDgw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1g-0000000Ep8l-2neU; Tue, 20 Feb 2024 13:19:12 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1Y-0000000Eozp-3hxT for hostap@lists.infradead.org; Tue, 20 Feb 2024 13:19:07 +0000 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=lcxwbcVZtt/uJehEL8vVCnBrXxOhFWRHlv2+87XT68U=; t=1708435141; x=1709644741; b=Qqj9HAsEE2bAMCsk7V3sZmBgfl8V2WzXZLe6JJgRUwJckw8 EuVPqLAt6k/UG0vXuSpTv15w81PvC7GVsJ4lSviqgGJIArjLZnbTFNHNwtOylOf1qxrDIfLfBBzEn HcwxmBK4AasbuJhKY9DvtJ7e5bOoD0mZSA1edn3vytXXn6PIqDiTEVolPg+T3CEy1VI6WbREJ+sAM TNAxIIO2DUFJjDOaxy2tiYjKZq+t/Qmnj/3/it9vxWb94tvYbLaMPXh+GMfxH+qMiWHVkq/7B93zj aWBW5wqNsyWXoi2tW0RJZcDa4xmk/Cpq3veCmrevLlKy1111KcXxPvyk/4NCXT+g==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rcQ1S-00000000ugq-0msX; Tue, 20 Feb 2024 14:18:58 +0100 From: benjamin@sipsolutions.net To: hostap@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH v2 01/20] tests: Add missing scan cache flush Date: Tue, 20 Feb 2024 14:18:08 +0100 Message-ID: <20240220131827.17766-2-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220131827.17766-1-benjamin@sipsolutions.net> References: <20240220131827.17766-1-benjamin@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240220_051905_235796_3AE45115 X-CRM114-Status: UNSURE ( 8.82 ) X-CRM114-Notice: Please train this message. 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: From: Benjamin Berg Otherwise a BSS from a previous test may still be in the cache. Signed-off-by: Benjamin Berg --- tests/hwsim/test_ap_hs20.py | 1 + 1 file changed, 1 insertion(+) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches 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_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.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 From: Benjamin Berg Otherwise a BSS from a previous test may still be in the cache. Signed-off-by: Benjamin Berg --- tests/hwsim/test_ap_hs20.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/hwsim/test_ap_hs20.py b/tests/hwsim/test_ap_hs20.py index 81becf04f..c1aebaa85 100644 --- a/tests/hwsim/test_ap_hs20.py +++ b/tests/hwsim/test_ap_hs20.py @@ -502,6 +502,7 @@ def test_ap_hs20_select(dev, apdev): params = hs20_ap_params() params['hessid'] = bssid hostapd.add_ap(apdev[0], params) + dev[0].flush_scan_cache() dev[0].hs20_enable() id = dev[0].add_cred_values({'realm': "example.com", 'username': "test", From patchwork Tue Feb 20 13:18:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1901473 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=h+aSf6i6; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=f5UwJehF; 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 4TfKkc3RLlz23d1 for ; Wed, 21 Feb 2024 00:19:36 +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=1Z+/2m2P4hLRq/fvjcORSLRxyw0OGDJEKYVYrRn1wiw=; b=h+aSf6i68AOM9r 3ZFZ3QSkewexjhN5E7DI7+IF1P/TFeQQvnfgS6R7q4Rt51Xvg8lrfJLnk2QdwDB+3kfTCYjA7Hauc pCyqsJksY32iEwMqrqM6bECR22CnezW+uPLprZPLp9NbowMbP4jjmOD3i2YUGo6ObWWOiw6RpytzR tioPj2iRnXarNzpvfBhyjAibGxV9e5eaermBQzvVOodcPoX/cesy5OuBGfiJ36pSM0a8iNWkIvok3 FmlMdGKDjMsUXBlWphrhSz6h7FgTB5bvyGhgz6QHk68fVCiMngoZcQHfxVy/NE0HctVnf1c3kAV8W qN1MePdC5clC5EmeVdng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1m-0000000EpCa-2TFD; Tue, 20 Feb 2024 13:19:18 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1Y-0000000Ep03-3iZm for hostap@lists.infradead.org; Tue, 20 Feb 2024 13:19:08 +0000 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=KNuKLpL0OvUvhLrTEQhobfR9WIUm/IoVriSXp9p9c8E=; t=1708435141; x=1709644741; b=f5UwJehFp7yn/YlgG/p/8PcNHR5yT1C7KTd0ewyjzSDW5Vm rhs5KVUxXmGVO0jzamnUQbPgIfm12nwvvsktYSJ1yVAQjdV+Bmws6YPZNqkct+lZofKrGcTu4T0QV qGexr14SDOz+0R2t6R/8EiEKRo0AMGb5Tia6cEJaMlqnARacSEfVSSvXgZr2f36/cdv+VymNpMZIX Xvji9OIs0N4+XcIL6Kq3MqkREDrPQCplXpQt38lKxGA/eRSrHUle+xpUJPYddKqx3IdCQ+IplA0LV +6LF50N9DAEDQ5pAGMvaNv/0Y3+3mKf/B1SJN8BxMsWUBBVLhCJAmWlbPW2ECNIA==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rcQ1S-00000000ugq-3skT; Tue, 20 Feb 2024 14:18:59 +0100 From: benjamin@sipsolutions.net To: hostap@lists.infradead.org Cc: Ilan Peer , Benjamin Berg Subject: [PATCH v2 02/20] nl80211: Explicitly differentiate between 5GHz mode and 6GHz mode Date: Tue, 20 Feb 2024 14:18:09 +0100 Message-ID: <20240220131827.17766-3-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220131827.17766-1-benjamin@sipsolutions.net> References: <20240220131827.17766-1-benjamin@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240220_051905_258817_657036A0 X-CRM114-Status: GOOD ( 16.72 ) 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: From: Ilan Peer When a device supports both the 5GHz band and the 6GHz band, these are reported as two separate modes, both with mode set to HOSTAPD_MODE_IEEE80211A. However, as these are different modes, each with i [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches 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_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.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 From: Ilan Peer When a device supports both the 5GHz band and the 6GHz band, these are reported as two separate modes, both with mode set to HOSTAPD_MODE_IEEE80211A. However, as these are different modes, each with its own characteristics, e.g., rates, capabilities etc., specifically differentiate between them by adding a flag to indicate whether the mode describes a 6GHz band capabilities or not. Signed-off-by: Ilan Peer Signed-off-by: Benjamin Berg --- src/ap/hw_features.c | 8 ++------ src/drivers/driver.h | 5 +++++ src/drivers/driver_nl80211_capa.c | 11 +++++++++-- wpa_supplicant/wpa_supplicant.c | 3 +-- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/ap/hw_features.c b/src/ap/hw_features.c index 596f2f020..fd401d78a 100644 --- a/src/ap/hw_features.c +++ b/src/ap/hw_features.c @@ -107,9 +107,7 @@ int hostapd_get_hw_features(struct hostapd_iface *iface) */ orig_mode_valid = true; mode = iface->current_mode->mode; - is_6ghz = mode == HOSTAPD_MODE_IEEE80211A && - iface->current_mode->num_channels > 0 && - is_6ghz_freq(iface->current_mode->channels[0].freq); + is_6ghz = iface->current_mode->is_6ghz; iface->current_mode = NULL; } hostapd_free_hw_features(iface->hw_features, iface->num_hw_features); @@ -1070,9 +1068,7 @@ static bool skip_mode(struct hostapd_iface *iface, return true; if (is_6ghz_op_class(iface->conf->op_class) && iface->freq == 0 && - (mode->mode != HOSTAPD_MODE_IEEE80211A || - mode->num_channels == 0 || - !is_6ghz_freq(mode->channels[0].freq))) + !mode->is_6ghz) return true; return false; diff --git a/src/drivers/driver.h b/src/drivers/driver.h index bff7502f1..3dcab8f31 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -246,6 +246,11 @@ struct hostapd_hw_modes { */ enum hostapd_hw_mode mode; + /** + * is_6ghz - true iff the mode information is for the 6GHz band + */ + bool is_6ghz; + /** * num_channels - Number of entries in the channels array */ diff --git a/src/drivers/driver_nl80211_capa.c b/src/drivers/driver_nl80211_capa.c index 59f1414ac..cef23b183 100644 --- a/src/drivers/driver_nl80211_capa.c +++ b/src/drivers/driver_nl80211_capa.c @@ -2156,6 +2156,9 @@ wpa_driver_nl80211_postprocess_modes(struct hostapd_hw_modes *modes, for (m = 0; m < *num_modes; m++) { if (!modes[m].num_channels) continue; + + modes[m].is_6ghz = false; + if (modes[m].channels[0].freq < 2000) { modes[m].num_channels = 0; continue; @@ -2167,10 +2170,14 @@ wpa_driver_nl80211_postprocess_modes(struct hostapd_hw_modes *modes, break; } } - } else if (modes[m].channels[0].freq > 50000) + } else if (modes[m].channels[0].freq > 50000) { modes[m].mode = HOSTAPD_MODE_IEEE80211AD; - else + } else if (is_6ghz_freq(modes[m].channels[0].freq)) { modes[m].mode = HOSTAPD_MODE_IEEE80211A; + modes[m].is_6ghz = true; + } else { + modes[m].mode = HOSTAPD_MODE_IEEE80211A; + } } /* Remove unsupported bands */ diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 91a213dac..cd37a20eb 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -9055,8 +9055,7 @@ struct hostapd_hw_modes * get_mode(struct hostapd_hw_modes *modes, if (modes[i].mode != mode || !modes[i].num_channels || !modes[i].channels) continue; - if ((!is_6ghz && !is_6ghz_freq(modes[i].channels[0].freq)) || - (is_6ghz && is_6ghz_freq(modes[i].channels[0].freq))) + if (is_6ghz == modes[i].is_6ghz) return &modes[i]; } From patchwork Tue Feb 20 13:18:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1901468 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=RtManr3V; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=fKilqHw/; 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 4TfKkW6Sbjz23d0 for ; Wed, 21 Feb 2024 00:19:31 +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=aXq7izEcA+PwMflt7m/3IrnWWHJLSCrJsC9NAqzU97Y=; b=RtManr3VLa4k6J 17f/FrpFo8MrKUIYVcUhT9wjQp7hRU7ToG+EHhSp1/JhGfZhD21LG6Jp4zHFVYbUqFnEmOiN55Ts6 6nWR9DsflMj7IMNIJ7b/QnfuQdsp5TS3pIEI8yNKjJmR44a9yEaelG/du2WEtJQ9VxTTXl1dktY72 V2iSkjLSsOMig7gJnBZjIvpyB/JDI3Xao7/mGNGdJz07BJk08eYMdvN/7UWbPwFJSPsfTGA3Ll1P5 P6TubiCClPxJX+MsVBk88NlyuUC9cWvVHA8UGxUbuvbqQK3T8J4gOagwk4OszxOMkFieXfc1BY0aX 8JTizNJo/y0CcSxtyrNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1c-0000000Ep5I-2xWt; Tue, 20 Feb 2024 13:19:08 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1Y-0000000Ep0W-3k2l for hostap@lists.infradead.org; Tue, 20 Feb 2024 13:19:06 +0000 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=ieL5DY+QuX/TzVCfm91a74W0ZtkajT0ylRiydVPtEAI=; t=1708435141; x=1709644741; b=fKilqHw/R3VJ7gOC3PO2wNM4gOd+DZzXC3yd2qHlwX9j5IY D2KI5/ebfvhrLItZysvVzvB0TojGpkPiyySLtpilFmUkzSsdAw53s1Jf5HkcJZlFsi3CWV+j/Up4v 15oPLonM4RgdTf0qSJ6XMo46oAScM5+WMY2pExa3TVtcaLc0r//oYTOBwFSH0LWUSBd1MP5GUp/PR nel6k7eTxqfAtdrAbQiEgj/b7JIU6V2FExb6wey94nU+i38vzqwMj7s0/NpZrMppF/KvmgDIcE+EE GzcaOcHlrI3VwqZH2Gf4B5P8qQ3SOsdyT9NEa0pkDET2Dic85ifXO4FFn0IXF/mA==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rcQ1T-00000000ugq-2dZp; Tue, 20 Feb 2024 14:18:59 +0100 From: benjamin@sipsolutions.net To: hostap@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH v2 03/20] nl80211: Fix link indexing in nl80211_connect_common Date: Tue, 20 Feb 2024 14:18:10 +0100 Message-ID: <20240220131827.17766-4-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220131827.17766-1-benjamin@sipsolutions.net> References: <20240220131827.17766-1-benjamin@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240220_051905_242190_A95B9B62 X-CRM114-Status: GOOD ( 14.19 ) 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: From: Benjamin Berg In some places the wrong index variable was used to access the link configuration. Fix this by simply using link_id instead of i. With this, the i loop variable is not needed anymore. We can simply always pass 0 to nla_nest_start. Also, the kernel does not care about the order that the links are provides, so just remove the spec [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches 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_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.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 From: Benjamin Berg In some places the wrong index variable was used to access the link configuration. Fix this by simply using link_id instead of i. With this, the i loop variable is not needed anymore. We can simply always pass 0 to nla_nest_start. Also, the kernel does not care about the order that the links are provides, so just remove the special handling for the assoc link. Signed-off-by: Benjamin Berg --- src/drivers/driver_nl80211.c | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index aa5ed58b2..e91eaf024 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -6718,7 +6718,6 @@ static int nl80211_connect_common(struct wpa_driver_nl80211_data *drv, if (params->mld_params.mld_addr && params->mld_params.valid_links > 0) { struct wpa_driver_mld_params *mld_params = ¶ms->mld_params; struct nlattr *links, *attr; - int i; u8 link_id; wpa_printf(MSG_DEBUG, " * MLD: MLD addr=" MACSTR, @@ -6734,31 +6733,11 @@ static int nl80211_connect_common(struct wpa_driver_nl80211_data *drv, if (!links) return -1; - attr = nla_nest_start(msg, 0); - if (!attr) - return -1; - - /* First add the association link ID */ - link_id = mld_params->assoc_link_id; - if (nla_put_u8(msg, NL80211_ATTR_MLO_LINK_ID, link_id) || - nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, - mld_params->mld_links[link_id].bssid) || - nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, - mld_params->mld_links[link_id].freq)) - return -1; - - os_memcpy(drv->sta_mlo_info.links[link_id].bssid, - mld_params->mld_links[link_id].bssid, ETH_ALEN); - - nla_nest_end(msg, attr); - - for (i = 1, link_id = 0; link_id < MAX_NUM_MLD_LINKS; - link_id++) { - if (!(mld_params->valid_links & BIT(link_id)) || - link_id == mld_params->assoc_link_id) + for (link_id = 0; link_id < MAX_NUM_MLD_LINKS; link_id++) { + if (!(mld_params->valid_links & BIT(link_id))) continue; - attr = nla_nest_start(msg, i); + attr = nla_nest_start(msg, 0); if (!attr) return -1; @@ -6768,11 +6747,11 @@ static int nl80211_connect_common(struct wpa_driver_nl80211_data *drv, mld_params->mld_links[link_id].bssid) || nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, mld_params->mld_links[link_id].freq) || - (mld_params->mld_links[i].disabled && + (mld_params->mld_links[link_id].disabled && nla_put_flag(msg, NL80211_ATTR_MLO_LINK_DISABLED)) || (mld_params->mld_links[link_id].ies && - mld_params->mld_links[i].ies_len && + mld_params->mld_links[link_id].ies_len && nla_put(msg, NL80211_ATTR_IE, mld_params->mld_links[link_id].ies_len, mld_params->mld_links[link_id].ies))) @@ -6782,7 +6761,6 @@ static int nl80211_connect_common(struct wpa_driver_nl80211_data *drv, mld_params->mld_links[link_id].bssid, ETH_ALEN); nla_nest_end(msg, attr); - i++; } nla_nest_end(msg, links); From patchwork Tue Feb 20 13:18:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1901469 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=qkM8ADWX; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=YeVUA3vJ; 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 4TfKkW6tXbz23d1 for ; Wed, 21 Feb 2024 00:19:31 +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=xy2cnJ/ayFb10pegFZcO8KBzzF4xHSQjzrlDSkDGg3M=; b=qkM8ADWXXcMAvN kLEyiATlchaBnJv9MqhtJBAI6tBM/0avG1Qxo6rMul8iWVYpxDBdhLAPzsn6ty6FKJISLP5pX9st7 Os3gidlY0Mmp+4wGc+udgfvRj98xSNRytN9iD9XNoKLd4hvGAzDTP2L7wWrLv3XcJlPz/vfSl7BDi LAFfsGiuO3j1KvupP6qh0IuEInfyMaGgol4MFyGXsQIPknvdyQfrsRjLPaqr6dWAT8+0Mm6U9RL+S iz2luPpp8Eq6+49/siRWf1OjTWzdFdJW7FuVire+k1mmIfWIzICnL292pFnlMAUFqJAqUC9sINHyP iv4wA4tQzZauHMIM7PPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1l-0000000EpBm-0C53; Tue, 20 Feb 2024 13:19:17 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1Y-0000000Ep11-3o5K for hostap@lists.infradead.org; Tue, 20 Feb 2024 13:19:07 +0000 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=DjYGo+rq7IhNfQ7WLmoPui6rk6YtfKa/Z50COXb2UCI=; t=1708435143; x=1709644743; b=YeVUA3vJPBtwKbNALFu/hIRa3SYVQ0oiMPXW95T9Wc0xVoi lztPD9YUTRjQBLY/VhBlEExuWE6q86i+VRyaOfRvqKHq8XoslLOO+jZFpG7+ZLZ+gp2MqmeCdNmnF YXAaW9uMXacUkaz/yNTPPyoKsNcde989e3ZAoobdyQcQvEG6hc6girWooGo0pLsUG90OGozAd7caz Ey8939gZ1qhJUQ/9SJd8eTs6et774huo7ReNI+2P4zcPUXq7CUky67pOq8BEWENK31aUbhIa3EDve EErPl0vJSIZm72JMFJFPws+lVG9gNl8ID1PU5+GSaxaJqJybGZxKGoZc342jr9jA==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rcQ1U-00000000ugq-1rRw; Tue, 20 Feb 2024 14:19:00 +0100 From: benjamin@sipsolutions.net To: hostap@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH v2 04/20] common: Introduce for_each_link macro Date: Tue, 20 Feb 2024 14:18:11 +0100 Message-ID: <20240220131827.17766-5-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220131827.17766-1-benjamin@sipsolutions.net> References: <20240220131827.17766-1-benjamin@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240220_051905_270922_B435F197 X-CRM114-Status: UNSURE ( 8.94 ) X-CRM114-Notice: Please train this message. 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: From: Benjamin Berg This is a simple macro iterating the given bitmask using the given variable. Having the macro avoids the for loop-continuation making it more readable overall. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches 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_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.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 From: Benjamin Berg This is a simple macro iterating the given bitmask using the given variable. Having the macro avoids the for loop-continuation making it more readable overall. Signed-off-by: Benjamin Berg --- src/utils/common.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils/common.h b/src/utils/common.h index d4ffb998b..3a8d9e022 100644 --- a/src/utils/common.h +++ b/src/utils/common.h @@ -599,6 +599,10 @@ int str_starts(const char *str, const char *start); u8 rssi_to_rcpi(int rssi); char * get_param(const char *cmd, const char *param); +#define for_each_link(__links, __i) \ + for ((__i) = 0; (__i) < MAX_NUM_MLD_LINKS; (__i)++) \ + if ((__links) & BIT(__i)) + void forced_memzero(void *ptr, size_t len); /* From patchwork Tue Feb 20 13:18:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1901475 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=qJS3+w/U; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=ixQq6mdD; 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 4TfKkk1qCNz23cy for ; Wed, 21 Feb 2024 00:19:42 +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=UZoisrL3sNx1hZIrHjCIE5BNPQBu1igihBasj21M854=; b=qJS3+w/UkZbsyz wO8UTai1kTkhCSU24eQr3KiBh7dje97Lx/2htrDs+Y0jX4/DDjW9NmOE3PJeLXWIToQ7BN784PdEc YAMAvdhHIRtW2mvxJGfOjL9FPOmOQxf7gGhxvAdVQAModUb2jXOUWjHRdAdXrL2SHSqc9prfTn0M0 Ef3ZWoXdJpk353iwweyV1J7tsGc86DprPqs4u4DtTLq0+6gcYVXEuMgEKfqV/xNy4+w+7QGq/Ws1T F9LUthcoSV+6b4zXqutPwm0xXMYvbkJcE+fFKQEjcw+Rwy3vN9xD/OS/VTiQTwK39GV8qaU+ZrOrq O1EtSY1pV4nt6pgaFmjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1t-0000000EpFc-18qy; Tue, 20 Feb 2024 13:19:25 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1Y-0000000Ep0m-3jhj for hostap@lists.infradead.org; Tue, 20 Feb 2024 13:19:10 +0000 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=EOESCvUSMMim7DWQWzBMpEHzmRM7VKmGUu5qAm1vvKs=; t=1708435142; x=1709644742; b=ixQq6mdDYi+tY3ckZ9U2bodp1WON4Iw6zX4s0agwypuDloJ 6Cw+k1UJRio2SerNMQ6++lJm18/TB/werxiTr6O6h4oAg1VWEGW0jPMId4x2wJzqHI9bkZfJ/UEIE 8fkN8ZLEcgkbTPuPx5AEXl+YbdeLwVMMUrd9AHYsE6yVOH482FqUYxF5gYkNBXZkrY21bns7HhAl/ tFDTtly4als9TDggmefBD8Do+nQXBt7BGqyzt7pcMqpb/1U4aCjIELGjdSYoemmFKjNvsDMiQBWya QDAZ1OI6L+B2QDBkvx6v9iUCOlruoYpgMsbPMdNyOUUeNAQbEQRtKWdV8dIbAx6w==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rcQ1U-00000000ugq-4AUE; Tue, 20 Feb 2024 14:19:01 +0100 From: benjamin@sipsolutions.net To: hostap@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH v2 05/20] Use for_each_link in most cases Date: Tue, 20 Feb 2024 14:18:12 +0100 Message-ID: <20240220131827.17766-6-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220131827.17766-1-benjamin@sipsolutions.net> References: <20240220131827.17766-1-benjamin@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240220_051905_384377_D21EEDA6 X-CRM114-Status: GOOD ( 18.25 ) 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: From: Benjamin Berg This was done using the below semantic patch. There are a few more places that were missed due to variable declarations or additional checks in the for loop. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches 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_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.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 From: Benjamin Berg This was done using the below semantic patch. There are a few more places that were missed due to variable declarations or additional checks in the for loop. @@ iterator name for_each_link; identifier max_links =~ "MAX_NUM_MLD_LINKS|MAX_NUM_MLO_LINKS"; expression links; expression further_tests; identifier i; statement stmt; @@ -for (i = 0; i < max_links; i++) +for_each_link(links, i) { ( - if (!(links & BIT(i))) - continue; ... | - if (!(links & BIT(i)) || further_tests) + if (further_tests) continue; ... | - if (further_tests || !(links & BIT(i))) + if (further_tests) continue; ... | - if (links & BIT(i)) stmt | - if (further_tests && (links & BIT(i))) + if (further_tests) stmt | - if ((links & BIT(i)) && further_tests) + if (further_tests) stmt ) } Signed-off-by: Benjamin Berg --- src/ap/wpa_auth.c | 5 +---- src/drivers/driver_nl80211.c | 30 ++++++------------------------ src/drivers/driver_nl80211_event.c | 14 +++----------- src/rsn_supp/tdls.c | 6 ++---- src/rsn_supp/wpa.c | 23 +++++++---------------- wpa_supplicant/bss.c | 5 +---- wpa_supplicant/ctrl_iface.c | 10 ++-------- wpa_supplicant/events.c | 10 ++-------- wpa_supplicant/rrm.c | 5 +---- wpa_supplicant/scan.c | 5 +---- wpa_supplicant/sme.c | 15 +++------------ wpa_supplicant/wnm_sta.c | 5 +---- wpa_supplicant/wpa_supplicant.c | 5 +---- 13 files changed, 31 insertions(+), 107 deletions(-) diff --git a/src/ap/wpa_auth.c b/src/ap/wpa_auth.c index afb0208e7..01a10b23c 100644 --- a/src/ap/wpa_auth.c +++ b/src/ap/wpa_auth.c @@ -3336,10 +3336,7 @@ static int wpa_auth_validate_ml_kdes_m2(struct wpa_state_machine *sm, } /* Find matching link ID and the MAC address for each link */ - for (i = 0; i < MAX_NUM_MLD_LINKS; i++) { - if (!(kde->valid_mlo_links & BIT(i))) - continue; - + for_each_link(kde->valid_mlo_links, i) { /* * Each entry should contain the link information and the MAC * address. diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index e91eaf024..bc01c4426 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -6733,10 +6733,7 @@ static int nl80211_connect_common(struct wpa_driver_nl80211_data *drv, if (!links) return -1; - for (link_id = 0; link_id < MAX_NUM_MLD_LINKS; link_id++) { - if (!(mld_params->valid_links & BIT(link_id))) - continue; - + for_each_link(mld_params->valid_links, link_id) { attr = nla_nest_start(msg, 0); if (!attr) return -1; @@ -7317,10 +7314,7 @@ static int wpa_driver_nl80211_associate( /* Error and force TEST_FAIL checking for each link */ ret = -EINVAL; - for (i = 0; i < MAX_NUM_MLD_LINKS; i++) { - if (!(params->mld_params.valid_links & BIT(i))) - continue; - + for_each_link(params->mld_params.valid_links, i) { if (TEST_FAIL_TAG("link")) err_info.link_id = i; } @@ -9270,10 +9264,7 @@ static int nl80211_put_any_link_id(struct nl_msg *msg, return 0; /* First try to pick a link that uses the same band */ - for (i = 0; i < MAX_NUM_MLD_LINKS; i++) { - if (!(mlo->valid_links & BIT(i))) - continue; - + for_each_link(mlo->valid_links, i) { if (any_valid_link_id == -1) any_valid_link_id = i; @@ -9711,10 +9702,7 @@ static int get_links_noise(struct nl_msg *msg, void *arg) if (!sinfo[NL80211_SURVEY_INFO_NOISE]) return NL_SKIP; - for (i = 0; i < MAX_NUM_MLD_LINKS; i++) { - if (!(mlo_sig->valid_links & BIT(i))) - continue; - + for_each_link(mlo_sig->valid_links, i) { if (nla_get_u32(sinfo[NL80211_SURVEY_INFO_FREQUENCY]) != mlo_sig->links[i].frequency) continue; @@ -9807,10 +9795,7 @@ static int nl80211_mlo_signal_poll(void *priv, os_memset(mlo_si, 0, sizeof(*mlo_si)); mlo_si->valid_links = drv->sta_mlo_info.valid_links; - for (i = 0; i < MAX_NUM_MLD_LINKS; i++) { - if (!(mlo_si->valid_links & BIT(i))) - continue; - + for_each_link(mlo_si->valid_links, i) { res = nl80211_get_link_signal(drv, drv->sta_mlo_info.links[i].bssid, &mlo_si->links[i].data); @@ -11002,10 +10987,7 @@ static int wpa_driver_nl80211_status(void *priv, char *buf, size_t buflen) return pos - buf; pos += res; - for (i = 0; i < MAX_NUM_MLD_LINKS; i++) { - if (!(mlo->valid_links & BIT(i))) - continue; - + for_each_link(mlo->valid_links, i) { res = os_snprintf(pos, end - pos, "link_addr[%u]=" MACSTR "\n" "link_bssid[%u]=" MACSTR "\n" diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c index b983f162d..d6c628cef 100644 --- a/src/drivers/driver_nl80211_event.c +++ b/src/drivers/driver_nl80211_event.c @@ -477,10 +477,7 @@ static void qca_nl80211_link_reconfig_event(struct wpa_driver_nl80211_data *drv, * links when the link used for (re)association is removed. */ if (removed_links & BIT(drv->sta_mlo_info.assoc_link_id)) { - for (i = 0; i < MAX_NUM_MLD_LINKS; i++) { - if (!(drv->sta_mlo_info.valid_links & BIT(i))) - continue; - + for_each_link(drv->sta_mlo_info.valid_links, i) { os_memcpy(drv->bssid, drv->sta_mlo_info.links[i].bssid, ETH_ALEN); drv->sta_mlo_info.assoc_link_id = i; @@ -702,10 +699,7 @@ static int nl80211_update_rejected_links_info(struct driver_sta_mlo_info *mlo, } /* 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; - + for_each_link((mlo->req_links & ~mlo->valid_links), i) { os_memcpy(mlo->links[i].bssid, resp_info.addr[i], ETH_ALEN); os_memcpy(mlo->links[i].addr, req_info.addr[i], ETH_ALEN); } @@ -875,9 +869,7 @@ qca_nl80211_tid_to_link_map_event(struct wpa_driver_nl80211_data *drv, wpa_printf(MSG_DEBUG, "nl80211: TID-to-link: Received uplink %x downlink %x", uplink, downlink); - for (i = 0; i < MAX_NUM_MLD_LINKS; i++) { - if (!(drv->sta_mlo_info.valid_links & BIT(i))) - continue; + for_each_link(drv->sta_mlo_info.valid_links, i) { if (uplink & BIT(i)) event.t2l_map_info.t2lmap[i].uplink |= BIT(tidnum); diff --git a/src/rsn_supp/tdls.c b/src/rsn_supp/tdls.c index 72ac9d947..060a5319b 100644 --- a/src/rsn_supp/tdls.c +++ b/src/rsn_supp/tdls.c @@ -1571,10 +1571,8 @@ static bool wpa_tdls_is_lnkid_bss_valid(struct wpa_sm *sm, } else { int i; - for (i = 0; i < MAX_NUM_MLD_LINKS; i++) { - if ((sm->mlo.valid_links & BIT(i)) && - ether_addr_equal(lnkid->bssid, - sm->mlo.links[i].bssid)) { + for_each_link(sm->mlo.valid_links, i) { + if (ether_addr_equal(lnkid->bssid, sm->mlo.links[i].bssid)) { *link_id = i; break; } diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c index 2109552c0..8956c4072 100644 --- a/src/rsn_supp/wpa.c +++ b/src/rsn_supp/wpa.c @@ -800,8 +800,8 @@ static size_t wpa_mlo_link_kde_len(struct wpa_sm *sm) int i; unsigned int num_links = 0; - for (i = 0; i < MAX_NUM_MLO_LINKS; i++) { - if (sm->mlo.assoc_link_id != i && (sm->mlo.req_links & BIT(i))) + for_each_link(sm->mlo.req_links, i) { + if (sm->mlo.assoc_link_id != i) num_links++; } @@ -814,8 +814,8 @@ static u8 * wpa_mlo_link_kde(struct wpa_sm *sm, u8 *pos) int i; u8 hdr[1 + ETH_ALEN]; - for (i = 0; i < MAX_NUM_MLO_LINKS; i++) { - if (sm->mlo.assoc_link_id == i || !(sm->mlo.req_links & BIT(i))) + for_each_link(sm->mlo.req_links, i) { + if (sm->mlo.assoc_link_id == i) continue; wpa_printf(MSG_DEBUG, @@ -1550,10 +1550,7 @@ static int wpa_supplicant_pairwise_mlo_gtk(struct wpa_sm *sm, { u8 i; - for (i = 0; i < MAX_NUM_MLO_LINKS; i++) { - if (!(sm->mlo.valid_links & BIT(i))) - continue; - + for_each_link(sm->mlo.valid_links, i) { if (!ie->mlo_gtk[i]) { wpa_msg(sm->ctx->msg_ctx, MSG_ERROR, "MLO RSN: GTK not found for link ID %u", i); @@ -1902,10 +1899,7 @@ static int mlo_ieee80211w_set_keys(struct wpa_sm *sm, sm->mgmt_group_cipher == WPA_CIPHER_GTK_NOT_USED) return 0; - for (i = 0; i < MAX_NUM_MLO_LINKS; i++) { - if (!(sm->mlo.valid_links & BIT(i))) - continue; - + for_each_link(sm->mlo.valid_links, i) { if (_mlo_ieee80211w_set_keys(sm, i, ie)) return -1; } @@ -2931,10 +2925,7 @@ static void wpa_supplicant_process_mlo_1_of_2(struct wpa_sm *sm, wpa_msg(sm->ctx->msg_ctx, MSG_INFO, "MLO RSN: Failed to configure MLO IGTK"); - for (i = 0; i < MAX_NUM_MLO_LINKS; i++) { - if (!(sm->mlo.valid_links & BIT(i))) - continue; - + for_each_link(sm->mlo.valid_links, i) { /* * AP may send group keys for subset of the all links during * rekey diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c index 22b694cf3..3a061ea60 100644 --- a/wpa_supplicant/bss.c +++ b/wpa_supplicant/bss.c @@ -414,10 +414,7 @@ static int wpa_bss_in_use(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) if (!wpa_s->valid_links) return 0; - for (i = 0; i < MAX_NUM_MLD_LINKS; i++) { - if (!(wpa_s->valid_links & BIT(i))) - continue; - + for_each_link(wpa_s->valid_links, i) { if (ether_addr_equal(bss->bssid, wpa_s->links[i].bssid)) return 1; } diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 500f4d1b5..8796e3060 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -11995,10 +11995,7 @@ static int wpas_ctrl_iface_mlo_signal_poll(struct wpa_supplicant *wpa_s, pos = buf; end = buf + buflen; - for (i = 0; i < MAX_NUM_MLD_LINKS; i++) { - if (!(mlo_si.valid_links & BIT(i))) - continue; - + for_each_link(mlo_si.valid_links, i) { ret = os_snprintf(pos, end - pos, "LINK_ID=%d\nRSSI=%d\nLINKSPEED=%lu\n" "NOISE=%d\nFREQUENCY=%u\n", @@ -12070,10 +12067,7 @@ static int wpas_ctrl_iface_mlo_status(struct wpa_supplicant *wpa_s, pos = buf; end = buf + buflen; - for (i = 0; i < MAX_NUM_MLD_LINKS; i++) { - if (!(wpa_s->valid_links & BIT(i))) - continue; - + for_each_link(wpa_s->valid_links, i) { ret = os_snprintf(pos, end - pos, "link_id=%d\nfreq=%u\n" "ap_link_addr=" MACSTR "\nsta_link_addr=" MACSTR "\n", diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 201e43f67..42cde3c8a 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -3983,10 +3983,7 @@ static int wpa_drv_get_mlo_info(struct wpa_supplicant *wpa_s) if (!mlo.valid_links) return 0; - for (i = 0; i < MAX_NUM_MLD_LINKS; i++) { - if (!(mlo.valid_links & BIT(i))) - continue; - + for_each_link(mlo.valid_links, i) { if (!ether_addr_equal(wpa_s->links[i].addr, mlo.links[i].addr) || !ether_addr_equal(wpa_s->links[i].bssid, @@ -4004,10 +4001,7 @@ static int wpa_drv_get_mlo_info(struct wpa_supplicant *wpa_s) wpa_s->valid_links = mlo.valid_links; wpa_s->mlo_assoc_link_id = mlo.assoc_link_id; os_memcpy(wpa_s->ap_mld_addr, mlo.ap_mld_addr, ETH_ALEN); - for (i = 0; i < MAX_NUM_MLD_LINKS; i++) { - if (!(wpa_s->valid_links & BIT(i))) - continue; - + for_each_link(wpa_s->valid_links, i) { os_memcpy(wpa_s->links[i].addr, mlo.links[i].addr, ETH_ALEN); os_memcpy(wpa_s->links[i].bssid, mlo.links[i].bssid, ETH_ALEN); wpa_s->links[i].freq = mlo.links[i].freq; diff --git a/wpa_supplicant/rrm.c b/wpa_supplicant/rrm.c index 7ce854be0..9673b29de 100644 --- a/wpa_supplicant/rrm.c +++ b/wpa_supplicant/rrm.c @@ -1520,10 +1520,7 @@ static bool wpas_beacon_rep_scan_match(struct wpa_supplicant *wpa_s, if (!wpa_s->valid_links) return ether_addr_equal(wpa_s->current_bss->bssid, bssid); - for (i = 0; i < MAX_NUM_MLD_LINKS; i++) { - if (!(wpa_s->valid_links & BIT(i))) - continue; - + for_each_link(wpa_s->valid_links, i) { if (ether_addr_equal(wpa_s->links[i].bssid, bssid)) return true; } diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index 6e6f05d42..e416bef99 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -698,10 +698,7 @@ static struct wpabuf * wpa_supplicant_ml_probe_ie(int mld_id, u16 links) else wpa_printf(MSG_DEBUG, "MLD: Probing links 0x%04x", links); - for (link_id = 0; link_id < MAX_NUM_MLD_LINKS; link_id++) { - if (!(links & BIT(link_id))) - continue; - + for_each_link(links, link_id) { wpabuf_put_u8(extra_ie, EHT_ML_SUB_ELEM_PER_STA_PROFILE); /* Subelement length includes only the control */ diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c index 00e1117d5..d12ffb3ce 100644 --- a/wpa_supplicant/sme.c +++ b/wpa_supplicant/sme.c @@ -405,10 +405,7 @@ static struct wpa_bss * wpas_ml_connect_pref(struct wpa_supplicant *wpa_s, return bss; if (!is_zero_ether_addr(wpa_s->conf->mld_connect_bssid_pref)) { - for (i = 0; i < MAX_NUM_MLD_LINKS; i++) { - if (!(wpa_s->valid_links & BIT(i))) - continue; - + for_each_link(wpa_s->valid_links, i) { if (wpa_s->mlo_assoc_link_id == i) continue; @@ -439,10 +436,7 @@ static struct wpa_bss * wpas_ml_connect_pref(struct wpa_supplicant *wpa_s, return bss; } - for (i = 0; i < MAX_NUM_MLD_LINKS; i++) { - if (!(wpa_s->valid_links & BIT(i))) - continue; - + for_each_link(wpa_s->valid_links, i) { if (wpa_s->mlo_assoc_link_id == i) continue; @@ -2597,10 +2591,7 @@ mscs_fail: params.mld_params.mld_addr = wpa_s->ap_mld_addr; params.mld_params.valid_links = wpa_s->valid_links; params.mld_params.assoc_link_id = wpa_s->mlo_assoc_link_id; - for (i = 0; i < MAX_NUM_MLD_LINKS; i++) { - if (!(wpa_s->valid_links & BIT(i))) - continue; - + for_each_link(wpa_s->valid_links, i) { params.mld_params.mld_links[i].bssid = wpa_s->links[i].bssid; params.mld_params.mld_links[i].freq = diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c index 3fc11b24e..b340fae06 100644 --- a/wpa_supplicant/wnm_sta.c +++ b/wpa_supplicant/wnm_sta.c @@ -2090,10 +2090,7 @@ bool wnm_is_bss_excluded(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) if (!wpa_s->valid_links) return false; - for (i = 0; i < MAX_NUM_MLD_LINKS; i++) { - if (!(wpa_s->valid_links & BIT(i))) - continue; - + for_each_link(wpa_s->valid_links, i) { if (ether_addr_equal(wpa_s->links[i].bssid, bss->bssid)) { wpa_dbg(wpa_s, MSG_DEBUG, "WNM: MLD: Disassociation imminent: current link"); diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index cd37a20eb..c19ab810a 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -9342,10 +9342,7 @@ bool wpas_ap_link_address(struct wpa_supplicant *wpa_s, const u8 *addr) if (!wpa_s->valid_links) return false; - for (i = 0; i < MAX_NUM_MLD_LINKS; i++) { - if (!(wpa_s->valid_links & BIT(i))) - continue; - + for_each_link(wpa_s->valid_links, i) { if (ether_addr_equal(wpa_s->links[i].bssid, addr)) return true; } From patchwork Tue Feb 20 13:18:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1901472 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=lKKaHMvF; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=tpWIsQVy; 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 4TfKkc0b2jz23d0 for ; Wed, 21 Feb 2024 00:19:36 +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=wTa18eMdY2g0LkItOiGeAuDY6kP+2mlPrY23G65+TYA=; b=lKKaHMvF8uygQJ zoy1EEPIfZ6+v0pI6XeF93U3ZL0lDSfg/LU2fGyzXmRDd7ykIszjMjLZDUWRCCx1oL5ong4yr37Tj c06TsvFJPw96y23S4JJuWnfBd5x/d25wQ5ArDm8UOxl0/XfS4eaQahVQuw6TcuRLVLNAKUs2fdADp yXaxqlFYs9A/Zl1tsvrF2hHztPd+9Y5bD6WWtszKCOJ7OmLuzIP8DMotvrzcezy1b0Knn21zLvWEt h/3CZ4ZubpZ0O9jak3mBRwzRBd/RUHsjlGogzFEYTjtjnxQRoCQheF5JoXa7YH5RcZYgAkObbSOCk V3KdKpD3f86JMK+gFClw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1p-0000000EpDW-1zBS; Tue, 20 Feb 2024 13:19:21 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1a-0000000Ep1C-19ki for hostap@lists.infradead.org; Tue, 20 Feb 2024 13:19:09 +0000 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=BJ56M+xuXzg0prSpkMF4xTCjWJ68NWQ36pJy5C9nln8=; t=1708435144; x=1709644744; b=tpWIsQVyXUKwYnAfNJ6XxUcUd6X2D5W3tbrX3D9BZjwyfkV uLs2gqYDq7TzMBYVrOy1M0nnrYOWVgELhUz8JRHTN2lOpioThEpUNohLsM2ZnozXjpBMalUTHI5Eq XndjDioAqImsqeB9EUqUqk0EHs8LopKTjp6mLAFUtkhk4Bz0uDY1HCTT1s8ttBxrskvt4R+5IR48g f3c0IHUyd2f7d7Iz0bIZit7OiOcfxzBJeT8K3kGCqKEKDVUtDWSRkLQbKNkVbcgX5GFAsiAo3Mcxo 2A6utUffGbG8ZBAEgnNebt5njBDYLoNts+sRHYxqI+WSha6/jDU253E5PCiloEKQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rcQ1V-00000000ugq-2UZg; Tue, 20 Feb 2024 14:19:01 +0100 From: benjamin@sipsolutions.net To: hostap@lists.infradead.org Cc: Benjamin Berg , Benjamin Berg Subject: [PATCH v2 06/20] Use for_each_link where possible Date: Tue, 20 Feb 2024 14:18:13 +0100 Message-ID: <20240220131827.17766-7-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220131827.17766-1-benjamin@sipsolutions.net> References: <20240220131827.17766-1-benjamin@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240220_051906_335053_C055D8B2 X-CRM114-Status: GOOD ( 11.47 ) 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: From: Benjamin Berg This takes care of the places that the spatch did not catch already. Signed-off-by: Benjamin Berg --- wpa_supplicant/events.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches 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_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.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 From: Benjamin Berg This takes care of the places that the spatch did not catch already. Signed-off-by: Benjamin Berg --- wpa_supplicant/events.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 42cde3c8a..cdc17b3c9 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -4034,12 +4034,9 @@ static int wpa_sm_set_ml_info(struct wpa_supplicant *wpa_s) wpa_mlo.valid_links = drv_mlo.valid_links; wpa_mlo.req_links = drv_mlo.req_links; - for (i = 0; i < MAX_NUM_MLD_LINKS; i++) { + for_each_link(drv_mlo.req_links, i) { struct wpa_bss *bss; - if (!(drv_mlo.req_links & BIT(i))) - continue; - bss = wpa_supplicant_get_new_bss(wpa_s, drv_mlo.links[i].bssid); if (!bss) { wpa_supplicant_update_scan_results(wpa_s); @@ -5863,13 +5860,10 @@ static void wpas_tid_link_map(struct wpa_supplicant *wpa_s, pos += res; if (!info->default_map) { - for (i = 0; i < MAX_NUM_MLD_LINKS && end > pos; i++) { + for_each_link(info->valid_links, i) { char uplink_map_str[9]; char downlink_map_str[9]; - if (!(info->valid_links & BIT(i))) - continue; - bitmap_to_str(info->t2lmap[i].uplink, uplink_map_str); bitmap_to_str(info->t2lmap[i].downlink, downlink_map_str); From patchwork Tue Feb 20 13:18:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1901478 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=rEo5gdWH; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=XFYU0wnf; 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 4TfKl33lTQz23cy for ; Wed, 21 Feb 2024 00:19:59 +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=9ATUrnh2HcTZR7spfjxG3NzV9et58SRARYHv8Q1PfsI=; b=rEo5gdWHkLlKhd jOqWJ8970OJ36cTgJv165ujH8T2RieYUVFS7OW46XUuDkjlCHi0cec0vHpTZ9/Mt1/rhOFWHu6Vpb MrYLvpdC6Xl+TTT97Q9JPpAxt4VHWXJqSRMHb2Gh60N3Il9+z9JLH0FU8UXYSIRBZwC00vZH4I0om qsVNLBD5HmCWpcwyFn+Tz2VTWpjV8tjHWAjCHSAseSphqyCX4+Jv76O20KS0tv7j2vIqpgniHCs24 AYLT6BqaDPLZ8UFVNpBsBKUaT06WYn9q2JtDDZcjpHW9vvs4Ccp6ln5dnIdiIK7Cl3nZcLfRn2CKX 3G9COyz+lRO+txJp9FuQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ26-0000000EpQ2-0Hlx; Tue, 20 Feb 2024 13:19:38 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1Z-0000000Ep1F-0PcH for hostap@lists.infradead.org; Tue, 20 Feb 2024 13:19:10 +0000 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=V/4k6rsPNgsRjY9RSHxg2t411/q0WEolELZWe71dzuM=; t=1708435144; x=1709644744; b=XFYU0wnfGxVOObiWHlqa75X+cw+p9YkUu2PcnSUSkmxwwKI /XVTIcjQbby3JzX9O8dOFqsVw6OPndKGtAJYhDksgfo+tVFBNIMhpXFwnYhkBaNtEl+6tjU+2PL7B PyVFLyDH8WUT7X5NX10QnlicihTGg5kE6aOIYY8rVwWB59EvA5vFrMQNe+J4A6OjOI9XDb+TgCiOs WahiyTGk3LYocSuZ7hGfSMCEbUydITpyEt+VxDfbXXAOXrtvN9KkeJUZRGLoeTTH9Iinrww2je5bm sfqOYDSpTqIw230p8NfZrUP3s+p2IS1YSSK1ZIKhAwyKNvQpxm49ftnlbpwVfjdg==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rcQ1W-00000000ugq-0krX; Tue, 20 Feb 2024 14:19:02 +0100 From: benjamin@sipsolutions.net To: hostap@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH v2 07/20] nl80211: Use valid_links bitmask for bss->links array Date: Tue, 20 Feb 2024 14:18:14 +0100 Message-ID: <20240220131827.17766-8-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220131827.17766-1-benjamin@sipsolutions.net> References: <20240220131827.17766-1-benjamin@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240220_051905_542403_3FBFC06A X-CRM114-Status: GOOD ( 26.29 ) 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: From: Benjamin Berg Most places in the codebase use a valid_links bitmask with an array. Switch the bss->links array instead of having a link_id inside. Signed-off-by: Benjamin Berg --- src/drivers/driver_nl80211.c | 179 ++++++++++ src/drivers/driver_nl80211.h | 29 ++++- src/drivers/driver_nl80211_event.c | [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches 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_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.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 From: Benjamin Berg Most places in the codebase use a valid_links bitmask with an array. Switch the bss->links array instead of having a link_id inside. Signed-off-by: Benjamin Berg --- src/drivers/driver_nl80211.c | 179 ++++++++++------------------- src/drivers/driver_nl80211.h | 29 ++++- src/drivers/driver_nl80211_event.c | 33 +++--- src/utils/common.h | 8 ++ 4 files changed, 111 insertions(+), 138 deletions(-) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index bc01c4426..639767f21 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -2289,7 +2289,6 @@ static void * wpa_driver_nl80211_drv_init(void *ctx, const char *ifname, { struct wpa_driver_nl80211_data *drv; struct i802_bss *bss; - unsigned int i; char path[128], buf[200], *pos; ssize_t len; int ret; @@ -2389,16 +2388,12 @@ skip_wifi_status: } /* - * Set the default link to be the first one, and set its address to that - * of the interface. + * Use link ID 0 for the single "link" of a non-MLD. */ + bss->valid_links = 0; bss->flink = &bss->links[0]; - bss->n_links = 1; os_memcpy(bss->flink->addr, bss->addr, ETH_ALEN); - for (i = 0; i < MAX_NUM_MLD_LINKS; i++) - bss->links[i].link_id = NL80211_DRV_LINK_ID_NA; - return bss; failed: @@ -3073,10 +3068,11 @@ wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv, static int wpa_driver_nl80211_del_beacon(struct i802_bss *bss, - struct i802_link *link) + int link_id) { struct nl_msg *msg; struct wpa_driver_nl80211_data *drv = bss->drv; + struct i802_link *link = nl80211_get_link(bss, link_id); if (!link->beacon_set) return 0; @@ -3091,13 +3087,12 @@ static int wpa_driver_nl80211_del_beacon(struct i802_bss *bss, if (!msg) return -ENOBUFS; - if (link->link_id != NL80211_DRV_LINK_ID_NA) { + if (link_id != NL80211_DRV_LINK_ID_NA) { wpa_printf(MSG_DEBUG, "nl80211: MLD: stop beaconing on link=%u", - link->link_id); + link_id); - if (nla_put_u8(msg, NL80211_ATTR_MLO_LINK_ID, - link->link_id)) { + if (nla_put_u8(msg, NL80211_ATTR_MLO_LINK_ID, link_id)) { nlmsg_free(msg); return -ENOBUFS; } @@ -3109,10 +3104,10 @@ static int wpa_driver_nl80211_del_beacon(struct i802_bss *bss, static void wpa_driver_nl80211_del_beacon_all(struct i802_bss *bss) { - unsigned int i; + unsigned int link_id; - for (i = 0; i < bss->n_links; i++) - wpa_driver_nl80211_del_beacon(bss, &bss->links[i]); + for_each_link_default(bss->valid_links, link_id, NL80211_DRV_LINK_ID_NA) + wpa_driver_nl80211_del_beacon(bss, link_id); } @@ -4191,21 +4186,6 @@ int wpa_driver_nl80211_authenticate_retry(struct wpa_driver_nl80211_data *drv) } -struct i802_link * nl80211_get_link(struct i802_bss *bss, s8 link_id) -{ - unsigned int i; - - for (i = 0; i < bss->n_links; i++) { - if (bss->links[i].link_id != link_id) - continue; - - return &bss->links[i]; - } - - return bss->flink; -} - - static void nl80211_link_set_freq(struct i802_bss *bss, s8 link_id, int freq) { struct i802_link *link = nl80211_get_link(bss, link_id); @@ -4217,9 +4197,9 @@ static void nl80211_link_set_freq(struct i802_bss *bss, s8 link_id, int freq) static int nl80211_get_link_freq(struct i802_bss *bss, const u8 *addr, bool bss_freq_debug) { - size_t i; + u8 i; - for (i = 0; i < bss->n_links; i++) { + for_each_link(bss->valid_links, i) { if (ether_addr_equal(bss->links[i].addr, addr)) { wpa_printf(MSG_DEBUG, "nl80211: Use link freq=%d for address " @@ -5060,20 +5040,17 @@ static int wpa_driver_nl80211_set_ap(void *priv, #endif /* CONFIG_MESH */ if (params->mld_ap) { - size_t i; - - for (i = 0; i < bss->n_links; i++) { - if (bss->links[i].link_id == params->mld_link_id) { - link = &bss->links[i]; - break; - } - } - - if (i == bss->n_links) { - wpa_printf(MSG_DEBUG, "nl80211: Link ID=%u not found", - params->mld_link_id); + if (!nl80211_link_valid(bss->valid_links, + params->mld_link_id)) { + wpa_printf(MSG_DEBUG, "nl80211: Link ID=%u invalid (valid: 0x%04x)", + params->mld_link_id, bss->valid_links); return -EINVAL; } + + link = nl80211_get_link(bss, params->mld_link_id); + } else if (bss->valid_links) { + wpa_printf(MSG_DEBUG, "nl80211: MLD configuration expected"); + return -EINVAL; } beacon_set = params->reenable ? 0 : link->beacon_set; @@ -5483,27 +5460,6 @@ fail: } -static bool nl80211_link_valid(struct i802_bss *bss, s8 link_id) -{ - unsigned int i; - - if (link_id < 0) - return false; - - for (i = 0; i < bss->n_links; i++) { - wpa_printf(MSG_DEBUG, "nl80211: %s - i=%u, link_id=%u", - __func__, i, bss->links[i].link_id); - if (bss->links[i].link_id == NL80211_DRV_LINK_ID_NA) - continue; - - if (bss->links[i].link_id == link_id) - return true; - } - - return false; -} - - static int nl80211_set_channel(struct i802_bss *bss, struct hostapd_freq_params *freq, int set_chan) { @@ -5524,7 +5480,7 @@ static int nl80211_set_channel(struct i802_bss *bss, return -1; } - if (nl80211_link_valid(bss, freq->link_id)) { + if (nl80211_link_valid(bss->valid_links, freq->link_id)) { wpa_printf(MSG_DEBUG, "nl80211: Set link_id=%u for freq", freq->link_id); @@ -8886,7 +8842,6 @@ static int wpa_driver_nl80211_if_add(void *priv, enum wpa_driver_if_type type, if (type == WPA_IF_AP_BSS && setup_ap) { struct i802_bss *new_bss = os_zalloc(sizeof(*new_bss)); - unsigned int i; if (new_bss == NULL) { if (added) @@ -8894,10 +8849,6 @@ static int wpa_driver_nl80211_if_add(void *priv, enum wpa_driver_if_type type, return -1; } - /* Initialize here before any failure path */ - for (i = 0; i < MAX_NUM_MLD_LINKS; i++) - new_bss->links[i].link_id = NL80211_DRV_LINK_ID_NA; - if (bridge && i802_check_bridge(drv, new_bss, bridge, ifname) < 0) { wpa_printf(MSG_ERROR, "nl80211: Failed to add the new " @@ -8922,7 +8873,7 @@ static int wpa_driver_nl80211_if_add(void *priv, enum wpa_driver_if_type type, new_bss->drv = drv; new_bss->next = drv->first_bss->next; new_bss->flink = &new_bss->links[0]; - new_bss->n_links = 1; + new_bss->valid_links = 0; os_memcpy(new_bss->flink->addr, new_bss->addr, ETH_ALEN); new_bss->flink->freq = drv->first_bss->flink->freq; @@ -9464,33 +9415,35 @@ static void nl80211_remove_links(struct i802_bss *bss) struct wpa_driver_nl80211_data *drv = bss->drv; struct nl_msg *msg; int ret; - u8 link_id; - - if (bss->n_links == 0) - return; + u8 link_id, i; - while (bss->links[0].link_id != NL80211_DRV_LINK_ID_NA) { - struct i802_link *link = &bss->links[0]; + for_each_link(bss->valid_links, link_id) { + struct i802_link *link = &bss->links[link_id]; wpa_printf(MSG_DEBUG, "nl80211: MLD: remove link_id=%u", - link->link_id); - - wpa_driver_nl80211_del_beacon(bss, link); + link_id); - link_id = link->link_id; + wpa_driver_nl80211_del_beacon(bss, link_id); /* First remove the link locally */ - if (bss->n_links == 1) { - bss->flink->link_id = NL80211_DRV_LINK_ID_NA; - os_memcpy(bss->flink->addr, bss->addr, ETH_ALEN); - } else { - struct i802_link *other = &bss->links[bss->n_links - 1]; + bss->valid_links &= ~BIT(link_id); + os_memset(link->addr, 0, ETH_ALEN); - os_memcpy(link, other, sizeof(*link)); - other->link_id = NL80211_DRV_LINK_ID_NA; - os_memset(other->addr, 0, ETH_ALEN); + /* Choose new deflink if we are removing that link */ + if (bss->flink == link) { + for_each_link_default(bss->valid_links, i, 0) { + bss->flink = &bss->links[i]; + break; + } + } - bss->n_links--; + /* If this was the last link, then reset default link */ + if (!bss->valid_links) { + /* Does keeping freq/bandwidth make sense? */ + if (bss->flink != link) + os_memcpy(bss->flink, link, sizeof(*link)); + + os_memcpy(bss->flink->addr, bss->addr, ETH_ALEN); } /* Remove the link from the kernel */ @@ -9501,7 +9454,7 @@ static void nl80211_remove_links(struct i802_bss *bss) wpa_printf(MSG_ERROR, "nl80211: remove link (%d) failed", link_id); - return; + continue; } ret = send_and_recv_cmd(drv, msg); @@ -9509,7 +9462,7 @@ static void nl80211_remove_links(struct i802_bss *bss) wpa_printf(MSG_ERROR, "nl80211: remove link (%d) failed. ret=%d (%s)", link_id, ret, strerror(-ret)); - return; + continue; } } } @@ -9524,7 +9477,7 @@ static int wpa_driver_nl80211_deinit_ap(void *priv) return -1; /* Stop beaconing */ - wpa_driver_nl80211_del_beacon(bss, bss->flink); + wpa_driver_nl80211_del_beacon(bss, NL80211_DRV_LINK_ID_NA); nl80211_remove_links(bss); @@ -13791,7 +13744,6 @@ static int nl80211_link_add(void *priv, u8 link_id, const u8 *addr) struct i802_bss *bss = priv; struct wpa_driver_nl80211_data *drv = bss->drv; struct nl_msg *msg; - unsigned int idx, i; int ret; wpa_printf(MSG_DEBUG, "nl80211: MLD: add link_id=%u, addr=" MACSTR, @@ -13804,32 +13756,24 @@ static int nl80211_link_add(void *priv, u8 link_id, const u8 *addr) return -EINVAL; } - if (bss->n_links >= MAX_NUM_MLD_LINKS) { - wpa_printf(MSG_DEBUG, "nl80211: MLD: already have n_links=%zu", - bss->n_links); + if (link_id >= MAX_NUM_MLD_LINKS) { + wpa_printf(MSG_DEBUG, + "nl80211: invalid link_id=%u", link_id); return -EINVAL; } - for (i = 0; i < bss->n_links; i++) { - if (bss->links[i].link_id == link_id && - bss->links[i].beacon_set) { - wpa_printf(MSG_DEBUG, - "nl80211: MLD: link already set"); - return -EINVAL; - } + if (bss->valid_links & BIT(link_id)) { + wpa_printf(MSG_DEBUG, + "nl80211: MLD: link already set"); + return -EINVAL; } - /* try using the first link entry, assuming it is not beaconing yet */ - if (bss->n_links == 1 && - bss->flink->link_id == NL80211_DRV_LINK_ID_NA) { + if (!bss->valid_links) { + /* Becoming MLD, verify we were not beaconing */ if (bss->flink->beacon_set) { wpa_printf(MSG_DEBUG, "nl80211: BSS already beaconing"); return -EINVAL; } - - idx = 0; - } else { - idx = bss->n_links; } msg = nl80211_drv_msg(drv, 0, NL80211_CMD_ADD_LINK); @@ -13847,12 +13791,15 @@ static int nl80211_link_add(void *priv, u8 link_id, const u8 *addr) return ret; } - bss->links[idx].link_id = link_id; - os_memcpy(bss->links[idx].addr, addr, ETH_ALEN); + os_memcpy(bss->links[link_id].addr, addr, ETH_ALEN); + + /* The new link is the first one, make it the default */ + if (!bss->valid_links) + bss->flink = &bss->links[link_id]; - bss->n_links = idx + 1; + bss->valid_links |= BIT(link_id); - wpa_printf(MSG_DEBUG, "nl80211: MLD: n_links=%zu", bss->n_links); + wpa_printf(MSG_DEBUG, "nl80211: MLD: valid_links=0x%04x", bss->valid_links); return 0; } diff --git a/src/drivers/driver_nl80211.h b/src/drivers/driver_nl80211.h index 8bb70ecfc..f1e20045b 100644 --- a/src/drivers/driver_nl80211.h +++ b/src/drivers/driver_nl80211.h @@ -55,18 +55,16 @@ struct nl80211_wiphy_data { struct i802_link { unsigned int beacon_set:1; - s8 link_id; int freq; int bandwidth; u8 addr[ETH_ALEN]; - void *ctx; }; struct i802_bss { struct wpa_driver_nl80211_data *drv; struct i802_bss *next; - size_t n_links; + u16 valid_links; struct i802_link links[MAX_NUM_MLD_LINKS]; struct i802_link *flink; @@ -352,7 +350,30 @@ int process_bss_event(struct nl_msg *msg, void *arg); 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); + +static inline struct i802_link * +nl80211_get_link(struct i802_bss *bss, s8 link_id) +{ + if (link_id < 0 || link_id >= MAX_NUM_MLD_LINKS) + return bss->flink; + + if (BIT(link_id) & bss->valid_links) + return &bss->links[link_id]; + + return bss->flink; +} + +static inline bool nl80211_link_valid(u16 links, s8 link_id) +{ + if (link_id < 0 || link_id >= MAX_NUM_MLD_LINKS) + return false; + + if (links & BIT(link_id)) + return true; + + return false; +} + static inline bool nl80211_attr_supported(struct wpa_driver_nl80211_data *drv, unsigned int attr) diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c index d6c628cef..be0e369a2 100644 --- a/src/drivers/driver_nl80211_event.c +++ b/src/drivers/driver_nl80211_event.c @@ -1610,18 +1610,17 @@ static void mlme_event_unprot_beacon(struct wpa_driver_nl80211_data *drv, } -static struct i802_link * -nl80211_get_mld_link_by_freq(struct i802_bss *bss, unsigned int freq) +static s8 +nl80211_get_link_id_by_freq(struct i802_bss *bss, unsigned int freq) { unsigned int i; - for (i = 0; i < bss->n_links; i++) { - if ((unsigned int) bss->links[i].freq == freq && - bss->links[i].link_id != -1) - return &bss->links[i]; + for_each_link(bss->valid_links, i) { + if ((unsigned int) bss->links[i].freq == freq) + return i; } - return NULL; + return NL80211_DRV_LINK_ID_NA; } @@ -1655,12 +1654,12 @@ static void mlme_event(struct i802_bss *bss, /* Determine the MLD link either by an explicitly provided link id or * finding a match based on the frequency. */ if (link) - mld_link = nl80211_get_link(bss, nla_get_u8(link)); + link_id = nla_get_u8(link); else if (freq) - mld_link = nl80211_get_mld_link_by_freq(bss, nla_get_u32(freq)); + link_id = nl80211_get_link_id_by_freq(bss, nla_get_u32(freq)); - if (mld_link) - link_id = mld_link->link_id; + if (nl80211_link_valid(bss->valid_links, link_id)) + mld_link = nl80211_get_link(bss, link_id); data = nla_data(frame); len = nla_len(frame); @@ -1912,7 +1911,7 @@ static void mlme_event_dh_event(struct wpa_driver_nl80211_data *drv, os_memset(&data, 0, sizeof(data)); addr = nla_data(tb[NL80211_ATTR_MAC]); - if (bss->links[0].link_id == NL80211_DRV_LINK_ID_NA && + if (!bss->valid_links && (tb[NL80211_ATTR_MLO_LINK_ID] || tb[NL80211_ATTR_MLD_ADDR])) { wpa_printf(MSG_ERROR, @@ -2176,7 +2175,7 @@ static void nl80211_new_station_event(struct wpa_driver_nl80211_data *drv, u8 *req_ies = NULL, *resp_ies = NULL; size_t req_ies_len = 0, resp_ies_len = 0; - if (bss->links[0].link_id == NL80211_DRV_LINK_ID_NA && + if (!bss->valid_links && (tb[NL80211_ATTR_MLO_LINK_ID] || tb[NL80211_ATTR_MLD_ADDR])) { wpa_printf(MSG_ERROR, @@ -2444,7 +2443,6 @@ static void nl80211_radar_event(struct wpa_driver_nl80211_data *drv, { union wpa_event_data data; enum nl80211_radar_event event_type; - struct i802_link *mld_link = NULL; if (!tb[NL80211_ATTR_WIPHY_FREQ] || !tb[NL80211_ATTR_RADAR_EVENT]) return; @@ -2455,10 +2453,9 @@ static void nl80211_radar_event(struct wpa_driver_nl80211_data *drv, event_type = nla_get_u32(tb[NL80211_ATTR_RADAR_EVENT]); if (data.dfs_event.freq) { - mld_link = nl80211_get_mld_link_by_freq(drv->first_bss, - data.dfs_event.freq); - if (mld_link) - data.dfs_event.link_id = mld_link->link_id; + data.dfs_event.link_id = + nl80211_get_link_id_by_freq(drv->first_bss, + data.dfs_event.freq); } /* Check HT params */ diff --git a/src/utils/common.h b/src/utils/common.h index 3a8d9e022..2b2611d02 100644 --- a/src/utils/common.h +++ b/src/utils/common.h @@ -603,6 +603,14 @@ char * get_param(const char *cmd, const char *param); for ((__i) = 0; (__i) < MAX_NUM_MLD_LINKS; (__i)++) \ if ((__links) & BIT(__i)) +/* Iterate all links, or, if no link is defined, iterate given index */ +#define for_each_link_default(_links, _i, _def_idx) \ + for ((_i) = (_links) ? 0 : (_def_idx); \ + (_i) < MAX_NUM_MLD_LINKS || \ + (!(_links) && (_i) == (_def_idx)); \ + (_i)++) \ + if (!(_links) || (_links) & BIT(_i)) + void forced_memzero(void *ptr, size_t len); /* From patchwork Tue Feb 20 13:18:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1901471 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=UDe8jm7T; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=sWO1z9LY; 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 4TfKkb5JXvz23cy for ; Wed, 21 Feb 2024 00:19:35 +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=fhxcFiZrXKkv7nl8y0F1RwJ8cualLBfAlSCOV3oDOXk=; b=UDe8jm7T0KLfDp zTuJFqW4YZ/ste5pvQRjniSQvgxNa//auliDyJWSH0KfQc4KCgJFK3aeCWUZOPhKqoDBgxo+yUdFN JUdLQ9ujEwUm5SvMo5coJd7yecGE4X10UhJ5DnVgvlMeHF2gBf7b1xhIkRmwG5B15s/qAB15HZ4zq 0XhhBjcInbUNgXOmNJdjY8zPF5IqSol1pA74sobN8Esd4CXM2FwOuzd+wS919xtyyhWfHyuzdCKaa kaC4YcPy/eFIRfLb9GXKAte+jBLr1jJ7B98WKb12CfcBfXeXiFbLwtXlvJ7ogBbp3UzSi5/qf/zbf UmVGVVvkO1ln3ESLblsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1n-0000000EpCz-3l1w; Tue, 20 Feb 2024 13:19:19 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1Z-0000000Ep1G-10lz for hostap@lists.infradead.org; Tue, 20 Feb 2024 13:19:09 +0000 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=uZKOwkf+JiLyN3pHMA8unYb6d6HpIwnfd7osZvfdNSQ=; t=1708435145; x=1709644745; b=sWO1z9LYgbCE4Gc71lW0+BR6hULfKhs46lU4ujHZ/fzqPYI RNsm9K6zMukf4eHyGtja5+aPf3ri3eFyjp7qlgaDQhl5G1RA40ftt86LzhuLsglEZmj8++5DjU1hg h+wJtYmE8Bfc+U+M06F0ZcUha1DB28ZTgEBt7OOpRtbOdPzD9vtz2rrPxy7CJpDNrjLAPHutPUKJn 19O2vjrBu5WFsVeP1ODTm5K6Pa4McPMxaVworo+V1NiaKgEh/dIqvnwr9veUmWLsFnx7UTCOck+dg Lp2Ij2pgy65yI9CmJJh0lcuYke7Zr6ImR7VZu8G8/T82zqxwW3671GmEZ4tXskNg==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rcQ1X-00000000ugq-0QXb; Tue, 20 Feb 2024 14:19:03 +0100 From: benjamin@sipsolutions.net To: hostap@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH v2 08/20] BSS: Switch struct wpa_bss to use valid_links bitmask Date: Tue, 20 Feb 2024 14:18:15 +0100 Message-ID: <20240220131827.17766-9-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220131827.17766-1-benjamin@sipsolutions.net> References: <20240220131827.17766-1-benjamin@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240220_051905_524130_E77799B6 X-CRM114-Status: GOOD ( 17.92 ) 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: From: Benjamin Berg This aligns both the supplicant and bss structures to use the same pattern of a valid_links bitmask plus per-link entries. Signed-off-by: Benjamin Berg --- wpa_supplicant/bss.c | 28 ++++++++++++ wpa_supplicant/bss.h | 5 +++-- wpa_supplicant/events.c | 5 ++--- wpa_supplicant/sme.c [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches 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_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.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 From: Benjamin Berg This aligns both the supplicant and bss structures to use the same pattern of a valid_links bitmask plus per-link entries. Signed-off-by: Benjamin Berg --- wpa_supplicant/bss.c | 28 ++++++++++++---------------- wpa_supplicant/bss.h | 5 +++-- wpa_supplicant/events.c | 5 ++--- wpa_supplicant/sme.c | 24 +++++++++++++----------- wpa_supplicant/wpa_supplicant.c | 12 ++++++------ 5 files changed, 36 insertions(+), 38 deletions(-) diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c index 3a061ea60..44d9f8ff9 100644 --- a/wpa_supplicant/bss.c +++ b/wpa_supplicant/bss.c @@ -1510,9 +1510,6 @@ wpa_bss_parse_ml_rnr_ap_info(struct wpa_supplicant *wpa_s, for (i = 0; i < count; i++) { u8 bss_params; - if (bss->n_mld_links >= MAX_NUM_MLD_LINKS) - return; - if (end - pos < ap_info->tbtt_info_len) break; @@ -1543,13 +1540,12 @@ wpa_bss_parse_ml_rnr_ap_info(struct wpa_supplicant *wpa_s, wpa_s, neigh_bss->bssid)) { struct mld_link *l; - l = &bss->mld_links[bss->n_mld_links]; - l->link_id = link_id; + bss->valid_links |= BIT(link_id); + l = &bss->mld_links[link_id]; os_memcpy(l->bssid, pos + 1, ETH_ALEN); l->freq = neigh_bss->freq; l->disabled = mld_params[2] & RNR_TBTT_INFO_MLD_PARAM2_LINK_DISABLED; - bss->n_mld_links++; } } @@ -1675,15 +1671,16 @@ int wpa_bss_parse_basic_ml_element(struct wpa_supplicant *wpa_s, os_memcpy(ap_mld_addr, ml_basic_common_info->mld_addr, ETH_ALEN); - bss->n_mld_links = 0; - l = &bss->mld_links[bss->n_mld_links]; link_id = ml_basic_common_info->variable[0] & EHT_ML_LINK_ID_MSK; - l->link_id = link_id; + + bss->mld_link_id = link_id; + bss->valid_links = BIT(link_id); + seen = bss->valid_links; + + l = &bss->mld_links[link_id]; os_memcpy(l->bssid, bss->bssid, ETH_ALEN); l->freq = bss->freq; - seen = BIT(link_id); - bss->n_mld_links++; /* * The AP MLD ID in the RNR corresponds to the MBSSID index, see @@ -1733,13 +1730,12 @@ int wpa_bss_parse_basic_ml_element(struct wpa_supplicant *wpa_s, } } - wpa_printf(MSG_DEBUG, "MLD: n_mld_links=%u (unresolved: 0x%04hx)", - bss->n_mld_links, missing); + wpa_printf(MSG_DEBUG, "MLD: valid_links=%04hx (unresolved: 0x%04hx)", + bss->valid_links, missing); - for (i = 0; i < bss->n_mld_links; i++) { + for_each_link(bss->valid_links, i) { wpa_printf(MSG_DEBUG, "MLD: link=%u, bssid=" MACSTR, - bss->mld_links[i].link_id, - MAC2STR(bss->mld_links[i].bssid)); + i, MAC2STR(bss->mld_links[i].bssid)); } if (missing_links) diff --git a/wpa_supplicant/bss.h b/wpa_supplicant/bss.h index c06c20acf..7ec5a5111 100644 --- a/wpa_supplicant/bss.h +++ b/wpa_supplicant/bss.h @@ -126,11 +126,12 @@ struct wpa_bss { size_t beacon_ie_len; /** MLD address of the AP */ u8 mld_addr[ETH_ALEN]; + /** MLD link of the AP */ + u8 mld_link_id; /** An array of MLD links */ - u8 n_mld_links; + u16 valid_links; struct mld_link { - u8 link_id; u8 bssid[ETH_ALEN]; int freq; diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index cdc17b3c9..9346a4f61 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1155,19 +1155,18 @@ static void owe_trans_ssid(struct wpa_supplicant *wpa_s, struct wpa_bss *bss, static bool wpas_valid_ml_bss(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) - { u16 removed_links; if (wpa_bss_parse_basic_ml_element(wpa_s, bss, NULL, NULL, NULL, NULL)) return true; - if (bss->n_mld_links == 0) + if (!bss->valid_links) return true; /* Check if the current BSS is going to be removed */ removed_links = wpa_bss_parse_reconf_ml_element(wpa_s, bss); - if (BIT(bss->mld_links[0].link_id) & removed_links) + if (BIT(bss->mld_link_id) & removed_links) return false; return true; diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c index d12ffb3ce..045ea6d62 100644 --- a/wpa_supplicant/sme.c +++ b/wpa_supplicant/sme.c @@ -517,21 +517,23 @@ out: static void wpas_sme_set_mlo_links(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) { - int i; + u8 i; wpa_s->valid_links = 0; + wpa_s->mlo_assoc_link_id = bss->mld_link_id; - for (i = 0; i < bss->n_mld_links; i++) { - u8 link_id = bss->mld_links[i].link_id; + for_each_link(bss->valid_links, i) { const u8 *bssid = bss->mld_links[i].bssid; - if (i == 0) - wpa_s->mlo_assoc_link_id = link_id; - wpa_s->valid_links |= BIT(link_id); - os_memcpy(wpa_s->links[link_id].bssid, bssid, ETH_ALEN); - wpa_s->links[link_id].freq = bss->mld_links[i].freq; - wpa_s->links[link_id].bss = wpa_bss_get_bssid(wpa_s, bssid); - wpa_s->links[link_id].disabled = bss->mld_links[i].disabled; + wpa_s->valid_links |= BIT(i); + os_memcpy(wpa_s->links[i].bssid, bssid, ETH_ALEN); + wpa_s->links[i].freq = bss->mld_links[i].freq; + wpa_s->links[i].disabled = bss->mld_links[i].disabled; + + if (bss->mld_link_id == i) + wpa_s->links[i].bss = bss; + else + wpa_s->links[i].bss = wpa_bss_get_bssid(wpa_s, bssid); } } @@ -572,7 +574,7 @@ static void sme_send_authentication(struct wpa_supplicant *wpa_s, if ((wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_MLO) && !wpa_bss_parse_basic_ml_element(wpa_s, bss, wpa_s->ap_mld_addr, NULL, ssid, NULL) && - bss->n_mld_links) { + bss->valid_links) { wpa_printf(MSG_DEBUG, "MLD: In authentication"); wpas_sme_set_mlo_links(wpa_s, bss); diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index c19ab810a..ca9ec3ed6 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -1006,13 +1006,13 @@ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, if (state == WPA_COMPLETED && wpa_s->new_connection) { struct wpa_ssid *ssid = wpa_s->current_ssid; int fils_hlp_sent = 0; - char mld_addr[50]; + char assoc_link[50]; - mld_addr[0] = '\0'; + assoc_link[0] = '\0'; if (wpa_s->valid_links) - os_snprintf(mld_addr, sizeof(mld_addr), - " ap_mld_addr=" MACSTR, - MAC2STR(wpa_s->ap_mld_addr)); + os_snprintf(assoc_link, sizeof(assoc_link), + " assoc_link=" MACSTR, + MAC2STR(wpa_s->links[wpa_s->mlo_assoc_link_id].bssid)); #ifdef CONFIG_SME if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) && @@ -1029,7 +1029,7 @@ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, MAC2STR(wpa_s->bssid), ssid ? ssid->id : -1, ssid && ssid->id_str ? ssid->id_str : "", - fils_hlp_sent ? " FILS_HLP_SENT" : "", mld_addr); + fils_hlp_sent ? " FILS_HLP_SENT" : "", assoc_link); #endif /* CONFIG_CTRL_IFACE || !CONFIG_NO_STDOUT_DEBUG */ wpas_clear_temp_disabled(wpa_s, ssid, 1); wpa_s->consecutive_conn_failures = 0; From patchwork Tue Feb 20 13:18:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1901476 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=zo7BPKEx; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=GaGcR78r; 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 4TfKkp5xdLz23cy for ; Wed, 21 Feb 2024 00:19:46 +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=piNgLs7qcFdkekZqsznPTwigKbueHX3hqvsQb+ab3Ss=; b=zo7BPKExVTiWGs AyMwzkUEGvIq03EW045bqipQisUwUVQFw20qaHSoXs4na/e4BRAZSoAWSp6RqgghKrBraJIS80nU+ sEALuU5bOEuQUBRlnujqJfXbEgtAwNvTqdjWByfBTo2xJ3ZXsbu48y5nqCNpifuIbIZHrDQNKe+BE XRBtzXGO5yWaINXeME1YCPvDOf4TFGzP6ulf2guvLmCH2CiUB2k/BPwbUTfcDN68vZS1FgsrzzS8L EFZIyIGZoZROxfow/QaEL3PM2QzHUjYzyU0gUgyfRoCyJqMejhqW1OsWg711dRe063lPoy3QWpne2 /3VPccxRqvsINgYpdQ7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1y-0000000EpJ2-1KsN; Tue, 20 Feb 2024 13:19:30 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1a-0000000Ep3W-2BpE for hostap@lists.infradead.org; Tue, 20 Feb 2024 13:19:10 +0000 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=gV9zkbVJHt4pbKmzFG3EEd8x8WScGNIlhjLcuA50csk=; t=1708435146; x=1709644746; b=GaGcR78r1Dar6J6/SYZENY9yjc+NQE4raWGvcLTNrZPhnDL pxIGIZ94YcJWHmaUfq6pu8DAGYc1kk9Vs6gV6dj7ZcF+15jTJftCbmEMJkbH2MaofhxMIm0uuhpBG U1bReJJnE2vhKlK1iCcypzw92uc4WKv9ft1CrDCYo4F/DO0fXds3FgAKezSxg/FU/lmD2FPCvSBQK um4u/dhY4tZwO0IU67kA8Hu8yRVrbiwWQadVqIR2zinRnh9iLdBuYX5hcnnRxsBF3+LHnaKg+fczU qB3kDjFE298dOKevbY3dUFS40ZuT1q89jfNa768yYSH/EJ20y3bm0LqUqiBn2RDQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rcQ1Y-00000000ugq-07XU; Tue, 20 Feb 2024 14:19:04 +0100 From: benjamin@sipsolutions.net To: hostap@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH v2 09/20] WNM: Clean up old scan data processing Date: Tue, 20 Feb 2024 14:18:16 +0100 Message-ID: <20240220131827.17766-10-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220131827.17766-1-benjamin@sipsolutions.net> References: <20240220131827.17766-1-benjamin@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240220_051906_815481_3963E06D X-CRM114-Status: GOOD ( 30.21 ) 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: From: Benjamin Berg When receiving a BTM request, wpa_s would try to fetch new results from the driver, and, independently of that, would also process the latest scan results that were partially updated by the previous f [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches 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_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.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 From: Benjamin Berg When receiving a BTM request, wpa_s would try to fetch new results from the driver, and, independently of that, would also process the latest scan results that were partially updated by the previous fetch. Simplify the logic by using wpa_supplicant_get_scan_results directly and then processing the old scan data as usual. However, this data may be outdated, so add a new heuristic to avoid roaming to a BSS if it is either outdated or bad. Doing this moves all scan data processing into wnm_scan_process. Signed-off-by: Benjamin Berg --- wpa_supplicant/events.c | 2 +- wpa_supplicant/wnm_sta.c | 146 ++++++++++++--------------------------- wpa_supplicant/wnm_sta.h | 2 +- 3 files changed, 45 insertions(+), 105 deletions(-) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 9346a4f61..d61512124 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -2493,7 +2493,7 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s, return 0; } - if (wnm_scan_process(wpa_s, 1) > 0) + if (wnm_scan_process(wpa_s, false) > 0) goto scan_work_done; if (sme_proc_obss_scan(wpa_s) > 0) diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c index b340fae06..6f5f63a8d 100644 --- a/wpa_supplicant/wnm_sta.c +++ b/wpa_supplicant/wnm_sta.c @@ -1172,7 +1172,7 @@ static void wnm_bss_tm_connect(struct wpa_supplicant *wpa_s, } -int wnm_scan_process(struct wpa_supplicant *wpa_s, int reply_on_fail) +int wnm_scan_process(struct wpa_supplicant *wpa_s, bool pre_scan_check) { struct wpa_bss *bss; struct wpa_ssid *ssid = wpa_s->current_ssid; @@ -1185,7 +1185,8 @@ int wnm_scan_process(struct wpa_supplicant *wpa_s, int reply_on_fail) wpa_dbg(wpa_s, MSG_DEBUG, "WNM: Process scan results for BSS Transition Management"); - if (os_reltime_before(&wpa_s->wnm_cand_valid_until, + if (!pre_scan_check && + os_reltime_before(&wpa_s->wnm_cand_valid_until, &wpa_s->scan_trigger_time)) { wpa_printf(MSG_DEBUG, "WNM: Previously stored BSS transition candidate list is not valid anymore - drop it"); wnm_deallocate_memory(wpa_s); @@ -1201,6 +1202,34 @@ int wnm_scan_process(struct wpa_supplicant *wpa_s, int reply_on_fail) /* Compare the Neighbor Report and scan results */ bss = compare_scan_neighbor_results(wpa_s, 0, &reason); + + /* + * If this is a pre-scan check, then returning 0 will trigger a scan + * and another call. In that case, reject "bad" candidates in the hope + * that a better candidate is found after scanning. + * + * Simple heuristic to check whether the selection is reasonable or a + * scan is a good idea. For that, we need to have found a candidate BSS + * (which might be the current one), it is up-to-date and we don't want + * to immediately roam back again. + */ + if (pre_scan_check) { + struct os_reltime age; + + if (!bss) + return 0; + + os_reltime_age(&bss->last_update, &age); + if (age.sec >= 10) + return 0; + + if (bss != wpa_s->current_bss && + wpa_supplicant_need_to_roam_within_ess(wpa_s, + wpa_s->current_bss, + bss)) + return 0; + } + if (!bss) { wpa_printf(MSG_DEBUG, "WNM: No BSS transition candidate match found"); status = WNM_BSS_TM_REJECT_NO_SUITABLE_CANDIDATES; @@ -1212,9 +1241,6 @@ int wnm_scan_process(struct wpa_supplicant *wpa_s, int reply_on_fail) return 1; send_bss_resp_fail: - if (!reply_on_fail) - return 0; - /* Send reject response for all the failures */ if (wpa_s->wnm_reply) { @@ -1354,79 +1380,6 @@ static void wnm_set_scan_freqs(struct wpa_supplicant *wpa_s) } -static int wnm_fetch_scan_results(struct wpa_supplicant *wpa_s) -{ - struct wpa_scan_results *scan_res; - struct wpa_bss *bss; - struct wpa_ssid *ssid = wpa_s->current_ssid; - u8 i, found = 0; - size_t j; - - wpa_dbg(wpa_s, MSG_DEBUG, - "WNM: Fetch current scan results from the driver for checking transition candidates"); - scan_res = wpa_drv_get_scan_results2(wpa_s); - if (!scan_res) { - wpa_dbg(wpa_s, MSG_DEBUG, "WNM: Failed to get scan results"); - return 0; - } - - if (scan_res->fetch_time.sec == 0) - os_get_reltime(&scan_res->fetch_time); - - filter_scan_res(wpa_s, scan_res); - - for (i = 0; i < wpa_s->wnm_num_neighbor_report; i++) { - struct neighbor_report *nei; - - nei = &wpa_s->wnm_neighbor_report_elements[i]; - if (nei->preference_present && nei->preference == 0) - continue; - - for (j = 0; j < scan_res->num; j++) { - struct wpa_scan_res *res; - const u8 *ssid_ie; - - res = scan_res->res[j]; - if (!ether_addr_equal(nei->bssid, res->bssid) || - res->age > WNM_SCAN_RESULT_AGE * 1000) - continue; - bss = wpa_s->current_bss; - ssid_ie = wpa_scan_get_ie(res, WLAN_EID_SSID); - if (bss && ssid_ie && ssid_ie[1] && - (bss->ssid_len != ssid_ie[1] || - os_memcmp(bss->ssid, ssid_ie + 2, - bss->ssid_len) != 0)) - continue; /* Skip entries for other ESSs */ - - /* Potential candidate found */ - found = 1; - scan_snr(res); - scan_est_throughput(wpa_s, res); - wpa_bss_update_scan_res(wpa_s, res, - &scan_res->fetch_time); - } - } - - wpa_scan_results_free(scan_res); - if (!found) { - wpa_dbg(wpa_s, MSG_DEBUG, - "WNM: No transition candidate matches existing scan results"); - return 0; - } - - bss = compare_scan_neighbor_results(wpa_s, WNM_SCAN_RESULT_AGE, NULL); - if (!bss) { - wpa_dbg(wpa_s, MSG_DEBUG, - "WNM: Comparison of scan results against transition candidates did not find matches"); - return 0; - } - - /* Associate to the network */ - wnm_bss_tm_connect(wpa_s, bss, ssid, 0); - return 1; -} - - static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s, const u8 *pos, const u8 *end, int reply) @@ -1634,32 +1587,19 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s, os_memcpy(wpa_s->wnm_cand_from_bss, wpa_s->bssid, ETH_ALEN); /* - * Fetch the latest scan results from the kernel and check for - * candidates based on those results first. This can help in - * finding more up-to-date information should the driver has - * done some internal scanning operations after the last scan - * result update in wpa_supplicant. - */ - if (wnm_fetch_scan_results(wpa_s) > 0) + * Try fetching the latest scan results from the kernel. + * This can help in finding more up-to-date information should the + * driver have done some internal scanning operations after the last + * scan result update in wpa_supplicant. + * + * It is not a new scan, this does not update the last_scan timestamp + * nor will it expire old BSSs. + */ + wpa_supplicant_update_scan_results(wpa_s); + if (wnm_scan_process(wpa_s, true) > 0) return; - - /* - * Try to use previously received scan results, if they are - * recent enough to use for a connection. - */ - if (wpa_s->last_scan_res_used > 0) { - struct os_reltime now; - - os_get_reltime(&now); - if (!os_reltime_expired(&now, &wpa_s->last_scan, 10)) { - wpa_printf(MSG_DEBUG, - "WNM: Try to use recent scan results"); - if (wnm_scan_process(wpa_s, 0) > 0) - return; - wpa_printf(MSG_DEBUG, - "WNM: No match in previous scan results - try a new scan"); - } - } + wpa_printf(MSG_DEBUG, + "WNM: No valid match in previous scan results - try a new scan"); wnm_set_scan_freqs(wpa_s); if (wpa_s->wnm_num_neighbor_report == 1) { diff --git a/wpa_supplicant/wnm_sta.h b/wpa_supplicant/wnm_sta.h index 2a473db4e..2eaa2964f 100644 --- a/wpa_supplicant/wnm_sta.h +++ b/wpa_supplicant/wnm_sta.h @@ -75,7 +75,7 @@ bool wnm_is_bss_excluded(struct wpa_supplicant *wpa_s, struct wpa_bss *bss); #ifdef CONFIG_WNM -int wnm_scan_process(struct wpa_supplicant *wpa_s, int reply_on_fail); +int wnm_scan_process(struct wpa_supplicant *wpa_s, bool pre_scan_check); void wnm_clear_coloc_intf_reporting(struct wpa_supplicant *wpa_s); #else /* CONFIG_WNM */ From patchwork Tue Feb 20 13:18:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1901474 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=xFYPzmj8; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=CBL1uldF; 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 4TfKkf0BYSz23cy for ; Wed, 21 Feb 2024 00:19: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=DvFHV457MC0K2hfIGc23nkEIR4we+6aERJPCLgDM5JQ=; b=xFYPzmj8NqgChE vWmnw+3NkEZMjA2xbYqxBU7h2o88odBN4efHMOs5kDBVx2+7aWFEV2c8OU5v5zWMyThwzzw9OqnEs ThnU9XRlQ3Dqs0nFEN5wbxgpeLg7cKFvVLBq9nkkc7jmj0VkvAkrGHE+ACXH3Z1CsZkQPjP2Qfg2o yzZdxmF1jGOPuy47m3KxRngy8DEfS1b3/xINvbPHsz/4ZaptjyunUacN9W1CBIJ+1F9WxMrofmhGB LBOmdN4Z91IIEUAZM/gqhD7CMzodRXPcorUCK9UB69AKhmnircsRlbXr+jzWZ1R8QLbeqmyGaNOwh qZRk8MF0SpG65BJoil5g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1r-0000000EpEO-0rcE; Tue, 20 Feb 2024 13:19:23 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1a-0000000Ep3V-1mAO for hostap@lists.infradead.org; Tue, 20 Feb 2024 13:19:09 +0000 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=7Ok6Lie8t6uPA5xi44X24e3b2hQR7uVH7lZjfkN6DKY=; t=1708435146; x=1709644746; b=CBL1uldFcRjOttr0wth3SwJC673HK1Xc1eW/31UCtz5gZp9 pt196og9uee0DM06gOPZ8tCGlSs8XTOERFBpkgVWspQhRBX0R5XKR9B9W+GM1TUGoMXwNr3VaF35u GMTaKB9X2HkQjnasX8JEoCACb12q/XTBNeookXzkPUTWQjUDeuNRp+Ai3qmXTzXKlJPEjUp8Girjc WYgv4yM1fBb9DgGPH/eQ9Q6x4MJFvgk0ps4QOz6mBan5snC0ezWifOGPxtKOEdDNDkRekiLs3gO0E jUkg0pDDqFTpSfutcbWg6Kq1gIqK5e9z1xBXLBEd/9uiQGr9W83uFOUzk/a5wUVA==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rcQ1Y-00000000ugq-2hU0; Tue, 20 Feb 2024 14:19:04 +0100 From: benjamin@sipsolutions.net To: hostap@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH v2 10/20] WNM: Don't scan frequencies of neighbors that should be ignored Date: Tue, 20 Feb 2024 14:18:17 +0100 Message-ID: <20240220131827.17766-11-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220131827.17766-1-benjamin@sipsolutions.net> References: <20240220131827.17766-1-benjamin@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240220_051906_547870_16D1750F X-CRM114-Status: GOOD ( 10.20 ) 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: From: Benjamin Berg It does not make sense to scan for neighbors that we are not supposed to use anyway. As such, skip them. Signed-off-by: Benjamin Berg --- wpa_supplicant/wnm_sta.c | 4 ++++ 1 file changed, 4 insertions(+) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches 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_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.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 From: Benjamin Berg It does not make sense to scan for neighbors that we are not supposed to use anyway. As such, skip them. Signed-off-by: Benjamin Berg --- wpa_supplicant/wnm_sta.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c index 6f5f63a8d..71608a394 100644 --- a/wpa_supplicant/wnm_sta.c +++ b/wpa_supplicant/wnm_sta.c @@ -1356,6 +1356,10 @@ static void wnm_set_scan_freqs(struct wpa_supplicant *wpa_s) struct neighbor_report *nei; nei = &wpa_s->wnm_neighbor_report_elements[i]; + + if (nei->preference_present && nei->preference == 0) + continue; + if (nei->freq <= 0) { wpa_printf(MSG_DEBUG, "WNM: Unknown neighbor operating frequency for " From patchwork Tue Feb 20 13:18:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1901477 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=aVIXL5so; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=SfKLS3og; 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 4TfKkt4YkZz23cy for ; Wed, 21 Feb 2024 00:19:50 +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=lJz3+NnxNlLyN6QY+y7PYZTC4WodYsMvh4PlIkUx6uY=; b=aVIXL5soHCVdHa olVqF8rFTAqHoEyyJwsVEyvTkWkYHeFfK7SXCCcWyI5naLSoJWuB1Qq/+EQWc4Av2ey6OhMpD+oE4 mouL03IQOaBrZTSwsXdk3pDnnPfobDrBxeDwtlRuBSTRXr4NEQwPw8PM2Yyml9B3jLd1fS/xtO3/N +62xsO9jCQhFF+IzaplkFPu/43bnwi3AEbvYbiQkMuz6+nGA07Gj1+0oTvm5RaIFp7kv5bIA7wEQV 5JldhxVcMhhxbwB7SU27EYxXVYW9hub0XXtDapBqnENn2m2DxUXC486yVCeDQAprLitpC6Eu9SSEC H6qRIFQiNB9CZHsVantQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ20-0000000EpL6-3x3q; Tue, 20 Feb 2024 13:19:32 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1b-0000000Ep3p-1AJo for hostap@lists.infradead.org; Tue, 20 Feb 2024 13:19:11 +0000 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=I77FWSOz0eRwqNZNLoUMCtx/BRcD/CHrUQS2Hjug4NM=; t=1708435147; x=1709644747; b=SfKLS3ogZ84GAeudJRA5f67e+EH1/Amnq1EwRsmsq90n0YA uUUN6k4q4pn/65/WOzZ4heiiI8iN4Mjx8PVd2YO4qqBunWur73qlNEldWdi9IRHDevOHFqdLC/sqK 9OIjyLMziiLwlsQsQs8CxGH3tbjdbefVa49EhlnZ4Le9UxKuXKOPMox/nMEUJhQWoYAzEaU9DfXv6 5hzJ8CYe0ZsE6pDYDsA2fpQZnwtHD/3XwBa+GhHQQlh/50q8X4+gDZdy10FKS/712g0E17orbUO+l DYHBq4o5ZSN0YlPuv4lKybWvo/7JOMEqbW1CBhMx4INpEiGIDgODsXRC+FmGjLBQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rcQ1Z-00000000ugq-19WA; Tue, 20 Feb 2024 14:19:05 +0100 From: benjamin@sipsolutions.net To: hostap@lists.infradead.org Cc: Avraham Stern , Benjamin Berg Subject: [PATCH v2 11/20] WNM: Wait for BTM response tx status before roaming Date: Tue, 20 Feb 2024 14:18:18 +0100 Message-ID: <20240220131827.17766-12-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220131827.17766-1-benjamin@sipsolutions.net> References: <20240220131827.17766-1-benjamin@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240220_051907_351172_ACDB85D1 X-CRM114-Status: GOOD ( 20.78 ) 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: From: Avraham Stern When accepting a BSS transition request there is a race between sending the response and roaming to the target AP. As a result, the response may not be sent because the station deauthenticated from th [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches 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_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.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 From: Avraham Stern When accepting a BSS transition request there is a race between sending the response and roaming to the target AP. As a result, the response may not be sent because the station deauthenticated from the AP before the response was actually sent. To make sure the BSS transition response is sent, start roaming only after the tx status is received for the BSS transition response. Signed-off-by: Avraham Stern Signed-off-by: Benjamin Berg --- wpa_supplicant/bss.c | 5 +++ wpa_supplicant/events.c | 7 +++++ wpa_supplicant/wnm_sta.c | 52 ++++++++++++++++++++++++++----- wpa_supplicant/wnm_sta.h | 2 ++ wpa_supplicant/wpa_supplicant_i.h | 1 + 5 files changed, 59 insertions(+), 8 deletions(-) diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c index 44d9f8ff9..bf123c026 100644 --- a/wpa_supplicant/bss.c +++ b/wpa_supplicant/bss.c @@ -400,6 +400,11 @@ static int wpa_bss_in_use(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) if (bss == wpa_s->ml_connect_probe_bss) return 1; +#ifdef CONFIG_WNM + if (bss == wpa_s->wnm_target_bss) + return 1; +#endif /* CONFIG_WNM */ + if (wpa_s->current_bss && (bss->ssid_len != wpa_s->current_bss->ssid_len || os_memcmp(bss->ssid, wpa_s->current_bss->ssid, diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index d61512124..d18f43628 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -6140,6 +6140,13 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, " type=%d stype=%d", MAC2STR(data->tx_status.dst), data->tx_status.type, data->tx_status.stype); +#ifdef CONFIG_WNM + if (data->tx_status.type == WLAN_FC_TYPE_MGMT && + data->tx_status.stype == WLAN_FC_STYPE_ACTION && + wnm_btm_resp_tx_status(wpa_s, data->tx_status.data, + data->tx_status.data_len) == 0) + break; +#endif /* CONFIG_WNM */ #ifdef CONFIG_PASN if (data->tx_status.type == WLAN_FC_TYPE_MGMT && data->tx_status.stype == WLAN_FC_STYPE_AUTH && diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c index 71608a394..ec5139889 100644 --- a/wpa_supplicant/wnm_sta.c +++ b/wpa_supplicant/wnm_sta.c @@ -1045,7 +1045,7 @@ static void wnm_add_cand_list(struct wpa_supplicant *wpa_s, struct wpabuf **buf) #define BTM_RESP_MIN_SIZE 5 + ETH_ALEN -static void wnm_send_bss_transition_mgmt_resp( +static int wnm_send_bss_transition_mgmt_resp( struct wpa_supplicant *wpa_s, u8 dialog_token, enum bss_trans_mgmt_status_code status, enum mbo_transition_reject_reason reason, @@ -1061,14 +1061,14 @@ static void wnm_send_bss_transition_mgmt_resp( if (!wpa_s->current_bss) { wpa_printf(MSG_DEBUG, "WNM: Current BSS not known - drop response"); - return; + return -1; } buf = wpabuf_alloc(BTM_RESP_MIN_SIZE); if (!buf) { wpa_printf(MSG_DEBUG, "WNM: Failed to allocate memory for BTM response"); - return; + return -1; } wpa_s->bss_tm_status = status; @@ -1106,7 +1106,7 @@ static void wnm_send_bss_transition_mgmt_resp( wpabuf_free(buf); wpa_printf(MSG_DEBUG, "WNM: Failed to allocate memory for MBO IE"); - return; + return -1; } wpabuf_put_data(buf, mbo, ret); @@ -1123,6 +1123,8 @@ static void wnm_send_bss_transition_mgmt_resp( } wpabuf_free(buf); + + return res; } @@ -1141,12 +1143,17 @@ static void wnm_bss_tm_connect(struct wpa_supplicant *wpa_s, /* Send the BSS Management Response - Accept */ if (wpa_s->wnm_reply) { wpa_s->wnm_reply = 0; + wpa_s->wnm_target_bss = bss; wpa_printf(MSG_DEBUG, "WNM: Sending successful BSS Transition Management Response"); - wnm_send_bss_transition_mgmt_resp( - wpa_s, wpa_s->wnm_dialog_token, WNM_BSS_TM_ACCEPT, - MBO_TRANSITION_REJECT_REASON_UNSPECIFIED, 0, - bss->bssid); + + /* Will be called again from TX handler */ + if (wnm_send_bss_transition_mgmt_resp( + wpa_s, wpa_s->wnm_dialog_token, + WNM_BSS_TM_ACCEPT, + MBO_TRANSITION_REJECT_REASON_UNSPECIFIED, 0, + bss->bssid) >= 0) + return; } if (bss == wpa_s->current_bss) { @@ -1632,6 +1639,35 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s, } +int wnm_btm_resp_tx_status(struct wpa_supplicant *wpa_s, const u8 *data, + size_t data_len) +{ + struct ieee80211_mgmt *frame = (void *)data; + + if (data_len < IEEE80211_HDRLEN + + sizeof(frame->u.action.u.bss_tm_resp) || + frame->u.action.category != WLAN_ACTION_WNM || + frame->u.action.u.bss_tm_resp.action != WNM_BSS_TRANS_MGMT_RESP || + frame->u.action.u.bss_tm_resp.status_code != WNM_BSS_TM_ACCEPT) + return -1; + + /* + * If disassoc imminent bit was set in the request, the response may + * indicate accept even if no candidate was found, so bail out here. + */ + if (!wpa_s->wnm_target_bss) { + wpa_printf(MSG_DEBUG, "WNM: Target BSS is not set"); + return 0; + } + + wnm_bss_tm_connect(wpa_s, wpa_s->wnm_target_bss, wpa_s->current_ssid, + 0); + + wpa_s->wnm_target_bss = NULL; + return 0; +} + + #define BTM_QUERY_MIN_SIZE 4 int wnm_send_bss_transition_mgmt_query(struct wpa_supplicant *wpa_s, diff --git a/wpa_supplicant/wnm_sta.h b/wpa_supplicant/wnm_sta.h index 2eaa2964f..08662f433 100644 --- a/wpa_supplicant/wnm_sta.h +++ b/wpa_supplicant/wnm_sta.h @@ -72,6 +72,8 @@ void wnm_set_coloc_intf_elems(struct wpa_supplicant *wpa_s, struct wpabuf *elems); bool wnm_is_bss_excluded(struct wpa_supplicant *wpa_s, struct wpa_bss *bss); +int wnm_btm_resp_tx_status(struct wpa_supplicant *wpa_s, const u8 *data, + size_t data_len); #ifdef CONFIG_WNM diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 6cacfe485..7a4db4bba 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1309,6 +1309,7 @@ struct wpa_supplicant { struct neighbor_report *wnm_neighbor_report_elements; struct os_reltime wnm_cand_valid_until; u8 wnm_cand_from_bss[ETH_ALEN]; + struct wpa_bss *wnm_target_bss; enum bss_trans_mgmt_status_code bss_tm_status; bool bss_trans_mgmt_in_progress; struct wpabuf *coloc_intf_elems; From patchwork Tue Feb 20 13:18:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1901480 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=4QBwGae0; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=T+7zjuMk; 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 4TfKlD1Tckz20Qg for ; Wed, 21 Feb 2024 00:20:08 +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=2Wpw//CD3F8C5OfbaO2rPqTrkcu1Yv6hIX996rEcrMM=; b=4QBwGae0uE00L1 bxONb+p+HXbggcbRRE5XVB/IsC3BXjIoZ+hABPN0eNFImflBeon7WCJofJZJhTk+PHDk8g1LQkOIf 09h2/TrFy4mr7PVUJ2eIEnXds0KynWqpbkRr7xaoulzDEaMW28eClNPZgSOg4/667isMmzQQ5msTX gyA4tzAsDA+Wbeu0CeAxpt9AHMFDM4/1X8bM3Y2FVbkALg9IIv7fLtU9Iwnxwm0iKTHtwbYAN9fVb lPpytJ/wQzF3UeCIVSJ1wfA25mejuwrZIZJCElwukf6H29kF2gVEUIrYY6nimjB6ikm3R4B4X8ecv um1EtRN/wtQ4Vnw2Kmow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ2F-0000000EpYk-3ktp; Tue, 20 Feb 2024 13:19:47 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1c-0000000Ep4n-1obq for hostap@lists.infradead.org; Tue, 20 Feb 2024 13:19:11 +0000 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=eLJ+vnL/lJUvHmokYRH+Lc+CIgvTRJaO4qGFcFiiO1c=; t=1708435148; x=1709644748; b=T+7zjuMkC6G8F8hT9M8G0OvEZxUzSBp1ImCZVabZH8nXCxR 9/jai5owOBQ3Tk8BlZ15bECJFYCNRZ/u7MDV2GBVStBui7wR0SJzGKb1koho75DZ0+czx9705QNpu skGHhM3LVS2FRQ5LqknUW27aTq1T6artg6f++FG9IkZnk46hOiouwr1eJrFaSxB+9GSmMOBIHo6IV G1oiQvq8g/aUr4fKK9SCo/gheyW5yBAJ+iV0H6ZVjtEJKFV2HkGw3B/NschmlX5M2T+Va/nXoZ2Zt kujgMpfR4AxDQGH1wJtXK8NIY1486R5yf6JqktYQ9xNXgGa4eFvz/q+lsK1XqRDQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rcQ1Z-00000000ugq-3ex8; Tue, 20 Feb 2024 14:19:06 +0100 From: benjamin@sipsolutions.net To: hostap@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH v2 12/20] WNM: Define a stub wnm_is_bss_excluded if WNM is disabled Date: Tue, 20 Feb 2024 14:18:19 +0100 Message-ID: <20240220131827.17766-13-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220131827.17766-1-benjamin@sipsolutions.net> References: <20240220131827.17766-1-benjamin@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240220_051908_631149_FBA6AE95 X-CRM114-Status: GOOD ( 11.69 ) 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: From: Benjamin Berg This removes the need to check for CONFIG_WNM. Signed-off-by: Benjamin Berg --- wpa_supplicant/events.c | 2 -- wpa_supplicant/wnm_sta.h | 9 ++++++++- 2 files changed, 8 insertions(+), 3 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches 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_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.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 From: Benjamin Berg This removes the need to check for CONFIG_WNM. Signed-off-by: Benjamin Berg --- wpa_supplicant/events.c | 2 -- wpa_supplicant/wnm_sta.h | 9 ++++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index d18f43628..fe77eb9f5 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1692,13 +1692,11 @@ struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s, return NULL; } -#ifdef CONFIG_WNM if (wnm_is_bss_excluded(wpa_s, bss)) { if (debug_print) wpa_dbg(wpa_s, MSG_DEBUG, " skip - BSSID excluded"); return NULL; } -#endif /* CONFIG_WNM */ for (ssid = group; ssid; ssid = only_first_ssid ? NULL : ssid->pnext) { if (wpa_scan_res_ok(wpa_s, ssid, match_ssid, match_ssid_len, diff --git a/wpa_supplicant/wnm_sta.h b/wpa_supplicant/wnm_sta.h index 08662f433..e1bb6724d 100644 --- a/wpa_supplicant/wnm_sta.h +++ b/wpa_supplicant/wnm_sta.h @@ -70,7 +70,6 @@ int wnm_send_coloc_intf_report(struct wpa_supplicant *wpa_s, u8 dialog_token, const struct wpabuf *elems); void wnm_set_coloc_intf_elems(struct wpa_supplicant *wpa_s, struct wpabuf *elems); -bool wnm_is_bss_excluded(struct wpa_supplicant *wpa_s, struct wpa_bss *bss); int wnm_btm_resp_tx_status(struct wpa_supplicant *wpa_s, const u8 *data, size_t data_len); @@ -80,6 +79,8 @@ int wnm_btm_resp_tx_status(struct wpa_supplicant *wpa_s, const u8 *data, int wnm_scan_process(struct wpa_supplicant *wpa_s, bool pre_scan_check); void wnm_clear_coloc_intf_reporting(struct wpa_supplicant *wpa_s); +bool wnm_is_bss_excluded(struct wpa_supplicant *wpa_s, struct wpa_bss *bss); + #else /* CONFIG_WNM */ static inline int wnm_scan_process(struct wpa_supplicant *wpa_s, @@ -92,6 +93,12 @@ static inline void wnm_clear_coloc_intf_reporting(struct wpa_supplicant *wpa_s) { } +static inline bool +wnm_is_bss_excluded(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) +{ + return false; +} + #endif /* CONFIG_WNM */ #endif /* WNM_STA_H */ From patchwork Tue Feb 20 13:18:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1901479 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=xVnhyp4H; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=kYV7d2gv; 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 4TfKl43H1Dz23d0 for ; Wed, 21 Feb 2024 00:20:00 +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=BQzTEAdrP7gAM2u/wGctf+GWsZj5jG+/1cewexSooNw=; b=xVnhyp4H6K/m0T ooLl3vfVvKOvZMQFi5hHmf1KEwyaC3u5IOIdDuSr1Zuq2/ynbRGK6XQMFAJm//cg4nOtZj9CQGSrN aTXgnWSJO7yQzjbEClhW4DXt79r/iPg/Y25X1+DoZJCO2OcbzXCcMFkh7Tb6Nn0mO/HJojH/X5yBz zbL6tJiXB40xKw/e461aa7c17eC2hdp2eiInY0NxzVQocm1keT06P/zN7X+pbQ+l2ARnFFgAeJbhm 5fmbSyj7mWPrkZcjb9ihz0tibvSGCgvMctLXW8wGk+1vNK2X9IyZpZmYOTxeeaOmkTo+5dJFzqOSv 16UgKi1g2yH1DjwHdZQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ29-0000000EpSu-39fO; Tue, 20 Feb 2024 13:19:41 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1c-0000000Ep4m-1MGZ for hostap@lists.infradead.org; Tue, 20 Feb 2024 13:19:11 +0000 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=2D32+DUsLE/93na9Idk7T/d5KH1YrvVQocWHljCw3DQ=; t=1708435148; x=1709644748; b=kYV7d2gv5vWQsSSqfilODLvxMPhW9PQKN5Yf/RvEPtePQ/a 1LpVT0mzzU4LMNBNCJlPznOtkJGV0bfZEm/tAfcbzrQ6dIQ9+vEGSw/G0FHIXpYbfwpps2xZyYLIv Ub/jQUpp4oUqCZhAqiZrt2e/Ze0RZFWb9eEODO49Zitn+9WuBNAbDYdBjz20CklfoAt0rY8sZ3sDh tdFbuxjUgveu1SV97EvFQhKZTkwy/Iwt2Xl+nBgNj0G+KrnmX3gmVdgqy980TiQBgwG4+d2AjU5QL cC9IOa5LjJe6OtPi6riLBq+/MAumAR8g2p0VAcU+K9fzCnvXSsCYAp5n9vh7g6Mg==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rcQ1a-00000000ugq-2ScP; Tue, 20 Feb 2024 14:19:06 +0100 From: benjamin@sipsolutions.net To: hostap@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH v2 13/20] WNM: Drop check for current_ssid Date: Tue, 20 Feb 2024 14:18:20 +0100 Message-ID: <20240220131827.17766-14-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220131827.17766-1-benjamin@sipsolutions.net> References: <20240220131827.17766-1-benjamin@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240220_051908_532755_99D946CE X-CRM114-Status: GOOD ( 10.41 ) 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: From: Benjamin Berg It should never be NULL. In the unlikely event that it is NULL, the logic changes slightly to reject all candidates. Signed-off-by: Benjamin Berg --- wpa_supplicant/wnm_sta.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches 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_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.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 From: Benjamin Berg It should never be NULL. In the unlikely event that it is NULL, the logic changes slightly to reject all candidates. Signed-off-by: Benjamin Berg --- wpa_supplicant/wnm_sta.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c index ec5139889..199d7985c 100644 --- a/wpa_supplicant/wnm_sta.c +++ b/wpa_supplicant/wnm_sta.c @@ -795,8 +795,7 @@ compare_scan_neighbor_results(struct wpa_supplicant *wpa_s, os_time_t age_secs, continue; } - if (wpa_s->current_ssid && - !wpa_scan_res_match(wpa_s, 0, target, wpa_s->current_ssid, + if (!wpa_scan_res_match(wpa_s, 0, target, wpa_s->current_ssid, 1, 0)) { wpa_printf(MSG_DEBUG, "Candidate BSS " MACSTR " (pref %d) does not match the current network profile", From patchwork Tue Feb 20 13:18:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1901481 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=q1KvZnzX; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=RnELpPuK; 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 4TfKlZ4Jblz20Qg for ; Wed, 21 Feb 2024 00:20:26 +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=rmgPzN1GA9t+zIdg79GLA1hRbHynpNdlsQrmT9KVBFM=; b=q1KvZnzXM/3THd BoC+I3Td6B+C/vohLVMMECOBuwB9jd73AXw/a6I8Upv7niaDCQmxZQuW78Ow5xnTEmVYrPSKXIU8m hSz7nmoRso43KaW2Y+fz29kwgPHoLCsUYWdXq/h3nwiRxgAK7kOQtykzh3rj9gM5ZRk0S+30EdSb6 DAoChBk7zPrrNUWgOxmW79hIIcjsLem0hvlPJHNuIJ3LRV0OmpIEqNZEJuJP+fBnyOtIKXLBs4BIj 79m9wcfXd+GQaZDbmfNWvu4gvtix84TyhqLt8y/xJEvIrWl9tZ/0U0wiCuTedm4xp8eaebq63meid zuiD1tnzEYYidzsuWEww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ2Z-0000000EprS-3Xc2; Tue, 20 Feb 2024 13:20:07 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1d-0000000Ep5C-0sPL for hostap@lists.infradead.org; Tue, 20 Feb 2024 13:19:12 +0000 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=DNesWWrNxslmfCfduxQHoGnsIwu78cymZ6imaCRQF7Y=; t=1708435149; x=1709644749; b=RnELpPuK38FbnuMXHjGii+EKug6WL8nc092Y76fgJULf/O6 BZPYfmbN9LBYfNCy1v0aedpWx3nKZxqw2HvtqNL6ewJaeTJVtOyQaxkJphFJikaXrmAX97vGDu95S WFuTqyETxyEzxGGDVwX/QAOB4M+YVgYxOA08isYZbDTTuQxenR0YHCwalRHi7eSHFQs+QczrY+PhU p3WSfG474SD9F8kytGtW2h+BQdaogrJmaBYVIw69L8mlTD+DDX2wb3JPIN71f+D89GmRI2/aTuFBF ZVqixH++/LFXbPx2RKXArNXfL1AnZwcwaUpIjAPXFlqhj12wB5e6S85h3vjgg+Bg==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rcQ1b-00000000ugq-0pQK; Tue, 20 Feb 2024 14:19:07 +0100 From: benjamin@sipsolutions.net To: hostap@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH v2 14/20] WNM: Drop explicit SSID check Date: Tue, 20 Feb 2024 14:18:21 +0100 Message-ID: <20240220131827.17766-15-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220131827.17766-1-benjamin@sipsolutions.net> References: <20240220131827.17766-1-benjamin@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240220_051909_382951_EADA94DF X-CRM114-Status: UNSURE ( 9.13 ) X-CRM114-Notice: Please train this message. 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: From: Benjamin Berg The call to wpa_scan_res_match already checks that the SSID matches current_ssid. Therefore there is no need to do any further checking. Signed-off-by: Benjamin Berg --- wpa_supplicant/wnm_sta.c | 18 ++++ 1 file changed, 4 insertions(+), 14 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches 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_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.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 From: Benjamin Berg The call to wpa_scan_res_match already checks that the SSID matches current_ssid. Therefore there is no need to do any further checking. Signed-off-by: Benjamin Berg --- wpa_supplicant/wnm_sta.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c index 199d7985c..2ba78377a 100644 --- a/wpa_supplicant/wnm_sta.c +++ b/wpa_supplicant/wnm_sta.c @@ -781,20 +781,10 @@ compare_scan_neighbor_results(struct wpa_supplicant *wpa_s, os_time_t age_secs, } } - if (bss->ssid_len != target->ssid_len || - os_memcmp(bss->ssid, target->ssid, bss->ssid_len) != 0) { - /* - * TODO: Could consider allowing transition to another - * ESS if PMF was enabled for the association. - */ - wpa_printf(MSG_DEBUG, "Candidate BSS " MACSTR - " (pref %d) in different ESS", - MAC2STR(nei->bssid), - nei->preference_present ? nei->preference : - -1); - continue; - } - + /* + * TODO: Could consider allowing transition to another ESS if + * PMF was enabled for the association. + */ if (!wpa_scan_res_match(wpa_s, 0, target, wpa_s->current_ssid, 1, 0)) { wpa_printf(MSG_DEBUG, "Candidate BSS " MACSTR From patchwork Tue Feb 20 13:18:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1901482 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=0KHYrRwE; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=o/PLxl//; 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 4TfKm02xlhz20Qg for ; Wed, 21 Feb 2024 00:20:48 +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=BHgdY9mrvcgxSSUZw1TvrKykt9/jKv+Iph5F2cPJtdQ=; b=0KHYrRwEJkevqr C0c8O2o2HKvkool4gsp7Uxmw4CxLCFBO83k/c1qP9yW3KP/3zVH0Jbj1r8dAIT8bje9s/r0yrYfIL VqQ71j+rRII2a3KMDQq7aXSj+ltz2ixrhLJzm1yLuKYHKBCb36VLXThwYc0kzn1jCEukQY4c0qNBw /SOMSzOAvym9AO10uD6NBSf4A4SQA3ew31enzBJrkhKjxM3dwQIji1qYpWKYNekhBKjNZfhHvmxWM dtq48IQWgSkbkHgX8T9bVqsrhL3Oxi8oqut/tCl21DoHc2/8HU0BkjvVfLxxJHX7EIyXTGQX0n6D4 p/PYabcwXYpyq3KMWacQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ2u-0000000EqA9-0xqc; Tue, 20 Feb 2024 13:20:28 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1e-0000000Ep6A-1lVv for hostap@lists.infradead.org; Tue, 20 Feb 2024 13:19:13 +0000 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=t45xQ8FhK5THcPfbfUZIxkmWFY0nFxk+mkzb5KnWhSk=; t=1708435150; x=1709644750; b=o/PLxl//WQV7Fn8JZvtoJbiZp3TiSZO5mWvIy7s/KWiFYiN zn+BHfB8LUxA4nkFxBIU+eGLY+eF5FKnpLiz9Of10YSjyskL9wbxT/U+0brdTTOt8Py4xMCpWldlc xzkvA6rKhPoYlrdNa23on9bAOLFAX+YRCOZ/jLOOmQahTsifu0YRuXfBXA2Bg8y54JmUjd+K5vZ6a IvlvadjKXkhC3LezK10NfmPWUGqFMtZIkf/zpUTJ7wKv8ACwd9IRRrnXB+e68fvqo3N6JLf80B+R5 +tRp4zehtRPi8zLUXkYMUI0GROLO8LPGH1MF2sC2kGIbUv6hiWYrS8R6EHEN/ECQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rcQ1b-00000000ugq-3PP6; Tue, 20 Feb 2024 14:19:08 +0100 From: benjamin@sipsolutions.net To: hostap@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH v2 15/20] WNM: Drop explicit wpa_is_bss_tmp_disallowed check Date: Tue, 20 Feb 2024 14:18:22 +0100 Message-ID: <20240220131827.17766-16-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220131827.17766-1-benjamin@sipsolutions.net> References: <20240220131827.17766-1-benjamin@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240220_051910_604623_52B98CE0 X-CRM114-Status: UNSURE ( 8.01 ) X-CRM114-Notice: Please train this message. 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: From: Benjamin Berg There is no need for this check as wpa_scan_res_match already calls the function. Signed-off-by: Benjamin Berg --- wpa_supplicant/wnm_sta.c | 8 -------- 1 file changed, 8 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches 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_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.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 From: Benjamin Berg There is no need for this check as wpa_scan_res_match already calls the function. Signed-off-by: Benjamin Berg --- wpa_supplicant/wnm_sta.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c index 2ba78377a..1d567029a 100644 --- a/wpa_supplicant/wnm_sta.c +++ b/wpa_supplicant/wnm_sta.c @@ -795,14 +795,6 @@ compare_scan_neighbor_results(struct wpa_supplicant *wpa_s, os_time_t age_secs, continue; } - if (wpa_is_bss_tmp_disallowed(wpa_s, target)) { - wpa_printf(MSG_DEBUG, - "MBO: Candidate BSS " MACSTR - " retry delay is not over yet", - MAC2STR(nei->bssid)); - continue; - } - if (target->level < bss->level && target->level < -80) { wpa_printf(MSG_DEBUG, "Candidate BSS " MACSTR " (pref %d) does not have sufficient signal level (%d)", From patchwork Tue Feb 20 13:18:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1901483 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=nTED6Ov0; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=ePhQr8V8; 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 4TfKmK0HL4z20Qg for ; Wed, 21 Feb 2024 00:21:05 +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=KLS51/EV8f7fLvWZShOnU18VTtkZXJNXoHQ2BOHAxy4=; b=nTED6Ov0sqc5+/ blQC+uuTwJ96B+QMbSXA+O8vN40g7EbVdjFKv4mBxepQDQyEwjY/G5c4IqdhMwGzB/Q4GMZduZeFr kOea+3L9wZ+BOH9/sTH/Uqi6rV8uib6BbzplpGY4+PbmSpfAo15t+qPW8qs21g25teUolVjAti+Qn 0cH3L3rixNahq7T9EEaSPgkEvuUes+tn9qnlN2DI2RVKI08T0Tun0UFm2nadxQZS8BDPVDi9ewjNI kco4SOiXXxmcawSg1PfWGcozwton7kc68r1KcNgzsEzLNltuD7zWSKshRR2vX6NkEaUg1jz487RkA 8/XvzuX8mQH4NL8wDtSg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ3D-0000000EqRG-0EwM; Tue, 20 Feb 2024 13:20:47 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1e-0000000Ep6p-3qAW for hostap@lists.infradead.org; Tue, 20 Feb 2024 13:19:13 +0000 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=Ibgc6ij8IL2S2l6XBM+QEM6JNmHbWeLeTA8FUsMtHkw=; t=1708435150; x=1709644750; b=ePhQr8V8WQ7q96Vpm3rzbc61Pg4D9baPEspQebFGY4HzMNb jrD9Ckt7ITXd89Ximb6kDhsuUnxPNJgGjcesg+5QI82i9ZXwo1d/jcc9zV2LljHsZT5gq2+XZGCAr w9P7QeHRSDDBD1TNTKy83yI/ouBVMzQLD8UiyYLfojYXoOWDtLmrRRZ2I0kwIyKJmpgVYGJT9zHce 4BLDBkb0x7Kz2z541yWhiHU6/uxg/8KTrKsmQwi4JXs/kUo9LIPGYh8C5/TM/JCy7QAWWA2Jy/C4u 1mz9IxklgspftbDIyArq/qG2PqkbE+Cc7dPaJGzD/tE6VIaFaR098Z+1RvHX9VEA==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rcQ1d-00000000ugq-0eAv; Tue, 20 Feb 2024 14:19:09 +0100 From: benjamin@sipsolutions.net To: hostap@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH v2 16/20] WNM: Do not store coloc_intf_elems Date: Tue, 20 Feb 2024 14:18:23 +0100 Message-ID: <20240220131827.17766-17-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220131827.17766-1-benjamin@sipsolutions.net> References: <20240220131827.17766-1-benjamin@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240220_051911_138504_CB55E0C5 X-CRM114-Status: GOOD ( 13.85 ) 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: From: Benjamin Berg The elements are (currently) not used except for sending an immediate response similar to COLOC_INTF_REPORT with the main difference being that the dialog token is included. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches 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_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.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 From: Benjamin Berg The elements are (currently) not used except for sending an immediate response similar to COLOC_INTF_REPORT with the main difference being that the dialog token is included. Do not store the elements. It easy enough to re-add this should the implementation improve. And this fixes the fact that the variable is cleared at odd times as wnm_deallocate_memory is used specifically to clear the neighbor report list of a BTM request. Signed-off-by: Benjamin Berg --- wpa_supplicant/wnm_sta.c | 13 ++++++------- wpa_supplicant/wpa_supplicant_i.h | 1 - 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c index 1d567029a..fe57e9649 100644 --- a/wpa_supplicant/wnm_sta.c +++ b/wpa_supplicant/wnm_sta.c @@ -430,9 +430,6 @@ void wnm_deallocate_memory(struct wpa_supplicant *wpa_s) wpa_s->wnm_num_neighbor_report = 0; os_free(wpa_s->wnm_neighbor_report_elements); wpa_s->wnm_neighbor_report_elements = NULL; - - wpabuf_free(wpa_s->coloc_intf_elems); - wpa_s->coloc_intf_elems = NULL; } @@ -2001,14 +1998,14 @@ int wnm_send_coloc_intf_report(struct wpa_supplicant *wpa_s, u8 dialog_token, void wnm_set_coloc_intf_elems(struct wpa_supplicant *wpa_s, struct wpabuf *elems) { - wpabuf_free(wpa_s->coloc_intf_elems); if (elems && wpabuf_len(elems) == 0) { wpabuf_free(elems); elems = NULL; } - wpa_s->coloc_intf_elems = elems; - if (wpa_s->conf->coloc_intf_reporting && wpa_s->coloc_intf_elems && + /* NOTE: The elements are not stored as they are only send out once */ + + if (wpa_s->conf->coloc_intf_reporting && elems && wpa_s->coloc_intf_dialog_token && (wpa_s->coloc_intf_auto_report == 1 || wpa_s->coloc_intf_auto_report == 3)) { @@ -2017,8 +2014,10 @@ void wnm_set_coloc_intf_elems(struct wpa_supplicant *wpa_s, */ wnm_send_coloc_intf_report(wpa_s, wpa_s->coloc_intf_dialog_token, - wpa_s->coloc_intf_elems); + elems); } + + wpabuf_free(elems); } diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 7a4db4bba..c8f346d72 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1312,7 +1312,6 @@ struct wpa_supplicant { struct wpa_bss *wnm_target_bss; enum bss_trans_mgmt_status_code bss_tm_status; bool bss_trans_mgmt_in_progress; - struct wpabuf *coloc_intf_elems; u8 coloc_intf_dialog_token; u8 coloc_intf_auto_report; u8 coloc_intf_timeout; From patchwork Tue Feb 20 13:18:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1901484 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=2Jeykp7Z; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=fasro9ez; 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 4TfKmT0pdGz20Qg for ; Wed, 21 Feb 2024 00:21:13 +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=awk5RK8Zlp3OOd0ShRRkHtWu1/r2/qeSTLRtaOXaaaw=; b=2Jeykp7Z54c2ak GFA2ZmXzGjsKCfsTZ2p2C/NrXh210Genb4XqK08he+TslS4qpPQP4DJOjHPH12dGS4LEtZQLX9jjn QWlT/K83aNrlmO8/VXrgcdRCNJ0VcSttqVsD35cEsv6+sRdDNb4CUN8r+c/wTEi66ZKuKsdN0K3DY kTHqFEhcxJNvN3KhpnR2sYlf66FBwRXC//O0FZNhaRYWvd+uyPMWKnAfKuHodYFe8GTldt/O0bIM2 VtDAvnhtEn3kT0RGp1NMBt/rPVEU28g1jogiz5zwXA88wPtI+uWK+3Xk2qhyzo8zqN4roY9Kwx9Df wX1h4ixCOoDUnzuFIrFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ3K-0000000EqY7-3moj; Tue, 20 Feb 2024 13:20:54 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1f-0000000Ep7D-3iod for hostap@lists.infradead.org; Tue, 20 Feb 2024 13:19:14 +0000 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=S1k4xTGEhbx6G+JowTfgr9bPemif5Dho+osoRdF2SvI=; t=1708435151; x=1709644751; b=fasro9ezNEDBWdFfaCYNHxukx4cGFVUyh7SYFmiWM9nw1yN 2uMqRLcTSTotLCVryQRBb5Y0F7tZgxcjgtSC38GMF/eQgQb6licE+/i7uaKICHwOzHfbkBn7Jr6dD fcO151CwMvio/uVHmI3HkpTTvSouaBI418YwiiI/MPRfcGuzanKh//9XbkZE27d1km6K/X1xu6xo8 ovk6EKxkWTtB6juDbKwGgKDndDkE9nhVPvSl0o5c2PaaylbZMx3xNGwy1N1m4HhRSyHsO7M3zQgUU mYeiJg/rrnYlAYTzyeVbW9btyR1LW0E0Clf2O4bd4EbEoSK0fL8kpmkz9ZEySMRg==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rcQ1d-00000000ugq-3eaD; Tue, 20 Feb 2024 14:19:10 +0100 From: benjamin@sipsolutions.net To: hostap@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH v2 17/20] WNM: Set wnm_reply to 0 when sending it Date: Tue, 20 Feb 2024 14:18:24 +0100 Message-ID: <20240220131827.17766-18-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220131827.17766-1-benjamin@sipsolutions.net> References: <20240220131827.17766-1-benjamin@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240220_051912_186104_B5BCCD28 X-CRM114-Status: GOOD ( 12.03 ) 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: From: Benjamin Berg There is no point in the caller to set it to zero. Just do so within wnm_send_bss_transition_mgmt_resp. Signed-off-by: Benjamin Berg --- wpa_supplicant/wnm_sta.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches 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_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.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 From: Benjamin Berg There is no point in the caller to set it to zero. Just do so within wnm_send_bss_transition_mgmt_resp. Signed-off-by: Benjamin Berg --- wpa_supplicant/wnm_sta.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c index fe57e9649..7567ea5b6 100644 --- a/wpa_supplicant/wnm_sta.c +++ b/wpa_supplicant/wnm_sta.c @@ -1032,6 +1032,8 @@ static int wnm_send_bss_transition_mgmt_resp( struct wpabuf *buf; int res; + wpa_s->wnm_reply = 0; + wpa_printf(MSG_DEBUG, "WNM: Send BSS Transition Management Response to " MACSTR " dialog_token=%u status=%u reason=%u delay=%d", @@ -1120,7 +1122,6 @@ static void wnm_bss_tm_connect(struct wpa_supplicant *wpa_s, /* Send the BSS Management Response - Accept */ if (wpa_s->wnm_reply) { - wpa_s->wnm_reply = 0; wpa_s->wnm_target_bss = bss; wpa_printf(MSG_DEBUG, "WNM: Sending successful BSS Transition Management Response"); @@ -1228,12 +1229,11 @@ int wnm_scan_process(struct wpa_supplicant *wpa_s, bool pre_scan_check) send_bss_resp_fail: /* Send reject response for all the failures */ - if (wpa_s->wnm_reply) { - wpa_s->wnm_reply = 0; + if (wpa_s->wnm_reply) wnm_send_bss_transition_mgmt_resp(wpa_s, wpa_s->wnm_dialog_token, status, reason, 0, NULL); - } + wnm_deallocate_memory(wpa_s); return 0; From patchwork Tue Feb 20 13:18:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1901485 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=IbKvErZy; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=RAHCJ1K8; 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 4TfKmg13YWz20Qg for ; Wed, 21 Feb 2024 00:21:23 +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=wRc4I0Jp4xjB9FvjX/JEmF0jIG6iIOBqK0iBnnFG5So=; b=IbKvErZyqNG7cZ 97qh/SOTjtU1VLZdvAWo2/gt+RJcz1LAKDrSRQfLlfP5wZTfrdrWZ7E50Jj9q7vTDW7Yn40nQsk11 I7mbDY9ycE1aGU+MI09JF4Gqr0/Icde4VXBTe+VtYkhfHFpi657zOhrttCzXSgXMhzb7MIITecKdb KkHfWAv65hLj7dI960MHx24pJdLNAPCocExSMYknY3rSGc0hGdTO8Ll8mOcQqhHmHfmI9Xas8qlpV NOqHL1mc0SZow3buQoid8jAMjL77rRFxboqsA83kxetu9obHgy/wV11oezzHrkuMyPR9zkObARJab hAM5WJ8MfvTm3EbFShbg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ3U-0000000EqgV-1gKf; Tue, 20 Feb 2024 13:21:04 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1g-0000000Ep7s-1tID for hostap@lists.infradead.org; Tue, 20 Feb 2024 13:19:14 +0000 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=wy0q1nFJ0cNdAmfVzFNvJZnFPbHGo12neVmf0M1Ai4k=; t=1708435152; x=1709644752; b=RAHCJ1K8uGCufBnxyDZ4ElKiv2djot/qmQtqGWQ151Cv0mN Q5NyCbSdJ52Zu/hs6rS22jhI22dsj5lFb7c5vhWhIyKhohH/WryL4mVtTspBwYdWBXjSDIEoKhpBV nO7eLFDSiGnKa4k1Jnwpa+0yi4Nd5e3DjqntRuQFLw5kTbxbqSJGRgEL4D94uEQJaw3TDbgIGIqs9 KuYxyKv0AdtHo+GE3dBMSpgDH7hTmOk8AI1HA1opYX4NLV0BPnXSIYejMWiqTZ1khp1b+n3uiuDJO sTsDSkIerKFwlEM7pGflIvtEZnSU1v+4tUTrAv8HSS2mXP742R6xrjDKesLX4HzQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rcQ1e-00000000ugq-2SCC; Tue, 20 Feb 2024 14:19:10 +0100 From: benjamin@sipsolutions.net To: hostap@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH v2 18/20] WNM: Remove dialog_token parameter Date: Tue, 20 Feb 2024 14:18:25 +0100 Message-ID: <20240220131827.17766-19-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220131827.17766-1-benjamin@sipsolutions.net> References: <20240220131827.17766-1-benjamin@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240220_051912_569630_735C209D X-CRM114-Status: GOOD ( 10.22 ) 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: From: Benjamin Berg All callers of wnm_send_bss_transition_mgmt_resp are explicitly passing wpa_s->wnm_dialog_token. As such, we might as well not pass it and use the variable directly. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches 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_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.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 From: Benjamin Berg All callers of wnm_send_bss_transition_mgmt_resp are explicitly passing wpa_s->wnm_dialog_token. As such, we might as well not pass it and use the variable directly. Signed-off-by: Benjamin Berg --- wpa_supplicant/wnm_sta.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c index 7567ea5b6..2d43950c8 100644 --- a/wpa_supplicant/wnm_sta.c +++ b/wpa_supplicant/wnm_sta.c @@ -1024,7 +1024,7 @@ static void wnm_add_cand_list(struct wpa_supplicant *wpa_s, struct wpabuf **buf) #define BTM_RESP_MIN_SIZE 5 + ETH_ALEN static int wnm_send_bss_transition_mgmt_resp( - struct wpa_supplicant *wpa_s, u8 dialog_token, + struct wpa_supplicant *wpa_s, enum bss_trans_mgmt_status_code status, enum mbo_transition_reject_reason reason, u8 delay, const u8 *target_bssid) @@ -1037,7 +1037,8 @@ static int wnm_send_bss_transition_mgmt_resp( wpa_printf(MSG_DEBUG, "WNM: Send BSS Transition Management Response to " MACSTR " dialog_token=%u status=%u reason=%u delay=%d", - MAC2STR(wpa_s->bssid), dialog_token, status, reason, delay); + MAC2STR(wpa_s->bssid), wpa_s->wnm_dialog_token, status, + reason, delay); if (!wpa_s->current_bss) { wpa_printf(MSG_DEBUG, "WNM: Current BSS not known - drop response"); @@ -1056,7 +1057,7 @@ static int wnm_send_bss_transition_mgmt_resp( wpabuf_put_u8(buf, WLAN_ACTION_WNM); wpabuf_put_u8(buf, WNM_BSS_TRANS_MGMT_RESP); - wpabuf_put_u8(buf, dialog_token); + wpabuf_put_u8(buf, wpa_s->wnm_dialog_token); wpabuf_put_u8(buf, status); wpabuf_put_u8(buf, delay); if (target_bssid) { @@ -1128,8 +1129,7 @@ static void wnm_bss_tm_connect(struct wpa_supplicant *wpa_s, /* Will be called again from TX handler */ if (wnm_send_bss_transition_mgmt_resp( - wpa_s, wpa_s->wnm_dialog_token, - WNM_BSS_TM_ACCEPT, + wpa_s, WNM_BSS_TM_ACCEPT, MBO_TRANSITION_REJECT_REASON_UNSPECIFIED, 0, bss->bssid) >= 0) return; @@ -1230,9 +1230,8 @@ send_bss_resp_fail: /* Send reject response for all the failures */ if (wpa_s->wnm_reply) - wnm_send_bss_transition_mgmt_resp(wpa_s, - wpa_s->wnm_dialog_token, - status, reason, 0, NULL); + wnm_send_bss_transition_mgmt_resp(wpa_s, status, reason, + 0, NULL); wnm_deallocate_memory(wpa_s); @@ -1415,8 +1414,7 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s, "WNM: Testing - reject BSS Transition Management Request: reject_btm_req_reason=%d", wpa_s->reject_btm_req_reason); wnm_send_bss_transition_mgmt_resp( - wpa_s, wpa_s->wnm_dialog_token, - wpa_s->reject_btm_req_reason, + wpa_s, wpa_s->reject_btm_req_reason, MBO_TRANSITION_REJECT_REASON_UNSPECIFIED, 0, NULL); return; } @@ -1544,8 +1542,7 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s, wpa_printf(MSG_DEBUG, "WNM: Candidate list included bit is set, but no candidates found"); wnm_send_bss_transition_mgmt_resp( - wpa_s, wpa_s->wnm_dialog_token, - WNM_BSS_TM_REJECT_NO_SUITABLE_CANDIDATES, + wpa_s, WNM_BSS_TM_REJECT_NO_SUITABLE_CANDIDATES, MBO_TRANSITION_REJECT_REASON_UNSPECIFIED, 0, NULL); return; @@ -1555,8 +1552,7 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s, wpa_printf(MSG_DEBUG, "WNM: Configuration prevents roaming (BSSID set)"); wnm_send_bss_transition_mgmt_resp( - wpa_s, wpa_s->wnm_dialog_token, - WNM_BSS_TM_REJECT_NO_SUITABLE_CANDIDATES, + wpa_s, WNM_BSS_TM_REJECT_NO_SUITABLE_CANDIDATES, MBO_TRANSITION_REJECT_REASON_UNSPECIFIED, 0, NULL); return; @@ -1611,7 +1607,7 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s, status = WNM_BSS_TM_REJECT_UNSPECIFIED; } wnm_send_bss_transition_mgmt_resp( - wpa_s, wpa_s->wnm_dialog_token, status, + wpa_s, status, MBO_TRANSITION_REJECT_REASON_UNSPECIFIED, 0, NULL); } } From patchwork Tue Feb 20 13:18:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1901486 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=sk9TUENh; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=uxsxgofP; 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 4TfKn12BD5z20Qg for ; Wed, 21 Feb 2024 00:21:41 +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=haNtKnIV9wExm/jdMdRvszbM6q+0mctjJcX1wQqPw7o=; b=sk9TUENhOM2Ye5 MZuPArFsv3MJZBgNqZLGf3JNUxE6zQX09S9x1QDnKN0RxWnMHaptWQIzBIVwO0cXncjzVfuWiDF1D YDHDzN02WPGJlSeuEtXWzrFP7a8y9DZqny897zt4CD74CgCRNV4771V6sgscRvRd9RxEDEKyquJ0S sEoALZ31RmZ0P9flEASJLmajYXdo5eV1H9v6rD4Shm+Bu8ABt1xn/Q3ZoilxqL7DPy7iuJ/i8l/TV I6C97iGkGHXr2wDQB1eTPiMfr+aXofYoKWJNM8waOo4c2cLPf1VR4nL8G5AjWIq/owOV0KAJOuuPd A2IOmcnE8tBbe/rS6hPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ3h-0000000EqrN-0vjs; Tue, 20 Feb 2024 13:21:17 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1i-0000000Ep9O-079k for hostap@lists.infradead.org; Tue, 20 Feb 2024 13:19:15 +0000 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=BHpjjxbiHO7YrUFWCDZ44Scg1J+ftPHhpaAb1ASZfIU=; t=1708435153; x=1709644753; b=uxsxgofPC3/16HZq2xE1vkdk8/kc6N/yv7aFbZ433H10SNx hNP3Ci6UoRIedjn9R3aI6/KGP9fHG1FEI3NymdteP8XWfMNAbqA7WSyW7682bMU8JYNaPBVM9NoI8 bC60kJ6l2KEiuoQs54JAPcz8WMzrF7SxGPHx56xLochVkL+C/ELJLasckrHxL9wcpjoVdpp0CoWR8 T2x7ZFIQqK3MWI/dpDO3PxnG2zmrhXjRoHKzDOIAHFZf5cb1v9I9NVUODH/qax8CD+Hco8f3PgCbR 7v9SYHSnBPtUyfMvdZ1qCnK4Xonk9vk9p0YY9ItNhG3xzSmd55PaNe6Ep7DNKEhA==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rcQ1f-00000000ugq-1gzz; Tue, 20 Feb 2024 14:19:12 +0100 From: benjamin@sipsolutions.net To: hostap@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH v2 19/20] WNM: Follow BTM procedure if last link is dropped Date: Tue, 20 Feb 2024 14:18:26 +0100 Message-ID: <20240220131827.17766-20-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220131827.17766-1-benjamin@sipsolutions.net> References: <20240220131827.17766-1-benjamin@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240220_051914_216988_948020C1 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: From: Benjamin Berg If the last link is dropped, it makes sense to follow the BTM procedure. However, in that case we need to prevent reconnection to this link specifically, while if the AP MLD is terminating we need to [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches 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_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.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 From: Benjamin Berg If the last link is dropped, it makes sense to follow the BTM procedure. However, in that case we need to prevent reconnection to this link specifically, while if the AP MLD is terminating we need to forbid connecting to the AP MLD. As such, add a new variable to track the BSSID or AP MLD ADDR. Which one it refers to depends on whether wnm_link_removal is set. This also simplifies the check in wnm_is_bss_excluded and untangles it from wpa_s->current_bss. Signed-off-by: Benjamin Berg --- wpa_supplicant/wnm_sta.c | 58 ++++++++++++++++++------------- wpa_supplicant/wpa_supplicant_i.h | 1 + 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c index 2d43950c8..8fc08194e 100644 --- a/wpa_supplicant/wnm_sta.c +++ b/wpa_supplicant/wnm_sta.c @@ -1071,7 +1071,7 @@ static int wnm_send_bss_transition_mgmt_resp( wpabuf_put_data(buf, "\0\0\0\0\0\0", ETH_ALEN); } - if (status == WNM_BSS_TM_ACCEPT && !wpa_s->wnm_link_removal) + if (status == WNM_BSS_TM_ACCEPT && target_bssid) wnm_add_cand_list(wpa_s, &buf); #ifdef CONFIG_MBO @@ -1463,15 +1463,36 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s, * set to 1, and the BSS Termination Included field is set to 1, only * one of the links is removed and the other links remain associated. * Ignore the Disassociation Imminent field in such a case. + * + * TODO: We should check if the AP has more than one link. + * TODO: We should pass the RX link and use that */ - if (disassoc_imminent && - (wpa_s->valid_links & (wpa_s->valid_links - 1)) != 0 && + if (disassoc_imminent && wpa_s->valid_links && (wpa_s->wnm_mode & WNM_BSS_TM_REQ_LINK_REMOVAL_IMMINENT) && (wpa_s->wnm_mode & WNM_BSS_TM_REQ_BSS_TERMINATION_INCLUDED)) { - wpa_printf(MSG_INFO, - "WNM: BTM request for a single MLO link - ignore disassociation imminent since other links remain associated"); - disassoc_imminent = false; + /* If we still have a link, then just accept the request */ + if (wpa_s->valid_links & (wpa_s->valid_links - 1)) { + wpa_printf(MSG_INFO, + "WNM: BTM request for a single MLO link - ignore disassociation imminent since other links remain associated"); + disassoc_imminent = false; + + wnm_send_bss_transition_mgmt_resp( + wpa_s, WNM_BSS_TM_ACCEPT, 0, 0, NULL); + + return; + } + + /* Last link is being removed (which must be the assoc link) */ wpa_s->wnm_link_removal = true; + memcpy(wpa_s->wnm_dissoc_addr, + wpa_s->links[wpa_s->mlo_assoc_link_id].bssid, + ETH_ALEN); + } else { + if (wpa_s->valid_links) + memcpy(wpa_s->wnm_dissoc_addr, wpa_s->ap_mld_addr, + ETH_ALEN); + else + memcpy(wpa_s->wnm_dissoc_addr, wpa_s->bssid, ETH_ALEN); } if (disassoc_imminent) { @@ -2026,8 +2047,6 @@ void wnm_clear_coloc_intf_reporting(struct wpa_supplicant *wpa_s) bool wnm_is_bss_excluded(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) { - unsigned int i; - if (!(wpa_s->wnm_mode & WNM_BSS_TM_REQ_DISASSOC_IMMINENT)) return false; @@ -2035,23 +2054,14 @@ bool wnm_is_bss_excluded(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) * In case disassociation imminent is set, do no try to use a BSS to * which we are connected. */ - - if (wpa_s->current_bss && - ether_addr_equal(wpa_s->current_bss->bssid, bss->bssid)) { - wpa_dbg(wpa_s, MSG_DEBUG, - "WNM: Disassociation imminent: current BSS"); - return true; - } - - if (!wpa_s->valid_links) - return false; - - for_each_link(wpa_s->valid_links, i) { - if (ether_addr_equal(wpa_s->links[i].bssid, bss->bssid)) { - wpa_dbg(wpa_s, MSG_DEBUG, - "WNM: MLD: Disassociation imminent: current link"); + if (wpa_s->wnm_link_removal || + !(wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_MLO) || + is_zero_ether_addr(bss->mld_addr)) { + if (ether_addr_equal(bss->bssid, wpa_s->wnm_dissoc_addr)) + return true; + } else { + if (ether_addr_equal(bss->mld_addr, wpa_s->wnm_dissoc_addr)) return true; - } } return false; diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index c8f346d72..6a40c4226 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1304,6 +1304,7 @@ struct wpa_supplicant { u8 wnm_num_neighbor_report; u8 wnm_mode; bool wnm_link_removal; + u8 wnm_dissoc_addr[ETH_ALEN]; u16 wnm_dissoc_timer; u8 wnm_bss_termination_duration[12]; struct neighbor_report *wnm_neighbor_report_elements; From patchwork Tue Feb 20 13:18:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1901487 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=urkC66Tf; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=bQw/29YW; 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 4TfKnD0m5Dz20Qg for ; Wed, 21 Feb 2024 00:21:52 +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=6nT6aMwgG2AdXAT76eiqPyqNCy4I7bT8jL85QsgeZ3U=; b=urkC66TfLDY/0k pDjhHClOQvyL0xZ9N0TozVrsvcwlGUniLjgaqp34/aOXkjOP3GC8bkk636RxClMsrS8gozjG7iSjU ncO4m+Wwcb43tVH8EDvqahk8GlQdU+33nWfZGCuqU04qEhGh6adEJCm8cslx99+B8EqQeqYe3Y4BJ BzF8RuF64/QsW5GrRuSUK7Ya3Eo3F14gd4Nbn+CoPXP+a5iejyWDAF27uYDp5A21zlQcBNA3vZl6N IKf8YN4V+UsJ77fES9rH1CUbzyFLNf68yj0Uyg/sq5o6NUs5G58xuHDCrg9rtbkMkgn31PEhfD3x0 kbpWfa9CrwgA0wnC4AyA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ3v-0000000Er2f-3ghU; Tue, 20 Feb 2024 13:21:31 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcQ1j-0000000EpA9-0R40 for hostap@lists.infradead.org; Tue, 20 Feb 2024 13:19:16 +0000 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=KB/S43XfJEil7/cjtLOaSu36GCQqYP081zAGCT89GZI=; t=1708435154; x=1709644754; b=bQw/29YWrzUKb87Q3y2R/SevaLioRra60ylE8+Ld6XLwxtc MEQf5al/C+K134MYCdCJEyzYOQdD4jrQKcTBX5cg6iBPpfEAgxRGQNBADHEsfpwABz3TL5qPj4zkp pNJ/n3X1rf5UPb+7FtjvxAcJ1CXGa407EqKZqOScfXqkD/h1827kESFN/ECpvof4iOuiGk0m/V+IL U+LtbnSXrTnrMaltyQeDGMsA8SswX7jpBI9u7k/6zirQWOF/diZoETgRnvJDYXDozHh8TZgJCtDMa mUMdDOSAvtED/iZuNUZsrGqlgS7h5YrfvY+hUKfInTcxA6DbCoK3NoN1C4xqVtRg==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rcQ1g-00000000ugq-3Uoc; Tue, 20 Feb 2024 14:19:13 +0100 From: benjamin@sipsolutions.net To: hostap@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH v2 20/20] WNM: Keep BTM information until connection completes Date: Tue, 20 Feb 2024 14:18:27 +0100 Message-ID: <20240220131827.17766-21-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220131827.17766-1-benjamin@sipsolutions.net> References: <20240220131827.17766-1-benjamin@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240220_051915_399143_2B26BCB1 X-CRM114-Status: GOOD ( 19.73 ) 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: From: Benjamin Berg In the MLD case, the information from the transition management request is relevant during the association process in order to filter out links that were disallowed by the BTM request. Also, the infor [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches 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_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.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 From: Benjamin Berg In the MLD case, the information from the transition management request is relevant during the association process in order to filter out links that were disallowed by the BTM request. Also, the information remains useful should a connection attempt fail. To enable these scenarios, keep the information around until the connection has completed. As this might make it impossible to establish a connection, also clear this information at the same time that a normal BSS ignore is cleared to avoid getting stuck in case the transition fails unexpectedly. Signed-off-by: Benjamin Berg --- wpa_supplicant/ctrl_iface.c | 2 ++ wpa_supplicant/events.c | 4 ++- wpa_supplicant/wnm_sta.c | 41 +++++++++++++++---------------- wpa_supplicant/wnm_sta.h | 16 +++++++++++- wpa_supplicant/wpa_supplicant.c | 8 +++--- wpa_supplicant/wpa_supplicant_i.h | 1 - 6 files changed, 45 insertions(+), 27 deletions(-) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 8796e3060..6c4764692 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -8850,6 +8850,8 @@ static void wpa_supplicant_ctrl_iface_flush(struct wpa_supplicant *wpa_s) wpa_s->next_ssid = NULL; + wnm_btm_reset(wpa_s); + #ifdef CONFIG_INTERWORKING #ifdef CONFIG_HS20 hs20_cancel_fetch_osu(wpa_s); diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index fe77eb9f5..8c40ed36f 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1802,10 +1802,12 @@ struct wpa_bss * wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s, break; } - if (selected == NULL && wpa_s->bssid_ignore && + if (selected == NULL && + (wpa_s->bssid_ignore || wnm_active_bss_trans_mgmt(wpa_s)) && !wpa_s->countermeasures) { wpa_dbg(wpa_s, MSG_DEBUG, "No APs found - clear BSSID ignore list and try again"); + wnm_btm_reset(wpa_s); wpa_bssid_ignore_clear(wpa_s); wpa_s->bssid_ignore_cleared = true; } else if (selected == NULL) diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c index 8fc08194e..022f14954 100644 --- a/wpa_supplicant/wnm_sta.c +++ b/wpa_supplicant/wnm_sta.c @@ -418,7 +418,7 @@ static void ieee802_11_rx_wnmsleep_resp(struct wpa_supplicant *wpa_s, } -void wnm_deallocate_memory(struct wpa_supplicant *wpa_s) +void wnm_btm_reset(struct wpa_supplicant *wpa_s) { int i; @@ -430,6 +430,18 @@ void wnm_deallocate_memory(struct wpa_supplicant *wpa_s) wpa_s->wnm_num_neighbor_report = 0; os_free(wpa_s->wnm_neighbor_report_elements); wpa_s->wnm_neighbor_report_elements = NULL; + + wpa_s->wnm_cand_valid_until.sec = 0; + wpa_s->wnm_cand_valid_until.usec = 0; + + wpa_s->wnm_mode = 0; + wpa_s->wnm_dialog_token = 0; + wpa_s->wnm_reply = 0; + +#ifdef CONFIG_MBO + wpa_s->wnm_mbo_trans_reason_present = 0; + wpa_s->wnm_mbo_transition_reason = 0; +#endif /* CONFIG_MBO */ } @@ -1138,7 +1150,7 @@ static void wnm_bss_tm_connect(struct wpa_supplicant *wpa_s, if (bss == wpa_s->current_bss) { wpa_printf(MSG_DEBUG, "WNM: Already associated with the preferred candidate"); - wnm_deallocate_memory(wpa_s); + wnm_btm_reset(wpa_s); return; } @@ -1154,7 +1166,6 @@ static void wnm_bss_tm_connect(struct wpa_supplicant *wpa_s, */ if (!already_connecting && radio_work_pending(wpa_s, "sme-connect")) wpa_s->bss_trans_mgmt_in_progress = true; - wnm_deallocate_memory(wpa_s); } @@ -1166,24 +1177,17 @@ int wnm_scan_process(struct wpa_supplicant *wpa_s, bool pre_scan_check) enum mbo_transition_reject_reason reason = MBO_TRANSITION_REJECT_REASON_UNSPECIFIED; - if (!wpa_s->wnm_neighbor_report_elements) + if (!wpa_s->wnm_dialog_token) return 0; wpa_dbg(wpa_s, MSG_DEBUG, "WNM: Process scan results for BSS Transition Management"); if (!pre_scan_check && + os_reltime_initialized(&wpa_s->wnm_cand_valid_until) && os_reltime_before(&wpa_s->wnm_cand_valid_until, &wpa_s->scan_trigger_time)) { wpa_printf(MSG_DEBUG, "WNM: Previously stored BSS transition candidate list is not valid anymore - drop it"); - wnm_deallocate_memory(wpa_s); - return 0; - } - - if (!wpa_s->current_bss || - !ether_addr_equal(wpa_s->wnm_cand_from_bss, - wpa_s->current_bss->bssid)) { - wpa_printf(MSG_DEBUG, "WNM: Stored BSS transition candidate list not from the current BSS - ignore it"); - return 0; + goto send_bss_resp_fail; } /* Compare the Neighbor Report and scan results */ @@ -1233,7 +1237,7 @@ send_bss_resp_fail: wnm_send_bss_transition_mgmt_resp(wpa_s, status, reason, 0, NULL); - wnm_deallocate_memory(wpa_s); + wnm_btm_reset(wpa_s); return 0; } @@ -1385,16 +1389,13 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s, if (end - pos < 5) return; -#ifdef CONFIG_MBO - wpa_s->wnm_mbo_trans_reason_present = 0; - wpa_s->wnm_mbo_transition_reason = 0; -#endif /* CONFIG_MBO */ - if (wpa_s->current_bss) beacon_int = wpa_s->current_bss->beacon_int; else beacon_int = 100; /* best guess */ + wnm_btm_reset(wpa_s); + wpa_s->wnm_dialog_token = pos[0]; wpa_s->wnm_mode = pos[1]; wpa_s->wnm_dissoc_timer = WPA_GET_LE16(pos + 2); @@ -1515,7 +1516,6 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s, unsigned int valid_ms; wpa_msg(wpa_s, MSG_INFO, "WNM: Preferred List Available"); - wnm_deallocate_memory(wpa_s); wpa_s->wnm_neighbor_report_elements = os_calloc( WNM_MAX_NEIGHBOR_REPORT, sizeof(struct neighbor_report)); @@ -1590,7 +1590,6 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s, wpa_s->wnm_cand_valid_until.sec += wpa_s->wnm_cand_valid_until.usec / 1000000; wpa_s->wnm_cand_valid_until.usec %= 1000000; - os_memcpy(wpa_s->wnm_cand_from_bss, wpa_s->bssid, ETH_ALEN); /* * Try fetching the latest scan results from the kernel. diff --git a/wpa_supplicant/wnm_sta.h b/wpa_supplicant/wnm_sta.h index e1bb6724d..d93ef73ff 100644 --- a/wpa_supplicant/wnm_sta.h +++ b/wpa_supplicant/wnm_sta.h @@ -65,7 +65,7 @@ int wnm_send_bss_transition_mgmt_query(struct wpa_supplicant *wpa_s, const char *btm_candidates, int cand_list); -void wnm_deallocate_memory(struct wpa_supplicant *wpa_s); +void wnm_btm_reset(struct wpa_supplicant *wpa_s); int wnm_send_coloc_intf_report(struct wpa_supplicant *wpa_s, u8 dialog_token, const struct wpabuf *elems); void wnm_set_coloc_intf_elems(struct wpa_supplicant *wpa_s, @@ -81,6 +81,11 @@ void wnm_clear_coloc_intf_reporting(struct wpa_supplicant *wpa_s); bool wnm_is_bss_excluded(struct wpa_supplicant *wpa_s, struct wpa_bss *bss); +static inline bool wnm_active_bss_trans_mgmt(struct wpa_supplicant *wpa_s) +{ + return !!wpa_s->wnm_dialog_token; +} + #else /* CONFIG_WNM */ static inline int wnm_scan_process(struct wpa_supplicant *wpa_s, @@ -99,6 +104,15 @@ wnm_is_bss_excluded(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) return false; } +static inline wnm_btm_reset(struct wpa_supplicant *wpa_s) +{ +} + +static inline bool wnm_active_bss_trans_mgmt(struct wpa_supplicant *wpa_s) +{ + return false; +} + #endif /* CONFIG_WNM */ #endif /* WNM_STA_H */ diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index ca9ec3ed6..dba971d3f 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -676,9 +676,7 @@ static void wpa_supplicant_cleanup(struct wpa_supplicant *wpa_s) wpa_s->disallow_aps_ssid = NULL; wnm_bss_keep_alive_deinit(wpa_s); -#ifdef CONFIG_WNM - wnm_deallocate_memory(wpa_s); -#endif /* CONFIG_WNM */ + wnm_btm_reset(wpa_s); ext_password_deinit(wpa_s->ext_pw); wpa_s->ext_pw = NULL; @@ -1076,6 +1074,10 @@ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, if (state == WPA_DISCONNECTED || state == WPA_INACTIVE) wpa_supplicant_start_autoscan(wpa_s); + if (state == WPA_COMPLETED || state == WPA_INTERFACE_DISABLED || + state == WPA_INACTIVE) + wnm_btm_reset(wpa_s); + #ifndef CONFIG_NO_WMM_AC if (old_state >= WPA_ASSOCIATED && wpa_s->wpa_state < WPA_ASSOCIATED) wmm_ac_notify_disassoc(wpa_s); diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 6a40c4226..2bbc52339 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1309,7 +1309,6 @@ struct wpa_supplicant { u8 wnm_bss_termination_duration[12]; struct neighbor_report *wnm_neighbor_report_elements; struct os_reltime wnm_cand_valid_until; - u8 wnm_cand_from_bss[ETH_ALEN]; struct wpa_bss *wnm_target_bss; enum bss_trans_mgmt_status_code bss_tm_status; bool bss_trans_mgmt_in_progress;