From patchwork Sun Nov 26 18:22:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 1868558 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=IW/FF3on; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=candelatech.com header.i=@candelatech.com header.a=rsa-sha256 header.s=default header.b=YsktWjao; 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 4SdcYP06Dxz1yS6 for ; Mon, 27 Nov 2023 05:23: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: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=GChtSFhopitKq7P3INphRiwft3604Q2dEGh4hvjGoPQ=; b=IW/FF3onc8IxF3 bppfSNKLXYI2mxPiTyZ5Z6OCokYxET+1N1sO3PfEVXiFC4nROyiZsmN8x8LZiV+VIybVdquWX9nR3 C7JAoU1Ex/tFxHDhixxbHscLrqrH/WxDloW/qtvtsNniL587Bp9OwC9nNoqVdZHLUN731ff9WIeWX K47H4szve4/6ELqnHqlIYyNFjN4mw8m+OyMmu3R/p9oa5x2/bwThmj/7VfKGcYvGv+1mJ2+I6CFoH +OeXCWr4GcpfJ1GUUvERde7vcxQ0WwOgLO9tKQRfHzXJeXc9OovwE7U5VZCXEKb4JrrwO3BS9ok34 iOIKF19DWlRbQ/Us7sXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r7JmD-00Ds29-2C; Sun, 26 Nov 2023 18:22:41 +0000 Received: from dispatch1-us1.ppe-hosted.com ([67.231.154.164]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r7Jm9-00Drya-0t for hostap@lists.infradead.org; Sun, 26 Nov 2023 18:22:39 +0000 X-Virus-Scanned: Proofpoint Essentials engine Received: from mail3.candelatech.com (mail2.candelatech.com [208.74.158.173]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id A1AB0940064 for ; Sun, 26 Nov 2023 18:22:33 +0000 (UTC) Received: from v-f36-64.candelatech.com (50-251-239-81-static.hfc.comcastbusiness.net [50.251.239.81]) by mail3.candelatech.com (Postfix) with ESMTP id 329D913C2B0; Sun, 26 Nov 2023 10:22:32 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 329D913C2B0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1701022952; bh=8J4sNbcw4PbhqbF2OuHw7YficXFLIkOkTshaMXLSvCw=; h=From:To:Cc:Subject:Date:From; b=YsktWjaoz2URMDXhwVvsek9EsjOdtqkBt6SI/cclv9aVicbmYEUQ9sZdIrtYlnPEu eBmnCcF+Xd8/I2o70sYN1BuyWRFij9bZdGwP65NCV2jNS7t+7NKZ98fa5smvM3Ksgv OnIbg+NpqlBTqO9cO5CxPF/t2RMuB37rXDEPRW04= From: greearb@candelatech.com To: hostap@lists.infradead.org Cc: Ben Greear Subject: [PATCH v2] supplicant: Allow simple bgscan to do btm queries. Date: Sun, 26 Nov 2023 10:22:29 -0800 Message-Id: <20231126182229.3409298-1-greearb@candelatech.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-MDID: 1701022954-W_pErYUOQ05Z X-MDID-O: us5;at1;1701022954;W_pErYUOQ05Z;;19b12d1ff1464714abe912ee75a411c0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231126_102237_479655_FCE93AEA X-CRM114-Status: GOOD ( 17.26 ) X-Spam-Score: -0.9 (/) 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: Ben Greear Allow doing X bss_transition_mgmt_query calls before falling back to scan. Example format to do 4 btm before attempting a scan: bgscan="simple:30:-65:300:4" Content analysis details: (-0.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [67.231.154.164 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [67.231.154.164 listed in wl.mailspike.net] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 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: Ben Greear Allow doing X bss_transition_mgmt_query calls before falling back to scan. Example format to do 4 btm before attempting a scan: bgscan="simple:30:-65:300:4" Signed-off-by: Ben Greear --- v2: Check ext capabilities before trying BTM query Schedule new timeout in case we do BTM query. wpa_supplicant/bgscan_simple.c | 38 ++++++++++++++++++++++++++++++ wpa_supplicant/wpa_supplicant.conf | 5 ++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/wpa_supplicant/bgscan_simple.c b/wpa_supplicant/bgscan_simple.c index f3127980e..cf5dd5773 100644 --- a/wpa_supplicant/bgscan_simple.c +++ b/wpa_supplicant/bgscan_simple.c @@ -16,10 +16,15 @@ #include "driver_i.h" #include "scan.h" #include "bgscan.h" +#include "config.h" +#include "wnm_sta.h" +#include "bss.h" struct bgscan_simple_data { struct wpa_supplicant *wpa_s; const struct wpa_ssid *ssid; + int use_btm_query; + unsigned int scan_action_count; int scan_interval; int signal_threshold; int short_scan_count; /* counter for scans using short scan interval */ @@ -36,6 +41,31 @@ static void bgscan_simple_timeout(void *eloop_ctx, void *timeout_ctx) struct wpa_supplicant *wpa_s = data->wpa_s; struct wpa_driver_scan_params params; + if (wpa_s->current_bss && + wpa_bss_ext_capab(wpa_s->current_bss, WLAN_EXT_CAPAB_BSS_TRANSITION) && + data->use_btm_query && !wpa_s->conf->disable_btm) { + int mod; + + /* try BTM x times, scan on x + 1 */ + data->scan_action_count++; + mod = data->scan_action_count % (data->use_btm_query + 1); + if (mod < data->use_btm_query) { + wpa_printf(MSG_DEBUG, "bgscan simple: Send bss transition mgt query %d/%d", + mod, data->use_btm_query); + if (wnm_send_bss_transition_mgmt_query(wpa_s, 6 /* better AP found */, NULL, 0)) { + wpa_printf(MSG_DEBUG, "bgscan simple: Failed send bss transition mgt query"); + /* Fall through and do regular scan */ + } else { + /* start new timeout for next one. We don't have scan callback to otherwise + * trigger future progress when using BTM path. + */ + eloop_register_timeout(data->scan_interval, 0, + bgscan_simple_timeout, data, NULL); + goto scan_ok; + } + } + } + os_memset(¶ms, 0, sizeof(params)); params.num_ssids = 1; params.ssids[0].ssid = data->ssid->ssid; @@ -58,6 +88,7 @@ static void bgscan_simple_timeout(void *eloop_ctx, void *timeout_ctx) eloop_register_timeout(data->scan_interval, 0, bgscan_simple_timeout, data, NULL); } else { + scan_ok: if (data->scan_interval == data->short_interval) { data->short_scan_count++; if (data->short_scan_count >= data->max_short_scans) { @@ -84,6 +115,8 @@ static int bgscan_simple_get_params(struct bgscan_simple_data *data, { const char *pos; + data->use_btm_query = 0; + data->short_interval = atoi(params); pos = os_strchr(params, ':'); @@ -99,6 +132,11 @@ static int bgscan_simple_get_params(struct bgscan_simple_data *data, } pos++; data->long_interval = atoi(pos); + pos = os_strchr(pos, ':'); + if (pos) { + pos++; + data->use_btm_query = atoi(pos); + } return 0; } diff --git a/wpa_supplicant/wpa_supplicant.conf b/wpa_supplicant/wpa_supplicant.conf index 420a62d4d..4285e95fa 100644 --- a/wpa_supplicant/wpa_supplicant.conf +++ b/wpa_supplicant/wpa_supplicant.conf @@ -1029,9 +1029,10 @@ fast_reauth=1 # parameter uses following format: ":" # Following bgscan modules are available: # simple - Periodic background scans based on signal strength +# send_btm_query > 0 means do this many BTM queries before attempting a scan. # bgscan="simple::: -# " -# bgscan="simple:30:-45:300" +# :" +# bgscan="simple:30:-45:300:3" # learn - Learn channels used by the network and try to avoid bgscans on other # channels (experimental) # bgscan="learn:::