]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
AP MLD: Simplify for_each_mld_link() macro
authorAditya Kumar Singh <quic_adisi@quicinc.com>
Thu, 28 Mar 2024 18:16:31 +0000 (23:46 +0530)
committerJouni Malinen <j@w1.fi>
Tue, 16 Apr 2024 07:51:24 +0000 (10:51 +0300)
for_each_mld_link() macro used three nested for loops. Since now the
affliated links are linked together via a linked list, the logic can be
improved by using dl_list_for_each() macro instead which uses one for
loop.

Modify for_each_mld_link() macro to use dl_list_for_each() instead.

Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
src/ap/beacon.c
src/ap/hostapd.h
src/ap/sta_info.c

index 143b3b4b7bd26a1194a4ac577276e6625a7cc60b..00ce933ad76417fae6335bbcbb7bc6f5f68998b1 100644 (file)
@@ -957,7 +957,6 @@ static void hostapd_fill_probe_resp_ml_params(struct hostapd_data *hapd,
 {
        struct probe_resp_params sta_info_params;
        struct hostapd_data *link;
-       unsigned int probed_mld_id, i, j;
 
        params->mld_ap = NULL;
        params->mld_info = os_zalloc(sizeof(*params->mld_info));
@@ -968,14 +967,7 @@ static void hostapd_fill_probe_resp_ml_params(struct hostapd_data *hapd,
                   "MLD: Got ML probe request with AP MLD ID %d for links %04x",
                   mld_id, links);
 
-       /*
-        * We want to include the AP MLD ID in the response if it was
-        * included in the request.
-        */
-       probed_mld_id = mld_id != -1 ? mld_id : hostapd_get_mld_id(hapd);
-
-       for_each_mld_link(link, i, j, hapd->iface->interfaces,
-                         probed_mld_id) {
+       for_each_mld_link(link, hapd) {
                struct mld_link_info *link_info;
                size_t buflen;
                u8 mld_link_id = link->mld_link_id;
index 4797d7d93ad7c8c2f11681582383866d96ffadc9..1d1943ac52ecbc82f40b9e60cf66b79f43318ddb 100644 (file)
@@ -827,19 +827,8 @@ struct hostapd_data * hostapd_mld_get_first_bss(struct hostapd_data *hapd);
 
 bool hostapd_mld_is_first_bss(struct hostapd_data *hapd);
 
-#define for_each_mld_link(_link, _bss_idx, _iface_idx, _ifaces, _mld_id) \
-       for (_iface_idx = 0;                                            \
-            _iface_idx < (_ifaces)->count;                             \
-            _iface_idx++)                                              \
-               for (_bss_idx = 0;                                      \
-                    _bss_idx <                                         \
-                       (_ifaces)->iface[_iface_idx]->num_bss;          \
-                    _bss_idx++)                                        \
-                       for (_link =                                    \
-                            (_ifaces)->iface[_iface_idx]->bss[_bss_idx]; \
-                           _link && _link->conf->mld_ap &&             \
-                               hostapd_get_mld_id(_link) == _mld_id;   \
-                           _link = NULL)
+#define for_each_mld_link(partner, self) \
+       dl_list_for_each(partner, &self->mld->links, struct hostapd_data, link)
 
 #else /* CONFIG_IEEE80211BE */
 
@@ -848,7 +837,7 @@ static inline bool hostapd_mld_is_first_bss(struct hostapd_data *hapd)
        return true;
 }
 
-#define for_each_mld_link(_link, _bss_idx, _iface_idx, _ifaces, _mld_id) \
+#define for_each_mld_link(partner, self) \
        if (false)
 
 #endif /* CONFIG_IEEE80211BE */
index 32944edff5c44f90b7854b66f5da78e4b82467ba..6e0b6dc98664450b11a0c5c24cae3c61d6f1aec4 100644 (file)
@@ -1761,10 +1761,8 @@ static void ap_sta_remove_link_sta(struct hostapd_data *hapd,
                                   struct sta_info *sta)
 {
        struct hostapd_data *tmp_hapd;
-       unsigned int i, j;
 
-       for_each_mld_link(tmp_hapd, i, j, hapd->iface->interfaces,
-                         hostapd_get_mld_id(hapd)) {
+       for_each_mld_link(tmp_hapd, hapd) {
                struct sta_info *tmp_sta;
 
                if (hapd == tmp_hapd)