All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH v3 13/14] station: try multiple roam candidates
Date: Thu, 15 Sep 2022 15:07:40 -0700	[thread overview]
Message-ID: <20220915220741.1128728-13-prestwoj@gmail.com> (raw)
In-Reply-To: <20220915220741.1128728-1-prestwoj@gmail.com>

There were a few failure paths in station_transition_start which
may not always be fatal. Both FT variants could fail, e.g. if
neither FT-over-DS or FT-over-Air were able to authenticate. In
this case it would be wise to try another BSS.
---
 src/station.c | 95 +++++++++++++++++++++++++++++++--------------------
 1 file changed, 58 insertions(+), 37 deletions(-)

diff --git a/src/station.c b/src/station.c
index 76023520..25d169dc 100644
--- a/src/station.c
+++ b/src/station.c
@@ -2113,21 +2113,23 @@ static void station_fast_transition_cb(struct netdev *netdev,
 static void station_netdev_event(struct netdev *netdev, enum netdev_event event,
 					void *event_data, void *user_data);
 
-static void station_transition_reassociate(struct station *station,
+static int station_transition_reassociate(struct station *station,
 						struct scan_bss *bss,
 						struct handshake_state *new_hs)
 {
-	if (netdev_reassociate(station->netdev, bss, station->connected_bss,
+	int ret;
+
+	ret = netdev_reassociate(station->netdev, bss, station->connected_bss,
 				new_hs, station_netdev_event,
-				station_reassociate_cb, station) < 0) {
-		handshake_state_free(new_hs);
-		station_roam_failed(station);
-		return;
-	}
+				station_reassociate_cb, station);
+	if (ret < 0)
+		return ret;
 
 	station->connected_bss = bss;
 	station->preparing_roam = false;
 	station_enter_state(station, STATION_STATE_ROAMING);
+
+	return 0;
 }
 
 static bool bss_match_bssid(const void *a, const void *b)
@@ -2199,10 +2201,14 @@ static void station_preauthenticate_cb(struct netdev *netdev,
 		handshake_state_set_supplicant_ie(new_hs, rsne_buf);
 	}
 
-	station_transition_reassociate(station, bss, new_hs);
+	if (station_transition_reassociate(station, bss, new_hs) < 0) {
+		handshake_state_free(new_hs);
+		station_roam_failed(station);
+	}
 }
 
-static void station_transition_start(struct station *station)
+static bool station_try_next_transition(struct station *station,
+					struct scan_bss *bss)
 {
 	struct handshake_state *hs = netdev_get_handshake(station->netdev);
 	struct network *connected = station->connected_network;
@@ -2210,7 +2216,6 @@ static void station_transition_start(struct station *station)
 	struct handshake_state *new_hs;
 	struct ie_rsn_info cur_rsne, target_rsne;
 	int ret;
-	struct scan_bss *bss = l_queue_peek_head(station->roam_bss_list);
 
 	l_debug("%u, target %s", netdev_get_ifindex(station->netdev),
 			util_address_to_string(bss->addr));
@@ -2226,11 +2231,8 @@ static void station_transition_start(struct station *station)
 
 		/* Rebuild handshake RSN for target AP */
 		if (station_build_handshake_rsn(hs, station->wiphy,
-				station->connected_network, bss) < 0) {
-			l_error("rebuilding handshake rsne failed");
-			station_roam_failed(station);
-			return;
-		}
+				station->connected_network, bss) < 0)
+			return false;
 
 		/* Reset the vendor_ies in case they're different */
 		vendor_ies = network_info_get_extra_ies(info, bss, &iov_elems);
@@ -2243,29 +2245,23 @@ static void station_transition_start(struct station *station)
 			/* No action responses from this BSS, try over air */
 			if (ret == -ENOENT)
 				goto try_over_air;
