Skip to contentSkip to conversation

client: special case daemon interface for non-interactive

PATCH In review James Prestwood 2 participants 5 messages Nov 2, 2021

lore
Share & tools
lore

James Prestwood

author
#0 lore raw

PATCH 1/4 client: special case daemon interface for non-interactive

In non-interactive mode, when a dbus method call returns the process exits. This is true for all methods except agent requests since e.g. Connect() call automatically requests credentials and the client must wait for that to return before exiting. The new daemon interface must also be treated in the same way and not exit.

---
 client/dbus-proxy.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
client/dbus-proxy.c +2 -1
index ab9fb5a5..0373a3df 100644
@@ -315,7 +315,8 @@ static void proxy_callback(struct l_dbus_message *message, void *user_data)
 	}
 
 	proxy = callback_data->user_data;
-	if (!strcmp(proxy->type->interface, IWD_AGENT_MANAGER_INTERFACE))
+	if (!strcmp(proxy->type->interface, IWD_AGENT_MANAGER_INTERFACE) ||
+			!strcmp(proxy->type->interface, IWD_DAEMON_INTERFACE))
 		return;
 
 quit:
Signature · 1 line
2.31.1
author
#1 lore raw

PATCH 2/4 auto-t: iwd.py: fix re-scanning bug on get_ordered_networks

Certain scenarios coupled with lost beacons could result in OrderedNetwork being initialized many times until the dbus library reached its maximum signal registrations. This could happen where there are two networks, IWD finds one in a scan but continues to scan for the other and the beacons are lost. The way get_ordered_networks was written it returns early if any networks are found. Since get_ordered_network (not plural) uses get_ordered_networks() in a loop this caused OrderedNetwork's to be created rapidly until python raises an exception.

To fix this, pass an optional list of networks being looked for to get_ordered_networks. Only if all the networks in the list are found will it return early, otherwise it will continue to scan.

---
 autotests/util/iwd.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
autotests/util/iwd.py +8 -5
index d6a7fe06..5e1e2721 100755
@@ -437,7 +437,7 @@ class Device(IWDDBusAbstract):
 
         self._wait_for_async_op()
 
-    def get_ordered_networks(self, scan_if_needed = True, full_scan = False):
+    def get_ordered_networks(self, scan_if_needed = True, full_scan = False, list = []):
         '''Return the list of networks found in the most recent
            scan, sorted by their user interface importance
            score as calculated by iwd.  If the device is
@@ -454,7 +454,10 @@ class Device(IWDDBusAbstract):
             ordered_network = OrderedNetwork(bus_obj, self._bus, self._namespace)
             ordered_networks.append(ordered_network)
 
-        if len(ordered_networks) > 0:
+        names = [x.name for x in ordered_networks]
+
+        # all() will always return true if 'list' is empty
+        if all(x in names for x in list) and len(names) > 0:
             return ordered_networks
         elif not scan_if_needed:
             return None
@@ -489,8 +492,8 @@ class Device(IWDDBusAbstract):
            network wasn't found. If the network is not found an exception is
            raised, this removes the need to extra asserts in autotests.
         '''
-        def wait_for_network(self, network, scan_if_needed):
-            networks = self.get_ordered_networks(scan_if_needed)
+        def wait_for_network(self, network, scan_if_needed, full_scan):
+            networks = self.get_ordered_networks(scan_if_needed, full_scan, list=[network])
 
             if not networks:
                 # No point in continuing if we aren't going to re-scan
@@ -505,7 +508,7 @@ class Device(IWDDBusAbstract):
 
             return False
 
