From patchwork Tue Jun 4 21:02:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wang X-Patchwork-Id: 1943573 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=AtTq6koT; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Er4HAQ7H; 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 4Vv32v40f5z20Tb for ; Wed, 5 Jun 2024 07:03:01 +1000 (AEST) 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: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:In-Reply-To:References: List-Owner; bh=uiRfMtus1DG7e/8IjOtEfLs0cHs/s44Ij68FzsuHqV8=; b=AtTq6koTdvAYfG iVvaGxpj1Z8ZZ4yL1jMgDcda6ks0wEr8Pv7olyhWKdLkDY6L6AfDjMUK0mC6Tl8R5Jcz+pxnWvqba P8wHdvg9NeqvQjKJ275xlpyMVB2M1+7X/uSflYXk3/8gp/+EogcefPYVW1YkOMQUIpNFGigLe4gbQ 5JLSH4I7NGAN9ew/c0tDU2hK/VwlUxxlOt6V0Ul1yvWpVA9/rFflmT+MOTsT9JR1u+iM0aFxSJL5E JM/kX1DRPGB0+NXc3MPOuXUMFazJUmkSZwkdy7NrRLxzgFcg+tzhk4s1HcOZGXFCrA3eO7D0bpyzn TfOxj4wp3B02P542TskQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEbIX-00000003mW8-0uY1; Tue, 04 Jun 2024 21:02:25 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEbIT-00000003mVJ-0aha for hostap@lists.infradead.org; Tue, 04 Jun 2024 21:02:22 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-42148c0cb1aso14505355e9.3 for ; Tue, 04 Jun 2024 14:02:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1717534939; x=1718139739; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=xbe4oFmfs89VdfSto42LXs53PfacHRrPxRitLr3QmzU=; b=Er4HAQ7H8xAQcxDi+bzeaHf0aTvSBI6YViX0WUTnewSw/sMLLPDJCLMO6sRxBx+Q+Q lsMMs5fhMQya29BwUnCtLkXjbxQ+1WuZOiK1H/qSAhJweWjcG+j16P52DR6bAvuX2dzs M/gTGn+1hNfg6fz3d+Zy7Dg2/XqqzV48K4Hd4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717534939; x=1718139739; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xbe4oFmfs89VdfSto42LXs53PfacHRrPxRitLr3QmzU=; b=LAV/Qeu18vszCMnFFvEXeZ7sIGlMdDYzvXJL244nC23vVckMd5YL3i4Ytq5DR9CPNA 0kFZfoVc6jE0PyHYu42kfBV2ue4Sv+UxVzP3ItsennUEJctcbBYwhiyaFTcrXguP2tLB tMomYfZB9kPSwgBFHQrKB06wehPmNMKFIR2DUu/wSNKxF0jgwkgZuhRpEmB372XlVTe6 WVZXuIXKYvdZ9UFCaWY4E+um1+GH1Zvh5SwKfANaBLkwteEyaTTStXL7+D93aLmLgboO FTkiL9R/Y/7J3qN/HwvmHmy61K3bQJZPRT+46/CAnlVm4COwk/J6HfI+dChfd2hcOZCh f8Eg== X-Gm-Message-State: AOJu0YywwYpdTP2adXZs7+taCkNQ257HE7NFpZFstEnJtjNVZBxQbWQy WCT4Th0QoU3qVRgGxSSDscKXYZFjbpt4wzz8RO8TTI4DMN7Z1YGtRc8qOiGq3A== X-Google-Smtp-Source: AGHT+IHtTvqQ1pcaKd33/sb+1b8sMmAzeJqiXPELwBMRbHu8V8RBA9aZDPZ01dAXqBFtsemk0q7LuQ== X-Received: by 2002:a05:6000:e:b0:35b:64c4:1f2b with SMTP id ffacd0b85a97d-35e84049439mr432449f8f.5.1717534938485; Tue, 04 Jun 2024 14:02:18 -0700 (PDT) Received: from matthewmwangcros2.c.googlers.com.com (203.75.199.104.bc.googleusercontent.com. [104.199.75.203]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-421555478b0sm16353555e9.17.2024.06.04.14.02.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 14:02:18 -0700 (PDT) From: Matthew Wang To: j@w1.fi Cc: hostap@lists.infradead.org, matthewmwang@chromium.org Subject: [PATCH] Trigger 6GHz scan if RNR contains matching short SSID Date: Tue, 4 Jun 2024 21:02:16 +0000 Message-ID: <20240604210216.331287-1-matthewmwang@chromium.org> X-Mailer: git-send-email 2.45.1.288.g0e0cd299f1-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240604_140221_267770_23364292 X-CRM114-Status: GOOD ( 22.67 ) 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: If a scan triggers a regdom update into a 6GHz-allowed regdom, and an RNR IE in one of the legacy band scan results points to a 6GHz scan result with a short SSID matching the current_ssid, delay conn [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:32f listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 T_SCC_BODY_TEXT_LINE No description available. -0.0 DKIMWL_WL_HIGH DKIMwl.org - High trust sender 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 If a scan triggers a regdom update into a 6GHz-allowed regdom, and an RNR IE in one of the legacy band scan results points to a 6GHz scan result with a short SSID matching the current_ssid, delay connection in favor of a 6GHz-only scan. This will optimize the case in which we first connect to a 5GHz AP, then later roam to a 6GHz one by directly connecting to the 6GHz one. Signed-off-by: Matthew Wang --- wpa_supplicant/events.c | 109 +++++++++++++++++++++++++++++++--------- 1 file changed, 84 insertions(+), 25 deletions(-) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 447fc8fd8..049cbf415 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -52,6 +52,7 @@ #include "wmm_ac.h" #include "nan_usd.h" #include "dpp_supplicant.h" +#include "utils/crc32.h" #define MAX_OWE_TRANSITION_BSS_SELECT_COUNT 5 @@ -2378,6 +2379,78 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, } +static int wpas_trigger_6ghz_scan(struct wpa_supplicant *wpa_s, + union wpa_event_data *data) +{ + struct wpa_driver_scan_params params; + unsigned int j; + + wpa_dbg(wpa_s, MSG_INFO, "Triggering 6GHz-only scan"); + os_memset(¶ms, 0, sizeof(params)); + params.non_coloc_6ghz = wpa_s->last_scan_non_coloc_6ghz; + for (j = 0; j < data->scan_info.num_ssids; j++) + params.ssids[j] = data->scan_info.ssids[j]; + params.num_ssids = data->scan_info.num_ssids; + wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211A, ¶ms, + true, !wpa_s->last_scan_non_coloc_6ghz, false); + if (!wpa_supplicant_trigger_scan(wpa_s, ¶ms, true, true)) { + os_free(params.freqs); + return 1; + } + wpa_dbg(wpa_s, MSG_INFO, "Failed to trigger 6GHz-only scan"); + os_free(params.freqs); + return 0; +} + + +static bool wpas_short_ssid_match(struct wpa_supplicant *wpa_s, + struct wpa_scan_results *scan_res) +{ + size_t i; + u32 current_ssid_short = ieee80211_crc32(wpa_s->current_ssid->ssid, + wpa_s->current_ssid->ssid_len); + + for (i = 0; i < scan_res->num; i++) { + struct wpa_scan_res *res = scan_res->res[i]; + const u8 *rnr_ie, *ie_end; + const struct ieee80211_neighbor_ap_info *info; + size_t left; + + rnr_ie = wpa_scan_get_ie(res, WLAN_EID_REDUCED_NEIGHBOR_REPORT); + if (!rnr_ie) + continue; + + ie_end = rnr_ie + 2 + rnr_ie[1]; + rnr_ie += 2; + + info = (const struct ieee80211_neighbor_ap_info *) rnr_ie; + if (info->tbtt_info_len < 11) + continue; + left = ie_end - rnr_ie; + + if (left < sizeof(struct ieee80211_neighbor_ap_info)) + continue; + + left -= sizeof(struct ieee80211_neighbor_ap_info); + if (left < info->tbtt_info_len) + continue; + + rnr_ie += sizeof(struct ieee80211_neighbor_ap_info); + while (rnr_ie + 11 <= ie_end) { + /* skip TBTT offset and BSSID */ + u32 short_ssid = WPA_GET_LE32(rnr_ie + 1 + ETH_ALEN); + + if (short_ssid == current_ssid_short) + return true; + + rnr_ie += info->tbtt_info_len; + } + } + + return false; +} + + /* * Return a negative value if no scan results could be fetched or if scan * results should not be shared with other virtual interfaces. @@ -2395,6 +2468,7 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s, int ret = 0; int ap = 0; bool trigger_6ghz_scan; + bool short_ssid_match_found = false; #ifndef CONFIG_NO_RANDOM_POOL size_t i, num; #endif /* CONFIG_NO_RANDOM_POOL */ @@ -2538,6 +2612,12 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s, wpa_s->wpa_state < WPA_COMPLETED) goto scan_work_done; + if (wpa_s->current_ssid && trigger_6ghz_scan && own_request && data && + wpas_short_ssid_match(wpa_s, scan_res)) { + wpa_dbg(wpa_s, MSG_INFO, "Short SSID match in scan results"); + short_ssid_match_found = true; + } + wpa_scan_results_free(scan_res); if (own_request && wpa_s->scan_work) { @@ -2564,6 +2644,9 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s, if (wpa_s->supp_pbc_active && !wpas_wps_partner_link_scan_done(wpa_s)) return ret; + if (short_ssid_match_found && wpas_trigger_6ghz_scan(wpa_s, data) > 0) + return 1; + return wpas_select_network_from_last_scan(wpa_s, 1, own_request, trigger_6ghz_scan, data); @@ -2578,30 +2661,6 @@ scan_work_done: } -static int wpas_trigger_6ghz_scan(struct wpa_supplicant *wpa_s, - union wpa_event_data *data) -{ - struct wpa_driver_scan_params params; - unsigned int j; - - wpa_dbg(wpa_s, MSG_INFO, "Triggering 6GHz-only scan"); - os_memset(¶ms, 0, sizeof(params)); - params.non_coloc_6ghz = wpa_s->last_scan_non_coloc_6ghz; - for (j = 0; j < data->scan_info.num_ssids; j++) - params.ssids[j] = data->scan_info.ssids[j]; - params.num_ssids = data->scan_info.num_ssids; - wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211A, ¶ms, - true, !wpa_s->last_scan_non_coloc_6ghz, false); - if (!wpa_supplicant_trigger_scan(wpa_s, ¶ms, true, true)) { - os_free(params.freqs); - return 1; - } - wpa_dbg(wpa_s, MSG_INFO, "Failed to trigger 6GHz-only scan"); - os_free(params.freqs); - return 0; -} - - /** * Select a network from the last scan * @wpa_s: Pointer to wpa_supplicant data @@ -2692,7 +2751,7 @@ static int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s, wpa_supplicant_rsn_preauth_scan_results(wpa_s); } else if (own_request) { if (wpa_s->support_6ghz && trigger_6ghz_scan && data && - wpas_trigger_6ghz_scan(wpa_s, data) < 0) + wpas_trigger_6ghz_scan(wpa_s, data) > 0) return 1; /*