From patchwork Mon Aug 6 19:46:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathy Vanhoef X-Patchwork-Id: 954186 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cs.kuleuven.be Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Pnlk97eW"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41kpC01HsTz9s4v for ; Tue, 7 Aug 2018 05:49:48 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=chODRuxiRT75oOtAdNXPB4vSz2gblyy8/o/x9zK0EBc=; b=Pnlk97eWYoKT+SXMOjIdALBCAi dhVa63L91SyrR+2cbp+7ejzHfet/XTc0BOxbJUzFZ2HyFDas/mlW7/GxWKARybRONLSdv6zK3ywF/ 7BZ5OATeOjH1tpow9agu8UQ8yuw8eD/pW//3wjZTXoi4yvRNmHvTJGJJrG7BEXUkPGY+MkiC2pvHG evlM1SYgOxf7vXYQwqboEgvXKbXXI+kkO6oifARu48ldBH+bKE0Zt3fNuj575jyyA/RFPrilZIkgx bCyLsPv11V7427sOtD90JQUfjabB6RuRsTllOHP6l1redlkdSsEi75YwY7slybBOkkRyQIWUA1GjB ucfQ8Ckw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmlVS-0007D3-2r; Mon, 06 Aug 2018 19:49:30 +0000 Received: from vmailrelay1.cs.kuleuven.be ([2a02:2c40:0:a000::118] helo=hermes4.cs.kuleuven.be) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmlVB-0007Bx-4L for hostap@lists.infradead.org; Mon, 06 Aug 2018 19:49:15 +0000 Received: from dr-zook.cs.kuleuven.be. (vdr-zook1.cs.kuleuven.be [IPv6:2a02:2c40:500:a005::12c]) by hermes4.cs.kuleuven.be. with ESMTP id w76JitdJ018493 for ; Mon, 6 Aug 2018 21:44:55 +0200 Received: from localhost (localhost [127.0.0.1]) by dr-zook.cs.kuleuven.be. (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id w76JisNB020819 for ; Mon, 6 Aug 2018 21:44:54 +0200 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dr-zook.cs.kuleuven.be. X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Virus-Scanned: Debian amavisd-new at dr-zook.cs.kuleuven.be Received: from dr-zook.cs.kuleuven.be. ([127.0.0.1]) by localhost (dr-zook.cs.kuleuven.be [127.0.0.1]) (amavisd-new, port 10023) with LMTP id XsABuGBKlHZt for ; Mon, 6 Aug 2018 21:44:47 +0200 (CEST) Received: from oryx.cs.kuleuven.be. (mail4.cs.kuleuven.be [IPv6:2a02:2c40:0:a000::122]) by dr-zook.cs.kuleuven.be. (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id w76JijjR020796 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 6 Aug 2018 21:44:45 +0200 Received: from localhost.localdomain (ip-83-134-207-58.dsl.scarlet.be [83.134.207.58]) (authenticated bits=0) by oryx.cs.kuleuven.be. (A_Good_MTA/8.14.4/Debian-4.1ubuntu1) with ESMTP id w76Jhl90019837 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 6 Aug 2018 21:44:44 +0200 From: Maty Vanhoef To: hostap@lists.infradead.org Subject: [PATCH 17/25] OCV: Perform a SA Query after a channel switch Date: Mon, 6 Aug 2018 15:46:35 -0400 Message-Id: <20180806194643.1328-18-Mathy.Vanhoef@cs.kuleuven.be> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180806194643.1328-1-Mathy.Vanhoef@cs.kuleuven.be> References: <20180806194643.1328-1-Mathy.Vanhoef@cs.kuleuven.be> X-Scanned-By: MIMEDefang 2.73 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180806_124913_469452_BB3FF0E1 X-CRM114-Status: GOOD ( 14.06 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maty Vanhoef MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org After the network changed to a new channel, perform a SA Query with the AP after a random delay. This is used to confirm that we are still operating on the real operating channel of the network. Signed-off-by: Mathy Vanhoef --- src/ap/drv_callbacks.c | 2 ++ wpa_supplicant/events.c | 1 + wpa_supplicant/sme.c | 22 ++++++++++++++++++++++ wpa_supplicant/sme.h | 1 + 4 files changed, 26 insertions(+) diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c index 1b15d3a69..a175c807b 100644 --- a/src/ap/drv_callbacks.c +++ b/src/ap/drv_callbacks.c @@ -735,6 +735,8 @@ void hostapd_event_sta_opmode_changed(struct hostapd_data *hapd, const u8 *addr, void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht, int offset, int width, int cf1, int cf2) { + /* TODO: If OCV is enabled deauth STAs that don't perform a SA Query */ + #ifdef NEED_AP_MLME int channel, chwidth, is_dfs; u8 seg0_idx = 0, seg1_idx = 0; diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index fb77f1dbd..428cb7368 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -4295,6 +4295,7 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, } #endif /* CONFIG_AP */ + sme_event_ch_switch(wpa_s); wpas_p2p_update_channel_list(wpa_s, WPAS_P2P_CHANNEL_UPDATE_CS); break; #ifdef CONFIG_AP diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c index a9202e28a..e699eb5b2 100644 --- a/wpa_supplicant/sme.c +++ b/wpa_supplicant/sme.c @@ -2051,6 +2051,7 @@ void sme_sched_obss_scan(struct wpa_supplicant *wpa_s, int enable) static const unsigned int sa_query_max_timeout = 1000; static const unsigned int sa_query_retry_timeout = 201; +static const unsigned int sa_query_ch_switch_max_delay = 5000; /* in usec */ static int sme_check_sa_query_timeout(struct wpa_supplicant *wpa_s) { @@ -2197,6 +2198,27 @@ void sme_event_unprot_disconnect(struct wpa_supplicant *wpa_s, const u8 *sa, } +void sme_event_ch_switch(struct wpa_supplicant *wpa_s) +{ + unsigned int usec; + u32 _rand; + + if (wpa_s->wpa_state != WPA_COMPLETED) + return; + if (!wpa_sm_ocv_enabled(wpa_s->wpa)) + return; + + wpa_dbg(wpa_s, MSG_DEBUG, "SME: Channel switch completed - " + "trigger new SA Query to verify new operating channel"); + sme_stop_sa_query(wpa_s); + + if (os_get_random((u8 *) &_rand, sizeof(_rand)) < 0) + _rand = os_random(); + usec = _rand % (sa_query_ch_switch_max_delay + 1); + eloop_register_timeout(0, usec, sme_sa_query_timer, wpa_s, NULL); +} + + static void sme_process_sa_query_request(struct wpa_supplicant *wpa_s, const u8 *sa, const u8 *data, size_t len) { diff --git a/wpa_supplicant/sme.h b/wpa_supplicant/sme.h index f3c822025..ea20da78f 100644 --- a/wpa_supplicant/sme.h +++ b/wpa_supplicant/sme.h @@ -28,6 +28,7 @@ void sme_event_disassoc(struct wpa_supplicant *wpa_s, struct disassoc_info *info); void sme_event_unprot_disconnect(struct wpa_supplicant *wpa_s, const u8 *sa, const u8 *da, u16 reason_code); +void sme_event_ch_switch(struct wpa_supplicant *wpa_s); void sme_sa_query_rx(struct wpa_supplicant *wpa_s, const u8 *sa, const u8 *data, size_t len); void sme_state_changed(struct wpa_supplicant *wpa_s);