Skip to contentSkip to conversation

scan: use signal strength if bss ranks are equal

PATCH In review James Prestwood 2 participants 3 messages Nov 8, 2021

lore
Share & tools
lore

James Prestwood

author
#0 lore raw

PATCH 1/2 scan: use signal strength if bss ranks are equal

If two BSS's end up with the same rank sort them based on signal strength so IWD still prefers the higher strength BSS.

---
 src/scan.c | 4 ++++
 1 file changed, 4 insertions(+)
src/scan.c +4 -0
index da7d129f..38a15c11 100644
@@ -1628,6 +1628,10 @@ int scan_bss_rank_compare(const void *a, const void *b, void *user_data)
 {
 	const struct scan_bss *new_bss = a, *bss = b;
 
+	if (bss->rank == new_bss->rank)
+		return (bss->signal_strength >
+					new_bss->signal_strength) ? 1 : -1;
+
 	return (bss->rank > new_bss->rank) ? 1 : -1;
 }
 
Signature · 1 line
2.31.1
author
#1 lore raw

PATCH 2/2 auto-t: add OWE transition test with extra open network

A user reported a crash in situations where there was an OWE transition pair, with an extra open network using the same SSID but not advertising the OWE transition IE:

++++++++ backtrace ++++++++
0x7f199cadf320 in /lib64/libc.so.6
0x418c08 in network_has_open_pair() at /home/jprestwo/iwd/src/station.c:712 0x4262ce in scan_finished() at /home/jprestwo/iwd/src/scan.c:1718 0x4273cd in get_scan_done() at /home/jprestwo/iwd/src/scan.c:1733 0x47cf7a in destroy_request() at /home/jprestwo/iwd/ell/genl.c:674 0x479f1c in io_callback() at /home/jprestwo/iwd/ell/io.c:120
0x47922d in l_main_iterate() at /home/jprestwo/iwd/ell/main.c:472 (discriminator 2) 0x4792dc in l_main_run() at /home/jprestwo/iwd/ell/main.c:521 0x47950c in l_main_run_with_signal() at /home/jprestwo/iwd/ell/main.c:649 0x403e97 in main() at /home/jprestwo/iwd/src/main.c:532 0x7f199cac9b75 in /lib64/libc.so.6
+++++++++++++++++++++++++++

---
 .../testOWE-transition/connection_test.py     | 36 +++++++++++++++++++
 1 file changed, 36 insertions(+)
autotests/testOWE-transition/connection_test.py +36 -0
index 9555766e..aeaea70a 100644
@@ -8,6 +8,7 @@ import iwd
 from iwd import IWD
 from iwd import NetworkType
 from hostapd import HostapdCLI
+from hwsim import Hwsim
 import testutil
 
 class Test(unittest.TestCase):
@@ -220,6 +221,38 @@ class Test(unittest.TestCase):
 
         self.validate(self.wd, self.hapd_open)
 
+    # OWE Transition pair + additional open network with the same SSID
+    def test_owe_transition_extra_open(self):
+        self.hapd_open.set_value('vendor_elements', 'dd15506f9a1c02000000f1000a6f77652d68696464656e')
+        self.hapd_open.reload()
+        self.hapd_owe.set_value('vendor_elements', 'dd15506f9a1c02000000f0000a7472616e736974696f6e')
+        self.hapd_owe.reload()
+
+        self.hapd_open2.set_value('ssid', 'transition')
+        self.hapd_open2.reload()
+
+        self.hapd_owe2.disable()
+
+        # Set the open network signal strength very low so it gets put last on
+        # the network bss_list, forcing the additional open network to be
+        # checked first.
+        self.rule0 = self.hwsim.rules.create()
+        self.rule0.source = self.hwsim.get_radio('rad0').addresses[0]
+        self.rule0.signal = -4000
+        self.rule0.enabled = True
+
+        devices = self.wd.list_devices(1)
+        device = devices[0]
+
+        device.scan()
+        condition = 'obj.scanning'
+        self.wd.wait_for_object_condition(device, condition)
+        condition = 'not obj.scanning'
+        self.wd.wait_for_object_condition(device, condition)
+
+
+        self.validate(self.wd, self.hapd_owe)
+
     def setUp(self):
         self.wd = IWD(True)
         self.hapd_owe = HostapdCLI(config='ssidOWE.conf')
@@ -227,6 +260,8 @@ class Test(unittest.TestCase):
         self.hapd_owe2 = HostapdCLI(config='ssidOWE-2.conf')
         self.hapd_open2 = HostapdCLI(config='ssidOpen-2.conf')
 
+        self.hwsim = Hwsim()
+
     def tearDown(self):
         IWD.clear_storage()
 
@@ -235,6 +270,7 @@ class Test(unittest.TestCase):
         self.wd = None
         self.hapd_open = None
         self.hapd_owe = None
+        self.hwsim = None
 
     @classmethod
     def setUpClass(cls):
Signature · 1 line
2.31.1
#2 lore raw
In reply to James Prestwood

Hi James,

Quoted 5 lines · James Prestwood

If two BSS's end up with the same rank sort them based on signal strength so IWD still prefers the higher strength BSS.

---
  src/scan.c | 4 ++++
  1 file changed, 4 insertions(+)

Both applied, thanks.

Regards,
-Denis