Skip to contentSkip to conversation

station: add two new roaming states (FT/FW)

PATCH In review James Prestwood 3 participants 6 messages Sep 28, 2022 – Sep 29, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 station: add two new roaming states (FT/FW)

This adds two new station states to differentiate between reassociation (ROAMING), Fast transition (FT_ROAMING) or a firmare based roam (FW_ROAMING).

---
 src/station.c | 33 +++++++++++++++++++++++++--------
 src/station.h |  4 +++-
 src/wsc.c     |  2 ++
 3 files changed, 30 insertions(+), 9 deletions(-)
src/station.c +25 -8
index 372e23c1..6bd66ffc 100644
@@ -197,6 +197,13 @@ static bool station_is_autoconnecting(struct station *station)
 			station->state == STATION_STATE_AUTOCONNECT_QUICK;
 }
 
+static bool station_is_roaming(struct station *station)
+{
+	return station->state == STATION_STATE_ROAMING ||
+			station->state == STATION_STATE_FT_ROAMING ||
+			station->state == STATION_STATE_FW_ROAMING;
+}
+
 static bool station_debug_event(struct station *station, const char *name)
 {
 	struct l_dbus_message *signal;
@@ -1461,6 +1468,10 @@ static const char *station_state_to_string(enum station_state state)
 		return "disconnecting";
 	case STATION_STATE_ROAMING:
 		return "roaming";
+	case STATION_STATE_FT_ROAMING:
+		return "ft-roaming";
+	case STATION_STATE_FW_ROAMING:
+		return "fw-roaming";
 	}
 
 	return "invalid";
@@ -1599,6 +1610,8 @@ static void station_enter_state(struct station *station,
 	case STATION_STATE_DISCONNECTING:
 		break;
 	case STATION_STATE_ROAMING:
+	case STATION_STATE_FT_ROAMING:
+	case STATION_STATE_FW_ROAMING:
 		station_set_evict_nocarrier(station, false);
 		break;
 	}
@@ -1722,7 +1735,7 @@ static void station_reset_connection_state(struct station *station)
 	if (station->state == STATION_STATE_CONNECTED ||
 			station->state == STATION_STATE_CONNECTING ||
 			station->state == STATION_STATE_CONNECTING_AUTO ||
-			station->state == STATION_STATE_ROAMING)
+			station_is_roaming(station))
 		network_disconnected(network);
 }
 
@@ -2055,7 +2068,7 @@ static void station_roam_failed(struct station *station)
 	 * If we attempted a reassociation or a fast transition, and ended up
 	 * here then we are now disconnected.
 	 */
-	if (station->state == STATION_STATE_ROAMING) {
+	if (station_is_roaming(station)) {
 		station_disassociated(station);
 		return;
 	}
@@ -2245,7 +2258,7 @@ try_next:
 
 	station->connected_bss = bss;
 	station->preparing_roam = false;
-	station_enter_state(station, STATION_STATE_ROAMING);
+	station_enter_state(station, STATION_STATE_FT_ROAMING);
 
 	return true;
 
@@ -2288,7 +2301,7 @@ static bool station_fast_transition(struct station *station,
 
 		station->connected_bss = bss;
 		station->preparing_roam = false;
-		station_enter_state(station, STATION_STATE_ROAMING);
+		station_enter_state(station, STATION_STATE_FT_ROAMING);
 
 		return true;
 	} else {
@@ -2742,7 +2755,8 @@ static bool station_cannot_roam(struct station *station)
 		disabled = false;
 
 	return disabled || station->preparing_roam ||
-					station->state == STATION_STATE_ROAMING;
+				station->state == STATION_STATE_ROAMING ||
+				station->state == STATION_STATE_FT_ROAMING;
 }
 
 #define WNM_REQUEST_MODE_PREFERRED_CANDIDATE_LIST	(1 << 0)
@@ -3180,7 +3194,8 @@ static void station_disconnect_event(struct station *station, void *event_data)
 					event_data, station);
 		return;
 	case STATION_STATE_CONNECTED:
