[PATCH v2 1/4] pmksa: add pmksa_cache_flush_ssid

James Prestwood
2026-03-24T19:20:57Z

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