Wireless Daemon for Linux
 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 06/13] network: update to use blacklist's new temporary type
Date: Mon, 24 Mar 2025 07:15:31 -0700	[thread overview]
Message-ID: <20250324141538.144578-7-prestwoj@gmail.com> (raw)
In-Reply-To: <20250324141538.144578-1-prestwoj@gmail.com>

Remove the temporary blacklist from network.c and use the new
BLACKLIST_REASON_TRANSIENT_ERROR reason.
---
 src/network.c | 34 +++++++++++++++++-----------------
 src/network.h |  2 --
 src/station.c | 12 ++++++------
 3 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/src/network.c b/src/network.c
index 4602a110..be6641c0 100644
--- a/src/network.c
+++ b/src/network.c
@@ -78,7 +78,6 @@ struct network {
 	struct l_queue *bss_list;
 	struct l_settings *settings;
 	struct l_queue *secrets;
-	struct l_queue *blacklist; /* temporary blacklist for BSS's */
 	uint8_t hessid[6];
 	char **nai_realms;
 	uint8_t *rc_ie;
@@ -168,6 +167,18 @@ static bool network_secret_check_cacheable(void *data, void *user_data)
 	return false;
 }
 
+static void remove_temporary_blacklist(void *user_data)
+{
+	struct scan_bss *bss = user_data;
+
+	blacklist_remove_bss(bss->addr, BLACKLIST_REASON_TRANSIENT_ERROR);
+}
+
+static void remove_blacklist_foreach(void *data, void *user_data)
+{
+	remove_temporary_blacklist(data);
+}
+
 void network_connected(struct network *network)
 {
 	enum security security = network_get_security(network);
@@ -198,7 +209,7 @@ void network_connected(struct network *network)
 	l_queue_foreach_remove(network->secrets,
 				network_secret_check_cacheable, network);
 
-	l_queue_clear(network->blacklist, NULL);
+	l_queue_foreach(network->bss_list, remove_blacklist_foreach, NULL);
 
 	network->provisioning_hidden = false;
 }
@@ -207,7 +218,7 @@ void network_disconnected(struct network *network)
 {
 	network_settings_close(network);
 
-	l_queue_clear(network->blacklist, NULL);
+	l_queue_foreach(network->bss_list, remove_blacklist_foreach, NULL);
 
 	if (network->provisioning_hidden)
 		station_hide_network(network->station, network);
@@ -254,7 +265,6 @@ struct network *network_create(struct station *station, const char *ssid,
 	}
 
 	network->bss_list = l_queue_new();
-	network->blacklist = l_queue_new();
 
 	return network;
 }
@@ -1197,11 +1207,6 @@ struct scan_bss *network_bss_find_by_addr(struct network *network,
 	return l_queue_find(network->bss_list, match_addr, addr);
 }
 