-	case STATION_STATE_ROAMING:
+	case STATION_STATE_FT_ROAMING:
+	case STATION_STATE_FW_ROAMING:
 		station_disassociated(station);
 		return;
 	default:
@@ -3234,7 +3249,7 @@ static void station_netdev_event(struct netdev *netdev, enum netdev_event event,
 			station_signal_agent_notify(station);
 		break;
 	case NETDEV_EVENT_ROAMING:
-		station_enter_state(station, STATION_STATE_ROAMING);
+		station_enter_state(station, STATION_STATE_FW_ROAMING);
 		break;
 	case NETDEV_EVENT_ROAMED:
 		station_event_roamed(station, (struct scan_bss *) event_data);
@@ -3246,7 +3261,7 @@ static void station_netdev_event(struct netdev *netdev, enum netdev_event event,
 		station_packets_lost(station, l_get_u32(event_data));
 		break;
 	case NETDEV_EVENT_FT_ROAMED:
-		if (station->state != STATION_STATE_ROAMING)
+		if (L_WARN_ON(station->state != STATION_STATE_FT_ROAMING))
 			return;
 
 		station_roamed(station);
@@ -4069,6 +4084,8 @@ static bool station_property_get_state(struct l_dbus *dbus,
 		statestr = "disconnecting";
 		break;
 	case STATION_STATE_ROAMING:
+	case STATION_STATE_FT_ROAMING:
+	case STATION_STATE_FW_ROAMING:
 		statestr = "roaming";
 		break;
 	}
src/station.h +3 -1
index 67d22f03..24fab321 100644
@@ -42,7 +42,9 @@ enum station_state {
 	STATION_STATE_CONNECTING_AUTO,
 	STATION_STATE_CONNECTED,
 	STATION_STATE_DISCONNECTING,
-	STATION_STATE_ROAMING
+	STATION_STATE_ROAMING,		/* Reassociation */
+	STATION_STATE_FT_ROAMING,	/* Fast transition */
+	STATION_STATE_FW_ROAMING,	/* Firmware roamed by itself */
 };
 
 enum station_event {
src/wsc.c +2 -0
index bb9f663b..cb2e2c3e 100644
@@ -665,6 +665,8 @@ static void wsc_check_can_connect(struct wsc_station_dbus *wsc,
 	case STATION_STATE_AUTOCONNECT_QUICK:
 	case STATION_STATE_AUTOCONNECT_FULL:
 	case STATION_STATE_ROAMING:
+	case STATION_STATE_FT_ROAMING:
+	case STATION_STATE_FW_ROAMING:
 		l_warn("%s: invalid station state", __func__);
 		break;
 	}
Signature · 1 line
2.34.3
#1 lore raw

PATCH 2/2 ft: optimize clearing authentications

Clearing all authentications during ft_authenticate was a very large hammer and may remove cached authentications that could be used if the current auth attempt fails.

For example the best BSS may have a problem and fail to authenticate early with FT-over-DS, then fail with FT-over-Air. But another BSS may have succeeded early with FT-over-DS. If ft_authenticate clears all ft_infos that successful authentication will be lost.

---
 src/ft.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
src/ft.c +12 -2
index cc13d2bf..c2607a1b 100644
@@ -1033,7 +1033,6 @@ int ft_authenticate(uint32_t ifindex, const struct scan_bss *target)
 						target->frequency,
 						200, ft_send_authenticate, info,
 						ft_authenticate_destroy);
-	ft_clear_authentications(ifindex);
 
 	l_queue_push_tail(info_list, info);
 
@@ -1055,9 +1054,20 @@ int ft_associate(uint32_t ifindex, const uint8_t *addr)
 	 *       a different BSS.
 	 */
 	info = ft_info_find(ifindex, addr);
-	if (!info || !info->parsed)
+	if (!info)
 		return -ENOENT;
 
+	/*
+	 * Either failed or no response. This may have been an FT-over-DS
+	 * attempt so clear out the entry so FT-over-Air can try again.
+	 */
+	if (!info->parsed) {
+		l_queue_remove(info_list, info);
+		ft_info_destroy(info);
+
+		return -ENOENT;
+	}
+
 	ft_prepare_handshake(info, hs);
 
 	ret = ft_tx_reassociate(ifindex, info->frequency, info->prev_bssid);
Signature · 1 line
2.34.3
#2 lore raw
In reply to James Prestwood

Hi James,

Quoted 28 lines · James Prestwood

This adds two new station states to differentiate between reassociation (ROAMING), Fast transition (FT_ROAMING) or a firmare based roam (FW_ROAMING).

---
 src/station.c | 33 +++++++++++++++++++++++++--------
 src/station.h |  4 +++-
 src/wsc.c     |  2 ++
 3 files changed, 30 insertions(+), 9 deletions(-)
src/station.c +7 -0
index 372e23c1..6bd66ffc 100644
@@ -197,6 +197,13 @@ static bool station_is_autoconnecting(struct station *station)
 			station->state == STATION_STATE_AUTOCONNECT_QUICK;
 }
 
+static bool station_is_roaming(struct station *station)
+{
+	return station->state == STATION_STATE_ROAMING ||
+			station->state == STATION_STATE_FT_ROAMING ||
+			station->state == STATION_STATE_FW_ROAMING;
+}
+
 static bool station_debug_event(struct station *station, const char *name)
 {
 	struct l_dbus_message *signal;

src/station.c static const char *station_state_to_string(enum station_state state) · line 1475

Quoted 8 lines
src/station.c +4 -0
@@ -1461,6 +1468,10 @@ static const char *station_state_to_string(enum station_state state)
 		return "disconnecting";
 	case STATION_STATE_ROAMING:
 		return "roaming";
+	case STATION_STATE_FT_ROAMING:
+		return "ft-roaming";
+	case STATION_STATE_FW_ROAMING:
+		return "fw-roaming";
 	}

I think you have to update the API doc in this case? doc/station-api.txt:

Properties string State [readonly]

Reflects the general network connection state. One of:

"connected", "disconnected", "connecting", "disconnecting", "roaming"

Is there a general policy regarding such extensions to the API? I am asking because our network management code tracks this state over DBus, and with this change our code will need some changes. I don't find it objectionable but it might mean I should keep a closer eye on the mailing list :-)

Kind regards,
Alvin

#3 lore raw

Hi Alvin,

Quoted 56 lines · Alvin Šipraga

Hi James,

Quoted 34 lines · James Prestwood

This adds two new station states to differentiate between reassociation (ROAMING), Fast transition (FT_ROAMING) or a firmare based roam (FW_ROAMING).
---
 src/station.c | 33 +++++++++++++++++++++++++-------- src/station.h |  4 +++-
 src/wsc.c     |  2 ++

 3 files changed, 30 insertions(+), 9 deletions(-)
src/station.c +0 -0
index 372e23c1..6bd66ffc 100644
@@ -197,6 +197,13 @@ static bool station_is_autoconnecting(struct
 station *station)

                        station->state ==
STATION_STATE_AUTOCONNECT_QUICK;
 }

