From patchwork Tue Mar 19 12:35:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Matyukevich X-Patchwork-Id: 1058372 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=quantenna.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="FlPzaT+3"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=quantenna.com header.i=@quantenna.com header.b="o2MELc0y"; 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 44NsyC3r7Kz9s3q for ; Tue, 19 Mar 2019 23:37:23 +1100 (AEDT) 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References: List-Owner; bh=BKfP+MSGsqiKQH/nf8Chn7YhHpl1c8ncUYnLt662ZNM=; b=FlPzaT+3VKEkpW 1HFx5JO0d4+2uqykw3IpDsvgGkFF6U/zXmTqdvK5FHMs6H6tK3h7SRm/NxdzblzKJdpWjl85BGopO zp7NE25SbNE1Za4errh9p7vnrGLyzPW0cGmQFNlYVZqJ30ASmbgFqXwsjajD65Lc7S3sc7bPQ5PaC 4ePmuV58Plmt78Z1V8phcS04r58hIFH7MsgyGnPnAs+UevayMgIs/CXmnOWH6pKHdCS8gqiqtFmCT YSB4ukjgb9lvw/pJphcxsHq7A5QxHDtPe7zefkFPD0cF/2PZY0NV75myzUzGqZvQvUDc5OxkVN4td 4+MVxF01y/m+Hv+X7cEw==; 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 1h6DzT-0002qC-FG; Tue, 19 Mar 2019 12:37:11 +0000 Received: from mail-eopbgr740082.outbound.protection.outlook.com ([40.107.74.82] helo=NAM01-BN3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h6DzP-0002pP-V3 for hostap@lists.infradead.org; Tue, 19 Mar 2019 12:37:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quantenna.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rxPQeTzxJR6PCgJAcZSR/65wc5cH9eR/zWyYJQSW6sY=; b=o2MELc0yj23PwXU9Tewh5qNUEiPKiqqh10Yn1t+HmgihrHcUoK9gqHH1e9/r0ZooLu/K85Vv+aPUXVKgYli801MQGegnQH4oq0oxKfQc204Z/sM4n7Wo1KhddHz+gTwp5+97+o73SX+W7gep02RwtqhOYlv5OilMa5PQZYlbHMA= Received: from CY4PR05MB3192.namprd05.prod.outlook.com (10.172.155.13) by CY4PR05MB3319.namprd05.prod.outlook.com (10.171.247.167) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1709.11; Tue, 19 Mar 2019 12:36:50 +0000 Received: from CY4PR05MB3192.namprd05.prod.outlook.com ([fe80::5953:8ce2:871f:739b]) by CY4PR05MB3192.namprd05.prod.outlook.com ([fe80::5953:8ce2:871f:739b%10]) with mapi id 15.20.1709.015; Tue, 19 Mar 2019 12:36:50 +0000 Received: from SN6PR05MB4928.namprd05.prod.outlook.com (52.135.117.74) by SN6PR05MB5390.namprd05.prod.outlook.com (52.135.111.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1730.6; Tue, 19 Mar 2019 12:35:57 +0000 Received: from SN6PR05MB4928.namprd05.prod.outlook.com ([fe80::ecfd:3a22:dcb3:3b9e]) by SN6PR05MB4928.namprd05.prod.outlook.com ([fe80::ecfd:3a22:dcb3:3b9e%4]) with mapi id 15.20.1709.015; Tue, 19 Mar 2019 12:35:57 +0000 From: Sergey Matyukevich To: "hostap@lists.infradead.org" Subject: [PATCH] STA OBSS: add check for overlapping BSSs Thread-Topic: [PATCH] STA OBSS: add check for overlapping BSSs Thread-Index: AQHU3lBMR5NYHMGetE+Zipk1HWZRgw== Date: Tue, 19 Mar 2019 12:35:56 +0000 Message-ID: <20190319123550.2102-1-sergey.matyukevich.os@quantenna.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR06CA0043.namprd06.prod.outlook.com (2603:10b6:a03:14b::20) To SN6PR05MB4928.namprd05.prod.outlook.com (2603:10b6:805:9d::10) authentication-results: spf=none (sender IP is ) smtp.mailfrom=sergey.matyukevich.os@quantenna.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.11.0 x-originating-ip: [195.182.157.78] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5ca28c4d-6798-46a1-2fee-08d6ac676ede x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020); SRVR:SN6PR05MB5390; x-ms-traffictypediagnostic: SN6PR05MB5390:|CY4PR05MB3319: x-moderation-data: 3/19/2019 12:36:48 PM x-microsoft-antispam-prvs: x-forefront-prvs: 0981815F2F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(396003)(136003)(346002)(376002)(39850400004)(189003)(199004)(2616005)(476003)(436003)(486006)(105586002)(106356001)(6436002)(50226002)(6512007)(5640700003)(5660300002)(8936002)(86362001)(66066001)(14454004)(68736007)(1076003)(256004)(3846002)(6116002)(102836004)(186003)(4326008)(99286004)(52116002)(103116003)(25786009)(71190400001)(71200400001)(478600001)(2906002)(97736004)(107886003)(6486002)(2501003)(6916009)(26005)(2351001)(53936002)(386003)(81156014)(81166006)(7736002)(1730700003)(8676002)(6506007)(305945005)(54906003)(36756003)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR05MB3319; H:CY4PR05MB3192.namprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: quantenna.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: +FXC0v66z1QCNXTy4IicxYclbQM36ZXBR9otxeuKiF4bXGEKgA6ocgomB6gNnZQqfRBFHoDyyO0icNLwv3OJSi14dSuuuJ1STgHPMWxJFVXPzlyetrv7i4qF6kyuEeZmcXM13TH45/+dzqi5Dbx3OapJjcraUdWzSv29yM6PsSxvwQ359ryrn55b4suBb6Q/IX7aJjyNCRVTToCrIcQ5Sr7/rHe3N7mQmb3zScN/i6T/rU9eZ1IrC3qv5PBLQGpb9EmQlBWE96rboO3l1G5xOOXfKPriabk9w4TjZlkBlO0glJbL+kqj8mlumQbP/sL8TB1KOpyjZRhGDVFWzc7A2EOJGUftJxoKjZtSQ4YLZ/D2qDPQ8mr/yZkjX21KdrFakMBaogfrfHSairD6+S//CcXuUBjefb5Z/za1T0qovR8= MIME-Version: 1.0 X-OriginatorOrg: quantenna.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5ca28c4d-6798-46a1-2fee-08d6ac676ede X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a355dbce-62b4-4789-9446-c1d5582180ff X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Mar 2019 12:36:50.5468 (UTC) X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR05MB3319 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190319_053708_126743_1C4A2E84 X-CRM114-Status: GOOD ( 18.23 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [40.107.74.82 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: Igor Mitsyanko , Sergey Matyukevich Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org In the current implementation connected STA performs OBSS scan according to requests from its 20/40 MHz AP. However STA checks only 40MHz intolerance bit from HT_CAP IE in scan results. Meanwhile, as per to 802.11 standard, STA should check overlapping BSSs as well. Note that all the required code to check overlapping BSSs is already exists in hostapd source tree since AP does those checks properly before operating as 20/40 MHz BSS in 2.4G band. So this commit makes use of existing code by doing the following changes: - extract new check_bss_coex_40mhz function from check_40mhz_2g4 - replace existing 40MHz intolerance check in sme_proc_obss_scan by new check_bss_coex_40mhz function Signed-off-by: Sergey Matyukevich --- src/common/hw_features_common.c | 132 ++++++++++++++++++++++------------------ src/common/hw_features_common.h | 1 + wpa_supplicant/events.c | 2 +- wpa_supplicant/sme.c | 52 ++++++++++------ wpa_supplicant/sme.h | 6 +- 5 files changed, 113 insertions(+), 80 deletions(-) diff --git a/src/common/hw_features_common.c b/src/common/hw_features_common.c index 49ed80657..e76edf106 100644 --- a/src/common/hw_features_common.c +++ b/src/common/hw_features_common.c @@ -273,6 +273,78 @@ static int check_20mhz_bss(struct wpa_scan_res *bss, int pri_freq, int start, } +int check_bss_coex_40mhz(struct wpa_scan_res *bss, int pri_freq, int sec_freq) +{ + int affected_start, affected_end; + struct ieee802_11_elems elems; + int pri_chan, sec_chan; + int pri = bss->freq; + int sec = pri; + + if (pri_freq == sec_freq) + return 0; + + affected_start = (pri_freq + sec_freq) / 2 - 25; + affected_end = (pri_freq + sec_freq) / 2 + 25; + + /* Check for overlapping 20 MHz BSS */ + if (check_20mhz_bss(bss, pri_freq, affected_start, + affected_end)) { + wpa_printf(MSG_DEBUG, + "Overlapping 20 MHz BSS is found"); + return 0; + } + + get_pri_sec_chan(bss, &pri_chan, &sec_chan); + + if (sec_chan) { + if (sec_chan < pri_chan) + sec = pri - 20; + else + sec = pri + 20; + } + + if ((pri < affected_start || pri > affected_end) && + (sec < affected_start || sec > affected_end)) + return 1; /* not within affected channel range */ + + wpa_printf(MSG_DEBUG, "Neighboring BSS: " MACSTR + " freq=%d pri=%d sec=%d", + MAC2STR(bss->bssid), bss->freq, pri_chan, sec_chan); + + if (sec_chan) { + if (pri_freq != pri || sec_freq != sec) { + wpa_printf(MSG_DEBUG, + "40 MHz pri/sec mismatch with BSS " + MACSTR + " <%d,%d> (chan=%d%c) vs. <%d,%d>", + MAC2STR(bss->bssid), + pri, sec, pri_chan, + sec > pri ? '+' : '-', + pri_freq, sec_freq); + return 0; + } + } + + ieee802_11_parse_elems((u8 *) (bss + 1), bss->ie_len, &elems, + 0); + if (elems.ht_capabilities) { + struct ieee80211_ht_capabilities *ht_cap = + (struct ieee80211_ht_capabilities *) + elems.ht_capabilities; + + if (le_to_host16(ht_cap->ht_capabilities_info) & + HT_CAP_INFO_40MHZ_INTOLERANT) { + wpa_printf(MSG_DEBUG, + "40 MHz Intolerant is set on channel %d in BSS " + MACSTR, pri, MAC2STR(bss->bssid)); + return 0; + } + } + + return 1; +} + int check_40mhz_2g4(struct hostapd_hw_modes *mode, struct wpa_scan_results *scan_res, int pri_chan, int sec_chan) @@ -293,67 +365,11 @@ int check_40mhz_2g4(struct hostapd_hw_modes *mode, wpa_printf(MSG_DEBUG, "40 MHz affected channel range: [%d,%d] MHz", affected_start, affected_end); for (i = 0; i < scan_res->num; i++) { - struct wpa_scan_res *bss = scan_res->res[i]; - int pri = bss->freq; - int sec = pri; - struct ieee802_11_elems elems; - - /* Check for overlapping 20 MHz BSS */ - if (check_20mhz_bss(bss, pri_freq, affected_start, - affected_end)) { - wpa_printf(MSG_DEBUG, - "Overlapping 20 MHz BSS is found"); + if (!check_bss_coex_40mhz(scan_res->res[i], pri_freq, sec_freq)) return 0; - } - - get_pri_sec_chan(bss, &pri_chan, &sec_chan); - - if (sec_chan) { - if (sec_chan < pri_chan) - sec = pri - 20; - else - sec = pri + 20; - } - - if ((pri < affected_start || pri > affected_end) && - (sec < affected_start || sec > affected_end)) - continue; /* not within affected channel range */ - - wpa_printf(MSG_DEBUG, "Neighboring BSS: " MACSTR - " freq=%d pri=%d sec=%d", - MAC2STR(bss->bssid), bss->freq, pri_chan, sec_chan); - - if (sec_chan) { - if (pri_freq != pri || sec_freq != sec) { - wpa_printf(MSG_DEBUG, - "40 MHz pri/sec mismatch with BSS " - MACSTR - " <%d,%d> (chan=%d%c) vs. <%d,%d>", - MAC2STR(bss->bssid), - pri, sec, pri_chan, - sec > pri ? '+' : '-', - pri_freq, sec_freq); - return 0; - } - } - - ieee802_11_parse_elems((u8 *) (bss + 1), bss->ie_len, &elems, - 0); - if (elems.ht_capabilities) { - struct ieee80211_ht_capabilities *ht_cap = - (struct ieee80211_ht_capabilities *) - elems.ht_capabilities; - - if (le_to_host16(ht_cap->ht_capabilities_info) & - HT_CAP_INFO_40MHZ_INTOLERANT) { - wpa_printf(MSG_DEBUG, - "40 MHz Intolerant is set on channel %d in BSS " - MACSTR, pri, MAC2STR(bss->bssid)); - return 0; - } - } } + return 1; } diff --git a/src/common/hw_features_common.h b/src/common/hw_features_common.h index eb1f1c57f..256b86cbf 100644 --- a/src/common/hw_features_common.h +++ b/src/common/hw_features_common.h @@ -43,5 +43,6 @@ u32 num_chan_to_bw(int num_chans); int chan_bw_allowed(const struct hostapd_channel_data *chan, u32 bw, int ht40_plus, int pri); int chan_pri_allowed(const struct hostapd_channel_data *chan); +int check_bss_coex_40mhz(struct wpa_scan_res *bss, int pri_freq, int sec_freq); #endif /* HW_FEATURES_COMMON_H */ diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index a46ef187c..4127be231 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1901,7 +1901,7 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s, if (wnm_scan_process(wpa_s, 1) > 0) goto scan_work_done; - if (sme_proc_obss_scan(wpa_s) > 0) + if (sme_proc_obss_scan(wpa_s, scan_res) > 0) goto scan_work_done; if (own_request && data && diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c index c435bf305..761449976 100644 --- a/wpa_supplicant/sme.c +++ b/wpa_supplicant/sme.c @@ -13,6 +13,7 @@ #include "common/ieee802_11_defs.h" #include "common/ieee802_11_common.h" #include "common/ocv.h" +#include "common/hw_features_common.h" #include "eapol_supp/eapol_supp_sm.h" #include "common/wpa_common.h" #include "common/sae.h" @@ -2049,13 +2050,14 @@ static void sme_send_2040_bss_coex(struct wpa_supplicant *wpa_s, } -int sme_proc_obss_scan(struct wpa_supplicant *wpa_s) +int sme_proc_obss_scan(struct wpa_supplicant *wpa_s, + struct wpa_scan_results *scan_res) { - struct wpa_bss *bss; + u8 chan_list[P2P_MAX_CHANNELS]; + u8 num_channels = 0, num_intol = 0; + int pri_freq, sec_freq; const u8 *ie; - u16 ht_cap; - u8 chan_list[P2P_MAX_CHANNELS], channel; - u8 num_channels = 0, num_intol = 0, i; + int i, c; if (!wpa_s->sme.sched_obss_scan) return 0; @@ -2083,30 +2085,42 @@ int sme_proc_obss_scan(struct wpa_supplicant *wpa_s) os_memset(chan_list, 0, sizeof(chan_list)); - dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) { - /* Skip other band bss */ + pri_freq = wpa_s->assoc_freq; + + switch (wpa_s->sme.ht_sec_chan) { + case HT_SEC_CHAN_ABOVE: + sec_freq = pri_freq + 20; + break; + case HT_SEC_CHAN_BELOW: + sec_freq = pri_freq - 20; + break; + case HT_SEC_CHAN_UNKNOWN: + default: + wpa_msg(wpa_s, MSG_WARNING, "Undefined secondary channel: drop OBSS results"); + return 1; + } + + for (i = 0; i < scan_res->num; i++) { + struct wpa_scan_res *bss = scan_res->res[i]; enum hostapd_hw_mode mode; + u8 channel; + + /* Skip other band bss */ mode = ieee80211_freq_to_chan(bss->freq, &channel); if (mode != HOSTAPD_MODE_IEEE80211G && mode != HOSTAPD_MODE_IEEE80211B) continue; - ie = wpa_bss_get_ie(bss, WLAN_EID_HT_CAP); - ht_cap = (ie && (ie[1] == 26)) ? WPA_GET_LE16(ie + 2) : 0; - wpa_printf(MSG_DEBUG, "SME OBSS scan BSS " MACSTR - " freq=%u chan=%u ht_cap=0x%x", - MAC2STR(bss->bssid), bss->freq, channel, ht_cap); - - if (!ht_cap || (ht_cap & HT_CAP_INFO_40MHZ_INTOLERANT)) { - if (ht_cap & HT_CAP_INFO_40MHZ_INTOLERANT) - num_intol++; + if (!check_bss_coex_40mhz(bss, pri_freq, sec_freq)) { + num_intol++; /* Check whether the channel is already considered */ - for (i = 0; i < num_channels; i++) { - if (channel == chan_list[i]) + for (c = 0; c < num_channels; c++) { + if (channel == chan_list[c]) break; } - if (i != num_channels) + + if (c != num_channels) continue; chan_list[num_channels++] = channel; diff --git a/wpa_supplicant/sme.h b/wpa_supplicant/sme.h index 1a7f9e832..42d5a8317 100644 --- a/wpa_supplicant/sme.h +++ b/wpa_supplicant/sme.h @@ -37,7 +37,8 @@ void sme_disassoc_while_authenticating(struct wpa_supplicant *wpa_s, void sme_clear_on_disassoc(struct wpa_supplicant *wpa_s); void sme_deinit(struct wpa_supplicant *wpa_s); -int sme_proc_obss_scan(struct wpa_supplicant *wpa_s); +int sme_proc_obss_scan(struct wpa_supplicant *wpa_s, + struct wpa_scan_results *scan_res); void sme_sched_obss_scan(struct wpa_supplicant *wpa_s, int enable); void sme_external_auth_trigger(struct wpa_supplicant *wpa_s, union wpa_event_data *data); @@ -112,7 +113,8 @@ static inline void sme_deinit(struct wpa_supplicant *wpa_s) { } -static inline int sme_proc_obss_scan(struct wpa_supplicant *wpa_s) +static inline int sme_proc_obss_scan(struct wpa_supplicant *wpa_s, + struct wpa_scan_results *scan_res) { return 0; }