From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH v3 5/9] station: provide new state in __station_connect_network
Date: Tue, 31 Oct 2023 11:47:46 -0700 [thread overview]
Message-ID: <20231031184750.722404-6-prestwoj@gmail.com> (raw)
In-Reply-To: <20231031184750.722404-1-prestwoj@gmail.com>
This is being done to allow the DPP module to work correctl. DPP
currently uses __station_connect_network incorrectly since it
does not (and cannot) change the state after calling. The only
way to connect with a state change is via station_connect_network
which requires a DBus method that triggered the connection; DPP
does not have this due to its potentially long run time.
To support DPP there are a few options:
1. Pass a state into __station_connect_network (this patch)
2. Support a NULL DBus message in station_connect_network. This
would require several NULL checks and adding all that to only
support DPP just didn't feel right.
3. A 3rd connect API in station which wraps
__station_connect_network and changes the state. And again, an
entirely new API for only DPP felt wrong (I guess we did this
for network_autoconnect though...)
Its about 50/50 between call sites that changed state after calling
and those that do not. Changing the state inside
__station_connect_network felt useful enough to cover the cases that
could benefit and the remaining cases could handle it easily enough:
- network_autoconnect(), and the state is changed by station after
calling so it more or less follows the same pattern just routes
through network. This will now pass the CONNECTING_AUTO state
from within network vs station.
- The disconnect/reconnect path. Here the state is changed to
ROAMING prior in order to avoid multiple state changes. Knowing
this the same ROAMING state can be passed which won't trigger a
state change.
- Retrying after a failed BSS. The state changes on the first call
then remains the same for each connection attempt. To support this
the current station->state is passed to avoid a state change.
---
src/dpp.c | 3 ++-
src/network.c | 3 ++-
src/station.c | 23 +++++++++++------------
src/station.h | 2 +-
4 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/src/dpp.c b/src/dpp.c
index e5e1b3fa..b0a79361 100644
--- a/src/dpp.c
+++ b/src/dpp.c
@@ -833,7 +833,8 @@ static void dpp_handle_config_response_frame(const struct mmpdu_header *frame,
offchannel_cancel(dpp->wdev_id, dpp->offchannel_id);
if (network && bss)
- __station_connect_network(station, network, bss);
+ __station_connect_network(station, network, bss,
+ STATION_STATE_CONNECTING);
else if (station) {
dpp->connect_scan_id = scan_active(dpp->wdev_id, NULL, 0,
dpp_scan_triggered,
diff --git a/src/network.c b/src/network.c
index 3099d102..f203834c 100644
--- a/src/network.c
+++ b/src/network.c
@@ -991,7 +991,8 @@ int network_autoconnect(struct network *network, struct scan_bss *bss)
return -ENOTSUP;
}
- return __station_connect_network(station, network, bss);
+ return __station_connect_network(station, network, bss,
+ STATION_STATE_CONNECTING_AUTO);
close_settings:
network_settings_close(network);
diff --git a/src/station.c b/src/station.c
index d4eb0cd8..3da02b06 100644
--- a/src/station.c
+++ b/src/station.c
@@ -280,9 +280,6 @@ static int station_autoconnect_next(struct station *station)
r = network_autoconnect(network, bss);
if (!r) {
- station_enter_state(station,
- STATION_STATE_CONNECTING_AUTO);
-
if (station->quick_scan_id) {
scan_cancel(netdev_get_wdev_id(station->netdev),
station->quick_scan_id);
@@ -3084,7 +3081,7 @@ static bool station_try_next_bss(struct station *station)
return false;
ret = __station_connect_network(station, station->connected_network,
- next);
+ next, station->state);
if (ret < 0)
return false;
@@ -3421,7 +3418,7 @@ static void station_netdev_event(struct netdev *netdev, enum netdev_event event,
}
int __station_connect_network(struct station *station, struct network *network,
- struct scan_bss *bss)
+ struct scan_bss *bss, enum station_state state)
{
struct handshake_state *hs;
int r;
@@ -3448,6 +3445,9 @@ int __station_connect_network(struct station *station, struct network *network,
station->connected_bss = bss;
station->connected_network = network;
+ if (station->state != state)
+ station_enter_state(station, state);
+
return 0;
}
@@ -3461,7 +3461,8 @@ static void station_disconnect_onconnect_cb(struct netdev *netdev, bool success,
err = __station_connect_network(station,
station->connect_pending_network,
- station->connect_pending_bss);
+ station->connect_pending_bss,
+ STATION_STATE_CONNECTING);
station->connect_pending_network = NULL;
station->connect_pending_bss = NULL;
@@ -3472,8 +3473,6 @@ static void station_disconnect_onconnect_cb(struct netdev *netdev, bool success,
station->connect_pending));
return;
}
-
- station_enter_state(station, STATION_STATE_CONNECTING);
}
static void station_disconnect_onconnect(struct station *station,
@@ -3531,12 +3530,11 @@ void station_connect_network(struct station *station, struct network *network,
return;
}
- err = __station_connect_network(station, network, bss);
+ err = __station_connect_network(station, network, bss,
+ STATION_STATE_CONNECTING);
if (err < 0)
goto error;
- station_enter_state(station, STATION_STATE_CONNECTING);
-
station->connect_pending = l_dbus_message_ref(message);
station_set_autoconnect(station, true);
@@ -3746,7 +3744,8 @@ static void station_disconnect_reconnect_cb(struct netdev *netdev, bool success,
struct station *station = user_data;
if (__station_connect_network(station, station->connected_network,
- station->connected_bss) < 0)
+ station->connected_bss,
+ STATION_STATE_ROAMING) < 0)
station_disassociated(station);
}
diff --git a/src/station.h b/src/station.h
index 24fab321..0d502a08 100644
--- a/src/station.h
+++ b/src/station.h
@@ -89,7 +89,7 @@ void station_remove_event_watch(uint32_t id);
bool station_set_autoconnect(struct station *station, bool autoconnect);
int __station_connect_network(struct station *station, struct network *network,
- struct scan_bss *bss);
+ struct scan_bss *bss, enum station_state state);
void station_connect_network(struct station *station, struct network *network,
struct scan_bss *bss,
struct l_dbus_message *message);
--
2.25.1
next prev parent reply other threads:[~2023-10-31 18:48 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-31 18:47 [PATCH v3 0/9] DPP PKEX Changes James Prestwood
2023-10-31 18:47 ` [PATCH v3 1/9] dpp: remove scan_periodic_stop calls James Prestwood
2023-11-03 1:40 ` Denis Kenzior
2023-10-31 18:47 ` [PATCH v3 2/9] dpp: fix config request header check James Prestwood
2023-10-31 18:47 ` [PATCH v3 3/9] dpp: allow enrollee to be authentication initiator James Prestwood
2023-10-31 18:47 ` [PATCH v3 4/9] dbus: add net.connman.iwd.SharedCodeAgent DBus interface James Prestwood
2023-10-31 18:47 ` James Prestwood [this message]
2023-10-31 18:47 ` [PATCH v3 6/9] doc: PKEX support for DPP James Prestwood
2023-11-03 2:07 ` Denis Kenzior
2023-11-03 11:24 ` James Prestwood
2023-10-31 18:47 ` [PATCH v3 7/9] dpp: SharedCode interface, {Register,Unregister}SharedCodeAgent James Prestwood
2023-11-03 2:09 ` Denis Kenzior
2023-10-31 18:47 ` [PATCH v3 8/9] dpp: initial version of PKEX enrollee support James Prestwood
2023-11-03 2:12 ` Denis Kenzior
2023-11-03 11:27 ` James Prestwood
2023-10-31 18:47 ` [PATCH v3 9/9] dpp: initial version of PKEX configurator support James Prestwood
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=20231031184750.722404-6-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