[PATCH 3/3] netdev: handle local CMD_ASSOCIATE failures (for FT)

James Prestwood <[email protected]> Fri, 15 Aug 2025 08:26:04 -0700
Newsgroups dev.linux.lists.iwd
Message-ID <[email protected]>
The issue surrounding this was described in detail in the previous
patch. The netdev piece simple and does two things:

1. Don't deauthenticate and fail the connection if the CMD_ASSOCIATE
   ACK comes back with a failure. A local rejection like this should
   not change the kernels internal state, so we can recover. In this
   case call the connect callback directly with a failure which
   station will handle.

2. Upon a successful CMD_ASSOCIATE ACK, signal
   NETDEV_EVENT_ASSOCIATING to let station know. This did require
   modifying the netdev_associate_event() to not duplicate event
   calls, specifically when FT is being used.
---
 src/netdev.c | 32 +++++++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/src/netdev.c b/src/netdev.c
index ca8bfea0..e45423be 100644
--- a/src/netdev.c
+++ b/src/netdev.c
@@ -2993,15 +2993,32 @@ static void netdev_cmd_ft_reassociate_cb(struct l_genl_msg *msg,
 						void *user_data)
 {
 	struct netdev *netdev = user_data;
+	int err = l_genl_msg_get_error(msg);
 
 	netdev->connect_cmd_id = 0;
 
-	if (l_genl_msg_get_error(msg) >= 0)
+	/*
+	 * If CMD_ASSOCIATE was accepted we're committed to association and
+	 * can no longer go back. Signal this to station so the state can
+	 * transition to ft-roaming.
+	 */
+	if (err >= 0) {
+		if (netdev->event_filter)
+			netdev->event_filter(netdev, NETDEV_EVENT_ASSOCIATING,
+						NULL, netdev->user_data);
 		return;
+	}
 
-	netdev_deauth_and_fail_connection(netdev,
-					NETDEV_RESULT_ASSOCIATION_FAILED,
-					MMPDU_STATUS_CODE_UNSPECIFIED);
+	l_debug("failed FT reassocaition (%d)", err);
+
+	/*
+	 * A failed ACK should not have changed the kernel's state. This means
+	 * we should still be connected to the current AP and can proceed to
+	 * trying more BSS's.
+	 */
+
+	netdev->connect_cb(netdev, NETDEV_RESULT_ASSOCIATION_FAILED, NULL,
+				netdev->user_data);
 }
 
 static bool kernel_will_retry_auth(uint16_t status_code,
@@ -3185,7 +3202,12 @@ static void netdev_associate_event(struct l_genl_msg *msg,
 	if (!netdev->connected || netdev->aborting)
 		return;
 
-	if (netdev->event_filter)
+	/*
+	 * For FT this event is sent in the CMD_ASSOCIATE ack to indicate
+	 * association was successfully started in the kernel, don't duplicate
+	 * and send here too.
+	 */
+	if (!netdev->in_ft && netdev->event_filter)
 		netdev->event_filter(netdev, NETDEV_EVENT_ASSOCIATING,
 					NULL, netdev->user_data);
 
-- 
2.34.1