Skip to content

Commit 54858ee

Browse files
CreaValixlinvjw
authored andcommitted
nl80211: Parse channel type attribute in an ibss join request
Prepare cfg80211 for IBSS HT: * extend cfg80211 ibss struct with channel_type * Check if extension channel can be used * Export can_beacon_sec_chan for use in mac80211 (will be called from ibss.c later). Signed-off-by: Alexander Simon <an.alexsimon@googlemail.com> [siwu@hrz.tu-chemnitz.de: Updates] * fix cfg80211_can_beacon_ext_chan comment * remove implicit channel_type enum assumptions * remove radar channel flags check * add HT IBSS feature flag * reword commit message Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de> Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fokus.fraunhofer.de> Reviewed-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 2b50b8f commit 54858ee

4 files changed

Lines changed: 50 additions & 7 deletions

File tree

‎include/linux/nl80211.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2785,9 +2785,11 @@ enum nl80211_ap_sme_features {
27852785
* @NL80211_FEATURE_SK_TX_STATUS: This driver supports reflecting back
27862786
* TX status to the socket error queue when requested with the
27872787
* socket option.
2788+
* @NL80211_FEATURE_HT_IBSS: This driver supports IBSS with HT datarates.
27882789
*/
27892790
enum nl80211_feature_flags {
27902791
NL80211_FEATURE_SK_TX_STATUS = 1 << 0,
2792+
NL80211_FEATURE_HT_IBSS = 1 << 1,
27912793
};
27922794

27932795
/**

‎include/net/cfg80211.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,7 @@ struct cfg80211_ibss_params {
11491149
u8 *ssid;
11501150
u8 *bssid;
11511151
struct ieee80211_channel *channel;
1152+
enum nl80211_channel_type channel_type;
11521153
u8 *ie;
11531154
u8 ssid_len, ie_len;
11541155
u16 beacon_interval;
@@ -3267,6 +3268,16 @@ void cfg80211_report_obss_beacon(struct wiphy *wiphy,
32673268
const u8 *frame, size_t len,
32683269
int freq, gfp_t gfp);
32693270

3271+
/*
3272+
* cfg80211_can_beacon_sec_chan - test if ht40 on extension channel can be used
3273+
* @wiphy: the wiphy
3274+
* @chan: main channel
3275+
* @channel_type: HT mode
3276+
*/
3277+
int cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
3278+
struct ieee80211_channel *chan,
3279+
enum nl80211_channel_type channel_type);
3280+
32703281
/* Logging, debugging and troubleshooting/diagnostic helpers. */
32713282

32723283
/* wiphy_printk helpers, similar to dev_printk */

‎net/wireless/chan.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
77
*/
88

9+
#include <linux/export.h>
910
#include <net/cfg80211.h>
1011
#include "core.h"
1112

@@ -44,9 +45,9 @@ rdev_freq_to_chan(struct cfg80211_registered_device *rdev,
4445
return chan;
4546
}
4647

47-
static bool can_beacon_sec_chan(struct wiphy *wiphy,
48-
struct ieee80211_channel *chan,
49-
enum nl80211_channel_type channel_type)
48+
int cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
49+
struct ieee80211_channel *chan,
50+
enum nl80211_channel_type channel_type)
5051
{
5152
struct ieee80211_channel *sec_chan;
5253
int diff;
@@ -75,6 +76,7 @@ static bool can_beacon_sec_chan(struct wiphy *wiphy,
7576

7677
return true;
7778
}
79+
EXPORT_SYMBOL(cfg80211_can_beacon_sec_chan);
7880

7981
int cfg80211_set_freq(struct cfg80211_registered_device *rdev,
8082
struct wireless_dev *wdev, int freq,
@@ -109,8 +111,8 @@ int cfg80211_set_freq(struct cfg80211_registered_device *rdev,
109111
switch (channel_type) {
110112
case NL80211_CHAN_HT40PLUS:
111113
case NL80211_CHAN_HT40MINUS:
112-
if (!can_beacon_sec_chan(&rdev->wiphy, chan,
113-
channel_type)) {
114+
if (!cfg80211_can_beacon_sec_chan(&rdev->wiphy, chan,
115+
channel_type)) {
114116
printk(KERN_DEBUG
115117
"cfg80211: Secondary channel not "
116118
"allowed to initiate communication\n");

‎net/wireless/nl80211.c‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4682,13 +4682,41 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info)
46824682
ibss.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);
46834683
}
46844684

4685-
ibss.channel = ieee80211_get_channel(wiphy,
4686-
nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]));
4685+
if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) {
4686+
enum nl80211_channel_type channel_type;
4687+
4688+
channel_type = nla_get_u32(
4689+
info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]);
4690+
if (channel_type != NL80211_CHAN_NO_HT &&
4691+
channel_type != NL80211_CHAN_HT20 &&
4692+
channel_type != NL80211_CHAN_HT40MINUS &&
4693+
channel_type != NL80211_CHAN_HT40PLUS)
4694+
return -EINVAL;
4695+
4696+
if (channel_type != NL80211_CHAN_NO_HT &&
4697+
!(wiphy->features & NL80211_FEATURE_HT_IBSS))
4698+
return -EINVAL;
4699+
4700+
ibss.channel_type = channel_type;
4701+
} else {
4702+
ibss.channel_type = NL80211_CHAN_NO_HT;
4703+
}
4704+
4705+
ibss.channel = rdev_freq_to_chan(rdev,
4706+
nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]),
4707+
ibss.channel_type);
46874708
if (!ibss.channel ||
46884709
ibss.channel->flags & IEEE80211_CHAN_NO_IBSS ||
46894710
ibss.channel->flags & IEEE80211_CHAN_DISABLED)
46904711
return -EINVAL;
46914712

4713+
/* Both channels should be able to initiate communication */
4714+
if ((ibss.channel_type == NL80211_CHAN_HT40PLUS ||
4715+
ibss.channel_type == NL80211_CHAN_HT40MINUS) &&
4716+
!cfg80211_can_beacon_sec_chan(&rdev->wiphy, ibss.channel,
4717+
ibss.channel_type))
4718+
return -EINVAL;
4719+
46924720
ibss.channel_fixed = !!info->attrs[NL80211_ATTR_FREQ_FIXED];
46934721
ibss.privacy = !!info->attrs[NL80211_ATTR_PRIVACY];
46944722

0 commit comments

Comments
 (0)