Skip to contentSkip to conversation

station: add additional internal state, STATION_STATE_NETCONFIG

PATCH In review James Prestwood 2 participants 4 messages Jan 5, 2024 – Jan 9, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 station: add additional internal state, STATION_STATE_NETCONFIG

This is still treated as "connecting" from a DBus perspective but will allow for better handling internally for some roaming corner cases.

---
 src/dpp.c     | 1 +
 src/station.c | 5 +++++
 src/station.h | 1 +
 src/wsc.c     | 1 +
 4 files changed, 8 insertions(+)
src/dpp.c +1 -0
index af6574fb..74b4c2bc 100644
@@ -3761,6 +3761,7 @@ static void dpp_station_state_watch(enum station_state state, void *user_data)
 	case STATION_STATE_CONNECTING:
 	case STATION_STATE_CONNECTED:
 	case STATION_STATE_CONNECTING_AUTO:
+	case STATION_STATE_NETCONFIG:
 		if (L_WARN_ON(dpp->role == DPP_CAPABILITY_CONFIGURATOR))
 			dpp_reset(dpp);
 
src/station.c +5 -0
index ac53bf2a..68cac945 100644
@@ -1497,6 +1497,8 @@ static const char *station_state_to_string(enum station_state state)
 		return "ft-roaming";
 	case STATION_STATE_FW_ROAMING:
 		return "fw-roaming";
+	case STATION_STATE_NETCONFIG:
+		return "connecting (netconfig)";
 	}
 
 	return "invalid";
@@ -1635,6 +1637,7 @@ static void station_enter_state(struct station *station,
 		station_set_drop_unicast_l2_multicast(station, false);
 		break;
 	case STATION_STATE_DISCONNECTING:
+	case STATION_STATE_NETCONFIG:
 		break;
 	case STATION_STATE_ROAMING:
 	case STATION_STATE_FT_ROAMING:
@@ -3342,6 +3345,7 @@ static void station_disconnect_event(struct station *station, void *event_data)
 	case STATION_STATE_CONNECTED:
 	case STATION_STATE_FT_ROAMING:
 	case STATION_STATE_FW_ROAMING:
+	case STATION_STATE_NETCONFIG:
 		station_disassociated(station);
 		return;
 	default:
@@ -4272,6 +4276,7 @@ static bool station_property_get_state(struct l_dbus *dbus,
 		break;
 	case STATION_STATE_CONNECTING:
 	case STATION_STATE_CONNECTING_AUTO:
+	case STATION_STATE_NETCONFIG:
 		statestr = "connecting";
 		break;
 	case STATION_STATE_CONNECTED:
src/station.h +1 -0
index 0d502a08..a38327e4 100644
@@ -45,6 +45,7 @@ enum station_state {
 	STATION_STATE_ROAMING,		/* Reassociation */
 	STATION_STATE_FT_ROAMING,	/* Fast transition */
 	STATION_STATE_FW_ROAMING,	/* Firmware roamed by itself */
+	STATION_STATE_NETCONFIG,
 };
 
 enum station_event {
src/wsc.c +1 -0
index cda877cf..f88f5deb 100644
@@ -654,6 +654,7 @@ static void wsc_check_can_connect(struct wsc_station_dbus *wsc,
 	case STATION_STATE_CONNECTING:
 	case STATION_STATE_CONNECTING_AUTO:
 	case STATION_STATE_CONNECTED:
+	case STATION_STATE_NETCONFIG:
 		if (station_disconnect(wsc->station) < 0)
 			goto error;
 
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 2/3 station: add handling for new NETCONFIG state

There was an unhandled corner case if netconfig was running and multiple roam conditions happened in sequence, all before netconfig had completed. A single roam before netconfig was already handled (23f0f5717c) but this did not take into account any additional roam conditions.

If IWD is in this state, having started netconfig, then roamed, and again restarted netconfig it is still in a roaming state which will prevent any further roams. IWD will remain "stuck" on the current BSS until netconfig completes or gets disconnected.

In addition the general state logic is wrong here. If IWD roams prior to netconfig it should stay in a connecting state (from the perspective of DBus).

To fix this a new internal station state was added (no changes to the DBus API) to distinguish between a purely WiFi connecting state (STATION_STATE_CONNECTING/AUTO) and netconfig (STATION_STATE_NETCONFIG). This allows IWD roam as needed if netconfig is still running. Also, some special handling was added so the station state property remains in a "connected" state until netconfig actually completes, regardless of roams.

For some background this scenario happens if the DHCP server goes down for an extended period, e.g. if its being upgraded/serviced.

---
 src/station.c | 36 +++++++++++++++++++++++++++---------
 1 file changed, 27 insertions(+), 9 deletions(-)

v2:
* Stay in a "connecting" state if roaming before netconfig from a DBus property perspective.
* Minor changes using L_IN_SET

There are still improvements needed in this area, but this at least fixes the major issues related to the state change and allowing multiple roams. Still TODO:

* Add a netconfig timeout (in ELL)
* Put netconfig behind a wiphy work item. This requires some thought since we'd still need to allow roam scans, but just not any other scans/offchannel.

src/station.c +27 -9
index 68cac945..a6442d3e 100644
@@ -1770,6 +1770,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_NETCONFIG ||
 			station_is_roaming(station))
 		network_disconnected(network);
 }
@@ -2045,8 +2046,7 @@ static void station_netconfig_event_handler(enum netconfig_event event,
 			dbus_pending_reply(&station->connect_pending, reply);
 		}
 
-		if (L_IN_SET(station->state, STATION_STATE_CONNECTING,
-				STATION_STATE_CONNECTING_AUTO))
+		if (station->state == STATION_STATE_NETCONFIG)
 			network_connect_failed(station->connected_network,
 						false);
 
@@ -2072,9 +2072,14 @@ static bool netconfig_after_roam(struct station *station)
 					network_get_settings(network)))
 		return false;
 
