Re: [PATCH v2 11/22] cfg80211: parse S1G Operation element for BSS channel

Johannes Berg
2020-09-18T10:46:03Z

On Mon, 2020-08-31 at 13:55 -0700, Thomas Pedersen wrote:
> Extract the BSS primary channel from the S1G Operation
> element.

Out of curiosity, do you even need to?

I mean ... you know what channel you received it on, surely?

> @@ -1318,15 +1318,26 @@ cfg80211_get_bss_channel(struct wiphy *wiphy, const u8 *ie, size_t ielen,
> tmp = cfg80211_find_ie(WLAN_EID_DS_PARAMS, ie, ielen);
> if (tmp && tmp[1] == 1) {
> channel_number = tmp[2];
> - } else {
> - tmp = cfg80211_find_ie(WLAN_EID_HT_OPERATION, ie, ielen);
> - if (tmp && tmp[1] >= sizeof(struct ieee80211_ht_operation)) {
> - struct ieee80211_ht_operation *htop = (void *)(tmp + 2);
> + goto found_channel;
> + }
>
> - channel_number = htop->primary_chan;
> - }
> + tmp = cfg80211_find_ie(WLAN_EID_HT_OPERATION, ie, ielen);
> + if (tmp && tmp[1] >= sizeof(struct ieee80211_ht_operation)) {
> + struct ieee80211_ht_operation *htop = (void *)(tmp + 2);
> +
> + channel_number = htop->primary_chan;
> + goto found_channel;
> + }
> +
> + tmp = cfg80211_find_ie(WLAN_EID_S1G_OPERATION, ie, ielen);
> + if (tmp && tmp[1] >= sizeof(struct ieee80211_s1g_oper_ie)) {
> + struct ieee80211_s1g_oper_ie *s1gop = (void *)(tmp + 2);
> +
> + channel_number = s1gop->primary_ch;
> + goto found_channel;
> }

I *am* a bit worried about this though - do you really want to try to
parse DS elements on S1G, or S1G elements on other bands? Seems like
there ought to be a band check here?

johannes