From patchwork Fri Nov 4 21:18:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wang X-Patchwork-Id: 1699883 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=hka41bxd; 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=NsZ2RiUs; 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 4N3tmb3Xz6z23lT for ; Sat, 5 Nov 2022 08:19:27 +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=9DstKaD8gq+cdvLTlKHlrBJXcjigL2d/+zD4YbXCCpE=; b=hka41bxdvoV+lm l0VvnT2PVpece9LvZ/6mcWBpeZ2FMe8o5Ma5uwHasXwwxje9yQ7lPlm2LCPn7lcQIw9oPqG0wIWgT GdGIrmJMbek19TxupAiQHgT+KtV20aep4v5ElGDchtQmPXm9UH0R41KpaMOx0WXE8M5eqb5hAgnFP s5qKsxolZ/qW/vo9FJrjzeAJkmNt9Cr+fbi2BiFGI8byLaNZGvLcMKvNwlPj5UkxfEbLHkvXMio57 HvECyPMKuSFRDnlvAgzR5xCMo4vd1df4Zf9r8+F+ukURydOUAre3HyHDOzxK8JOkoenlzrHKfYlRd L6qTL+6mMgE/kMS48kZg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1or44v-005A3m-Mi; Fri, 04 Nov 2022 21:18:18 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1or44o-005A0n-80 for hostap@lists.infradead.org; Fri, 04 Nov 2022 21:18:12 +0000 Received: by mail-pl1-x634.google.com with SMTP id u6so5987753plq.12 for ; Fri, 04 Nov 2022 14:18:06 -0700 (PDT) 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=XxFGLVVMzy+LQlgKBld/wvIVfWFcPNkSlN6QFe5AiGw=; b=NsZ2RiUse6ImDUGVccLPhlufv3dEV4zMbzJBlS8neJLCFzoNO+wk19+7SR60z/Bouo /90CU2Sgh6Kg5EdfQ2HNZP+WJvp8K8wyqAgSbRw1WHojpYbiNjjfskT+rLJReySLrptL p1R4f9ojZuDzOOZFzfJxW6r66Jwi8KNywLBYo= 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=XxFGLVVMzy+LQlgKBld/wvIVfWFcPNkSlN6QFe5AiGw=; b=H7cXJ2CANOyQvT2pr75SGAa4ebCb/kYpUVKZugggfsv3V5GVbJJ5b0T7fP9U/BfYw1 xK6RJc4eDHkbRmvQSeWFE2QAEC9ss0poNxT4iklTGifvfgoHm8fOxseUeAEcoXnedKG2 9RVWkvyGujm1g1/8A6QupWabeFsRS35zAJ0TgUaDYNZ/bUYSfGLyrkXuDOxb6eGQO3Bo aKvHO9hrx6q1o0h/iOYze8x2kDaiLIbwopN8aWtcBpTgmitWV6p/stVUAi+TH1Zo8GgS gUzBfecedT1TroiyR1hbXYX7zTME1L0AErHclzOKk7yIJD1BLosm4ffY1mdVmEHWb2tu Sp2A== X-Gm-Message-State: ACrzQf0QeD+jMlAviOqYEhahXCbOKjmJa9tdydfcyLcVX1kmAXUTDwbf cOk0pjkKh92BxMAiO2Q2jxLLtLuLR6fh7Q== X-Google-Smtp-Source: AMsMyM4jEtixqwZ5YBDOsCSIvTith8JxYEl5+4CpmHdiv+0ynYud6H2/srTR/zemcShHyOIZeg/kCw== X-Received: by 2002:a17:902:7482:b0:186:6d69:6e01 with SMTP id h2-20020a170902748200b001866d696e01mr389530pll.160.1667596685723; Fri, 04 Nov 2022 14:18:05 -0700 (PDT) Received: from matthewmwang2.mtv.corp.google.com ([2620:15c:9d:4:e782:6fe2:8921:6889]) by smtp.gmail.com with ESMTPSA id t7-20020a635f07000000b0046a1c832e9fsm173123pgb.34.2022.11.04.14.18.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 14:18:05 -0700 (PDT) From: Matthew Wang To: j@w1.fi Cc: hostap@lists.infradead.org, matthewmwang@chromium.org Subject: [PATCH] p2p: discount current op freq Date: Fri, 4 Nov 2022 14:18:02 -0700 Message-Id: <20221104211802.1732163-1-matthewmwang@chromium.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221104_141810_341355_78FA067A X-CRM114-Status: GOOD ( 20.91 ) 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: When scanning for a new connection, we currently optimize by scanning all frequencies only when our MCC capabilities will allow an additional operating frequency, and scan only the existing operating [...] 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:634 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 When scanning for a new connection, we currently optimize by scanning all frequencies only when our MCC capabilities will allow an additional operating frequency, and scan only the existing operating frequencies otherwise. This is problematic when there the current operating frequency singularly accounts for one of the shared radio frequencies because we should be able to switch operating frequencies without adding to the channel count. Fix this. Signed-off-by: Matthew Wang --- wpa_supplicant/p2p_supplicant.c | 10 +++++----- wpa_supplicant/scan.c | 11 +++++++++-- wpa_supplicant/sme.c | 2 +- wpa_supplicant/wpa_supplicant.c | 12 +++++++++--- wpa_supplicant/wpa_supplicant_i.h | 5 ++++- 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index f6252b1aa..f9d93439d 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -188,7 +188,7 @@ static int wpas_p2p_num_unused_channels(struct wpa_supplicant *wpa_s) if (!freqs) return -1; - num = get_shared_radio_freqs(wpa_s, freqs, + num = get_shared_radio_freqs(wpa_s, freqs, 0, wpa_s->num_multichan_concurrent); os_free(freqs); @@ -215,7 +215,7 @@ wpas_p2p_valid_oper_freqs(struct wpa_supplicant *wpa_s, if (!freqs) return 0; - num = get_shared_radio_freqs_data(wpa_s, freqs, + num = get_shared_radio_freqs_data(wpa_s, freqs, 0, wpa_s->num_multichan_concurrent); os_memset(p2p_freqs, 0, sizeof(struct wpa_used_freq_data) * len); @@ -6442,7 +6442,7 @@ static int wpas_p2p_init_go_params(struct wpa_supplicant *wpa_s, if (!freqs) return -1; - num = get_shared_radio_freqs_data(wpa_s, freqs, + num = get_shared_radio_freqs_data(wpa_s, freqs, 0, wpa_s->num_multichan_concurrent); if (wpa_s->current_ssid && @@ -8292,7 +8292,7 @@ void wpas_p2p_update_channel_list(struct wpa_supplicant *wpa_s, if (!freqs) return; - num = get_shared_radio_freqs_data(wpa_s, freqs, num); + num = get_shared_radio_freqs_data(wpa_s, freqs, 0, num); os_memset(&chan, 0, sizeof(chan)); os_memset(&cli_chan, 0, sizeof(cli_chan)); @@ -9838,7 +9838,7 @@ static void wpas_p2p_reconsider_moving_go(void *eloop_ctx, void *timeout_ctx) if (!freqs) return; - num = get_shared_radio_freqs_data(wpa_s, freqs, num); + num = get_shared_radio_freqs_data(wpa_s, freqs, 0, num); /* Previous attempt to move a GO was not possible -- try again. */ wpas_p2p_consider_moving_gos(wpa_s, freqs, num, diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index 05913a181..ea701bbac 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -1267,7 +1267,8 @@ ssid_list_set: params.freqs = os_calloc(num + 1, sizeof(int)); if (params.freqs) { - num = get_shared_radio_freqs(wpa_s, params.freqs, num); + num = get_shared_radio_freqs(wpa_s, params.freqs, 0, + num); if (num > 0) { wpa_dbg(wpa_s, MSG_DEBUG, "Scan only the " "current operating channels since " @@ -1357,7 +1358,13 @@ scan: params.freqs = os_calloc(num + 1, sizeof(int)); if (params.freqs) { - num = get_shared_radio_freqs(wpa_s, params.freqs, num); + /* + * Exclude the operating frequency of the current + * interface since we're looking to transition off of + * it. + */ + num = get_shared_radio_freqs(wpa_s, params.freqs, + 1, num); if (num > 0 && num == wpa_s->num_multichan_concurrent) { wpa_dbg(wpa_s, MSG_DEBUG, "Scan only the current operating channels since all channels are already used"); } else { diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c index 41b67f8eb..cfac4986a 100644 --- a/wpa_supplicant/sme.c +++ b/wpa_supplicant/sme.c @@ -895,7 +895,7 @@ no_fils: */ if (wpa_s->num_multichan_concurrent < 2) { int freq, num; - num = get_shared_radio_freqs(wpa_s, &freq, 1); + num = get_shared_radio_freqs(wpa_s, &freq, 0, 1); if (num > 0 && freq > 0 && freq != params.freq) { wpa_printf(MSG_DEBUG, "Conflicting frequency found (%d != %d)", diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 761017248..12e436b01 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -4128,7 +4128,7 @@ static void wpas_start_assoc_cb(struct wpa_radio_work *work, int deinit) */ if (wpa_s->num_multichan_concurrent < 2) { int freq, num; - num = get_shared_radio_freqs(wpa_s, &freq, 1); + num = get_shared_radio_freqs(wpa_s, &freq, 0, 1); if (num > 0 && freq > 0 && freq != params.freq.freq) { wpa_printf(MSG_DEBUG, "Assoc conflicting freq found (%d != %d)", @@ -8404,6 +8404,7 @@ void dump_freq_data(struct wpa_supplicant *wpa_s, const char *title, */ int get_shared_radio_freqs_data(struct wpa_supplicant *wpa_s, struct wpa_used_freq_data *freqs_data, + unsigned int exclude_current, unsigned int len) { struct wpa_supplicant *ifs; @@ -8420,6 +8421,9 @@ int get_shared_radio_freqs_data(struct wpa_supplicant *wpa_s, if (idx == len) break; + if (exclude_current && ifs == wpa_s) + continue; + if (ifs->current_ssid == NULL || ifs->assoc_freq == 0) continue; @@ -8457,7 +8461,8 @@ int get_shared_radio_freqs_data(struct wpa_supplicant *wpa_s, * are using the same radio as the current interface. */ int get_shared_radio_freqs(struct wpa_supplicant *wpa_s, - int *freq_array, unsigned int len) + int *freq_array, unsigned int exclude_current, + unsigned int len) { struct wpa_used_freq_data *freqs_data; int num, i; @@ -8468,7 +8473,8 @@ int get_shared_radio_freqs(struct wpa_supplicant *wpa_s, if (!freqs_data) return -1; - num = get_shared_radio_freqs_data(wpa_s, freqs_data, len); + num = get_shared_radio_freqs_data(wpa_s, freqs_data, exclude_current, + len); for (i = 0; i < num; i++) freq_array[i] = freqs_data[i].freq; diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 813e5ac1b..c3d74e81c 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1850,11 +1850,14 @@ void dump_freq_data(struct wpa_supplicant *wpa_s, const char *title, struct wpa_used_freq_data *freqs_data, unsigned int len); +int get_op_freq(struct wpa_supplicant *wpa_s); int get_shared_radio_freqs_data(struct wpa_supplicant *wpa_s, struct wpa_used_freq_data *freqs_data, + unsigned int exclude_current, unsigned int len); int get_shared_radio_freqs(struct wpa_supplicant *wpa_s, - int *freq_array, unsigned int len); + int *freq_array, unsigned int exclude_current, + unsigned int len); void wpas_network_reenabled(void *eloop_ctx, void *timeout_ctx);