diff mbox series

[1/5] tests: hwsim: add test reconnecting on assoc failure

Message ID 20190202221607.9965-1-johannes@sipsolutions.net
State Accepted
Headers show
Series [1/5] tests: hwsim: add test reconnecting on assoc failure | expand

Commit Message

Johannes Berg Feb. 2, 2019, 10:16 p.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

Add a test that drops the authentication frame, so that
hostapd thinks the station is unknown, and then sends one
by itself, so the station thinks it's associated. This
tests mostly the kernel's capability to recover from this
scenario.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 tests/hwsim/test_ap_open.py | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

Comments

Jouni Malinen Feb. 5, 2019, 10:38 p.m. UTC | #1
Thanks, applied 1-3, 5. For 4/5, I think I'll need to wait a bit longer
on enabling MACsec in the default config since the needed
linux/if_macsec.h header file is not available in many recent distro
releases that are still in use (e.g., Ubuntu 16.04) and same for the
libnl netlink/route/link/macsec.h (libnl 3.3).
diff mbox series

Patch

diff --git a/tests/hwsim/test_ap_open.py b/tests/hwsim/test_ap_open.py
index 3907925352ea..c60b325ccb8b 100644
--- a/tests/hwsim/test_ap_open.py
+++ b/tests/hwsim/test_ap_open.py
@@ -129,6 +129,36 @@  def test_ap_open_assoc_timeout(dev, apdev):
     hapd.set("ext_mgmt_frame_handling", "0")
     dev[0].wait_connected(timeout=15)
 
+def test_ap_open_auth_drop_sta(dev, apdev):
+    """AP dropping station after successful authentication"""
+    hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" })
+    dev[0].scan(freq="2412")
+    hapd.set("ext_mgmt_frame_handling", "1")
+    dev[0].connect("open", key_mgmt="NONE", scan_freq="2412",
+                   wait_connect=False)
+    for i in range(0, 10):
+        req = hapd.mgmt_rx()
+        if req is None:
+            raise Exception("MGMT RX wait timed out")
+        if req['subtype'] == 11:
+            break
+        req = None
+    if not req:
+        raise Exception("Authentication frame not received")
+
+    # turn off before sending successful response
+    hapd.set("ext_mgmt_frame_handling", "0")
+
+    resp = {}
+    resp['fc'] = req['fc']
+    resp['da'] = req['sa']
+    resp['sa'] = req['da']
+    resp['bssid'] = req['bssid']
+    resp['payload'] = struct.pack('<HHH', 0, 2, 0)
+    hapd.mgmt_tx(resp)
+
+    dev[0].wait_connected(timeout=15)
+
 @remote_compatible
 def test_ap_open_id_str(dev, apdev):
     """AP with open mode and id_str"""