]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
nl80211: Report invalid signal and noise when info is unavailable
authorAvraham Stern <avraham.stern@intel.com>
Tue, 3 Nov 2020 07:54:16 +0000 (09:54 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 4 Dec 2020 10:42:15 +0000 (12:42 +0200)
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 <avraham.stern@intel.com>
Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Reviewed-by: Brian Norris <briannorris@chromium.org>
src/drivers/driver_nl80211_event.c
wpa_supplicant/bss.h

index f75f7b3aeffe9990e75949b1afe0ab03df77d858..a3e2eee93ce8855f150923a9c65b0c6697f08616 100644 (file)
@@ -1376,7 +1376,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 ||
@@ -1443,19 +1442,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);
+       res = nl80211_get_link_noise(drv, &ed.signal_change);
        if (res == 0) {
-               ed.signal_change.current_noise = sig.current_noise;
                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);
index 7cb1745dbbeed7a6d814cd5efc44d7d3ec55d8b2..919bbe113677042be8db22c13e5e5217841f0dc8 100644 (file)
@@ -177,7 +177,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 && new_level < 0)
                bss->level = new_level;
 }