From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH v2 3/5] pmksa: add driver callbacks and pmksa_cache_free
Date: Thu, 13 Feb 2025 12:18:14 -0800 [thread overview]
Message-ID: <20250213201816.230112-4-prestwoj@gmail.com> (raw)
In-Reply-To: <20250213201816.230112-1-prestwoj@gmail.com>
In order to support fullmac drivers the PMKSA entries must be added
and removed from the kernel. To accomplish this a set of driver
callbacks will be added to the PMKSA module. In addition a new
pmksa_cache_free API will be added whos only purpose is to handle
the removal from the kernel.
---
src/pmksa.c | 38 ++++++++++++++++++++++++++++++++++++--
src/pmksa.h | 9 +++++++++
2 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/src/pmksa.c b/src/pmksa.c
index bb539b85..a50c8208 100644
--- a/src/pmksa.c
+++ b/src/pmksa.c
@@ -40,6 +40,9 @@
static uint64_t dot11RSNAConfigPMKLifetime = 43200ULL * L_USEC_PER_SEC;
static uint32_t pmksa_cache_capacity = 255;
+static pmksa_cache_add_func_t driver_add;
+static pmksa_cache_remove_func_t driver_remove;
+static pmksa_cache_flush_func_t driver_flush;
struct min_heap {
struct pmksa **data;
@@ -142,7 +145,7 @@ int pmksa_cache_put(struct pmksa *pmksa)
l_debug("Adding entry with PMKID: "PMKID, PMKID_STR(pmksa->pmkid));
if (cache.used == cache.capacity) {
- l_free(cache.data[0]);
+ pmksa_cache_free(cache.data[0]);
cache.data[0] = pmksa;
__minheap_sift_down(cache.data, cache.used, 0, &ops);
return 0;
@@ -152,6 +155,9 @@ int pmksa_cache_put(struct pmksa *pmksa)
__minheap_sift_up(cache.data, cache.used, &ops);
cache.used += 1;
+ if (driver_add)
+ driver_add(pmksa);
+
return 0;
}
@@ -167,7 +173,7 @@ int pmksa_cache_expire(uint64_t cutoff)
for (i = 0; i < used; i++) {
if (cache.data[i]->expiration <= cutoff) {
- l_free(cache.data[i]);
+ pmksa_cache_free(cache.data[i]);
continue;
}
@@ -190,11 +196,30 @@ int pmksa_cache_flush(void)
{
uint32_t i;
+ /*
+ * The driver flush operation is done via a single kernel API call which
+ * is why below we use l_free instead of pmksa_cache_free as to not
+ * induce a DEL_PMKSA kernel call for each entry.
+ */
+ if (driver_flush)
+ driver_flush();
+
for (i = 0; i < cache.used; i++)
l_free(cache.data[i]);
memset(cache.data, 0, cache.capacity * sizeof(struct pmksa *));
cache.used = 0;
+
+ return 0;
+}
+
+int pmksa_cache_free(struct pmksa *pmksa)
+{
+ if (driver_remove)
+ driver_remove(pmksa);
+
+ l_free(pmksa);
+
return 0;
}
@@ -217,6 +242,15 @@ void __pmksa_set_config(const struct l_settings *config)
&pmksa_cache_capacity);
}
+void __pmksa_set_driver_callbacks(pmksa_cache_add_func_t add,
+ pmksa_cache_remove_func_t remove,
+ pmksa_cache_flush_func_t flush)
+{
+ driver_add = add;
+ driver_remove = remove;
+ driver_flush = flush;
+}
+
static int pmksa_init(void)
{
cache.capacity = pmksa_cache_capacity;
diff --git a/src/pmksa.h b/src/pmksa.h
index 67879309..6a624504 100644
--- a/src/pmksa.h
+++ b/src/pmksa.h
@@ -32,6 +32,10 @@ struct pmksa {
size_t pmk_len;
};
+typedef void (*pmksa_cache_add_func_t)(const struct pmksa *pmksa);
+typedef void (*pmksa_cache_remove_func_t)(const struct pmksa *pmksa);
+typedef void (*pmksa_cache_flush_func_t)(void);
+
struct pmksa **__pmksa_cache_get_all(uint32_t *out_n_entries);
struct pmksa *pmksa_cache_get(const uint8_t spa[static 6],
@@ -41,6 +45,11 @@ 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_free(struct pmksa *pmksa);
uint64_t pmksa_lifetime(void);
void __pmksa_set_config(const struct l_settings *config);
+
+void __pmksa_set_driver_callbacks(pmksa_cache_add_func_t add,
+ pmksa_cache_remove_func_t remove,
+ pmksa_cache_flush_func_t flush);
--
2.34.1
next prev parent reply other threads:[~2025-02-13 20:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-13 20:18 [PATCH v2 0/5] PMKSA support for fullmac drivers James Prestwood
2025-02-13 20:18 ` [PATCH v2 1/5] netdev: don't set CQM thresholds for fullmac cards James Prestwood
2025-02-13 20:18 ` [PATCH v2 2/5] netdev: remove/update some iwd_notice logs James Prestwood
2025-02-13 20:18 ` James Prestwood [this message]
2025-02-13 20:18 ` [PATCH v2 4/5] handshake: use pmksa_cache_free James Prestwood
2025-02-13 20:18 ` [PATCH v2 5/5] netdev: implement PMKSA for fullmac drivers James Prestwood
2025-04-01 16:17 ` [PATCH v2 0/5] PMKSA support " Denis Kenzior
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=20250213201816.230112-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox