Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5456012rwd; Sun, 18 Jun 2023 11:51:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4dMwpJQkvTAYMq/Ev5VID6OhYVqosrFUod9Iwjh/l2/g1Qrf72Hiz2+mJA5SlroZbqeYAY X-Received: by 2002:a05:6a20:3d1d:b0:104:ffd0:232a with SMTP id y29-20020a056a203d1d00b00104ffd0232amr18958648pzi.8.1687114313554; Sun, 18 Jun 2023 11:51:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687114313; cv=none; d=google.com; s=arc-20160816; b=NawTlNnOB+nIPRsbSuzE5Uu5tUtbeSL544THW2uKETuCA7XtoP7Au7+JM//DaAEefb Et77x6XS9f2tdHecjdyg+NQWTib0egjHZX8evERFoP7EWVLmijHuqRLWvtV/jmZcPp+k rfAL8GXR4jxCi3Y+efXetibeWUfd/j7MT1q6jNnjbRLm7Q6gtRhjbI5G/V8qxwFAic2q eWFvAr0u3c7gW9+QsCLncsUueMhxrAxg3jGuLhNmx8fdJDeqeH60ItrWYQkDNAxwS7tx UnRd6EF72OmdRcThq1D2thRceNEs1WVAowkIYWaZf7+3UQuoOzMwvcVKd+Fak9RncD35 5x2A== 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=rDDFS+tUe5FuRwLU22q948g7QFNY+hnlYGFVaGlDqSg=; b=vBb2KNGSu/g/cXp1F0ThnEFiZy8FF0Ns33bFUYLDzINmILEafx5bMO+a3ZNZmrs1vT 6oK2PTtiXvjJC02naZoKVaVFW/jsZcesLiVfcO0E7x7LewGRDEhTdZsenLsLYVNPf/Wj +qtT1x+lfPI+zA+SRax38b+nHy+LTA62gC4DXzVUlLUNE3nnt5VPoFeZQJCSOVY7U7Q9 N8kzs0vdUpYQZU5btnlDtxy1tYVNiG81u8N8FRIHxDUzjujXhbWhCuDhghogL/7ubJ4x U5BUBpPV6Twh2jjdkVqzkh5o/doDlRDMcMWz7YO9sRq6tkAAcpgv3eA0+BgWRzILKKqZ VXaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=n9+jZXuv; 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=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z192-20020a6333c9000000b00530b6228f91si7770657pgz.895.2023.06.18.11.51.46; Sun, 18 Jun 2023 11:51:53 -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=@intel.com header.s=Intel header.b=n9+jZXuv; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229676AbjFRSvQ (ORCPT + 61 others); Sun, 18 Jun 2023 14:51:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbjFRSvP (ORCPT ); Sun, 18 Jun 2023 14:51:15 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 406D7E72 for ; Sun, 18 Jun 2023 11:51:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687114264; x=1718650264; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0c2/wKWdYa0n3zzQ8JO5F+2h68IrTvIYwoOFtF9XiBU=; b=n9+jZXuv8mxfvBWBMdMO7q0YKxZ9t9+1m35N4Tq1TM8GcVepI1j95AcY XxnkKaRTA0Rsp5zmBVNn7MMmfnYlXUJ0ZeFTjxdOkoZqNUocn16frdPGo c+EvNg9FxsYQyeemKQ1HOIm60FOyu4cAvEeQGhwtBV59GSN2BHphSBbaa lOueE6/Vk1AU8IJAbQyPTppKJvZQ65P7faar+ZybHKO1dGsCkGLEVVv0t Zah3yXh1dMC9o8XIOPI1pWshwdB+QPUjL3NIOE45rM+YTyGSBFlesMxBc L4HMJfa3kcllpWvKMn7b04Ia23V/1xQ07slAoR9kONnuDTNaaE0olauJi Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10745"; a="339116677" X-IronPort-AV: E=Sophos;i="6.00,253,1681196400"; d="scan'208";a="339116677" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jun 2023 11:51:03 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10745"; a="747234133" X-IronPort-AV: E=Sophos;i="6.00,253,1681196400"; d="scan'208";a="747234133" Received: from aflumen-mobl2.ger.corp.intel.com (HELO ggreenma-mobl2.intel.com) ([10.251.178.161]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jun 2023 11:51:01 -0700 From: gregory.greenman@intel.com To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Benjamin Berg , Gregory Greenman Subject: [PATCH 19/20] wifi: cfg80211: search all RNR elements for colocated APs Date: Sun, 18 Jun 2023 21:50:01 +0300 Message-Id: <20230618214436.ffe2c014f478.I372a4f96c88f7ea28ac39e94e0abfc465b5330d4@changeid> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230618185002.817236-1-gregory.greenman@intel.com> References: <20230618185002.817236-1-gregory.greenman@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE,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: Benjamin Berg An AP reporting colocated APs may send more than one reduced neighbor report element. As such, iterate all elements instead of only parsing the first one when looking for colocated APs. Signed-off-by: Benjamin Berg Signed-off-by: Gregory Greenman --- net/wireless/scan.c | 127 ++++++++++++++++++++++---------------------- 1 file changed, 63 insertions(+), 64 deletions(-) diff --git a/net/wireless/scan.c b/net/wireless/scan.c index b2cf7abd5ad0..465334b3960e 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -643,90 +643,89 @@ static int cfg80211_parse_colocated_ap(const struct cfg80211_bss_ies *ies, int n_coloc = 0, ret; LIST_HEAD(ap_list); - elem = cfg80211_find_elem(WLAN_EID_REDUCED_NEIGHBOR_REPORT, ies->data, - ies->len); - if (!elem) - return 0; - - pos = elem->data; - end = pos + elem->datalen; - ret = cfg80211_calc_short_ssid(ies, &ssid_elem, &s_ssid_tmp); if (ret) return ret; - /* RNR IE may contain more than one NEIGHBOR_AP_INFO */ - while (pos + sizeof(*ap_info) <= end) { - enum nl80211_band band; - int freq; - u8 length, i, count; + for_each_element_id(elem, WLAN_EID_REDUCED_NEIGHBOR_REPORT, + ies->data, ies->len) { + pos = elem->data; + end = elem->data + elem->datalen; - ap_info = (void *)pos; - count = u8_get_bits(ap_info->tbtt_info_hdr, - IEEE80211_AP_INFO_TBTT_HDR_COUNT) + 1; - length = ap_info->tbtt_info_len; + /* RNR IE may contain more than one NEIGHBOR_AP_INFO */ + while (pos + sizeof(*ap_info) <= end) { + enum nl80211_band band; + int freq; + u8 length, i, count; - pos += sizeof(*ap_info); + ap_info = (void *)pos; + count = u8_get_bits(ap_info->tbtt_info_hdr, + IEEE80211_AP_INFO_TBTT_HDR_COUNT) + 1; + length = ap_info->tbtt_info_len; - if (!ieee80211_operating_class_to_band(ap_info->op_class, - &band)) - break; + pos += sizeof(*ap_info); - freq = ieee80211_channel_to_frequency(ap_info->channel, band); + if (!ieee80211_operating_class_to_band(ap_info->op_class, + &band)) + break; - if (end - pos < count * length) - break; + freq = ieee80211_channel_to_frequency(ap_info->channel, + band); - if (u8_get_bits(ap_info->tbtt_info_hdr, - IEEE80211_AP_INFO_TBTT_HDR_TYPE) != - IEEE80211_TBTT_INFO_TYPE_TBTT) { - pos += count * length; - continue; - } + if (end - pos < count * length) + break; - /* - * TBTT info must include bss param + BSSID + - * (short SSID or same_ssid bit to be set). - * ignore other options, and move to the - * next AP info - */ - if (band != NL80211_BAND_6GHZ || - !(length == offsetofend(struct ieee80211_tbtt_info_7_8_9, - bss_params) || - length == sizeof(struct ieee80211_tbtt_info_7_8_9) || - length >= offsetofend(struct ieee80211_tbtt_info_ge_11, - bss_params))) { - pos += count * length; - continue; - } + if (u8_get_bits(ap_info->tbtt_info_hdr, + IEEE80211_AP_INFO_TBTT_HDR_TYPE) != + IEEE80211_TBTT_INFO_TYPE_TBTT) { + pos += count * length; + continue; + } - for (i = 0; i < count; i++) { - struct cfg80211_colocated_ap *entry; + /* TBTT info must include bss param + BSSID + + * (short SSID or same_ssid bit to be set). + * ignore other options, and move to the + * next AP info + */ + if (band != NL80211_BAND_6GHZ || + !(length == offsetofend(struct ieee80211_tbtt_info_7_8_9, + bss_params) || + length == sizeof(struct ieee80211_tbtt_info_7_8_9) || + length >= offsetofend(struct ieee80211_tbtt_info_ge_11, + bss_params))) { + pos += count * length; + continue; + } - entry = kzalloc(sizeof(*entry) + IEEE80211_MAX_SSID_LEN, - GFP_ATOMIC); + for (i = 0; i < count; i++) { + struct cfg80211_colocated_ap *entry; - if (!entry) - goto error; + entry = kzalloc(sizeof(*entry) + IEEE80211_MAX_SSID_LEN, + GFP_ATOMIC); - entry->center_freq = freq; + if (!entry) + goto error; - if (!cfg80211_parse_ap_info(entry, pos, length, - ssid_elem, s_ssid_tmp)) { - n_coloc++; - list_add_tail(&entry->list, &ap_list); - } else { - kfree(entry); - } + entry->center_freq = freq; + + if (!cfg80211_parse_ap_info(entry, pos, length, + ssid_elem, + s_ssid_tmp)) { + n_coloc++; + list_add_tail(&entry->list, &ap_list); + } else { + kfree(entry); + } - pos += length; + pos += length; + } } - } error: - if (pos != end) { - cfg80211_free_coloc_ap_list(&ap_list); - return 0; + if (pos != end) { + cfg80211_free_coloc_ap_list(&ap_list); + return 0; + } } list_splice_tail(&ap_list, list); -- 2.38.1