[PATCH v2] wpa_supplicant: dBus: Flush Sate Property Change

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The "State" property in wpa_supplicant helps track important WiFi
connection events (like when the security key is being updated).
Currently, updates to this property aren't always sent right away. This
delay can make it difficult to accurately track the different stages of
the connection process. Some of the state property changes can be missed
if the property changes more than once within the
WPA_DBUS_SEND_PROP_CHANGED_TIMEOUT.

This change ensures that any updates to the "State" property are sent
immediately. This will provide a more accurate and real-time view of the
WiFi connection process.

The hwsim tests dbus_roam and dbus_remove_connected assume that the
currentBSS and state properties are always sent together which is not
accurate. The state property can be sent first without the currentBSS if
the WPA_DBUS_SEND_PROP_CHANGED_TIMEOUT is reached before currentBSS has
changed.

Updated the hwsim tests to wait for the two properties separately.

Change-Id: I92a1fa089a87cc45cf32a6c35189e6843e65f665
Signed-off-by: Arowa Suliman <arowa@xxxxxxxxxxxx>
---
 tests/hwsim/test_dbus.py       | 75 +++++++++++++++++++++++-----------
 wpa_supplicant/dbus/dbus_new.c |  1 +
 2 files changed, 52 insertions(+), 24 deletions(-)

diff --git a/tests/hwsim/test_dbus.py b/tests/hwsim/test_dbus.py
index 3ff911364..ba310ebed 100644
--- a/tests/hwsim/test_dbus.py
+++ b/tests/hwsim/test_dbus.py
@@ -1462,8 +1462,13 @@ def test_dbus_remove_connected(dev, apdev):
                     self.state = 7
                     iface.Reconnect()
                 elif self.state == 8:
+                    if 'CurrentBSS' in properties:
+                      self.state = 10
+                      self.loop.quit()
                     self.state = 9
-                    self.loop.quit()
+            if 'CurrentBSS' in properties and self.state == 9:
+                self.state = 10
+                self.loop.quit()
 
         def run_connect(self, *args):
             logger.debug("run_connect")
@@ -1476,11 +1481,16 @@ def test_dbus_remove_connected(dev, apdev):
             return False
 
         def success(self):
-            if not self.network_added or \
-               not self.network_removed or \
-               not self.network_selected:
-                return False
-            return self.state == 9
+          if not self.network_added:
+            logger.debug("network not added")
+            return False
+          if not self.network_selected:
+            logger.debug("network not Selected")
+            return False
+          if not self.network_removed:
+            logger.debug("network not Removed")
+            return False
+          return self.state == 10
 
     with TestDbusConnect(bus) as t:
         if not t.success():
@@ -6044,6 +6054,10 @@ def test_dbus_roam(dev, apdev):
         def __init__(self, bus):
             TestDbus.__init__(self, bus)
             self.state = 0
+            self.state_complete = False
+            self.current_bss = False
+            self.roam_complete = False
+            self.dst = ""
 
         def __enter__(self):
             gobject.timeout_add(1, self.run_connect)
@@ -6055,25 +6069,38 @@ def test_dbus_roam(dev, apdev):
 
         def propertiesChanged(self, properties):
             logger.debug("propertiesChanged: %s" % str(properties))
-            if 'State' in properties and properties['State'] == "completed":
-                if self.state == 0:
+            if self.state == 0 :
+                # Wait for connected and current BSS change.
+                if self.state_complete and self.current_bss:
+                    # Trigger roam event.
+                    iface.Roam(self.dst)
                     self.state = 1
-                    cur = properties["CurrentBSS"]
-                    bss_obj = bus.get_object(WPAS_DBUS_SERVICE, cur)
-                    res = bss_obj.Get(WPAS_DBUS_BSS, 'BSSID',
-                                      dbus_interface=dbus.PROPERTIES_IFACE)
-                    bssid_str = ''
-                    for item in res:
-                        if len(bssid_str) > 0:
-                            bssid_str += ':'
-                        bssid_str += '%02x' % item
-                    dst = bssid if bssid_str == bssid2 else bssid2
-                    iface.Roam(dst)
-                elif self.state == 1:
-                    if "RoamComplete" in properties and \
-                       properties["RoamComplete"]:
-                        self.state = 2
-                        self.loop.quit()
+                    self.state_complete = False
+                else:
+                    if 'State' in properties and properties['State'] == "completed":
+                        self.state_complete = True
+                    if 'CurrentBSS' in properties:
+                        cur = properties["CurrentBSS"]
+                        bss_obj = bus.get_object(WPAS_DBUS_SERVICE, cur)
+                        res = bss_obj.Get(WPAS_DBUS_BSS, 'BSSID',
+                                            dbus_interface=dbus.PROPERTIES_IFACE)
+                        bssid_str = ''
+                        for item in res:
+                            if len(bssid_str) > 0:
+                                bssid_str += ':'
+                            bssid_str += '%02x' % item
+                        self.dst = bssid if bssid_str == bssid2 else bssid2
+                        self.current_bss = True
+            elif self.state == 1:
+                # Wait for roam event.
+                if self.state_complete and self.roam_complete:
+                    self.state = 2
+                    self.loop.quit()
+                else:
+                    if 'State' in properties and properties['State'] == "completed":
+                        self.state_complete = True
+                    if 'RoamComplete' in properties and properties['RoamComplete']:
+                        self.roam_complete = True
 
         def run_connect(self, *args):
             logger.debug("run_connect")
diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index 00b38edf5..8db3407e9 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -2327,6 +2327,7 @@ void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
 		break;
 	case WPAS_DBUS_PROP_STATE:
 		prop = "State";
+                flush = TRUE;
 		break;
 	case WPAS_DBUS_PROP_CURRENT_BSS:
 		prop = "CurrentBSS";
-- 
2.44.0.278.ge034bb2e1d-goog


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux