public inbox for iwd@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH v2 1/4] pmksa: add pmksa_cache_flush_ssid
@ 2026-03-24 19:20 James Prestwood
  2026-03-24 19:20 ` [PATCH v2 2/4] common: add security_to_akms() James Prestwood
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: James Prestwood @ 2026-03-24 19:20 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

Adds a new flushing method to remove all PMKSA entries for a given
SSID/AKM list
---
 src/pmksa.c | 30 ++++++++++++++++++++++++++++++
 src/pmksa.h |  1 +
 2 files changed, 31 insertions(+)

v2:
 * Check AKM's as well as SSID

diff --git a/src/pmksa.c b/src/pmksa.c
index a50c8208..7f37f0c7 100644
--- a/src/pmksa.c
+++ b/src/pmksa.c
@@ -213,6 +213,36 @@ int pmksa_cache_flush(void)
 	return 0;
 }
 
+/*
+ * Flushes all PMKSA entries that match an SSID
+ */
+int pmksa_cache_flush_ssid(const uint8_t *ssid, size_t ssid_len, uint32_t akms)
+{
+	int i;
+	int used = cache.used;
+	int remaining = 0;
+
+	for (i = 0; i < used; i++) {
+		/* Check that the both the AKM matches as well as the SSID */
+		if ((cache.data[i]->akm & akms) &&
+				!memcmp(ssid, cache.data[i]->ssid,
+					cache.data[i]->ssid_len)) {
+			pmksa_cache_free(cache.data[i]);
+			continue;
+		}
+
+		cache.data[remaining] = cache.data[i];
+		remaining += 1;
+	}
+
+	cache.used = remaining;
+
+	for (i = cache.used >> 1; i >= 0; i--)
+		__minheap_sift_down(cache.data, cache.used, i, &ops);
+
+	return used - remaining;
+}
+
 int pmksa_cache_free(struct pmksa *pmksa)
 {
 	if (driver_remove)
diff --git a/src/pmksa.h b/src/pmksa.h
index 6a624504..9f059a11 100644
--- a/src/pmksa.h
+++ b/src/pmksa.h
@@ -45,6 +45,7 @@ struct pmksa *pmksa_cache_get(const uint8_t spa[static 6],
 int pmksa_cache_put(struct pmksa *pmksa);
 int pmksa_cache_expire(uint64_t cutoff);
 int pmksa_cache_flush(void);
+int pmksa_cache_flush_ssid(const uint8_t *ssid, size_t ssid_len, uint32_t akms);
 int pmksa_cache_free(struct pmksa *pmksa);
 
 uint64_t pmksa_lifetime(void);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-24 19:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-24 19:20 [PATCH v2 1/4] pmksa: add pmksa_cache_flush_ssid James Prestwood
2026-03-24 19:20 ` [PATCH v2 2/4] common: add security_to_akms() James Prestwood
2026-03-24 19:20 ` [PATCH v2 3/4] network: remove PMKSA entries on known network removal James Prestwood
2026-03-24 19:20 ` [PATCH v2 4/4] auto-t: add test for known network removal of a PMKSA network James Prestwood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox