commit 72e7d3ceb83d1e8b223974478f5ca539371ab894
parent afa9a1261c784b8109e3be3ef681787c85aa2aa1
Author: Andrew Zaborowski <andrew.zaborowski@intel.com>
Date: Fri, 30 Sep 2022 16:48:00 +0200
station: Handle NETCONFIG_EVENT_FAILED
If IPv4 setup fails and the netconfig logic gives up, continue as if the
connection had failed at earlier stages so that autoconnect can try the
next available network.
Diffstat:
1 file changed, 43 insertions(+), 0 deletions(-)
diff --git a/src/station.c b/src/station.c
@@ -2101,6 +2101,30 @@ delayed_retry:
station_roam_retry(station);
}
+static void station_disconnect_on_error_cb(struct netdev *netdev, bool success,
+ void *user_data)
+{
+ struct station *station = user_data;
+ bool continue_autoconnect;
+
+ station_enter_state(station, STATION_STATE_DISCONNECTED);
+
+ continue_autoconnect = station->state == STATION_STATE_CONNECTING_AUTO;
+
+ if (continue_autoconnect) {
+ if (station_autoconnect_next(station) < 0) {
+ l_debug("Nothing left on autoconnect list");
+ station_enter_state(station,
+ STATION_STATE_AUTOCONNECT_FULL);
+ }
+
+ return;
+ }
+
+ if (station->autoconnect)
+ station_enter_state(station, STATION_STATE_AUTOCONNECT_QUICK);
+}
+
static void station_netconfig_event_handler(enum netconfig_event event,
void *user_data)
{
@@ -2109,7 +2133,26 @@ static void station_netconfig_event_handler(enum netconfig_event event,
switch (event) {
case NETCONFIG_EVENT_CONNECTED:
station_enter_state(station, STATION_STATE_CONNECTED);
+ break;
+ case NETCONFIG_EVENT_FAILED:
+ if (station->connect_pending) {
+ struct l_dbus_message *reply = dbus_error_failed(
+ station->connect_pending);
+
+ dbus_pending_reply(&station->connect_pending, reply);
+ }
+
+ if (L_IN_SET(station->state, STATION_STATE_CONNECTING,
+ STATION_STATE_CONNECTING_AUTO))
+ network_connect_failed(station->connected_network,
+ false);
+
+ netdev_disconnect(station->netdev,
+ station_disconnect_on_error_cb,
+ station);
+ station_reset_connection_state(station);
+ station_enter_state(station, STATION_STATE_DISCONNECTING);
break;
default:
l_error("station: Unsupported netconfig event: %d.", event);