src/station.c +4 -0
+static bool station_is_roaming(struct station *station)
+{
+       return station->state == STATION_STATE_ROAMING ||
+                       station->state == STATION_STATE_FT_ROAMING

||
+                       station->state == STATION_STATE_FW_ROAMING;

src/station.c +2 -0
+}
+

 static bool station_debug_event(struct station *station, const char *name)
 {
        struct l_dbus_message *signal;

src/station.c +0 -0
@@ -1461,6 +1468,10 @@ static const char
 *station_state_to_string(enum station_state state)
                 return "disconnecting";
Quoted 7 lines

        case STATION_STATE_ROAMING:
                return "roaming";
+       case STATION_STATE_FT_ROAMING:
+               return "ft-roaming";
+       case STATION_STATE_FW_ROAMING:
+               return "fw-roaming";
        }

I think you have to update the API doc in this case? doc/station- api.txt:

Properties      string State [readonly]

                        Reflects the general network connection state.  One of:

                        "connected", "disconnected", "connecting", "disconnecting", "roaming"

Quoted 6 lines

Is there a general policy regarding such extensions to the API? I am asking because our network management code tracks this state over DBus,
and with this change our code will need some changes. I don't find it objectionable but it might mean I should keep a closer eye on the mailing list :-)

This is only changing the internal to_string() function, not the DBus API (it has its own state_to_string function, mostly duplicated). This should only effect the debug prints for state changes and expose any weird driver behavior related to the ROAMING state rather than hide it.

