All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] auto-t: hwsim.py: convert addresses to 42:* format
@ 2021-08-23 18:32 James Prestwood
  2021-08-23 18:32 ` [PATCH 2/3] auto-t: testSAQuery remove ungraceful restart James Prestwood
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: James Prestwood @ 2021-08-23 18:32 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 1767 bytes --]

mac80211_hwsim has a funny quirk with multiple addresses in
radios. Some operations require address index zero, some index
one. And these addresses (possibly a result of how test-runner
initializes radios) sometimes get mixed up. For example scan
results may show a BSS address as 02:00:00:00:00:00, while the
next test run shows 42:00:00:00:00:00.

Ultimately, sending out frames requires the first nibble of the
address to be 0x4 so to handle both variants of addresses described
above hwsim.py was updated to always bitwise OR the first byte
with 0x40.
---
 autotests/util/hwsim.py | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/autotests/util/hwsim.py b/autotests/util/hwsim.py
index 52543062..db106dcb 100755
--- a/autotests/util/hwsim.py
+++ b/autotests/util/hwsim.py
@@ -335,14 +335,26 @@ class Hwsim(iwd.AsyncOpAbstract):
     def object_manager(self):
         return self._object_manager_if
 
+    @staticmethod
+    def _convert_address(address):
+        first = int(address[0:2], base=16)
+        first |= 0x40
+        first = format(first, 'x')
+
+        address = first + address[2:]
+
+        return address
+
     def spoof_disassociate(self, radio, freq, station):
         '''
             Send a spoofed disassociate frame to a station
         '''
+        dest = self._convert_address(radio.addresses[0].replace(':', ''))
+
         frame = 'a0 00 3a 01'
         frame += station.replace(':', '')
-        frame += radio.addresses[0].replace(':', '')
-        frame += radio.addresses[0].replace(':', '')
+        frame += dest
+        frame += dest
         frame += '30 01 07 00'
         self.spoof_frame(radio, freq, station, frame)
 
-- 
2.31.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] auto-t: testSAQuery remove ungraceful restart
  2021-08-23 18:32 [PATCH 1/3] auto-t: hwsim.py: convert addresses to 42:* format James Prestwood
@ 2021-08-23 18:32 ` James Prestwood
  2021-08-23 18:32 ` [PATCH 3/3] auto-t: hostapd.py: remove ungraceful_restart James Prestwood
  2021-08-25 13:52 ` [PATCH 1/3] auto-t: hwsim.py: convert addresses to 42:* format Denis Kenzior
  2 siblings, 0 replies; 4+ messages in thread
From: James Prestwood @ 2021-08-23 18:32 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 1017 bytes --]

Instead the same effect can be seen by just ifdown/ifup the interface.
---
 autotests/testSAQuery/connection_test.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/autotests/testSAQuery/connection_test.py b/autotests/testSAQuery/connection_test.py
index 3a66d118..03280d0e 100644
--- a/autotests/testSAQuery/connection_test.py
+++ b/autotests/testSAQuery/connection_test.py
@@ -38,7 +38,10 @@ class Test(unittest.TestCase):
         # Make AP go down ungracefully, when hostapd comes back up it should
         # send an unprotected disassociate frame so the client will re-auth.
         # This will kick off the SA Query procedure
-        hostapd.ungraceful_restart()
+        hostapd.interface.set_interface_state('down')
+        hostapd.interface.set_interface_state('up')
+
+        hostapd.wait_for_event('INTERFACE-ENABLED')
 
         condition = 'not obj.connected'
         wd.wait_for_object_condition(ordered_network.network_object, condition)
