From patchwork Wed Dec 21 03:15:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wang X-Patchwork-Id: 1718127 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=yWB4JxEa; 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=SkVx/diF; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NcJX90t1Cz23dP for ; Wed, 21 Dec 2022 14:17: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: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=oyTWwxAQSCBWVqvKvBC/RCgYGHuv9HE4ndMr9oPk/4k=; b=yWB4JxEaE8BIg+ mv+zVq5OZvESGxNwN64XVXWsdV7PGuQihIqPr52gDWrXPxnNlSnro3s0gyi/hnBCZdQHkhQr90AL5 NrZWqcUJhGlxQrtH8eFsAtQhpntStU3TXvHXbMq85szQl3V8xMvJTOvvl4DBJ01fIBu6YD4pepZov cRYwPb8VKmjmo0PVdXYUhARsmFsU/1WZ9AEqG/7cNvPf0ZTnkssCIyKdumYPzmNyJP/Gyf39+KnW1 QbrZsKyFnHRERC44HZP33GLOKxHHp0wri2TdLzQAGmiWWMxCZHcV7H+CMByU7bamnaL/l6SrtpyA4 bes1diecMUPdlrxO/VgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p7paK-008WO6-C0; Wed, 21 Dec 2022 03:16:00 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p7paE-008WIG-6A for hostap@lists.infradead.org; Wed, 21 Dec 2022 03:15:56 +0000 Received: by mail-pj1-x1034.google.com with SMTP id o8-20020a17090a9f8800b00223de0364beso791708pjp.4 for ; Tue, 20 Dec 2022 19:15:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=QV3H7aymU+e0I80XGJdJMM5h/2bFGpegM2V62mBf8HI=; b=SkVx/diFd+c4PIFbcQmnP6w+l7bb5THo2VqRxRU3egrukmI/0ZkJ+dyc3yWP1AjdJE p8lhbq1ucGyB2Jz+ExjB/vIR82haJyCS+trUu4K/nVnZ1Myz6IFRMiX19MwTwUblaGMq OxKGCB87EabCccUj7StYO9UMBXWCE7zssLfhc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=QV3H7aymU+e0I80XGJdJMM5h/2bFGpegM2V62mBf8HI=; b=nZwt/QERpm3A2XJcz7v6LAfOJC9jjnF5GlmnhcGc6248pB6dIRTz1iZ/byDeqyFi8A MvItDpJKTUg87RQ8NpzPIulaGL5+UGUyNrz7wKg0EMMysPhKzFYjCxynlISSvqM8Dt9i KZBNsfs4u2qnHhJTuLH/wd4Oh8q6spH2pHSAHZmhSb0z6lgRTyexoHZk/0zT3sbI/G6o HZSA7ZQ8+m9dlQz513mHGBo/yukBy8ze78kKLcgWjhTHWvLo6N2EUGD9Innp1tW/s9E9 oMrR40HzlizajPLZWE6e0E8DgHp6/r2C4iuZK4VztlKvuRGJPAGke5OzBMR37cfvYwVw 0fVg== X-Gm-Message-State: AFqh2krNTe9XTNGk2JoMx8aBZ1LLBFqjznUKiAymTjogpnt47rK6/SzZ +fNNg9zfciuy523/B4/0kDZSlA== X-Google-Smtp-Source: AMrXdXvIVPZCz66Vl1B+Jn/oXGH/vnbtqEw1MxnlEdCGvhTkbg4djdV/gTzDuhH9Et7r6knK77bmbw== X-Received: by 2002:a17:902:9348:b0:190:e63a:ea91 with SMTP id g8-20020a170902934800b00190e63aea91mr512767plp.0.1671592551843; Tue, 20 Dec 2022 19:15:51 -0800 (PST) Received: from matthewmwang2.mtv.corp.google.com ([2620:15c:9d:4:d8b6:8a2e:abcd:f214]) by smtp.gmail.com with ESMTPSA id o1-20020a170902d4c100b001894881842dsm10094986plg.151.2022.12.20.19.15.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 19:15:51 -0800 (PST) From: Matthew Wang To: j@w1.fi Cc: hostap@lists.infradead.org, matthewmwang@chromium.org, Matthew Wang Subject: [PATCH v3 2/3] P2P: optimize join scan freq Date: Tue, 20 Dec 2022 19:15:46 -0800 Message-Id: <20221221031546.1373427-1-matthewmwang@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221220_191554_525305_03E1A93F X-CRM114-Status: GOOD ( 23.29 ) X-Spam-Score: -0.4 (/) 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: Matthew Wang Allow clients to force the BSSID of an auto GO. If the auto GO has been discovered on another interface, optimize scan frequency by performing a single channel scan first. Android and ChromeOS use thi [...] Content analysis details: (-0.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1034 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.2 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 From: Matthew Wang Allow clients to force the BSSID of an auto GO. If the auto GO has been discovered on another interface, optimize scan frequency by performing a single channel scan first. Android and ChromeOS use this to streamline auto GO discovery. Signed-off-by: Matthew Wang --- wpa_supplicant/bss.c | 5 ++-- wpa_supplicant/ctrl_iface.c | 2 +- wpa_supplicant/dbus/dbus_new_handlers_p2p.c | 6 ++++- wpa_supplicant/events.c | 2 +- wpa_supplicant/p2p_supplicant.c | 24 ++++++++++++------ wpa_supplicant/p2p_supplicant.h | 3 ++- wpa_supplicant/scan.c | 27 ++++++++++++++++++++- wpa_supplicant/wpa_supplicant_i.h | 1 + 8 files changed, 56 insertions(+), 14 deletions(-) diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c index cd2c164c3b7..0f986bbcad8 100644 --- a/wpa_supplicant/bss.c +++ b/wpa_supplicant/bss.c @@ -240,7 +240,7 @@ void wpa_bss_remove(struct wpa_supplicant *wpa_s, struct wpa_bss *bss, /** * wpa_bss_get - Fetch a BSS table entry based on BSSID and SSID * @wpa_s: Pointer to wpa_supplicant data - * @bssid: BSSID + * @bssid: BSSID, or %NULL to match any BSSID * @ssid: SSID * @ssid_len: Length of @ssid * Returns: Pointer to the BSS entry or %NULL if not found @@ -252,7 +252,8 @@ struct wpa_bss * wpa_bss_get(struct wpa_supplicant *wpa_s, const u8 *bssid, if (!wpa_supplicant_filter_bssid_match(wpa_s, bssid)) return NULL; dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) { - if (os_memcmp(bss->bssid, bssid, ETH_ALEN) == 0 && + if ((!bssid || + os_memcmp(bss->bssid, bssid, ETH_ALEN) == 0) && bss->ssid_len == ssid_len && os_memcmp(bss->ssid, ssid, ssid_len) == 0) return bss; diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 6588fd47b4a..27397e99b57 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -7128,7 +7128,7 @@ static int p2p_ctrl_group_add_persistent(struct wpa_supplicant *wpa_s, return wpas_p2p_group_add_persistent(wpa_s, ssid, 0, freq, vht_center_freq2, 0, ht40, vht, vht_chwidth, he, edmg, - NULL, 0, 0, allow_6ghz, 0); + NULL, 0, 0, allow_6ghz, 0, false); } diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c index 370aee278cf..26e8833e688 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c +++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c @@ -356,6 +356,7 @@ DBusMessage * wpas_dbus_handler_p2p_group_add(DBusMessage *message, int persistent_group = 0; int freq = 0; int retry_limit = 0; + int force_go_bssid = 0; char *iface = NULL; unsigned int group_id = 0; struct wpa_ssid *ssid; @@ -382,6 +383,9 @@ DBusMessage * wpas_dbus_handler_p2p_group_add(DBusMessage *message, retry_limit = entry.int32_value; if (retry_limit <= 0) goto inv_args_clear; + } else if (os_strcmp(entry.key, "force_go_bssid") && + entry.type == DBUS_TYPE_BOOLEAN) { + force_go_bssid = entry.bool_value; } else if (os_strcmp(entry.key, "persistent_group_object") == 0 && entry.type == DBUS_TYPE_OBJECT_PATH) @@ -432,7 +436,7 @@ DBusMessage * wpas_dbus_handler_p2p_group_add(DBusMessage *message, if (wpas_p2p_group_add_persistent(wpa_s, ssid, 0, freq, 0, 0, 0, 0, 0, 0, 0, NULL, 0, 0, - false, retry_limit)) { + false, retry_limit, true)) { reply = wpas_dbus_error_unknown_error( message, "Failed to reinvoke a persistent group"); diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 64b2bcd1daf..c8c639a939a 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1162,7 +1162,7 @@ static void owe_trans_ssid(struct wpa_supplicant *wpa_s, struct wpa_bss *bss, } -static int disabled_freq(struct wpa_supplicant *wpa_s, int freq) +int disabled_freq(struct wpa_supplicant *wpa_s, int freq) { int i, j; diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 6cf5a485f00..a2b70a6d675 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -3299,7 +3299,8 @@ static void wpas_invitation_received(void *ctx, const u8 *sa, const u8 *bssid, wpa_s->conf->p2p_go_he, wpa_s->conf->p2p_go_edmg, NULL, go ? P2P_MAX_INITIAL_CONN_WAIT_GO_REINVOKE : 0, - 1, is_p2p_allow_6ghz(wpa_s->global->p2p), 0); + 1, is_p2p_allow_6ghz(wpa_s->global->p2p), 0, + false); } else if (bssid) { wpa_s->user_initiated_pd = 0; wpa_msg_global(wpa_s, MSG_INFO, @@ -3529,7 +3530,8 @@ static void wpas_invitation_result(void *ctx, int status, const u8 *bssid, ssid->mode == WPAS_MODE_P2P_GO ? P2P_MAX_INITIAL_CONN_WAIT_GO_REINVOKE : 0, 1, - is_p2p_allow_6ghz(wpa_s->global->p2p), 0); + is_p2p_allow_6ghz(wpa_s->global->p2p), 0, + false); } @@ -4615,7 +4617,7 @@ static void wpas_p2ps_prov_complete(void *ctx, u8 status, const u8 *dev, persistent_go->mode == WPAS_MODE_P2P_GO ? P2P_MAX_INITIAL_CONN_WAIT_GO_REINVOKE : - 0, 0, false, 0); + 0, 0, false, 0, false); } else if (response_done) { wpas_p2p_group_add(wpa_s, 1, freq, 0, 0, 0, 0, 0, 0, false); @@ -4738,7 +4740,7 @@ static int wpas_prov_disc_resp_cb(void *ctx) NULL, persistent_go->mode == WPAS_MODE_P2P_GO ? P2P_MAX_INITIAL_CONN_WAIT_GO_REINVOKE : 0, 0, - is_p2p_allow_6ghz(wpa_s->global->p2p), 0); + is_p2p_allow_6ghz(wpa_s->global->p2p), 0, false); } else { wpas_p2p_group_add(wpa_s, 1, freq, 0, 0, 0, 0, 0, 0, is_p2p_allow_6ghz(wpa_s->global->p2p)); @@ -6911,7 +6913,8 @@ int wpas_p2p_group_add(struct wpa_supplicant *wpa_s, int persistent_group, static int wpas_start_p2p_client(struct wpa_supplicant *wpa_s, struct wpa_ssid *params, int addr_allocated, - int freq, int force_scan, int retry_limit) + int freq, int force_scan, int retry_limit, + bool force_go_bssid) { struct wpa_ssid *ssid; int other_iface_found = 0; @@ -6954,6 +6957,11 @@ static int wpas_start_p2p_client(struct wpa_supplicant *wpa_s, if (params->passphrase) ssid->passphrase = os_strdup(params->passphrase); + if (force_go_bssid && params->bssid_set) { + ssid->bssid_set = 1; + os_memcpy(ssid->bssid, params->bssid, ETH_ALEN); + } + wpa_s->show_group_started = 1; wpa_s->p2p_in_invitation = 1; wpa_s->p2p_retry_limit = retry_limit; @@ -7000,7 +7008,8 @@ int wpas_p2p_group_add_persistent(struct wpa_supplicant *wpa_s, int edmg, const struct p2p_channels *channels, int connection_timeout, int force_scan, - bool allow_6ghz, int retry_limit) + bool allow_6ghz, int retry_limit, + bool force_go_bssid) { struct p2p_go_neg_results params; int go = 0, freq; @@ -7068,7 +7077,8 @@ int wpas_p2p_group_add_persistent(struct wpa_supplicant *wpa_s, } return wpas_start_p2p_client(wpa_s, ssid, addr_allocated, freq, - force_scan, retry_limit); + force_scan, retry_limit, + force_go_bssid); } else { return -1; } diff --git a/wpa_supplicant/p2p_supplicant.h b/wpa_supplicant/p2p_supplicant.h index 11cc9c390ea..e113c62b232 100644 --- a/wpa_supplicant/p2p_supplicant.h +++ b/wpa_supplicant/p2p_supplicant.h @@ -52,7 +52,8 @@ int wpas_p2p_group_add_persistent(struct wpa_supplicant *wpa_s, int max_oper_chwidth, int he, int edmg, const struct p2p_channels *channels, int connection_timeout, int force_scan, - bool allow_6ghz, int retry_limit); + bool allow_6ghz, int retry_limit, + bool force_go_bssid); struct p2p_group * wpas_p2p_group_init(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid); enum wpas_p2p_prov_disc_use { diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index cc9faf2a807..88d7e6e65e9 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -445,11 +445,36 @@ static void wpa_supplicant_optimize_freqs( } if (params->freqs == NULL && wpa_s->p2p_in_invitation) { + /* + * Perform a single-channel scan if the GO has already been + * discovered on another non-P2P interface. Note that a scan + * initiated by a P2P interface (e.g. the device interface) + * should already have sufficient IEs and scan results will be + * fetched on interface creation in that case. + */ + if (wpa_s->p2p_in_invitation == 1 && wpa_s->current_ssid) { + struct wpa_supplicant *ifs; + struct wpa_bss *bss = NULL; + struct wpa_ssid *ssid = wpa_s->current_ssid; + u8 *bssid = ssid->bssid_set ? ssid->bssid : NULL; + dl_list_for_each(ifs, &wpa_s->radio->ifaces, + struct wpa_supplicant, radio_list) { + bss = wpa_bss_get(ifs, bssid, ssid->ssid, + ssid->ssid_len); + if (bss) + break; + } + if (bss && !disabled_freq(wpa_s, bss->freq)) { + params->freqs = os_calloc(2, sizeof(int)); + if (params->freqs) + params->freqs[0] = bss->freq; + } + } /* * Optimize scan based on GO information during persistent * group reinvocation */ - if (wpa_s->p2p_in_invitation < 5 && + if (params->freqs == NULL && wpa_s->p2p_in_invitation < 5 && wpa_s->p2p_invite_go_freq > 0) { if (wpa_s->p2p_invite_go_freq == 2 || wpa_s->p2p_invite_go_freq == 5) { diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index da8152560f8..8491588d6fc 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1823,6 +1823,7 @@ int get_shared_radio_freqs_data(struct wpa_supplicant *wpa_s, int get_shared_radio_freqs(struct wpa_supplicant *wpa_s, int *freq_array, unsigned int len, bool exclude_current); +int disabled_freq(struct wpa_supplicant *wpa_s, int freq); void wpas_network_reenabled(void *eloop_ctx, void *timeout_ctx);