Quoted 3 lines

Kind regards,
Alvin

#4 lore raw
Quoted 66 lines · James Prestwood

Hi Alvin,

Quoted 56 lines · Alvin Šipraga

Hi James,

Quoted 34 lines · James Prestwood

This adds two new station states to differentiate between reassociation (ROAMING), Fast transition (FT_ROAMING) or a firmare based roam (FW_ROAMING).
---
 src/station.c | 33 +++++++++++++++++++++++++-------- src/station.h |  4 +++-
 src/wsc.c     |  2 ++

 3 files changed, 30 insertions(+), 9 deletions(-)
src/station.c +0 -0
index 372e23c1..6bd66ffc 100644
@@ -197,6 +197,13 @@ static bool station_is_autoconnecting(struct
 station *station)

                        station->state ==
STATION_STATE_AUTOCONNECT_QUICK;
 }

src/station.c +4 -0
+static bool station_is_roaming(struct station *station)
+{
+       return station->state == STATION_STATE_ROAMING ||
+                       station->state == STATION_STATE_FT_ROAMING

||
+                       station->state == STATION_STATE_FW_ROAMING;

src/station.c +2 -0
+}
+

 static bool station_debug_event(struct station *station, const char *name)
 {
        struct l_dbus_message *signal;

src/station.c +0 -0
@@ -1461,6 +1468,10 @@ static const char
 *station_state_to_string(enum station_state state)
                 return "disconnecting";
Quoted 7 lines

        case STATION_STATE_ROAMING:
                return "roaming";
+       case STATION_STATE_FT_ROAMING:
+               return "ft-roaming";
+       case STATION_STATE_FW_ROAMING:
+               return "fw-roaming";
        }

I think you have to update the API doc in this case? doc/station- api.txt:

Properties      string State [readonly]

                        Reflects the general network connection state.  One of:

                        "connected", "disconnected", "connecting", "disconnecting", "roaming"

Quoted 6 lines

Is there a general policy regarding such extensions to the API? I am asking because our network management code tracks this state over DBus,
and with this change our code will need some changes. I don't find it objectionable but it might mean I should keep a closer eye on the mailing list :-)

Quoted 4 lines

This is only changing the internal to_string() function, not the DBus API (it has its own state_to_string function, mostly duplicated). This should only effect the debug prints for state changes and expose any weird driver behavior related to the ROAMING state rather than hide it.

Ah, OK! My bad. Thanks for the clarification :-)

Kind regards,
Alvin

#5 lore raw
In reply to James Prestwood

Hi James,

Quoted 9 lines · James Prestwood

This adds two new station states to differentiate between reassociation (ROAMING), Fast transition (FT_ROAMING) or a firmare based roam (FW_ROAMING).

---
  src/station.c | 33 +++++++++++++++++++++++++--------
  src/station.h |  4 +++-
  src/wsc.c     |  2 ++
  3 files changed, 30 insertions(+), 9 deletions(-)

Both applied, thanks.

Regards,
-Denis