-- 
2.31.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] auto-t: hostapd.py: remove ungraceful_restart
  2021-08-23 18:32 [PATCH 1/3] auto-t: hwsim.py: convert addresses to 42:* format James Prestwood
  2021-08-23 18:32 ` [PATCH 2/3] auto-t: testSAQuery remove ungraceful restart James Prestwood
@ 2021-08-23 18:32 ` James Prestwood
  2021-08-25 13:52 ` [PATCH 1/3] auto-t: hwsim.py: convert addresses to 42:* format Denis Kenzior
  2 siblings, 0 replies; 4+ messages in thread
From: James Prestwood @ 2021-08-23 18:32 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 2476 bytes --]

This is no longer needed and greatly simplifies the class
---
 autotests/util/hostapd.py | 37 +++++--------------------------------
 1 file changed, 5 insertions(+), 32 deletions(-)

diff --git a/autotests/util/hostapd.py b/autotests/util/hostapd.py
index 8b81d467..2dcf38f9 100644
--- a/autotests/util/hostapd.py
+++ b/autotests/util/hostapd.py
@@ -43,10 +43,10 @@ class HostapdCLI(object):
 
         return cls._instances[config]
 
-    def _init_hostapd(self, config, reinit=False):
+    def __init__(self, config=None, *args, **kwargs):
         global ctrl_count
 
-        if self._initialized and not reinit:
+        if self._initialized:
             return
 
         self._initialized = True
@@ -83,9 +83,6 @@ class HostapdCLI(object):
 
         ctrl_count = ctrl_count + 1
 
-    def __init__(self, config=None, *args, **kwargs):
-        self._init_hostapd(config)
-
     def _poll_event(self, event):
         if not self._data_available(0.25):
             return False
@@ -117,20 +114,15 @@ class HostapdCLI(object):
 
         return self.ctrl_sock.recv(4096).decode('utf-8')
 
-    def _del_hostapd(self, force=False):
-        if not self.ctrl_sock:
-            return
-
-        self.ctrl_sock.close()
+    def __del__(self):
+        if self.ctrl_sock:
+            self.ctrl_sock.close()
 
         try:
             os.remove(self.local_ctrl)
         except:
             pass
 
-    def __del__(self):
-        self._del_hostapd()
-
         HostapdCLI._instances[self.config] = None
 
         # Check if this is the final instance
@@ -202,25 +194,6 @@ class HostapdCLI(object):
         if 'OK' not in proc.out:
             raise Exception('BSS_TM_REQ failed, is hostapd built with CONFIG_WNM_AP=y?')
 
-    def ungraceful_restart(self):
-        '''
-            Ungracefully kill and restart hostapd
-        '''
-        ctx.stop_process(ctx.hostapd.process, True)
-
-        self.interface.set_interface_state('down')
-        self.interface.set_interface_state('up')
-
-        self._del_hostapd(force=True)
-
-        ctx.start_hostapd()
-
-        # Give hostapd a second to start and initialize the control interface
-        time.sleep(1)
-
-        # New hostapd process, so re-init
-        self._init_hostapd(config=self.config, reinit=True)
-
     def req_beacon(self, addr, request):
         '''
             Send a RRM Beacon request
-- 
2.31.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/3] auto-t: hwsim.py: convert addresses to 42:* format
  2021-08-23 18:32 [PATCH 1/3] auto-t: hwsim.py: convert addresses to 42:* format James Prestwood
  2021-08-23 18:32 ` [PATCH 2/3] auto-t: testSAQuery remove ungraceful restart James Prestwood
  2021-08-23 18:32 ` [PATCH 3/3] auto-t: hostapd.py: remove ungraceful_restart James Prestwood
@ 2021-08-25 13:52 ` Denis Kenzior
  2 siblings, 0 replies; 4+ messages in thread
From: Denis Kenzior @ 2021-08-25 13:52 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 786 bytes --]

Hi James,

On 8/23/21 1:32 PM, James Prestwood wrote:
> mac80211_hwsim has a funny quirk with multiple addresses in
> radios. Some operations require address index zero, some index
> one. And these addresses (possibly a result of how test-runner
> initializes radios) sometimes get mixed up. For example scan
> results may show a BSS address as 02:00:00:00:00:00, while the
> next test run shows 42:00:00:00:00:00.
> 
> Ultimately, sending out frames requires the first nibble of the
> address to be 0x4 so to handle both variants of addresses described
> above hwsim.py was updated to always bitwise OR the first byte
> with 0x40.
> ---
>   autotests/util/hwsim.py | 16 ++++++++++++++--
>   1 file changed, 14 insertions(+), 2 deletions(-)
> 

All applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-08-25 13:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-23 18:32 [PATCH 1/3] auto-t: hwsim.py: convert addresses to 42:* format James Prestwood
2021-08-23 18:32 ` [PATCH 2/3] auto-t: testSAQuery remove ungraceful restart James Prestwood
2021-08-23 18:32 ` [PATCH 3/3] auto-t: hostapd.py: remove ungraceful_restart James Prestwood
2021-08-25 13:52 ` [PATCH 1/3] auto-t: hwsim.py: convert addresses to 42:* format Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.