Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp508668imw; Wed, 13 Jul 2022 02:48:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s14zhZbafOpsvWvA6D7qrwH9Ye1hX/FQkjT8UuuJ+xan3+zeBU9LIjiD+/Ab23jHDxmv9m X-Received: by 2002:a05:6a02:30d:b0:412:9de2:eb48 with SMTP id bn13-20020a056a02030d00b004129de2eb48mr2222071pgb.47.1657705727307; Wed, 13 Jul 2022 02:48:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657705727; cv=none; d=google.com; s=arc-20160816; b=J+0UxYSf+bA1b2EWUWMDNxOuSndIHHehvgiPnWluwZT1zBhfBVqK2WTj+cfb3xT7SY 3XiWmHmZM8R70fJ/OJ6GqtTGKWsP9ZIOadNz/ZM3ek3G1/HArPeH8X8H1OyUe7lle3P9 0Oiw1gBFrLnfj9UKWL4wkbVwFy9rmkY7udh+rEAIBdvJGyV90NMnPda+C33bPT4S/b91 VZ16qP7zelpyhcxfug/9dDxIwudCGWZAraW6PgwUTdjlLQsh3S3pWXqYanitiwWS7TzL jB+8eqo91yTTJm6GpHGpTQurE0yoFkySMsK8nn+Pyd/+a+BDITOeNW+EMwAPONlqz8px WaEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jdhcQglGBX/kKsb3TZgWVbsR9yCMB8Mf1eGS4DXYiZM=; b=OsVyK6ERYHB1LnehD9CdTZLDKp4YlOLXBLJo0tJxj0qJ7XgkWUAQJ2DZmwW4Ljiy6e RYfvrll1MVuPhh4BGz3iDgO8lWFDipX92mPK4/zqMbnOpdifZVGXwQ7hwphR1g8KJjC3 5ZOmP9/Oz8jDdzU5r33gKns87S8FX+IplkkhLtMbcxrTy489joRX0UM59yop8MfFggix GbF7YDw2KAWC0EkOPcWP7lC9HJIMkXDSzK6LwrWdrLF94zt9olDWA+AaGAA5gtb+J00l YTUeQWg6ZpqolE3YwTVTCqIHXibT0CMXmpD70EXUeB4WFgLoFZrocIguXSPIgBbQG9rG U02Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=H38exBtP; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e6-20020a170902ef4600b0016c6988d23asi3350670plx.370.2022.07.13.02.48.39; Wed, 13 Jul 2022 02:48:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=H38exBtP; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235991AbiGMJqc (ORCPT + 65 others); Wed, 13 Jul 2022 05:46:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236234AbiGMJpd (ORCPT ); Wed, 13 Jul 2022 05:45:33 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8A09F6830 for ; Wed, 13 Jul 2022 02:45:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=jdhcQglGBX/kKsb3TZgWVbsR9yCMB8Mf1eGS4DXYiZM=; t=1657705525; x=1658915125; b=H38exBtPdqQJeyKT5vKmwjeqZiFZjOpCIyZL9aYIAfOtFol v6UAf9JWAZ3EtavOs4tWQwZCFzkDzRVOxpGeolpT5vfn0kfuVttADPcx92os8J11ceIgZUg9ohgoz +x1jBKNS7WucDyCSAUxeuB2kXsyB3ntJcLufgmE61Wc6n0g8P9WqKIuzBRSMtjqzvDCDSdwf/eRjL ipP3EhNdlyniSpVuESSRC0TOVsB1vMWxc33jjRejCBEpaqGpBuCS+mpYNaxhfxK63JtlcTpneidyX XJ584DbEKU1l29z9tie8bqJT6MOfSYIm5woOL20d9a6o/2z7o9C5qxjh+gb+w4cw==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.95) (envelope-from ) id 1oBYvr-00EgvB-T2; Wed, 13 Jul 2022 11:45:24 +0200 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg Subject: [PATCH 54/76] wifi: mac80211: refactor adding custom elements Date: Wed, 13 Jul 2022 11:44:40 +0200 Message-Id: <20220713114425.a5f550da0b0a.Icbed923cede8717295b8c651af8a524ebc48dbb6@changeid> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220713094502.163926-1-johannes@sipsolutions.net> References: <20220713094502.163926-1-johannes@sipsolutions.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg Rework the sorting of custom elements into the association request by moving the elements before HT/VHT/HE to each their own function. While at it, fix the placement of the ones that should be between VHT and HE. This doesn't fix the placement of elements that should be between HE and EHT yet, a similar change might be needed in the future. Signed-off-by: Johannes Berg --- net/mac80211/mlme.c | 212 ++++++++++++++++++++++++++------------------ 1 file changed, 125 insertions(+), 87 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index a442de3670b9..36cce750528a 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -839,6 +839,120 @@ static void ieee80211_assoc_add_rates(struct sk_buff *skb, } } +static size_t ieee80211_add_before_ht_elems(struct sk_buff *skb, + const u8 *elems, + size_t elems_len, + size_t offset) +{ + size_t noffset; + + static const u8 before_ht[] = { + WLAN_EID_SSID, + WLAN_EID_SUPP_RATES, + WLAN_EID_EXT_SUPP_RATES, + WLAN_EID_PWR_CAPABILITY, + WLAN_EID_SUPPORTED_CHANNELS, + WLAN_EID_RSN, + WLAN_EID_QOS_CAPA, + WLAN_EID_RRM_ENABLED_CAPABILITIES, + WLAN_EID_MOBILITY_DOMAIN, + WLAN_EID_FAST_BSS_TRANSITION, /* reassoc only */ + WLAN_EID_RIC_DATA, /* reassoc only */ + WLAN_EID_SUPPORTED_REGULATORY_CLASSES, + }; + static const u8 after_ric[] = { + WLAN_EID_SUPPORTED_REGULATORY_CLASSES, + WLAN_EID_HT_CAPABILITY, + WLAN_EID_BSS_COEX_2040, + /* luckily this is almost always there */ + WLAN_EID_EXT_CAPABILITY, + WLAN_EID_QOS_TRAFFIC_CAPA, + WLAN_EID_TIM_BCAST_REQ, + WLAN_EID_INTERWORKING, + /* 60 GHz (Multi-band, DMG, MMS) can't happen */ + WLAN_EID_VHT_CAPABILITY, + WLAN_EID_OPMODE_NOTIF, + }; + + if (!elems_len) + return offset; + + noffset = ieee80211_ie_split_ric(elems, elems_len, + before_ht, + ARRAY_SIZE(before_ht), + after_ric, + ARRAY_SIZE(after_ric), + offset); + skb_put_data(skb, elems + offset, noffset - offset); + + return noffset; +} + +static size_t ieee80211_add_before_vht_elems(struct sk_buff *skb, + const u8 *elems, + size_t elems_len, + size_t offset) +{ + static const u8 before_vht[] = { + /* + * no need to list the ones split off before HT + * or generated here + */ + WLAN_EID_BSS_COEX_2040, + WLAN_EID_EXT_CAPABILITY, + WLAN_EID_QOS_TRAFFIC_CAPA, + WLAN_EID_TIM_BCAST_REQ, + WLAN_EID_INTERWORKING, + /* 60 GHz (Multi-band, DMG, MMS) can't happen */ + }; + size_t noffset; + + if (!elems_len) + return offset; + + /* RIC already taken care of in ieee80211_add_before_ht_elems() */ + noffset = ieee80211_ie_split(elems, elems_len, + before_vht, ARRAY_SIZE(before_vht), + offset); + skb_put_data(skb, elems + offset, noffset - offset); + + return noffset; +} + +static size_t ieee80211_add_before_he_elems(struct sk_buff *skb, + const u8 *elems, + size_t elems_len, + size_t offset) +{ + static const u8 before_he[] = { + /* + * no need to list the ones split off before VHT + * or generated here + */ + WLAN_EID_OPMODE_NOTIF, + WLAN_EID_EXTENSION, WLAN_EID_EXT_FUTURE_CHAN_GUIDANCE, + /* 11ai elements */ + WLAN_EID_EXTENSION, WLAN_EID_EXT_FILS_SESSION, + WLAN_EID_EXTENSION, WLAN_EID_EXT_FILS_PUBLIC_KEY, + WLAN_EID_EXTENSION, WLAN_EID_EXT_FILS_KEY_CONFIRM, + WLAN_EID_EXTENSION, WLAN_EID_EXT_FILS_HLP_CONTAINER, + WLAN_EID_EXTENSION, WLAN_EID_EXT_FILS_IP_ADDR_ASSIGN, + /* TODO: add 11ah/11aj/11ak elements */ + }; + size_t noffset; + + if (!elems_len) + return offset; + + /* RIC already taken care of in ieee80211_add_before_ht_elems() */ + noffset = ieee80211_ie_split(elems, elems_len, + before_he, ARRAY_SIZE(before_he), + offset); + skb_put_data(skb, elems + offset, noffset - offset); + + return noffset; +} + static int ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) { struct ieee80211_local *local = sdata->local; @@ -994,45 +1108,9 @@ static int ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) ext_capa->data[2] |= WLAN_EXT_CAPA3_MULTI_BSSID_SUPPORT; /* if present, add any custom IEs that go before HT */ - if (assoc_data->ie_len) { - static const u8 before_ht[] = { - WLAN_EID_SSID, - WLAN_EID_SUPP_RATES, - WLAN_EID_EXT_SUPP_RATES, - WLAN_EID_PWR_CAPABILITY, - WLAN_EID_SUPPORTED_CHANNELS, - WLAN_EID_RSN, - WLAN_EID_QOS_CAPA, - WLAN_EID_RRM_ENABLED_CAPABILITIES, - WLAN_EID_MOBILITY_DOMAIN, - WLAN_EID_FAST_BSS_TRANSITION, /* reassoc only */ - WLAN_EID_RIC_DATA, /* reassoc only */ - WLAN_EID_SUPPORTED_REGULATORY_CLASSES, - }; - static const u8 after_ric[] = { - WLAN_EID_SUPPORTED_REGULATORY_CLASSES, - WLAN_EID_HT_CAPABILITY, - WLAN_EID_BSS_COEX_2040, - /* luckily this is almost always there */ - WLAN_EID_EXT_CAPABILITY, - WLAN_EID_QOS_TRAFFIC_CAPA, - WLAN_EID_TIM_BCAST_REQ, - WLAN_EID_INTERWORKING, - /* 60 GHz (Multi-band, DMG, MMS) can't happen */ - WLAN_EID_VHT_CAPABILITY, - WLAN_EID_OPMODE_NOTIF, - }; - - noffset = ieee80211_ie_split_ric(assoc_data->ie, - assoc_data->ie_len, - before_ht, - ARRAY_SIZE(before_ht), - after_ric, - ARRAY_SIZE(after_ric), - offset); - skb_put_data(skb, assoc_data->ie + offset, noffset - offset); - offset = noffset; - } + offset = ieee80211_add_before_ht_elems(skb, assoc_data->ie, + assoc_data->ie_len, + offset); if (WARN_ON_ONCE((link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_HT) && !(link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_VHT))) @@ -1044,54 +1122,9 @@ static int ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) sband, chan, link->smps_mode); /* if present, add any custom IEs that go before VHT */ - if (assoc_data->ie_len) { - static const u8 before_vht[] = { - /* - * no need to list the ones split off before HT - * or generated here - */ - WLAN_EID_BSS_COEX_2040, - WLAN_EID_EXT_CAPABILITY, - WLAN_EID_QOS_TRAFFIC_CAPA, - WLAN_EID_TIM_BCAST_REQ, - WLAN_EID_INTERWORKING, - /* 60 GHz (Multi-band, DMG, MMS) can't happen */ - }; - - /* RIC already taken above, so no need to handle here anymore */ - noffset = ieee80211_ie_split(assoc_data->ie, assoc_data->ie_len, - before_vht, ARRAY_SIZE(before_vht), - offset); - skb_put_data(skb, assoc_data->ie + offset, noffset - offset); - offset = noffset; - } - - /* if present, add any custom IEs that go before HE */ - if (assoc_data->ie_len) { - static const u8 before_he[] = { - /* - * no need to list the ones split off before VHT - * or generated here - */ - WLAN_EID_OPMODE_NOTIF, - WLAN_EID_EXTENSION, WLAN_EID_EXT_FUTURE_CHAN_GUIDANCE, - /* 11ai elements */ - WLAN_EID_EXTENSION, WLAN_EID_EXT_FILS_SESSION, - WLAN_EID_EXTENSION, WLAN_EID_EXT_FILS_PUBLIC_KEY, - WLAN_EID_EXTENSION, WLAN_EID_EXT_FILS_KEY_CONFIRM, - WLAN_EID_EXTENSION, WLAN_EID_EXT_FILS_HLP_CONTAINER, - WLAN_EID_EXTENSION, WLAN_EID_EXT_FILS_IP_ADDR_ASSIGN, - /* TODO: add 11ah/11aj/11ak elements */ - }; - - /* RIC already taken above, so no need to handle here anymore */ - noffset = ieee80211_ie_split(assoc_data->ie, assoc_data->ie_len, - before_he, ARRAY_SIZE(before_he), - offset); - pos = skb_put(skb, noffset - offset); - memcpy(pos, assoc_data->ie + offset, noffset - offset); - offset = noffset; - } + offset = ieee80211_add_before_vht_elems(skb, assoc_data->ie, + assoc_data->ie_len, + offset); if (sband->band != NL80211_BAND_6GHZ && !(link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_VHT)) @@ -1108,6 +1141,11 @@ static int ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) link->u.mgd.conn_flags |= IEEE80211_CONN_DISABLE_HE | IEEE80211_CONN_DISABLE_EHT; + /* if present, add any custom IEs that go before HE */ + offset = ieee80211_add_before_he_elems(skb, assoc_data->ie, + assoc_data->ie_len, + offset); + if (!(link->u.mgd.conn_flags & IEEE80211_CONN_DISABLE_HE)) { ieee80211_add_he_ie(link, skb, sband); -- 2.36.1