ac3d1011489a1b3f6fd29149832c52c2df661569
[openwrt/openwrt.git] /
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Thu, 26 Sep 2024 14:07:50 +0200
3 Subject: [PATCH] wifi: mac80211: use vif radio mask to limit creating chanctx
4
5 Reject frequencies not supported by any radio that the vif is allowed to use.
6
7 Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 ---
9
10 --- a/net/mac80211/chan.c
11 +++ b/net/mac80211/chan.c
12 @@ -1167,7 +1167,7 @@ ieee80211_replace_chanctx(struct ieee802
13 static bool
14 ieee80211_find_available_radio(struct ieee80211_local *local,
15 const struct ieee80211_chan_req *chanreq,
16 - int *radio_idx)
17 + u32 radio_mask, int *radio_idx)
18 {
19 struct wiphy *wiphy = local->hw.wiphy;
20 const struct wiphy_radio *radio;
21 @@ -1178,6 +1178,9 @@ ieee80211_find_available_radio(struct ie
22 return true;
23
24 for (i = 0; i < wiphy->n_radio; i++) {
25 + if (!(radio_mask & BIT(i)))
26 + continue;
27 +
28 radio = &wiphy->radio[i];
29 if (!cfg80211_radio_chandef_valid(radio, &chanreq->oper))
30 continue;
31 @@ -1211,7 +1214,9 @@ int ieee80211_link_reserve_chanctx(struc
32 new_ctx = ieee80211_find_reservation_chanctx(local, chanreq, mode);
33 if (!new_ctx) {
34 if (ieee80211_can_create_new_chanctx(local, -1) &&
35 - ieee80211_find_available_radio(local, chanreq, &radio_idx))
36 + ieee80211_find_available_radio(local, chanreq,
37 + sdata->wdev.radio_mask,
38 + &radio_idx))
39 new_ctx = ieee80211_new_chanctx(local, chanreq, mode,
40 false, radio_idx);
41 else
42 @@ -1881,7 +1886,9 @@ int _ieee80211_link_use_channel(struct i
43 /* Note: context is now reserved */
44 if (ctx)
45 reserved = true;
46 - else if (!ieee80211_find_available_radio(local, chanreq, &radio_idx))
47 + else if (!ieee80211_find_available_radio(local, chanreq,
48 + sdata->wdev.radio_mask,
49 + &radio_idx))
50 ctx = ERR_PTR(-EBUSY);
51 else
52 ctx = ieee80211_new_chanctx(local, chanreq, mode,