Skip to contentSkip to conversation

netdev: always honor disconnect events if issued by AP

PATCH In review James Prestwood 2 participants 3 messages Nov 23, 2021

lore
Share & tools
lore

James Prestwood

author
#0 lore raw

PATCH v2 1/2 netdev: always honor disconnect events if issued by AP

The disconnect event handler was mistakenly bailing out if FT or reassociation was going on. This was done because a disconnect event is sent by the kernel when CMD_AUTH/CMD_ASSOC is used.

The problem is an AP could also disconnect IWD which should never be ignored.

To fix this always parse the disconnect event and, if issued by the AP, always notify watchers of the disconnect.

---
 src/netdev.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
src/netdev.c +9 -2
index 96e473a9..e35a8b82 100644
@@ -1165,8 +1165,7 @@ static void netdev_disconnect_event(struct l_genl_msg *msg,
 
 	l_debug("");
 
-	if (!netdev->connected || netdev->disconnect_cmd_id > 0 ||
-			netdev->in_ft || netdev->in_reassoc)
+	if (!netdev->connected || netdev->disconnect_cmd_id > 0)
 		return;
 
 	if (!l_genl_attr_init(&attr, msg)) {
@@ -1190,6 +1189,13 @@ static void netdev_disconnect_event(struct l_genl_msg *msg,
 		}
 	}
 
+	/*
+	 * Only ignore this event if issued by the kernel since this is
+	 * normal when using CMD_AUTH/ASSOC.
+	 */
+	if (!disconnect_by_ap && (netdev->in_ft || netdev->in_reassoc))
+		return;
+
 	l_info("Received Deauthentication event, reason: %hu, from_ap: %s",
 			reason_code, disconnect_by_ap ? "true" : "false");
 
@@ -3171,6 +3177,7 @@ static void netdev_associate_event(struct l_genl_msg *msg,
 
 	if (!netdev->ap) {
 		netdev->associated = true;
+		netdev->in_reassoc = false;
 		return;
 	}
 
Signature · 1 line
2.31.1
author
#1 lore raw

PATCH v2 2/2 auto-t: testPSK-roam deauthenticate IWD after roam

After roaming deauth IWD and check the connection state.

---
 autotests/testPSK-roam/connection_test.py | 4 ++++
 1 file changed, 4 insertions(+)
autotests/testPSK-roam/connection_test.py +4 -0
index 437e52fc..8d9b22ad 100644
@@ -100,6 +100,10 @@ class Test(unittest.TestCase):
         self.assertRaises(Exception, testutil.test_ifaces_connected,
                           (self.bss_hostapd[1].ifname, device.name, True, True))
 
+        self.bss_hostapd[0].deauthenticate(device.address)
+        condition = 'obj.state == DeviceState.disconnected'
+        wd.wait_for_object_condition(device, condition)
+
     def test_ft_psk(self):
         wd = IWD(True)
 
Signature · 1 line
2.31.1
#2 lore raw
In reply to James Prestwood

Hi James,

Quoted 4 lines · James Prestwood

The disconnect event handler was mistakenly bailing out if FT or reassociation was going on. This was done because a disconnect event is sent by the kernel when CMD_AUTH/CMD_ASSOC is used.

Quoted 9 lines

The problem is an AP could also disconnect IWD which should never be ignored.

To fix this always parse the disconnect event and, if issued by the AP, always notify watchers of the disconnect.

---
  src/netdev.c | 11 +++++++++--
  1 file changed, 9 insertions(+), 2 deletions(-)

Both applied, thanks.

Regards,
-Denis