[PATCHv6 1/6] nl80211: check if channel can be used in join_ibss

Simon Wunderlich
2013-01-08T13:04:53Z

IBSS should also consider interface combinations.

Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
---
net/wireless/nl80211.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 9bd8340..62e98f5 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5463,6 +5463,7 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info)
{
struct cfg80211_registered_device *rdev = info->user_ptr[0];
struct net_device *dev = info->user_ptr[1];
+ struct wireless_dev *wdev = dev->ieee80211_ptr;
struct cfg80211_ibss_params ibss;
struct wiphy *wiphy;
struct cfg80211_cached_keys *connkeys = NULL;
@@ -5524,6 +5525,15 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info)
ibss.channel_fixed = !!info->attrs[NL80211_ATTR_FREQ_FIXED];
ibss.privacy = !!info->attrs[NL80211_ATTR_PRIVACY];

+ mutex_lock(&rdev->devlist_mtx);
+ err = cfg80211_can_use_chan(rdev, wdev, ibss.chandef.chan,
+ ibss.channel_fixed ? CHAN_MODE_SHARED :
+ CHAN_MODE_EXCLUSIVE);
+ mutex_unlock(&rdev->devlist_mtx);
+
+ if (err)
+ return -EINVAL;
+
if (info->attrs[NL80211_ATTR_BSS_BASIC_RATES]) {
u8 *rates =
nla_data(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]);
--
1.7.10.4