Skip to content

Commit f4489eb

Browse files
Michal Kaziorjmberg-intel
authored andcommitted
cfg80211: add channel tracking for AP and mesh
We need to know which channel is used by a running AP and mesh for channel context accounting and finding matching/active interface combination. STA/IBSS have current_bss already which allows us to check which channel a vif is tuned to. Non-fixed channel IBSS can be handled with additional changes. Monitor mode is going to be handled differently. Signed-off-by: Michal Kazior <michal.kazior@tieto.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent ac80014 commit f4489eb

5 files changed

Lines changed: 22 additions & 5 deletions

File tree

‎include/net/cfg80211.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2408,6 +2408,9 @@ struct wireless_dev {
24082408
struct ieee80211_channel *preset_chan;
24092409
enum nl80211_channel_type preset_chantype;
24102410

2411+
/* for AP and mesh channel tracking */
2412+
struct ieee80211_channel *channel;
2413+
24112414
bool ps;
24122415
int ps_timeout;
24132416

‎net/wireless/ap.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ static int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
2424
return -ENOENT;
2525

2626
err = rdev->ops->stop_ap(&rdev->wiphy, dev);
27-
if (!err)
27+
if (!err) {
2828
wdev->beacon_interval = 0;
29+
wdev->channel = NULL;
30+
}
2931

3032
return err;
3133
}

‎net/wireless/mesh.c‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev,
159159
if (!err) {
160160
memcpy(wdev->ssid, setup->mesh_id, setup->mesh_id_len);
161161
wdev->mesh_id_len = setup->mesh_id_len;
162+
wdev->channel = setup->channel;
162163
}
163164

164165
return err;
@@ -184,6 +185,7 @@ int cfg80211_set_mesh_freq(struct cfg80211_registered_device *rdev,
184185
enum nl80211_channel_type channel_type)
185186
{
186187
struct ieee80211_channel *channel;
188+
int err;
187189

188190
channel = rdev_freq_to_chan(rdev, freq, channel_type);
189191
if (!channel || !cfg80211_can_beacon_sec_chan(&rdev->wiphy,
@@ -205,9 +207,14 @@ int cfg80211_set_mesh_freq(struct cfg80211_registered_device *rdev,
205207

206208
if (!netif_running(wdev->netdev))
207209
return -ENETDOWN;
208-
return rdev->ops->libertas_set_mesh_channel(&rdev->wiphy,
209-
wdev->netdev,
210-
channel);
210+
211+
err = rdev->ops->libertas_set_mesh_channel(&rdev->wiphy,
212+
wdev->netdev,
213+
channel);
214+
if (!err)
215+
wdev->channel = channel;
216+
217+
return err;
211218
}
212219

213220
if (wdev->mesh_id_len)
@@ -249,8 +256,11 @@ static int __cfg80211_leave_mesh(struct cfg80211_registered_device *rdev,
249256
return -ENOTCONN;
250257

251258
err = rdev->ops->leave_mesh(&rdev->wiphy, dev);
252-
if (!err)
259+
if (!err) {
253260
wdev->mesh_id_len = 0;
261+
wdev->channel = NULL;
262+
}
263+
254264
return err;
255265
}
256266

‎net/wireless/mlme.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,7 @@ void cfg80211_ch_switch_notify(struct net_device *dev, int freq,
947947
if (WARN_ON(!chan))
948948
goto out;
949949

950+
wdev->channel = chan;
950951
nl80211_ch_switch_notify(rdev, dev, freq, type, GFP_KERNEL);
951952
out:
952953
wdev_unlock(wdev);

‎net/wireless/nl80211.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,6 +2488,7 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
24882488
wdev->preset_chan = params.channel;
24892489
wdev->preset_chantype = params.channel_type;
24902490
wdev->beacon_interval = params.beacon_interval;
2491+
wdev->channel = params.channel;
24912492
}
24922493
return err;
24932494
}

0 commit comments

Comments
 (0)