mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-09 23:00:21 +00:00
wifi: mac80211: use cfg80211 defragmentation helper
Use the shared functionality rather than copying it into mac80211. Signed-off-by: Benjamin Berg <benjamin.berg@intel.com> Signed-off-by: Gregory Greenman <gregory.greenman@intel.com> Link: https://lore.kernel.org/r/20230616094949.7dcbf82baade.Ic68d1f547cb75d66037abdbb0f066db20ff41ba3@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
f837a653a0
commit
a76236de58
@ -1752,6 +1752,8 @@ struct ieee802_11_elems {
|
|||||||
|
|
||||||
/* mult-link element can be de-fragmented and thus u8 is not sufficient */
|
/* mult-link element can be de-fragmented and thus u8 is not sufficient */
|
||||||
size_t multi_link_len;
|
size_t multi_link_len;
|
||||||
|
/* The element in the original IEs */
|
||||||
|
const struct element *multi_link_elem;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* store the per station profile pointer and length in case that the
|
* store the per station profile pointer and length in case that the
|
||||||
|
@ -984,6 +984,7 @@ ieee80211_parse_extension_element(u32 *crc,
|
|||||||
break;
|
break;
|
||||||
case WLAN_EID_EXT_EHT_MULTI_LINK:
|
case WLAN_EID_EXT_EHT_MULTI_LINK:
|
||||||
if (ieee80211_mle_size_ok(data, len)) {
|
if (ieee80211_mle_size_ok(data, len)) {
|
||||||
|
elems->multi_link_elem = (void *)elem;
|
||||||
elems->multi_link = (void *)data;
|
elems->multi_link = (void *)data;
|
||||||
elems->multi_link_len = len;
|
elems->multi_link_len = len;
|
||||||
}
|
}
|
||||||
@ -1458,56 +1459,11 @@ static size_t ieee802_11_find_bssid_profile(const u8 *start, size_t len,
|
|||||||
return found ? profile_len : 0;
|
return found ? profile_len : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ieee80211_defragment_element(struct ieee802_11_elems *elems,
|
|
||||||
void **elem_ptr, size_t *len,
|
|
||||||
size_t total_len, u8 frag_id)
|
|
||||||
{
|
|
||||||
u8 *data = *elem_ptr, *pos, *start;
|
|
||||||
const struct element *elem;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Since 'data' points to the data of the element, not the element
|
|
||||||
* itself, allow 254 in case it was an extended element where the
|
|
||||||
* extended ID isn't part of the data we see here and thus not part of
|
|
||||||
* 'len' either.
|
|
||||||
*/
|
|
||||||
if (!data || (*len != 254 && *len != 255))
|
|
||||||
return;
|
|
||||||
|
|
||||||
start = elems->scratch_pos;
|
|
||||||
|
|
||||||
if (WARN_ON(*len > (elems->scratch + elems->scratch_len -
|
|
||||||
elems->scratch_pos)))
|
|
||||||
return;
|
|
||||||
|
|
||||||
memcpy(elems->scratch_pos, data, *len);
|
|
||||||
elems->scratch_pos += *len;
|
|
||||||
|
|
||||||
pos = data + *len;
|
|
||||||
total_len -= *len;
|
|
||||||
for_each_element(elem, pos, total_len) {
|
|
||||||
if (elem->id != frag_id)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (WARN_ON(elem->datalen >
|
|
||||||
(elems->scratch + elems->scratch_len -
|
|
||||||
elems->scratch_pos)))
|
|
||||||
return;
|
|
||||||
|
|
||||||
memcpy(elems->scratch_pos, elem->data, elem->datalen);
|
|
||||||
elems->scratch_pos += elem->datalen;
|
|
||||||
|
|
||||||
*len += elem->datalen;
|
|
||||||
}
|
|
||||||
|
|
||||||
*elem_ptr = start;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ieee80211_mle_get_sta_prof(struct ieee802_11_elems *elems,
|
static void ieee80211_mle_get_sta_prof(struct ieee802_11_elems *elems,
|
||||||
u8 link_id)
|
u8 link_id)
|
||||||
{
|
{
|
||||||
const struct ieee80211_multi_link_elem *ml = elems->multi_link;
|
const struct ieee80211_multi_link_elem *ml = elems->multi_link;
|
||||||
size_t ml_len = elems->multi_link_len;
|
ssize_t ml_len = elems->multi_link_len;
|
||||||
const struct element *sub;
|
const struct element *sub;
|
||||||
|
|
||||||
if (!ml || !ml_len)
|
if (!ml || !ml_len)
|
||||||
@ -1519,6 +1475,7 @@ static void ieee80211_mle_get_sta_prof(struct ieee802_11_elems *elems,
|
|||||||
|
|
||||||
for_each_mle_subelement(sub, (u8 *)ml, ml_len) {
|
for_each_mle_subelement(sub, (u8 *)ml, ml_len) {
|
||||||
struct ieee80211_mle_per_sta_profile *prof = (void *)sub->data;
|
struct ieee80211_mle_per_sta_profile *prof = (void *)sub->data;
|
||||||
|
ssize_t sta_prof_len;
|
||||||
u16 control;
|
u16 control;
|
||||||
|
|
||||||
if (sub->id != IEEE80211_MLE_SUBELEM_PER_STA_PROFILE)
|
if (sub->id != IEEE80211_MLE_SUBELEM_PER_STA_PROFILE)
|
||||||
@ -1536,14 +1493,23 @@ static void ieee80211_mle_get_sta_prof(struct ieee802_11_elems *elems,
|
|||||||
if (!(control & IEEE80211_MLE_STA_CONTROL_COMPLETE_PROFILE))
|
if (!(control & IEEE80211_MLE_STA_CONTROL_COMPLETE_PROFILE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
elems->prof = prof;
|
|
||||||
elems->sta_prof_len = sub->datalen;
|
|
||||||
|
|
||||||
/* the sub element can be fragmented */
|
/* the sub element can be fragmented */
|
||||||
ieee80211_defragment_element(elems, (void **)&elems->prof,
|
sta_prof_len =
|
||||||
&elems->sta_prof_len,
|
cfg80211_defragment_element(sub,
|
||||||
ml_len - (sub->data - (u8 *)ml),
|
(u8 *)ml, ml_len,
|
||||||
IEEE80211_MLE_SUBELEM_FRAGMENT);
|
elems->scratch_pos,
|
||||||
|
elems->scratch +
|
||||||
|
elems->scratch_len -
|
||||||
|
elems->scratch_pos,
|
||||||
|
IEEE80211_MLE_SUBELEM_FRAGMENT);
|
||||||
|
|
||||||
|
if (sta_prof_len < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
elems->prof = (void *)elems->scratch_pos;
|
||||||
|
elems->sta_prof_len = sta_prof_len;
|
||||||
|
elems->scratch_pos += sta_prof_len;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1557,17 +1523,28 @@ static void ieee80211_mle_parse_link(struct ieee802_11_elems *elems,
|
|||||||
.from_ap = params->from_ap,
|
.from_ap = params->from_ap,
|
||||||
.link_id = -1,
|
.link_id = -1,
|
||||||
};
|
};
|
||||||
|
ssize_t ml_len = elems->multi_link_len;
|
||||||
const struct element *non_inherit = NULL;
|
const struct element *non_inherit = NULL;
|
||||||
const u8 *end;
|
const u8 *end;
|
||||||
|
|
||||||
if (params->link_id == -1)
|
if (params->link_id == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ieee80211_defragment_element(elems, (void **)&elems->multi_link,
|
ml_len = cfg80211_defragment_element(elems->multi_link_elem,
|
||||||
&elems->multi_link_len,
|
elems->ie_start,
|
||||||
elems->total_len - ((u8 *)elems->multi_link -
|
elems->total_len,
|
||||||
elems->ie_start),
|
elems->scratch_pos,
|
||||||
WLAN_EID_FRAGMENT);
|
elems->scratch +
|
||||||
|
elems->scratch_len -
|
||||||
|
elems->scratch_pos,
|
||||||
|
WLAN_EID_FRAGMENT);
|
||||||
|
|
||||||
|
if (ml_len < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
elems->multi_link = (const void *)elems->scratch_pos;
|
||||||
|
elems->multi_link_len = ml_len;
|
||||||
|
elems->scratch_pos += ml_len;
|
||||||
|
|
||||||
ieee80211_mle_get_sta_prof(elems, params->link_id);
|
ieee80211_mle_get_sta_prof(elems, params->link_id);
|
||||||
prof = elems->prof;
|
prof = elems->prof;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user