7363c3873f6a2e42df514ea388027fbc2152dffc
[openwrt/openwrt.git] /
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Thu, 26 Sep 2024 14:06:11 +0200
3 Subject: [PATCH] wifi: mac80211: use vif radio mask to limit ibss scan
4 frequencies
5
6 Reject frequencies not supported by any radio that the vif is allowed to use.
7
8 Signed-off-by: Felix Fietkau <nbd@nbd.name>
9 ---
10
11 --- a/net/mac80211/scan.c
12 +++ b/net/mac80211/scan.c
13 @@ -1178,14 +1178,14 @@ int ieee80211_request_ibss_scan(struct i
14 unsigned int n_channels)
15 {
16 struct ieee80211_local *local = sdata->local;
17 - int ret = -EBUSY, i, n_ch = 0;
18 + int i, n_ch = 0;
19 enum nl80211_band band;
20
21 lockdep_assert_wiphy(local->hw.wiphy);
22
23 /* busy scanning */
24 if (local->scan_req)
25 - goto unlock;
26 + return -EBUSY;
27
28 /* fill internal scan request */
29 if (!channels) {
30 @@ -1202,7 +1202,9 @@ int ieee80211_request_ibss_scan(struct i
31 &local->hw.wiphy->bands[band]->channels[i];
32
33 if (tmp_ch->flags & (IEEE80211_CHAN_NO_IR |
34 - IEEE80211_CHAN_DISABLED))
35 + IEEE80211_CHAN_DISABLED) ||
36 + !cfg80211_wdev_channel_allowed(&sdata->wdev,
37 + tmp_ch))
38 continue;
39
40 local->int_scan_req->channels[n_ch] = tmp_ch;
41 @@ -1211,21 +1213,23 @@ int ieee80211_request_ibss_scan(struct i
42 }
43
44 if (WARN_ON_ONCE(n_ch == 0))
45 - goto unlock;
46 + return -EINVAL;
47
48 local->int_scan_req->n_channels = n_ch;
49 } else {
50 for (i = 0; i < n_channels; i++) {
51 if (channels[i]->flags & (IEEE80211_CHAN_NO_IR |
52 - IEEE80211_CHAN_DISABLED))
53 + IEEE80211_CHAN_DISABLED) ||
54 + !cfg80211_wdev_channel_allowed(&sdata->wdev,
55 + channels[i]))
56 continue;
57
58 local->int_scan_req->channels[n_ch] = channels[i];
59 n_ch++;
60 }
61
62 - if (WARN_ON_ONCE(n_ch == 0))
63 - goto unlock;
64 + if (n_ch == 0)
65 + return -EINVAL;
66
67 local->int_scan_req->n_channels = n_ch;
68 }
69 @@ -1235,9 +1239,7 @@ int ieee80211_request_ibss_scan(struct i
70 memcpy(local->int_scan_req->ssids[0].ssid, ssid, IEEE80211_MAX_SSID_LEN);
71 local->int_scan_req->ssids[0].ssid_len = ssid_len;
72
73 - ret = __ieee80211_start_scan(sdata, sdata->local->int_scan_req);
74 - unlock:
75 - return ret;
76 + return __ieee80211_start_scan(sdata, sdata->local->int_scan_req);
77 }
78
79 void ieee80211_scan_cancel(struct ieee80211_local *local)