From: Chenming Huang Date: Wed, 26 Feb 2025 14:32:25 +0000 (+0530) Subject: AP MLD: List PMKSA entries from MLD-level cache too X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4dcf75777defe17195f3b2c39346a969d771440;p=thirdparty%2Fhostap.git AP MLD: List PMKSA entries from MLD-level cache too Include PMKSA entries from both the link-level and MLD-level PMKSA caches in the PMKSA control interface command output. Signed-off-by: Chenming Huang --- diff --git a/src/ap/pmksa_cache_auth.c b/src/ap/pmksa_cache_auth.c index 2fce8383d..07155402f 100644 --- a/src/ap/pmksa_cache_auth.c +++ b/src/ap/pmksa_cache_auth.c @@ -644,29 +644,25 @@ int pmksa_cache_auth_radius_das_disconnect(struct rsn_pmksa_cache *pmksa, * @pmksa: Pointer to PMKSA cache data from pmksa_cache_auth_init() * @buf: Buffer for the list * @len: Length of the buffer + * @index: Externally stored index counter * Returns: Number of bytes written to buffer * * This function is used to generate a text format representation of the * current PMKSA cache contents for the ctrl_iface PMKSA command. */ -int pmksa_cache_auth_list(struct rsn_pmksa_cache *pmksa, char *buf, size_t len) +int pmksa_cache_auth_list(struct rsn_pmksa_cache *pmksa, char *buf, size_t len, + int *index) { - int i, ret; + int ret; char *pos = buf; struct rsn_pmksa_cache_entry *entry; struct os_reltime now; os_get_reltime(&now); - ret = os_snprintf(pos, buf + len - pos, - "Index / SPA / PMKID / expiration (in seconds) / opportunistic\n"); - if (os_snprintf_error(buf + len - pos, ret)) - return pos - buf; - pos += ret; - i = 0; entry = pmksa->pmksa; while (entry) { ret = os_snprintf(pos, buf + len - pos, "%d " MACSTR " ", - i, MAC2STR(entry->spa)); + *index, MAC2STR(entry->spa)); if (os_snprintf_error(buf + len - pos, ret)) return pos - buf; pos += ret; @@ -679,6 +675,7 @@ int pmksa_cache_auth_list(struct rsn_pmksa_cache *pmksa, char *buf, size_t len) return pos - buf; pos += ret; entry = entry->next; + (*index)++; } return pos - buf; } diff --git a/src/ap/pmksa_cache_auth.h b/src/ap/pmksa_cache_auth.h index e38e7eca6..ade1c4989 100644 --- a/src/ap/pmksa_cache_auth.h +++ b/src/ap/pmksa_cache_auth.h @@ -75,7 +75,8 @@ void pmksa_cache_free_entry(struct rsn_pmksa_cache *pmksa, struct rsn_pmksa_cache_entry *entry); int pmksa_cache_auth_radius_das_disconnect(struct rsn_pmksa_cache *pmksa, struct radius_das_attrs *attr); -int pmksa_cache_auth_list(struct rsn_pmksa_cache *pmksa, char *buf, size_t len); +int pmksa_cache_auth_list(struct rsn_pmksa_cache *pmksa, char *buf, size_t len, + int *index); void pmksa_cache_auth_flush(struct rsn_pmksa_cache *pmksa); int pmksa_cache_auth_list_mesh(struct rsn_pmksa_cache *pmksa, const u8 *addr, char *buf, size_t len); diff --git a/src/ap/wpa_auth.c b/src/ap/wpa_auth.c index 48c12320b..7726b8210 100644 --- a/src/ap/wpa_auth.c +++ b/src/ap/wpa_auth.c @@ -6636,9 +6636,27 @@ void wpa_auth_pmksa_remove(struct wpa_authenticator *wpa_auth, int wpa_auth_pmksa_list(struct wpa_authenticator *wpa_auth, char *buf, size_t len) { + int ret, index; + char *pos = buf, *end = buf + len; + if (!wpa_auth || !wpa_auth->pmksa) return 0; - return pmksa_cache_auth_list(wpa_auth->pmksa, buf, len); + + ret = os_snprintf(pos, len, + "Index / SPA / PMKID / expiration (in seconds) / opportunistic\n"); + if (os_snprintf_error(end - pos, ret)) + return pos - buf; + pos += ret; + + index = 0; + pos += pmksa_cache_auth_list(wpa_auth->pmksa, pos, end - pos, &index); +#ifdef CONFIG_IEEE80211BE + if (wpa_auth->ml_pmksa) + pos += pmksa_cache_auth_list(wpa_auth->ml_pmksa, + pos, end - pos, &index); +#endif /* CONFIG_IEEE80211BE */ + + return pos - buf; }