From patchwork Sun Sep 13 12:59:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Otcheretianski, Andrei" X-Patchwork-Id: 1363088 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=2001:8b0:10b:1231::1; helo=merlin.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=intel.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=NYH0kbDk; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (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 4Bq8kD2RY6z9sSP for ; Sun, 13 Sep 2020 23:00:50 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.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=DpBFGAqH7OzNXwQwyZ8tXqSjQQku0ORfn0ODkdNahHQ=; b=NYH0kbDkEitkAnVnrww61YdLi CXrya2bou56owpkjE/mVuyTcXz6hXJybc3Z7PbITvbS+VKjN0B8YOTMKKfzqT8tx/L9agEuF0D8w8 ZG+wJVwa3SUdKNeEyu0+g/FGQ/Yrc0VFXlEU+KbfUCX4NMan/kYxOMkBPv1my2qZe0hT5fNesmEA6 5xMDHu9LrTyxlMtXYBwqloAXmX5LOzHyXkFe0xrzBCKPOHxY1g/qN0DvSPo42yc158vMlJfYhxqil E9IO5MgBl9zZPS++FJz1N7Fbe3gwH6xG87U5xpgwRDOlfsK3gN648XuUiw1vuMfXq4W9UZ7VxOqHR Jz9Rcrjmw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHRbo-0006S3-0C; Sun, 13 Sep 2020 12:59:56 +0000 Received: from mga05.intel.com ([192.55.52.43]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHRbl-0006Rh-5I for hostap@lists.infradead.org; Sun, 13 Sep 2020 12:59:54 +0000 IronPort-SDR: gb2u0OHnSMsg2JFaM2wjb0ebg7lJ9vkaLk0kGE5thh7TxcuAhR39te4YlGzax5PCU5hqbjLph3 2aYo0ovs0R0A== X-IronPort-AV: E=McAfee;i="6000,8403,9742"; a="243811700" X-IronPort-AV: E=Sophos;i="5.76,422,1592895600"; d="scan'208";a="243811700" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2020 05:59:49 -0700 IronPort-SDR: /42irR1gkPh1//JQ8/WEGG2j726BeueL9iMLJZkY8vsUSS4oB14FmIpoeEY/uF6lXP3zP/3NkV z3CIUryDbWJQ== X-IronPort-AV: E=Sophos;i="5.76,422,1592895600"; d="scan'208";a="481933839" Received: from ealfassi-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.251.188.222]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2020 05:59:47 -0700 From: Andrei Otcheretianski To: hostap@lists.infradead.org Subject: [PATCH v2] driver_nl80211: report invalid signal and noise when info is unavailable Date: Sun, 13 Sep 2020 15:59:34 +0300 Message-Id: <20200913125934.2808-1-andrei.otcheretianski@intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200913122406.20952-1-andrei.otcheretianski@intel.com> References: <20200913122406.20952-1-andrei.otcheretianski@intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200913_085953_341269_784B9C84 X-CRM114-Status: GOOD ( 19.25 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [192.55.52.43 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 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: Andrei Otcheretianski , Avraham Stern Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Avraham Stern When the driver sends a CQM RSSI threshold event, wpa_supplicant queries the driver for the signal and noise values. However, it is possible that by that time the station has already disconnected from the AP, so these values are no longer valid. In this case, indicate that these values are invalid by setting them to WPA_INVALID_NOISE. Previously a value of 0 would be reported, which may be confusing as this is a valid value. Since nl80211_get_link_signal() and nl80211_get_link_noise() already set invalid values for a case of failure, just use the value set by these functions even if they fail. Signed-off-by: Avraham Stern Signed-off-by: Andrei Otcheretianski --- src/drivers/driver_nl80211_event.c | 26 ++++++++++++++++---------- wpa_supplicant/bss.h | 2 +- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c index ce95e9cd39..31b2799535 100644 --- a/src/drivers/driver_nl80211_event.c +++ b/src/drivers/driver_nl80211_event.c @@ -1277,7 +1277,6 @@ static void nl80211_cqm_event(struct wpa_driver_nl80211_data *drv, struct nlattr *cqm[NL80211_ATTR_CQM_MAX + 1]; enum nl80211_cqm_rssi_threshold_event event; union wpa_event_data ed; - struct wpa_signal_info sig; int res; if (tb[NL80211_ATTR_CQM] == NULL || @@ -1344,20 +1343,27 @@ static void nl80211_cqm_event(struct wpa_driver_nl80211_data *drv, return; } - res = nl80211_get_link_signal(drv, &sig); + /* + * nl80211_get_link_signal() and nl80211_get_link_noise() set default + * values in case querying the driver fails. + */ + res = nl80211_get_link_signal(drv, &ed.signal_change); if (res == 0) { - ed.signal_change.current_signal = sig.current_signal; - ed.signal_change.current_txrate = sig.current_txrate; wpa_printf(MSG_DEBUG, "nl80211: Signal: %d dBm txrate: %d", - sig.current_signal, sig.current_txrate); + ed.signal_change.current_signal, + ed.signal_change.current_txrate); + } else { + wpa_printf(MSG_DEBUG, + "nl80211: querying the driver for signal info failed"); } - res = nl80211_get_link_noise(drv, &sig); - if (res == 0) { - ed.signal_change.current_noise = sig.current_noise; + res = nl80211_get_link_noise(drv, &ed.signal_change); + if (res == 0) wpa_printf(MSG_DEBUG, "nl80211: Noise: %d dBm", - sig.current_noise); - } + ed.signal_change.current_noise); + else + wpa_printf(MSG_DEBUG, + "nl80211: querying the driver for noise info failed"); wpa_supplicant_event(drv->ctx, EVENT_SIGNAL_CHANGE, &ed); } diff --git a/wpa_supplicant/bss.h b/wpa_supplicant/bss.h index 0716761749..750cdcbccc 100644 --- a/wpa_supplicant/bss.h +++ b/wpa_supplicant/bss.h @@ -169,7 +169,7 @@ static inline int bss_is_pbss(struct wpa_bss *bss) static inline void wpa_bss_update_level(struct wpa_bss *bss, int new_level) { - if (bss != NULL && new_level < 0) + if (bss != NULL && new_level > -WPA_INVALID_NOISE) bss->level = new_level; }