($INBOX_DIR/description missing)
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH v2 1/4] knownnetworks: network: support updating known network settings
Date: Mon, 18 Dec 2023 06:12:47 -0800	[thread overview]
Message-ID: <20231218141250.202157-1-prestwoj@gmail.com> (raw)

Currently if a known network is modified on disk the settings are not
reloaded by network. Only disconnecting/reconnecting to the network
would update the settings. This poses an issue to DPP since its
creating or updating a known network after configuration then trying
to connect. The connection itself works fine since the PSK/passphrase
is set to the network object directly, but any additional settings
are not updated.

To fix this add a new UPDATED known network event. This is then
handled from within network and all settings read from disk are
applied to the network object.
---
 src/knownnetworks.c |  4 ++++
 src/knownnetworks.h |  1 +
 src/network.c       | 27 ++++++++++++++++++++++++---
 3 files changed, 29 insertions(+), 3 deletions(-)

v2:
 * Instead of bothering with individual settings we can just use the
   new l_settings object. This would still prefer agent-obtained creds
   set into the network object but also honor any new settings written
   to the profile if there is an ongoing connection. This is a much
   simpler approach (unless I'm missing something). Only questionable
   piece is what to do with the Security group. I hesitate to skip it
   because its what we have on disk, but it could mean the network
   object isn't synced with its settings. But I'm not sure this is
   any different than what we have today, if a profile is modified
   during an ongoing connection its settings (including security)
   won't get updated until a disconnect/reconnect.

 * Remove frequency sync on UPDATED event

diff --git a/src/knownnetworks.c b/src/knownnetworks.c
index d4d50a6f..04ce74ec 100644
--- a/src/knownnetworks.c
+++ b/src/knownnetworks.c
@@ -468,6 +468,10 @@ void known_network_update(struct network_info *network,
 	known_network_set_autoconnect(network, new->is_autoconnectable);
 
 	memcpy(&network->config, new, sizeof(struct network_config));
+
+	WATCHLIST_NOTIFY(&known_network_watches,
+				known_networks_watch_func_t,
+				KNOWN_NETWORKS_EVENT_UPDATED, network);
 }
 
 bool known_networks_foreach(known_networks_foreach_func_t function,
diff --git a/src/knownnetworks.h b/src/knownnetworks.h
index 0a5c9e25..e8ffac0b 100644
--- a/src/knownnetworks.h
+++ b/src/knownnetworks.h
@@ -35,6 +35,7 @@ struct network_info;
 enum known_networks_event {
 	KNOWN_NETWORKS_EVENT_ADDED,
 	KNOWN_NETWORKS_EVENT_REMOVED,
+	KNOWN_NETWORKS_EVENT_UPDATED,
 };
 
 struct network_info_ops {
diff --git a/src/network.c b/src/network.c
index 3918ae08..f19482d8 100644
--- a/src/network.c
+++ b/src/network.c
@@ -2001,7 +2001,8 @@ static void network_update_hotspot(struct network *network, void *user_data)
 	match_hotspot_network(info, network);
 }
 
-static void match_known_network(struct station *station, void *user_data)
+static void match_known_network(struct station *station, void *user_data,
+				bool new)
 {
 	struct network_info *info = user_data;
 	struct network *network;
@@ -2011,7 +2012,14 @@ static void match_known_network(struct station *station, void *user_data)
 		if (!network)
 			return;
 
-		network_set_info(network, info);
+		if (new)
+			network_set_info(network, info);
+
+		if (network->settings)
+			l_settings_free(network->settings);
+
+		network->settings = network_info_open_settings(info);
+
 		return;
 	}
 
@@ -2019,17 +2027,30 @@ static void match_known_network(struct station *station, void *user_data)
 	station_network_foreach(station, network_update_hotspot, info);
 }
 
+static void add_known_network(struct station *station, void *user_data)
+{
+	match_known_network(station, (struct network_info *)user_data, true);
+}
+
+static void update_known_network(struct station *station, void *user_data)
+{
+	match_known_network(station, (struct network_info *)user_data, false);
+}
+
 static void known_networks_changed(enum known_networks_event event,
 					const struct network_info *info,
 					void *user_data)
 {
 	switch (event) {
 	case KNOWN_NETWORKS_EVENT_ADDED:
-		station_foreach(match_known_network, (void *) info);
+		station_foreach(add_known_network, (void *) info);
 
 		/* Syncs frequencies of newly known network */
 		known_network_frequency_sync((struct network_info *)info);
 		break;
+	case KNOWN_NETWORKS_EVENT_UPDATED:
+		station_foreach(update_known_network, (void *) info);
+		break;
 	case KNOWN_NETWORKS_EVENT_REMOVED:
 		station_foreach(emit_known_network_removed, (void *) info);
 		break;
-- 
2.34.1


             reply	other threads:[~2023-12-18 14:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-18 14:12 James Prestwood [this message]
2023-12-18 14:12 ` [PATCH v2 2/4] dpp: fix extra settings not being used when connecting James Prestwood
2023-12-18 14:12 ` [PATCH v2 3/4] auto-t: add DPP tests to check extra settings are applied James Prestwood
2023-12-18 14:12 ` [PATCH v2 4/4] auto-t: increase RAM when running with valgrind (UML) James Prestwood
2023-12-19  4:31 ` [PATCH v2 1/4] knownnetworks: network: support updating known network settings Denis Kenzior
2023-12-19 12:57   ` James Prestwood
2023-12-19 16:31     ` Denis Kenzior
2023-12-19 16:53       ` James Prestwood
2023-12-19 17:46         ` Denis Kenzior
2023-12-19 17:49           ` 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=20231218141250.202157-1-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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).