]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.36.2/cfg80211-fix-extension-channel-checks-to-initiate-communication.patch
Remove duplicated commits
[thirdparty/kernel/stable-queue.git] / releases / 2.6.36.2 / cfg80211-fix-extension-channel-checks-to-initiate-communication.patch
1 From 9236d838c920e90708570d9bbd7bb82d30a38130 Mon Sep 17 00:00:00 2001
2 From: Luis R. Rodriguez <lrodriguez@atheros.com>
3 Date: Fri, 12 Nov 2010 16:31:23 -0800
4 Subject: cfg80211: fix extension channel checks to initiate communication
5
6 From: Luis R. Rodriguez <lrodriguez@atheros.com>
7
8 commit 9236d838c920e90708570d9bbd7bb82d30a38130 upstream.
9
10 When operating in a mode that initiates communication and using
11 HT40 we should fail if we cannot use both primary and secondary
12 channels to initiate communication. Our current ht40 allowmap
13 only covers STA mode of operation, for beaconing modes we need
14 a check on the fly as the mode of operation is dynamic and
15 there other flags other than disable which we should read
16 to check if we can initiate communication.
17
18 Do not allow for initiating communication if our secondary HT40
19 channel has is either disabled, has a passive scan flag, a
20 no-ibss flag or is a radar channel. Userspace now has similar
21 checks but this is also needed in-kernel.
22
23 Reported-by: Jouni Malinen <jouni.malinen@atheros.com>
24 Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
25 Signed-off-by: John W. Linville <linville@tuxdriver.com>
26 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
27
28 ---
29 net/wireless/chan.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
30 1 file changed, 51 insertions(+)
31
32 --- a/net/wireless/chan.c
33 +++ b/net/wireless/chan.c
34 @@ -44,6 +44,36 @@ rdev_freq_to_chan(struct cfg80211_regist
35 return chan;
36 }
37
38 +static bool can_beacon_sec_chan(struct wiphy *wiphy,
39 + struct ieee80211_channel *chan,
40 + enum nl80211_channel_type channel_type)
41 +{
42 + struct ieee80211_channel *sec_chan;
43 + int diff;
44 +
45 + switch (channel_type) {
46 + case NL80211_CHAN_HT40PLUS:
47 + diff = 20;
48 + case NL80211_CHAN_HT40MINUS:
49 + diff = -20;
50 + default:
51 + return false;
52 + }
53 +
54 + sec_chan = ieee80211_get_channel(wiphy, chan->center_freq + diff);
55 + if (!sec_chan)
56 + return false;
57 +
58 + /* we'll need a DFS capability later */
59 + if (sec_chan->flags & (IEEE80211_CHAN_DISABLED |
60 + IEEE80211_CHAN_PASSIVE_SCAN |
61 + IEEE80211_CHAN_NO_IBSS |
62 + IEEE80211_CHAN_RADAR))
63 + return false;
64 +
65 + return true;
66 +}
67 +
68 int cfg80211_set_freq(struct cfg80211_registered_device *rdev,
69 struct wireless_dev *wdev, int freq,
70 enum nl80211_channel_type channel_type)
71 @@ -68,6 +98,27 @@ int cfg80211_set_freq(struct cfg80211_re
72 if (!chan)
73 return -EINVAL;
74
75 + /* Both channels should be able to initiate communication */
76 + if (wdev && (wdev->iftype == NL80211_IFTYPE_ADHOC ||
77 + wdev->iftype == NL80211_IFTYPE_AP ||
78 + wdev->iftype == NL80211_IFTYPE_AP_VLAN ||
79 + wdev->iftype == NL80211_IFTYPE_MESH_POINT)) {
80 + switch (channel_type) {
81 + case NL80211_CHAN_HT40PLUS:
82 + case NL80211_CHAN_HT40MINUS:
83 + if (!can_beacon_sec_chan(&rdev->wiphy, chan,
84 + channel_type)) {
85 + printk(KERN_DEBUG
86 + "cfg80211: Secondary channel not "
87 + "allowed to initiate communication\n");
88 + return -EINVAL;
89 + }
90 + break;
91 + default:
92 + break;
93 + }
94 + }
95 +
96 result = rdev->ops->set_channel(&rdev->wiphy,
97 wdev ? wdev->netdev : NULL,
98 chan, channel_type);