]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Use local variables for current BSS signal strength in roaming
authorEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Fri, 6 Dec 2019 22:27:47 +0000 (14:27 -0800)
committerJouni Malinen <j@w1.fi>
Mon, 30 Dec 2019 21:57:47 +0000 (23:57 +0200)
This is a step towards allowing these values to be determined based on
signal poll instead of scan results.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
wpa_supplicant/events.c

index 2bf35cb5898a16625b1f3f363ea05d85fd40f742..075bf6fcfb5223c69832ab078b3dc4129e2944dc 100644 (file)
@@ -1680,7 +1680,8 @@ 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;
 #endif /* CONFIG_NO_ROAMING */
 
        if (wpa_s->reassociate)
@@ -1731,7 +1732,10 @@ 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;
+
+       if (selected->est_throughput > cur_est + 5000) {
                wpa_dbg(wpa_s, MSG_DEBUG,
                        "Allow reassociation - selected BSS has better estimated throughput");
                return 1;
@@ -1739,30 +1743,28 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s,
 
        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_DEBUG, "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_DEBUG,
                        "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;
@@ -1791,7 +1793,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_DEBUG,
                        "Skip roam - too small difference in signal level (%d < %d)",