-	return netconfig_configure(station->netconfig,
+	if (!netconfig_configure(station->netconfig,
 					station_netconfig_event_handler,
-					station);
+					station))
+		return false;
+
+	station_enter_state(station, STATION_STATE_NETCONFIG);
+
+	return true;
 }
 
 static void station_roamed(struct station *station)
@@ -3253,6 +3258,8 @@ static void station_connect_ok(struct station *station)
 						station_netconfig_event_handler,
 						station)))
 			return;
+
+		station_enter_state(station, STATION_STATE_NETCONFIG);
 	} else
 		station_enter_state(station, STATION_STATE_CONNECTED);
 }
@@ -4064,8 +4071,10 @@ static struct l_dbus_message *station_dbus_scan(struct l_dbus *dbus,
 	if (station->dbus_scan_id)
 		return dbus_error_busy(message);
 
-	if (station->state == STATION_STATE_CONNECTING ||
-			station->state == STATION_STATE_CONNECTING_AUTO)
+	if (L_IN_SET(station->state, STATION_STATE_CONNECTING,
+				STATION_STATE_CONNECTING_AUTO,
+				STATION_STATE_NETCONFIG) ||
+				station_is_roaming(station))
 		return dbus_error_busy(message);
 
 	station->dbus_scan_subset_idx = 0;
@@ -4288,7 +4297,14 @@ static bool station_property_get_state(struct l_dbus *dbus,
 	case STATION_STATE_ROAMING:
 	case STATION_STATE_FT_ROAMING:
 	case STATION_STATE_FW_ROAMING:
-		statestr = "roaming";
+		/*
+		 * Stay in a connecting state if roaming before netconfig
+		 * has finished
+		 */
+		if (station->netconfig_after_roam)
+			statestr = "connecting";
+		else
+			statestr = "roaming";
 		break;
 	}
 
@@ -5022,8 +5038,10 @@ static struct l_dbus_message *station_debug_scan(struct l_dbus *dbus,
 	if (station->dbus_scan_id)
 		return dbus_error_busy(message);
 
-	if (station->state == STATION_STATE_CONNECTING ||
-			station->state == STATION_STATE_CONNECTING_AUTO)
+	if (L_IN_SET(station->state, STATION_STATE_CONNECTING,
+				STATION_STATE_CONNECTING_AUTO,
+				STATION_STATE_NETCONFIG) ||
+				station_is_roaming(station))
 		return dbus_error_busy(message);
 
 	if (!l_dbus_message_get_arguments(message, "aq", &iter))
Signature · 1 line
2.34.1
#2 lore raw

PATCH v2 3/3 auto-t: add test for roaming + netconfig

In reply to James Prestwood

This test ensures IWD will continue to roam and restart netconfig if roam conditions are met prior to netconfig finishing.

---
 autotests/testNetconfigRoam/TestFT.psk        |  2 +
 .../testNetconfigRoam/ft-psk-ccmp-1.conf      | 41 +++++++++
 .../testNetconfigRoam/ft-psk-ccmp-2.conf      | 41 +++++++++
 autotests/testNetconfigRoam/hw.conf           |  8 ++
 autotests/testNetconfigRoam/main.conf         |  3 +
 .../testNetconfigRoam/netconfig_roam_test.py  | 91 +++++++++++++++++++
 6 files changed, 186 insertions(+)
 create mode 100644 autotests/testNetconfigRoam/TestFT.psk
 create mode 100644 autotests/testNetconfigRoam/ft-psk-ccmp-1.conf
 create mode 100644 autotests/testNetconfigRoam/ft-psk-ccmp-2.conf
 create mode 100644 autotests/testNetconfigRoam/hw.conf
 create mode 100644 autotests/testNetconfigRoam/main.conf
 create mode 100644 autotests/testNetconfigRoam/netconfig_roam_test.py

v2:
* Updated to check/ensure that IWD remains "connecting" even through multiple roams.

autotests/testNetconfigRoam/TestFT.psk new file +2 -0
new file mode 100644
index 00000000..e82d1295
@@ -0,0 +1,2 @@
+[Security]
+Passphrase=EasilyGuessedPassword
autotests/testNetconfigRoam/ft-psk-ccmp-1.conf new file +41 -0

41 lines not on this page · raw message

autotests/testNetconfigRoam/ft-psk-ccmp-2.conf new file +41 -0

41 lines not on this page · raw message

autotests/testNetconfigRoam/hw.conf new file +8 -0
new file mode 100644
index 00000000..c2b35d6e
@@ -0,0 +1,8 @@
+[SETUP]
+num_radios=3
+start_iwd=0
+hwsim_medium=yes
+
+[HOSTAPD]
+rad0=ft-psk-ccmp-1.conf
+rad1=ft-psk-ccmp-2.conf
autotests/testNetconfigRoam/main.conf new file +3 -0
new file mode 100644
index 00000000..aedd4ebd
@@ -0,0 +1,3 @@
+[General]
+EnableNetworkConfiguration=true
+RoamRetryInterval=1
autotests/testNetconfigRoam/netconfig_roam_test.py new file +91 -0

91 lines not on this page · raw message

Signature · 1 line
2.34.1
#3 lore raw
In reply to James Prestwood

Hi James,

Quoted 10 lines · James Prestwood

This is still treated as "connecting" from a DBus perspective but will allow for better handling internally for some roaming corner cases.

---
  src/dpp.c     | 1 +
  src/station.c | 5 +++++
  src/station.h | 1 +
  src/wsc.c     | 1 +
  4 files changed, 8 insertions(+)

All applied, thanks.

Regards,
-Denis