@@ -201,3 +201,30 @@ def test_ap_open_out_of_memory(dev, apdev):
# verify that a new interface can still be added when memory allocation does
# not fail
hostapd.add_ap(apdev[1]['ifname'], { "ssid": "open" })
+
+def test_ap_open_disconnect_in_ps(dev, apdev):
+ """disconnect with the client in PS to regression-test a kernel bug"""
+ hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" })
+ dev[0].connect("open", key_mgmt="NONE", scan_freq="2412",
+ bg_scan_period="0")
+ ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5)
+ if ev is None:
+ raise Exception("No connection event received from hostapd")
+
+ def set_ps(val):
+ psf = open('/sys/kernel/debug/ieee80211/phy0/hwsim/ps', 'w')
+ psf.write('%d\n' % val)
+ psf.close()
+
+ # set to manual PS-Poll
+ set_ps(3)
+ try:
+ # inject some traffic
+ sa = hapd.own_addr()
+ da = dev[0].own_addr()
+ hapd.request('DATA_TEST_TX {} {} 0'.format(da, sa))
+
+ # disconnect - with traffic pending - shouldn't cause kernel warnings
+ dev[0].request("DISCONNECT")
+ finally:
+ set_ps(0)