developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1 | From aaa8ad411db97a885da1d3a7f925df38df294f75 Mon Sep 17 00:00:00 2001 |
| 2 | From: Michael-CY Lee <michael-cy.lee@mediatek.com> |
| 3 | Date: Thu, 9 May 2024 09:24:43 +0800 |
| 4 | Subject: [PATCH 68/89] mtk: mac80211: legacy AP scan request should contain |
| 5 | valid channels |
| 6 | |
| 7 | In single-wiphy, if scan_freqs is not specified in scan request, |
| 8 | mac80211 will trigger a scan that includes all bands. |
| 9 | However, legacy AP should only scan the channels of its operating band. |
| 10 | |
| 11 | This commit adds the checks for including valid channels in legacy AP |
| 12 | scan. |
| 13 | |
| 14 | Signed-off-by: Michael-CY Lee <michael-cy.lee@mediatek.com> |
| 15 | |
| 16 | preset_chandef is only set on the first wdev of each phy, so we refer to |
| 17 | another data structure for the band of current wdev. |
| 18 | |
| 19 | Signed-off-by: Michael-CY Lee <michael-cy.lee@mediatek.com> |
| 20 | --- |
| 21 | net/wireless/nl80211.c | 21 +++++++++++++++++++++ |
| 22 | 1 file changed, 21 insertions(+) |
| 23 | |
| 24 | diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c |
| 25 | index ea251a9..cb14460 100644 |
| 26 | --- a/net/wireless/nl80211.c |
| 27 | +++ b/net/wireless/nl80211.c |
| 28 | @@ -9382,6 +9382,12 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info) |
| 29 | n_channels = validate_scan_freqs(scan_freqs); |
| 30 | if (!n_channels) |
| 31 | return -EINVAL; |
| 32 | + } else if (wdev->iftype == NL80211_IFTYPE_AP && !wdev->valid_links) { |
| 33 | + struct ieee80211_channel *chan = wdev->links[0].ap.chandef.chan; |
| 34 | + if (!chan || !wiphy->bands[chan->band]) |
| 35 | + return -EINVAL; |
| 36 | + |
| 37 | + n_channels = wiphy->bands[chan->band]->n_channels; |
| 38 | } else { |
| 39 | n_channels = ieee80211_get_num_supported_channels(wiphy); |
| 40 | } |
| 41 | @@ -9434,6 +9440,21 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info) |
| 42 | } |
| 43 | |
| 44 | /* ignore disabled channels */ |
| 45 | + if (chan->flags & IEEE80211_CHAN_DISABLED) |
| 46 | + continue; |
| 47 | + |
| 48 | + request->channels[i] = chan; |
| 49 | + i++; |
| 50 | + } |
| 51 | + } else if (wdev->iftype == NL80211_IFTYPE_AP && !wdev->valid_links) { |
| 52 | + enum nl80211_band band = wdev->links[0].ap.chandef.chan->band; |
| 53 | + int j; |
| 54 | + |
| 55 | + for (j = 0; j < wiphy->bands[band]->n_channels; j++) { |
| 56 | + struct ieee80211_channel *chan; |
| 57 | + |
| 58 | + chan = &wiphy->bands[band]->channels[j]; |
| 59 | + |
| 60 | if (chan->flags & IEEE80211_CHAN_DISABLED) |
| 61 | continue; |
| 62 | |
| 63 | -- |
| 64 | 2.18.0 |
| 65 | |