]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
AP MLD: List PMKSA entries from MLD-level cache too
authorChenming Huang <quic_chenhuan@quicinc.com>
Wed, 26 Feb 2025 14:32:25 +0000 (20:02 +0530)
committerJouni Malinen <j@w1.fi>
Thu, 27 Feb 2025 10:11:44 +0000 (12:11 +0200)
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 <quic_chenhuan@quicinc.com>
src/ap/pmksa_cache_auth.c
src/ap/pmksa_cache_auth.h
src/ap/wpa_auth.c

index 2fce8383d975d90e7f4607a64b3b08f5897c4c0b..07155402fa155ab6e51ef01d1ed0171fac146f5f 100644 (file)
@@ -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;
 }
index e38e7eca66e74cecbf90576afd3f423e1e1092ff..ade1c498950f4f32c3cb970a62e9e33050684098 100644 (file)
@@ -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);
index 48c12320b01b4e408864056d089be895f539bd4b..7726b8210bdc6f608c1626b708e3ca19254ab659 100644 (file)
@@ -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;
 }