-        return ctx.non_block_wait(wait_for_network, 30, self, network, scan_if_needed,
+        return ctx.non_block_wait(wait_for_network, 30, self, network, scan_if_needed, full_scan,
                                     exception=Exception("Network %s not found" % network))
 
     def wps_push_button(self):
Signature · 1 line
2.31.1
author
#2 lore raw

PATCH 3/4 auto-t: allow testAP to benefit from re-scanning

In reply to James Prestwood

If a beacon is lost testAP will fail since it did not utilize any rescanning logic. Now it can use this feature by passing full_scan. This is required since IWD APs are not known to test-runner like hostapd APs are.

---
 autotests/testAP/connection_test.py  | 5 +++--
 autotests/testAP/dhcp_config_test.py | 4 ++--
 autotests/testAP/dhcp_test.py        | 4 ++--
 autotests/testAP/failure_test.py     | 6 ++++--
 4 files changed, 11 insertions(+), 8 deletions(-)
autotests/testAP/connection_test.py +3 -2
index 1bba5f35..4c784014 100644
@@ -55,9 +55,10 @@ class Test(unittest.TestCase):
             condition = 'not obj.scanning'
             wd.wait_for_object_condition(dev2, condition)
 
-            ordered_networks = dev2.get_ordered_networks()
+            networks = {}
+            networks['TestAP1'] = dev2.get_ordered_network('TestAP1')
+            networks['TestAP2'] = dev2.get_ordered_network('TestAP2', full_scan=True)
 
-            networks = { n.name: n for n in ordered_networks }
             self.assertEqual(networks['TestAP1'].type, NetworkType.psk)
             self.assertEqual(networks['TestAP2'].type, NetworkType.psk)
 
autotests/testAP/dhcp_config_test.py +2 -2
index 975cab4d..afea5415 100644
@@ -37,9 +37,9 @@ class Test(unittest.TestCase):
             condition = 'not obj.scanning'
             wd.wait_for_object_condition(dev2, condition)
 
-            ordered_networks = dev2.get_ordered_networks()
+            networks = {}
+            networks['APConfig'] = dev2.get_ordered_network('APConfig', full_scan=True)
 
-            networks = { n.name: n for n in ordered_networks }
             self.assertEqual(networks['APConfig'].type, NetworkType.psk)
 
             psk_agent = PSKAgent('password123')
autotests/testAP/dhcp_test.py +2 -2
index e69c4465..0118b17d 100644
@@ -34,9 +34,9 @@ class Test(unittest.TestCase):
             condition = 'not obj.scanning'
             wd.wait_for_object_condition(dev2, condition)
 
-            ordered_networks = dev2.get_ordered_networks()
+            networks = {}
+            networks['TestAP2'] = dev2.get_ordered_network('TestAP2', full_scan=True)
 
-            networks = { n.name: n for n in ordered_networks }
             self.assertEqual(networks['TestAP2'].type, NetworkType.psk)
 
             psk_agent = PSKAgent('Password2')
autotests/testAP/failure_test.py +4 -2
index fc5cb6a7..05b5a7fb 100644
@@ -56,8 +56,10 @@ class Test(unittest.TestCase):
             condition = 'not obj.scanning'
             wd.wait_for_object_condition(dev2, condition)
 
-            ordered_networks = dev2.get_ordered_networks()
-            networks = { n.name: n for n in ordered_networks }
+            networks = {}
+            networks['TestAP1'] = dev2.get_ordered_network('TestAP1')
+            networks['TestAP2'] = dev2.get_ordered_network('TestAP2', full_scan=True)
+
             self.assertEqual(networks['TestAP1'].type, NetworkType.psk)
             self.assertEqual(networks['TestAP2'].type, NetworkType.psk)
 
Signature · 1 line
2.31.1
author
#3 lore raw

PATCH 4/4 test-runner: increase test timeout maximum

In reply to James Prestwood

The OWE transition tests takes quite a while and sometimes hits the maximum timeout.

---
 tools/test-runner | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/test-runner +1 -1
index d62f8b51..9ae33301 100755
@@ -45,7 +45,7 @@ TIOCSTTY = 0x540E
 config = None
 intf_id = 0
 
-TEST_MAX_TIMEOUT = 120
+TEST_MAX_TIMEOUT = 240
 
 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
 
Signature · 1 line
2.31.1
#4 lore raw
In reply to James Prestwood

Hi James,

Quoted 9 lines · James Prestwood

In non-interactive mode, when a dbus method call returns the process exits. This is true for all methods except agent requests since e.g. Connect() call automatically requests credentials and the client must wait for that to return before exiting. The new daemon interface must also be treated in the same way and not exit.

---
  client/dbus-proxy.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

All applied, thanks.

Regards,
-Denis