From patchwork Fri Dec 6 22:27:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wang X-Patchwork-Id: 1210079 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="URa2Bp5e"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="mA3dB0d9"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47bphp176Lz9sPK for ; Mon, 16 Dec 2019 15:49:30 +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=Z5gQgAU0AYgBGjRhbtZp6fSmkeDAAb4xtCOyr+pyT5w=; b=URa2Bp5eKZds52 PLK5miatro8Jx2xgAnYz2ludt1Dko7/EteD74DuPA8I6T3OJQ3OVXvDUQV98PU8d6MxnnYJCZQNtL U74IOVoHKuC/ywrgIwxDlpHNwSr/ShdL3LL8P0oz5WqbpqLM8bbxDORpkLONbRU81rxKaX26sXUbn H1eq8rt6MvTsF7HLlXhY63tSE9xS0VIme4a5WdZPc7CY6J+MV8u3VNM302FwsH4M88fYnOH/RESW5 YUsodaSJDSg5GKMk2N4WMP/KdMsdwD6kg7OJ8D39rzd35y3ZIKey36iyx1MRJKhOzWHawDqnVbai2 zRHFU9i5hmz0rcm4RF7g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1igiJy-0000rc-MW; Mon, 16 Dec 2019 04:49:26 +0000 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1idM4x-00072d-7Y for hostap@lists.infradead.org; Fri, 06 Dec 2019 22:28:04 +0000 Received: by mail-pg1-x530.google.com with SMTP id z124so3997207pgb.13 for ; Fri, 06 Dec 2019 14:28:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=eHNpBZQq5+7rDtMch7cCX8GAQ5TQkk1gnMsrPwpupdE=; b=mA3dB0d9ay7anV7KMOQquboyKIepa43lozGo/4gTAwcY8vAlwMp0if/5Tp/nD1FVf5 qDQZCh37nthAOrQO82+QYIzKHLiXD+beMpbxVaubk5VU6m1urjSkN2+zlmFrJzOjZ7Ti 4zD3MKHeiPfzBVZAX1txd0+vs4sModc7D64qY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=eHNpBZQq5+7rDtMch7cCX8GAQ5TQkk1gnMsrPwpupdE=; b=AvVn44rwDZR9saXFn8GoxdaldmGkc7tQQrZKHkIgSairmek0YzvDZHl23P1FohK+9y wxS11lZ+1Yiuv/sEXLiI85KNai/Hqy1RkzV2U6OXYiUWpKNroS+v/cudvvIq6uYqiLr8 3ooQL0c0zwwuZBFdA2Wo+X7ORbHVKzO2yw28/So5Cw6LvNZJ+9ouO5oo4rN6pPPz/at7 H/K/pylv07Qrzbs/03IEOIeRN5Rh1f8thPjZM459FF+P2eVoI6nzasWb/etQwApVijMg qwpWirQE9mXzIYjOqvqminkLrFontWORZVB41dwCtD+oNhqd3WOtJNEzUdWAVmKu/AcV /xrg== X-Gm-Message-State: APjAAAWdEDuvi+xszWmQXmo1R6CZZBQd4dNaNWrWnl/bQp/iBRrxYnBU VCyMDuCdaq6JWPTjvgSWOIs1YnMXzVo= X-Google-Smtp-Source: APXvYqwgJycH7YfRYk86AC/gSAF5PEXy8FNT7zZckAVe3KQeURMXM5IQAm5tQ/9T1UVGQItMnlNtcw== X-Received: by 2002:a63:cc02:: with SMTP id x2mr6209128pgf.114.1575671282290; Fri, 06 Dec 2019 14:28:02 -0800 (PST) Received: from localhost ([2620:15c:202:201:2b10:8627:31e7:c5ec]) by smtp.gmail.com with ESMTPSA id h6sm16037772pgq.61.2019.12.06.14.28.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Dec 2019 14:28:01 -0800 (PST) From: Matthew Wang To: j@w1.fi Subject: [PATCH 1/5] wpa_supplicant: Bump up logging level for roaming decisions Date: Fri, 6 Dec 2019 14:27:44 -0800 Message-Id: <20191206222748.153534-1-matthewmwang@chromium.org> X-Mailer: git-send-email 2.24.0.393.g34dc348eaf-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191206_142803_270990_D6FE0E9F X-CRM114-Status: GOOD ( 13.22 ) 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 [2607:f8b0:4864:20:0:0:0:530 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 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_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-Mailman-Approved-At: Sun, 15 Dec 2019 20:49:24 -0800 X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: briannorris@chromium.org, hostap@lists.infradead.org, matthewmwang@chromium.org, Kirtika Ruchandani Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Kirtika Ruchandani Chrome OS relies on its connection manager, shill, to bump up the logging level in wpa_supplicant during 'interesting' times via its WiFi::SetConnectionDebugging method. The method sets wpa_supplicant debug level to 'info' (quieter) or 'debug' (when verbose). Currently, it is not guaranteed that SetConnectionDebugging will be called on all roaming paths, therefore we end up with two scenarios in the logs: one where roaming happens out of the blue, like so (timestamp removed): shill: [INFO:manager.cc(497)] Service updated; state: Connected failure Unknown shill: [INFO:wifi.cc(9)] Enabling high bitrates. // Connected here shill: [INFO:service.cc(404)] Service : state Connected -> Online shill: [INFO:manager.cc(497)] Service updated; state: Online failure Unknown shill: [INFO:wifi_service.cc(78)] Representative endpoint updated for service... shill: [INFO:manager.cc(74)] Default physical service: (connected) shill: [INFO:wifi.cc(9)] Scan on wlan0 from RequestScan // We have roamed to a new AP that we are trying to authenticate with, // and we don't know why... wpa_supplicant: wlan0: SME: Trying to authenticate with <> (SSID='' freq= MHz) wpa_supplicant: wlan0: Trying to associate with <> (SSID='' freq= MHz) The second scenario, and the preferable one, is where we get details of how roaming decisions were made. This happens when WiFi::SetConnectionDebugging(true) is on the execution path, which seems to be only when connecting to a new service: wpa_supplicant: BSS: last_scan_res_used=14/32 wpa_supplicant: wlan0: New scan results available (own=1 ext=0) wpa_supplicant: bgscan simple: scan result notification wpa_supplicant: bgscan simple: freq_idx 0 wpa_supplicant: bgscan_poll_signal_monitor: bgscan poll noisefloor: 9999 wpa_supplicant: wlan0: Radio work 'scan'<> done in <> seconds wpa_supplicant: wlan0: Selecting BSS from priority group <> wpa_supplicant: wlan0: 0: ssid='' wpa_ie_len=<> rsn_ie_len=<> caps=<> level=<> freq=<> wps wpa_supplicant: wlan0: selected based on RSN IE wpa_supplicant: wlan0: selected BSS <> ssid='' wpa_supplicant: wlan0: Allow reassociation - selected BSS has better estimated throughput wpa_supplicant: wlan0: Considering connect request: reassociate: 0 selected: <> bssid: <> ... wpa_supplicant: wlan0: Request association with <> wpa_supplicant: wlan0: Re-association to the same ESS ... wpa_supplicant: wlan0: SME: Trying to authenticate with <> (SSID='' freq=<> MHz) Until we have confidence that all roaming scenarios do go through shill and can be intercepted with WiFi::SetConnectionDebugging(true), the safer route is to bump up the logging level of the following directly in wpa_supplicant itself: - roaming decisions. - estimated throughput and channel quality calculations. Signed-off-by: Kirtika Ruchandani --- wpa_supplicant/events.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 21ce943d6..46c8b9bae 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1705,13 +1705,13 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, return 1; /* current BSS not seen in the last scan */ #ifndef CONFIG_NO_ROAMING - wpa_dbg(wpa_s, MSG_DEBUG, "Considering within-ESS reassociation"); - wpa_dbg(wpa_s, MSG_DEBUG, "Current BSS: " MACSTR + wpa_dbg(wpa_s, MSG_INFO, "Considering within-ESS reassociation"); + wpa_dbg(wpa_s, MSG_INFO, "Current BSS: " MACSTR " freq=%d level=%d snr=%d est_throughput=%u", MAC2STR(current_bss->bssid), current_bss->freq, current_bss->level, current_bss->snr, current_bss->est_throughput); - wpa_dbg(wpa_s, MSG_DEBUG, "Selected BSS: " MACSTR + wpa_dbg(wpa_s, MSG_INFO, "Selected BSS: " MACSTR " freq=%d level=%d snr=%d est_throughput=%u", MAC2STR(selected->bssid), selected->freq, selected->level, selected->snr, selected->est_throughput); @@ -1719,14 +1719,16 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, if (wpa_s->current_ssid->bssid_set && os_memcmp(selected->bssid, wpa_s->current_ssid->bssid, ETH_ALEN) == 0) { - wpa_dbg(wpa_s, MSG_DEBUG, "Allow reassociation - selected BSS " + wpa_dbg(wpa_s, MSG_INFO, "Allow reassociation - selected BSS " "has preferred BSSID"); return 1; } if (selected->est_throughput > current_bss->est_throughput + 5000) { - wpa_dbg(wpa_s, MSG_DEBUG, - "Allow reassociation - selected BSS has better estimated throughput"); + wpa_dbg(wpa_s, MSG_INFO, + "Allow reassociation - selected BSS has better " + "estimated throughput (current: %u, selected: %u)", + current_bss->est_throughput, selected->est_throughput); return 1; } @@ -1734,7 +1736,7 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, if (current_bss->level < 0 && current_bss->level > selected->level + to_5ghz * 2) { - wpa_dbg(wpa_s, MSG_DEBUG, "Skip roam - Current BSS has better " + wpa_dbg(wpa_s, MSG_INFO, "Skip roam - Current BSS has better " "signal level"); return 0; } @@ -1786,7 +1788,7 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, } diff = abs(current_bss->level - selected->level); if (diff < min_diff) { - wpa_dbg(wpa_s, MSG_DEBUG, + wpa_dbg(wpa_s, MSG_INFO, "Skip roam - too small difference in signal level (%d < %d)", diff, min_diff); return 0; From patchwork Fri Dec 6 22:27:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wang X-Patchwork-Id: 1210080 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="iu5ZY4pf"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ViJTZLKP"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47bpj24Zxjz9sPK for ; Mon, 16 Dec 2019 15:49:42 +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: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=9U/eIUlod0HWrYxma+Pj/j1zKaqUTHYSZvBKpT/8C5U=; b=iu5ZY4pfmW02dn IRNZngPDhWWXSxS3J0IJ7pOL/BoYKJGi/J1qUvAuqdcJyRStMT23k8yDOS3Is2yl6mpIKvGwCGxgI bm55z2/sCfnwSTIrKYhwNQPZyZcNSRTRkIVtSHUkDLHyLdXW7xsiSh0xh+VwI2ARFp3HTMNB1wAqw G4yO9bHBEhoSW74lQUrtPlldS8piN9obYkNE7hytAHinAvJ+tc/DS4Y5a7IP+bhzWuELHzn3lFF1W BaxNJ41XSKBLlzH9LmoR9CPSPSQHO6+dhiMLfOxPTyR4OXyGQy1Dd0uTeKQtU9678WX9xG3Uop2R2 TBYff5Zp8LEKSx1BjtBA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1igiKA-00010e-1A; Mon, 16 Dec 2019 04:49:38 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1idM50-00072x-13 for hostap@lists.infradead.org; Fri, 06 Dec 2019 22:28:07 +0000 Received: by mail-pf1-x435.google.com with SMTP id 2so4065481pfx.6 for ; Fri, 06 Dec 2019 14:28:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kCMVd/t+k/x1mWCiozFKcypNrnGdA2QSYE/93wslnpA=; b=ViJTZLKPvxaMqZ+i4YNDZf7dg3CMT5ACNGKuCqbQPAECailz0Ne4sKMzuq8V6yomYD dm070Z8rnMSQLMnm6vlj+5Bg1qk1v+6ylV744ChCe0lZTdOjoIjKAbGEElmILEu1J5Ik XgRUTibK/HqLF5JqKu4enhOaEfvc0VAk63/1s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kCMVd/t+k/x1mWCiozFKcypNrnGdA2QSYE/93wslnpA=; b=Q9jgnXcZVlRQ1oh5A8PyFUlPFgt/0vxx3zWz3T0CZD17UAvavlWzPeuq3v5qAuJebF u+d11He9jMzhAZwRCXKbQCw7oxialYKfQzjuYFAhG2sjQa3cr7LhRMvwH3Tr0ifpr9yr HPbVJipUjKCoyL7C7IheTqV0pTeIizOULE93+rWN7jCIRCGI99iJ2aeiDyAUYz7scm/b Jq5brR7UKJMniknzkkYo3kz+bFuxOQTS8hQdBwSjDIMECA/s0Aj0PYJo+sjl+ad9RT0/ 4wbx1/y3WCQS5zV+zzrry96e1izUnOuI6a3Cp3beN8aq9DQBqfqaRI5tnBDo9jZ943kS eyXg== X-Gm-Message-State: APjAAAUPn6VfN2MMuL0K43wYeqk2Z6f6C8ppPFKmepqo2K9CcWF3zkAO wqHyJ/LvuDXj43BudNAQB9WYBQ== X-Google-Smtp-Source: APXvYqxwX8zTfL/PHFZqCmxY4QVHXMycpmCS2ICBmohit8MxQ+JR9LvgUhK3zKGFTAcCjnnusUrrSg== X-Received: by 2002:a63:646:: with SMTP id 67mr6141963pgg.150.1575671285113; Fri, 06 Dec 2019 14:28:05 -0800 (PST) Received: from localhost ([2620:15c:202:201:2b10:8627:31e7:c5ec]) by smtp.gmail.com with ESMTPSA id a6sm15733185pgg.25.2019.12.06.14.28.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Dec 2019 14:28:04 -0800 (PST) From: Matthew Wang To: j@w1.fi Subject: [PATCH 2/5] wpa_supplicant: Bump up logging level for blacklist decisions Date: Fri, 6 Dec 2019 14:27:45 -0800 Message-Id: <20191206222748.153534-2-matthewmwang@chromium.org> X-Mailer: git-send-email 2.24.0.393.g34dc348eaf-goog In-Reply-To: <20191206222748.153534-1-matthewmwang@chromium.org> References: <20191206222748.153534-1-matthewmwang@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191206_142806_070067_CF07DF75 X-CRM114-Status: GOOD ( 10.49 ) 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 [2607:f8b0:4864:20:0:0:0:435 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 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_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-Mailman-Approved-At: Sun, 15 Dec 2019 20:49:36 -0800 X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: briannorris@chromium.org, hostap@lists.infradead.org, matthewmwang@chromium.org, Kirtika Ruchandani Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Kirtika Ruchandani Chrome OS relies on its connection manager, shill, to bump up the logging level in wpa_supplicant during 'interesting' times via its WiFi::SetConnectionDebugging method. The method sets wpa_supplicant debug level to 'info' (quieter) or 'debug' (verbose). It's not clear SetConnectionDebugging is being called on execution paths of interest - in particular, APs we are connected to at one instant show up as blacklisted in the scan after an unexpected disconnect, like so: (<> implies redacted/placeholder) wlan0: New scan results available (own=1 ext=0) wlan0: Radio work 'scan'@<> done in <> seconds wlan0: Selecting BSS from priority group <> // This SSID was one we were connected to before, and there was // no mention of blacklisting it in the log lines prior to this. wlan0: 0: <> ssid='<>' wpa_ie_len=0 rsn_ie_len=<> caps=<> level=<> freq=<> wps wlan0: skip - blacklisted (count=2 limit=0) wlan0: 1: <> ssid='<>' wpa_ie_len=0 rsn_ie_len=<> caps=<> level=<> freq=<> wps Ensure that we always print blacklist adding/clearing decisions - its only 3 lines anyways. Signed-off-by: Kirtika Ruchandani --- wpa_supplicant/blacklist.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wpa_supplicant/blacklist.c b/wpa_supplicant/blacklist.c index e53dc38b3..da9259ce0 100644 --- a/wpa_supplicant/blacklist.c +++ b/wpa_supplicant/blacklist.c @@ -63,7 +63,7 @@ int wpa_blacklist_add(struct wpa_supplicant *wpa_s, const u8 *bssid) e = wpa_blacklist_get(wpa_s, bssid); if (e) { e->count++; - wpa_printf(MSG_DEBUG, "BSSID " MACSTR " blacklist count " + wpa_printf(MSG_INFO, "BSSID " MACSTR " blacklist count " "incremented to %d", MAC2STR(bssid), e->count); return e->count; @@ -104,7 +104,7 @@ int wpa_blacklist_del(struct wpa_supplicant *wpa_s, const u8 *bssid) } else { prev->next = e->next; } - wpa_printf(MSG_DEBUG, "Removed BSSID " MACSTR " from " + wpa_printf(MSG_INFO, "Removed BSSID " MACSTR " from " "blacklist", MAC2STR(bssid)); os_free(e); return 0; @@ -132,7 +132,7 @@ void wpa_blacklist_clear(struct wpa_supplicant *wpa_s) max_count = e->count; prev = e; e = e->next; - wpa_printf(MSG_DEBUG, "Removed BSSID " MACSTR " from " + wpa_printf(MSG_INFO, "Removed BSSID " MACSTR " from " "blacklist (clear)", MAC2STR(prev->bssid)); os_free(prev); } From patchwork Fri Dec 6 22:27:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wang X-Patchwork-Id: 1210081 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="uLJKvJ9a"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="U5CI67Ed"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47bpjB1vdTz9sPK for ; Mon, 16 Dec 2019 15:49:50 +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: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=Y7ZID3VVrBYyQiH5nwmgddEqE6uqERpwxoG6qgo/5uk=; b=uLJKvJ9aWfOb+q E5EDHMCyo46bVsomF7j3q6f7luy/kA4msq115o4T+DftkVt92emINtiKal+OvHLOw61pp0bN5npzU ZTLtMFogsJkFXP0Ur9M8dDpU3dBa6evDDj59gl1vb6qLt0gse9fnqoBTgrq8IvIDWT1RvnEPEsFal rt0afHqnU9urV6jR4tdB/MCfAFSLIJ8tslZgcOoBDpSzfipPorfxTi+xfkY5aNQXysnJbhqWJD79M 4D+7Rw3IKHTLF2iRQV9h3G6uwZMmmlg/z+RFFrKFg73wtcjKxUIOpxiwSnlTcZzQhmrNukKnjFo5+ umKT+exuPqWDYLE9WmzQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1igiKG-000185-8Q; Mon, 16 Dec 2019 04:49:44 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1idM52-00073c-6g for hostap@lists.infradead.org; Fri, 06 Dec 2019 22:28:09 +0000 Received: by mail-pl1-x642.google.com with SMTP id w7so3297366plz.12 for ; Fri, 06 Dec 2019 14:28:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gfD1+T1MnzK1D/hAI5/Jo0k7XMn69cElm0lkXTCiPEw=; b=U5CI67EdluuWIMOX5fqbZhyKJwQ5BFrqGFtzUqgzUmcXOIZLcWJAWzn9pPj7WqzJ+N +XWZXceZ8cLqm9WBW91yJzcEEaNy+49YX0b+CCoRFyapvt+SwsGZ56DWmzeHtQK3TMU/ QmBo55KqB9B9TaIs662kTEdK2M1GQtemF5W0g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gfD1+T1MnzK1D/hAI5/Jo0k7XMn69cElm0lkXTCiPEw=; b=rIBQckNAJbqY5RJpbR5OeMFpuCiSK06DpVdksLuMNxOz8aLYjXroTjhGjP7xzbFs9B /NJzG+A8wbw0RfEnG1axjl6TG6vbj0qdPSKucvvmx9dg5GCkPPgAhCuf51M2/XSKv5G/ OvC1VwvYxSAwhRuIgj0rVJrYJ7Wq+jH8iSDpQrfFIoCXTe9kOLzArEtwlaF5ZOsmg0cp A1d2S2XrB0Cf7cALjdHSA8p7Gh4BL3PAdn0g9pCAJSGD+XoKAn5O8RiU+ySvmLRpqr6R gceV2iMIn9xOrfQi/y5wN/dW0hVa25brnAC/l3fA4prlGi+tPo/8sgaoDwjwOa35/n9N 2Otg== X-Gm-Message-State: APjAAAVgkP97xxYwkq9xexUvp7uHs6zWnVTMPYADpoeTFfHRxSOuAwbC YjDDYmjpqEGyuZLDprcn1VaCNg== X-Google-Smtp-Source: APXvYqwVBg+WYjj9LTffvR1xcYTFTQTz2mh328vV24Syf/qbId9sK33d82Xkylxca3dS3kIrkc718A== X-Received: by 2002:a17:90a:77c5:: with SMTP id e5mr747184pjs.83.1575671287442; Fri, 06 Dec 2019 14:28:07 -0800 (PST) Received: from localhost ([2620:15c:202:201:2b10:8627:31e7:c5ec]) by smtp.gmail.com with ESMTPSA id 128sm351520pgi.87.2019.12.06.14.28.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Dec 2019 14:28:06 -0800 (PST) From: Matthew Wang To: j@w1.fi Subject: [PATCH 3/5] wpa_supplicant: Bump logging level in need_to_roam() Date: Fri, 6 Dec 2019 14:27:46 -0800 Message-Id: <20191206222748.153534-3-matthewmwang@chromium.org> X-Mailer: git-send-email 2.24.0.393.g34dc348eaf-goog In-Reply-To: <20191206222748.153534-1-matthewmwang@chromium.org> References: <20191206222748.153534-1-matthewmwang@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191206_142808_240371_8219D13D X-CRM114-Status: GOOD ( 10.46 ) 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 [2607:f8b0:4864:20:0:0:0:642 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 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_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-Mailman-Approved-At: Sun, 15 Dec 2019 20:49:41 -0800 X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: briannorris@chromium.org, hostap@lists.infradead.org, matthewmwang@chromium.org Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Bump up logging level from MSG_DEBUG to MSG_INFO in need_to_roam() function for more visibility. Signed-off-by: Matthew Wang --- wpa_supplicant/events.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 46c8b9bae..32e62c5d1 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1742,7 +1742,7 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, } if (current_bss->est_throughput > selected->est_throughput + 5000) { - wpa_dbg(wpa_s, MSG_DEBUG, + wpa_dbg(wpa_s, MSG_INFO, "Skip roam - Current BSS has better estimated throughput"); return 0; } @@ -1794,7 +1794,7 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, return 0; } - wpa_dbg(wpa_s, MSG_DEBUG, + wpa_dbg(wpa_s, MSG_INFO, "Allow reassociation due to difference in signal level (%d >= %d)", diff, min_diff); return 1; From patchwork Fri Dec 6 22:27:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wang X-Patchwork-Id: 1210082 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BSeXwblU"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="CN6aDUvN"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47bpjM4Nmfz9sPT for ; Mon, 16 Dec 2019 15:49:59 +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: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=CWnGQAZ2FvTUANVQLzKgMouFbWFPIuxgfMeAC6EHcJU=; b=BSeXwblU/fK6N6 bCajIkNs3nnH1UcssLBh+d6o56fBmDEaxOTRiar6vg71qSg6B9wwNva/YvE+gSNtjzo4pcPxbRH9x /wHEQkasCQ/REoYK1JGXwrAXJ7sUF2NIZiz85lUk3dxGfoiktl5RQ6FHMtd8a5Vl76xRwmgKTK52m vMkDqkkWsl8Y3+i3a6PPP19ovEkfyOvUxBda2OJ0A5ofDMncZ/DY5+RRWOXIrANW2lLc9xXHQ8LDS LElMz38CHuwjIjLQKiu33wAUp0lj5dk6zQBTLg4m+P5GL50YWu0jFu6ZwDRYpMrCs6uEptEaOUDyG d9AdMxe3YLeoMTKvWbfQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1igiKQ-0001IK-6N; Mon, 16 Dec 2019 04:49:54 +0000 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1idM54-00074B-Li for hostap@lists.infradead.org; Fri, 06 Dec 2019 22:28:12 +0000 Received: by mail-pg1-x529.google.com with SMTP id l24so4021916pgk.2 for ; Fri, 06 Dec 2019 14:28:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EtY1jUsYIMtlfPKzl3TajqRoqBT4syAPCIvOXJ4GNl0=; b=CN6aDUvNF2iPA3yT//c7l6z9D3lEVRid1f0rQCzgftxPTxwLym9kIy/VxHgfysRgkt fw8bdLq/kFl6rmmrQH2rceeqGd/rvOQHFcGCyQBg1qFXMmsTzFTZi/ro0DjezS0Pv0bs yPhglwJ8SmqSFMSRx4TEGB9+3Glk9GkncWVfA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EtY1jUsYIMtlfPKzl3TajqRoqBT4syAPCIvOXJ4GNl0=; b=lMT+OVRKV2om9QEA50q8FCc0S2pzksW0bii9VCRxBqbYWtXrrT843ILDPxvHk8B3It iz3iPXuCsw0zKD2dXLoVazUuI+9EOttWbp5saezmUzmOXNZkDgt213E4zhosAWM+nz0v 3jihdy6QX4pnpZooKFg5AIkx2E9juMaT330CcfvEvAA4+hd9In9arD9k2ZmzK20n61IN DjlcTu+q9UAvOjdK/dK6mcZgb869xKxk3f8BDRulJAsvlUr36Ww7saO8W1LS9HZtmyd+ rQlGw2CXlG/yvg8WpXi3AM1eTwQzoXXMjE3EWOBR4Gavj1k5LoTQvExaOyT41ssgSnx5 ughA== X-Gm-Message-State: APjAAAXKhrGreHZ7g7Bz2pTn+U8V9ZxzAUX7rTmQtbsEz/6+fwqqGMeT Olr5ydu5Pos0Bw88Y+tSTyFJgw== X-Google-Smtp-Source: APXvYqzju73/tvHBw2/U82JK5MW/iB3G1PFvbjHOdUGeR147VJ25Eh+zehSSpRZRf58XiR7uwnty0Q== X-Received: by 2002:a62:f247:: with SMTP id y7mr16898009pfl.5.1575671289623; Fri, 06 Dec 2019 14:28:09 -0800 (PST) Received: from localhost ([2620:15c:202:201:2b10:8627:31e7:c5ec]) by smtp.gmail.com with ESMTPSA id 73sm16235715pgc.13.2019.12.06.14.28.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Dec 2019 14:28:08 -0800 (PST) From: Matthew Wang To: j@w1.fi Subject: [PATCH 4/5] wpa_supplicant: fix the constant roaming problem Date: Fri, 6 Dec 2019 14:27:47 -0800 Message-Id: <20191206222748.153534-4-matthewmwang@chromium.org> X-Mailer: git-send-email 2.24.0.393.g34dc348eaf-goog In-Reply-To: <20191206222748.153534-1-matthewmwang@chromium.org> References: <20191206222748.153534-1-matthewmwang@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191206_142810_708766_D52BDD61 X-CRM114-Status: GOOD ( 22.18 ) 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 [2607:f8b0:4864:20:0:0:0:529 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 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_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-Mailman-Approved-At: Sun, 15 Dec 2019 20:49:47 -0800 X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Emmanuel Grumbach , briannorris@chromium.org, hostap@lists.infradead.org, matthewmwang@chromium.org Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Emmanuel Grumbach We saw that on certain platforms in certain places we keep switching between two APs and eventually get the same RSSI. Debugging showed that we have a very big difference between the two antennas. Ant A can hear AP A very well (-60) but AP B very bad (-80) Ant B can hear AP B very well (-60) but AP A very bad (-80) When the device associates to AP A, it'll learn to use Ant A. If the device uses one single antenna to receive the scan results, it may hear the AP it is currently associated to on the second antenna and get bad results. Because of that, the wpa_supplicant will roam to the other AP and the same scenario will repeat itself: Association to AP A (Ant A reports -60). Scan on Ant A: AP A: -60, AP B: -80 Scan on Ant B: AP A: -80, AP A: -60 ==> ROAM. Association to AP B (Ant B reports -60) Scan on Ant A: AP A: -60, AP B: -80 ==> ROAM Etc... Fix this by querying the signal of the current AP using drv_signal_poll() instead of relying on the signal that we get from the scan results. Signed-off-by: Emmanuel Grumbach --- wpa_supplicant/events.c | 89 +++++++++++++++++++++++++------ wpa_supplicant/scan.c | 55 +++++++++---------- wpa_supplicant/scan.h | 4 ++ wpa_supplicant/wpa_supplicant_i.h | 9 ++++ 4 files changed, 115 insertions(+), 42 deletions(-) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 32e62c5d1..cf0aa2b57 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1665,6 +1665,33 @@ static void wpa_supplicant_rsn_preauth_scan_results( } +static int wpas_get_snr_signal_info(const struct wpa_signal_info *si) +{ + int noise = IS_5GHZ(si->frequency) ? + DEFAULT_NOISE_FLOOR_5GHZ : + DEFAULT_NOISE_FLOOR_2GHZ; + + /* + * Since we take the average beacon signal, we can't use + * the current noise measurement (average vs. snapshot), + * so use the default values instead. + */ + return si->avg_beacon_signal - noise; +} + + +static unsigned int +wpas_get_est_throughput_from_bss_snr(const struct wpa_supplicant *wpa_s, + const struct wpa_bss *bss, int snr) +{ + int rate = wpa_bss_get_max_rate(bss); + const u8 *ies = (void *)(bss + 1); + size_t ie_len = bss->ie_len ?: bss->beacon_ie_len; + + return wpas_get_est_tpt(wpa_s, ies, ie_len, rate, snr); +} + + static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, struct wpa_bss *selected, struct wpa_ssid *ssid) @@ -1673,7 +1700,9 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, #ifndef CONFIG_NO_ROAMING int min_diff, diff; int to_5ghz; - int cur_est, sel_est; + int cur_level; + unsigned int cur_est, sel_est; + struct wpa_signal_info si; #endif /* CONFIG_NO_ROAMING */ if (wpa_s->reassociate) @@ -1724,40 +1753,70 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, return 1; } - if (selected->est_throughput > current_bss->est_throughput + 5000) { + cur_level = current_bss->level; + cur_est = current_bss->est_throughput; + + /* + * Try to poll the signal from the driver since this will allow to get + * more accurate values. In some cases, there can be big differences + * between the RSSI of the probe response of the AP we are associated + * to and the beacons we hear from the same AP after association. This + * can happen when there are two antennas that hear the AP very + * differently. If the driver chooses to hear the probe responses + * during the scan on the "bad" antenna because it wants to save power, + * but knows to choose the other antenna after association, we will + * hear our AP with a low RSSI as part of the scan, even we can hear + * it decently on the other antenna. + * To cope with this, ask the driver to teach us how it hears the AP. + * Also, the scan results may be a bit old, since we can very quickly + * get fresh information about our own AP, do that. + */ + if (!wpa_drv_signal_poll(wpa_s, &si)) { + if (si.avg_beacon_signal) { + int snr = wpas_get_snr_signal_info(&si); + + cur_level = si.avg_beacon_signal; + cur_est = wpas_get_est_throughput_from_bss_snr(wpa_s, + current_bss, + snr); + wpa_dbg(wpa_s, MSG_INFO, + "Using poll to get accurate level and est throughput: level=%d snr=%d est_throughput=%u", + cur_level, snr, cur_est); + } + } + + if (selected->est_throughput > cur_est + 5000) { wpa_dbg(wpa_s, MSG_INFO, - "Allow reassociation - selected BSS has better " - "estimated throughput (current: %u, selected: %u)", - current_bss->est_throughput, selected->est_throughput); + "Allow reassociation - selected BSS has better estimated throughput (current: %u, selected: %u)", + cur_est, selected->est_throughput); + return 1; } to_5ghz = selected->freq > 4000 && current_bss->freq < 4000; - if (current_bss->level < 0 && - current_bss->level > selected->level + to_5ghz * 2) { + if (cur_level < 0 && cur_level > selected->level + to_5ghz * 2) { wpa_dbg(wpa_s, MSG_INFO, "Skip roam - Current BSS has better " "signal level"); return 0; } - if (current_bss->est_throughput > selected->est_throughput + 5000) { + if (cur_est > selected->est_throughput + 5000) { wpa_dbg(wpa_s, MSG_INFO, "Skip roam - Current BSS has better estimated throughput"); return 0; } - cur_est = current_bss->est_throughput; sel_est = selected->est_throughput; min_diff = 2; - if (current_bss->level < 0) { - if (current_bss->level < -85) + if (cur_level < 0) { + if (cur_level < -85) min_diff = 1; - else if (current_bss->level < -80) + else if (cur_level < -80) min_diff = 2; - else if (current_bss->level < -75) + else if (cur_level < -75) min_diff = 3; - else if (current_bss->level < -70) + else if (cur_level < -70) min_diff = 4; else min_diff = 5; @@ -1786,7 +1845,7 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, else min_diff = 0; } - diff = abs(current_bss->level - selected->level); + diff = abs(cur_level - selected->level); if (diff < min_diff) { wpa_dbg(wpa_s, MSG_INFO, "Skip roam - too small difference in signal level (%d < %d)", diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index 4d158a9c6..e0e4c348b 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -2178,14 +2178,6 @@ void filter_scan_res(struct wpa_supplicant *wpa_s, } -/* - * Noise floor values to use when we have signal strength - * measurements, but no noise floor measurements. These values were - * measured in an office environment with many APs. - */ -#define DEFAULT_NOISE_FLOOR_2GHZ (-89) -#define DEFAULT_NOISE_FLOOR_5GHZ (-92) - void scan_snr(struct wpa_scan_res *res) { if (res->flags & WPA_SCAN_NOISE_INVALID) { @@ -2269,21 +2261,13 @@ static unsigned int max_vht80_rate(int snr) return 390000; /* VHT80 MCS9 */ } - -void scan_est_throughput(struct wpa_supplicant *wpa_s, - struct wpa_scan_res *res) +unsigned int wpas_get_est_tpt(const struct wpa_supplicant *wpa_s, + const u8 *ies, size_t ies_len, int rate, + int snr) { enum local_hw_capab capab = wpa_s->hw_capab; - int rate; /* max legacy rate in 500 kb/s units */ - const u8 *ie; unsigned int est, tmp; - int snr = res->snr; - - if (res->est_throughput) - return; - - /* Get maximum legacy rate */ - rate = wpa_scan_get_max_rate(res); + const u8 *ie; /* Limit based on estimated SNR */ if (rate > 1 * 2 && snr < 1) @@ -2309,7 +2293,7 @@ void scan_est_throughput(struct wpa_supplicant *wpa_s, est = rate * 500; if (capab == CAPAB_HT || capab == CAPAB_HT40 || capab == CAPAB_VHT) { - ie = wpa_scan_get_ie(res, WLAN_EID_HT_CAP); + ie = get_ie(ies, ies_len, WLAN_EID_HT_CAP); if (ie) { tmp = max_ht20_rate(snr); if (tmp > est) @@ -2318,7 +2302,7 @@ void scan_est_throughput(struct wpa_supplicant *wpa_s, } if (capab == CAPAB_HT40 || capab == CAPAB_VHT) { - ie = wpa_scan_get_ie(res, WLAN_EID_HT_OPERATION); + ie = get_ie(ies, ies_len, WLAN_EID_HT_OPERATION); if (ie && ie[1] >= 2 && (ie[3] & HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK)) { tmp = max_ht40_rate(snr); @@ -2329,13 +2313,13 @@ void scan_est_throughput(struct wpa_supplicant *wpa_s, if (capab == CAPAB_VHT) { /* Use +1 to assume VHT is always faster than HT */ - ie = wpa_scan_get_ie(res, WLAN_EID_VHT_CAP); + ie = get_ie(ies, ies_len, WLAN_EID_VHT_CAP); if (ie) { tmp = max_ht20_rate(snr) + 1; if (tmp > est) est = tmp; - ie = wpa_scan_get_ie(res, WLAN_EID_HT_OPERATION); + ie = get_ie(ies, ies_len, WLAN_EID_HT_OPERATION); if (ie && ie[1] >= 2 && (ie[3] & HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK)) { @@ -2344,7 +2328,7 @@ void scan_est_throughput(struct wpa_supplicant *wpa_s, est = tmp; } - ie = wpa_scan_get_ie(res, WLAN_EID_VHT_OPERATION); + ie = get_ie(ies, ies_len, WLAN_EID_VHT_OPERATION); if (ie && ie[1] >= 1 && (ie[2] & VHT_OPMODE_CHANNEL_WIDTH_MASK)) { tmp = max_vht80_rate(snr) + 1; @@ -2354,9 +2338,26 @@ void scan_est_throughput(struct wpa_supplicant *wpa_s, } } - /* TODO: channel utilization and AP load (e.g., from AP Beacon) */ + return est; +} + +void scan_est_throughput(struct wpa_supplicant *wpa_s, + struct wpa_scan_res *res) +{ + int rate; /* max legacy rate in 500 kb/s units */ + int snr = res->snr; + const u8 *ies = (void *)(res + 1); - res->est_throughput = est; + if (res->est_throughput) + return; + + /* Get maximum legacy rate */ + rate = wpa_scan_get_max_rate(res); + + res->est_throughput = + wpas_get_est_tpt(wpa_s, ies, res->ie_len, rate, snr); + + /* TODO: channel utilization and AP load (e.g., from AP Beacon) */ } diff --git a/wpa_supplicant/scan.h b/wpa_supplicant/scan.h index 58caa7818..38e46d124 100644 --- a/wpa_supplicant/scan.h +++ b/wpa_supplicant/scan.h @@ -60,6 +60,10 @@ void filter_scan_res(struct wpa_supplicant *wpa_s, void scan_snr(struct wpa_scan_res *res); void scan_est_throughput(struct wpa_supplicant *wpa_s, struct wpa_scan_res *res); + +unsigned int wpas_get_est_tpt(const struct wpa_supplicant *wpa_s, + const u8 *ies, size_t ies_len, int rate, + int snr); void wpa_supplicant_set_default_scan_ies(struct wpa_supplicant *wpa_s); #endif /* SCAN_H */ diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 8c5defc3b..eefaf1b13 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1561,4 +1561,13 @@ int wpas_ctrl_iface_get_pref_freq_list_override(struct wpa_supplicant *wpa_s, int wpa_is_fils_supported(struct wpa_supplicant *wpa_s); int wpa_is_fils_sk_pfs_supported(struct wpa_supplicant *wpa_s); +/* + * Noise floor values to use when we have signal strength + * measurements, but no noise floor measurements. These values were + * measured in an office environment with many APs. + */ +#define DEFAULT_NOISE_FLOOR_2GHZ (-89) +#define DEFAULT_NOISE_FLOOR_5GHZ (-92) +#define IS_5GHZ(n) (n > 4000) + #endif /* WPA_SUPPLICANT_I_H */ From patchwork Fri Dec 6 22:27:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wang X-Patchwork-Id: 1210083 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="oXd7CgtR"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="SDvyaQM0"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47bpjr73t9z9sPK for ; Mon, 16 Dec 2019 15:50:22 +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: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=4TB7EGwgRqitqpZEv/WVzCtn+Y3TfRuKQDsIPZB6zPQ=; b=oXd7CgtRTXuAtg cISCgoxawgfSNPjKRCeCRHf0DKGSmQfU8G3owLlAZSqtvipCGZmLCzp17X9pe1UJdV2RcDxnB+p0a PxKbp9k0X3MmTwgKQX6uUNj3hMfEwX2/becRxQJm370pN+KNqwHCrkBEJ0BtfZ9jjwroa0nElj2LS Z/ntGUryxp+GaFcEs4tmcGZkxArtIiIjJcdc9eIJe5qYiXAWV7tA0O5B3MdrA+dMaNMOe3WwwYTc9 ZHkZL8L7mmoA+YHBeYon7QdyvLBg8+8IFEkN2fpFQe7e7M4+25smIWYs6Tp+mL84nL4Q7Aw+0lEco Az1Omy3WHl2VqQS9ls6g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1igiKj-0002hd-77; Mon, 16 Dec 2019 04:50:13 +0000 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1idM56-00074f-CZ for hostap@lists.infradead.org; Fri, 06 Dec 2019 22:28:13 +0000 Received: by mail-pj1-x1044.google.com with SMTP id w23so3344728pjd.2 for ; Fri, 06 Dec 2019 14:28:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yVgVgFZHc31yuWPZASm7GK5NGRIQEtNeai703MjsdYc=; b=SDvyaQM0e4EtSf+kI8y4D4Kxf60DyCdvUSkNbuOWYtHEsJPhzJhFDGx3Ogynfh0Iuj S2TXd7y+1APQA9ir11HdUfRTPvvsta+OygA+0Ln4XKabNbtKEQtklSdT1T3TMWvAwz3U CtQKvTsuQcgIJTmOhTB+It9UAnuMQeBc0xbbE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yVgVgFZHc31yuWPZASm7GK5NGRIQEtNeai703MjsdYc=; b=D3yqIvCVXOgc3lgqvstVfNk5e5MBDeBiFjYKzTicZAX2efpttRrFssD//4B5pWOR0Y zsp4Wg6IzG8OlnO/qRpqzWFtCv3X0OqFLONZBkJBOC5n6w0JkuyPfvvEsPB5g0tc1nIm bWonoK9aa7GSumqQe+bEBA70IYoI7P+pk2TEu+GknItRnaz2ppO/b7kkPJdfyOKw0MbJ mAVL5/gMjDj0hy9JbxJFoVGdO/jQi8sIEU4YwhBPWOvyn8WXKjzskT6tW4UQQg1F9fH8 VzYHCyQ/+bGVm01TGMiylkRFopiYbxVCcqR95jz+tdkbH3atzjJFxYrs90Bk73Q1y/yc PHNA== X-Gm-Message-State: APjAAAVx5MiqSO0VIVyIxFOqFb0vPYc8WYY8+Bs+oa+nA0bWmrdEljlx IF7vgDuVqYbZdi45UefoiLEoUKjnfF0= X-Google-Smtp-Source: APXvYqzuDnkj0YP0tX4A13fjjmyFZPUVlkkWx8tyn3ubIla7tig+89JjPmQJrf5VEDsBwHWxLuM0aA== X-Received: by 2002:a17:902:fe03:: with SMTP id g3mr17495061plj.1.1575671291557; Fri, 06 Dec 2019 14:28:11 -0800 (PST) Received: from localhost ([2620:15c:202:201:2b10:8627:31e7:c5ec]) by smtp.gmail.com with ESMTPSA id a26sm16651215pff.155.2019.12.06.14.28.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Dec 2019 14:28:11 -0800 (PST) From: Matthew Wang To: j@w1.fi Subject: [PATCH 5/5] wpa_supplicant: fall back to avg_signal Date: Fri, 6 Dec 2019 14:27:48 -0800 Message-Id: <20191206222748.153534-5-matthewmwang@chromium.org> X-Mailer: git-send-email 2.24.0.393.g34dc348eaf-goog In-Reply-To: <20191206222748.153534-1-matthewmwang@chromium.org> References: <20191206222748.153534-1-matthewmwang@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191206_142812_426129_842EAACB X-CRM114-Status: GOOD ( 14.00 ) 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 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -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_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-Mailman-Approved-At: Sun, 15 Dec 2019 20:49:53 -0800 X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: briannorris@chromium.org, hostap@lists.infradead.org, matthewmwang@chromium.org Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Some drivers (e.g. Marvell WiFi) don't report avg_beacon_signal, but it's still useful to poll for the signal again when a roaming decision needs to be made. Use si.avg_signal when si.avg_beacon_signal is not available. Signed-off-by: Matthew Wang --- wpa_supplicant/events.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index cf0aa2b57..c87011297 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1667,7 +1667,7 @@ static void wpa_supplicant_rsn_preauth_scan_results( static int wpas_get_snr_signal_info(const struct wpa_signal_info *si) { - int noise = IS_5GHZ(si->frequency) ? + int noise = IS_5GHZ(frequency) ? DEFAULT_NOISE_FLOOR_5GHZ : DEFAULT_NOISE_FLOOR_2GHZ; @@ -1676,7 +1676,7 @@ static int wpas_get_snr_signal_info(const struct wpa_signal_info *si) * the current noise measurement (average vs. snapshot), * so use the default values instead. */ - return si->avg_beacon_signal - noise; + return avg_signal - noise; } @@ -1772,10 +1772,10 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, * get fresh information about our own AP, do that. */ if (!wpa_drv_signal_poll(wpa_s, &si)) { - if (si.avg_beacon_signal) { - int snr = wpas_get_snr_signal_info(&si); + if (si.avg_beacon_signal || si.avg_signal) { + cur_level = si.avg_beacon_signal ? si.avg_beacon_signal : si.avg_signal; + int snr = wpas_get_snr_signal_info(si.frequency, cur_level); - cur_level = si.avg_beacon_signal; cur_est = wpas_get_est_throughput_from_bss_snr(wpa_s, current_bss, snr);