Skip to contentSkip to conversation

station: move scan cancelation to __station_connect_network

PATCH Superseded James Prestwood 1 participant 3 messages Feb 4, 2021

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 station: move scan cancelation to __station_connect_network

This handles connect-on-disconnect, as well as retrying other BSS's on failures rather than only explicit Connect() calls.

---
 src/station.c | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)
src/station.c +19 -19
index 8c1e97d6..06c4d75e 100644
@@ -2497,6 +2497,25 @@ int __station_connect_network(struct station *station, struct network *network,
 	struct handshake_state *hs;
 	int r;
 
+	/*
+	 * If a hidden scan is not completed, station_is_busy would not
+	 * indicate anything is going on so we need to cancel the scan and
+	 * fail the connection now.
+	 */
+	if (station->hidden_network_scan_id) {
+		scan_cancel(netdev_get_wdev_id(station->netdev),
+				station->hidden_network_scan_id);
+
+		dbus_pending_reply(&station->hidden_pending,
+				dbus_error_failed(station->hidden_pending));
+	}
+
+	if (station->quick_scan_id) {
+		scan_cancel(netdev_get_wdev_id(station->netdev),
+				station->quick_scan_id);
+		station->quick_scan_id = 0;
+	}
+
 	hs = station_handshake_setup(station, network, bss);
 	if (!hs)
 		return -ENOTSUP;
@@ -2576,25 +2595,6 @@ void station_connect_network(struct station *station, struct network *network,
 	struct l_dbus *dbus = dbus_get_bus();
 	int err;
 
-	/*
-	 * If a hidden scan is not completed, station_is_busy would not
-	 * indicate anything is going on so we need to cancel the scan and
-	 * fail the connection now.
-	 */
-	if (station->hidden_network_scan_id) {
-		scan_cancel(netdev_get_wdev_id(station->netdev),
-				station->hidden_network_scan_id);
-
-		dbus_pending_reply(&station->hidden_pending,
-				dbus_error_failed(station->hidden_pending));
-	}
-
-	if (station->quick_scan_id) {
-		scan_cancel(netdev_get_wdev_id(station->netdev),
-				station->quick_scan_id);
-		station->quick_scan_id = 0;
-	}
-
 	if (station_is_busy(station)) {
 		station_disconnect_onconnect(station, network, bss, message);
 
Signature · 1 line
2.26.2
#1 lore raw

PATCH 2/3 station: do not flush scan results

This causes issuse with CMD_AUTHENTICATE based protocols as flushing removes the BSS's from the kernel which CMD_AUTHENTICATE cannot handle as CMD_CONNECT does.

---
 src/station.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/station.c +1 -1
index 06c4d75e..1f59e270 100644
@@ -1095,7 +1095,7 @@ static uint32_t station_scan_trigger(struct station *station,
 	struct scan_parameters params;
 
 	memset(&params, 0, sizeof(params));
-	params.flush = true;
+	params.flush = false;
 	params.freqs = freqs;
 
 	if (wiphy_can_randomize_mac_addr(station->wiphy) ||
Signature · 1 line
2.26.2
#2 lore raw

PATCH 3/3 auto-t: fix wait_for_object_condition to work with any object

In reply to James Prestwood

After recent changes fixing wait_for_object_condition it was accidentally made to only work with classes, not other types of objects. Instead create a minimal class to hold _wait_timed_out so it doesnt rely on 'obj' holding the boolean.

---
 autotests/util/iwd.py | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
autotests/util/iwd.py +9 -6
index 4fa26517..6b153ea7 100755
@@ -1009,23 +1009,26 @@ class IWD(AsyncOpAbstract):
 
     @staticmethod
     def _wait_for_object_condition(obj, condition_str, max_wait = 50):
-        obj._wait_timed_out = False
+        class TimeoutData:
+            _wait_timed_out = False
 
-        def wait_timeout_cb():
-            obj._wait_timed_out = True
+        data = TimeoutData()
+
+        def wait_timeout_cb(data):
+            data._wait_timed_out = True
             return False
 
         try:
-            timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb)
+            timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb, data)
             context = ctx.mainloop.get_context()
             while not eval(condition_str):
                 context.iteration(may_block=True)
-                if obj._wait_timed_out and ctx.args.gdb == None:
+                if data._wait_timed_out and ctx.args.gdb == None:
                     raise TimeoutError('[' + condition_str + ']'\
                                        ' condition was not met in '\
                                        + str(max_wait) + ' sec')
         finally:
-            if not obj._wait_timed_out:
+            if not data._wait_timed_out:
                 GLib.source_remove(timeout)
 
     def wait_for_object_condition(self, *args, **kwargs):
Signature · 1 line
2.26.2