Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2992566pxb; Thu, 3 Feb 2022 21:20:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJyQNz0eC6CDLn2VvB1LaF6XGtYbUksBiLCo7HySU3E5z6dnemFY+9zDuZ/O6nqa2kmH8GT9 X-Received: by 2002:a17:90b:3b82:: with SMTP id pc2mr1288218pjb.234.1643952054796; Thu, 03 Feb 2022 21:20:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643952054; cv=none; d=google.com; s=arc-20160816; b=NjHn5b7GGhgTJ5VNTjghgl1w6c3XEAumV9UAG+O2JvRWN+wgkqvhTzWPikFN8Jz4X/ 05j4ylnf/NK7uyUUYTuXgJkVGNi7NxAo7RmcRZI452TpowPcESG/EuSLC7k4Y59EA9TO dDQxWV21ZQEOfdKokCiE/didSI1GNfWT3Y+g8H0wXNwbpbpPGdQ5SqvUDYiQBHMS8zoT oPR+Z+vm2RnqMVKzSsQuG7u5QwnshElTYgVupsfFH2I7noCQEkQjs+wlEeBn1+uAwSr0 OkOX2N+stZJEbKCATfrDpDUvfoq41GfhSirA4GGgWAV5XaWYdrCQ7334/bvUDW4at3Y9 WQvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=J8izCMubhPxmraWY4PYRse5rWcXVEQvqmsH8Yonz6Ss=; b=e/dBLRI23u/EAQF4HpPWKpyNXKupNMonqn+m7kDjDHzk/irUob5L5vWDYXN9rEpBEc MrDWZbWpzDGQ9kHr0f9tlJ/+6ZfrLjylPVDI2EEEnXmQoLrQqPDxMZl1Ac20tfae7dg2 SRcD1woBU4LHo1dFpHomJ7IVimDGtofMmt20HRFz/vGCijoBKJ9uAZIjvtIMp4uR/x6v QnvJMFdCzCSaIZx/EPlCwt5jB8jWO2MmUXkhOMMvlttr+cePKfE2AuJpESi+SPQW9QAi 6wuUiIFxLDv+badYUeCuL+MUFl40fttUNow3N786QR0/sykF8dk1ncE5yRSX4eCj7vP5 HSDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=MGG4P1lA; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h123si947854pgc.414.2022.02.03.21.20.36; Thu, 03 Feb 2022 21:20:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=MGG4P1lA; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351858AbiBCPWY (ORCPT + 72 others); Thu, 3 Feb 2022 10:22:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236933AbiBCPWX (ORCPT ); Thu, 3 Feb 2022 10:22:23 -0500 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63E76C06173B for ; Thu, 3 Feb 2022 07:22:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject :Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=J8izCMubhPxmraWY4PYRse5rWcXVEQvqmsH8Yonz6Ss=; b=MGG4P1lA51gDyvphFashkARHxU ArGeZLKrqHcwT8MTgkpjxim9XDTHIhJv4dJ/SbrKNjefi5sxjqXUGSojlhIq/D6WnkHcGL0woQBwI dNtrFKjB/MiY/mq8s+b0MjxMPYhXZiYzpLQy1e6hEoiB1uFje/3pCgqSoRLE/7sBBcoI=; Received: from p200300daa71e0b007cedb37d167c1481.dip0.t-ipconnect.de ([2003:da:a71e:b00:7ced:b37d:167c:1481] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1nFdwD-0004NA-J0; Thu, 03 Feb 2022 16:22:21 +0100 From: Felix Fietkau To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net Subject: [RFC] mac80211: upgrade passive scan to active scan on DFS channels after beacon rx Date: Thu, 3 Feb 2022 16:22:20 +0100 Message-Id: <20220203152220.9134-1-nbd@nbd.name> X-Mailer: git-send-email 2.32.0 (Apple Git-132) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org In client mode, we can't connect to hidden SSID APs or SSIDs not advertised in beacons on DFS channels, since we're forced to passive scan. Fix this by sending out a probe request immediately after the first beacon, if active scan was requested by the user. Signed-off-by: Felix Fietkau --- net/mac80211/ieee80211_i.h | 5 +++++ net/mac80211/scan.c | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 330ea62231fa..958e3e114d0f 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1128,6 +1128,9 @@ struct tpt_led_trigger { * a scan complete for an aborted scan. * @SCAN_HW_CANCELLED: Set for our scan work function when the scan is being * cancelled. + * @SCAN_BEACON_WAIT: Set whenever we're passive scanning because of radar/no-IR + * and could send a probe request after receiving a beacon. + * @SCAN_BEACON_DONE: Beacon received, we can now send a probe request */ enum { SCAN_SW_SCANNING, @@ -1136,6 +1139,8 @@ enum { SCAN_COMPLETED, SCAN_ABORTED, SCAN_HW_CANCELLED, + SCAN_BEACON_WAIT, + SCAN_BEACON_DONE, }; /** diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index 5e6b275afc9e..b698756887eb 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c @@ -281,6 +281,16 @@ void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb) if (likely(!sdata1 && !sdata2)) return; + if (test_and_clear_bit(SCAN_BEACON_WAIT, &local->scanning)) { + /* + * we were passive scanning because of radar/no-IR, but + * the beacon/proberesp rx gives us an opportunity to upgrade + * to active scan + */ + set_bit(SCAN_BEACON_DONE, &local->scanning); + ieee80211_queue_delayed_work(&local->hw, &local->scan_work, 0); + } + if (ieee80211_is_probe_resp(mgmt->frame_control)) { struct cfg80211_scan_request *scan_req; struct cfg80211_sched_scan_request *sched_scan_req; @@ -787,6 +797,8 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata, IEEE80211_CHAN_RADAR)) || !req->n_ssids) { next_delay = IEEE80211_PASSIVE_CHANNEL_TIME; + if (req->n_ssids) + set_bit(SCAN_BEACON_WAIT, &local->scanning); } else { ieee80211_scan_state_send_probe(local, &next_delay); next_delay = IEEE80211_CHANNEL_TIME; @@ -998,6 +1010,8 @@ static void ieee80211_scan_state_set_channel(struct ieee80211_local *local, !scan_req->n_ssids) { *next_delay = IEEE80211_PASSIVE_CHANNEL_TIME; local->next_scan_state = SCAN_DECISION; + if (scan_req->n_ssids) + set_bit(SCAN_BEACON_WAIT, &local->scanning); return; } @@ -1090,6 +1104,8 @@ void ieee80211_scan_work(struct work_struct *work) goto out; } + clear_bit(SCAN_BEACON_WAIT, &local->scanning); + /* * as long as no delay is required advance immediately * without scheduling a new work @@ -1100,6 +1116,10 @@ void ieee80211_scan_work(struct work_struct *work) goto out_complete; } + if (test_and_clear_bit(SCAN_BEACON_DONE, &local->scanning) && + local->next_scan_state == SCAN_DECISION) + local->next_scan_state = SCAN_SEND_PROBE; + switch (local->next_scan_state) { case SCAN_DECISION: /* if no more bands/channels left, complete scan */ -- 2.32.0 (Apple Git-132)