wifi: mac80211: simplify multi-link element parsing
authorJohannes Berg <johannes.berg@intel.com>
Wed, 28 Feb 2024 08:48:13 +0000 (09:48 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 4 Mar 2024 13:32:57 +0000 (14:32 +0100)
We shouldn't assign elems->ml_basic{,len} before defragmentation,
and we don't need elems->ml_reconf{,len} at all since we don't do
defragmentation. Clean that up a bit. This does require always
defragmention even when it may not be needed, but that's easier
to reason about.

Reviewed-by: Ilan Peer <ilan.peer@intel.com>
Reviewed-by: Miriam Rachel Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240228094902.e0115da4d2a6.I89a80f7387eabef8df3955485d4a583ed024c5b1@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/ieee80211_i.h
net/mac80211/mlme.c
net/mac80211/parse.c

index 32b5ac8947bdd7faaec5bc3ad6ccab7dc8cd3ac3..26cf24a3158309ebd221e4761537e80fe8afb61f 100644 (file)
@@ -1736,7 +1736,6 @@ struct ieee802_11_elems {
        const struct ieee80211_eht_cap_elem *eht_cap;
        const struct ieee80211_eht_operation *eht_operation;
        const struct ieee80211_multi_link_elem *ml_basic;
-       const struct ieee80211_multi_link_elem *ml_reconf;
        const struct ieee80211_bandwidth_indication *bandwidth_indication;
        const struct ieee80211_ttlm_elem *ttlm[IEEE80211_TTLM_MAX_CNT];
 
@@ -1764,12 +1763,11 @@ struct ieee802_11_elems {
 
        /* mult-link element can be de-fragmented and thus u8 is not sufficient */
        size_t ml_basic_len;
-       size_t ml_reconf_len;
 
-       /* The basic Multi-Link element in the original IEs */
+       /* The basic Multi-Link element in the original elements */
        const struct element *ml_basic_elem;
 
-       /* The reconfiguration Multi-Link element in the original IEs */
+       /* The reconfiguration Multi-Link element in the original elements */
        const struct element *ml_reconf_elem;
 
        u8 ttlm_num;
index 2c72d4d0fc259834a61bd0cbdee03112454e387a..3be4f4cf12c3414ee5c9ac557cb2fcf966328148 100644 (file)
@@ -5760,7 +5760,7 @@ static void ieee80211_ml_reconfiguration(struct ieee80211_sub_if_data *sdata,
        u8 link_id;
        u32 delay;
 
-       if (!ieee80211_vif_is_mld(&sdata->vif) || !elems->ml_reconf)
+       if (!ieee80211_vif_is_mld(&sdata->vif) || !elems->ml_reconf_elem)
                return;
 
        ml_len = cfg80211_defragment_element(elems->ml_reconf_elem,
@@ -5773,9 +5773,7 @@ static void ieee80211_ml_reconfiguration(struct ieee80211_sub_if_data *sdata,
        if (ml_len < 0)
                return;
 
-       elems->ml_reconf = (const void *)elems->scratch_pos;
-       elems->ml_reconf_len = ml_len;
-       ml = elems->ml_reconf;
+       ml = (const void *)elems->scratch_pos;
 
        /* Directly parse the sub elements as the common information doesn't
         * hold any useful information.
index d231aaecc2199d2af8779d9b69049949e2e6c0c5..8bdf6e7efa58b4ad05a18876bf9607e082b38f51 100644 (file)
@@ -129,19 +129,15 @@ ieee80211_parse_extension_element(u32 *crc,
                        switch (le16_get_bits(mle->control,
                                              IEEE80211_ML_CONTROL_TYPE)) {
                        case IEEE80211_ML_CONTROL_TYPE_BASIC:
-                               if (elems->ml_basic) {
+                               if (elems->ml_basic_elem) {
                                        elems->parse_error |=
                                                IEEE80211_PARSE_ERR_DUP_NEST_ML_BASIC;
                                        break;
                                }
                                elems->ml_basic_elem = (void *)elem;
-                               elems->ml_basic = data;
-                               elems->ml_basic_len = len;
                                break;
                        case IEEE80211_ML_CONTROL_TYPE_RECONF:
                                elems->ml_reconf_elem = (void *)elem;
-                               elems->ml_reconf = data;
-                               elems->ml_reconf_len = len;
                                break;
                        default:
                                break;
@@ -776,9 +772,6 @@ static void ieee80211_mle_parse_link(struct ieee802_11_elems *elems,
        const struct element *non_inherit = NULL;
        const u8 *end;
 
-       if (params->link_id == -1)
-               return;
-
        ml_len = cfg80211_defragment_element(elems->ml_basic_elem,
                                             elems->ie_start,
                                             elems->total_len,
@@ -795,6 +788,9 @@ static void ieee80211_mle_parse_link(struct ieee802_11_elems *elems,
        elems->ml_basic_len = ml_len;
        elems->scratch_pos += ml_len;
 
+       if (params->link_id == -1)
+               return;
+
        ieee80211_mle_get_sta_prof(elems, params->link_id);
        prof = elems->prof;