-			else if (ret < 0) {
-				/*
-				 * If we are here FT-over-air will not work
-				 * either (identical checks) so try again later.
-				 */
-				station_roam_retry(station);
-				return;
-			}
+			else if (ret < 0)
+				return false;
+
+			station->connected_bss = bss;
+			station->preparing_roam = false;
+			station_enter_state(station, STATION_STATE_ROAMING);
+
+			return true;
 		} else {
 try_over_air:
 			if (netdev_fast_transition(station->netdev, bss,
 					station->connected_bss,
-					station_fast_transition_cb) < 0) {
-				station_roam_failed(station);
-				return;
-			}
-		}
-
-		station->connected_bss = bss;
-		station->preparing_roam = false;
-		station_enter_state(station, STATION_STATE_ROAMING);
+					station_fast_transition_cb) < 0)
+				return false;
 
-		return;
+			return true;
+		}
 	}
 
 	/* Non-FT transition */
@@ -2296,17 +2292,42 @@ try_over_air:
 		if (netdev_preauthenticate(station->netdev, bss,
 						station_preauthenticate_cb,
 						station) >= 0)
-			return;
+			return true;
 	}
 
 	new_hs = station_handshake_setup(station, connected, bss);
 	if (!new_hs) {
 		l_error("station_handshake_setup failed in reassociation");
-		station_roam_failed(station);
-		return;
+		return false;
+	}
+
+	if (station_transition_reassociate(station, bss, new_hs) < 0) {
+		handshake_state_free(new_hs);
+		return false;
+	}
+
+	return true;
+}
+
+static void station_transition_start(struct station *station)
+{
+	struct scan_bss *bss;
+	bool roaming = false;
+
+	/*
+	 * For each failed attempt pop the BSS leaving the head of the queue
+	 * with the current roam candidate.
+	 */
+	while ((bss = l_queue_peek_head(station->roam_bss_list))) {
+		roaming = station_try_next_transition(station, bss);
+		if (roaming)
+			break;
+
+		l_queue_pop_head(station->roam_bss_list);
 	}
 
-	station_transition_reassociate(station, bss, new_hs);
+	if (!roaming)
+		station_roam_failed(station);
 }
 
 static void station_roam_scan_triggered(int err, void *user_data)
-- 
2.34.3


  parent reply	other threads:[~2022-09-15 22:08 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-15 22:07 [PATCH v3 01/14] frame-xchg: add type to frame_xchg_prefix James Prestwood
2022-09-15 22:07 ` [PATCH v3 02/14] station: don't set OCVC for FT AKMs James Prestwood
2022-09-15 22:07 ` [PATCH v3 03/14] ft: remove OCI element from auth/assoc James Prestwood
2022-09-16 16:05   ` Denis Kenzior
2022-09-16 16:18     ` James Prestwood
2022-09-15 22:07 ` [PATCH v3 04/14] frame-xchg: create global group enum James Prestwood
2022-09-16 16:06   ` Denis Kenzior
2022-09-16 16:28     ` James Prestwood
2022-09-15 22:07 ` [PATCH v3 05/14] ft: netdev: prep for FT isolation into ft.c James Prestwood
2022-09-15 22:07 ` [PATCH v3 06/14] netdev: use new ft_sm for over-DS James Prestwood
2022-09-15 22:07 ` [PATCH v3 07/14] ft: implement offchannel authentication James Prestwood
2022-09-15 22:07 ` [PATCH v3 08/14] netdev: update FT-over-Air to use ft_authenticate() James Prestwood
2022-09-15 22:07 ` [PATCH v3 09/14] ft: remove unused code after refactor James Prestwood
2022-09-15 22:07 ` [PATCH v3 10/14] ft: add ft_sm_can_associate James Prestwood
2022-09-15 22:07 ` [PATCH v3 11/14] netdev: check for authentication for FT-over-DS James Prestwood
2022-09-15 22:07 ` [PATCH v3 12/14] station: create list of roam candidates James Prestwood
2022-09-15 22:07 ` James Prestwood [this message]
2022-09-15 22:07 ` [PATCH v3 14/14] netdev: add NETDEV_EVENT_FT_AUTHENTICATE, handle in station James Prestwood
2022-09-16 16:04 ` [PATCH v3 01/14] frame-xchg: add type to frame_xchg_prefix Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220915220741.1128728-13-prestwoj@gmail.com \
    --to=prestwoj@gmail.com \
    --cc=iwd@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.