-static bool match_bss(const void *a, const void *b)
-{
-	return a == b;
-}
-
 struct erp_cache_entry *network_get_erp_cache(struct network *network)
 {
 	struct erp_cache_entry *cache;
@@ -1277,7 +1282,8 @@ struct scan_bss *network_bss_select(struct network *network,
 			candidate = bss;
 
 		/* check if temporarily blacklisted */
-		if (l_queue_find(network->blacklist, match_bss, bss))
+		if (blacklist_contains_bss(bss->addr,
+					BLACKLIST_REASON_TRANSIENT_ERROR))
 			continue;
 
 		if (blacklist_contains_bss(bss->addr,
@@ -1784,11 +1790,6 @@ struct l_dbus_message *network_connect_new_hidden_network(
 	return dbus_error_not_supported(message);
 }
 
-void network_blacklist_add(struct network *network, struct scan_bss *bss)
-{
-	l_queue_push_head(network->blacklist, bss);
-}
-
 static bool network_property_get_name(struct l_dbus *dbus,
 					struct l_dbus_message *message,
 					struct l_dbus_message_builder *builder,
@@ -1934,8 +1935,7 @@ void network_remove(struct network *network, int reason)
 	if (network->info)
 		network->info->seen_count -= 1;
 
-	l_queue_destroy(network->bss_list, NULL);
-	l_queue_destroy(network->blacklist, NULL);
+	l_queue_destroy(network->bss_list, remove_temporary_blacklist);
 
 	if (network->nai_realms)
 		l_strv_free(network->nai_realms);
diff --git a/src/network.h b/src/network.h
index 849051dd..1e01de88 100644
--- a/src/network.h
+++ b/src/network.h
@@ -95,8 +95,6 @@ struct l_dbus_message *network_connect_new_hidden_network(
 						struct network *network,
 						struct l_dbus_message *message);
 
-void network_blacklist_add(struct network *network, struct scan_bss *bss);
-
 struct erp_cache_entry *network_get_erp_cache(struct network *network);
 
 const struct l_queue_entry *network_bss_list_get_entries(
diff --git a/src/station.c b/src/station.c
index e2ed78f3..c4ba9413 100644
--- a/src/station.c
+++ b/src/station.c
@@ -3408,8 +3408,8 @@ static bool station_retry_with_reason(struct station *station,
 	 * Network blacklist the BSS as well, since the timeout blacklist could
 	 * be disabled
 	 */
-	network_blacklist_add(station->connected_network,
-				station->connected_bss);
+	blacklist_add_bss(station->connected_bss->addr,
+				BLACKLIST_REASON_TRANSIENT_ERROR);
 
 try_next:
 	return station_try_next_bss(station);
@@ -3481,8 +3481,8 @@ static bool station_retry_with_status(struct station *station,
 	 * will allow network_bss_select to traverse the BSS list and ignore
 	 * BSS's which have previously failed
 	 */
-	network_blacklist_add(station->connected_network,
-				station->connected_bss);
+	blacklist_add_bss(station->connected_bss->addr,
+				BLACKLIST_REASON_TRANSIENT_ERROR);
 
 try_next:
 	iwd_notice(IWD_NOTICE_CONNECT_FAILED, "status: %u", status_code);
@@ -3579,8 +3579,8 @@ static void station_connect_cb(struct netdev *netdev, enum netdev_result result,
 		iwd_notice(IWD_NOTICE_DISCONNECT_INFO, "reason: %u", reason);
 
 		/* Disconnected while connecting */
-		network_blacklist_add(station->connected_network,
-						station->connected_bss);
+		blacklist_add_bss(station->connected_bss->addr,
+					BLACKLIST_REASON_TRANSIENT_ERROR);
 		if (station_try_next_bss(station))
 			return;
 
-- 
2.34.1


  parent reply	other threads:[~2025-03-24 14:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-24 14:15 [PATCH v2 00/13] Roam blacklisting and scan BSS groups James Prestwood
2025-03-24 14:15 ` [PATCH v2 01/13] station: always network (temp) blacklist on failure James Prestwood
2025-03-24 14:15 ` [PATCH v2 02/13] auto-t: add test for disabling the timeout blacklist James Prestwood
2025-03-24 14:15 ` [PATCH v2 03/13] blacklist: include a blacklist reason when adding/finding James Prestwood
2025-03-24 14:15 ` [PATCH v2 04/13] blacklist: fix pruning to remove the entry if its expired James Prestwood
2025-03-24 14:15 ` [PATCH v2 05/13] blacklist: add BLACKLIST_REASON_TRANSIENT_ERROR James Prestwood
2025-03-24 14:15 ` James Prestwood [this message]
2025-03-24 14:15 ` [PATCH v2 07/13] blacklist: add new blacklist reason, ROAM_REQUESTED James Prestwood
2025-03-24 14:15 ` [PATCH v2 08/13] scan: Introduce higher level scan BSS groups James Prestwood
2025-03-24 14:15 ` [PATCH v2 09/13] station: roam blacklist BSS when a roam is requested James Prestwood
2025-03-24 14:15 ` [PATCH v2 10/13] station: roam blacklist AP even mid-roam James Prestwood
2025-03-24 14:15 ` [PATCH v2 11/13] station: adapt roam scan logic to look at the bss group James Prestwood
2025-03-24 14:15 ` [PATCH v2 12/13] auto-t: add tests for AP roam blacklisting James Prestwood
2025-03-24 14:15 ` [PATCH v2 13/13] doc: document OptimalSignalThreshold and InitialRoamRequestedTimeout 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=20250324141538.144578-7-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