From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH 4/8] network: update to use blacklist's new temporary type
Date: Mon, 10 Mar 2025 14:40:55 -0700 [thread overview]
Message-ID: <20250310214059.20809-4-prestwoj@gmail.com> (raw)
In-Reply-To: <20250310214059.20809-1-prestwoj@gmail.com>
Remove the temporary blacklist from network.c and use the new
BLACKLIST_REASON_TEMPORARY type.
---
src/network.c | 34 +++++++++++++++++-----------------
src/network.h | 2 --
src/station.c | 8 ++++----
3 files changed, 21 insertions(+), 23 deletions(-)
diff --git a/src/network.c b/src/network.c
index 92b44ed3..b48eaa51 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_TEMPORARY);
+}
+
+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_TEMPORARY))
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 fab37478..d16e82af 100644
--- a/src/station.c
+++ b/src/station.c
@@ -3462,8 +3462,8 @@ static bool station_retry_with_status(struct station *station,
* obtain that IE, but this should be done in the future.
*/
if (IS_TEMPORARY_STATUS(status_code))
- network_blacklist_add(station->connected_network,
- station->connected_bss);
+ blacklist_add_bss(station->connected_bss->addr,
+ BLACKLIST_REASON_TEMPORARY);
else if (!station_pmksa_fallback(station, status_code))
blacklist_add_bss(station->connected_bss->addr,
BLACKLIST_REASON_PERMANENT);
@@ -3562,8 +3562,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_TEMPORARY);
if (station_try_next_bss(station))
return;
--
2.34.1
next prev parent reply other threads:[~2025-03-10 21:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-10 21:40 [PATCH 1/8] blacklist: include a blacklist reason when adding/finding James Prestwood
2025-03-10 21:40 ` [PATCH 2/8] blacklist: fix pruning to remove the entry if its expired James Prestwood
2025-03-10 21:40 ` [PATCH 3/8] blacklist: add BLACKLIST_REASON_TEMPORARY James Prestwood
2025-03-10 21:40 ` James Prestwood [this message]
2025-03-10 21:40 ` [PATCH 5/8] blacklist: add new blacklist reason, ROAM_REQUESTED James Prestwood
2025-03-10 21:40 ` [PATCH 6/8] scan: Introduce higher level scan BSS groups James Prestwood
2025-03-10 21:40 ` [PATCH 7/8] station: roam blacklist BSS when a roam is requested James Prestwood
2025-03-10 21:40 ` [PATCH 8/8] auto-t: add test for AP roam blacklisting 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=20250310214059.20809-4-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.