mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-22 12:52:49 +01:00
auto-t: fix rekey/reauth logic in a few ways
The rekey/reauth logic was broken in a few different ways. For rekeys the event list was not being reset so any past 4-way handshake would allow the call to pass. This actually removes the need for the sleep in the extended key ID test because the actual handshake event is waited for correctly. For both rekeys and reauths, just waiting for the EAP/handshake events was not enough. Without checking if the client got disconnected we essentially allow a full disconnect and reconnect, meaning the rekey/reauth failed. Now a 'disallow' array can be passed to wait_for_event which will throw an exception if any events in that array are encountered while waiting for the target event.
This commit is contained in:
parent
53e8bf4cb0
commit
267feb94b0
@ -50,8 +50,6 @@ class Test(unittest.TestCase):
|
||||
testutil.test_iface_operstate()
|
||||
testutil.test_ifaces_connected()
|
||||
|
||||
wd.wait(0.5)
|
||||
|
||||
device.disconnect()
|
||||
|
||||
condition = 'not obj.connected'
|
||||
|
@ -102,23 +102,26 @@ class HostapdCLI(object):
|
||||
|
||||
return True
|
||||
|
||||
def _poll_event(self, event):
|
||||
def _poll_event(self, event, disallow):
|
||||
# Look through the list (most recent is first) until the even is found.
|
||||
# Once found consume this event and any older ones as to not
|
||||
# accidentally trigger a false positive later on.
|
||||
for idx, e in enumerate(self.events):
|
||||
for d in disallow:
|
||||
if d in e:
|
||||
raise Exception('Event %s found while waiting for %s' % (d, event))
|
||||
if event in e:
|
||||
self.events = self.events[:idx]
|
||||
return e
|
||||
|
||||
return False
|
||||
|
||||
def wait_for_event(self, event, timeout=10):
|
||||
def wait_for_event(self, event, timeout=10, disallow=[]):
|
||||
if event == 'AP-ENABLED':
|
||||
if self.enabled:
|
||||
return 'AP-ENABLED'
|
||||
|
||||
return ctx.non_block_wait(self._poll_event, timeout, event,
|
||||
return ctx.non_block_wait(self._poll_event, timeout, event, disallow,
|
||||
exception=TimeoutError("waiting for event"))
|
||||
|
||||
def _data_available(self):
|
||||
@ -166,8 +169,8 @@ class HostapdCLI(object):
|
||||
self.events = []
|
||||
cmd = 'EAPOL_REAUTH ' + client_address
|
||||
self.ctrl_sock.sendall(cmd.encode('utf-8'))
|
||||
self.wait_for_event('CTRL-EVENT-EAP-STARTED')
|
||||
self.wait_for_event('CTRL-EVENT-EAP-SUCCESS')
|
||||
self.wait_for_event('CTRL-EVENT-EAP-STARTED', disallow=['AP-STA-DISCONNECTED'])
|
||||
self.wait_for_event('CTRL-EVENT-EAP-SUCCESS', disallow=['AP-STA-DISCONNECTED'])
|
||||
|
||||
def reload(self):
|
||||
# Seemingly all three commands needed for the instance to notice
|
||||
@ -234,7 +237,8 @@ class HostapdCLI(object):
|
||||
if address:
|
||||
cmd = 'REKEY_PTK %s' % address
|
||||
self.ctrl_sock.sendall(cmd.encode('utf-8'))
|
||||
self.wait_for_event('EAPOL-4WAY-HS-COMPLETED')
|
||||
self.events = []
|
||||
self.wait_for_event('EAPOL-4WAY-HS-COMPLETED', disallow=['AP-STA-DISCONNECTED'])
|
||||
return
|
||||
|
||||
cmd = 'REKEY_GTK'
|
||||
|
Loading…
Reference in New Issue
Block a user