From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH v2 2/3] station: add handling for new NETCONFIG state
Date: Fri, 5 Jan 2024 06:47:49 -0800 [thread overview]
Message-ID: <20240105144750.839705-2-prestwoj@gmail.com> (raw)
In-Reply-To: <20240105144750.839705-1-prestwoj@gmail.com>
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.
diff --git a/src/station.c b/src/station.c
index 68cac945..a6442d3e 100644
--- a/src/station.c
+++ b/src/station.c
@@ -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))
--
2.34.1
next prev parent reply other threads:[~2024-01-05 14:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-05 14:47 [PATCH v2 1/3] station: add additional internal state, STATION_STATE_NETCONFIG James Prestwood
2024-01-05 14:47 ` James Prestwood [this message]
2024-01-05 14:47 ` [PATCH v2 3/3] auto-t: add test for roaming + netconfig James Prestwood
2024-01-09 4:20 ` [PATCH v2 1/3] station: add additional internal state, STATION_STATE_NETCONFIG 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=20240105144750.839705-2-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox