diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
commit | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch) | |
tree | a8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /net/wireless | |
parent | 406089d01562f1e2bf9f089fd7637009ebaad589 (diff) |
Patched in Tegra support.
Diffstat (limited to 'net/wireless')
34 files changed, 2487 insertions, 9078 deletions
diff --git a/net/wireless/Kconfig b/net/wireless/Kconfig index 16d08b39921..8e2a668c923 100644 --- a/net/wireless/Kconfig +++ b/net/wireless/Kconfig | |||
@@ -74,27 +74,6 @@ config CFG80211_REG_DEBUG | |||
74 | 74 | ||
75 | If unsure, say N. | 75 | If unsure, say N. |
76 | 76 | ||
77 | config CFG80211_CERTIFICATION_ONUS | ||
78 | bool "cfg80211 certification onus" | ||
79 | depends on CFG80211 && EXPERT | ||
80 | default n | ||
81 | ---help--- | ||
82 | You should disable this option unless you are both capable | ||
83 | and willing to ensure your system will remain regulatory | ||
84 | compliant with the features available under this option. | ||
85 | Some options may still be under heavy development and | ||
86 | for whatever reason regulatory compliance has not or | ||
87 | cannot yet be verified. Regulatory verification may at | ||
88 | times only be possible until you have the final system | ||
89 | in place. | ||
90 | |||
91 | This option should only be enabled by system integrators | ||
92 | or distributions that have done work necessary to ensure | ||
93 | regulatory certification on the system with the enabled | ||
94 | features. Alternatively you can enable this option if | ||
95 | you are a wireless researcher and are working in a controlled | ||
96 | and approved environment by your local regulatory agency. | ||
97 | |||
98 | config CFG80211_DEFAULT_PS | 77 | config CFG80211_DEFAULT_PS |
99 | bool "enable powersave by default" | 78 | bool "enable powersave by default" |
100 | depends on CFG80211 | 79 | depends on CFG80211 |
@@ -135,18 +114,32 @@ config CFG80211_WEXT | |||
135 | bool "cfg80211 wireless extensions compatibility" | 114 | bool "cfg80211 wireless extensions compatibility" |
136 | depends on CFG80211 | 115 | depends on CFG80211 |
137 | select WEXT_CORE | 116 | select WEXT_CORE |
117 | default y | ||
138 | help | 118 | help |
139 | Enable this option if you need old userspace for wireless | 119 | Enable this option if you need old userspace for wireless |
140 | extensions with cfg80211-based drivers. | 120 | extensions with cfg80211-based drivers. |
141 | 121 | ||
122 | config WIRELESS_EXT_SYSFS | ||
123 | bool "Wireless extensions sysfs files" | ||
124 | default y | ||
125 | depends on WEXT_CORE && SYSFS | ||
126 | help | ||
127 | This option enables the deprecated wireless statistics | ||
128 | files in /sys/class/net/*/wireless/. The same information | ||
129 | is available via the ioctls as well. | ||
130 | |||
131 | Say Y if you have programs using it, like old versions of | ||
132 | hal. | ||
133 | |||
142 | config LIB80211 | 134 | config LIB80211 |
143 | tristate | 135 | tristate "Common routines for IEEE802.11 drivers" |
144 | default n | 136 | default n |
145 | help | 137 | help |
146 | This options enables a library of common routines used | 138 | This options enables a library of common routines used |
147 | by IEEE802.11 wireless LAN drivers. | 139 | by IEEE802.11 wireless LAN drivers. |
148 | 140 | ||
149 | Drivers should select this themselves if needed. | 141 | Drivers should select this themselves if needed. Say Y if |
142 | you want this built into your kernel. | ||
150 | 143 | ||
151 | config LIB80211_CRYPT_WEP | 144 | config LIB80211_CRYPT_WEP |
152 | tristate | 145 | tristate |
@@ -166,3 +159,14 @@ config LIB80211_DEBUG | |||
166 | from lib80211. | 159 | from lib80211. |
167 | 160 | ||
168 | If unsure, say N. | 161 | If unsure, say N. |
162 | |||
163 | config CFG80211_ALLOW_RECONNECT | ||
164 | bool "Allow reconnect while already connected" | ||
165 | depends on CFG80211 | ||
166 | default n | ||
167 | help | ||
168 | cfg80211 stack doesn't allow to connect if you are already | ||
169 | connected. This option allows to make a connection in this case. | ||
170 | |||
171 | Select this option ONLY for wlan drivers that are specifically | ||
172 | built for such purposes. | ||
diff --git a/net/wireless/Makefile b/net/wireless/Makefile index a761670af31..55a28ab21db 100644 --- a/net/wireless/Makefile +++ b/net/wireless/Makefile | |||
@@ -10,13 +10,11 @@ obj-$(CONFIG_WEXT_SPY) += wext-spy.o | |||
10 | obj-$(CONFIG_WEXT_PRIV) += wext-priv.o | 10 | obj-$(CONFIG_WEXT_PRIV) += wext-priv.o |
11 | 11 | ||
12 | cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o scan.o nl80211.o | 12 | cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o scan.o nl80211.o |
13 | cfg80211-y += mlme.o ibss.o sme.o chan.o ethtool.o mesh.o ap.o trace.o | 13 | cfg80211-y += mlme.o ibss.o sme.o chan.o ethtool.o mesh.o |
14 | cfg80211-$(CONFIG_CFG80211_DEBUGFS) += debugfs.o | 14 | cfg80211-$(CONFIG_CFG80211_DEBUGFS) += debugfs.o |
15 | cfg80211-$(CONFIG_CFG80211_WEXT) += wext-compat.o wext-sme.o | 15 | cfg80211-$(CONFIG_CFG80211_WEXT) += wext-compat.o wext-sme.o |
16 | cfg80211-$(CONFIG_CFG80211_INTERNAL_REGDB) += regdb.o | 16 | cfg80211-$(CONFIG_CFG80211_INTERNAL_REGDB) += regdb.o |
17 | 17 | ||
18 | CFLAGS_trace.o := -I$(src) | ||
19 | |||
20 | ccflags-y += -D__CHECK_ENDIAN__ | 18 | ccflags-y += -D__CHECK_ENDIAN__ |
21 | 19 | ||
22 | $(obj)/regdb.c: $(src)/db.txt $(src)/genregdb.awk | 20 | $(obj)/regdb.c: $(src)/db.txt $(src)/genregdb.awk |
diff --git a/net/wireless/ap.c b/net/wireless/ap.c deleted file mode 100644 index 324e8d851dc..00000000000 --- a/net/wireless/ap.c +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | #include <linux/ieee80211.h> | ||
2 | #include <linux/export.h> | ||
3 | #include <net/cfg80211.h> | ||
4 | #include "nl80211.h" | ||
5 | #include "core.h" | ||
6 | #include "rdev-ops.h" | ||
7 | |||
8 | |||
9 | static int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev, | ||
10 | struct net_device *dev) | ||
11 | { | ||
12 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
13 | int err; | ||
14 | |||
15 | ASSERT_WDEV_LOCK(wdev); | ||
16 | |||
17 | if (!rdev->ops->stop_ap) | ||
18 | return -EOPNOTSUPP; | ||
19 | |||
20 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && | ||
21 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) | ||
22 | return -EOPNOTSUPP; | ||
23 | |||
24 | if (!wdev->beacon_interval) | ||
25 | return -ENOENT; | ||
26 | |||
27 | err = rdev_stop_ap(rdev, dev); | ||
28 | if (!err) { | ||
29 | wdev->beacon_interval = 0; | ||
30 | wdev->channel = NULL; | ||
31 | wdev->ssid_len = 0; | ||
32 | } | ||
33 | |||
34 | return err; | ||
35 | } | ||
36 | |||
37 | int cfg80211_stop_ap(struct cfg80211_registered_device *rdev, | ||
38 | struct net_device *dev) | ||
39 | { | ||
40 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
41 | int err; | ||
42 | |||
43 | wdev_lock(wdev); | ||
44 | err = __cfg80211_stop_ap(rdev, dev); | ||
45 | wdev_unlock(wdev); | ||
46 | |||
47 | return err; | ||
48 | } | ||
diff --git a/net/wireless/chan.c b/net/wireless/chan.c index a7990bb1652..17cd0c04d13 100644 --- a/net/wireless/chan.c +++ b/net/wireless/chan.c | |||
@@ -6,365 +6,130 @@ | |||
6 | * Copyright 2009 Johannes Berg <johannes@sipsolutions.net> | 6 | * Copyright 2009 Johannes Berg <johannes@sipsolutions.net> |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/export.h> | ||
10 | #include <net/cfg80211.h> | 9 | #include <net/cfg80211.h> |
11 | #include "core.h" | 10 | #include "core.h" |
12 | #include "rdev-ops.h" | ||
13 | 11 | ||
14 | void cfg80211_chandef_create(struct cfg80211_chan_def *chandef, | 12 | struct ieee80211_channel * |
15 | struct ieee80211_channel *chan, | 13 | rdev_freq_to_chan(struct cfg80211_registered_device *rdev, |
16 | enum nl80211_channel_type chan_type) | 14 | int freq, enum nl80211_channel_type channel_type) |
17 | { | 15 | { |
18 | if (WARN_ON(!chan)) | 16 | struct ieee80211_channel *chan; |
19 | return; | 17 | struct ieee80211_sta_ht_cap *ht_cap; |
20 | |||
21 | chandef->chan = chan; | ||
22 | chandef->center_freq2 = 0; | ||
23 | |||
24 | switch (chan_type) { | ||
25 | case NL80211_CHAN_NO_HT: | ||
26 | chandef->width = NL80211_CHAN_WIDTH_20_NOHT; | ||
27 | chandef->center_freq1 = chan->center_freq; | ||
28 | break; | ||
29 | case NL80211_CHAN_HT20: | ||
30 | chandef->width = NL80211_CHAN_WIDTH_20; | ||
31 | chandef->center_freq1 = chan->center_freq; | ||
32 | break; | ||
33 | case NL80211_CHAN_HT40PLUS: | ||
34 | chandef->width = NL80211_CHAN_WIDTH_40; | ||
35 | chandef->center_freq1 = chan->center_freq + 10; | ||
36 | break; | ||
37 | case NL80211_CHAN_HT40MINUS: | ||
38 | chandef->width = NL80211_CHAN_WIDTH_40; | ||
39 | chandef->center_freq1 = chan->center_freq - 10; | ||
40 | break; | ||
41 | default: | ||
42 | WARN_ON(1); | ||
43 | } | ||
44 | } | ||
45 | EXPORT_SYMBOL(cfg80211_chandef_create); | ||
46 | |||
47 | bool cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef) | ||
48 | { | ||
49 | u32 control_freq; | ||
50 | |||
51 | if (!chandef->chan) | ||
52 | return false; | ||
53 | |||
54 | control_freq = chandef->chan->center_freq; | ||
55 | |||
56 | switch (chandef->width) { | ||
57 | case NL80211_CHAN_WIDTH_20: | ||
58 | case NL80211_CHAN_WIDTH_20_NOHT: | ||
59 | if (chandef->center_freq1 != control_freq) | ||
60 | return false; | ||
61 | if (chandef->center_freq2) | ||
62 | return false; | ||
63 | break; | ||
64 | case NL80211_CHAN_WIDTH_40: | ||
65 | if (chandef->center_freq1 != control_freq + 10 && | ||
66 | chandef->center_freq1 != control_freq - 10) | ||
67 | return false; | ||
68 | if (chandef->center_freq2) | ||
69 | return false; | ||
70 | break; | ||
71 | case NL80211_CHAN_WIDTH_80P80: | ||
72 | if (chandef->center_freq1 != control_freq + 30 && | ||
73 | chandef->center_freq1 != control_freq + 10 && | ||
74 | chandef->center_freq1 != control_freq - 10 && | ||
75 | chandef->center_freq1 != control_freq - 30) | ||
76 | return false; | ||
77 | if (!chandef->center_freq2) | ||
78 | return false; | ||
79 | break; | ||
80 | case NL80211_CHAN_WIDTH_80: | ||
81 | if (chandef->center_freq1 != control_freq + 30 && | ||
82 | chandef->center_freq1 != control_freq + 10 && | ||
83 | chandef->center_freq1 != control_freq - 10 && | ||
84 | chandef->center_freq1 != control_freq - 30) | ||
85 | return false; | ||
86 | if (chandef->center_freq2) | ||
87 | return false; | ||
88 | break; | ||
89 | case NL80211_CHAN_WIDTH_160: | ||
90 | if (chandef->center_freq1 != control_freq + 70 && | ||
91 | chandef->center_freq1 != control_freq + 50 && | ||
92 | chandef->center_freq1 != control_freq + 30 && | ||
93 | chandef->center_freq1 != control_freq + 10 && | ||
94 | chandef->center_freq1 != control_freq - 10 && | ||
95 | chandef->center_freq1 != control_freq - 30 && | ||
96 | chandef->center_freq1 != control_freq - 50 && | ||
97 | chandef->center_freq1 != control_freq - 70) | ||
98 | return false; | ||
99 | if (chandef->center_freq2) | ||
100 | return false; | ||
101 | break; | ||
102 | default: | ||
103 | return false; | ||
104 | } | ||
105 | |||
106 | return true; | ||
107 | } | ||
108 | EXPORT_SYMBOL(cfg80211_chandef_valid); | ||
109 | |||
110 | static void chandef_primary_freqs(const struct cfg80211_chan_def *c, | ||
111 | int *pri40, int *pri80) | ||
112 | { | ||
113 | int tmp; | ||
114 | |||
115 | switch (c->width) { | ||
116 | case NL80211_CHAN_WIDTH_40: | ||
117 | *pri40 = c->center_freq1; | ||
118 | *pri80 = 0; | ||
119 | break; | ||
120 | case NL80211_CHAN_WIDTH_80: | ||
121 | case NL80211_CHAN_WIDTH_80P80: | ||
122 | *pri80 = c->center_freq1; | ||
123 | /* n_P20 */ | ||
124 | tmp = (30 + c->chan->center_freq - c->center_freq1)/20; | ||
125 | /* n_P40 */ | ||
126 | tmp /= 2; | ||
127 | /* freq_P40 */ | ||
128 | *pri40 = c->center_freq1 - 20 + 40 * tmp; | ||
129 | break; | ||
130 | case NL80211_CHAN_WIDTH_160: | ||
131 | /* n_P20 */ | ||
132 | tmp = (70 + c->chan->center_freq - c->center_freq1)/20; | ||
133 | /* n_P40 */ | ||
134 | tmp /= 2; | ||
135 | /* freq_P40 */ | ||
136 | *pri40 = c->center_freq1 - 60 + 40 * tmp; | ||
137 | /* n_P80 */ | ||
138 | tmp /= 2; | ||
139 | *pri80 = c->center_freq1 - 40 + 80 * tmp; | ||
140 | break; | ||
141 | default: | ||
142 | WARN_ON_ONCE(1); | ||
143 | } | ||
144 | } | ||
145 | |||
146 | const struct cfg80211_chan_def * | ||
147 | cfg80211_chandef_compatible(const struct cfg80211_chan_def *c1, | ||
148 | const struct cfg80211_chan_def *c2) | ||
149 | { | ||
150 | u32 c1_pri40, c1_pri80, c2_pri40, c2_pri80; | ||
151 | |||
152 | /* If they are identical, return */ | ||
153 | if (cfg80211_chandef_identical(c1, c2)) | ||
154 | return c1; | ||
155 | 18 | ||
156 | /* otherwise, must have same control channel */ | 19 | chan = ieee80211_get_channel(&rdev->wiphy, freq); |
157 | if (c1->chan != c2->chan) | ||
158 | return NULL; | ||
159 | 20 | ||
160 | /* | 21 | /* Primary channel not allowed */ |
161 | * If they have the same width, but aren't identical, | 22 | if (!chan || chan->flags & IEEE80211_CHAN_DISABLED) |
162 | * then they can't be compatible. | ||
163 | */ | ||
164 | if (c1->width == c2->width) | ||
165 | return NULL; | 23 | return NULL; |
166 | 24 | ||
167 | if (c1->width == NL80211_CHAN_WIDTH_20_NOHT || | 25 | if (channel_type == NL80211_CHAN_HT40MINUS && |
168 | c1->width == NL80211_CHAN_WIDTH_20) | 26 | chan->flags & IEEE80211_CHAN_NO_HT40MINUS) |
169 | return c2; | ||
170 | |||
171 | if (c2->width == NL80211_CHAN_WIDTH_20_NOHT || | ||
172 | c2->width == NL80211_CHAN_WIDTH_20) | ||
173 | return c1; | ||
174 | |||
175 | chandef_primary_freqs(c1, &c1_pri40, &c1_pri80); | ||
176 | chandef_primary_freqs(c2, &c2_pri40, &c2_pri80); | ||
177 | |||
178 | if (c1_pri40 != c2_pri40) | ||
179 | return NULL; | 27 | return NULL; |
180 | 28 | else if (channel_type == NL80211_CHAN_HT40PLUS && | |
181 | WARN_ON(!c1_pri80 && !c2_pri80); | 29 | chan->flags & IEEE80211_CHAN_NO_HT40PLUS) |
182 | if (c1_pri80 && c2_pri80 && c1_pri80 != c2_pri80) | ||
183 | return NULL; | 30 | return NULL; |
184 | 31 | ||
185 | if (c1->width > c2->width) | 32 | ht_cap = &rdev->wiphy.bands[chan->band]->ht_cap; |
186 | return c1; | ||
187 | return c2; | ||
188 | } | ||
189 | EXPORT_SYMBOL(cfg80211_chandef_compatible); | ||
190 | 33 | ||
191 | static bool cfg80211_secondary_chans_ok(struct wiphy *wiphy, | 34 | if (channel_type != NL80211_CHAN_NO_HT) { |
192 | u32 center_freq, u32 bandwidth, | 35 | if (!ht_cap->ht_supported) |
193 | u32 prohibited_flags) | 36 | return NULL; |
194 | { | ||
195 | struct ieee80211_channel *c; | ||
196 | u32 freq; | ||
197 | 37 | ||
198 | for (freq = center_freq - bandwidth/2 + 10; | 38 | if (channel_type != NL80211_CHAN_HT20 && |
199 | freq <= center_freq + bandwidth/2 - 10; | 39 | (!(ht_cap->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) || |
200 | freq += 20) { | 40 | ht_cap->cap & IEEE80211_HT_CAP_40MHZ_INTOLERANT)) |
201 | c = ieee80211_get_channel(wiphy, freq); | 41 | return NULL; |
202 | if (!c || c->flags & prohibited_flags) | ||
203 | return false; | ||
204 | } | 42 | } |
205 | 43 | ||
206 | return true; | 44 | return chan; |
207 | } | 45 | } |
208 | 46 | ||
209 | bool cfg80211_chandef_usable(struct wiphy *wiphy, | 47 | static bool can_beacon_sec_chan(struct wiphy *wiphy, |
210 | const struct cfg80211_chan_def *chandef, | 48 | struct ieee80211_channel *chan, |
211 | u32 prohibited_flags) | 49 | enum nl80211_channel_type channel_type) |
212 | { | 50 | { |
213 | struct ieee80211_sta_ht_cap *ht_cap; | 51 | struct ieee80211_channel *sec_chan; |
214 | struct ieee80211_sta_vht_cap *vht_cap; | 52 | int diff; |
215 | u32 width, control_freq; | ||
216 | |||
217 | if (WARN_ON(!cfg80211_chandef_valid(chandef))) | ||
218 | return false; | ||
219 | |||
220 | ht_cap = &wiphy->bands[chandef->chan->band]->ht_cap; | ||
221 | vht_cap = &wiphy->bands[chandef->chan->band]->vht_cap; | ||
222 | |||
223 | control_freq = chandef->chan->center_freq; | ||
224 | 53 | ||
225 | switch (chandef->width) { | 54 | switch (channel_type) { |
226 | case NL80211_CHAN_WIDTH_20: | 55 | case NL80211_CHAN_HT40PLUS: |
227 | if (!ht_cap->ht_supported) | 56 | diff = 20; |
228 | return false; | ||
229 | case NL80211_CHAN_WIDTH_20_NOHT: | ||
230 | width = 20; | ||
231 | break; | ||
232 | case NL80211_CHAN_WIDTH_40: | ||
233 | width = 40; | ||
234 | if (!ht_cap->ht_supported) | ||
235 | return false; | ||
236 | if (!(ht_cap->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) || | ||
237 | ht_cap->cap & IEEE80211_HT_CAP_40MHZ_INTOLERANT) | ||
238 | return false; | ||
239 | if (chandef->center_freq1 < control_freq && | ||
240 | chandef->chan->flags & IEEE80211_CHAN_NO_HT40MINUS) | ||
241 | return false; | ||
242 | if (chandef->center_freq1 > control_freq && | ||
243 | chandef->chan->flags & IEEE80211_CHAN_NO_HT40PLUS) | ||
244 | return false; | ||
245 | break; | ||
246 | case NL80211_CHAN_WIDTH_80P80: | ||
247 | if (!(vht_cap->cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ)) | ||
248 | return false; | ||
249 | case NL80211_CHAN_WIDTH_80: | ||
250 | if (!vht_cap->vht_supported) | ||
251 | return false; | ||
252 | width = 80; | ||
253 | break; | 57 | break; |
254 | case NL80211_CHAN_WIDTH_160: | 58 | case NL80211_CHAN_HT40MINUS: |
255 | if (!vht_cap->vht_supported) | 59 | diff = -20; |
256 | return false; | ||
257 | if (!(vht_cap->cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ)) | ||
258 | return false; | ||
259 | width = 160; | ||
260 | break; | 60 | break; |
261 | default: | 61 | default: |
262 | WARN_ON_ONCE(1); | ||
263 | return false; | 62 | return false; |
264 | } | 63 | } |
265 | 64 | ||
266 | /* TODO: missing regulatory check on 80/160 bandwidth */ | 65 | sec_chan = ieee80211_get_channel(wiphy, chan->center_freq + diff); |
267 | 66 | if (!sec_chan) | |
268 | if (width > 20) | 67 | return false; |
269 | prohibited_flags |= IEEE80211_CHAN_NO_OFDM; | ||
270 | 68 | ||
271 | if (!cfg80211_secondary_chans_ok(wiphy, chandef->center_freq1, | 69 | /* we'll need a DFS capability later */ |
272 | width, prohibited_flags)) | 70 | if (sec_chan->flags & (IEEE80211_CHAN_DISABLED | |
71 | IEEE80211_CHAN_PASSIVE_SCAN | | ||
72 | IEEE80211_CHAN_NO_IBSS | | ||
73 | IEEE80211_CHAN_RADAR)) | ||
273 | return false; | 74 | return false; |
274 | 75 | ||
275 | if (!chandef->center_freq2) | 76 | return true; |
276 | return true; | ||
277 | return cfg80211_secondary_chans_ok(wiphy, chandef->center_freq2, | ||
278 | width, prohibited_flags); | ||
279 | } | 77 | } |
280 | EXPORT_SYMBOL(cfg80211_chandef_usable); | ||
281 | 78 | ||
282 | bool cfg80211_reg_can_beacon(struct wiphy *wiphy, | 79 | int cfg80211_set_freq(struct cfg80211_registered_device *rdev, |
283 | struct cfg80211_chan_def *chandef) | 80 | struct wireless_dev *wdev, int freq, |
81 | enum nl80211_channel_type channel_type) | ||
284 | { | 82 | { |
285 | bool res; | 83 | struct ieee80211_channel *chan; |
84 | int result; | ||
286 | 85 | ||
287 | trace_cfg80211_reg_can_beacon(wiphy, chandef); | 86 | if (wdev && wdev->iftype == NL80211_IFTYPE_MONITOR) |
87 | wdev = NULL; | ||
288 | 88 | ||
289 | res = cfg80211_chandef_usable(wiphy, chandef, | 89 | if (wdev) { |
290 | IEEE80211_CHAN_DISABLED | | 90 | ASSERT_WDEV_LOCK(wdev); |
291 | IEEE80211_CHAN_PASSIVE_SCAN | | ||
292 | IEEE80211_CHAN_NO_IBSS | | ||
293 | IEEE80211_CHAN_RADAR); | ||
294 | 91 | ||
295 | trace_cfg80211_return_bool(res); | 92 | if (!netif_running(wdev->netdev)) |
296 | return res; | 93 | return -ENETDOWN; |
297 | } | 94 | } |
298 | EXPORT_SYMBOL(cfg80211_reg_can_beacon); | ||
299 | 95 | ||
300 | int cfg80211_set_monitor_channel(struct cfg80211_registered_device *rdev, | 96 | if (!rdev->ops->set_channel) |
301 | struct cfg80211_chan_def *chandef) | ||
302 | { | ||
303 | if (!rdev->ops->set_monitor_channel) | ||
304 | return -EOPNOTSUPP; | 97 | return -EOPNOTSUPP; |
305 | if (!cfg80211_has_monitors_only(rdev)) | ||
306 | return -EBUSY; | ||
307 | 98 | ||
308 | return rdev_set_monitor_channel(rdev, chandef); | 99 | chan = rdev_freq_to_chan(rdev, freq, channel_type); |
309 | } | 100 | if (!chan) |
310 | 101 | return -EINVAL; | |
311 | void | 102 | |
312 | cfg80211_get_chan_state(struct wireless_dev *wdev, | 103 | /* Both channels should be able to initiate communication */ |
313 | struct ieee80211_channel **chan, | 104 | if (wdev && (wdev->iftype == NL80211_IFTYPE_ADHOC || |
314 | enum cfg80211_chan_mode *chanmode) | 105 | wdev->iftype == NL80211_IFTYPE_AP || |
315 | { | 106 | wdev->iftype == NL80211_IFTYPE_AP_VLAN || |
316 | *chan = NULL; | 107 | wdev->iftype == NL80211_IFTYPE_MESH_POINT || |
317 | *chanmode = CHAN_MODE_UNDEFINED; | 108 | wdev->iftype == NL80211_IFTYPE_P2P_GO)) { |
318 | 109 | switch (channel_type) { | |
319 | ASSERT_WDEV_LOCK(wdev); | 110 | case NL80211_CHAN_HT40PLUS: |
320 | 111 | case NL80211_CHAN_HT40MINUS: | |
321 | if (wdev->netdev && !netif_running(wdev->netdev)) | 112 | if (!can_beacon_sec_chan(&rdev->wiphy, chan, |
322 | return; | 113 | channel_type)) { |
323 | 114 | printk(KERN_DEBUG | |
324 | switch (wdev->iftype) { | 115 | "cfg80211: Secondary channel not " |
325 | case NL80211_IFTYPE_ADHOC: | 116 | "allowed to initiate communication\n"); |
326 | if (wdev->current_bss) { | 117 | return -EINVAL; |
327 | *chan = wdev->current_bss->pub.channel; | 118 | } |
328 | *chanmode = wdev->ibss_fixed | 119 | break; |
329 | ? CHAN_MODE_SHARED | 120 | default: |
330 | : CHAN_MODE_EXCLUSIVE; | 121 | break; |
331 | return; | ||
332 | } | 122 | } |
333 | case NL80211_IFTYPE_STATION: | ||
334 | case NL80211_IFTYPE_P2P_CLIENT: | ||
335 | if (wdev->current_bss) { | ||
336 | *chan = wdev->current_bss->pub.channel; | ||
337 | *chanmode = CHAN_MODE_SHARED; | ||
338 | return; | ||
339 | } | ||
340 | break; | ||
341 | case NL80211_IFTYPE_AP: | ||
342 | case NL80211_IFTYPE_P2P_GO: | ||
343 | if (wdev->beacon_interval) { | ||
344 | *chan = wdev->channel; | ||
345 | *chanmode = CHAN_MODE_SHARED; | ||
346 | } | ||
347 | return; | ||
348 | case NL80211_IFTYPE_MESH_POINT: | ||
349 | if (wdev->mesh_id_len) { | ||
350 | *chan = wdev->channel; | ||
351 | *chanmode = CHAN_MODE_SHARED; | ||
352 | } | ||
353 | return; | ||
354 | case NL80211_IFTYPE_MONITOR: | ||
355 | case NL80211_IFTYPE_AP_VLAN: | ||
356 | case NL80211_IFTYPE_WDS: | ||
357 | /* these interface types don't really have a channel */ | ||
358 | return; | ||
359 | case NL80211_IFTYPE_P2P_DEVICE: | ||
360 | if (wdev->wiphy->features & | ||
361 | NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL) | ||
362 | *chanmode = CHAN_MODE_EXCLUSIVE; | ||
363 | return; | ||
364 | case NL80211_IFTYPE_UNSPECIFIED: | ||
365 | case NUM_NL80211_IFTYPES: | ||
366 | WARN_ON(1); | ||
367 | } | 123 | } |
368 | 124 | ||
369 | return; | 125 | result = rdev->ops->set_channel(&rdev->wiphy, |
126 | wdev ? wdev->netdev : NULL, | ||
127 | chan, channel_type); | ||
128 | if (result) | ||
129 | return result; | ||
130 | |||
131 | if (wdev) | ||
132 | wdev->channel = chan; | ||
133 | |||
134 | return 0; | ||
370 | } | 135 | } |
diff --git a/net/wireless/core.c b/net/wireless/core.c index b677eab55b6..c14865172da 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "debugfs.h" | 26 | #include "debugfs.h" |
27 | #include "wext-compat.h" | 27 | #include "wext-compat.h" |
28 | #include "ethtool.h" | 28 | #include "ethtool.h" |
29 | #include "rdev-ops.h" | ||
30 | 29 | ||
31 | /* name for sysfs, %d is appended */ | 30 | /* name for sysfs, %d is appended */ |
32 | #define PHY_NAME "phy" | 31 | #define PHY_NAME "phy" |
@@ -97,6 +96,69 @@ struct wiphy *wiphy_idx_to_wiphy(int wiphy_idx) | |||
97 | return &rdev->wiphy; | 96 | return &rdev->wiphy; |
98 | } | 97 | } |
99 | 98 | ||
99 | /* requires cfg80211_mutex to be held! */ | ||
100 | struct cfg80211_registered_device * | ||
101 | __cfg80211_rdev_from_info(struct genl_info *info) | ||
102 | { | ||
103 | int ifindex; | ||
104 | struct cfg80211_registered_device *bywiphyidx = NULL, *byifidx = NULL; | ||
105 | struct net_device *dev; | ||
106 | int err = -EINVAL; | ||
107 | |||
108 | assert_cfg80211_lock(); | ||
109 | |||
110 | if (info->attrs[NL80211_ATTR_WIPHY]) { | ||
111 | bywiphyidx = cfg80211_rdev_by_wiphy_idx( | ||
112 | nla_get_u32(info->attrs[NL80211_ATTR_WIPHY])); | ||
113 | err = -ENODEV; | ||
114 | } | ||
115 | |||
116 | if (info->attrs[NL80211_ATTR_IFINDEX]) { | ||
117 | ifindex = nla_get_u32(info->attrs[NL80211_ATTR_IFINDEX]); | ||
118 | dev = dev_get_by_index(genl_info_net(info), ifindex); | ||
119 | if (dev) { | ||
120 | if (dev->ieee80211_ptr) | ||
121 | byifidx = | ||
122 | wiphy_to_dev(dev->ieee80211_ptr->wiphy); | ||
123 | dev_put(dev); | ||
124 | } | ||
125 | err = -ENODEV; | ||
126 | } | ||
127 | |||
128 | if (bywiphyidx && byifidx) { | ||
129 | if (bywiphyidx != byifidx) | ||
130 | return ERR_PTR(-EINVAL); | ||
131 | else | ||
132 | return bywiphyidx; /* == byifidx */ | ||
133 | } | ||
134 | if (bywiphyidx) | ||
135 | return bywiphyidx; | ||
136 | |||
137 | if (byifidx) | ||
138 | return byifidx; | ||
139 | |||
140 | return ERR_PTR(err); | ||
141 | } | ||
142 | |||
143 | struct cfg80211_registered_device * | ||
144 | cfg80211_get_dev_from_info(struct genl_info *info) | ||
145 | { | ||
146 | struct cfg80211_registered_device *rdev; | ||
147 | |||
148 | mutex_lock(&cfg80211_mutex); | ||
149 | rdev = __cfg80211_rdev_from_info(info); | ||
150 | |||
151 | /* if it is not an error we grab the lock on | ||
152 | * it to assure it won't be going away while | ||
153 | * we operate on it */ | ||
154 | if (!IS_ERR(rdev)) | ||
155 | mutex_lock(&rdev->mtx); | ||
156 | |||
157 | mutex_unlock(&cfg80211_mutex); | ||
158 | |||
159 | return rdev; | ||
160 | } | ||
161 | |||
100 | struct cfg80211_registered_device * | 162 | struct cfg80211_registered_device * |
101 | cfg80211_get_dev_from_ifindex(struct net *net, int ifindex) | 163 | cfg80211_get_dev_from_ifindex(struct net *net, int ifindex) |
102 | { | 164 | { |
@@ -177,9 +239,7 @@ int cfg80211_switch_netns(struct cfg80211_registered_device *rdev, | |||
177 | if (!(rdev->wiphy.flags & WIPHY_FLAG_NETNS_OK)) | 239 | if (!(rdev->wiphy.flags & WIPHY_FLAG_NETNS_OK)) |
178 | return -EOPNOTSUPP; | 240 | return -EOPNOTSUPP; |
179 | 241 | ||
180 | list_for_each_entry(wdev, &rdev->wdev_list, list) { | 242 | list_for_each_entry(wdev, &rdev->netdev_list, list) { |
181 | if (!wdev->netdev) | ||
182 | continue; | ||
183 | wdev->netdev->features &= ~NETIF_F_NETNS_LOCAL; | 243 | wdev->netdev->features &= ~NETIF_F_NETNS_LOCAL; |
184 | err = dev_change_net_namespace(wdev->netdev, net, "wlan%d"); | 244 | err = dev_change_net_namespace(wdev->netdev, net, "wlan%d"); |
185 | if (err) | 245 | if (err) |
@@ -191,10 +251,8 @@ int cfg80211_switch_netns(struct cfg80211_registered_device *rdev, | |||
191 | /* failed -- clean up to old netns */ | 251 | /* failed -- clean up to old netns */ |
192 | net = wiphy_net(&rdev->wiphy); | 252 | net = wiphy_net(&rdev->wiphy); |
193 | 253 | ||
194 | list_for_each_entry_continue_reverse(wdev, &rdev->wdev_list, | 254 | list_for_each_entry_continue_reverse(wdev, &rdev->netdev_list, |
195 | list) { | 255 | list) { |
196 | if (!wdev->netdev) | ||
197 | continue; | ||
198 | wdev->netdev->features &= ~NETIF_F_NETNS_LOCAL; | 256 | wdev->netdev->features &= ~NETIF_F_NETNS_LOCAL; |
199 | err = dev_change_net_namespace(wdev->netdev, net, | 257 | err = dev_change_net_namespace(wdev->netdev, net, |
200 | "wlan%d"); | 258 | "wlan%d"); |
@@ -217,7 +275,7 @@ static void cfg80211_rfkill_poll(struct rfkill *rfkill, void *data) | |||
217 | { | 275 | { |
218 | struct cfg80211_registered_device *rdev = data; | 276 | struct cfg80211_registered_device *rdev = data; |
219 | 277 | ||
220 | rdev_rfkill_poll(rdev); | 278 | rdev->ops->rfkill_poll(&rdev->wiphy); |
221 | } | 279 | } |
222 | 280 | ||
223 | static int cfg80211_rfkill_set_block(void *data, bool blocked) | 281 | static int cfg80211_rfkill_set_block(void *data, bool blocked) |
@@ -231,24 +289,8 @@ static int cfg80211_rfkill_set_block(void *data, bool blocked) | |||
231 | rtnl_lock(); | 289 | rtnl_lock(); |
232 | mutex_lock(&rdev->devlist_mtx); | 290 | mutex_lock(&rdev->devlist_mtx); |
233 | 291 | ||
234 | list_for_each_entry(wdev, &rdev->wdev_list, list) { | 292 | list_for_each_entry(wdev, &rdev->netdev_list, list) |
235 | if (wdev->netdev) { | 293 | dev_close(wdev->netdev); |
236 | dev_close(wdev->netdev); | ||
237 | continue; | ||
238 | } | ||
239 | /* otherwise, check iftype */ | ||
240 | switch (wdev->iftype) { | ||
241 | case NL80211_IFTYPE_P2P_DEVICE: | ||
242 | if (!wdev->p2p_started) | ||
243 | break; | ||
244 | rdev_stop_p2p_device(rdev, wdev); | ||
245 | wdev->p2p_started = false; | ||
246 | rdev->opencount--; | ||
247 | break; | ||
248 | default: | ||
249 | break; | ||
250 | } | ||
251 | } | ||
252 | 294 | ||
253 | mutex_unlock(&rdev->devlist_mtx); | 295 | mutex_unlock(&rdev->devlist_mtx); |
254 | rtnl_unlock(); | 296 | rtnl_unlock(); |
@@ -325,9 +367,7 @@ struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv) | |||
325 | mutex_init(&rdev->mtx); | 367 | mutex_init(&rdev->mtx); |
326 | mutex_init(&rdev->devlist_mtx); | 368 | mutex_init(&rdev->devlist_mtx); |
327 | mutex_init(&rdev->sched_scan_mtx); | 369 | mutex_init(&rdev->sched_scan_mtx); |
328 | INIT_LIST_HEAD(&rdev->wdev_list); | 370 | INIT_LIST_HEAD(&rdev->netdev_list); |
329 | INIT_LIST_HEAD(&rdev->beacon_registrations); | ||
330 | spin_lock_init(&rdev->beacon_registrations_lock); | ||
331 | spin_lock_init(&rdev->bss_lock); | 371 | spin_lock_init(&rdev->bss_lock); |
332 | INIT_LIST_HEAD(&rdev->bss_list); | 372 | INIT_LIST_HEAD(&rdev->bss_list); |
333 | INIT_WORK(&rdev->scan_done_wk, __cfg80211_scan_done); | 373 | INIT_WORK(&rdev->scan_done_wk, __cfg80211_scan_done); |
@@ -373,8 +413,6 @@ struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv) | |||
373 | rdev->wiphy.rts_threshold = (u32) -1; | 413 | rdev->wiphy.rts_threshold = (u32) -1; |
374 | rdev->wiphy.coverage_class = 0; | 414 | rdev->wiphy.coverage_class = 0; |
375 | 415 | ||
376 | rdev->wiphy.features = NL80211_FEATURE_SCAN_FLUSH; | ||
377 | |||
378 | return &rdev->wiphy; | 416 | return &rdev->wiphy; |
379 | } | 417 | } |
380 | EXPORT_SYMBOL(wiphy_new); | 418 | EXPORT_SYMBOL(wiphy_new); |
@@ -384,6 +422,10 @@ static int wiphy_verify_combinations(struct wiphy *wiphy) | |||
384 | const struct ieee80211_iface_combination *c; | 422 | const struct ieee80211_iface_combination *c; |
385 | int i, j; | 423 | int i, j; |
386 | 424 | ||
425 | /* If we have combinations enforce them */ | ||
426 | if (wiphy->n_iface_combinations) | ||
427 | wiphy->flags |= WIPHY_FLAG_ENFORCE_COMBINATIONS; | ||
428 | |||
387 | for (i = 0; i < wiphy->n_iface_combinations; i++) { | 429 | for (i = 0; i < wiphy->n_iface_combinations; i++) { |
388 | u32 cnt = 0; | 430 | u32 cnt = 0; |
389 | u16 all_iftypes = 0; | 431 | u16 all_iftypes = 0; |
@@ -398,14 +440,6 @@ static int wiphy_verify_combinations(struct wiphy *wiphy) | |||
398 | if (WARN_ON(!c->num_different_channels)) | 440 | if (WARN_ON(!c->num_different_channels)) |
399 | return -EINVAL; | 441 | return -EINVAL; |
400 | 442 | ||
401 | /* | ||
402 | * Put a sane limit on maximum number of different | ||
403 | * channels to simplify channel accounting code. | ||
404 | */ | ||
405 | if (WARN_ON(c->num_different_channels > | ||
406 | CFG80211_MAX_NUM_DIFFERENT_CHANNELS)) | ||
407 | return -EINVAL; | ||
408 | |||
409 | if (WARN_ON(!c->n_limits)) | 443 | if (WARN_ON(!c->n_limits)) |
410 | return -EINVAL; | 444 | return -EINVAL; |
411 | 445 | ||
@@ -427,11 +461,6 @@ static int wiphy_verify_combinations(struct wiphy *wiphy) | |||
427 | if (WARN_ON(wiphy->software_iftypes & types)) | 461 | if (WARN_ON(wiphy->software_iftypes & types)) |
428 | return -EINVAL; | 462 | return -EINVAL; |
429 | 463 | ||
430 | /* Only a single P2P_DEVICE can be allowed */ | ||
431 | if (WARN_ON(types & BIT(NL80211_IFTYPE_P2P_DEVICE) && | ||
432 | c->limits[j].max > 1)) | ||
433 | return -EINVAL; | ||
434 | |||
435 | cnt += c->limits[j].max; | 464 | cnt += c->limits[j].max; |
436 | /* | 465 | /* |
437 | * Don't advertise an unsupported type | 466 | * Don't advertise an unsupported type |
@@ -459,15 +488,9 @@ int wiphy_register(struct wiphy *wiphy) | |||
459 | int i; | 488 | int i; |
460 | u16 ifmodes = wiphy->interface_modes; | 489 | u16 ifmodes = wiphy->interface_modes; |
461 | 490 | ||
462 | #ifdef CONFIG_PM | ||
463 | if (WARN_ON((wiphy->wowlan.flags & WIPHY_WOWLAN_GTK_REKEY_FAILURE) && | 491 | if (WARN_ON((wiphy->wowlan.flags & WIPHY_WOWLAN_GTK_REKEY_FAILURE) && |
464 | !(wiphy->wowlan.flags & WIPHY_WOWLAN_SUPPORTS_GTK_REKEY))) | 492 | !(wiphy->wowlan.flags & WIPHY_WOWLAN_SUPPORTS_GTK_REKEY))) |
465 | return -EINVAL; | 493 | return -EINVAL; |
466 | #endif | ||
467 | |||
468 | if (WARN_ON(wiphy->ap_sme_capa && | ||
469 | !(wiphy->flags & WIPHY_FLAG_HAVE_AP_SME))) | ||
470 | return -EINVAL; | ||
471 | 494 | ||
472 | if (WARN_ON(wiphy->addresses && !wiphy->n_addresses)) | 495 | if (WARN_ON(wiphy->addresses && !wiphy->n_addresses)) |
473 | return -EINVAL; | 496 | return -EINVAL; |
@@ -498,14 +521,8 @@ int wiphy_register(struct wiphy *wiphy) | |||
498 | continue; | 521 | continue; |
499 | 522 | ||
500 | sband->band = band; | 523 | sband->band = band; |
501 | if (WARN_ON(!sband->n_channels)) | 524 | |
502 | return -EINVAL; | 525 | if (WARN_ON(!sband->n_channels || !sband->n_bitrates)) |
503 | /* | ||
504 | * on 60gHz band, there are no legacy rates, so | ||
505 | * n_bitrates is 0 | ||
506 | */ | ||
507 | if (WARN_ON(band != IEEE80211_BAND_60GHZ && | ||
508 | !sband->n_bitrates)) | ||
509 | return -EINVAL; | 526 | return -EINVAL; |
510 | 527 | ||
511 | /* | 528 | /* |
@@ -531,7 +548,8 @@ int wiphy_register(struct wiphy *wiphy) | |||
531 | for (i = 0; i < sband->n_channels; i++) { | 548 | for (i = 0; i < sband->n_channels; i++) { |
532 | sband->channels[i].orig_flags = | 549 | sband->channels[i].orig_flags = |
533 | sband->channels[i].flags; | 550 | sband->channels[i].flags; |
534 | sband->channels[i].orig_mag = INT_MAX; | 551 | sband->channels[i].orig_mag = |
552 | sband->channels[i].max_antenna_gain; | ||
535 | sband->channels[i].orig_mpwr = | 553 | sband->channels[i].orig_mpwr = |
536 | sband->channels[i].max_power; | 554 | sband->channels[i].max_power; |
537 | sband->channels[i].band = band; | 555 | sband->channels[i].band = band; |
@@ -545,14 +563,12 @@ int wiphy_register(struct wiphy *wiphy) | |||
545 | return -EINVAL; | 563 | return -EINVAL; |
546 | } | 564 | } |
547 | 565 | ||
548 | #ifdef CONFIG_PM | ||
549 | if (rdev->wiphy.wowlan.n_patterns) { | 566 | if (rdev->wiphy.wowlan.n_patterns) { |
550 | if (WARN_ON(!rdev->wiphy.wowlan.pattern_min_len || | 567 | if (WARN_ON(!rdev->wiphy.wowlan.pattern_min_len || |
551 | rdev->wiphy.wowlan.pattern_min_len > | 568 | rdev->wiphy.wowlan.pattern_min_len > |
552 | rdev->wiphy.wowlan.pattern_max_len)) | 569 | rdev->wiphy.wowlan.pattern_max_len)) |
553 | return -EINVAL; | 570 | return -EINVAL; |
554 | } | 571 | } |
555 | #endif | ||
556 | 572 | ||
557 | /* check and set up bitrates */ | 573 | /* check and set up bitrates */ |
558 | ieee80211_set_bitrate_flags(wiphy); | 574 | ieee80211_set_bitrate_flags(wiphy); |
@@ -566,7 +582,7 @@ int wiphy_register(struct wiphy *wiphy) | |||
566 | } | 582 | } |
567 | 583 | ||
568 | /* set up regulatory info */ | 584 | /* set up regulatory info */ |
569 | wiphy_regulatory_register(wiphy); | 585 | wiphy_update_regulatory(wiphy, NL80211_REGDOM_SET_BY_CORE); |
570 | 586 | ||
571 | list_add_rcu(&rdev->list, &cfg80211_rdev_list); | 587 | list_add_rcu(&rdev->list, &cfg80211_rdev_list); |
572 | cfg80211_rdev_list_generation++; | 588 | cfg80211_rdev_list_generation++; |
@@ -648,10 +664,10 @@ void wiphy_unregister(struct wiphy *wiphy) | |||
648 | mutex_lock(&rdev->devlist_mtx); | 664 | mutex_lock(&rdev->devlist_mtx); |
649 | __count = rdev->opencount; | 665 | __count = rdev->opencount; |
650 | mutex_unlock(&rdev->devlist_mtx); | 666 | mutex_unlock(&rdev->devlist_mtx); |
651 | __count == 0; })); | 667 | __count == 0;})); |
652 | 668 | ||
653 | mutex_lock(&rdev->devlist_mtx); | 669 | mutex_lock(&rdev->devlist_mtx); |
654 | BUG_ON(!list_empty(&rdev->wdev_list)); | 670 | BUG_ON(!list_empty(&rdev->netdev_list)); |
655 | mutex_unlock(&rdev->devlist_mtx); | 671 | mutex_unlock(&rdev->devlist_mtx); |
656 | 672 | ||
657 | /* | 673 | /* |
@@ -676,11 +692,9 @@ void wiphy_unregister(struct wiphy *wiphy) | |||
676 | /* nothing */ | 692 | /* nothing */ |
677 | cfg80211_unlock_rdev(rdev); | 693 | cfg80211_unlock_rdev(rdev); |
678 | 694 | ||
679 | /* | 695 | /* If this device got a regulatory hint tell core its |
680 | * If this device got a regulatory hint tell core its | 696 | * free to listen now to a new shiny device regulatory hint */ |
681 | * free to listen now to a new shiny device regulatory hint | 697 | reg_device_remove(wiphy); |
682 | */ | ||
683 | wiphy_regulatory_deregister(wiphy); | ||
684 | 698 | ||
685 | cfg80211_rdev_list_generation++; | 699 | cfg80211_rdev_list_generation++; |
686 | device_del(&rdev->wiphy.dev); | 700 | device_del(&rdev->wiphy.dev); |
@@ -690,27 +704,19 @@ void wiphy_unregister(struct wiphy *wiphy) | |||
690 | flush_work(&rdev->scan_done_wk); | 704 | flush_work(&rdev->scan_done_wk); |
691 | cancel_work_sync(&rdev->conn_work); | 705 | cancel_work_sync(&rdev->conn_work); |
692 | flush_work(&rdev->event_work); | 706 | flush_work(&rdev->event_work); |
693 | |||
694 | if (rdev->wowlan && rdev->ops->set_wakeup) | ||
695 | rdev_set_wakeup(rdev, false); | ||
696 | cfg80211_rdev_free_wowlan(rdev); | ||
697 | } | 707 | } |
698 | EXPORT_SYMBOL(wiphy_unregister); | 708 | EXPORT_SYMBOL(wiphy_unregister); |
699 | 709 | ||
700 | void cfg80211_dev_free(struct cfg80211_registered_device *rdev) | 710 | void cfg80211_dev_free(struct cfg80211_registered_device *rdev) |
701 | { | 711 | { |
702 | struct cfg80211_internal_bss *scan, *tmp; | 712 | struct cfg80211_internal_bss *scan, *tmp; |
703 | struct cfg80211_beacon_registration *reg, *treg; | ||
704 | rfkill_destroy(rdev->rfkill); | 713 | rfkill_destroy(rdev->rfkill); |
705 | mutex_destroy(&rdev->mtx); | 714 | mutex_destroy(&rdev->mtx); |
706 | mutex_destroy(&rdev->devlist_mtx); | 715 | mutex_destroy(&rdev->devlist_mtx); |
707 | mutex_destroy(&rdev->sched_scan_mtx); | 716 | mutex_destroy(&rdev->sched_scan_mtx); |
708 | list_for_each_entry_safe(reg, treg, &rdev->beacon_registrations, list) { | ||
709 | list_del(®->list); | ||
710 | kfree(reg); | ||
711 | } | ||
712 | list_for_each_entry_safe(scan, tmp, &rdev->bss_list, list) | 717 | list_for_each_entry_safe(scan, tmp, &rdev->bss_list, list) |
713 | cfg80211_put_bss(&scan->pub); | 718 | cfg80211_put_bss(&scan->pub); |
719 | cfg80211_rdev_free_wowlan(rdev); | ||
714 | kfree(rdev); | 720 | kfree(rdev); |
715 | } | 721 | } |
716 | 722 | ||
@@ -739,7 +745,7 @@ static void wdev_cleanup_work(struct work_struct *work) | |||
739 | 745 | ||
740 | cfg80211_lock_rdev(rdev); | 746 | cfg80211_lock_rdev(rdev); |
741 | 747 | ||
742 | if (WARN_ON(rdev->scan_req && rdev->scan_req->wdev == wdev)) { | 748 | if (WARN_ON(rdev->scan_req && rdev->scan_req->dev == wdev->netdev)) { |
743 | rdev->scan_req->aborted = true; | 749 | rdev->scan_req->aborted = true; |
744 | ___cfg80211_scan_done(rdev, true); | 750 | ___cfg80211_scan_done(rdev, true); |
745 | } | 751 | } |
@@ -763,50 +769,11 @@ static void wdev_cleanup_work(struct work_struct *work) | |||
763 | dev_put(wdev->netdev); | 769 | dev_put(wdev->netdev); |
764 | } | 770 | } |
765 | 771 | ||
766 | void cfg80211_unregister_wdev(struct wireless_dev *wdev) | ||
767 | { | ||
768 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | ||
769 | |||
770 | ASSERT_RTNL(); | ||
771 | |||
772 | if (WARN_ON(wdev->netdev)) | ||
773 | return; | ||
774 | |||
775 | mutex_lock(&rdev->devlist_mtx); | ||
776 | list_del_rcu(&wdev->list); | ||
777 | rdev->devlist_generation++; | ||
778 | |||
779 | switch (wdev->iftype) { | ||
780 | case NL80211_IFTYPE_P2P_DEVICE: | ||
781 | if (!wdev->p2p_started) | ||
782 | break; | ||
783 | rdev_stop_p2p_device(rdev, wdev); | ||
784 | wdev->p2p_started = false; | ||
785 | rdev->opencount--; | ||
786 | break; | ||
787 | default: | ||
788 | WARN_ON_ONCE(1); | ||
789 | break; | ||
790 | } | ||
791 | mutex_unlock(&rdev->devlist_mtx); | ||
792 | } | ||
793 | EXPORT_SYMBOL(cfg80211_unregister_wdev); | ||
794 | |||
795 | static struct device_type wiphy_type = { | 772 | static struct device_type wiphy_type = { |
796 | .name = "wlan", | 773 | .name = "wlan", |
797 | }; | 774 | }; |
798 | 775 | ||
799 | void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev, | 776 | static int cfg80211_netdev_notifier_call(struct notifier_block * nb, |
800 | enum nl80211_iftype iftype, int num) | ||
801 | { | ||
802 | ASSERT_RTNL(); | ||
803 | |||
804 | rdev->num_running_ifaces += num; | ||
805 | if (iftype == NL80211_IFTYPE_MONITOR) | ||
806 | rdev->num_running_monitor_ifaces += num; | ||
807 | } | ||
808 | |||
809 | static int cfg80211_netdev_notifier_call(struct notifier_block *nb, | ||
810 | unsigned long state, | 777 | unsigned long state, |
811 | void *ndev) | 778 | void *ndev) |
812 | { | 779 | { |
@@ -840,8 +807,7 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb, | |||
840 | spin_lock_init(&wdev->mgmt_registrations_lock); | 807 | spin_lock_init(&wdev->mgmt_registrations_lock); |
841 | 808 | ||
842 | mutex_lock(&rdev->devlist_mtx); | 809 | mutex_lock(&rdev->devlist_mtx); |
843 | wdev->identifier = ++rdev->wdev_id; | 810 | list_add_rcu(&wdev->list, &rdev->netdev_list); |
844 | list_add_rcu(&wdev->list, &rdev->wdev_list); | ||
845 | rdev->devlist_generation++; | 811 | rdev->devlist_generation++; |
846 | /* can only change netns with wiphy */ | 812 | /* can only change netns with wiphy */ |
847 | dev->features |= NETIF_F_NETNS_LOCAL; | 813 | dev->features |= NETIF_F_NETNS_LOCAL; |
@@ -866,7 +832,8 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb, | |||
866 | /* allow mac80211 to determine the timeout */ | 832 | /* allow mac80211 to determine the timeout */ |
867 | wdev->ps_timeout = -1; | 833 | wdev->ps_timeout = -1; |
868 | 834 | ||
869 | netdev_set_default_ethtool_ops(dev, &cfg80211_ethtool_ops); | 835 | if (!dev->ethtool_ops) |
836 | dev->ethtool_ops = &cfg80211_ethtool_ops; | ||
870 | 837 | ||
871 | if ((wdev->iftype == NL80211_IFTYPE_STATION || | 838 | if ((wdev->iftype == NL80211_IFTYPE_STATION || |
872 | wdev->iftype == NL80211_IFTYPE_P2P_CLIENT || | 839 | wdev->iftype == NL80211_IFTYPE_P2P_CLIENT || |
@@ -899,16 +866,12 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb, | |||
899 | case NL80211_IFTYPE_MESH_POINT: | 866 | case NL80211_IFTYPE_MESH_POINT: |
900 | cfg80211_leave_mesh(rdev, dev); | 867 | cfg80211_leave_mesh(rdev, dev); |
901 | break; | 868 | break; |
902 | case NL80211_IFTYPE_AP: | ||
903 | cfg80211_stop_ap(rdev, dev); | ||
904 | break; | ||
905 | default: | 869 | default: |
906 | break; | 870 | break; |
907 | } | 871 | } |
908 | wdev->beacon_interval = 0; | 872 | wdev->beacon_interval = 0; |
909 | break; | 873 | break; |
910 | case NETDEV_DOWN: | 874 | case NETDEV_DOWN: |
911 | cfg80211_update_iface_num(rdev, wdev->iftype, -1); | ||
912 | dev_hold(dev); | 875 | dev_hold(dev); |
913 | queue_work(cfg80211_wq, &wdev->cleanup_work); | 876 | queue_work(cfg80211_wq, &wdev->cleanup_work); |
914 | break; | 877 | break; |
@@ -925,7 +888,6 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb, | |||
925 | mutex_unlock(&rdev->devlist_mtx); | 888 | mutex_unlock(&rdev->devlist_mtx); |
926 | dev_put(dev); | 889 | dev_put(dev); |
927 | } | 890 | } |
928 | cfg80211_update_iface_num(rdev, wdev->iftype, 1); | ||
929 | cfg80211_lock_rdev(rdev); | 891 | cfg80211_lock_rdev(rdev); |
930 | mutex_lock(&rdev->devlist_mtx); | 892 | mutex_lock(&rdev->devlist_mtx); |
931 | wdev_lock(wdev); | 893 | wdev_lock(wdev); |
@@ -970,8 +932,9 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb, | |||
970 | if ((wdev->iftype == NL80211_IFTYPE_STATION || | 932 | if ((wdev->iftype == NL80211_IFTYPE_STATION || |
971 | wdev->iftype == NL80211_IFTYPE_P2P_CLIENT) && | 933 | wdev->iftype == NL80211_IFTYPE_P2P_CLIENT) && |
972 | rdev->ops->set_power_mgmt) | 934 | rdev->ops->set_power_mgmt) |
973 | if (rdev_set_power_mgmt(rdev, dev, wdev->ps, | 935 | if (rdev->ops->set_power_mgmt(wdev->wiphy, dev, |
974 | wdev->ps_timeout)) { | 936 | wdev->ps, |
937 | wdev->ps_timeout)) { | ||
975 | /* assume this means it's off */ | 938 | /* assume this means it's off */ |
976 | wdev->ps = false; | 939 | wdev->ps = false; |
977 | } | 940 | } |
@@ -1008,20 +971,13 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb, | |||
1008 | */ | 971 | */ |
1009 | synchronize_rcu(); | 972 | synchronize_rcu(); |
1010 | INIT_LIST_HEAD(&wdev->list); | 973 | INIT_LIST_HEAD(&wdev->list); |
1011 | /* | ||
1012 | * Ensure that all events have been processed and | ||
1013 | * freed. | ||
1014 | */ | ||
1015 | cfg80211_process_wdev_events(wdev); | ||
1016 | break; | 974 | break; |
1017 | case NETDEV_PRE_UP: | 975 | case NETDEV_PRE_UP: |
1018 | if (!(wdev->wiphy->interface_modes & BIT(wdev->iftype))) | 976 | if (!(wdev->wiphy->interface_modes & BIT(wdev->iftype))) |
1019 | return notifier_from_errno(-EOPNOTSUPP); | 977 | return notifier_from_errno(-EOPNOTSUPP); |
1020 | if (rfkill_blocked(rdev->rfkill)) | 978 | if (rfkill_blocked(rdev->rfkill)) |
1021 | return notifier_from_errno(-ERFKILL); | 979 | return notifier_from_errno(-ERFKILL); |
1022 | mutex_lock(&rdev->devlist_mtx); | ||
1023 | ret = cfg80211_can_add_interface(rdev, wdev->iftype); | 980 | ret = cfg80211_can_add_interface(rdev, wdev->iftype); |
1024 | mutex_unlock(&rdev->devlist_mtx); | ||
1025 | if (ret) | 981 | if (ret) |
1026 | return notifier_from_errno(ret); | 982 | return notifier_from_errno(ret); |
1027 | break; | 983 | break; |
diff --git a/net/wireless/core.h b/net/wireless/core.h index 3563097169c..8672e028022 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/debugfs.h> | 13 | #include <linux/debugfs.h> |
14 | #include <linux/rfkill.h> | 14 | #include <linux/rfkill.h> |
15 | #include <linux/workqueue.h> | 15 | #include <linux/workqueue.h> |
16 | #include <linux/rtnetlink.h> | ||
17 | #include <net/genetlink.h> | 16 | #include <net/genetlink.h> |
18 | #include <net/cfg80211.h> | 17 | #include <net/cfg80211.h> |
19 | #include "reg.h" | 18 | #include "reg.h" |
@@ -47,21 +46,14 @@ struct cfg80211_registered_device { | |||
47 | /* wiphy index, internal only */ | 46 | /* wiphy index, internal only */ |
48 | int wiphy_idx; | 47 | int wiphy_idx; |
49 | 48 | ||
50 | /* associated wireless interfaces */ | 49 | /* associate netdev list */ |
51 | struct mutex devlist_mtx; | 50 | struct mutex devlist_mtx; |
52 | /* protected by devlist_mtx or RCU */ | 51 | /* protected by devlist_mtx or RCU */ |
53 | struct list_head wdev_list; | 52 | struct list_head netdev_list; |
54 | int devlist_generation, wdev_id; | 53 | int devlist_generation; |
55 | int opencount; /* also protected by devlist_mtx */ | 54 | int opencount; /* also protected by devlist_mtx */ |
56 | wait_queue_head_t dev_wait; | 55 | wait_queue_head_t dev_wait; |
57 | 56 | ||
58 | struct list_head beacon_registrations; | ||
59 | spinlock_t beacon_registrations_lock; | ||
60 | |||
61 | /* protected by RTNL only */ | ||
62 | int num_running_ifaces; | ||
63 | int num_running_monitor_ifaces; | ||
64 | |||
65 | /* BSSes/scanning */ | 57 | /* BSSes/scanning */ |
66 | spinlock_t bss_lock; | 58 | spinlock_t bss_lock; |
67 | struct list_head bss_list; | 59 | struct list_head bss_list; |
@@ -138,6 +130,8 @@ struct cfg80211_internal_bss { | |||
138 | unsigned long ts; | 130 | unsigned long ts; |
139 | struct kref ref; | 131 | struct kref ref; |
140 | atomic_t hold; | 132 | atomic_t hold; |
133 | bool beacon_ies_allocated; | ||
134 | bool proberesp_ies_allocated; | ||
141 | 135 | ||
142 | /* must be last because of priv member */ | 136 | /* must be last because of priv member */ |
143 | struct cfg80211_bss pub; | 137 | struct cfg80211_bss pub; |
@@ -148,6 +142,11 @@ static inline struct cfg80211_internal_bss *bss_from_pub(struct cfg80211_bss *pu | |||
148 | return container_of(pub, struct cfg80211_internal_bss, pub); | 142 | return container_of(pub, struct cfg80211_internal_bss, pub); |
149 | } | 143 | } |
150 | 144 | ||
145 | static inline void cfg80211_ref_bss(struct cfg80211_internal_bss *bss) | ||
146 | { | ||
147 | kref_get(&bss->ref); | ||
148 | } | ||
149 | |||
151 | static inline void cfg80211_hold_bss(struct cfg80211_internal_bss *bss) | 150 | static inline void cfg80211_hold_bss(struct cfg80211_internal_bss *bss) |
152 | { | 151 | { |
153 | atomic_inc(&bss->hold); | 152 | atomic_inc(&bss->hold); |
@@ -163,6 +162,32 @@ static inline void cfg80211_unhold_bss(struct cfg80211_internal_bss *bss) | |||
163 | struct cfg80211_registered_device *cfg80211_rdev_by_wiphy_idx(int wiphy_idx); | 162 | struct cfg80211_registered_device *cfg80211_rdev_by_wiphy_idx(int wiphy_idx); |
164 | int get_wiphy_idx(struct wiphy *wiphy); | 163 | int get_wiphy_idx(struct wiphy *wiphy); |
165 | 164 | ||
165 | struct cfg80211_registered_device * | ||
166 | __cfg80211_rdev_from_info(struct genl_info *info); | ||
167 | |||
168 | /* | ||
169 | * This function returns a pointer to the driver | ||
170 | * that the genl_info item that is passed refers to. | ||
171 | * If successful, it returns non-NULL and also locks | ||
172 | * the driver's mutex! | ||
173 | * | ||
174 | * This means that you need to call cfg80211_unlock_rdev() | ||
175 | * before being allowed to acquire &cfg80211_mutex! | ||
176 | * | ||
177 | * This is necessary because we need to lock the global | ||
178 | * mutex to get an item off the list safely, and then | ||
179 | * we lock the rdev mutex so it doesn't go away under us. | ||
180 | * | ||
181 | * We don't want to keep cfg80211_mutex locked | ||
182 | * for all the time in order to allow requests on | ||
183 | * other interfaces to go through at the same time. | ||
184 | * | ||
185 | * The result of this can be a PTR_ERR and hence must | ||
186 | * be checked with IS_ERR() for errors. | ||
187 | */ | ||
188 | extern struct cfg80211_registered_device * | ||
189 | cfg80211_get_dev_from_info(struct genl_info *info); | ||
190 | |||
166 | /* requires cfg80211_rdev_mutex to be held! */ | 191 | /* requires cfg80211_rdev_mutex to be held! */ |
167 | struct wiphy *wiphy_idx_to_wiphy(int wiphy_idx); | 192 | struct wiphy *wiphy_idx_to_wiphy(int wiphy_idx); |
168 | 193 | ||
@@ -201,14 +226,6 @@ static inline void wdev_unlock(struct wireless_dev *wdev) | |||
201 | #define ASSERT_RDEV_LOCK(rdev) lockdep_assert_held(&(rdev)->mtx) | 226 | #define ASSERT_RDEV_LOCK(rdev) lockdep_assert_held(&(rdev)->mtx) |
202 | #define ASSERT_WDEV_LOCK(wdev) lockdep_assert_held(&(wdev)->mtx) | 227 | #define ASSERT_WDEV_LOCK(wdev) lockdep_assert_held(&(wdev)->mtx) |
203 | 228 | ||
204 | static inline bool cfg80211_has_monitors_only(struct cfg80211_registered_device *rdev) | ||
205 | { | ||
206 | ASSERT_RTNL(); | ||
207 | |||
208 | return rdev->num_running_ifaces == rdev->num_running_monitor_ifaces && | ||
209 | rdev->num_running_ifaces > 0; | ||
210 | } | ||
211 | |||
212 | enum cfg80211_event_type { | 229 | enum cfg80211_event_type { |
213 | EVENT_CONNECT_RESULT, | 230 | EVENT_CONNECT_RESULT, |
214 | EVENT_ROAMED, | 231 | EVENT_ROAMED, |
@@ -230,11 +247,12 @@ struct cfg80211_event { | |||
230 | u16 status; | 247 | u16 status; |
231 | } cr; | 248 | } cr; |
232 | struct { | 249 | struct { |
250 | struct ieee80211_channel *channel; | ||
251 | u8 bssid[ETH_ALEN]; | ||
233 | const u8 *req_ie; | 252 | const u8 *req_ie; |
234 | const u8 *resp_ie; | 253 | const u8 *resp_ie; |
235 | size_t req_ie_len; | 254 | size_t req_ie_len; |
236 | size_t resp_ie_len; | 255 | size_t resp_ie_len; |
237 | struct cfg80211_bss *bss; | ||
238 | } rm; | 256 | } rm; |
239 | struct { | 257 | struct { |
240 | const u8 *ie; | 258 | const u8 *ie; |
@@ -253,16 +271,6 @@ struct cfg80211_cached_keys { | |||
253 | int def, defmgmt; | 271 | int def, defmgmt; |
254 | }; | 272 | }; |
255 | 273 | ||
256 | enum cfg80211_chan_mode { | ||
257 | CHAN_MODE_UNDEFINED, | ||
258 | CHAN_MODE_SHARED, | ||
259 | CHAN_MODE_EXCLUSIVE, | ||
260 | }; | ||
261 | |||
262 | struct cfg80211_beacon_registration { | ||
263 | struct list_head list; | ||
264 | u32 nlportid; | ||
265 | }; | ||
266 | 274 | ||
267 | /* free object */ | 275 | /* free object */ |
268 | extern void cfg80211_dev_free(struct cfg80211_registered_device *rdev); | 276 | extern void cfg80211_dev_free(struct cfg80211_registered_device *rdev); |
@@ -271,6 +279,8 @@ extern int cfg80211_dev_rename(struct cfg80211_registered_device *rdev, | |||
271 | char *newname); | 279 | char *newname); |
272 | 280 | ||
273 | void ieee80211_set_bitrate_flags(struct wiphy *wiphy); | 281 | void ieee80211_set_bitrate_flags(struct wiphy *wiphy); |
282 | void wiphy_update_regulatory(struct wiphy *wiphy, | ||
283 | enum nl80211_reg_initiator setby); | ||
274 | 284 | ||
275 | void cfg80211_bss_expire(struct cfg80211_registered_device *dev); | 285 | void cfg80211_bss_expire(struct cfg80211_registered_device *dev); |
276 | void cfg80211_bss_age(struct cfg80211_registered_device *dev, | 286 | void cfg80211_bss_age(struct cfg80211_registered_device *dev, |
@@ -299,21 +309,14 @@ extern const struct mesh_config default_mesh_config; | |||
299 | extern const struct mesh_setup default_mesh_setup; | 309 | extern const struct mesh_setup default_mesh_setup; |
300 | int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev, | 310 | int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev, |
301 | struct net_device *dev, | 311 | struct net_device *dev, |
302 | struct mesh_setup *setup, | 312 | const struct mesh_setup *setup, |
303 | const struct mesh_config *conf); | 313 | const struct mesh_config *conf); |
304 | int cfg80211_join_mesh(struct cfg80211_registered_device *rdev, | 314 | int cfg80211_join_mesh(struct cfg80211_registered_device *rdev, |
305 | struct net_device *dev, | 315 | struct net_device *dev, |
306 | struct mesh_setup *setup, | 316 | const struct mesh_setup *setup, |
307 | const struct mesh_config *conf); | 317 | const struct mesh_config *conf); |
308 | int cfg80211_leave_mesh(struct cfg80211_registered_device *rdev, | 318 | int cfg80211_leave_mesh(struct cfg80211_registered_device *rdev, |
309 | struct net_device *dev); | 319 | struct net_device *dev); |
310 | int cfg80211_set_mesh_channel(struct cfg80211_registered_device *rdev, | ||
311 | struct wireless_dev *wdev, | ||
312 | struct cfg80211_chan_def *chandef); | ||
313 | |||
314 | /* AP */ | ||
315 | int cfg80211_stop_ap(struct cfg80211_registered_device *rdev, | ||
316 | struct net_device *dev); | ||
317 | 320 | ||
318 | /* MLME */ | 321 | /* MLME */ |
319 | int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, | 322 | int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, |
@@ -324,31 +327,27 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, | |||
324 | const u8 *ssid, int ssid_len, | 327 | const u8 *ssid, int ssid_len, |
325 | const u8 *ie, int ie_len, | 328 | const u8 *ie, int ie_len, |
326 | const u8 *key, int key_len, int key_idx, | 329 | const u8 *key, int key_len, int key_idx, |
327 | const u8 *sae_data, int sae_data_len); | 330 | bool local_state_change); |
328 | int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, | 331 | int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, |
329 | struct net_device *dev, struct ieee80211_channel *chan, | 332 | struct net_device *dev, struct ieee80211_channel *chan, |
330 | enum nl80211_auth_type auth_type, const u8 *bssid, | 333 | enum nl80211_auth_type auth_type, const u8 *bssid, |
331 | const u8 *ssid, int ssid_len, | 334 | const u8 *ssid, int ssid_len, |
332 | const u8 *ie, int ie_len, | 335 | const u8 *ie, int ie_len, |
333 | const u8 *key, int key_len, int key_idx, | 336 | const u8 *key, int key_len, int key_idx, |
334 | const u8 *sae_data, int sae_data_len); | 337 | bool local_state_change); |
335 | int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, | 338 | int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, |
336 | struct net_device *dev, | 339 | struct net_device *dev, |
337 | struct ieee80211_channel *chan, | 340 | struct ieee80211_channel *chan, |
338 | const u8 *bssid, const u8 *prev_bssid, | 341 | const u8 *bssid, const u8 *prev_bssid, |
339 | const u8 *ssid, int ssid_len, | 342 | const u8 *ssid, int ssid_len, |
340 | const u8 *ie, int ie_len, bool use_mfp, | 343 | const u8 *ie, int ie_len, bool use_mfp, |
341 | struct cfg80211_crypto_settings *crypt, | 344 | struct cfg80211_crypto_settings *crypt); |
342 | u32 assoc_flags, struct ieee80211_ht_cap *ht_capa, | ||
343 | struct ieee80211_ht_cap *ht_capa_mask); | ||
344 | int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, | 345 | int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, |
345 | struct net_device *dev, struct ieee80211_channel *chan, | 346 | struct net_device *dev, struct ieee80211_channel *chan, |
346 | const u8 *bssid, const u8 *prev_bssid, | 347 | const u8 *bssid, const u8 *prev_bssid, |
347 | const u8 *ssid, int ssid_len, | 348 | const u8 *ssid, int ssid_len, |
348 | const u8 *ie, int ie_len, bool use_mfp, | 349 | const u8 *ie, int ie_len, bool use_mfp, |
349 | struct cfg80211_crypto_settings *crypt, | 350 | struct cfg80211_crypto_settings *crypt); |
350 | u32 assoc_flags, struct ieee80211_ht_cap *ht_capa, | ||
351 | struct ieee80211_ht_cap *ht_capa_mask); | ||
352 | int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev, | 351 | int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev, |
353 | struct net_device *dev, const u8 *bssid, | 352 | struct net_device *dev, const u8 *bssid, |
354 | const u8 *ie, int ie_len, u16 reason, | 353 | const u8 *ie, int ie_len, u16 reason, |
@@ -374,12 +373,11 @@ int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_pid, | |||
374 | void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlpid); | 373 | void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlpid); |
375 | void cfg80211_mlme_purge_registrations(struct wireless_dev *wdev); | 374 | void cfg80211_mlme_purge_registrations(struct wireless_dev *wdev); |
376 | int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, | 375 | int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, |
377 | struct wireless_dev *wdev, | 376 | struct net_device *dev, |
378 | struct ieee80211_channel *chan, bool offchan, | 377 | struct ieee80211_channel *chan, bool offchan, |
379 | unsigned int wait, const u8 *buf, size_t len, | 378 | enum nl80211_channel_type channel_type, |
380 | bool no_cck, bool dont_wait_for_ack, u64 *cookie); | 379 | bool channel_type_valid, unsigned int wait, |
381 | void cfg80211_oper_and_ht_capa(struct ieee80211_ht_cap *ht_capa, | 380 | const u8 *buf, size_t len, u64 *cookie); |
382 | const struct ieee80211_ht_cap *ht_capa_mask); | ||
383 | 381 | ||
384 | /* SME */ | 382 | /* SME */ |
385 | int __cfg80211_connect(struct cfg80211_registered_device *rdev, | 383 | int __cfg80211_connect(struct cfg80211_registered_device *rdev, |
@@ -398,7 +396,8 @@ int cfg80211_disconnect(struct cfg80211_registered_device *rdev, | |||
398 | struct net_device *dev, u16 reason, | 396 | struct net_device *dev, u16 reason, |
399 | bool wextev); | 397 | bool wextev); |
400 | void __cfg80211_roamed(struct wireless_dev *wdev, | 398 | void __cfg80211_roamed(struct wireless_dev *wdev, |
401 | struct cfg80211_bss *bss, | 399 | struct ieee80211_channel *channel, |
400 | const u8 *bssid, | ||
402 | const u8 *req_ie, size_t req_ie_len, | 401 | const u8 *req_ie, size_t req_ie_len, |
403 | const u8 *resp_ie, size_t resp_ie_len); | 402 | const u8 *resp_ie, size_t resp_ie_len); |
404 | int cfg80211_mgd_wext_connect(struct cfg80211_registered_device *rdev, | 403 | int cfg80211_mgd_wext_connect(struct cfg80211_registered_device *rdev, |
@@ -409,7 +408,6 @@ void cfg80211_sme_failed_assoc(struct wireless_dev *wdev); | |||
409 | bool cfg80211_sme_failed_reassoc(struct wireless_dev *wdev); | 408 | bool cfg80211_sme_failed_reassoc(struct wireless_dev *wdev); |
410 | 409 | ||
411 | /* internal helpers */ | 410 | /* internal helpers */ |
412 | bool cfg80211_supported_cipher_suite(struct wiphy *wiphy, u32 cipher); | ||
413 | int cfg80211_validate_key_settings(struct cfg80211_registered_device *rdev, | 411 | int cfg80211_validate_key_settings(struct cfg80211_registered_device *rdev, |
414 | struct key_params *params, int key_idx, | 412 | struct key_params *params, int key_idx, |
415 | bool pairwise, const u8 *mac_addr); | 413 | bool pairwise, const u8 *mac_addr); |
@@ -417,8 +415,7 @@ void __cfg80211_disconnected(struct net_device *dev, const u8 *ie, | |||
417 | size_t ie_len, u16 reason, bool from_ap); | 415 | size_t ie_len, u16 reason, bool from_ap); |
418 | void cfg80211_sme_scan_done(struct net_device *dev); | 416 | void cfg80211_sme_scan_done(struct net_device *dev); |
419 | void cfg80211_sme_rx_auth(struct net_device *dev, const u8 *buf, size_t len); | 417 | void cfg80211_sme_rx_auth(struct net_device *dev, const u8 *buf, size_t len); |
420 | void cfg80211_sme_disassoc(struct net_device *dev, | 418 | void cfg80211_sme_disassoc(struct net_device *dev, int idx); |
421 | struct cfg80211_internal_bss *bss); | ||
422 | void __cfg80211_scan_done(struct work_struct *wk); | 419 | void __cfg80211_scan_done(struct work_struct *wk); |
423 | void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak); | 420 | void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak); |
424 | void __cfg80211_sched_scan_results(struct work_struct *wk); | 421 | void __cfg80211_sched_scan_results(struct work_struct *wk); |
@@ -429,22 +426,10 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev, | |||
429 | struct net_device *dev, enum nl80211_iftype ntype, | 426 | struct net_device *dev, enum nl80211_iftype ntype, |
430 | u32 *flags, struct vif_params *params); | 427 | u32 *flags, struct vif_params *params); |
431 | void cfg80211_process_rdev_events(struct cfg80211_registered_device *rdev); | 428 | void cfg80211_process_rdev_events(struct cfg80211_registered_device *rdev); |
432 | void cfg80211_process_wdev_events(struct wireless_dev *wdev); | ||
433 | |||
434 | int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev, | ||
435 | struct wireless_dev *wdev, | ||
436 | enum nl80211_iftype iftype, | ||
437 | struct ieee80211_channel *chan, | ||
438 | enum cfg80211_chan_mode chanmode); | ||
439 | 429 | ||
440 | static inline int | 430 | int cfg80211_can_change_interface(struct cfg80211_registered_device *rdev, |
441 | cfg80211_can_change_interface(struct cfg80211_registered_device *rdev, | 431 | struct wireless_dev *wdev, |
442 | struct wireless_dev *wdev, | 432 | enum nl80211_iftype iftype); |
443 | enum nl80211_iftype iftype) | ||
444 | { | ||
445 | return cfg80211_can_use_iftype_chan(rdev, wdev, iftype, NULL, | ||
446 | CHAN_MODE_UNDEFINED); | ||
447 | } | ||
448 | 433 | ||
449 | static inline int | 434 | static inline int |
450 | cfg80211_can_add_interface(struct cfg80211_registered_device *rdev, | 435 | cfg80211_can_add_interface(struct cfg80211_registered_device *rdev, |
@@ -453,23 +438,14 @@ cfg80211_can_add_interface(struct cfg80211_registered_device *rdev, | |||
453 | return cfg80211_can_change_interface(rdev, NULL, iftype); | 438 | return cfg80211_can_change_interface(rdev, NULL, iftype); |
454 | } | 439 | } |
455 | 440 | ||
456 | static inline int | 441 | struct ieee80211_channel * |
457 | cfg80211_can_use_chan(struct cfg80211_registered_device *rdev, | 442 | rdev_freq_to_chan(struct cfg80211_registered_device *rdev, |
458 | struct wireless_dev *wdev, | 443 | int freq, enum nl80211_channel_type channel_type); |
459 | struct ieee80211_channel *chan, | 444 | int cfg80211_set_freq(struct cfg80211_registered_device *rdev, |
460 | enum cfg80211_chan_mode chanmode) | 445 | struct wireless_dev *wdev, int freq, |
461 | { | 446 | enum nl80211_channel_type channel_type); |
462 | return cfg80211_can_use_iftype_chan(rdev, wdev, wdev->iftype, | ||
463 | chan, chanmode); | ||
464 | } | ||
465 | |||
466 | void | ||
467 | cfg80211_get_chan_state(struct wireless_dev *wdev, | ||
468 | struct ieee80211_channel **chan, | ||
469 | enum cfg80211_chan_mode *chanmode); | ||
470 | 447 | ||
471 | int cfg80211_set_monitor_channel(struct cfg80211_registered_device *rdev, | 448 | u16 cfg80211_calculate_bitrate(struct rate_info *rate); |
472 | struct cfg80211_chan_def *chandef); | ||
473 | 449 | ||
474 | int ieee80211_get_ratemask(struct ieee80211_supported_band *sband, | 450 | int ieee80211_get_ratemask(struct ieee80211_supported_band *sband, |
475 | const u8 *rates, unsigned int n_rates, | 451 | const u8 *rates, unsigned int n_rates, |
@@ -478,11 +454,6 @@ int ieee80211_get_ratemask(struct ieee80211_supported_band *sband, | |||
478 | int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev, | 454 | int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev, |
479 | u32 beacon_int); | 455 | u32 beacon_int); |
480 | 456 | ||
481 | void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev, | ||
482 | enum nl80211_iftype iftype, int num); | ||
483 | |||
484 | #define CFG80211_MAX_NUM_DIFFERENT_CHANNELS 10 | ||
485 | |||
486 | #ifdef CONFIG_CFG80211_DEVELOPER_WARNINGS | 457 | #ifdef CONFIG_CFG80211_DEVELOPER_WARNINGS |
487 | #define CFG80211_DEV_WARN_ON(cond) WARN_ON(cond) | 458 | #define CFG80211_DEV_WARN_ON(cond) WARN_ON(cond) |
488 | #else | 459 | #else |
diff --git a/net/wireless/debugfs.c b/net/wireless/debugfs.c index 920cabe0461..39765bcfb47 100644 --- a/net/wireless/debugfs.c +++ b/net/wireless/debugfs.c | |||
@@ -13,6 +13,12 @@ | |||
13 | #include "core.h" | 13 | #include "core.h" |
14 | #include "debugfs.h" | 14 | #include "debugfs.h" |
15 | 15 | ||
16 | static int cfg80211_open_file_generic(struct inode *inode, struct file *file) | ||
17 | { | ||
18 | file->private_data = inode->i_private; | ||
19 | return 0; | ||
20 | } | ||
21 | |||
16 | #define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...) \ | 22 | #define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...) \ |
17 | static ssize_t name## _read(struct file *file, char __user *userbuf, \ | 23 | static ssize_t name## _read(struct file *file, char __user *userbuf, \ |
18 | size_t count, loff_t *ppos) \ | 24 | size_t count, loff_t *ppos) \ |
@@ -27,7 +33,7 @@ static ssize_t name## _read(struct file *file, char __user *userbuf, \ | |||
27 | \ | 33 | \ |
28 | static const struct file_operations name## _ops = { \ | 34 | static const struct file_operations name## _ops = { \ |
29 | .read = name## _read, \ | 35 | .read = name## _read, \ |
30 | .open = simple_open, \ | 36 | .open = cfg80211_open_file_generic, \ |
31 | .llseek = generic_file_llseek, \ | 37 | .llseek = generic_file_llseek, \ |
32 | }; | 38 | }; |
33 | 39 | ||
@@ -96,7 +102,7 @@ static ssize_t ht40allow_map_read(struct file *file, | |||
96 | 102 | ||
97 | static const struct file_operations ht40allow_map_ops = { | 103 | static const struct file_operations ht40allow_map_ops = { |
98 | .read = ht40allow_map_read, | 104 | .read = ht40allow_map_read, |
99 | .open = simple_open, | 105 | .open = cfg80211_open_file_generic, |
100 | .llseek = default_llseek, | 106 | .llseek = default_llseek, |
101 | }; | 107 | }; |
102 | 108 | ||
diff --git a/net/wireless/ethtool.c b/net/wireless/ethtool.c index 48c48ffafa1..9bde4d1d3e9 100644 --- a/net/wireless/ethtool.c +++ b/net/wireless/ethtool.c | |||
@@ -2,7 +2,6 @@ | |||
2 | #include <net/cfg80211.h> | 2 | #include <net/cfg80211.h> |
3 | #include "core.h" | 3 | #include "core.h" |
4 | #include "ethtool.h" | 4 | #include "ethtool.h" |
5 | #include "rdev-ops.h" | ||
6 | 5 | ||
7 | static void cfg80211_get_drvinfo(struct net_device *dev, | 6 | static void cfg80211_get_drvinfo(struct net_device *dev, |
8 | struct ethtool_drvinfo *info) | 7 | struct ethtool_drvinfo *info) |
@@ -48,8 +47,9 @@ static void cfg80211_get_ringparam(struct net_device *dev, | |||
48 | memset(rp, 0, sizeof(*rp)); | 47 | memset(rp, 0, sizeof(*rp)); |
49 | 48 | ||
50 | if (rdev->ops->get_ringparam) | 49 | if (rdev->ops->get_ringparam) |
51 | rdev_get_ringparam(rdev, &rp->tx_pending, &rp->tx_max_pending, | 50 | rdev->ops->get_ringparam(wdev->wiphy, |
52 | &rp->rx_pending, &rp->rx_max_pending); | 51 | &rp->tx_pending, &rp->tx_max_pending, |
52 | &rp->rx_pending, &rp->rx_max_pending); | ||
53 | } | 53 | } |
54 | 54 | ||
55 | static int cfg80211_set_ringparam(struct net_device *dev, | 55 | static int cfg80211_set_ringparam(struct net_device *dev, |
@@ -62,37 +62,12 @@ static int cfg80211_set_ringparam(struct net_device *dev, | |||
62 | return -EINVAL; | 62 | return -EINVAL; |
63 | 63 | ||
64 | if (rdev->ops->set_ringparam) | 64 | if (rdev->ops->set_ringparam) |
65 | return rdev_set_ringparam(rdev, rp->tx_pending, rp->rx_pending); | 65 | return rdev->ops->set_ringparam(wdev->wiphy, |
66 | rp->tx_pending, rp->rx_pending); | ||
66 | 67 | ||
67 | return -ENOTSUPP; | 68 | return -ENOTSUPP; |
68 | } | 69 | } |
69 | 70 | ||
70 | static int cfg80211_get_sset_count(struct net_device *dev, int sset) | ||
71 | { | ||
72 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
73 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | ||
74 | if (rdev->ops->get_et_sset_count) | ||
75 | return rdev_get_et_sset_count(rdev, dev, sset); | ||
76 | return -EOPNOTSUPP; | ||
77 | } | ||
78 | |||
79 | static void cfg80211_get_stats(struct net_device *dev, | ||
80 | struct ethtool_stats *stats, u64 *data) | ||
81 | { | ||
82 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
83 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | ||
84 | if (rdev->ops->get_et_stats) | ||
85 | rdev_get_et_stats(rdev, dev, stats, data); | ||
86 | } | ||
87 | |||
88 | static void cfg80211_get_strings(struct net_device *dev, u32 sset, u8 *data) | ||
89 | { | ||
90 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
91 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | ||
92 | if (rdev->ops->get_et_strings) | ||
93 | rdev_get_et_strings(rdev, dev, sset, data); | ||
94 | } | ||
95 | |||
96 | const struct ethtool_ops cfg80211_ethtool_ops = { | 71 | const struct ethtool_ops cfg80211_ethtool_ops = { |
97 | .get_drvinfo = cfg80211_get_drvinfo, | 72 | .get_drvinfo = cfg80211_get_drvinfo, |
98 | .get_regs_len = cfg80211_get_regs_len, | 73 | .get_regs_len = cfg80211_get_regs_len, |
@@ -100,7 +75,4 @@ const struct ethtool_ops cfg80211_ethtool_ops = { | |||
100 | .get_link = ethtool_op_get_link, | 75 | .get_link = ethtool_op_get_link, |
101 | .get_ringparam = cfg80211_get_ringparam, | 76 | .get_ringparam = cfg80211_get_ringparam, |
102 | .set_ringparam = cfg80211_set_ringparam, | 77 | .set_ringparam = cfg80211_set_ringparam, |
103 | .get_strings = cfg80211_get_strings, | ||
104 | .get_ethtool_stats = cfg80211_get_stats, | ||
105 | .get_sset_count = cfg80211_get_sset_count, | ||
106 | }; | 78 | }; |
diff --git a/net/wireless/genregdb.awk b/net/wireless/genregdb.awk index 9392f8cbb90..53c143f5e77 100644 --- a/net/wireless/genregdb.awk +++ b/net/wireless/genregdb.awk | |||
@@ -7,17 +7,10 @@ | |||
7 | # | 7 | # |
8 | # Copyright 2009 John W. Linville <linville@tuxdriver.com> | 8 | # Copyright 2009 John W. Linville <linville@tuxdriver.com> |
9 | # | 9 | # |
10 | # Permission to use, copy, modify, and/or distribute this software for any | 10 | # This program is free software; you can redistribute it and/or modify |
11 | # purpose with or without fee is hereby granted, provided that the above | 11 | # it under the terms of the GNU General Public License version 2 as |
12 | # copyright notice and this permission notice appear in all copies. | 12 | # published by the Free Software Foundation. |
13 | # | 13 | # |
14 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
15 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
16 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
17 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
18 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
19 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
20 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
21 | 14 | ||
22 | BEGIN { | 15 | BEGIN { |
23 | active = 0 | 16 | active = 0 |
diff --git a/net/wireless/ibss.c b/net/wireless/ibss.c index 9b9551e4a6f..f33fbb79437 100644 --- a/net/wireless/ibss.c +++ b/net/wireless/ibss.c | |||
@@ -7,11 +7,9 @@ | |||
7 | #include <linux/etherdevice.h> | 7 | #include <linux/etherdevice.h> |
8 | #include <linux/if_arp.h> | 8 | #include <linux/if_arp.h> |
9 | #include <linux/slab.h> | 9 | #include <linux/slab.h> |
10 | #include <linux/export.h> | ||
11 | #include <net/cfg80211.h> | 10 | #include <net/cfg80211.h> |
12 | #include "wext-compat.h" | 11 | #include "wext-compat.h" |
13 | #include "nl80211.h" | 12 | #include "nl80211.h" |
14 | #include "rdev-ops.h" | ||
15 | 13 | ||
16 | 14 | ||
17 | void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid) | 15 | void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid) |
@@ -43,7 +41,6 @@ void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid) | |||
43 | cfg80211_hold_bss(bss_from_pub(bss)); | 41 | cfg80211_hold_bss(bss_from_pub(bss)); |
44 | wdev->current_bss = bss_from_pub(bss); | 42 | wdev->current_bss = bss_from_pub(bss); |
45 | 43 | ||
46 | wdev->sme_state = CFG80211_SME_CONNECTED; | ||
47 | cfg80211_upload_connect_keys(wdev); | 44 | cfg80211_upload_connect_keys(wdev); |
48 | 45 | ||
49 | nl80211_send_ibss_bssid(wiphy_to_dev(wdev->wiphy), dev, bssid, | 46 | nl80211_send_ibss_bssid(wiphy_to_dev(wdev->wiphy), dev, bssid, |
@@ -62,9 +59,7 @@ void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid, gfp_t gfp) | |||
62 | struct cfg80211_event *ev; | 59 | struct cfg80211_event *ev; |
63 | unsigned long flags; | 60 | unsigned long flags; |
64 | 61 | ||
65 | trace_cfg80211_ibss_joined(dev, bssid); | 62 | CFG80211_DEV_WARN_ON(!wdev->ssid_len); |
66 | |||
67 | CFG80211_DEV_WARN_ON(wdev->sme_state != CFG80211_SME_CONNECTING); | ||
68 | 63 | ||
69 | ev = kzalloc(sizeof(*ev), gfp); | 64 | ev = kzalloc(sizeof(*ev), gfp); |
70 | if (!ev) | 65 | if (!ev) |
@@ -100,9 +95,9 @@ int __cfg80211_join_ibss(struct cfg80211_registered_device *rdev, | |||
100 | * 11a for maximum compatibility. | 95 | * 11a for maximum compatibility. |
101 | */ | 96 | */ |
102 | struct ieee80211_supported_band *sband = | 97 | struct ieee80211_supported_band *sband = |
103 | rdev->wiphy.bands[params->chandef.chan->band]; | 98 | rdev->wiphy.bands[params->channel->band]; |
104 | int j; | 99 | int j; |
105 | u32 flag = params->chandef.chan->band == IEEE80211_BAND_5GHZ ? | 100 | u32 flag = params->channel->band == IEEE80211_BAND_5GHZ ? |
106 | IEEE80211_RATE_MANDATORY_A : | 101 | IEEE80211_RATE_MANDATORY_A : |
107 | IEEE80211_RATE_MANDATORY_B; | 102 | IEEE80211_RATE_MANDATORY_B; |
108 | 103 | ||
@@ -116,25 +111,12 @@ int __cfg80211_join_ibss(struct cfg80211_registered_device *rdev, | |||
116 | kfree(wdev->connect_keys); | 111 | kfree(wdev->connect_keys); |
117 | wdev->connect_keys = connkeys; | 112 | wdev->connect_keys = connkeys; |
118 | 113 | ||
119 | wdev->ibss_fixed = params->channel_fixed; | ||
120 | #ifdef CONFIG_CFG80211_WEXT | 114 | #ifdef CONFIG_CFG80211_WEXT |
121 | wdev->wext.ibss.chandef = params->chandef; | 115 | wdev->wext.ibss.channel = params->channel; |
122 | #endif | 116 | #endif |
123 | wdev->sme_state = CFG80211_SME_CONNECTING; | 117 | err = rdev->ops->join_ibss(&rdev->wiphy, dev, params); |
124 | |||
125 | err = cfg80211_can_use_chan(rdev, wdev, params->chandef.chan, | ||
126 | params->channel_fixed | ||
127 | ? CHAN_MODE_SHARED | ||
128 | : CHAN_MODE_EXCLUSIVE); | ||
129 | if (err) { | ||
130 | wdev->connect_keys = NULL; | ||
131 | return err; | ||
132 | } | ||
133 | |||
134 | err = rdev_join_ibss(rdev, dev, params); | ||
135 | if (err) { | 118 | if (err) { |
136 | wdev->connect_keys = NULL; | 119 | wdev->connect_keys = NULL; |
137 | wdev->sme_state = CFG80211_SME_IDLE; | ||
138 | return err; | 120 | return err; |
139 | } | 121 | } |
140 | 122 | ||
@@ -178,7 +160,7 @@ static void __cfg80211_clear_ibss(struct net_device *dev, bool nowext) | |||
178 | */ | 160 | */ |
179 | if (rdev->ops->del_key) | 161 | if (rdev->ops->del_key) |
180 | for (i = 0; i < 6; i++) | 162 | for (i = 0; i < 6; i++) |
181 | rdev_del_key(rdev, dev, i, false, NULL); | 163 | rdev->ops->del_key(wdev->wiphy, dev, i, false, NULL); |
182 | 164 | ||
183 | if (wdev->current_bss) { | 165 | if (wdev->current_bss) { |
184 | cfg80211_unhold_bss(wdev->current_bss); | 166 | cfg80211_unhold_bss(wdev->current_bss); |
@@ -186,7 +168,6 @@ static void __cfg80211_clear_ibss(struct net_device *dev, bool nowext) | |||
186 | } | 168 | } |
187 | 169 | ||
188 | wdev->current_bss = NULL; | 170 | wdev->current_bss = NULL; |
189 | wdev->sme_state = CFG80211_SME_IDLE; | ||
190 | wdev->ssid_len = 0; | 171 | wdev->ssid_len = 0; |
191 | #ifdef CONFIG_CFG80211_WEXT | 172 | #ifdef CONFIG_CFG80211_WEXT |
192 | if (!nowext) | 173 | if (!nowext) |
@@ -214,7 +195,7 @@ int __cfg80211_leave_ibss(struct cfg80211_registered_device *rdev, | |||
214 | if (!wdev->ssid_len) | 195 | if (!wdev->ssid_len) |
215 | return -ENOLINK; | 196 | return -ENOLINK; |
216 | 197 | ||
217 | err = rdev_leave_ibss(rdev, dev); | 198 | err = rdev->ops->leave_ibss(&rdev->wiphy, dev); |
218 | 199 | ||
219 | if (err) | 200 | if (err) |
220 | return err; | 201 | return err; |
@@ -251,9 +232,7 @@ int cfg80211_ibss_wext_join(struct cfg80211_registered_device *rdev, | |||
251 | wdev->wext.ibss.beacon_interval = 100; | 232 | wdev->wext.ibss.beacon_interval = 100; |
252 | 233 | ||
253 | /* try to find an IBSS channel if none requested ... */ | 234 | /* try to find an IBSS channel if none requested ... */ |
254 | if (!wdev->wext.ibss.chandef.chan) { | 235 | if (!wdev->wext.ibss.channel) { |
255 | wdev->wext.ibss.chandef.width = NL80211_CHAN_WIDTH_20_NOHT; | ||
256 | |||
257 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) { | 236 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) { |
258 | struct ieee80211_supported_band *sband; | 237 | struct ieee80211_supported_band *sband; |
259 | struct ieee80211_channel *chan; | 238 | struct ieee80211_channel *chan; |
@@ -268,15 +247,15 @@ int cfg80211_ibss_wext_join(struct cfg80211_registered_device *rdev, | |||
268 | continue; | 247 | continue; |
269 | if (chan->flags & IEEE80211_CHAN_DISABLED) | 248 | if (chan->flags & IEEE80211_CHAN_DISABLED) |
270 | continue; | 249 | continue; |
271 | wdev->wext.ibss.chandef.chan = chan; | 250 | wdev->wext.ibss.channel = chan; |
272 | break; | 251 | break; |
273 | } | 252 | } |
274 | 253 | ||
275 | if (wdev->wext.ibss.chandef.chan) | 254 | if (wdev->wext.ibss.channel) |
276 | break; | 255 | break; |
277 | } | 256 | } |
278 | 257 | ||
279 | if (!wdev->wext.ibss.chandef.chan) | 258 | if (!wdev->wext.ibss.channel) |
280 | return -EINVAL; | 259 | return -EINVAL; |
281 | } | 260 | } |
282 | 261 | ||
@@ -338,7 +317,7 @@ int cfg80211_ibss_wext_siwfreq(struct net_device *dev, | |||
338 | return -EINVAL; | 317 | return -EINVAL; |
339 | } | 318 | } |
340 | 319 | ||
341 | if (wdev->wext.ibss.chandef.chan == chan) | 320 | if (wdev->wext.ibss.channel == chan) |
342 | return 0; | 321 | return 0; |
343 | 322 | ||
344 | wdev_lock(wdev); | 323 | wdev_lock(wdev); |
@@ -351,8 +330,7 @@ int cfg80211_ibss_wext_siwfreq(struct net_device *dev, | |||
351 | return err; | 330 | return err; |
352 | 331 | ||
353 | if (chan) { | 332 | if (chan) { |
354 | wdev->wext.ibss.chandef.chan = chan; | 333 | wdev->wext.ibss.channel = chan; |
355 | wdev->wext.ibss.chandef.width = NL80211_CHAN_WIDTH_20_NOHT; | ||
356 | wdev->wext.ibss.channel_fixed = true; | 334 | wdev->wext.ibss.channel_fixed = true; |
357 | } else { | 335 | } else { |
358 | /* cfg80211_ibss_wext_join will pick one if needed */ | 336 | /* cfg80211_ibss_wext_join will pick one if needed */ |
@@ -382,8 +360,8 @@ int cfg80211_ibss_wext_giwfreq(struct net_device *dev, | |||
382 | wdev_lock(wdev); | 360 | wdev_lock(wdev); |
383 | if (wdev->current_bss) | 361 | if (wdev->current_bss) |
384 | chan = wdev->current_bss->pub.channel; | 362 | chan = wdev->current_bss->pub.channel; |
385 | else if (wdev->wext.ibss.chandef.chan) | 363 | else if (wdev->wext.ibss.channel) |
386 | chan = wdev->wext.ibss.chandef.chan; | 364 | chan = wdev->wext.ibss.channel; |
387 | wdev_unlock(wdev); | 365 | wdev_unlock(wdev); |
388 | 366 | ||
389 | if (chan) { | 367 | if (chan) { |
@@ -494,7 +472,7 @@ int cfg80211_ibss_wext_siwap(struct net_device *dev, | |||
494 | 472 | ||
495 | /* fixed already - and no change */ | 473 | /* fixed already - and no change */ |
496 | if (wdev->wext.ibss.bssid && bssid && | 474 | if (wdev->wext.ibss.bssid && bssid && |
497 | ether_addr_equal(bssid, wdev->wext.ibss.bssid)) | 475 | compare_ether_addr(bssid, wdev->wext.ibss.bssid) == 0) |
498 | return 0; | 476 | return 0; |
499 | 477 | ||
500 | wdev_lock(wdev); | 478 | wdev_lock(wdev); |
diff --git a/net/wireless/lib80211.c b/net/wireless/lib80211.c index a55c27b75ee..3268fac5ab2 100644 --- a/net/wireless/lib80211.c +++ b/net/wireless/lib80211.c | |||
@@ -41,11 +41,6 @@ struct lib80211_crypto_alg { | |||
41 | static LIST_HEAD(lib80211_crypto_algs); | 41 | static LIST_HEAD(lib80211_crypto_algs); |
42 | static DEFINE_SPINLOCK(lib80211_crypto_lock); | 42 | static DEFINE_SPINLOCK(lib80211_crypto_lock); |
43 | 43 | ||
44 | static void lib80211_crypt_deinit_entries(struct lib80211_crypt_info *info, | ||
45 | int force); | ||
46 | static void lib80211_crypt_quiescing(struct lib80211_crypt_info *info); | ||
47 | static void lib80211_crypt_deinit_handler(unsigned long data); | ||
48 | |||
49 | const char *print_ssid(char *buf, const char *ssid, u8 ssid_len) | 44 | const char *print_ssid(char *buf, const char *ssid, u8 ssid_len) |
50 | { | 45 | { |
51 | const char *s = ssid; | 46 | const char *s = ssid; |
@@ -116,8 +111,7 @@ void lib80211_crypt_info_free(struct lib80211_crypt_info *info) | |||
116 | } | 111 | } |
117 | EXPORT_SYMBOL(lib80211_crypt_info_free); | 112 | EXPORT_SYMBOL(lib80211_crypt_info_free); |
118 | 113 | ||
119 | static void lib80211_crypt_deinit_entries(struct lib80211_crypt_info *info, | 114 | void lib80211_crypt_deinit_entries(struct lib80211_crypt_info *info, int force) |
120 | int force) | ||
121 | { | 115 | { |
122 | struct lib80211_crypt_data *entry, *next; | 116 | struct lib80211_crypt_data *entry, *next; |
123 | unsigned long flags; | 117 | unsigned long flags; |
@@ -137,9 +131,10 @@ static void lib80211_crypt_deinit_entries(struct lib80211_crypt_info *info, | |||
137 | } | 131 | } |
138 | spin_unlock_irqrestore(info->lock, flags); | 132 | spin_unlock_irqrestore(info->lock, flags); |
139 | } | 133 | } |
134 | EXPORT_SYMBOL(lib80211_crypt_deinit_entries); | ||
140 | 135 | ||
141 | /* After this, crypt_deinit_list won't accept new members */ | 136 | /* After this, crypt_deinit_list won't accept new members */ |
142 | static void lib80211_crypt_quiescing(struct lib80211_crypt_info *info) | 137 | void lib80211_crypt_quiescing(struct lib80211_crypt_info *info) |
143 | { | 138 | { |
144 | unsigned long flags; | 139 | unsigned long flags; |
145 | 140 | ||
@@ -147,8 +142,9 @@ static void lib80211_crypt_quiescing(struct lib80211_crypt_info *info) | |||
147 | info->crypt_quiesced = 1; | 142 | info->crypt_quiesced = 1; |
148 | spin_unlock_irqrestore(info->lock, flags); | 143 | spin_unlock_irqrestore(info->lock, flags); |
149 | } | 144 | } |
145 | EXPORT_SYMBOL(lib80211_crypt_quiescing); | ||
150 | 146 | ||
151 | static void lib80211_crypt_deinit_handler(unsigned long data) | 147 | void lib80211_crypt_deinit_handler(unsigned long data) |
152 | { | 148 | { |
153 | struct lib80211_crypt_info *info = (struct lib80211_crypt_info *)data; | 149 | struct lib80211_crypt_info *info = (struct lib80211_crypt_info *)data; |
154 | unsigned long flags; | 150 | unsigned long flags; |
@@ -164,6 +160,7 @@ static void lib80211_crypt_deinit_handler(unsigned long data) | |||
164 | } | 160 | } |
165 | spin_unlock_irqrestore(info->lock, flags); | 161 | spin_unlock_irqrestore(info->lock, flags); |
166 | } | 162 | } |
163 | EXPORT_SYMBOL(lib80211_crypt_deinit_handler); | ||
167 | 164 | ||
168 | void lib80211_crypt_delayed_deinit(struct lib80211_crypt_info *info, | 165 | void lib80211_crypt_delayed_deinit(struct lib80211_crypt_info *info, |
169 | struct lib80211_crypt_data **crypt) | 166 | struct lib80211_crypt_data **crypt) |
diff --git a/net/wireless/lib80211_crypt_ccmp.c b/net/wireless/lib80211_crypt_ccmp.c index 1526c211db6..dacb3b4b1bd 100644 --- a/net/wireless/lib80211_crypt_ccmp.c +++ b/net/wireless/lib80211_crypt_ccmp.c | |||
@@ -77,6 +77,8 @@ static void *lib80211_ccmp_init(int key_idx) | |||
77 | 77 | ||
78 | priv->tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); | 78 | priv->tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); |
79 | if (IS_ERR(priv->tfm)) { | 79 | if (IS_ERR(priv->tfm)) { |
80 | printk(KERN_DEBUG "lib80211_crypt_ccmp: could not allocate " | ||
81 | "crypto API aes\n"); | ||
80 | priv->tfm = NULL; | 82 | priv->tfm = NULL; |
81 | goto fail; | 83 | goto fail; |
82 | } | 84 | } |
@@ -304,8 +306,10 @@ static int lib80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
304 | pos = skb->data + hdr_len; | 306 | pos = skb->data + hdr_len; |
305 | keyidx = pos[3]; | 307 | keyidx = pos[3]; |
306 | if (!(keyidx & (1 << 5))) { | 308 | if (!(keyidx & (1 << 5))) { |
307 | net_dbg_ratelimited("CCMP: received packet without ExtIV flag from %pM\n", | 309 | if (net_ratelimit()) { |
308 | hdr->addr2); | 310 | printk(KERN_DEBUG "CCMP: received packet without ExtIV" |
311 | " flag from %pM\n", hdr->addr2); | ||
312 | } | ||
309 | key->dot11RSNAStatsCCMPFormatErrors++; | 313 | key->dot11RSNAStatsCCMPFormatErrors++; |
310 | return -2; | 314 | return -2; |
311 | } | 315 | } |
@@ -316,8 +320,11 @@ static int lib80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
316 | return -6; | 320 | return -6; |
317 | } | 321 | } |
318 | if (!key->key_set) { | 322 | if (!key->key_set) { |
319 | net_dbg_ratelimited("CCMP: received packet from %pM with keyid=%d that does not have a configured key\n", | 323 | if (net_ratelimit()) { |
320 | hdr->addr2, keyidx); | 324 | printk(KERN_DEBUG "CCMP: received packet from %pM" |
325 | " with keyid=%d that does not have a configured" | ||
326 | " key\n", hdr->addr2, keyidx); | ||
327 | } | ||
321 | return -3; | 328 | return -3; |
322 | } | 329 | } |
323 | 330 | ||
@@ -331,11 +338,15 @@ static int lib80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
331 | 338 | ||
332 | if (ccmp_replay_check(pn, key->rx_pn)) { | 339 | if (ccmp_replay_check(pn, key->rx_pn)) { |
333 | #ifdef CONFIG_LIB80211_DEBUG | 340 | #ifdef CONFIG_LIB80211_DEBUG |
334 | net_dbg_ratelimited("CCMP: replay detected: STA=%pM previous PN %02x%02x%02x%02x%02x%02x received PN %02x%02x%02x%02x%02x%02x\n", | 341 | if (net_ratelimit()) { |
335 | hdr->addr2, | 342 | printk(KERN_DEBUG "CCMP: replay detected: STA=%pM " |
336 | key->rx_pn[0], key->rx_pn[1], key->rx_pn[2], | 343 | "previous PN %02x%02x%02x%02x%02x%02x " |
337 | key->rx_pn[3], key->rx_pn[4], key->rx_pn[5], | 344 | "received PN %02x%02x%02x%02x%02x%02x\n", |
338 | pn[0], pn[1], pn[2], pn[3], pn[4], pn[5]); | 345 | hdr->addr2, |
346 | key->rx_pn[0], key->rx_pn[1], key->rx_pn[2], | ||
347 | key->rx_pn[3], key->rx_pn[4], key->rx_pn[5], | ||
348 | pn[0], pn[1], pn[2], pn[3], pn[4], pn[5]); | ||
349 | } | ||
339 | #endif | 350 | #endif |
340 | key->dot11RSNAStatsCCMPReplays++; | 351 | key->dot11RSNAStatsCCMPReplays++; |
341 | return -4; | 352 | return -4; |
@@ -361,8 +372,10 @@ static int lib80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
361 | } | 372 | } |
362 | 373 | ||
363 | if (memcmp(mic, a, CCMP_MIC_LEN) != 0) { | 374 | if (memcmp(mic, a, CCMP_MIC_LEN) != 0) { |
364 | net_dbg_ratelimited("CCMP: decrypt failed: STA=%pM\n", | 375 | if (net_ratelimit()) { |
365 | hdr->addr2); | 376 | printk(KERN_DEBUG "CCMP: decrypt failed: STA=" |
377 | "%pM\n", hdr->addr2); | ||
378 | } | ||
366 | key->dot11RSNAStatsCCMPDecryptErrors++; | 379 | key->dot11RSNAStatsCCMPDecryptErrors++; |
367 | return -5; | 380 | return -5; |
368 | } | 381 | } |
diff --git a/net/wireless/lib80211_crypt_tkip.c b/net/wireless/lib80211_crypt_tkip.c index d475cfc8568..7ea4f2b0770 100644 --- a/net/wireless/lib80211_crypt_tkip.c +++ b/net/wireless/lib80211_crypt_tkip.c | |||
@@ -101,6 +101,7 @@ static void *lib80211_tkip_init(int key_idx) | |||
101 | priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, | 101 | priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, |
102 | CRYPTO_ALG_ASYNC); | 102 | CRYPTO_ALG_ASYNC); |
103 | if (IS_ERR(priv->tx_tfm_arc4)) { | 103 | if (IS_ERR(priv->tx_tfm_arc4)) { |
104 | printk(KERN_DEBUG pr_fmt("could not allocate crypto API arc4\n")); | ||
104 | priv->tx_tfm_arc4 = NULL; | 105 | priv->tx_tfm_arc4 = NULL; |
105 | goto fail; | 106 | goto fail; |
106 | } | 107 | } |
@@ -108,6 +109,7 @@ static void *lib80211_tkip_init(int key_idx) | |||
108 | priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0, | 109 | priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0, |
109 | CRYPTO_ALG_ASYNC); | 110 | CRYPTO_ALG_ASYNC); |
110 | if (IS_ERR(priv->tx_tfm_michael)) { | 111 | if (IS_ERR(priv->tx_tfm_michael)) { |
112 | printk(KERN_DEBUG pr_fmt("could not allocate crypto API michael_mic\n")); | ||
111 | priv->tx_tfm_michael = NULL; | 113 | priv->tx_tfm_michael = NULL; |
112 | goto fail; | 114 | goto fail; |
113 | } | 115 | } |
@@ -115,6 +117,7 @@ static void *lib80211_tkip_init(int key_idx) | |||
115 | priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, | 117 | priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, |
116 | CRYPTO_ALG_ASYNC); | 118 | CRYPTO_ALG_ASYNC); |
117 | if (IS_ERR(priv->rx_tfm_arc4)) { | 119 | if (IS_ERR(priv->rx_tfm_arc4)) { |
120 | printk(KERN_DEBUG pr_fmt("could not allocate crypto API arc4\n")); | ||
118 | priv->rx_tfm_arc4 = NULL; | 121 | priv->rx_tfm_arc4 = NULL; |
119 | goto fail; | 122 | goto fail; |
120 | } | 123 | } |
@@ -122,6 +125,7 @@ static void *lib80211_tkip_init(int key_idx) | |||
122 | priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0, | 125 | priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0, |
123 | CRYPTO_ALG_ASYNC); | 126 | CRYPTO_ALG_ASYNC); |
124 | if (IS_ERR(priv->rx_tfm_michael)) { | 127 | if (IS_ERR(priv->rx_tfm_michael)) { |
128 | printk(KERN_DEBUG pr_fmt("could not allocate crypto API michael_mic\n")); | ||
125 | priv->rx_tfm_michael = NULL; | 129 | priv->rx_tfm_michael = NULL; |
126 | goto fail; | 130 | goto fail; |
127 | } | 131 | } |
@@ -360,9 +364,12 @@ static int lib80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
360 | struct scatterlist sg; | 364 | struct scatterlist sg; |
361 | 365 | ||
362 | if (tkey->flags & IEEE80211_CRYPTO_TKIP_COUNTERMEASURES) { | 366 | if (tkey->flags & IEEE80211_CRYPTO_TKIP_COUNTERMEASURES) { |
363 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | 367 | if (net_ratelimit()) { |
364 | net_dbg_ratelimited("TKIP countermeasures: dropped TX packet to %pM\n", | 368 | struct ieee80211_hdr *hdr = |
365 | hdr->addr1); | 369 | (struct ieee80211_hdr *)skb->data; |
370 | printk(KERN_DEBUG ": TKIP countermeasures: dropped " | ||
371 | "TX packet to %pM\n", hdr->addr1); | ||
372 | } | ||
366 | return -1; | 373 | return -1; |
367 | } | 374 | } |
368 | 375 | ||
@@ -417,8 +424,10 @@ static int lib80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
417 | hdr = (struct ieee80211_hdr *)skb->data; | 424 | hdr = (struct ieee80211_hdr *)skb->data; |
418 | 425 | ||
419 | if (tkey->flags & IEEE80211_CRYPTO_TKIP_COUNTERMEASURES) { | 426 | if (tkey->flags & IEEE80211_CRYPTO_TKIP_COUNTERMEASURES) { |
420 | net_dbg_ratelimited("TKIP countermeasures: dropped received packet from %pM\n", | 427 | if (net_ratelimit()) { |
421 | hdr->addr2); | 428 | printk(KERN_DEBUG ": TKIP countermeasures: dropped " |
429 | "received packet from %pM\n", hdr->addr2); | ||
430 | } | ||
422 | return -1; | 431 | return -1; |
423 | } | 432 | } |
424 | 433 | ||
@@ -428,8 +437,10 @@ static int lib80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
428 | pos = skb->data + hdr_len; | 437 | pos = skb->data + hdr_len; |
429 | keyidx = pos[3]; | 438 | keyidx = pos[3]; |
430 | if (!(keyidx & (1 << 5))) { | 439 | if (!(keyidx & (1 << 5))) { |
431 | net_dbg_ratelimited("TKIP: received packet without ExtIV flag from %pM\n", | 440 | if (net_ratelimit()) { |
432 | hdr->addr2); | 441 | printk(KERN_DEBUG "TKIP: received packet without ExtIV" |
442 | " flag from %pM\n", hdr->addr2); | ||
443 | } | ||
433 | return -2; | 444 | return -2; |
434 | } | 445 | } |
435 | keyidx >>= 6; | 446 | keyidx >>= 6; |
@@ -439,8 +450,11 @@ static int lib80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
439 | return -6; | 450 | return -6; |
440 | } | 451 | } |
441 | if (!tkey->key_set) { | 452 | if (!tkey->key_set) { |
442 | net_dbg_ratelimited("TKIP: received packet from %pM with keyid=%d that does not have a configured key\n", | 453 | if (net_ratelimit()) { |
443 | hdr->addr2, keyidx); | 454 | printk(KERN_DEBUG "TKIP: received packet from %pM" |
455 | " with keyid=%d that does not have a configured" | ||
456 | " key\n", hdr->addr2, keyidx); | ||
457 | } | ||
444 | return -3; | 458 | return -3; |
445 | } | 459 | } |
446 | iv16 = (pos[0] << 8) | pos[2]; | 460 | iv16 = (pos[0] << 8) | pos[2]; |
@@ -449,9 +463,12 @@ static int lib80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
449 | 463 | ||
450 | if (tkip_replay_check(iv32, iv16, tkey->rx_iv32, tkey->rx_iv16)) { | 464 | if (tkip_replay_check(iv32, iv16, tkey->rx_iv32, tkey->rx_iv16)) { |
451 | #ifdef CONFIG_LIB80211_DEBUG | 465 | #ifdef CONFIG_LIB80211_DEBUG |
452 | net_dbg_ratelimited("TKIP: replay detected: STA=%pM previous TSC %08x%04x received TSC %08x%04x\n", | 466 | if (net_ratelimit()) { |
453 | hdr->addr2, tkey->rx_iv32, tkey->rx_iv16, | 467 | printk(KERN_DEBUG "TKIP: replay detected: STA=%pM" |
454 | iv32, iv16); | 468 | " previous TSC %08x%04x received TSC " |
469 | "%08x%04x\n", hdr->addr2, | ||
470 | tkey->rx_iv32, tkey->rx_iv16, iv32, iv16); | ||
471 | } | ||
455 | #endif | 472 | #endif |
456 | tkey->dot11RSNAStatsTKIPReplays++; | 473 | tkey->dot11RSNAStatsTKIPReplays++; |
457 | return -4; | 474 | return -4; |
@@ -468,8 +485,11 @@ static int lib80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
468 | crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16); | 485 | crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16); |
469 | sg_init_one(&sg, pos, plen + 4); | 486 | sg_init_one(&sg, pos, plen + 4); |
470 | if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) { | 487 | if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) { |
471 | net_dbg_ratelimited("TKIP: failed to decrypt received packet from %pM\n", | 488 | if (net_ratelimit()) { |
472 | hdr->addr2); | 489 | printk(KERN_DEBUG ": TKIP: failed to decrypt " |
490 | "received packet from %pM\n", | ||
491 | hdr->addr2); | ||
492 | } | ||
473 | return -7; | 493 | return -7; |
474 | } | 494 | } |
475 | 495 | ||
@@ -485,8 +505,10 @@ static int lib80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
485 | tkey->rx_phase1_done = 0; | 505 | tkey->rx_phase1_done = 0; |
486 | } | 506 | } |
487 | #ifdef CONFIG_LIB80211_DEBUG | 507 | #ifdef CONFIG_LIB80211_DEBUG |
488 | net_dbg_ratelimited("TKIP: ICV error detected: STA=%pM\n", | 508 | if (net_ratelimit()) { |
489 | hdr->addr2); | 509 | printk(KERN_DEBUG "TKIP: ICV error detected: STA=" |
510 | "%pM\n", hdr->addr2); | ||
511 | } | ||
490 | #endif | 512 | #endif |
491 | tkey->dot11RSNAStatsTKIPICVErrors++; | 513 | tkey->dot11RSNAStatsTKIPICVErrors++; |
492 | return -5; | 514 | return -5; |
diff --git a/net/wireless/lib80211_crypt_wep.c b/net/wireless/lib80211_crypt_wep.c index c1304018fc1..2f265e033ae 100644 --- a/net/wireless/lib80211_crypt_wep.c +++ b/net/wireless/lib80211_crypt_wep.c | |||
@@ -50,12 +50,16 @@ static void *lib80211_wep_init(int keyidx) | |||
50 | 50 | ||
51 | priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); | 51 | priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); |
52 | if (IS_ERR(priv->tx_tfm)) { | 52 | if (IS_ERR(priv->tx_tfm)) { |
53 | printk(KERN_DEBUG "lib80211_crypt_wep: could not allocate " | ||
54 | "crypto API arc4\n"); | ||
53 | priv->tx_tfm = NULL; | 55 | priv->tx_tfm = NULL; |
54 | goto fail; | 56 | goto fail; |
55 | } | 57 | } |
56 | 58 | ||
57 | priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); | 59 | priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); |
58 | if (IS_ERR(priv->rx_tfm)) { | 60 | if (IS_ERR(priv->rx_tfm)) { |
61 | printk(KERN_DEBUG "lib80211_crypt_wep: could not allocate " | ||
62 | "crypto API arc4\n"); | ||
59 | priv->rx_tfm = NULL; | 63 | priv->rx_tfm = NULL; |
60 | goto fail; | 64 | goto fail; |
61 | } | 65 | } |
diff --git a/net/wireless/mesh.c b/net/wireless/mesh.c index f9d6ce5cfab..5c116083eec 100644 --- a/net/wireless/mesh.c +++ b/net/wireless/mesh.c | |||
@@ -1,9 +1,7 @@ | |||
1 | #include <linux/ieee80211.h> | 1 | #include <linux/ieee80211.h> |
2 | #include <linux/export.h> | ||
3 | #include <net/cfg80211.h> | 2 | #include <net/cfg80211.h> |
4 | #include "nl80211.h" | 3 | #include "nl80211.h" |
5 | #include "core.h" | 4 | #include "core.h" |
6 | #include "rdev-ops.h" | ||
7 | 5 | ||
8 | /* Default values, timeouts in ms */ | 6 | /* Default values, timeouts in ms */ |
9 | #define MESH_TTL 31 | 7 | #define MESH_TTL 31 |
@@ -14,21 +12,14 @@ | |||
14 | #define MESH_HOLD_T 100 | 12 | #define MESH_HOLD_T 100 |
15 | 13 | ||
16 | #define MESH_PATH_TIMEOUT 5000 | 14 | #define MESH_PATH_TIMEOUT 5000 |
17 | #define MESH_RANN_INTERVAL 5000 | ||
18 | #define MESH_PATH_TO_ROOT_TIMEOUT 6000 | ||
19 | #define MESH_ROOT_INTERVAL 5000 | ||
20 | #define MESH_ROOT_CONFIRMATION_INTERVAL 2000 | ||
21 | 15 | ||
22 | /* | 16 | /* |
23 | * Minimum interval between two consecutive PREQs originated by the same | 17 | * Minimum interval between two consecutive PREQs originated by the same |
24 | * interface | 18 | * interface |
25 | */ | 19 | */ |
26 | #define MESH_PREQ_MIN_INT 10 | 20 | #define MESH_PREQ_MIN_INT 10 |
27 | #define MESH_PERR_MIN_INT 100 | ||
28 | #define MESH_DIAM_TRAVERSAL_TIME 50 | 21 | #define MESH_DIAM_TRAVERSAL_TIME 50 |
29 | 22 | ||
30 | #define MESH_RSSI_THRESHOLD 0 | ||
31 | |||
32 | /* | 23 | /* |
33 | * A path will be refreshed if it is used PATH_REFRESH_TIME milliseconds | 24 | * A path will be refreshed if it is used PATH_REFRESH_TIME milliseconds |
34 | * before timing out. This way it will remain ACTIVE and no data frames | 25 | * before timing out. This way it will remain ACTIVE and no data frames |
@@ -42,7 +33,6 @@ | |||
42 | 33 | ||
43 | #define MESH_MAX_PREQ_RETRIES 4 | 34 | #define MESH_MAX_PREQ_RETRIES 4 |
44 | 35 | ||
45 | #define MESH_SYNC_NEIGHBOR_OFFSET_MAX 50 | ||
46 | 36 | ||
47 | const struct mesh_config default_mesh_config = { | 37 | const struct mesh_config default_mesh_config = { |
48 | .dot11MeshRetryTimeout = MESH_RET_T, | 38 | .dot11MeshRetryTimeout = MESH_RET_T, |
@@ -53,27 +43,15 @@ const struct mesh_config default_mesh_config = { | |||
53 | .element_ttl = MESH_DEFAULT_ELEMENT_TTL, | 43 | .element_ttl = MESH_DEFAULT_ELEMENT_TTL, |
54 | .auto_open_plinks = true, | 44 | .auto_open_plinks = true, |
55 | .dot11MeshMaxPeerLinks = MESH_MAX_ESTAB_PLINKS, | 45 | .dot11MeshMaxPeerLinks = MESH_MAX_ESTAB_PLINKS, |
56 | .dot11MeshNbrOffsetMaxNeighbor = MESH_SYNC_NEIGHBOR_OFFSET_MAX, | ||
57 | .dot11MeshHWMPactivePathTimeout = MESH_PATH_TIMEOUT, | 46 | .dot11MeshHWMPactivePathTimeout = MESH_PATH_TIMEOUT, |
58 | .dot11MeshHWMPpreqMinInterval = MESH_PREQ_MIN_INT, | 47 | .dot11MeshHWMPpreqMinInterval = MESH_PREQ_MIN_INT, |
59 | .dot11MeshHWMPperrMinInterval = MESH_PERR_MIN_INT, | ||
60 | .dot11MeshHWMPnetDiameterTraversalTime = MESH_DIAM_TRAVERSAL_TIME, | 48 | .dot11MeshHWMPnetDiameterTraversalTime = MESH_DIAM_TRAVERSAL_TIME, |
61 | .dot11MeshHWMPmaxPREQretries = MESH_MAX_PREQ_RETRIES, | 49 | .dot11MeshHWMPmaxPREQretries = MESH_MAX_PREQ_RETRIES, |
62 | .path_refresh_time = MESH_PATH_REFRESH_TIME, | 50 | .path_refresh_time = MESH_PATH_REFRESH_TIME, |
63 | .min_discovery_timeout = MESH_MIN_DISCOVERY_TIMEOUT, | 51 | .min_discovery_timeout = MESH_MIN_DISCOVERY_TIMEOUT, |
64 | .dot11MeshHWMPRannInterval = MESH_RANN_INTERVAL, | ||
65 | .dot11MeshGateAnnouncementProtocol = false, | ||
66 | .dot11MeshForwarding = true, | ||
67 | .rssi_threshold = MESH_RSSI_THRESHOLD, | ||
68 | .ht_opmode = IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED, | ||
69 | .dot11MeshHWMPactivePathToRootTimeout = MESH_PATH_TO_ROOT_TIMEOUT, | ||
70 | .dot11MeshHWMProotInterval = MESH_ROOT_INTERVAL, | ||
71 | .dot11MeshHWMPconfirmationInterval = MESH_ROOT_CONFIRMATION_INTERVAL, | ||
72 | }; | 52 | }; |
73 | 53 | ||
74 | const struct mesh_setup default_mesh_setup = { | 54 | const struct mesh_setup default_mesh_setup = { |
75 | /* cfg80211_join_mesh() will pick a channel if needed */ | ||
76 | .sync_method = IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET, | ||
77 | .path_sel_proto = IEEE80211_PATH_PROTOCOL_HWMP, | 55 | .path_sel_proto = IEEE80211_PATH_PROTOCOL_HWMP, |
78 | .path_metric = IEEE80211_PATH_METRIC_AIRTIME, | 56 | .path_metric = IEEE80211_PATH_METRIC_AIRTIME, |
79 | .ie = NULL, | 57 | .ie = NULL, |
@@ -83,7 +61,7 @@ const struct mesh_setup default_mesh_setup = { | |||
83 | 61 | ||
84 | int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev, | 62 | int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev, |
85 | struct net_device *dev, | 63 | struct net_device *dev, |
86 | struct mesh_setup *setup, | 64 | const struct mesh_setup *setup, |
87 | const struct mesh_config *conf) | 65 | const struct mesh_config *conf) |
88 | { | 66 | { |
89 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 67 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
@@ -109,60 +87,10 @@ int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev, | |||
109 | if (!rdev->ops->join_mesh) | 87 | if (!rdev->ops->join_mesh) |
110 | return -EOPNOTSUPP; | 88 | return -EOPNOTSUPP; |
111 | 89 | ||
112 | if (!setup->chandef.chan) { | 90 | err = rdev->ops->join_mesh(&rdev->wiphy, dev, conf, setup); |
113 | /* if no channel explicitly given, use preset channel */ | ||
114 | setup->chandef = wdev->preset_chandef; | ||
115 | } | ||
116 | |||
117 | if (!setup->chandef.chan) { | ||
118 | /* if we don't have that either, use the first usable channel */ | ||
119 | enum ieee80211_band band; | ||
120 | |||
121 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) { | ||
122 | struct ieee80211_supported_band *sband; | ||
123 | struct ieee80211_channel *chan; | ||
124 | int i; | ||
125 | |||
126 | sband = rdev->wiphy.bands[band]; | ||
127 | if (!sband) | ||
128 | continue; | ||
129 | |||
130 | for (i = 0; i < sband->n_channels; i++) { | ||
131 | chan = &sband->channels[i]; | ||
132 | if (chan->flags & (IEEE80211_CHAN_NO_IBSS | | ||
133 | IEEE80211_CHAN_PASSIVE_SCAN | | ||
134 | IEEE80211_CHAN_DISABLED | | ||
135 | IEEE80211_CHAN_RADAR)) | ||
136 | continue; | ||
137 | setup->chandef.chan = chan; | ||
138 | break; | ||
139 | } | ||
140 | |||
141 | if (setup->chandef.chan) | ||
142 | break; | ||
143 | } | ||
144 | |||
145 | /* no usable channel ... */ | ||
146 | if (!setup->chandef.chan) | ||
147 | return -EINVAL; | ||
148 | |||
149 | setup->chandef.width = NL80211_CHAN_WIDTH_20_NOHT; | ||
150 | setup->chandef.center_freq1 = setup->chandef.chan->center_freq; | ||
151 | } | ||
152 | |||
153 | if (!cfg80211_reg_can_beacon(&rdev->wiphy, &setup->chandef)) | ||
154 | return -EINVAL; | ||
155 | |||
156 | err = cfg80211_can_use_chan(rdev, wdev, setup->chandef.chan, | ||
157 | CHAN_MODE_SHARED); | ||
158 | if (err) | ||
159 | return err; | ||
160 | |||
161 | err = rdev_join_mesh(rdev, dev, conf, setup); | ||
162 | if (!err) { | 91 | if (!err) { |
163 | memcpy(wdev->ssid, setup->mesh_id, setup->mesh_id_len); | 92 | memcpy(wdev->ssid, setup->mesh_id, setup->mesh_id_len); |
164 | wdev->mesh_id_len = setup->mesh_id_len; | 93 | wdev->mesh_id_len = setup->mesh_id_len; |
165 | wdev->channel = setup->chandef.chan; | ||
166 | } | 94 | } |
167 | 95 | ||
168 | return err; | 96 | return err; |
@@ -170,67 +98,24 @@ int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev, | |||
170 | 98 | ||
171 | int cfg80211_join_mesh(struct cfg80211_registered_device *rdev, | 99 | int cfg80211_join_mesh(struct cfg80211_registered_device *rdev, |
172 | struct net_device *dev, | 100 | struct net_device *dev, |
173 | struct mesh_setup *setup, | 101 | const struct mesh_setup *setup, |
174 | const struct mesh_config *conf) | 102 | const struct mesh_config *conf) |
175 | { | 103 | { |
176 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 104 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
177 | int err; | 105 | int err; |
178 | 106 | ||
179 | mutex_lock(&rdev->devlist_mtx); | ||
180 | wdev_lock(wdev); | 107 | wdev_lock(wdev); |
181 | err = __cfg80211_join_mesh(rdev, dev, setup, conf); | 108 | err = __cfg80211_join_mesh(rdev, dev, setup, conf); |
182 | wdev_unlock(wdev); | 109 | wdev_unlock(wdev); |
183 | mutex_unlock(&rdev->devlist_mtx); | ||
184 | 110 | ||
185 | return err; | 111 | return err; |
186 | } | 112 | } |
187 | 113 | ||
188 | int cfg80211_set_mesh_channel(struct cfg80211_registered_device *rdev, | ||
189 | struct wireless_dev *wdev, | ||
190 | struct cfg80211_chan_def *chandef) | ||
191 | { | ||
192 | int err; | ||
193 | |||
194 | /* | ||
195 | * Workaround for libertas (only!), it puts the interface | ||
196 | * into mesh mode but doesn't implement join_mesh. Instead, | ||
197 | * it is configured via sysfs and then joins the mesh when | ||
198 | * you set the channel. Note that the libertas mesh isn't | ||
199 | * compatible with 802.11 mesh. | ||
200 | */ | ||
201 | if (rdev->ops->libertas_set_mesh_channel) { | ||
202 | if (chandef->width != NL80211_CHAN_WIDTH_20_NOHT) | ||
203 | return -EINVAL; | ||
204 | |||
205 | if (!netif_running(wdev->netdev)) | ||
206 | return -ENETDOWN; | ||
207 | |||
208 | err = cfg80211_can_use_chan(rdev, wdev, chandef->chan, | ||
209 | CHAN_MODE_SHARED); | ||
210 | if (err) | ||
211 | return err; | ||
212 | |||
213 | err = rdev_libertas_set_mesh_channel(rdev, wdev->netdev, | ||
214 | chandef->chan); | ||
215 | if (!err) | ||
216 | wdev->channel = chandef->chan; | ||
217 | |||
218 | return err; | ||
219 | } | ||
220 | |||
221 | if (wdev->mesh_id_len) | ||
222 | return -EBUSY; | ||
223 | |||
224 | wdev->preset_chandef = *chandef; | ||
225 | return 0; | ||
226 | } | ||
227 | |||
228 | void cfg80211_notify_new_peer_candidate(struct net_device *dev, | 114 | void cfg80211_notify_new_peer_candidate(struct net_device *dev, |
229 | const u8 *macaddr, const u8* ie, u8 ie_len, gfp_t gfp) | 115 | const u8 *macaddr, const u8* ie, u8 ie_len, gfp_t gfp) |
230 | { | 116 | { |
231 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 117 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
232 | 118 | ||
233 | trace_cfg80211_notify_new_peer_candidate(dev, macaddr); | ||
234 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_MESH_POINT)) | 119 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_MESH_POINT)) |
235 | return; | 120 | return; |
236 | 121 | ||
@@ -256,12 +141,9 @@ static int __cfg80211_leave_mesh(struct cfg80211_registered_device *rdev, | |||
256 | if (!wdev->mesh_id_len) | 141 | if (!wdev->mesh_id_len) |
257 | return -ENOTCONN; | 142 | return -ENOTCONN; |
258 | 143 | ||
259 | err = rdev_leave_mesh(rdev, dev); | 144 | err = rdev->ops->leave_mesh(&rdev->wiphy, dev); |
260 | if (!err) { | 145 | if (!err) |
261 | wdev->mesh_id_len = 0; | 146 | wdev->mesh_id_len = 0; |
262 | wdev->channel = NULL; | ||
263 | } | ||
264 | |||
265 | return err; | 147 | return err; |
266 | } | 148 | } |
267 | 149 | ||
diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c index 5e8123ee63f..832f6574e4e 100644 --- a/net/wireless/mlme.c +++ b/net/wireless/mlme.c | |||
@@ -6,7 +6,6 @@ | |||
6 | 6 | ||
7 | #include <linux/kernel.h> | 7 | #include <linux/kernel.h> |
8 | #include <linux/module.h> | 8 | #include <linux/module.h> |
9 | #include <linux/etherdevice.h> | ||
10 | #include <linux/netdevice.h> | 9 | #include <linux/netdevice.h> |
11 | #include <linux/nl80211.h> | 10 | #include <linux/nl80211.h> |
12 | #include <linux/slab.h> | 11 | #include <linux/slab.h> |
@@ -15,27 +14,46 @@ | |||
15 | #include <net/iw_handler.h> | 14 | #include <net/iw_handler.h> |
16 | #include "core.h" | 15 | #include "core.h" |
17 | #include "nl80211.h" | 16 | #include "nl80211.h" |
18 | #include "rdev-ops.h" | ||
19 | |||
20 | 17 | ||
21 | void cfg80211_send_rx_auth(struct net_device *dev, const u8 *buf, size_t len) | 18 | void cfg80211_send_rx_auth(struct net_device *dev, const u8 *buf, size_t len) |
22 | { | 19 | { |
23 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 20 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
24 | struct wiphy *wiphy = wdev->wiphy; | 21 | struct wiphy *wiphy = wdev->wiphy; |
25 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 22 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
23 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf; | ||
24 | u8 *bssid = mgmt->bssid; | ||
25 | int i; | ||
26 | u16 status = le16_to_cpu(mgmt->u.auth.status_code); | ||
27 | bool done = false; | ||
26 | 28 | ||
27 | trace_cfg80211_send_rx_auth(dev); | ||
28 | wdev_lock(wdev); | 29 | wdev_lock(wdev); |
29 | 30 | ||
30 | nl80211_send_rx_auth(rdev, dev, buf, len, GFP_KERNEL); | 31 | for (i = 0; i < MAX_AUTH_BSSES; i++) { |
31 | cfg80211_sme_rx_auth(dev, buf, len); | 32 | if (wdev->authtry_bsses[i] && |
33 | memcmp(wdev->authtry_bsses[i]->pub.bssid, bssid, | ||
34 | ETH_ALEN) == 0) { | ||
35 | if (status == WLAN_STATUS_SUCCESS) { | ||
36 | wdev->auth_bsses[i] = wdev->authtry_bsses[i]; | ||
37 | } else { | ||
38 | cfg80211_unhold_bss(wdev->authtry_bsses[i]); | ||
39 | cfg80211_put_bss(&wdev->authtry_bsses[i]->pub); | ||
40 | } | ||
41 | wdev->authtry_bsses[i] = NULL; | ||
42 | done = true; | ||
43 | break; | ||
44 | } | ||
45 | } | ||
46 | |||
47 | if (done) { | ||
48 | nl80211_send_rx_auth(rdev, dev, buf, len, GFP_KERNEL); | ||
49 | cfg80211_sme_rx_auth(dev, buf, len); | ||
50 | } | ||
32 | 51 | ||
33 | wdev_unlock(wdev); | 52 | wdev_unlock(wdev); |
34 | } | 53 | } |
35 | EXPORT_SYMBOL(cfg80211_send_rx_auth); | 54 | EXPORT_SYMBOL(cfg80211_send_rx_auth); |
36 | 55 | ||
37 | void cfg80211_send_rx_assoc(struct net_device *dev, struct cfg80211_bss *bss, | 56 | void cfg80211_send_rx_assoc(struct net_device *dev, const u8 *buf, size_t len) |
38 | const u8 *buf, size_t len) | ||
39 | { | 57 | { |
40 | u16 status_code; | 58 | u16 status_code; |
41 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 59 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
@@ -43,9 +61,9 @@ void cfg80211_send_rx_assoc(struct net_device *dev, struct cfg80211_bss *bss, | |||
43 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 61 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
44 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf; | 62 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf; |
45 | u8 *ie = mgmt->u.assoc_resp.variable; | 63 | u8 *ie = mgmt->u.assoc_resp.variable; |
46 | int ieoffs = offsetof(struct ieee80211_mgmt, u.assoc_resp.variable); | 64 | int i, ieoffs = offsetof(struct ieee80211_mgmt, u.assoc_resp.variable); |
65 | struct cfg80211_internal_bss *bss = NULL; | ||
47 | 66 | ||
48 | trace_cfg80211_send_rx_assoc(dev, bss); | ||
49 | wdev_lock(wdev); | 67 | wdev_lock(wdev); |
50 | 68 | ||
51 | status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code); | 69 | status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code); |
@@ -57,20 +75,43 @@ void cfg80211_send_rx_assoc(struct net_device *dev, struct cfg80211_bss *bss, | |||
57 | * frame instead of reassoc. | 75 | * frame instead of reassoc. |
58 | */ | 76 | */ |
59 | if (status_code != WLAN_STATUS_SUCCESS && wdev->conn && | 77 | if (status_code != WLAN_STATUS_SUCCESS && wdev->conn && |
60 | cfg80211_sme_failed_reassoc(wdev)) { | 78 | cfg80211_sme_failed_reassoc(wdev)) |
61 | cfg80211_put_bss(bss); | ||
62 | goto out; | 79 | goto out; |
63 | } | ||
64 | 80 | ||
65 | nl80211_send_rx_assoc(rdev, dev, buf, len, GFP_KERNEL); | 81 | nl80211_send_rx_assoc(rdev, dev, buf, len, GFP_KERNEL); |
66 | 82 | ||
67 | if (status_code != WLAN_STATUS_SUCCESS && wdev->conn) { | 83 | if (status_code == WLAN_STATUS_SUCCESS) { |
84 | for (i = 0; i < MAX_AUTH_BSSES; i++) { | ||
85 | if (!wdev->auth_bsses[i]) | ||
86 | continue; | ||
87 | if (memcmp(wdev->auth_bsses[i]->pub.bssid, mgmt->bssid, | ||
88 | ETH_ALEN) == 0) { | ||
89 | bss = wdev->auth_bsses[i]; | ||
90 | wdev->auth_bsses[i] = NULL; | ||
91 | /* additional reference to drop hold */ | ||
92 | cfg80211_ref_bss(bss); | ||
93 | break; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | /* | ||
98 | * We might be coming here because the driver reported | ||
99 | * a successful association at the same time as the | ||
100 | * user requested a deauth. In that case, we will have | ||
101 | * removed the BSS from the auth_bsses list due to the | ||
102 | * deauth request when the assoc response makes it. If | ||
103 | * the two code paths acquire the lock the other way | ||
104 | * around, that's just the standard situation of a | ||
105 | * deauth being requested while connected. | ||
106 | */ | ||
107 | if (!bss) | ||
108 | goto out; | ||
109 | } else if (wdev->conn) { | ||
68 | cfg80211_sme_failed_assoc(wdev); | 110 | cfg80211_sme_failed_assoc(wdev); |
69 | /* | 111 | /* |
70 | * do not call connect_result() now because the | 112 | * do not call connect_result() now because the |
71 | * sme will schedule work that does it later. | 113 | * sme will schedule work that does it later. |
72 | */ | 114 | */ |
73 | cfg80211_put_bss(bss); | ||
74 | goto out; | 115 | goto out; |
75 | } | 116 | } |
76 | 117 | ||
@@ -83,10 +124,17 @@ void cfg80211_send_rx_assoc(struct net_device *dev, struct cfg80211_bss *bss, | |||
83 | wdev->sme_state = CFG80211_SME_CONNECTING; | 124 | wdev->sme_state = CFG80211_SME_CONNECTING; |
84 | } | 125 | } |
85 | 126 | ||
86 | /* this consumes the bss reference */ | 127 | /* this consumes one bss reference (unless bss is NULL) */ |
87 | __cfg80211_connect_result(dev, mgmt->bssid, NULL, 0, ie, len - ieoffs, | 128 | __cfg80211_connect_result(dev, mgmt->bssid, NULL, 0, ie, len - ieoffs, |
88 | status_code, | 129 | status_code, |
89 | status_code == WLAN_STATUS_SUCCESS, bss); | 130 | status_code == WLAN_STATUS_SUCCESS, |
131 | bss ? &bss->pub : NULL); | ||
132 | /* drop hold now, and also reference acquired above */ | ||
133 | if (bss) { | ||
134 | cfg80211_unhold_bss(bss); | ||
135 | cfg80211_put_bss(&bss->pub); | ||
136 | } | ||
137 | |||
90 | out: | 138 | out: |
91 | wdev_unlock(wdev); | 139 | wdev_unlock(wdev); |
92 | } | 140 | } |
@@ -100,19 +148,42 @@ void __cfg80211_send_deauth(struct net_device *dev, | |||
100 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 148 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
101 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf; | 149 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf; |
102 | const u8 *bssid = mgmt->bssid; | 150 | const u8 *bssid = mgmt->bssid; |
103 | bool was_current = false; | 151 | int i; |
152 | bool found = false, was_current = false; | ||
104 | 153 | ||
105 | trace___cfg80211_send_deauth(dev); | ||
106 | ASSERT_WDEV_LOCK(wdev); | 154 | ASSERT_WDEV_LOCK(wdev); |
107 | 155 | ||
108 | if (wdev->current_bss && | 156 | if (wdev->current_bss && |
109 | ether_addr_equal(wdev->current_bss->pub.bssid, bssid)) { | 157 | memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) { |
110 | cfg80211_unhold_bss(wdev->current_bss); | 158 | cfg80211_unhold_bss(wdev->current_bss); |
111 | cfg80211_put_bss(&wdev->current_bss->pub); | 159 | cfg80211_put_bss(&wdev->current_bss->pub); |
112 | wdev->current_bss = NULL; | 160 | wdev->current_bss = NULL; |
161 | found = true; | ||
113 | was_current = true; | 162 | was_current = true; |
163 | } else for (i = 0; i < MAX_AUTH_BSSES; i++) { | ||
164 | if (wdev->auth_bsses[i] && | ||
165 | memcmp(wdev->auth_bsses[i]->pub.bssid, bssid, ETH_ALEN) == 0) { | ||
166 | cfg80211_unhold_bss(wdev->auth_bsses[i]); | ||
167 | cfg80211_put_bss(&wdev->auth_bsses[i]->pub); | ||
168 | wdev->auth_bsses[i] = NULL; | ||
169 | found = true; | ||
170 | break; | ||
171 | } | ||
172 | if (wdev->authtry_bsses[i] && | ||
173 | memcmp(wdev->authtry_bsses[i]->pub.bssid, bssid, | ||
174 | ETH_ALEN) == 0 && | ||
175 | memcmp(mgmt->sa, dev->dev_addr, ETH_ALEN) == 0) { | ||
176 | cfg80211_unhold_bss(wdev->authtry_bsses[i]); | ||
177 | cfg80211_put_bss(&wdev->authtry_bsses[i]->pub); | ||
178 | wdev->authtry_bsses[i] = NULL; | ||
179 | found = true; | ||
180 | break; | ||
181 | } | ||
114 | } | 182 | } |
115 | 183 | ||
184 | if (!found) | ||
185 | return; | ||
186 | |||
116 | nl80211_send_deauth(rdev, dev, buf, len, GFP_KERNEL); | 187 | nl80211_send_deauth(rdev, dev, buf, len, GFP_KERNEL); |
117 | 188 | ||
118 | if (wdev->sme_state == CFG80211_SME_CONNECTED && was_current) { | 189 | if (wdev->sme_state == CFG80211_SME_CONNECTED && was_current) { |
@@ -121,7 +192,7 @@ void __cfg80211_send_deauth(struct net_device *dev, | |||
121 | 192 | ||
122 | reason_code = le16_to_cpu(mgmt->u.deauth.reason_code); | 193 | reason_code = le16_to_cpu(mgmt->u.deauth.reason_code); |
123 | 194 | ||
124 | from_ap = !ether_addr_equal(mgmt->sa, dev->dev_addr); | 195 | from_ap = memcmp(mgmt->sa, dev->dev_addr, ETH_ALEN) != 0; |
125 | __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap); | 196 | __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap); |
126 | } else if (wdev->sme_state == CFG80211_SME_CONNECTING) { | 197 | } else if (wdev->sme_state == CFG80211_SME_CONNECTING) { |
127 | __cfg80211_connect_result(dev, mgmt->bssid, NULL, 0, NULL, 0, | 198 | __cfg80211_connect_result(dev, mgmt->bssid, NULL, 0, NULL, 0, |
@@ -149,10 +220,11 @@ void __cfg80211_send_disassoc(struct net_device *dev, | |||
149 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 220 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
150 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf; | 221 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf; |
151 | const u8 *bssid = mgmt->bssid; | 222 | const u8 *bssid = mgmt->bssid; |
223 | int i; | ||
152 | u16 reason_code; | 224 | u16 reason_code; |
153 | bool from_ap; | 225 | bool from_ap; |
226 | bool done = false; | ||
154 | 227 | ||
155 | trace___cfg80211_send_disassoc(dev); | ||
156 | ASSERT_WDEV_LOCK(wdev); | 228 | ASSERT_WDEV_LOCK(wdev); |
157 | 229 | ||
158 | nl80211_send_disassoc(rdev, dev, buf, len, GFP_KERNEL); | 230 | nl80211_send_disassoc(rdev, dev, buf, len, GFP_KERNEL); |
@@ -161,18 +233,24 @@ void __cfg80211_send_disassoc(struct net_device *dev, | |||
161 | return; | 233 | return; |
162 | 234 | ||
163 | if (wdev->current_bss && | 235 | if (wdev->current_bss && |
164 | ether_addr_equal(wdev->current_bss->pub.bssid, bssid)) { | 236 | memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) { |
165 | cfg80211_sme_disassoc(dev, wdev->current_bss); | 237 | for (i = 0; i < MAX_AUTH_BSSES; i++) { |
166 | cfg80211_unhold_bss(wdev->current_bss); | 238 | if (wdev->authtry_bsses[i] || wdev->auth_bsses[i]) |
167 | cfg80211_put_bss(&wdev->current_bss->pub); | 239 | continue; |
168 | wdev->current_bss = NULL; | 240 | wdev->auth_bsses[i] = wdev->current_bss; |
241 | wdev->current_bss = NULL; | ||
242 | done = true; | ||
243 | cfg80211_sme_disassoc(dev, i); | ||
244 | break; | ||
245 | } | ||
246 | WARN_ON(!done); | ||
169 | } else | 247 | } else |
170 | WARN_ON(1); | 248 | WARN_ON(1); |
171 | 249 | ||
172 | 250 | ||
173 | reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); | 251 | reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); |
174 | 252 | ||
175 | from_ap = !ether_addr_equal(mgmt->sa, dev->dev_addr); | 253 | from_ap = memcmp(mgmt->sa, dev->dev_addr, ETH_ALEN) != 0; |
176 | __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap); | 254 | __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap); |
177 | } | 255 | } |
178 | EXPORT_SYMBOL(__cfg80211_send_disassoc); | 256 | EXPORT_SYMBOL(__cfg80211_send_disassoc); |
@@ -194,7 +272,6 @@ void cfg80211_send_unprot_deauth(struct net_device *dev, const u8 *buf, | |||
194 | struct wiphy *wiphy = wdev->wiphy; | 272 | struct wiphy *wiphy = wdev->wiphy; |
195 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 273 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
196 | 274 | ||
197 | trace_cfg80211_send_unprot_deauth(dev); | ||
198 | nl80211_send_unprot_deauth(rdev, dev, buf, len, GFP_ATOMIC); | 275 | nl80211_send_unprot_deauth(rdev, dev, buf, len, GFP_ATOMIC); |
199 | } | 276 | } |
200 | EXPORT_SYMBOL(cfg80211_send_unprot_deauth); | 277 | EXPORT_SYMBOL(cfg80211_send_unprot_deauth); |
@@ -206,18 +283,44 @@ void cfg80211_send_unprot_disassoc(struct net_device *dev, const u8 *buf, | |||
206 | struct wiphy *wiphy = wdev->wiphy; | 283 | struct wiphy *wiphy = wdev->wiphy; |
207 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 284 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
208 | 285 | ||
209 | trace_cfg80211_send_unprot_disassoc(dev); | ||
210 | nl80211_send_unprot_disassoc(rdev, dev, buf, len, GFP_ATOMIC); | 286 | nl80211_send_unprot_disassoc(rdev, dev, buf, len, GFP_ATOMIC); |
211 | } | 287 | } |
212 | EXPORT_SYMBOL(cfg80211_send_unprot_disassoc); | 288 | EXPORT_SYMBOL(cfg80211_send_unprot_disassoc); |
213 | 289 | ||
290 | static void __cfg80211_auth_remove(struct wireless_dev *wdev, const u8 *addr) | ||
291 | { | ||
292 | int i; | ||
293 | bool done = false; | ||
294 | |||
295 | ASSERT_WDEV_LOCK(wdev); | ||
296 | |||
297 | for (i = 0; addr && i < MAX_AUTH_BSSES; i++) { | ||
298 | if (wdev->authtry_bsses[i] && | ||
299 | memcmp(wdev->authtry_bsses[i]->pub.bssid, | ||
300 | addr, ETH_ALEN) == 0) { | ||
301 | cfg80211_unhold_bss(wdev->authtry_bsses[i]); | ||
302 | cfg80211_put_bss(&wdev->authtry_bsses[i]->pub); | ||
303 | wdev->authtry_bsses[i] = NULL; | ||
304 | done = true; | ||
305 | break; | ||
306 | } | ||
307 | } | ||
308 | |||
309 | WARN_ON(!done); | ||
310 | } | ||
311 | |||
312 | void __cfg80211_auth_canceled(struct net_device *dev, const u8 *addr) | ||
313 | { | ||
314 | __cfg80211_auth_remove(dev->ieee80211_ptr, addr); | ||
315 | } | ||
316 | EXPORT_SYMBOL(__cfg80211_auth_canceled); | ||
317 | |||
214 | void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr) | 318 | void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr) |
215 | { | 319 | { |
216 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 320 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
217 | struct wiphy *wiphy = wdev->wiphy; | 321 | struct wiphy *wiphy = wdev->wiphy; |
218 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 322 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
219 | 323 | ||
220 | trace_cfg80211_send_auth_timeout(dev, addr); | ||
221 | wdev_lock(wdev); | 324 | wdev_lock(wdev); |
222 | 325 | ||
223 | nl80211_send_auth_timeout(rdev, dev, addr, GFP_KERNEL); | 326 | nl80211_send_auth_timeout(rdev, dev, addr, GFP_KERNEL); |
@@ -226,6 +329,8 @@ void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr) | |||
226 | WLAN_STATUS_UNSPECIFIED_FAILURE, | 329 | WLAN_STATUS_UNSPECIFIED_FAILURE, |
227 | false, NULL); | 330 | false, NULL); |
228 | 331 | ||
332 | __cfg80211_auth_remove(wdev, addr); | ||
333 | |||
229 | wdev_unlock(wdev); | 334 | wdev_unlock(wdev); |
230 | } | 335 | } |
231 | EXPORT_SYMBOL(cfg80211_send_auth_timeout); | 336 | EXPORT_SYMBOL(cfg80211_send_auth_timeout); |
@@ -235,8 +340,9 @@ void cfg80211_send_assoc_timeout(struct net_device *dev, const u8 *addr) | |||
235 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 340 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
236 | struct wiphy *wiphy = wdev->wiphy; | 341 | struct wiphy *wiphy = wdev->wiphy; |
237 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 342 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
343 | int i; | ||
344 | bool done = false; | ||
238 | 345 | ||
239 | trace_cfg80211_send_assoc_timeout(dev, addr); | ||
240 | wdev_lock(wdev); | 346 | wdev_lock(wdev); |
241 | 347 | ||
242 | nl80211_send_assoc_timeout(rdev, dev, addr, GFP_KERNEL); | 348 | nl80211_send_assoc_timeout(rdev, dev, addr, GFP_KERNEL); |
@@ -245,6 +351,20 @@ void cfg80211_send_assoc_timeout(struct net_device *dev, const u8 *addr) | |||
245 | WLAN_STATUS_UNSPECIFIED_FAILURE, | 351 | WLAN_STATUS_UNSPECIFIED_FAILURE, |
246 | false, NULL); | 352 | false, NULL); |
247 | 353 | ||
354 | for (i = 0; addr && i < MAX_AUTH_BSSES; i++) { | ||
355 | if (wdev->auth_bsses[i] && | ||
356 | memcmp(wdev->auth_bsses[i]->pub.bssid, | ||
357 | addr, ETH_ALEN) == 0) { | ||
358 | cfg80211_unhold_bss(wdev->auth_bsses[i]); | ||
359 | cfg80211_put_bss(&wdev->auth_bsses[i]->pub); | ||
360 | wdev->auth_bsses[i] = NULL; | ||
361 | done = true; | ||
362 | break; | ||
363 | } | ||
364 | } | ||
365 | |||
366 | WARN_ON(!done); | ||
367 | |||
248 | wdev_unlock(wdev); | 368 | wdev_unlock(wdev); |
249 | } | 369 | } |
250 | EXPORT_SYMBOL(cfg80211_send_assoc_timeout); | 370 | EXPORT_SYMBOL(cfg80211_send_assoc_timeout); |
@@ -271,7 +391,6 @@ void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr, | |||
271 | } | 391 | } |
272 | #endif | 392 | #endif |
273 | 393 | ||
274 | trace_cfg80211_michael_mic_failure(dev, addr, key_type, key_id, tsc); | ||
275 | nl80211_michael_mic_failure(rdev, dev, addr, key_type, key_id, tsc, gfp); | 394 | nl80211_michael_mic_failure(rdev, dev, addr, key_type, key_id, tsc, gfp); |
276 | } | 395 | } |
277 | EXPORT_SYMBOL(cfg80211_michael_mic_failure); | 396 | EXPORT_SYMBOL(cfg80211_michael_mic_failure); |
@@ -285,11 +404,12 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, | |||
285 | const u8 *ssid, int ssid_len, | 404 | const u8 *ssid, int ssid_len, |
286 | const u8 *ie, int ie_len, | 405 | const u8 *ie, int ie_len, |
287 | const u8 *key, int key_len, int key_idx, | 406 | const u8 *key, int key_len, int key_idx, |
288 | const u8 *sae_data, int sae_data_len) | 407 | bool local_state_change) |
289 | { | 408 | { |
290 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 409 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
291 | struct cfg80211_auth_request req; | 410 | struct cfg80211_auth_request req; |
292 | int err; | 411 | struct cfg80211_internal_bss *bss; |
412 | int i, err, slot = -1, nfree = 0; | ||
293 | 413 | ||
294 | ASSERT_WDEV_LOCK(wdev); | 414 | ASSERT_WDEV_LOCK(wdev); |
295 | 415 | ||
@@ -298,15 +418,25 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, | |||
298 | return -EINVAL; | 418 | return -EINVAL; |
299 | 419 | ||
300 | if (wdev->current_bss && | 420 | if (wdev->current_bss && |
301 | ether_addr_equal(bssid, wdev->current_bss->pub.bssid)) | 421 | memcmp(bssid, wdev->current_bss->pub.bssid, ETH_ALEN) == 0) |
302 | return -EALREADY; | 422 | return -EALREADY; |
303 | 423 | ||
424 | for (i = 0; i < MAX_AUTH_BSSES; i++) { | ||
425 | if (wdev->authtry_bsses[i] && | ||
426 | memcmp(bssid, wdev->authtry_bsses[i]->pub.bssid, | ||
427 | ETH_ALEN) == 0) | ||
428 | return -EALREADY; | ||
429 | if (wdev->auth_bsses[i] && | ||
430 | memcmp(bssid, wdev->auth_bsses[i]->pub.bssid, | ||
431 | ETH_ALEN) == 0) | ||
432 | return -EALREADY; | ||
433 | } | ||
434 | |||
304 | memset(&req, 0, sizeof(req)); | 435 | memset(&req, 0, sizeof(req)); |
305 | 436 | ||
437 | req.local_state_change = local_state_change; | ||
306 | req.ie = ie; | 438 | req.ie = ie; |
307 | req.ie_len = ie_len; | 439 | req.ie_len = ie_len; |
308 | req.sae_data = sae_data; | ||
309 | req.sae_data_len = sae_data_len; | ||
310 | req.auth_type = auth_type; | 440 | req.auth_type = auth_type; |
311 | req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len, | 441 | req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len, |
312 | WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); | 442 | WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); |
@@ -316,15 +446,39 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, | |||
316 | if (!req.bss) | 446 | if (!req.bss) |
317 | return -ENOENT; | 447 | return -ENOENT; |
318 | 448 | ||
319 | err = cfg80211_can_use_chan(rdev, wdev, req.bss->channel, | 449 | bss = bss_from_pub(req.bss); |
320 | CHAN_MODE_SHARED); | 450 | |
321 | if (err) | 451 | for (i = 0; i < MAX_AUTH_BSSES; i++) { |
452 | if (!wdev->auth_bsses[i] && !wdev->authtry_bsses[i]) { | ||
453 | slot = i; | ||
454 | nfree++; | ||
455 | } | ||
456 | } | ||
457 | |||
458 | /* we need one free slot for disassoc and one for this auth */ | ||
459 | if (nfree < 2) { | ||
460 | err = -ENOSPC; | ||
322 | goto out; | 461 | goto out; |
462 | } | ||
323 | 463 | ||
324 | err = rdev_auth(rdev, dev, &req); | 464 | if (local_state_change) |
465 | wdev->auth_bsses[slot] = bss; | ||
466 | else | ||
467 | wdev->authtry_bsses[slot] = bss; | ||
468 | cfg80211_hold_bss(bss); | ||
325 | 469 | ||
326 | out: | 470 | err = rdev->ops->auth(&rdev->wiphy, dev, &req); |
327 | cfg80211_put_bss(req.bss); | 471 | if (err) { |
472 | if (local_state_change) | ||
473 | wdev->auth_bsses[slot] = NULL; | ||
474 | else | ||
475 | wdev->authtry_bsses[slot] = NULL; | ||
476 | cfg80211_unhold_bss(bss); | ||
477 | } | ||
478 | |||
479 | out: | ||
480 | if (err) | ||
481 | cfg80211_put_bss(req.bss); | ||
328 | return err; | 482 | return err; |
329 | } | 483 | } |
330 | 484 | ||
@@ -334,52 +488,31 @@ int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, | |||
334 | const u8 *ssid, int ssid_len, | 488 | const u8 *ssid, int ssid_len, |
335 | const u8 *ie, int ie_len, | 489 | const u8 *ie, int ie_len, |
336 | const u8 *key, int key_len, int key_idx, | 490 | const u8 *key, int key_len, int key_idx, |
337 | const u8 *sae_data, int sae_data_len) | 491 | bool local_state_change) |
338 | { | 492 | { |
339 | int err; | 493 | int err; |
340 | 494 | ||
341 | mutex_lock(&rdev->devlist_mtx); | ||
342 | wdev_lock(dev->ieee80211_ptr); | 495 | wdev_lock(dev->ieee80211_ptr); |
343 | err = __cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid, | 496 | err = __cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid, |
344 | ssid, ssid_len, ie, ie_len, | 497 | ssid, ssid_len, ie, ie_len, |
345 | key, key_len, key_idx, | 498 | key, key_len, key_idx, local_state_change); |
346 | sae_data, sae_data_len); | ||
347 | wdev_unlock(dev->ieee80211_ptr); | 499 | wdev_unlock(dev->ieee80211_ptr); |
348 | mutex_unlock(&rdev->devlist_mtx); | ||
349 | 500 | ||
350 | return err; | 501 | return err; |
351 | } | 502 | } |
352 | 503 | ||
353 | /* Do a logical ht_capa &= ht_capa_mask. */ | ||
354 | void cfg80211_oper_and_ht_capa(struct ieee80211_ht_cap *ht_capa, | ||
355 | const struct ieee80211_ht_cap *ht_capa_mask) | ||
356 | { | ||
357 | int i; | ||
358 | u8 *p1, *p2; | ||
359 | if (!ht_capa_mask) { | ||
360 | memset(ht_capa, 0, sizeof(*ht_capa)); | ||
361 | return; | ||
362 | } | ||
363 | |||
364 | p1 = (u8*)(ht_capa); | ||
365 | p2 = (u8*)(ht_capa_mask); | ||
366 | for (i = 0; i<sizeof(*ht_capa); i++) | ||
367 | p1[i] &= p2[i]; | ||
368 | } | ||
369 | |||
370 | int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, | 504 | int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, |
371 | struct net_device *dev, | 505 | struct net_device *dev, |
372 | struct ieee80211_channel *chan, | 506 | struct ieee80211_channel *chan, |
373 | const u8 *bssid, const u8 *prev_bssid, | 507 | const u8 *bssid, const u8 *prev_bssid, |
374 | const u8 *ssid, int ssid_len, | 508 | const u8 *ssid, int ssid_len, |
375 | const u8 *ie, int ie_len, bool use_mfp, | 509 | const u8 *ie, int ie_len, bool use_mfp, |
376 | struct cfg80211_crypto_settings *crypt, | 510 | struct cfg80211_crypto_settings *crypt) |
377 | u32 assoc_flags, struct ieee80211_ht_cap *ht_capa, | ||
378 | struct ieee80211_ht_cap *ht_capa_mask) | ||
379 | { | 511 | { |
380 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 512 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
381 | struct cfg80211_assoc_request req; | 513 | struct cfg80211_assoc_request req; |
382 | int err; | 514 | struct cfg80211_internal_bss *bss; |
515 | int i, err, slot = -1; | ||
383 | bool was_connected = false; | 516 | bool was_connected = false; |
384 | 517 | ||
385 | ASSERT_WDEV_LOCK(wdev); | 518 | ASSERT_WDEV_LOCK(wdev); |
@@ -387,7 +520,7 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, | |||
387 | memset(&req, 0, sizeof(req)); | 520 | memset(&req, 0, sizeof(req)); |
388 | 521 | ||
389 | if (wdev->current_bss && prev_bssid && | 522 | if (wdev->current_bss && prev_bssid && |
390 | ether_addr_equal(wdev->current_bss->pub.bssid, prev_bssid)) { | 523 | memcmp(wdev->current_bss->pub.bssid, prev_bssid, ETH_ALEN) == 0) { |
391 | /* | 524 | /* |
392 | * Trying to reassociate: Allow this to proceed and let the old | 525 | * Trying to reassociate: Allow this to proceed and let the old |
393 | * association to be dropped when the new one is completed. | 526 | * association to be dropped when the new one is completed. |
@@ -404,15 +537,6 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, | |||
404 | memcpy(&req.crypto, crypt, sizeof(req.crypto)); | 537 | memcpy(&req.crypto, crypt, sizeof(req.crypto)); |
405 | req.use_mfp = use_mfp; | 538 | req.use_mfp = use_mfp; |
406 | req.prev_bssid = prev_bssid; | 539 | req.prev_bssid = prev_bssid; |
407 | req.flags = assoc_flags; | ||
408 | if (ht_capa) | ||
409 | memcpy(&req.ht_capa, ht_capa, sizeof(req.ht_capa)); | ||
410 | if (ht_capa_mask) | ||
411 | memcpy(&req.ht_capa_mask, ht_capa_mask, | ||
412 | sizeof(req.ht_capa_mask)); | ||
413 | cfg80211_oper_and_ht_capa(&req.ht_capa_mask, | ||
414 | rdev->wiphy.ht_capa_mod_mask); | ||
415 | |||
416 | req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len, | 540 | req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len, |
417 | WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); | 541 | WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); |
418 | if (!req.bss) { | 542 | if (!req.bss) { |
@@ -421,20 +545,26 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, | |||
421 | return -ENOENT; | 545 | return -ENOENT; |
422 | } | 546 | } |
423 | 547 | ||
424 | err = cfg80211_can_use_chan(rdev, wdev, req.bss->channel, | 548 | bss = bss_from_pub(req.bss); |
425 | CHAN_MODE_SHARED); | ||
426 | if (err) | ||
427 | goto out; | ||
428 | 549 | ||
429 | err = rdev_assoc(rdev, dev, &req); | 550 | for (i = 0; i < MAX_AUTH_BSSES; i++) { |
551 | if (bss == wdev->auth_bsses[i]) { | ||
552 | slot = i; | ||
553 | break; | ||
554 | } | ||
555 | } | ||
430 | 556 | ||
431 | out: | 557 | if (slot < 0) { |
432 | if (err) { | 558 | err = -ENOTCONN; |
433 | if (was_connected) | 559 | goto out; |
434 | wdev->sme_state = CFG80211_SME_CONNECTED; | ||
435 | cfg80211_put_bss(req.bss); | ||
436 | } | 560 | } |
437 | 561 | ||
562 | err = rdev->ops->assoc(&rdev->wiphy, dev, &req); | ||
563 | out: | ||
564 | if (err && was_connected) | ||
565 | wdev->sme_state = CFG80211_SME_CONNECTED; | ||
566 | /* still a reference in wdev->auth_bsses[slot] */ | ||
567 | cfg80211_put_bss(req.bss); | ||
438 | return err; | 568 | return err; |
439 | } | 569 | } |
440 | 570 | ||
@@ -444,20 +574,15 @@ int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, | |||
444 | const u8 *bssid, const u8 *prev_bssid, | 574 | const u8 *bssid, const u8 *prev_bssid, |
445 | const u8 *ssid, int ssid_len, | 575 | const u8 *ssid, int ssid_len, |
446 | const u8 *ie, int ie_len, bool use_mfp, | 576 | const u8 *ie, int ie_len, bool use_mfp, |
447 | struct cfg80211_crypto_settings *crypt, | 577 | struct cfg80211_crypto_settings *crypt) |
448 | u32 assoc_flags, struct ieee80211_ht_cap *ht_capa, | ||
449 | struct ieee80211_ht_cap *ht_capa_mask) | ||
450 | { | 578 | { |
451 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 579 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
452 | int err; | 580 | int err; |
453 | 581 | ||
454 | mutex_lock(&rdev->devlist_mtx); | ||
455 | wdev_lock(wdev); | 582 | wdev_lock(wdev); |
456 | err = __cfg80211_mlme_assoc(rdev, dev, chan, bssid, prev_bssid, | 583 | err = __cfg80211_mlme_assoc(rdev, dev, chan, bssid, prev_bssid, |
457 | ssid, ssid_len, ie, ie_len, use_mfp, crypt, | 584 | ssid, ssid_len, ie, ie_len, use_mfp, crypt); |
458 | assoc_flags, ht_capa, ht_capa_mask); | ||
459 | wdev_unlock(wdev); | 585 | wdev_unlock(wdev); |
460 | mutex_unlock(&rdev->devlist_mtx); | ||
461 | 586 | ||
462 | return err; | 587 | return err; |
463 | } | 588 | } |
@@ -468,21 +593,36 @@ int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev, | |||
468 | bool local_state_change) | 593 | bool local_state_change) |
469 | { | 594 | { |
470 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 595 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
471 | struct cfg80211_deauth_request req = { | 596 | struct cfg80211_deauth_request req; |
472 | .bssid = bssid, | 597 | int i; |
473 | .reason_code = reason, | ||
474 | .ie = ie, | ||
475 | .ie_len = ie_len, | ||
476 | .local_state_change = local_state_change, | ||
477 | }; | ||
478 | 598 | ||
479 | ASSERT_WDEV_LOCK(wdev); | 599 | ASSERT_WDEV_LOCK(wdev); |
480 | 600 | ||
481 | if (local_state_change && (!wdev->current_bss || | 601 | memset(&req, 0, sizeof(req)); |
482 | !ether_addr_equal(wdev->current_bss->pub.bssid, bssid))) | 602 | req.reason_code = reason; |
483 | return 0; | 603 | req.local_state_change = local_state_change; |
604 | req.ie = ie; | ||
605 | req.ie_len = ie_len; | ||
606 | if (wdev->current_bss && | ||
607 | memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) { | ||
608 | req.bss = &wdev->current_bss->pub; | ||
609 | } else for (i = 0; i < MAX_AUTH_BSSES; i++) { | ||
610 | if (wdev->auth_bsses[i] && | ||
611 | memcmp(bssid, wdev->auth_bsses[i]->pub.bssid, ETH_ALEN) == 0) { | ||
612 | req.bss = &wdev->auth_bsses[i]->pub; | ||
613 | break; | ||
614 | } | ||
615 | if (wdev->authtry_bsses[i] && | ||
616 | memcmp(bssid, wdev->authtry_bsses[i]->pub.bssid, ETH_ALEN) == 0) { | ||
617 | req.bss = &wdev->authtry_bsses[i]->pub; | ||
618 | break; | ||
619 | } | ||
620 | } | ||
484 | 621 | ||
485 | return rdev_deauth(rdev, dev, &req); | 622 | if (!req.bss) |
623 | return -ENOTCONN; | ||
624 | |||
625 | return rdev->ops->deauth(&rdev->wiphy, dev, &req, wdev); | ||
486 | } | 626 | } |
487 | 627 | ||
488 | int cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev, | 628 | int cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev, |
@@ -522,12 +662,12 @@ static int __cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev, | |||
522 | req.local_state_change = local_state_change; | 662 | req.local_state_change = local_state_change; |
523 | req.ie = ie; | 663 | req.ie = ie; |
524 | req.ie_len = ie_len; | 664 | req.ie_len = ie_len; |
525 | if (ether_addr_equal(wdev->current_bss->pub.bssid, bssid)) | 665 | if (memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) |
526 | req.bss = &wdev->current_bss->pub; | 666 | req.bss = &wdev->current_bss->pub; |
527 | else | 667 | else |
528 | return -ENOTCONN; | 668 | return -ENOTCONN; |
529 | 669 | ||
530 | return rdev_disassoc(rdev, dev, &req); | 670 | return rdev->ops->disassoc(&rdev->wiphy, dev, &req, wdev); |
531 | } | 671 | } |
532 | 672 | ||
533 | int cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev, | 673 | int cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev, |
@@ -551,7 +691,7 @@ void cfg80211_mlme_down(struct cfg80211_registered_device *rdev, | |||
551 | { | 691 | { |
552 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 692 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
553 | struct cfg80211_deauth_request req; | 693 | struct cfg80211_deauth_request req; |
554 | u8 bssid[ETH_ALEN]; | 694 | int i; |
555 | 695 | ||
556 | ASSERT_WDEV_LOCK(wdev); | 696 | ASSERT_WDEV_LOCK(wdev); |
557 | 697 | ||
@@ -563,41 +703,62 @@ void cfg80211_mlme_down(struct cfg80211_registered_device *rdev, | |||
563 | req.ie = NULL; | 703 | req.ie = NULL; |
564 | req.ie_len = 0; | 704 | req.ie_len = 0; |
565 | 705 | ||
566 | if (!wdev->current_bss) | ||
567 | return; | ||
568 | |||
569 | memcpy(bssid, wdev->current_bss->pub.bssid, ETH_ALEN); | ||
570 | req.bssid = bssid; | ||
571 | rdev_deauth(rdev, dev, &req); | ||
572 | |||
573 | if (wdev->current_bss) { | 706 | if (wdev->current_bss) { |
574 | cfg80211_unhold_bss(wdev->current_bss); | 707 | req.bss = &wdev->current_bss->pub; |
575 | cfg80211_put_bss(&wdev->current_bss->pub); | 708 | rdev->ops->deauth(&rdev->wiphy, dev, &req, wdev); |
576 | wdev->current_bss = NULL; | 709 | if (wdev->current_bss) { |
710 | cfg80211_unhold_bss(wdev->current_bss); | ||
711 | cfg80211_put_bss(&wdev->current_bss->pub); | ||
712 | wdev->current_bss = NULL; | ||
713 | } | ||
714 | } | ||
715 | |||
716 | for (i = 0; i < MAX_AUTH_BSSES; i++) { | ||
717 | if (wdev->auth_bsses[i]) { | ||
718 | req.bss = &wdev->auth_bsses[i]->pub; | ||
719 | rdev->ops->deauth(&rdev->wiphy, dev, &req, wdev); | ||
720 | if (wdev->auth_bsses[i]) { | ||
721 | cfg80211_unhold_bss(wdev->auth_bsses[i]); | ||
722 | cfg80211_put_bss(&wdev->auth_bsses[i]->pub); | ||
723 | wdev->auth_bsses[i] = NULL; | ||
724 | } | ||
725 | } | ||
726 | if (wdev->authtry_bsses[i]) { | ||
727 | req.bss = &wdev->authtry_bsses[i]->pub; | ||
728 | rdev->ops->deauth(&rdev->wiphy, dev, &req, wdev); | ||
729 | if (wdev->authtry_bsses[i]) { | ||
730 | cfg80211_unhold_bss(wdev->authtry_bsses[i]); | ||
731 | cfg80211_put_bss(&wdev->authtry_bsses[i]->pub); | ||
732 | wdev->authtry_bsses[i] = NULL; | ||
733 | } | ||
734 | } | ||
577 | } | 735 | } |
578 | } | 736 | } |
579 | 737 | ||
580 | void cfg80211_ready_on_channel(struct wireless_dev *wdev, u64 cookie, | 738 | void cfg80211_ready_on_channel(struct net_device *dev, u64 cookie, |
581 | struct ieee80211_channel *chan, | 739 | struct ieee80211_channel *chan, |
740 | enum nl80211_channel_type channel_type, | ||
582 | unsigned int duration, gfp_t gfp) | 741 | unsigned int duration, gfp_t gfp) |
583 | { | 742 | { |
584 | struct wiphy *wiphy = wdev->wiphy; | 743 | struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; |
585 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 744 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
586 | 745 | ||
587 | trace_cfg80211_ready_on_channel(wdev, cookie, chan, duration); | 746 | nl80211_send_remain_on_channel(rdev, dev, cookie, chan, channel_type, |
588 | nl80211_send_remain_on_channel(rdev, wdev, cookie, chan, duration, gfp); | 747 | duration, gfp); |
589 | } | 748 | } |
590 | EXPORT_SYMBOL(cfg80211_ready_on_channel); | 749 | EXPORT_SYMBOL(cfg80211_ready_on_channel); |
591 | 750 | ||
592 | void cfg80211_remain_on_channel_expired(struct wireless_dev *wdev, u64 cookie, | 751 | void cfg80211_remain_on_channel_expired(struct net_device *dev, |
752 | u64 cookie, | ||
593 | struct ieee80211_channel *chan, | 753 | struct ieee80211_channel *chan, |
754 | enum nl80211_channel_type channel_type, | ||
594 | gfp_t gfp) | 755 | gfp_t gfp) |
595 | { | 756 | { |
596 | struct wiphy *wiphy = wdev->wiphy; | 757 | struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; |
597 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 758 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
598 | 759 | ||
599 | trace_cfg80211_ready_on_channel_expired(wdev, cookie, chan); | 760 | nl80211_send_remain_on_channel_cancel(rdev, dev, cookie, chan, |
600 | nl80211_send_remain_on_channel_cancel(rdev, wdev, cookie, chan, gfp); | 761 | channel_type, gfp); |
601 | } | 762 | } |
602 | EXPORT_SYMBOL(cfg80211_remain_on_channel_expired); | 763 | EXPORT_SYMBOL(cfg80211_remain_on_channel_expired); |
603 | 764 | ||
@@ -607,7 +768,6 @@ void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr, | |||
607 | struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; | 768 | struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; |
608 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 769 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
609 | 770 | ||
610 | trace_cfg80211_new_sta(dev, mac_addr, sinfo); | ||
611 | nl80211_send_sta_event(rdev, dev, mac_addr, sinfo, gfp); | 771 | nl80211_send_sta_event(rdev, dev, mac_addr, sinfo, gfp); |
612 | } | 772 | } |
613 | EXPORT_SYMBOL(cfg80211_new_sta); | 773 | EXPORT_SYMBOL(cfg80211_new_sta); |
@@ -617,26 +777,14 @@ void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp) | |||
617 | struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; | 777 | struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; |
618 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 778 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
619 | 779 | ||
620 | trace_cfg80211_del_sta(dev, mac_addr); | ||
621 | nl80211_send_sta_del_event(rdev, dev, mac_addr, gfp); | 780 | nl80211_send_sta_del_event(rdev, dev, mac_addr, gfp); |
622 | } | 781 | } |
623 | EXPORT_SYMBOL(cfg80211_del_sta); | 782 | EXPORT_SYMBOL(cfg80211_del_sta); |
624 | 783 | ||
625 | void cfg80211_conn_failed(struct net_device *dev, const u8 *mac_addr, | ||
626 | enum nl80211_connect_failed_reason reason, | ||
627 | gfp_t gfp) | ||
628 | { | ||
629 | struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; | ||
630 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | ||
631 | |||
632 | nl80211_send_conn_failed_event(rdev, dev, mac_addr, reason, gfp); | ||
633 | } | ||
634 | EXPORT_SYMBOL(cfg80211_conn_failed); | ||
635 | |||
636 | struct cfg80211_mgmt_registration { | 784 | struct cfg80211_mgmt_registration { |
637 | struct list_head list; | 785 | struct list_head list; |
638 | 786 | ||
639 | u32 nlportid; | 787 | u32 nlpid; |
640 | 788 | ||
641 | int match_len; | 789 | int match_len; |
642 | 790 | ||
@@ -645,7 +793,7 @@ struct cfg80211_mgmt_registration { | |||
645 | u8 match[]; | 793 | u8 match[]; |
646 | }; | 794 | }; |
647 | 795 | ||
648 | int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_portid, | 796 | int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_pid, |
649 | u16 frame_type, const u8 *match_data, | 797 | u16 frame_type, const u8 *match_data, |
650 | int match_len) | 798 | int match_len) |
651 | { | 799 | { |
@@ -693,12 +841,13 @@ int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_portid, | |||
693 | 841 | ||
694 | memcpy(nreg->match, match_data, match_len); | 842 | memcpy(nreg->match, match_data, match_len); |
695 | nreg->match_len = match_len; | 843 | nreg->match_len = match_len; |
696 | nreg->nlportid = snd_portid; | 844 | nreg->nlpid = snd_pid; |
697 | nreg->frame_type = cpu_to_le16(frame_type); | 845 | nreg->frame_type = cpu_to_le16(frame_type); |
698 | list_add(&nreg->list, &wdev->mgmt_registrations); | 846 | list_add(&nreg->list, &wdev->mgmt_registrations); |
699 | 847 | ||
700 | if (rdev->ops->mgmt_frame_register) | 848 | if (rdev->ops->mgmt_frame_register) |
701 | rdev_mgmt_frame_register(rdev, wdev, frame_type, true); | 849 | rdev->ops->mgmt_frame_register(wiphy, wdev->netdev, |
850 | frame_type, true); | ||
702 | 851 | ||
703 | out: | 852 | out: |
704 | spin_unlock_bh(&wdev->mgmt_registrations_lock); | 853 | spin_unlock_bh(&wdev->mgmt_registrations_lock); |
@@ -706,7 +855,7 @@ int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_portid, | |||
706 | return err; | 855 | return err; |
707 | } | 856 | } |
708 | 857 | ||
709 | void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlportid) | 858 | void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlpid) |
710 | { | 859 | { |
711 | struct wiphy *wiphy = wdev->wiphy; | 860 | struct wiphy *wiphy = wdev->wiphy; |
712 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 861 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
@@ -715,14 +864,14 @@ void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlportid) | |||
715 | spin_lock_bh(&wdev->mgmt_registrations_lock); | 864 | spin_lock_bh(&wdev->mgmt_registrations_lock); |
716 | 865 | ||
717 | list_for_each_entry_safe(reg, tmp, &wdev->mgmt_registrations, list) { | 866 | list_for_each_entry_safe(reg, tmp, &wdev->mgmt_registrations, list) { |
718 | if (reg->nlportid != nlportid) | 867 | if (reg->nlpid != nlpid) |
719 | continue; | 868 | continue; |
720 | 869 | ||
721 | if (rdev->ops->mgmt_frame_register) { | 870 | if (rdev->ops->mgmt_frame_register) { |
722 | u16 frame_type = le16_to_cpu(reg->frame_type); | 871 | u16 frame_type = le16_to_cpu(reg->frame_type); |
723 | 872 | ||
724 | rdev_mgmt_frame_register(rdev, wdev, | 873 | rdev->ops->mgmt_frame_register(wiphy, wdev->netdev, |
725 | frame_type, false); | 874 | frame_type, false); |
726 | } | 875 | } |
727 | 876 | ||
728 | list_del(®->list); | 877 | list_del(®->list); |
@@ -730,9 +879,6 @@ void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlportid) | |||
730 | } | 879 | } |
731 | 880 | ||
732 | spin_unlock_bh(&wdev->mgmt_registrations_lock); | 881 | spin_unlock_bh(&wdev->mgmt_registrations_lock); |
733 | |||
734 | if (nlportid == wdev->ap_unexpected_nlportid) | ||
735 | wdev->ap_unexpected_nlportid = 0; | ||
736 | } | 882 | } |
737 | 883 | ||
738 | void cfg80211_mlme_purge_registrations(struct wireless_dev *wdev) | 884 | void cfg80211_mlme_purge_registrations(struct wireless_dev *wdev) |
@@ -750,11 +896,13 @@ void cfg80211_mlme_purge_registrations(struct wireless_dev *wdev) | |||
750 | } | 896 | } |
751 | 897 | ||
752 | int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, | 898 | int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, |
753 | struct wireless_dev *wdev, | 899 | struct net_device *dev, |
754 | struct ieee80211_channel *chan, bool offchan, | 900 | struct ieee80211_channel *chan, bool offchan, |
755 | unsigned int wait, const u8 *buf, size_t len, | 901 | enum nl80211_channel_type channel_type, |
756 | bool no_cck, bool dont_wait_for_ack, u64 *cookie) | 902 | bool channel_type_valid, unsigned int wait, |
903 | const u8 *buf, size_t len, u64 *cookie) | ||
757 | { | 904 | { |
905 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
758 | const struct ieee80211_mgmt *mgmt; | 906 | const struct ieee80211_mgmt *mgmt; |
759 | u16 stype; | 907 | u16 stype; |
760 | 908 | ||
@@ -791,8 +939,8 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, | |||
791 | break; | 939 | break; |
792 | } | 940 | } |
793 | 941 | ||
794 | if (!ether_addr_equal(wdev->current_bss->pub.bssid, | 942 | if (memcmp(wdev->current_bss->pub.bssid, |
795 | mgmt->bssid)) { | 943 | mgmt->bssid, ETH_ALEN)) { |
796 | err = -ENOTCONN; | 944 | err = -ENOTCONN; |
797 | break; | 945 | break; |
798 | } | 946 | } |
@@ -805,8 +953,8 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, | |||
805 | break; | 953 | break; |
806 | 954 | ||
807 | /* for station, check that DA is the AP */ | 955 | /* for station, check that DA is the AP */ |
808 | if (!ether_addr_equal(wdev->current_bss->pub.bssid, | 956 | if (memcmp(wdev->current_bss->pub.bssid, |
809 | mgmt->da)) { | 957 | mgmt->da, ETH_ALEN)) { |
810 | err = -ENOTCONN; | 958 | err = -ENOTCONN; |
811 | break; | 959 | break; |
812 | } | 960 | } |
@@ -814,11 +962,11 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, | |||
814 | case NL80211_IFTYPE_AP: | 962 | case NL80211_IFTYPE_AP: |
815 | case NL80211_IFTYPE_P2P_GO: | 963 | case NL80211_IFTYPE_P2P_GO: |
816 | case NL80211_IFTYPE_AP_VLAN: | 964 | case NL80211_IFTYPE_AP_VLAN: |
817 | if (!ether_addr_equal(mgmt->bssid, wdev_address(wdev))) | 965 | if (memcmp(mgmt->bssid, dev->dev_addr, ETH_ALEN)) |
818 | err = -EINVAL; | 966 | err = -EINVAL; |
819 | break; | 967 | break; |
820 | case NL80211_IFTYPE_MESH_POINT: | 968 | case NL80211_IFTYPE_MESH_POINT: |
821 | if (!ether_addr_equal(mgmt->sa, mgmt->bssid)) { | 969 | if (memcmp(mgmt->sa, mgmt->bssid, ETH_ALEN)) { |
822 | err = -EINVAL; | 970 | err = -EINVAL; |
823 | break; | 971 | break; |
824 | } | 972 | } |
@@ -827,11 +975,6 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, | |||
827 | * cfg80211 doesn't track the stations | 975 | * cfg80211 doesn't track the stations |
828 | */ | 976 | */ |
829 | break; | 977 | break; |
830 | case NL80211_IFTYPE_P2P_DEVICE: | ||
831 | /* | ||
832 | * fall through, P2P device only supports | ||
833 | * public action frames | ||
834 | */ | ||
835 | default: | 978 | default: |
836 | err = -EOPNOTSUPP; | 979 | err = -EOPNOTSUPP; |
837 | break; | 980 | break; |
@@ -842,18 +985,19 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, | |||
842 | return err; | 985 | return err; |
843 | } | 986 | } |
844 | 987 | ||
845 | if (!ether_addr_equal(mgmt->sa, wdev_address(wdev))) | 988 | if (memcmp(mgmt->sa, dev->dev_addr, ETH_ALEN) != 0) |
846 | return -EINVAL; | 989 | return -EINVAL; |
847 | 990 | ||
848 | /* Transmit the Action frame as requested by user space */ | 991 | /* Transmit the Action frame as requested by user space */ |
849 | return rdev_mgmt_tx(rdev, wdev, chan, offchan, | 992 | return rdev->ops->mgmt_tx(&rdev->wiphy, dev, chan, offchan, |
850 | wait, buf, len, no_cck, dont_wait_for_ack, | 993 | channel_type, channel_type_valid, |
851 | cookie); | 994 | wait, buf, len, cookie); |
852 | } | 995 | } |
853 | 996 | ||
854 | bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_mbm, | 997 | bool cfg80211_rx_mgmt(struct net_device *dev, int freq, const u8 *buf, |
855 | const u8 *buf, size_t len, gfp_t gfp) | 998 | size_t len, gfp_t gfp) |
856 | { | 999 | { |
1000 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
857 | struct wiphy *wiphy = wdev->wiphy; | 1001 | struct wiphy *wiphy = wdev->wiphy; |
858 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 1002 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
859 | struct cfg80211_mgmt_registration *reg; | 1003 | struct cfg80211_mgmt_registration *reg; |
@@ -867,13 +1011,10 @@ bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_mbm, | |||
867 | cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE); | 1011 | cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE); |
868 | u16 stype; | 1012 | u16 stype; |
869 | 1013 | ||
870 | trace_cfg80211_rx_mgmt(wdev, freq, sig_mbm); | ||
871 | stype = (le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE) >> 4; | 1014 | stype = (le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE) >> 4; |
872 | 1015 | ||
873 | if (!(stypes->rx & BIT(stype))) { | 1016 | if (!(stypes->rx & BIT(stype))) |
874 | trace_cfg80211_return_bool(false); | ||
875 | return false; | 1017 | return false; |
876 | } | ||
877 | 1018 | ||
878 | data = buf + ieee80211_hdrlen(mgmt->frame_control); | 1019 | data = buf + ieee80211_hdrlen(mgmt->frame_control); |
879 | data_len = len - ieee80211_hdrlen(mgmt->frame_control); | 1020 | data_len = len - ieee80211_hdrlen(mgmt->frame_control); |
@@ -893,8 +1034,7 @@ bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_mbm, | |||
893 | /* found match! */ | 1034 | /* found match! */ |
894 | 1035 | ||
895 | /* Indicate the received Action frame to user space */ | 1036 | /* Indicate the received Action frame to user space */ |
896 | if (nl80211_send_mgmt(rdev, wdev, reg->nlportid, | 1037 | if (nl80211_send_mgmt(rdev, dev, reg->nlpid, freq, |
897 | freq, sig_mbm, | ||
898 | buf, len, gfp)) | 1038 | buf, len, gfp)) |
899 | continue; | 1039 | continue; |
900 | 1040 | ||
@@ -904,21 +1044,19 @@ bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_mbm, | |||
904 | 1044 | ||
905 | spin_unlock_bh(&wdev->mgmt_registrations_lock); | 1045 | spin_unlock_bh(&wdev->mgmt_registrations_lock); |
906 | 1046 | ||
907 | trace_cfg80211_return_bool(result); | ||
908 | return result; | 1047 | return result; |
909 | } | 1048 | } |
910 | EXPORT_SYMBOL(cfg80211_rx_mgmt); | 1049 | EXPORT_SYMBOL(cfg80211_rx_mgmt); |
911 | 1050 | ||
912 | void cfg80211_mgmt_tx_status(struct wireless_dev *wdev, u64 cookie, | 1051 | void cfg80211_mgmt_tx_status(struct net_device *dev, u64 cookie, |
913 | const u8 *buf, size_t len, bool ack, gfp_t gfp) | 1052 | const u8 *buf, size_t len, bool ack, gfp_t gfp) |
914 | { | 1053 | { |
1054 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
915 | struct wiphy *wiphy = wdev->wiphy; | 1055 | struct wiphy *wiphy = wdev->wiphy; |
916 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 1056 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
917 | 1057 | ||
918 | trace_cfg80211_mgmt_tx_status(wdev, cookie, ack); | ||
919 | |||
920 | /* Indicate TX status of the Action frame to user space */ | 1058 | /* Indicate TX status of the Action frame to user space */ |
921 | nl80211_send_mgmt_tx_status(rdev, wdev, cookie, buf, len, ack, gfp); | 1059 | nl80211_send_mgmt_tx_status(rdev, dev, cookie, buf, len, ack, gfp); |
922 | } | 1060 | } |
923 | EXPORT_SYMBOL(cfg80211_mgmt_tx_status); | 1061 | EXPORT_SYMBOL(cfg80211_mgmt_tx_status); |
924 | 1062 | ||
@@ -930,8 +1068,6 @@ void cfg80211_cqm_rssi_notify(struct net_device *dev, | |||
930 | struct wiphy *wiphy = wdev->wiphy; | 1068 | struct wiphy *wiphy = wdev->wiphy; |
931 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 1069 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
932 | 1070 | ||
933 | trace_cfg80211_cqm_rssi_notify(dev, rssi_event); | ||
934 | |||
935 | /* Indicate roaming trigger event to user space */ | 1071 | /* Indicate roaming trigger event to user space */ |
936 | nl80211_send_cqm_rssi_notify(rdev, dev, rssi_event, gfp); | 1072 | nl80211_send_cqm_rssi_notify(rdev, dev, rssi_event, gfp); |
937 | } | 1073 | } |
@@ -944,26 +1080,11 @@ void cfg80211_cqm_pktloss_notify(struct net_device *dev, | |||
944 | struct wiphy *wiphy = wdev->wiphy; | 1080 | struct wiphy *wiphy = wdev->wiphy; |
945 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 1081 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
946 | 1082 | ||
947 | trace_cfg80211_cqm_pktloss_notify(dev, peer, num_packets); | ||
948 | |||
949 | /* Indicate roaming trigger event to user space */ | 1083 | /* Indicate roaming trigger event to user space */ |
950 | nl80211_send_cqm_pktloss_notify(rdev, dev, peer, num_packets, gfp); | 1084 | nl80211_send_cqm_pktloss_notify(rdev, dev, peer, num_packets, gfp); |
951 | } | 1085 | } |
952 | EXPORT_SYMBOL(cfg80211_cqm_pktloss_notify); | 1086 | EXPORT_SYMBOL(cfg80211_cqm_pktloss_notify); |
953 | 1087 | ||
954 | void cfg80211_cqm_txe_notify(struct net_device *dev, | ||
955 | const u8 *peer, u32 num_packets, | ||
956 | u32 rate, u32 intvl, gfp_t gfp) | ||
957 | { | ||
958 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
959 | struct wiphy *wiphy = wdev->wiphy; | ||
960 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | ||
961 | |||
962 | nl80211_send_cqm_txe_notify(rdev, dev, peer, num_packets, | ||
963 | rate, intvl, gfp); | ||
964 | } | ||
965 | EXPORT_SYMBOL(cfg80211_cqm_txe_notify); | ||
966 | |||
967 | void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid, | 1088 | void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid, |
968 | const u8 *replay_ctr, gfp_t gfp) | 1089 | const u8 *replay_ctr, gfp_t gfp) |
969 | { | 1090 | { |
@@ -971,81 +1092,6 @@ void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid, | |||
971 | struct wiphy *wiphy = wdev->wiphy; | 1092 | struct wiphy *wiphy = wdev->wiphy; |
972 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 1093 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
973 | 1094 | ||
974 | trace_cfg80211_gtk_rekey_notify(dev, bssid); | ||
975 | nl80211_gtk_rekey_notify(rdev, dev, bssid, replay_ctr, gfp); | 1095 | nl80211_gtk_rekey_notify(rdev, dev, bssid, replay_ctr, gfp); |
976 | } | 1096 | } |
977 | EXPORT_SYMBOL(cfg80211_gtk_rekey_notify); | 1097 | EXPORT_SYMBOL(cfg80211_gtk_rekey_notify); |
978 | |||
979 | void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index, | ||
980 | const u8 *bssid, bool preauth, gfp_t gfp) | ||
981 | { | ||
982 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
983 | struct wiphy *wiphy = wdev->wiphy; | ||
984 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | ||
985 | |||
986 | trace_cfg80211_pmksa_candidate_notify(dev, index, bssid, preauth); | ||
987 | nl80211_pmksa_candidate_notify(rdev, dev, index, bssid, preauth, gfp); | ||
988 | } | ||
989 | EXPORT_SYMBOL(cfg80211_pmksa_candidate_notify); | ||
990 | |||
991 | void cfg80211_ch_switch_notify(struct net_device *dev, | ||
992 | struct cfg80211_chan_def *chandef) | ||
993 | { | ||
994 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
995 | struct wiphy *wiphy = wdev->wiphy; | ||
996 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | ||
997 | |||
998 | trace_cfg80211_ch_switch_notify(dev, chandef); | ||
999 | |||
1000 | wdev_lock(wdev); | ||
1001 | |||
1002 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && | ||
1003 | wdev->iftype != NL80211_IFTYPE_P2P_GO)) | ||
1004 | goto out; | ||
1005 | |||
1006 | wdev->channel = chandef->chan; | ||
1007 | nl80211_ch_switch_notify(rdev, dev, chandef, GFP_KERNEL); | ||
1008 | out: | ||
1009 | wdev_unlock(wdev); | ||
1010 | return; | ||
1011 | } | ||
1012 | EXPORT_SYMBOL(cfg80211_ch_switch_notify); | ||
1013 | |||
1014 | bool cfg80211_rx_spurious_frame(struct net_device *dev, | ||
1015 | const u8 *addr, gfp_t gfp) | ||
1016 | { | ||
1017 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
1018 | bool ret; | ||
1019 | |||
1020 | trace_cfg80211_rx_spurious_frame(dev, addr); | ||
1021 | |||
1022 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && | ||
1023 | wdev->iftype != NL80211_IFTYPE_P2P_GO)) { | ||
1024 | trace_cfg80211_return_bool(false); | ||
1025 | return false; | ||
1026 | } | ||
1027 | ret = nl80211_unexpected_frame(dev, addr, gfp); | ||
1028 | trace_cfg80211_return_bool(ret); | ||
1029 | return ret; | ||
1030 | } | ||
1031 | EXPORT_SYMBOL(cfg80211_rx_spurious_frame); | ||
1032 | |||
1033 | bool cfg80211_rx_unexpected_4addr_frame(struct net_device *dev, | ||
1034 | const u8 *addr, gfp_t gfp) | ||
1035 | { | ||
1036 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
1037 | bool ret; | ||
1038 | |||
1039 | trace_cfg80211_rx_unexpected_4addr_frame(dev, addr); | ||
1040 | |||
1041 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && | ||
1042 | wdev->iftype != NL80211_IFTYPE_P2P_GO && | ||
1043 | wdev->iftype != NL80211_IFTYPE_AP_VLAN)) { | ||
1044 | trace_cfg80211_return_bool(false); | ||
1045 | return false; | ||
1046 | } | ||
1047 | ret = nl80211_unexpected_4addr_frame(dev, addr, gfp); | ||
1048 | trace_cfg80211_return_bool(ret); | ||
1049 | return ret; | ||
1050 | } | ||
1051 | EXPORT_SYMBOL(cfg80211_rx_unexpected_4addr_frame); | ||
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index f45706adaf3..fb18bb4dea7 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -22,12 +22,6 @@ | |||
22 | #include "core.h" | 22 | #include "core.h" |
23 | #include "nl80211.h" | 23 | #include "nl80211.h" |
24 | #include "reg.h" | 24 | #include "reg.h" |
25 | #include "rdev-ops.h" | ||
26 | |||
27 | static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev, | ||
28 | struct genl_info *info, | ||
29 | struct cfg80211_crypto_settings *settings, | ||
30 | int cipher_limit); | ||
31 | 25 | ||
32 | static int nl80211_pre_doit(struct genl_ops *ops, struct sk_buff *skb, | 26 | static int nl80211_pre_doit(struct genl_ops *ops, struct sk_buff *skb, |
33 | struct genl_info *info); | 27 | struct genl_info *info); |
@@ -46,175 +40,29 @@ static struct genl_family nl80211_fam = { | |||
46 | .post_doit = nl80211_post_doit, | 40 | .post_doit = nl80211_post_doit, |
47 | }; | 41 | }; |
48 | 42 | ||
49 | /* returns ERR_PTR values */ | 43 | /* internal helper: get rdev and dev */ |
50 | static struct wireless_dev * | 44 | static int get_rdev_dev_by_info_ifindex(struct genl_info *info, |
51 | __cfg80211_wdev_from_attrs(struct net *netns, struct nlattr **attrs) | 45 | struct cfg80211_registered_device **rdev, |
52 | { | 46 | struct net_device **dev) |
53 | struct cfg80211_registered_device *rdev; | ||
54 | struct wireless_dev *result = NULL; | ||
55 | bool have_ifidx = attrs[NL80211_ATTR_IFINDEX]; | ||
56 | bool have_wdev_id = attrs[NL80211_ATTR_WDEV]; | ||
57 | u64 wdev_id; | ||
58 | int wiphy_idx = -1; | ||
59 | int ifidx = -1; | ||
60 | |||
61 | assert_cfg80211_lock(); | ||
62 | |||
63 | if (!have_ifidx && !have_wdev_id) | ||
64 | return ERR_PTR(-EINVAL); | ||
65 | |||
66 | if (have_ifidx) | ||
67 | ifidx = nla_get_u32(attrs[NL80211_ATTR_IFINDEX]); | ||
68 | if (have_wdev_id) { | ||
69 | wdev_id = nla_get_u64(attrs[NL80211_ATTR_WDEV]); | ||
70 | wiphy_idx = wdev_id >> 32; | ||
71 | } | ||
72 | |||
73 | list_for_each_entry(rdev, &cfg80211_rdev_list, list) { | ||
74 | struct wireless_dev *wdev; | ||
75 | |||
76 | if (wiphy_net(&rdev->wiphy) != netns) | ||
77 | continue; | ||
78 | |||
79 | if (have_wdev_id && rdev->wiphy_idx != wiphy_idx) | ||
80 | continue; | ||
81 | |||
82 | mutex_lock(&rdev->devlist_mtx); | ||
83 | list_for_each_entry(wdev, &rdev->wdev_list, list) { | ||
84 | if (have_ifidx && wdev->netdev && | ||
85 | wdev->netdev->ifindex == ifidx) { | ||
86 | result = wdev; | ||
87 | break; | ||
88 | } | ||
89 | if (have_wdev_id && wdev->identifier == (u32)wdev_id) { | ||
90 | result = wdev; | ||
91 | break; | ||
92 | } | ||
93 | } | ||
94 | mutex_unlock(&rdev->devlist_mtx); | ||
95 | |||
96 | if (result) | ||
97 | break; | ||
98 | } | ||
99 | |||
100 | if (result) | ||
101 | return result; | ||
102 | return ERR_PTR(-ENODEV); | ||
103 | } | ||
104 | |||
105 | static struct cfg80211_registered_device * | ||
106 | __cfg80211_rdev_from_attrs(struct net *netns, struct nlattr **attrs) | ||
107 | { | 47 | { |
108 | struct cfg80211_registered_device *rdev = NULL, *tmp; | 48 | struct nlattr **attrs = info->attrs; |
109 | struct net_device *netdev; | 49 | int ifindex; |
110 | |||
111 | assert_cfg80211_lock(); | ||
112 | |||
113 | if (!attrs[NL80211_ATTR_WIPHY] && | ||
114 | !attrs[NL80211_ATTR_IFINDEX] && | ||
115 | !attrs[NL80211_ATTR_WDEV]) | ||
116 | return ERR_PTR(-EINVAL); | ||
117 | |||
118 | if (attrs[NL80211_ATTR_WIPHY]) | ||
119 | rdev = cfg80211_rdev_by_wiphy_idx( | ||
120 | nla_get_u32(attrs[NL80211_ATTR_WIPHY])); | ||
121 | |||
122 | if (attrs[NL80211_ATTR_WDEV]) { | ||
123 | u64 wdev_id = nla_get_u64(attrs[NL80211_ATTR_WDEV]); | ||
124 | struct wireless_dev *wdev; | ||
125 | bool found = false; | ||
126 | |||
127 | tmp = cfg80211_rdev_by_wiphy_idx(wdev_id >> 32); | ||
128 | if (tmp) { | ||
129 | /* make sure wdev exists */ | ||
130 | mutex_lock(&tmp->devlist_mtx); | ||
131 | list_for_each_entry(wdev, &tmp->wdev_list, list) { | ||
132 | if (wdev->identifier != (u32)wdev_id) | ||
133 | continue; | ||
134 | found = true; | ||
135 | break; | ||
136 | } | ||
137 | mutex_unlock(&tmp->devlist_mtx); | ||
138 | |||
139 | if (!found) | ||
140 | tmp = NULL; | ||
141 | |||
142 | if (rdev && tmp != rdev) | ||
143 | return ERR_PTR(-EINVAL); | ||
144 | rdev = tmp; | ||
145 | } | ||
146 | } | ||
147 | 50 | ||
148 | if (attrs[NL80211_ATTR_IFINDEX]) { | 51 | if (!attrs[NL80211_ATTR_IFINDEX]) |
149 | int ifindex = nla_get_u32(attrs[NL80211_ATTR_IFINDEX]); | 52 | return -EINVAL; |
150 | netdev = dev_get_by_index(netns, ifindex); | ||
151 | if (netdev) { | ||
152 | if (netdev->ieee80211_ptr) | ||
153 | tmp = wiphy_to_dev( | ||
154 | netdev->ieee80211_ptr->wiphy); | ||
155 | else | ||
156 | tmp = NULL; | ||
157 | |||
158 | dev_put(netdev); | ||
159 | |||
160 | /* not wireless device -- return error */ | ||
161 | if (!tmp) | ||
162 | return ERR_PTR(-EINVAL); | ||
163 | 53 | ||
164 | /* mismatch -- return error */ | 54 | ifindex = nla_get_u32(attrs[NL80211_ATTR_IFINDEX]); |
165 | if (rdev && tmp != rdev) | 55 | *dev = dev_get_by_index(genl_info_net(info), ifindex); |
166 | return ERR_PTR(-EINVAL); | 56 | if (!*dev) |
57 | return -ENODEV; | ||
167 | 58 | ||
168 | rdev = tmp; | 59 | *rdev = cfg80211_get_dev_from_ifindex(genl_info_net(info), ifindex); |
169 | } | 60 | if (IS_ERR(*rdev)) { |
61 | dev_put(*dev); | ||
62 | return PTR_ERR(*rdev); | ||
170 | } | 63 | } |
171 | 64 | ||
172 | if (!rdev) | 65 | return 0; |
173 | return ERR_PTR(-ENODEV); | ||
174 | |||
175 | if (netns != wiphy_net(&rdev->wiphy)) | ||
176 | return ERR_PTR(-ENODEV); | ||
177 | |||
178 | return rdev; | ||
179 | } | ||
180 | |||
181 | /* | ||
182 | * This function returns a pointer to the driver | ||
183 | * that the genl_info item that is passed refers to. | ||
184 | * If successful, it returns non-NULL and also locks | ||
185 | * the driver's mutex! | ||
186 | * | ||
187 | * This means that you need to call cfg80211_unlock_rdev() | ||
188 | * before being allowed to acquire &cfg80211_mutex! | ||
189 | * | ||
190 | * This is necessary because we need to lock the global | ||
191 | * mutex to get an item off the list safely, and then | ||
192 | * we lock the rdev mutex so it doesn't go away under us. | ||
193 | * | ||
194 | * We don't want to keep cfg80211_mutex locked | ||
195 | * for all the time in order to allow requests on | ||
196 | * other interfaces to go through at the same time. | ||
197 | * | ||
198 | * The result of this can be a PTR_ERR and hence must | ||
199 | * be checked with IS_ERR() for errors. | ||
200 | */ | ||
201 | static struct cfg80211_registered_device * | ||
202 | cfg80211_get_dev_from_info(struct net *netns, struct genl_info *info) | ||
203 | { | ||
204 | struct cfg80211_registered_device *rdev; | ||
205 | |||
206 | mutex_lock(&cfg80211_mutex); | ||
207 | rdev = __cfg80211_rdev_from_attrs(netns, info->attrs); | ||
208 | |||
209 | /* if it is not an error we grab the lock on | ||
210 | * it to assure it won't be going away while | ||
211 | * we operate on it */ | ||
212 | if (!IS_ERR(rdev)) | ||
213 | mutex_lock(&rdev->mtx); | ||
214 | |||
215 | mutex_unlock(&cfg80211_mutex); | ||
216 | |||
217 | return rdev; | ||
218 | } | 66 | } |
219 | 67 | ||
220 | /* policy for the attributes */ | 68 | /* policy for the attributes */ |
@@ -223,13 +71,8 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = { | |||
223 | [NL80211_ATTR_WIPHY_NAME] = { .type = NLA_NUL_STRING, | 71 | [NL80211_ATTR_WIPHY_NAME] = { .type = NLA_NUL_STRING, |
224 | .len = 20-1 }, | 72 | .len = 20-1 }, |
225 | [NL80211_ATTR_WIPHY_TXQ_PARAMS] = { .type = NLA_NESTED }, | 73 | [NL80211_ATTR_WIPHY_TXQ_PARAMS] = { .type = NLA_NESTED }, |
226 | |||
227 | [NL80211_ATTR_WIPHY_FREQ] = { .type = NLA_U32 }, | 74 | [NL80211_ATTR_WIPHY_FREQ] = { .type = NLA_U32 }, |
228 | [NL80211_ATTR_WIPHY_CHANNEL_TYPE] = { .type = NLA_U32 }, | 75 | [NL80211_ATTR_WIPHY_CHANNEL_TYPE] = { .type = NLA_U32 }, |
229 | [NL80211_ATTR_CHANNEL_WIDTH] = { .type = NLA_U32 }, | ||
230 | [NL80211_ATTR_CENTER_FREQ1] = { .type = NLA_U32 }, | ||
231 | [NL80211_ATTR_CENTER_FREQ2] = { .type = NLA_U32 }, | ||
232 | |||
233 | [NL80211_ATTR_WIPHY_RETRY_SHORT] = { .type = NLA_U8 }, | 76 | [NL80211_ATTR_WIPHY_RETRY_SHORT] = { .type = NLA_U8 }, |
234 | [NL80211_ATTR_WIPHY_RETRY_LONG] = { .type = NLA_U8 }, | 77 | [NL80211_ATTR_WIPHY_RETRY_LONG] = { .type = NLA_U8 }, |
235 | [NL80211_ATTR_WIPHY_FRAG_THRESHOLD] = { .type = NLA_U32 }, | 78 | [NL80211_ATTR_WIPHY_FRAG_THRESHOLD] = { .type = NLA_U32 }, |
@@ -249,7 +92,7 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = { | |||
249 | [NL80211_ATTR_KEY_IDX] = { .type = NLA_U8 }, | 92 | [NL80211_ATTR_KEY_IDX] = { .type = NLA_U8 }, |
250 | [NL80211_ATTR_KEY_CIPHER] = { .type = NLA_U32 }, | 93 | [NL80211_ATTR_KEY_CIPHER] = { .type = NLA_U32 }, |
251 | [NL80211_ATTR_KEY_DEFAULT] = { .type = NLA_FLAG }, | 94 | [NL80211_ATTR_KEY_DEFAULT] = { .type = NLA_FLAG }, |
252 | [NL80211_ATTR_KEY_SEQ] = { .type = NLA_BINARY, .len = 16 }, | 95 | [NL80211_ATTR_KEY_SEQ] = { .type = NLA_BINARY, .len = 8 }, |
253 | [NL80211_ATTR_KEY_TYPE] = { .type = NLA_U32 }, | 96 | [NL80211_ATTR_KEY_TYPE] = { .type = NLA_U32 }, |
254 | 97 | ||
255 | [NL80211_ATTR_BEACON_INTERVAL] = { .type = NLA_U32 }, | 98 | [NL80211_ATTR_BEACON_INTERVAL] = { .type = NLA_U32 }, |
@@ -267,7 +110,7 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = { | |||
267 | [NL80211_ATTR_STA_VLAN] = { .type = NLA_U32 }, | 110 | [NL80211_ATTR_STA_VLAN] = { .type = NLA_U32 }, |
268 | [NL80211_ATTR_MNTR_FLAGS] = { /* NLA_NESTED can't be empty */ }, | 111 | [NL80211_ATTR_MNTR_FLAGS] = { /* NLA_NESTED can't be empty */ }, |
269 | [NL80211_ATTR_MESH_ID] = { .type = NLA_BINARY, | 112 | [NL80211_ATTR_MESH_ID] = { .type = NLA_BINARY, |
270 | .len = IEEE80211_MAX_MESH_ID_LEN }, | 113 | .len = IEEE80211_MAX_MESH_ID_LEN }, |
271 | [NL80211_ATTR_MPATH_NEXT_HOP] = { .type = NLA_U32 }, | 114 | [NL80211_ATTR_MPATH_NEXT_HOP] = { .type = NLA_U32 }, |
272 | 115 | ||
273 | [NL80211_ATTR_REG_ALPHA2] = { .type = NLA_STRING, .len = 2 }, | 116 | [NL80211_ATTR_REG_ALPHA2] = { .type = NLA_STRING, .len = 2 }, |
@@ -334,37 +177,6 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = { | |||
334 | [NL80211_ATTR_SCHED_SCAN_INTERVAL] = { .type = NLA_U32 }, | 177 | [NL80211_ATTR_SCHED_SCAN_INTERVAL] = { .type = NLA_U32 }, |
335 | [NL80211_ATTR_REKEY_DATA] = { .type = NLA_NESTED }, | 178 | [NL80211_ATTR_REKEY_DATA] = { .type = NLA_NESTED }, |
336 | [NL80211_ATTR_SCAN_SUPP_RATES] = { .type = NLA_NESTED }, | 179 | [NL80211_ATTR_SCAN_SUPP_RATES] = { .type = NLA_NESTED }, |
337 | [NL80211_ATTR_HIDDEN_SSID] = { .type = NLA_U32 }, | ||
338 | [NL80211_ATTR_IE_PROBE_RESP] = { .type = NLA_BINARY, | ||
339 | .len = IEEE80211_MAX_DATA_LEN }, | ||
340 | [NL80211_ATTR_IE_ASSOC_RESP] = { .type = NLA_BINARY, | ||
341 | .len = IEEE80211_MAX_DATA_LEN }, | ||
342 | [NL80211_ATTR_ROAM_SUPPORT] = { .type = NLA_FLAG }, | ||
343 | [NL80211_ATTR_SCHED_SCAN_MATCH] = { .type = NLA_NESTED }, | ||
344 | [NL80211_ATTR_TX_NO_CCK_RATE] = { .type = NLA_FLAG }, | ||
345 | [NL80211_ATTR_TDLS_ACTION] = { .type = NLA_U8 }, | ||
346 | [NL80211_ATTR_TDLS_DIALOG_TOKEN] = { .type = NLA_U8 }, | ||
347 | [NL80211_ATTR_TDLS_OPERATION] = { .type = NLA_U8 }, | ||
348 | [NL80211_ATTR_TDLS_SUPPORT] = { .type = NLA_FLAG }, | ||
349 | [NL80211_ATTR_TDLS_EXTERNAL_SETUP] = { .type = NLA_FLAG }, | ||
350 | [NL80211_ATTR_DONT_WAIT_FOR_ACK] = { .type = NLA_FLAG }, | ||
351 | [NL80211_ATTR_PROBE_RESP] = { .type = NLA_BINARY, | ||
352 | .len = IEEE80211_MAX_DATA_LEN }, | ||
353 | [NL80211_ATTR_DFS_REGION] = { .type = NLA_U8 }, | ||
354 | [NL80211_ATTR_DISABLE_HT] = { .type = NLA_FLAG }, | ||
355 | [NL80211_ATTR_HT_CAPABILITY_MASK] = { | ||
356 | .len = NL80211_HT_CAPABILITY_LEN | ||
357 | }, | ||
358 | [NL80211_ATTR_NOACK_MAP] = { .type = NLA_U16 }, | ||
359 | [NL80211_ATTR_INACTIVITY_TIMEOUT] = { .type = NLA_U16 }, | ||
360 | [NL80211_ATTR_BG_SCAN_PERIOD] = { .type = NLA_U16 }, | ||
361 | [NL80211_ATTR_WDEV] = { .type = NLA_U64 }, | ||
362 | [NL80211_ATTR_USER_REG_HINT_TYPE] = { .type = NLA_U32 }, | ||
363 | [NL80211_ATTR_SAE_DATA] = { .type = NLA_BINARY, }, | ||
364 | [NL80211_ATTR_VHT_CAPABILITY] = { .len = NL80211_VHT_CAPABILITY_LEN }, | ||
365 | [NL80211_ATTR_SCAN_FLAGS] = { .type = NLA_U32 }, | ||
366 | [NL80211_ATTR_P2P_CTWINDOW] = { .type = NLA_U8 }, | ||
367 | [NL80211_ATTR_P2P_OPPPS] = { .type = NLA_U8 }, | ||
368 | }; | 180 | }; |
369 | 181 | ||
370 | /* policy for the key attributes */ | 182 | /* policy for the key attributes */ |
@@ -372,7 +184,7 @@ static const struct nla_policy nl80211_key_policy[NL80211_KEY_MAX + 1] = { | |||
372 | [NL80211_KEY_DATA] = { .type = NLA_BINARY, .len = WLAN_MAX_KEY_LEN }, | 184 | [NL80211_KEY_DATA] = { .type = NLA_BINARY, .len = WLAN_MAX_KEY_LEN }, |
373 | [NL80211_KEY_IDX] = { .type = NLA_U8 }, | 185 | [NL80211_KEY_IDX] = { .type = NLA_U8 }, |
374 | [NL80211_KEY_CIPHER] = { .type = NLA_U32 }, | 186 | [NL80211_KEY_CIPHER] = { .type = NLA_U32 }, |
375 | [NL80211_KEY_SEQ] = { .type = NLA_BINARY, .len = 16 }, | 187 | [NL80211_KEY_SEQ] = { .type = NLA_BINARY, .len = 8 }, |
376 | [NL80211_KEY_DEFAULT] = { .type = NLA_FLAG }, | 188 | [NL80211_KEY_DEFAULT] = { .type = NLA_FLAG }, |
377 | [NL80211_KEY_DEFAULT_MGMT] = { .type = NLA_FLAG }, | 189 | [NL80211_KEY_DEFAULT_MGMT] = { .type = NLA_FLAG }, |
378 | [NL80211_KEY_TYPE] = { .type = NLA_U32 }, | 190 | [NL80211_KEY_TYPE] = { .type = NLA_U32 }, |
@@ -407,13 +219,6 @@ nl80211_rekey_policy[NUM_NL80211_REKEY_DATA] = { | |||
407 | [NL80211_REKEY_DATA_REPLAY_CTR] = { .len = NL80211_REPLAY_CTR_LEN }, | 219 | [NL80211_REKEY_DATA_REPLAY_CTR] = { .len = NL80211_REPLAY_CTR_LEN }, |
408 | }; | 220 | }; |
409 | 221 | ||
410 | static const struct nla_policy | ||
411 | nl80211_match_policy[NL80211_SCHED_SCAN_MATCH_ATTR_MAX + 1] = { | ||
412 | [NL80211_SCHED_SCAN_MATCH_ATTR_SSID] = { .type = NLA_BINARY, | ||
413 | .len = IEEE80211_MAX_SSID_LEN }, | ||
414 | [NL80211_SCHED_SCAN_MATCH_ATTR_RSSI] = { .type = NLA_U32 }, | ||
415 | }; | ||
416 | |||
417 | /* ifidx get helper */ | 222 | /* ifidx get helper */ |
418 | static int nl80211_get_ifidx(struct netlink_callback *cb) | 223 | static int nl80211_get_ifidx(struct netlink_callback *cb) |
419 | { | 224 | { |
@@ -506,36 +311,30 @@ static bool is_valid_ie_attr(const struct nlattr *attr) | |||
506 | } | 311 | } |
507 | 312 | ||
508 | /* message building helper */ | 313 | /* message building helper */ |
509 | static inline void *nl80211hdr_put(struct sk_buff *skb, u32 portid, u32 seq, | 314 | static inline void *nl80211hdr_put(struct sk_buff *skb, u32 pid, u32 seq, |
510 | int flags, u8 cmd) | 315 | int flags, u8 cmd) |
511 | { | 316 | { |
512 | /* since there is no private header just add the generic one */ | 317 | /* since there is no private header just add the generic one */ |
513 | return genlmsg_put(skb, portid, seq, &nl80211_fam, flags, cmd); | 318 | return genlmsg_put(skb, pid, seq, &nl80211_fam, flags, cmd); |
514 | } | 319 | } |
515 | 320 | ||
516 | static int nl80211_msg_put_channel(struct sk_buff *msg, | 321 | static int nl80211_msg_put_channel(struct sk_buff *msg, |
517 | struct ieee80211_channel *chan) | 322 | struct ieee80211_channel *chan) |
518 | { | 323 | { |
519 | if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_FREQ, | 324 | NLA_PUT_U32(msg, NL80211_FREQUENCY_ATTR_FREQ, |
520 | chan->center_freq)) | 325 | chan->center_freq); |
521 | goto nla_put_failure; | ||
522 | 326 | ||
523 | if ((chan->flags & IEEE80211_CHAN_DISABLED) && | 327 | if (chan->flags & IEEE80211_CHAN_DISABLED) |
524 | nla_put_flag(msg, NL80211_FREQUENCY_ATTR_DISABLED)) | 328 | NLA_PUT_FLAG(msg, NL80211_FREQUENCY_ATTR_DISABLED); |
525 | goto nla_put_failure; | 329 | if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN) |
526 | if ((chan->flags & IEEE80211_CHAN_PASSIVE_SCAN) && | 330 | NLA_PUT_FLAG(msg, NL80211_FREQUENCY_ATTR_PASSIVE_SCAN); |
527 | nla_put_flag(msg, NL80211_FREQUENCY_ATTR_PASSIVE_SCAN)) | 331 | if (chan->flags & IEEE80211_CHAN_NO_IBSS) |
528 | goto nla_put_failure; | 332 | NLA_PUT_FLAG(msg, NL80211_FREQUENCY_ATTR_NO_IBSS); |
529 | if ((chan->flags & IEEE80211_CHAN_NO_IBSS) && | 333 | if (chan->flags & IEEE80211_CHAN_RADAR) |
530 | nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_IBSS)) | 334 | NLA_PUT_FLAG(msg, NL80211_FREQUENCY_ATTR_RADAR); |
531 | goto nla_put_failure; | ||
532 | if ((chan->flags & IEEE80211_CHAN_RADAR) && | ||
533 | nla_put_flag(msg, NL80211_FREQUENCY_ATTR_RADAR)) | ||
534 | goto nla_put_failure; | ||
535 | 335 | ||
536 | if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_MAX_TX_POWER, | 336 | NLA_PUT_U32(msg, NL80211_FREQUENCY_ATTR_MAX_TX_POWER, |
537 | DBM_TO_MBM(chan->max_power))) | 337 | DBM_TO_MBM(chan->max_power)); |
538 | goto nla_put_failure; | ||
539 | 338 | ||
540 | return 0; | 339 | return 0; |
541 | 340 | ||
@@ -595,9 +394,10 @@ static int nl80211_parse_key_new(struct nlattr *key, struct key_parse *k) | |||
595 | 394 | ||
596 | if (tb[NL80211_KEY_DEFAULT_TYPES]) { | 395 | if (tb[NL80211_KEY_DEFAULT_TYPES]) { |
597 | struct nlattr *kdt[NUM_NL80211_KEY_DEFAULT_TYPES]; | 396 | struct nlattr *kdt[NUM_NL80211_KEY_DEFAULT_TYPES]; |
598 | err = nla_parse_nested(kdt, NUM_NL80211_KEY_DEFAULT_TYPES - 1, | 397 | int err = nla_parse_nested(kdt, |
599 | tb[NL80211_KEY_DEFAULT_TYPES], | 398 | NUM_NL80211_KEY_DEFAULT_TYPES - 1, |
600 | nl80211_key_default_policy); | 399 | tb[NL80211_KEY_DEFAULT_TYPES], |
400 | nl80211_key_default_policy); | ||
601 | if (err) | 401 | if (err) |
602 | return err; | 402 | return err; |
603 | 403 | ||
@@ -700,7 +500,7 @@ static int nl80211_parse_key(struct genl_info *info, struct key_parse *k) | |||
700 | 500 | ||
701 | static struct cfg80211_cached_keys * | 501 | static struct cfg80211_cached_keys * |
702 | nl80211_parse_connkeys(struct cfg80211_registered_device *rdev, | 502 | nl80211_parse_connkeys(struct cfg80211_registered_device *rdev, |
703 | struct nlattr *keys, bool *no_ht) | 503 | struct nlattr *keys) |
704 | { | 504 | { |
705 | struct key_parse parse; | 505 | struct key_parse parse; |
706 | struct nlattr *key; | 506 | struct nlattr *key; |
@@ -743,12 +543,6 @@ nl80211_parse_connkeys(struct cfg80211_registered_device *rdev, | |||
743 | result->params[parse.idx].key_len = parse.p.key_len; | 543 | result->params[parse.idx].key_len = parse.p.key_len; |
744 | result->params[parse.idx].key = result->data[parse.idx]; | 544 | result->params[parse.idx].key = result->data[parse.idx]; |
745 | memcpy(result->data[parse.idx], parse.p.key, parse.p.key_len); | 545 | memcpy(result->data[parse.idx], parse.p.key, parse.p.key_len); |
746 | |||
747 | if (parse.p.cipher == WLAN_CIPHER_SUITE_WEP40 || | ||
748 | parse.p.cipher == WLAN_CIPHER_SUITE_WEP104) { | ||
749 | if (no_ht) | ||
750 | *no_ht = true; | ||
751 | } | ||
752 | } | 546 | } |
753 | 547 | ||
754 | return result; | 548 | return result; |
@@ -793,8 +587,8 @@ static int nl80211_put_iftypes(struct sk_buff *msg, u32 attr, u16 ifmodes) | |||
793 | 587 | ||
794 | i = 0; | 588 | i = 0; |
795 | while (ifmodes) { | 589 | while (ifmodes) { |
796 | if ((ifmodes & 1) && nla_put_flag(msg, i)) | 590 | if (ifmodes & 1) |
797 | goto nla_put_failure; | 591 | NLA_PUT_FLAG(msg, i); |
798 | ifmodes >>= 1; | 592 | ifmodes >>= 1; |
799 | i++; | 593 | i++; |
800 | } | 594 | } |
@@ -837,9 +631,8 @@ static int nl80211_put_iface_combinations(struct wiphy *wiphy, | |||
837 | nl_limit = nla_nest_start(msg, j + 1); | 631 | nl_limit = nla_nest_start(msg, j + 1); |
838 | if (!nl_limit) | 632 | if (!nl_limit) |
839 | goto nla_put_failure; | 633 | goto nla_put_failure; |
840 | if (nla_put_u32(msg, NL80211_IFACE_LIMIT_MAX, | 634 | NLA_PUT_U32(msg, NL80211_IFACE_LIMIT_MAX, |
841 | c->limits[j].max)) | 635 | c->limits[j].max); |
842 | goto nla_put_failure; | ||
843 | if (nl80211_put_iftypes(msg, NL80211_IFACE_LIMIT_TYPES, | 636 | if (nl80211_put_iftypes(msg, NL80211_IFACE_LIMIT_TYPES, |
844 | c->limits[j].types)) | 637 | c->limits[j].types)) |
845 | goto nla_put_failure; | 638 | goto nla_put_failure; |
@@ -848,14 +641,13 @@ static int nl80211_put_iface_combinations(struct wiphy *wiphy, | |||
848 | 641 | ||
849 | nla_nest_end(msg, nl_limits); | 642 | nla_nest_end(msg, nl_limits); |
850 | 643 | ||
851 | if (c->beacon_int_infra_match && | 644 | if (c->beacon_int_infra_match) |
852 | nla_put_flag(msg, NL80211_IFACE_COMB_STA_AP_BI_MATCH)) | 645 | NLA_PUT_FLAG(msg, |
853 | goto nla_put_failure; | 646 | NL80211_IFACE_COMB_STA_AP_BI_MATCH); |
854 | if (nla_put_u32(msg, NL80211_IFACE_COMB_NUM_CHANNELS, | 647 | NLA_PUT_U32(msg, NL80211_IFACE_COMB_NUM_CHANNELS, |
855 | c->num_different_channels) || | 648 | c->num_different_channels); |
856 | nla_put_u32(msg, NL80211_IFACE_COMB_MAXNUM, | 649 | NLA_PUT_U32(msg, NL80211_IFACE_COMB_MAXNUM, |
857 | c->max_interfaces)) | 650 | c->max_interfaces); |
858 | goto nla_put_failure; | ||
859 | 651 | ||
860 | nla_nest_end(msg, nl_combi); | 652 | nla_nest_end(msg, nl_combi); |
861 | } | 653 | } |
@@ -867,7 +659,7 @@ nla_put_failure: | |||
867 | return -ENOBUFS; | 659 | return -ENOBUFS; |
868 | } | 660 | } |
869 | 661 | ||
870 | static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flags, | 662 | static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, |
871 | struct cfg80211_registered_device *dev) | 663 | struct cfg80211_registered_device *dev) |
872 | { | 664 | { |
873 | void *hdr; | 665 | void *hdr; |
@@ -882,90 +674,63 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flag | |||
882 | const struct ieee80211_txrx_stypes *mgmt_stypes = | 674 | const struct ieee80211_txrx_stypes *mgmt_stypes = |
883 | dev->wiphy.mgmt_stypes; | 675 | dev->wiphy.mgmt_stypes; |
884 | 676 | ||
885 | hdr = nl80211hdr_put(msg, portid, seq, flags, NL80211_CMD_NEW_WIPHY); | 677 | hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_WIPHY); |
886 | if (!hdr) | 678 | if (!hdr) |
887 | return -1; | 679 | return -1; |
888 | 680 | ||
889 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, dev->wiphy_idx) || | 681 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, dev->wiphy_idx); |
890 | nla_put_string(msg, NL80211_ATTR_WIPHY_NAME, wiphy_name(&dev->wiphy)) || | 682 | NLA_PUT_STRING(msg, NL80211_ATTR_WIPHY_NAME, wiphy_name(&dev->wiphy)); |
891 | nla_put_u32(msg, NL80211_ATTR_GENERATION, | 683 | |
892 | cfg80211_rdev_list_generation) || | 684 | NLA_PUT_U32(msg, NL80211_ATTR_GENERATION, |
893 | nla_put_u8(msg, NL80211_ATTR_WIPHY_RETRY_SHORT, | 685 | cfg80211_rdev_list_generation); |
894 | dev->wiphy.retry_short) || | 686 | |
895 | nla_put_u8(msg, NL80211_ATTR_WIPHY_RETRY_LONG, | 687 | NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_RETRY_SHORT, |
896 | dev->wiphy.retry_long) || | 688 | dev->wiphy.retry_short); |
897 | nla_put_u32(msg, NL80211_ATTR_WIPHY_FRAG_THRESHOLD, | 689 | NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_RETRY_LONG, |
898 | dev->wiphy.frag_threshold) || | 690 | dev->wiphy.retry_long); |
899 | nla_put_u32(msg, NL80211_ATTR_WIPHY_RTS_THRESHOLD, | 691 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FRAG_THRESHOLD, |
900 | dev->wiphy.rts_threshold) || | 692 | dev->wiphy.frag_threshold); |
901 | nla_put_u8(msg, NL80211_ATTR_WIPHY_COVERAGE_CLASS, | 693 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_RTS_THRESHOLD, |
902 | dev->wiphy.coverage_class) || | 694 | dev->wiphy.rts_threshold); |
903 | nla_put_u8(msg, NL80211_ATTR_MAX_NUM_SCAN_SSIDS, | 695 | NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_COVERAGE_CLASS, |
904 | dev->wiphy.max_scan_ssids) || | 696 | dev->wiphy.coverage_class); |
905 | nla_put_u8(msg, NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS, | 697 | NLA_PUT_U8(msg, NL80211_ATTR_MAX_NUM_SCAN_SSIDS, |
906 | dev->wiphy.max_sched_scan_ssids) || | 698 | dev->wiphy.max_scan_ssids); |
907 | nla_put_u16(msg, NL80211_ATTR_MAX_SCAN_IE_LEN, | 699 | NLA_PUT_U8(msg, NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS, |
908 | dev->wiphy.max_scan_ie_len) || | 700 | dev->wiphy.max_sched_scan_ssids); |
909 | nla_put_u16(msg, NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN, | 701 | NLA_PUT_U16(msg, NL80211_ATTR_MAX_SCAN_IE_LEN, |
910 | dev->wiphy.max_sched_scan_ie_len) || | 702 | dev->wiphy.max_scan_ie_len); |
911 | nla_put_u8(msg, NL80211_ATTR_MAX_MATCH_SETS, | 703 | NLA_PUT_U16(msg, NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN, |
912 | dev->wiphy.max_match_sets)) | 704 | dev->wiphy.max_sched_scan_ie_len); |
913 | goto nla_put_failure; | 705 | |
914 | 706 | if (dev->wiphy.flags & WIPHY_FLAG_IBSS_RSN) | |
915 | if ((dev->wiphy.flags & WIPHY_FLAG_IBSS_RSN) && | 707 | NLA_PUT_FLAG(msg, NL80211_ATTR_SUPPORT_IBSS_RSN); |
916 | nla_put_flag(msg, NL80211_ATTR_SUPPORT_IBSS_RSN)) | 708 | if (dev->wiphy.flags & WIPHY_FLAG_MESH_AUTH) |
917 | goto nla_put_failure; | 709 | NLA_PUT_FLAG(msg, NL80211_ATTR_SUPPORT_MESH_AUTH); |
918 | if ((dev->wiphy.flags & WIPHY_FLAG_MESH_AUTH) && | 710 | |
919 | nla_put_flag(msg, NL80211_ATTR_SUPPORT_MESH_AUTH)) | 711 | NLA_PUT(msg, NL80211_ATTR_CIPHER_SUITES, |
920 | goto nla_put_failure; | 712 | sizeof(u32) * dev->wiphy.n_cipher_suites, |
921 | if ((dev->wiphy.flags & WIPHY_FLAG_AP_UAPSD) && | 713 | dev->wiphy.cipher_suites); |
922 | nla_put_flag(msg, NL80211_ATTR_SUPPORT_AP_UAPSD)) | 714 | |
923 | goto nla_put_failure; | 715 | NLA_PUT_U8(msg, NL80211_ATTR_MAX_NUM_PMKIDS, |
924 | if ((dev->wiphy.flags & WIPHY_FLAG_SUPPORTS_FW_ROAM) && | 716 | dev->wiphy.max_num_pmkids); |
925 | nla_put_flag(msg, NL80211_ATTR_ROAM_SUPPORT)) | 717 | |
926 | goto nla_put_failure; | 718 | if (dev->wiphy.flags & WIPHY_FLAG_CONTROL_PORT_PROTOCOL) |
927 | if ((dev->wiphy.flags & WIPHY_FLAG_SUPPORTS_TDLS) && | 719 | NLA_PUT_FLAG(msg, NL80211_ATTR_CONTROL_PORT_ETHERTYPE); |
928 | nla_put_flag(msg, NL80211_ATTR_TDLS_SUPPORT)) | 720 | |
929 | goto nla_put_failure; | 721 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX, |
930 | if ((dev->wiphy.flags & WIPHY_FLAG_TDLS_EXTERNAL_SETUP) && | 722 | dev->wiphy.available_antennas_tx); |
931 | nla_put_flag(msg, NL80211_ATTR_TDLS_EXTERNAL_SETUP)) | 723 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX, |
932 | goto nla_put_failure; | 724 | dev->wiphy.available_antennas_rx); |
933 | |||
934 | if (nla_put(msg, NL80211_ATTR_CIPHER_SUITES, | ||
935 | sizeof(u32) * dev->wiphy.n_cipher_suites, | ||
936 | dev->wiphy.cipher_suites)) | ||
937 | goto nla_put_failure; | ||
938 | |||
939 | if (nla_put_u8(msg, NL80211_ATTR_MAX_NUM_PMKIDS, | ||
940 | dev->wiphy.max_num_pmkids)) | ||
941 | goto nla_put_failure; | ||
942 | |||
943 | if ((dev->wiphy.flags & WIPHY_FLAG_CONTROL_PORT_PROTOCOL) && | ||
944 | nla_put_flag(msg, NL80211_ATTR_CONTROL_PORT_ETHERTYPE)) | ||
945 | goto nla_put_failure; | ||
946 | |||
947 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX, | ||
948 | dev->wiphy.available_antennas_tx) || | ||
949 | nla_put_u32(msg, NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX, | ||
950 | dev->wiphy.available_antennas_rx)) | ||
951 | goto nla_put_failure; | ||
952 | |||
953 | if ((dev->wiphy.flags & WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD) && | ||
954 | nla_put_u32(msg, NL80211_ATTR_PROBE_RESP_OFFLOAD, | ||
955 | dev->wiphy.probe_resp_offload)) | ||
956 | goto nla_put_failure; | ||
957 | 725 | ||
958 | if ((dev->wiphy.available_antennas_tx || | 726 | if ((dev->wiphy.available_antennas_tx || |
959 | dev->wiphy.available_antennas_rx) && dev->ops->get_antenna) { | 727 | dev->wiphy.available_antennas_rx) && dev->ops->get_antenna) { |
960 | u32 tx_ant = 0, rx_ant = 0; | 728 | u32 tx_ant = 0, rx_ant = 0; |
961 | int res; | 729 | int res; |
962 | res = rdev_get_antenna(dev, &tx_ant, &rx_ant); | 730 | res = dev->ops->get_antenna(&dev->wiphy, &tx_ant, &rx_ant); |
963 | if (!res) { | 731 | if (!res) { |
964 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY_ANTENNA_TX, | 732 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_TX, tx_ant); |
965 | tx_ant) || | 733 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_RX, rx_ant); |
966 | nla_put_u32(msg, NL80211_ATTR_WIPHY_ANTENNA_RX, | ||
967 | rx_ant)) | ||
968 | goto nla_put_failure; | ||
969 | } | 734 | } |
970 | } | 735 | } |
971 | 736 | ||
@@ -986,26 +751,17 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flag | |||
986 | goto nla_put_failure; | 751 | goto nla_put_failure; |
987 | 752 | ||
988 | /* add HT info */ | 753 | /* add HT info */ |
989 | if (dev->wiphy.bands[band]->ht_cap.ht_supported && | 754 | if (dev->wiphy.bands[band]->ht_cap.ht_supported) { |
990 | (nla_put(msg, NL80211_BAND_ATTR_HT_MCS_SET, | 755 | NLA_PUT(msg, NL80211_BAND_ATTR_HT_MCS_SET, |
991 | sizeof(dev->wiphy.bands[band]->ht_cap.mcs), | 756 | sizeof(dev->wiphy.bands[band]->ht_cap.mcs), |
992 | &dev->wiphy.bands[band]->ht_cap.mcs) || | 757 | &dev->wiphy.bands[band]->ht_cap.mcs); |
993 | nla_put_u16(msg, NL80211_BAND_ATTR_HT_CAPA, | 758 | NLA_PUT_U16(msg, NL80211_BAND_ATTR_HT_CAPA, |
994 | dev->wiphy.bands[band]->ht_cap.cap) || | 759 | dev->wiphy.bands[band]->ht_cap.cap); |
995 | nla_put_u8(msg, NL80211_BAND_ATTR_HT_AMPDU_FACTOR, | 760 | NLA_PUT_U8(msg, NL80211_BAND_ATTR_HT_AMPDU_FACTOR, |
996 | dev->wiphy.bands[band]->ht_cap.ampdu_factor) || | 761 | dev->wiphy.bands[band]->ht_cap.ampdu_factor); |
997 | nla_put_u8(msg, NL80211_BAND_ATTR_HT_AMPDU_DENSITY, | 762 | NLA_PUT_U8(msg, NL80211_BAND_ATTR_HT_AMPDU_DENSITY, |
998 | dev->wiphy.bands[band]->ht_cap.ampdu_density))) | 763 | dev->wiphy.bands[band]->ht_cap.ampdu_density); |
999 | goto nla_put_failure; | 764 | } |
1000 | |||
1001 | /* add VHT info */ | ||
1002 | if (dev->wiphy.bands[band]->vht_cap.vht_supported && | ||
1003 | (nla_put(msg, NL80211_BAND_ATTR_VHT_MCS_SET, | ||
1004 | sizeof(dev->wiphy.bands[band]->vht_cap.vht_mcs), | ||
1005 | &dev->wiphy.bands[band]->vht_cap.vht_mcs) || | ||
1006 | nla_put_u32(msg, NL80211_BAND_ATTR_VHT_CAPA, | ||
1007 | dev->wiphy.bands[band]->vht_cap.cap))) | ||
1008 | goto nla_put_failure; | ||
1009 | 765 | ||
1010 | /* add frequencies */ | 766 | /* add frequencies */ |
1011 | nl_freqs = nla_nest_start(msg, NL80211_BAND_ATTR_FREQS); | 767 | nl_freqs = nla_nest_start(msg, NL80211_BAND_ATTR_FREQS); |
@@ -1038,13 +794,11 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flag | |||
1038 | goto nla_put_failure; | 794 | goto nla_put_failure; |
1039 | 795 | ||
1040 | rate = &dev->wiphy.bands[band]->bitrates[i]; | 796 | rate = &dev->wiphy.bands[band]->bitrates[i]; |
1041 | if (nla_put_u32(msg, NL80211_BITRATE_ATTR_RATE, | 797 | NLA_PUT_U32(msg, NL80211_BITRATE_ATTR_RATE, |
1042 | rate->bitrate)) | 798 | rate->bitrate); |
1043 | goto nla_put_failure; | 799 | if (rate->flags & IEEE80211_RATE_SHORT_PREAMBLE) |
1044 | if ((rate->flags & IEEE80211_RATE_SHORT_PREAMBLE) && | 800 | NLA_PUT_FLAG(msg, |
1045 | nla_put_flag(msg, | 801 | NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE); |
1046 | NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE)) | ||
1047 | goto nla_put_failure; | ||
1048 | 802 | ||
1049 | nla_nest_end(msg, nl_rate); | 803 | nla_nest_end(msg, nl_rate); |
1050 | } | 804 | } |
@@ -1064,15 +818,14 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flag | |||
1064 | do { \ | 818 | do { \ |
1065 | if (dev->ops->op) { \ | 819 | if (dev->ops->op) { \ |
1066 | i++; \ | 820 | i++; \ |
1067 | if (nla_put_u32(msg, i, NL80211_CMD_ ## n)) \ | 821 | NLA_PUT_U32(msg, i, NL80211_CMD_ ## n); \ |
1068 | goto nla_put_failure; \ | ||
1069 | } \ | 822 | } \ |
1070 | } while (0) | 823 | } while (0) |
1071 | 824 | ||
1072 | CMD(add_virtual_intf, NEW_INTERFACE); | 825 | CMD(add_virtual_intf, NEW_INTERFACE); |
1073 | CMD(change_virtual_intf, SET_INTERFACE); | 826 | CMD(change_virtual_intf, SET_INTERFACE); |
1074 | CMD(add_key, NEW_KEY); | 827 | CMD(add_key, NEW_KEY); |
1075 | CMD(start_ap, START_AP); | 828 | CMD(add_beacon, NEW_BEACON); |
1076 | CMD(add_station, NEW_STATION); | 829 | CMD(add_station, NEW_STATION); |
1077 | CMD(add_mpath, NEW_MPATH); | 830 | CMD(add_mpath, NEW_MPATH); |
1078 | CMD(update_mesh_config, SET_MESH_CONFIG); | 831 | CMD(update_mesh_config, SET_MESH_CONFIG); |
@@ -1086,68 +839,40 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flag | |||
1086 | CMD(set_pmksa, SET_PMKSA); | 839 | CMD(set_pmksa, SET_PMKSA); |
1087 | CMD(del_pmksa, DEL_PMKSA); | 840 | CMD(del_pmksa, DEL_PMKSA); |
1088 | CMD(flush_pmksa, FLUSH_PMKSA); | 841 | CMD(flush_pmksa, FLUSH_PMKSA); |
1089 | if (dev->wiphy.flags & WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL) | 842 | CMD(remain_on_channel, REMAIN_ON_CHANNEL); |
1090 | CMD(remain_on_channel, REMAIN_ON_CHANNEL); | ||
1091 | CMD(set_bitrate_mask, SET_TX_BITRATE_MASK); | 843 | CMD(set_bitrate_mask, SET_TX_BITRATE_MASK); |
1092 | CMD(mgmt_tx, FRAME); | 844 | CMD(mgmt_tx, FRAME); |
1093 | CMD(mgmt_tx_cancel_wait, FRAME_WAIT_CANCEL); | 845 | CMD(mgmt_tx_cancel_wait, FRAME_WAIT_CANCEL); |
1094 | if (dev->wiphy.flags & WIPHY_FLAG_NETNS_OK) { | 846 | if (dev->wiphy.flags & WIPHY_FLAG_NETNS_OK) { |
1095 | i++; | 847 | i++; |
1096 | if (nla_put_u32(msg, i, NL80211_CMD_SET_WIPHY_NETNS)) | 848 | NLA_PUT_U32(msg, i, NL80211_CMD_SET_WIPHY_NETNS); |
1097 | goto nla_put_failure; | ||
1098 | } | ||
1099 | if (dev->ops->set_monitor_channel || dev->ops->start_ap || | ||
1100 | dev->ops->join_mesh) { | ||
1101 | i++; | ||
1102 | if (nla_put_u32(msg, i, NL80211_CMD_SET_CHANNEL)) | ||
1103 | goto nla_put_failure; | ||
1104 | } | 849 | } |
850 | CMD(set_channel, SET_CHANNEL); | ||
1105 | CMD(set_wds_peer, SET_WDS_PEER); | 851 | CMD(set_wds_peer, SET_WDS_PEER); |
1106 | if (dev->wiphy.flags & WIPHY_FLAG_SUPPORTS_TDLS) { | ||
1107 | CMD(tdls_mgmt, TDLS_MGMT); | ||
1108 | CMD(tdls_oper, TDLS_OPER); | ||
1109 | } | ||
1110 | if (dev->wiphy.flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN) | 852 | if (dev->wiphy.flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN) |
1111 | CMD(sched_scan_start, START_SCHED_SCAN); | 853 | CMD(sched_scan_start, START_SCHED_SCAN); |
1112 | CMD(probe_client, PROBE_CLIENT); | ||
1113 | CMD(set_noack_map, SET_NOACK_MAP); | ||
1114 | if (dev->wiphy.flags & WIPHY_FLAG_REPORTS_OBSS) { | ||
1115 | i++; | ||
1116 | if (nla_put_u32(msg, i, NL80211_CMD_REGISTER_BEACONS)) | ||
1117 | goto nla_put_failure; | ||
1118 | } | ||
1119 | CMD(start_p2p_device, START_P2P_DEVICE); | ||
1120 | CMD(set_mcast_rate, SET_MCAST_RATE); | ||
1121 | |||
1122 | #ifdef CONFIG_NL80211_TESTMODE | ||
1123 | CMD(testmode_cmd, TESTMODE); | ||
1124 | #endif | ||
1125 | 854 | ||
1126 | #undef CMD | 855 | #undef CMD |
1127 | 856 | ||
1128 | if (dev->ops->connect || dev->ops->auth) { | 857 | if (dev->ops->connect || dev->ops->auth) { |
1129 | i++; | 858 | i++; |
1130 | if (nla_put_u32(msg, i, NL80211_CMD_CONNECT)) | 859 | NLA_PUT_U32(msg, i, NL80211_CMD_CONNECT); |
1131 | goto nla_put_failure; | ||
1132 | } | 860 | } |
1133 | 861 | ||
1134 | if (dev->ops->disconnect || dev->ops->deauth) { | 862 | if (dev->ops->disconnect || dev->ops->deauth) { |
1135 | i++; | 863 | i++; |
1136 | if (nla_put_u32(msg, i, NL80211_CMD_DISCONNECT)) | 864 | NLA_PUT_U32(msg, i, NL80211_CMD_DISCONNECT); |
1137 | goto nla_put_failure; | ||
1138 | } | 865 | } |
1139 | 866 | ||
1140 | nla_nest_end(msg, nl_cmds); | 867 | nla_nest_end(msg, nl_cmds); |
1141 | 868 | ||
1142 | if (dev->ops->remain_on_channel && | 869 | if (dev->ops->remain_on_channel) |
1143 | (dev->wiphy.flags & WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL) && | 870 | NLA_PUT_U32(msg, NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION, |
1144 | nla_put_u32(msg, NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION, | 871 | dev->wiphy.max_remain_on_channel_duration); |
1145 | dev->wiphy.max_remain_on_channel_duration)) | ||
1146 | goto nla_put_failure; | ||
1147 | 872 | ||
1148 | if ((dev->wiphy.flags & WIPHY_FLAG_OFFCHAN_TX) && | 873 | /* for now at least assume all drivers have it */ |
1149 | nla_put_flag(msg, NL80211_ATTR_OFFCHANNEL_TX_OK)) | 874 | if (dev->ops->mgmt_tx) |
1150 | goto nla_put_failure; | 875 | NLA_PUT_FLAG(msg, NL80211_ATTR_OFFCHANNEL_TX_OK); |
1151 | 876 | ||
1152 | if (mgmt_stypes) { | 877 | if (mgmt_stypes) { |
1153 | u16 stypes; | 878 | u16 stypes; |
@@ -1165,10 +890,9 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flag | |||
1165 | i = 0; | 890 | i = 0; |
1166 | stypes = mgmt_stypes[ift].tx; | 891 | stypes = mgmt_stypes[ift].tx; |
1167 | while (stypes) { | 892 | while (stypes) { |
1168 | if ((stypes & 1) && | 893 | if (stypes & 1) |
1169 | nla_put_u16(msg, NL80211_ATTR_FRAME_TYPE, | 894 | NLA_PUT_U16(msg, NL80211_ATTR_FRAME_TYPE, |
1170 | (i << 4) | IEEE80211_FTYPE_MGMT)) | 895 | (i << 4) | IEEE80211_FTYPE_MGMT); |
1171 | goto nla_put_failure; | ||
1172 | stypes >>= 1; | 896 | stypes >>= 1; |
1173 | i++; | 897 | i++; |
1174 | } | 898 | } |
@@ -1188,10 +912,9 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flag | |||
1188 | i = 0; | 912 | i = 0; |
1189 | stypes = mgmt_stypes[ift].rx; | 913 | stypes = mgmt_stypes[ift].rx; |
1190 | while (stypes) { | 914 | while (stypes) { |
1191 | if ((stypes & 1) && | 915 | if (stypes & 1) |
1192 | nla_put_u16(msg, NL80211_ATTR_FRAME_TYPE, | 916 | NLA_PUT_U16(msg, NL80211_ATTR_FRAME_TYPE, |
1193 | (i << 4) | IEEE80211_FTYPE_MGMT)) | 917 | (i << 4) | IEEE80211_FTYPE_MGMT); |
1194 | goto nla_put_failure; | ||
1195 | stypes >>= 1; | 918 | stypes >>= 1; |
1196 | i++; | 919 | i++; |
1197 | } | 920 | } |
@@ -1200,7 +923,6 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flag | |||
1200 | nla_nest_end(msg, nl_ifs); | 923 | nla_nest_end(msg, nl_ifs); |
1201 | } | 924 | } |
1202 | 925 | ||
1203 | #ifdef CONFIG_PM | ||
1204 | if (dev->wiphy.wowlan.flags || dev->wiphy.wowlan.n_patterns) { | 926 | if (dev->wiphy.wowlan.flags || dev->wiphy.wowlan.n_patterns) { |
1205 | struct nlattr *nl_wowlan; | 927 | struct nlattr *nl_wowlan; |
1206 | 928 | ||
@@ -1209,23 +931,22 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flag | |||
1209 | if (!nl_wowlan) | 931 | if (!nl_wowlan) |
1210 | goto nla_put_failure; | 932 | goto nla_put_failure; |
1211 | 933 | ||
1212 | if (((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_ANY) && | 934 | if (dev->wiphy.wowlan.flags & WIPHY_WOWLAN_ANY) |
1213 | nla_put_flag(msg, NL80211_WOWLAN_TRIG_ANY)) || | 935 | NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_ANY); |
1214 | ((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_DISCONNECT) && | 936 | if (dev->wiphy.wowlan.flags & WIPHY_WOWLAN_DISCONNECT) |
1215 | nla_put_flag(msg, NL80211_WOWLAN_TRIG_DISCONNECT)) || | 937 | NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_DISCONNECT); |
1216 | ((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_MAGIC_PKT) && | 938 | if (dev->wiphy.wowlan.flags & WIPHY_WOWLAN_MAGIC_PKT) |
1217 | nla_put_flag(msg, NL80211_WOWLAN_TRIG_MAGIC_PKT)) || | 939 | NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_MAGIC_PKT); |
1218 | ((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_SUPPORTS_GTK_REKEY) && | 940 | if (dev->wiphy.wowlan.flags & WIPHY_WOWLAN_SUPPORTS_GTK_REKEY) |
1219 | nla_put_flag(msg, NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED)) || | 941 | NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED); |
1220 | ((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_GTK_REKEY_FAILURE) && | 942 | if (dev->wiphy.wowlan.flags & WIPHY_WOWLAN_GTK_REKEY_FAILURE) |
1221 | nla_put_flag(msg, NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE)) || | 943 | NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE); |
1222 | ((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_EAP_IDENTITY_REQ) && | 944 | if (dev->wiphy.wowlan.flags & WIPHY_WOWLAN_EAP_IDENTITY_REQ) |
1223 | nla_put_flag(msg, NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST)) || | 945 | NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST); |
1224 | ((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_4WAY_HANDSHAKE) && | 946 | if (dev->wiphy.wowlan.flags & WIPHY_WOWLAN_4WAY_HANDSHAKE) |
1225 | nla_put_flag(msg, NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE)) || | 947 | NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE); |
1226 | ((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_RFKILL_RELEASE) && | 948 | if (dev->wiphy.wowlan.flags & WIPHY_WOWLAN_RFKILL_RELEASE) |
1227 | nla_put_flag(msg, NL80211_WOWLAN_TRIG_RFKILL_RELEASE))) | 949 | NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_RFKILL_RELEASE); |
1228 | goto nla_put_failure; | ||
1229 | if (dev->wiphy.wowlan.n_patterns) { | 950 | if (dev->wiphy.wowlan.n_patterns) { |
1230 | struct nl80211_wowlan_pattern_support pat = { | 951 | struct nl80211_wowlan_pattern_support pat = { |
1231 | .max_patterns = dev->wiphy.wowlan.n_patterns, | 952 | .max_patterns = dev->wiphy.wowlan.n_patterns, |
@@ -1234,14 +955,12 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flag | |||
1234 | .max_pattern_len = | 955 | .max_pattern_len = |
1235 | dev->wiphy.wowlan.pattern_max_len, | 956 | dev->wiphy.wowlan.pattern_max_len, |
1236 | }; | 957 | }; |
1237 | if (nla_put(msg, NL80211_WOWLAN_TRIG_PKT_PATTERN, | 958 | NLA_PUT(msg, NL80211_WOWLAN_TRIG_PKT_PATTERN, |
1238 | sizeof(pat), &pat)) | 959 | sizeof(pat), &pat); |
1239 | goto nla_put_failure; | ||
1240 | } | 960 | } |
1241 | 961 | ||
1242 | nla_nest_end(msg, nl_wowlan); | 962 | nla_nest_end(msg, nl_wowlan); |
1243 | } | 963 | } |
1244 | #endif | ||
1245 | 964 | ||
1246 | if (nl80211_put_iftypes(msg, NL80211_ATTR_SOFTWARE_IFTYPES, | 965 | if (nl80211_put_iftypes(msg, NL80211_ATTR_SOFTWARE_IFTYPES, |
1247 | dev->wiphy.software_iftypes)) | 966 | dev->wiphy.software_iftypes)) |
@@ -1250,21 +969,6 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flag | |||
1250 | if (nl80211_put_iface_combinations(&dev->wiphy, msg)) | 969 | if (nl80211_put_iface_combinations(&dev->wiphy, msg)) |
1251 | goto nla_put_failure; | 970 | goto nla_put_failure; |
1252 | 971 | ||
1253 | if ((dev->wiphy.flags & WIPHY_FLAG_HAVE_AP_SME) && | ||
1254 | nla_put_u32(msg, NL80211_ATTR_DEVICE_AP_SME, | ||
1255 | dev->wiphy.ap_sme_capa)) | ||
1256 | goto nla_put_failure; | ||
1257 | |||
1258 | if (nla_put_u32(msg, NL80211_ATTR_FEATURE_FLAGS, | ||
1259 | dev->wiphy.features)) | ||
1260 | goto nla_put_failure; | ||
1261 | |||
1262 | if (dev->wiphy.ht_capa_mod_mask && | ||
1263 | nla_put(msg, NL80211_ATTR_HT_CAPABILITY_MASK, | ||
1264 | sizeof(*dev->wiphy.ht_capa_mod_mask), | ||
1265 | dev->wiphy.ht_capa_mod_mask)) | ||
1266 | goto nla_put_failure; | ||
1267 | |||
1268 | return genlmsg_end(msg, hdr); | 972 | return genlmsg_end(msg, hdr); |
1269 | 973 | ||
1270 | nla_put_failure: | 974 | nla_put_failure: |
@@ -1284,7 +988,7 @@ static int nl80211_dump_wiphy(struct sk_buff *skb, struct netlink_callback *cb) | |||
1284 | continue; | 988 | continue; |
1285 | if (++idx <= start) | 989 | if (++idx <= start) |
1286 | continue; | 990 | continue; |
1287 | if (nl80211_send_wiphy(skb, NETLINK_CB(cb->skb).portid, | 991 | if (nl80211_send_wiphy(skb, NETLINK_CB(cb->skb).pid, |
1288 | cb->nlh->nlmsg_seq, NLM_F_MULTI, | 992 | cb->nlh->nlmsg_seq, NLM_F_MULTI, |
1289 | dev) < 0) { | 993 | dev) < 0) { |
1290 | idx--; | 994 | idx--; |
@@ -1307,7 +1011,7 @@ static int nl80211_get_wiphy(struct sk_buff *skb, struct genl_info *info) | |||
1307 | if (!msg) | 1011 | if (!msg) |
1308 | return -ENOMEM; | 1012 | return -ENOMEM; |
1309 | 1013 | ||
1310 | if (nl80211_send_wiphy(msg, info->snd_portid, info->snd_seq, 0, dev) < 0) { | 1014 | if (nl80211_send_wiphy(msg, info->snd_pid, info->snd_seq, 0, dev) < 0) { |
1311 | nlmsg_free(msg); | 1015 | nlmsg_free(msg); |
1312 | return -ENOBUFS; | 1016 | return -ENOBUFS; |
1313 | } | 1017 | } |
@@ -1326,148 +1030,73 @@ static const struct nla_policy txq_params_policy[NL80211_TXQ_ATTR_MAX + 1] = { | |||
1326 | static int parse_txq_params(struct nlattr *tb[], | 1030 | static int parse_txq_params(struct nlattr *tb[], |
1327 | struct ieee80211_txq_params *txq_params) | 1031 | struct ieee80211_txq_params *txq_params) |
1328 | { | 1032 | { |
1329 | if (!tb[NL80211_TXQ_ATTR_AC] || !tb[NL80211_TXQ_ATTR_TXOP] || | 1033 | if (!tb[NL80211_TXQ_ATTR_QUEUE] || !tb[NL80211_TXQ_ATTR_TXOP] || |
1330 | !tb[NL80211_TXQ_ATTR_CWMIN] || !tb[NL80211_TXQ_ATTR_CWMAX] || | 1034 | !tb[NL80211_TXQ_ATTR_CWMIN] || !tb[NL80211_TXQ_ATTR_CWMAX] || |
1331 | !tb[NL80211_TXQ_ATTR_AIFS]) | 1035 | !tb[NL80211_TXQ_ATTR_AIFS]) |
1332 | return -EINVAL; | 1036 | return -EINVAL; |
1333 | 1037 | ||
1334 | txq_params->ac = nla_get_u8(tb[NL80211_TXQ_ATTR_AC]); | 1038 | txq_params->queue = nla_get_u8(tb[NL80211_TXQ_ATTR_QUEUE]); |
1335 | txq_params->txop = nla_get_u16(tb[NL80211_TXQ_ATTR_TXOP]); | 1039 | txq_params->txop = nla_get_u16(tb[NL80211_TXQ_ATTR_TXOP]); |
1336 | txq_params->cwmin = nla_get_u16(tb[NL80211_TXQ_ATTR_CWMIN]); | 1040 | txq_params->cwmin = nla_get_u16(tb[NL80211_TXQ_ATTR_CWMIN]); |
1337 | txq_params->cwmax = nla_get_u16(tb[NL80211_TXQ_ATTR_CWMAX]); | 1041 | txq_params->cwmax = nla_get_u16(tb[NL80211_TXQ_ATTR_CWMAX]); |
1338 | txq_params->aifs = nla_get_u8(tb[NL80211_TXQ_ATTR_AIFS]); | 1042 | txq_params->aifs = nla_get_u8(tb[NL80211_TXQ_ATTR_AIFS]); |
1339 | 1043 | ||
1340 | if (txq_params->ac >= NL80211_NUM_ACS) | ||
1341 | return -EINVAL; | ||
1342 | |||
1343 | return 0; | 1044 | return 0; |
1344 | } | 1045 | } |
1345 | 1046 | ||
1346 | static bool nl80211_can_set_dev_channel(struct wireless_dev *wdev) | 1047 | static bool nl80211_can_set_dev_channel(struct wireless_dev *wdev) |
1347 | { | 1048 | { |
1348 | /* | 1049 | /* |
1349 | * You can only set the channel explicitly for WDS interfaces, | 1050 | * You can only set the channel explicitly for AP, mesh |
1350 | * all others have their channel managed via their respective | 1051 | * and WDS type interfaces; all others have their channel |
1351 | * "establish a connection" command (connect, join, ...) | 1052 | * managed via their respective "establish a connection" |
1352 | * | 1053 | * command (connect, join, ...) |
1353 | * For AP/GO and mesh mode, the channel can be set with the | ||
1354 | * channel userspace API, but is only stored and passed to the | ||
1355 | * low-level driver when the AP starts or the mesh is joined. | ||
1356 | * This is for backward compatibility, userspace can also give | ||
1357 | * the channel in the start-ap or join-mesh commands instead. | ||
1358 | * | 1054 | * |
1359 | * Monitors are special as they are normally slaved to | 1055 | * Monitors are special as they are normally slaved to |
1360 | * whatever else is going on, so they have their own special | 1056 | * whatever else is going on, so they behave as though |
1361 | * operation to set the monitor channel if possible. | 1057 | * you tried setting the wiphy channel itself. |
1362 | */ | 1058 | */ |
1363 | return !wdev || | 1059 | return !wdev || |
1364 | wdev->iftype == NL80211_IFTYPE_AP || | 1060 | wdev->iftype == NL80211_IFTYPE_AP || |
1061 | wdev->iftype == NL80211_IFTYPE_WDS || | ||
1365 | wdev->iftype == NL80211_IFTYPE_MESH_POINT || | 1062 | wdev->iftype == NL80211_IFTYPE_MESH_POINT || |
1366 | wdev->iftype == NL80211_IFTYPE_MONITOR || | 1063 | wdev->iftype == NL80211_IFTYPE_MONITOR || |
1367 | wdev->iftype == NL80211_IFTYPE_P2P_GO; | 1064 | wdev->iftype == NL80211_IFTYPE_P2P_GO; |
1368 | } | 1065 | } |
1369 | 1066 | ||
1370 | static int nl80211_parse_chandef(struct cfg80211_registered_device *rdev, | ||
1371 | struct genl_info *info, | ||
1372 | struct cfg80211_chan_def *chandef) | ||
1373 | { | ||
1374 | u32 control_freq; | ||
1375 | |||
1376 | if (!info->attrs[NL80211_ATTR_WIPHY_FREQ]) | ||
1377 | return -EINVAL; | ||
1378 | |||
1379 | control_freq = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]); | ||
1380 | |||
1381 | chandef->chan = ieee80211_get_channel(&rdev->wiphy, control_freq); | ||
1382 | chandef->width = NL80211_CHAN_WIDTH_20_NOHT; | ||
1383 | chandef->center_freq1 = control_freq; | ||
1384 | chandef->center_freq2 = 0; | ||
1385 | |||
1386 | /* Primary channel not allowed */ | ||
1387 | if (!chandef->chan || chandef->chan->flags & IEEE80211_CHAN_DISABLED) | ||
1388 | return -EINVAL; | ||
1389 | |||
1390 | if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) { | ||
1391 | enum nl80211_channel_type chantype; | ||
1392 | |||
1393 | chantype = nla_get_u32( | ||
1394 | info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]); | ||
1395 | |||
1396 | switch (chantype) { | ||
1397 | case NL80211_CHAN_NO_HT: | ||
1398 | case NL80211_CHAN_HT20: | ||
1399 | case NL80211_CHAN_HT40PLUS: | ||
1400 | case NL80211_CHAN_HT40MINUS: | ||
1401 | cfg80211_chandef_create(chandef, chandef->chan, | ||
1402 | chantype); | ||
1403 | break; | ||
1404 | default: | ||
1405 | return -EINVAL; | ||
1406 | } | ||
1407 | } else if (info->attrs[NL80211_ATTR_CHANNEL_WIDTH]) { | ||
1408 | chandef->width = | ||
1409 | nla_get_u32(info->attrs[NL80211_ATTR_CHANNEL_WIDTH]); | ||
1410 | if (info->attrs[NL80211_ATTR_CENTER_FREQ1]) | ||
1411 | chandef->center_freq1 = | ||
1412 | nla_get_u32( | ||
1413 | info->attrs[NL80211_ATTR_CENTER_FREQ1]); | ||
1414 | if (info->attrs[NL80211_ATTR_CENTER_FREQ2]) | ||
1415 | chandef->center_freq2 = | ||
1416 | nla_get_u32( | ||
1417 | info->attrs[NL80211_ATTR_CENTER_FREQ2]); | ||
1418 | } | ||
1419 | |||
1420 | if (!cfg80211_chandef_valid(chandef)) | ||
1421 | return -EINVAL; | ||
1422 | |||
1423 | if (!cfg80211_chandef_usable(&rdev->wiphy, chandef, | ||
1424 | IEEE80211_CHAN_DISABLED)) | ||
1425 | return -EINVAL; | ||
1426 | |||
1427 | return 0; | ||
1428 | } | ||
1429 | |||
1430 | static int __nl80211_set_channel(struct cfg80211_registered_device *rdev, | 1067 | static int __nl80211_set_channel(struct cfg80211_registered_device *rdev, |
1431 | struct wireless_dev *wdev, | 1068 | struct wireless_dev *wdev, |
1432 | struct genl_info *info) | 1069 | struct genl_info *info) |
1433 | { | 1070 | { |
1434 | struct cfg80211_chan_def chandef; | 1071 | enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT; |
1072 | u32 freq; | ||
1435 | int result; | 1073 | int result; |
1436 | enum nl80211_iftype iftype = NL80211_IFTYPE_MONITOR; | ||
1437 | 1074 | ||
1438 | if (wdev) | 1075 | if (!info->attrs[NL80211_ATTR_WIPHY_FREQ]) |
1439 | iftype = wdev->iftype; | 1076 | return -EINVAL; |
1440 | 1077 | ||
1441 | if (!nl80211_can_set_dev_channel(wdev)) | 1078 | if (!nl80211_can_set_dev_channel(wdev)) |
1442 | return -EOPNOTSUPP; | 1079 | return -EOPNOTSUPP; |
1443 | 1080 | ||
1444 | result = nl80211_parse_chandef(rdev, info, &chandef); | 1081 | if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) { |
1445 | if (result) | 1082 | channel_type = nla_get_u32(info->attrs[ |
1446 | return result; | 1083 | NL80211_ATTR_WIPHY_CHANNEL_TYPE]); |
1084 | if (channel_type != NL80211_CHAN_NO_HT && | ||
1085 | channel_type != NL80211_CHAN_HT20 && | ||
1086 | channel_type != NL80211_CHAN_HT40PLUS && | ||
1087 | channel_type != NL80211_CHAN_HT40MINUS) | ||
1088 | return -EINVAL; | ||
1089 | } | ||
1090 | |||
1091 | freq = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]); | ||
1447 | 1092 | ||
1448 | mutex_lock(&rdev->devlist_mtx); | 1093 | mutex_lock(&rdev->devlist_mtx); |
1449 | switch (iftype) { | 1094 | if (wdev) { |
1450 | case NL80211_IFTYPE_AP: | 1095 | wdev_lock(wdev); |
1451 | case NL80211_IFTYPE_P2P_GO: | 1096 | result = cfg80211_set_freq(rdev, wdev, freq, channel_type); |
1452 | if (wdev->beacon_interval) { | 1097 | wdev_unlock(wdev); |
1453 | result = -EBUSY; | 1098 | } else { |
1454 | break; | 1099 | result = cfg80211_set_freq(rdev, NULL, freq, channel_type); |
1455 | } | ||
1456 | if (!cfg80211_reg_can_beacon(&rdev->wiphy, &chandef)) { | ||
1457 | result = -EINVAL; | ||
1458 | break; | ||
1459 | } | ||
1460 | wdev->preset_chandef = chandef; | ||
1461 | result = 0; | ||
1462 | break; | ||
1463 | case NL80211_IFTYPE_MESH_POINT: | ||
1464 | result = cfg80211_set_mesh_channel(rdev, wdev, &chandef); | ||
1465 | break; | ||
1466 | case NL80211_IFTYPE_MONITOR: | ||
1467 | result = cfg80211_set_monitor_channel(rdev, &chandef); | ||
1468 | break; | ||
1469 | default: | ||
1470 | result = -EINVAL; | ||
1471 | } | 1100 | } |
1472 | mutex_unlock(&rdev->devlist_mtx); | 1101 | mutex_unlock(&rdev->devlist_mtx); |
1473 | 1102 | ||
@@ -1502,7 +1131,7 @@ static int nl80211_set_wds_peer(struct sk_buff *skb, struct genl_info *info) | |||
1502 | return -EOPNOTSUPP; | 1131 | return -EOPNOTSUPP; |
1503 | 1132 | ||
1504 | bssid = nla_data(info->attrs[NL80211_ATTR_MAC]); | 1133 | bssid = nla_data(info->attrs[NL80211_ATTR_MAC]); |
1505 | return rdev_set_wds_peer(rdev, dev, bssid); | 1134 | return rdev->ops->set_wds_peer(wdev->wiphy, dev, bssid); |
1506 | } | 1135 | } |
1507 | 1136 | ||
1508 | 1137 | ||
@@ -1541,8 +1170,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) | |||
1541 | } | 1170 | } |
1542 | 1171 | ||
1543 | if (!netdev) { | 1172 | if (!netdev) { |
1544 | rdev = __cfg80211_rdev_from_attrs(genl_info_net(info), | 1173 | rdev = __cfg80211_rdev_from_info(info); |
1545 | info->attrs); | ||
1546 | if (IS_ERR(rdev)) { | 1174 | if (IS_ERR(rdev)) { |
1547 | mutex_unlock(&cfg80211_mutex); | 1175 | mutex_unlock(&cfg80211_mutex); |
1548 | return PTR_ERR(rdev); | 1176 | return PTR_ERR(rdev); |
@@ -1552,8 +1180,11 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) | |||
1552 | result = 0; | 1180 | result = 0; |
1553 | 1181 | ||
1554 | mutex_lock(&rdev->mtx); | 1182 | mutex_lock(&rdev->mtx); |
1555 | } else | 1183 | } else if (netif_running(netdev) && |
1184 | nl80211_can_set_dev_channel(netdev->ieee80211_ptr)) | ||
1556 | wdev = netdev->ieee80211_ptr; | 1185 | wdev = netdev->ieee80211_ptr; |
1186 | else | ||
1187 | wdev = NULL; | ||
1557 | 1188 | ||
1558 | /* | 1189 | /* |
1559 | * end workaround code, by now the rdev is available | 1190 | * end workaround code, by now the rdev is available |
@@ -1578,22 +1209,6 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) | |||
1578 | goto bad_res; | 1209 | goto bad_res; |
1579 | } | 1210 | } |
1580 | 1211 | ||
1581 | if (!netdev) { | ||
1582 | result = -EINVAL; | ||
1583 | goto bad_res; | ||
1584 | } | ||
1585 | |||
1586 | if (netdev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && | ||
1587 | netdev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) { | ||
1588 | result = -EINVAL; | ||
1589 | goto bad_res; | ||
1590 | } | ||
1591 | |||
1592 | if (!netif_running(netdev)) { | ||
1593 | result = -ENETDOWN; | ||
1594 | goto bad_res; | ||
1595 | } | ||
1596 | |||
1597 | nla_for_each_nested(nl_txq_params, | 1212 | nla_for_each_nested(nl_txq_params, |
1598 | info->attrs[NL80211_ATTR_WIPHY_TXQ_PARAMS], | 1213 | info->attrs[NL80211_ATTR_WIPHY_TXQ_PARAMS], |
1599 | rem_txq_params) { | 1214 | rem_txq_params) { |
@@ -1605,29 +1220,23 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) | |||
1605 | if (result) | 1220 | if (result) |
1606 | goto bad_res; | 1221 | goto bad_res; |
1607 | 1222 | ||
1608 | result = rdev_set_txq_params(rdev, netdev, | 1223 | result = rdev->ops->set_txq_params(&rdev->wiphy, |
1609 | &txq_params); | 1224 | &txq_params); |
1610 | if (result) | 1225 | if (result) |
1611 | goto bad_res; | 1226 | goto bad_res; |
1612 | } | 1227 | } |
1613 | } | 1228 | } |
1614 | 1229 | ||
1615 | if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) { | 1230 | if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) { |
1616 | result = __nl80211_set_channel(rdev, | 1231 | result = __nl80211_set_channel(rdev, wdev, info); |
1617 | nl80211_can_set_dev_channel(wdev) ? wdev : NULL, | ||
1618 | info); | ||
1619 | if (result) | 1232 | if (result) |
1620 | goto bad_res; | 1233 | goto bad_res; |
1621 | } | 1234 | } |
1622 | 1235 | ||
1623 | if (info->attrs[NL80211_ATTR_WIPHY_TX_POWER_SETTING]) { | 1236 | if (info->attrs[NL80211_ATTR_WIPHY_TX_POWER_SETTING]) { |
1624 | struct wireless_dev *txp_wdev = wdev; | ||
1625 | enum nl80211_tx_power_setting type; | 1237 | enum nl80211_tx_power_setting type; |
1626 | int idx, mbm = 0; | 1238 | int idx, mbm = 0; |
1627 | 1239 | ||
1628 | if (!(rdev->wiphy.features & NL80211_FEATURE_VIF_TXPOWER)) | ||
1629 | txp_wdev = NULL; | ||
1630 | |||
1631 | if (!rdev->ops->set_tx_power) { | 1240 | if (!rdev->ops->set_tx_power) { |
1632 | result = -EOPNOTSUPP; | 1241 | result = -EOPNOTSUPP; |
1633 | goto bad_res; | 1242 | goto bad_res; |
@@ -1647,7 +1256,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) | |||
1647 | mbm = nla_get_u32(info->attrs[idx]); | 1256 | mbm = nla_get_u32(info->attrs[idx]); |
1648 | } | 1257 | } |
1649 | 1258 | ||
1650 | result = rdev_set_tx_power(rdev, txp_wdev, type, mbm); | 1259 | result = rdev->ops->set_tx_power(&rdev->wiphy, type, mbm); |
1651 | if (result) | 1260 | if (result) |
1652 | goto bad_res; | 1261 | goto bad_res; |
1653 | } | 1262 | } |
@@ -1676,7 +1285,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) | |||
1676 | tx_ant = tx_ant & rdev->wiphy.available_antennas_tx; | 1285 | tx_ant = tx_ant & rdev->wiphy.available_antennas_tx; |
1677 | rx_ant = rx_ant & rdev->wiphy.available_antennas_rx; | 1286 | rx_ant = rx_ant & rdev->wiphy.available_antennas_rx; |
1678 | 1287 | ||
1679 | result = rdev_set_antenna(rdev, tx_ant, rx_ant); | 1288 | result = rdev->ops->set_antenna(&rdev->wiphy, tx_ant, rx_ant); |
1680 | if (result) | 1289 | if (result) |
1681 | goto bad_res; | 1290 | goto bad_res; |
1682 | } | 1291 | } |
@@ -1761,7 +1370,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) | |||
1761 | if (changed & WIPHY_PARAM_COVERAGE_CLASS) | 1370 | if (changed & WIPHY_PARAM_COVERAGE_CLASS) |
1762 | rdev->wiphy.coverage_class = coverage_class; | 1371 | rdev->wiphy.coverage_class = coverage_class; |
1763 | 1372 | ||
1764 | result = rdev_set_wiphy_params(rdev, changed); | 1373 | result = rdev->ops->set_wiphy_params(&rdev->wiphy, changed); |
1765 | if (result) { | 1374 | if (result) { |
1766 | rdev->wiphy.retry_short = old_retry_short; | 1375 | rdev->wiphy.retry_short = old_retry_short; |
1767 | rdev->wiphy.retry_long = old_retry_long; | 1376 | rdev->wiphy.retry_long = old_retry_long; |
@@ -1778,81 +1387,25 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) | |||
1778 | return result; | 1387 | return result; |
1779 | } | 1388 | } |
1780 | 1389 | ||
1781 | static inline u64 wdev_id(struct wireless_dev *wdev) | ||
1782 | { | ||
1783 | return (u64)wdev->identifier | | ||
1784 | ((u64)wiphy_to_dev(wdev->wiphy)->wiphy_idx << 32); | ||
1785 | } | ||
1786 | |||
1787 | static int nl80211_send_chandef(struct sk_buff *msg, | ||
1788 | struct cfg80211_chan_def *chandef) | ||
1789 | { | ||
1790 | WARN_ON(!cfg80211_chandef_valid(chandef)); | ||
1791 | |||
1792 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, | ||
1793 | chandef->chan->center_freq)) | ||
1794 | return -ENOBUFS; | ||
1795 | switch (chandef->width) { | ||
1796 | case NL80211_CHAN_WIDTH_20_NOHT: | ||
1797 | case NL80211_CHAN_WIDTH_20: | ||
1798 | case NL80211_CHAN_WIDTH_40: | ||
1799 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, | ||
1800 | cfg80211_get_chandef_type(chandef))) | ||
1801 | return -ENOBUFS; | ||
1802 | break; | ||
1803 | default: | ||
1804 | break; | ||
1805 | } | ||
1806 | if (nla_put_u32(msg, NL80211_ATTR_CHANNEL_WIDTH, chandef->width)) | ||
1807 | return -ENOBUFS; | ||
1808 | if (nla_put_u32(msg, NL80211_ATTR_CENTER_FREQ1, chandef->center_freq1)) | ||
1809 | return -ENOBUFS; | ||
1810 | if (chandef->center_freq2 && | ||
1811 | nla_put_u32(msg, NL80211_ATTR_CENTER_FREQ2, chandef->center_freq2)) | ||
1812 | return -ENOBUFS; | ||
1813 | return 0; | ||
1814 | } | ||
1815 | 1390 | ||
1816 | static int nl80211_send_iface(struct sk_buff *msg, u32 portid, u32 seq, int flags, | 1391 | static int nl80211_send_iface(struct sk_buff *msg, u32 pid, u32 seq, int flags, |
1817 | struct cfg80211_registered_device *rdev, | 1392 | struct cfg80211_registered_device *rdev, |
1818 | struct wireless_dev *wdev) | 1393 | struct net_device *dev) |
1819 | { | 1394 | { |
1820 | struct net_device *dev = wdev->netdev; | ||
1821 | void *hdr; | 1395 | void *hdr; |
1822 | 1396 | ||
1823 | hdr = nl80211hdr_put(msg, portid, seq, flags, NL80211_CMD_NEW_INTERFACE); | 1397 | hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_INTERFACE); |
1824 | if (!hdr) | 1398 | if (!hdr) |
1825 | return -1; | 1399 | return -1; |
1826 | 1400 | ||
1827 | if (dev && | 1401 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); |
1828 | (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || | 1402 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); |
1829 | nla_put_string(msg, NL80211_ATTR_IFNAME, dev->name))) | 1403 | NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, dev->name); |
1830 | goto nla_put_failure; | 1404 | NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, dev->ieee80211_ptr->iftype); |
1831 | |||
1832 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | ||
1833 | nla_put_u32(msg, NL80211_ATTR_IFTYPE, wdev->iftype) || | ||
1834 | nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)) || | ||
1835 | nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, wdev_address(wdev)) || | ||
1836 | nla_put_u32(msg, NL80211_ATTR_GENERATION, | ||
1837 | rdev->devlist_generation ^ | ||
1838 | (cfg80211_rdev_list_generation << 2))) | ||
1839 | goto nla_put_failure; | ||
1840 | |||
1841 | if (rdev->ops->get_channel) { | ||
1842 | int ret; | ||
1843 | struct cfg80211_chan_def chandef; | ||
1844 | |||
1845 | ret = rdev_get_channel(rdev, wdev, &chandef); | ||
1846 | if (ret == 0) { | ||
1847 | if (nl80211_send_chandef(msg, &chandef)) | ||
1848 | goto nla_put_failure; | ||
1849 | } | ||
1850 | } | ||
1851 | 1405 | ||
1852 | if (wdev->ssid_len) { | 1406 | NLA_PUT_U32(msg, NL80211_ATTR_GENERATION, |
1853 | if (nla_put(msg, NL80211_ATTR_SSID, wdev->ssid_len, wdev->ssid)) | 1407 | rdev->devlist_generation ^ |
1854 | goto nla_put_failure; | 1408 | (cfg80211_rdev_list_generation << 2)); |
1855 | } | ||
1856 | 1409 | ||
1857 | return genlmsg_end(msg, hdr); | 1410 | return genlmsg_end(msg, hdr); |
1858 | 1411 | ||
@@ -1881,14 +1434,14 @@ static int nl80211_dump_interface(struct sk_buff *skb, struct netlink_callback * | |||
1881 | if_idx = 0; | 1434 | if_idx = 0; |
1882 | 1435 | ||
1883 | mutex_lock(&rdev->devlist_mtx); | 1436 | mutex_lock(&rdev->devlist_mtx); |
1884 | list_for_each_entry(wdev, &rdev->wdev_list, list) { | 1437 | list_for_each_entry(wdev, &rdev->netdev_list, list) { |
1885 | if (if_idx < if_start) { | 1438 | if (if_idx < if_start) { |
1886 | if_idx++; | 1439 | if_idx++; |
1887 | continue; | 1440 | continue; |
1888 | } | 1441 | } |
1889 | if (nl80211_send_iface(skb, NETLINK_CB(cb->skb).portid, | 1442 | if (nl80211_send_iface(skb, NETLINK_CB(cb->skb).pid, |
1890 | cb->nlh->nlmsg_seq, NLM_F_MULTI, | 1443 | cb->nlh->nlmsg_seq, NLM_F_MULTI, |
1891 | rdev, wdev) < 0) { | 1444 | rdev, wdev->netdev) < 0) { |
1892 | mutex_unlock(&rdev->devlist_mtx); | 1445 | mutex_unlock(&rdev->devlist_mtx); |
1893 | goto out; | 1446 | goto out; |
1894 | } | 1447 | } |
@@ -1911,14 +1464,14 @@ static int nl80211_get_interface(struct sk_buff *skb, struct genl_info *info) | |||
1911 | { | 1464 | { |
1912 | struct sk_buff *msg; | 1465 | struct sk_buff *msg; |
1913 | struct cfg80211_registered_device *dev = info->user_ptr[0]; | 1466 | struct cfg80211_registered_device *dev = info->user_ptr[0]; |
1914 | struct wireless_dev *wdev = info->user_ptr[1]; | 1467 | struct net_device *netdev = info->user_ptr[1]; |
1915 | 1468 | ||
1916 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | 1469 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); |
1917 | if (!msg) | 1470 | if (!msg) |
1918 | return -ENOMEM; | 1471 | return -ENOMEM; |
1919 | 1472 | ||
1920 | if (nl80211_send_iface(msg, info->snd_portid, info->snd_seq, 0, | 1473 | if (nl80211_send_iface(msg, info->snd_pid, info->snd_seq, 0, |
1921 | dev, wdev) < 0) { | 1474 | dev, netdev) < 0) { |
1922 | nlmsg_free(msg); | 1475 | nlmsg_free(msg); |
1923 | return -ENOBUFS; | 1476 | return -ENOBUFS; |
1924 | } | 1477 | } |
@@ -2058,8 +1611,7 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info) | |||
2058 | { | 1611 | { |
2059 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | 1612 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; |
2060 | struct vif_params params; | 1613 | struct vif_params params; |
2061 | struct wireless_dev *wdev; | 1614 | struct net_device *dev; |
2062 | struct sk_buff *msg; | ||
2063 | int err; | 1615 | int err; |
2064 | enum nl80211_iftype type = NL80211_IFTYPE_UNSPECIFIED; | 1616 | enum nl80211_iftype type = NL80211_IFTYPE_UNSPECIFIED; |
2065 | u32 flags; | 1617 | u32 flags; |
@@ -2086,25 +1638,19 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info) | |||
2086 | return err; | 1638 | return err; |
2087 | } | 1639 | } |
2088 | 1640 | ||
2089 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | ||
2090 | if (!msg) | ||
2091 | return -ENOMEM; | ||
2092 | |||
2093 | err = parse_monitor_flags(type == NL80211_IFTYPE_MONITOR ? | 1641 | err = parse_monitor_flags(type == NL80211_IFTYPE_MONITOR ? |
2094 | info->attrs[NL80211_ATTR_MNTR_FLAGS] : NULL, | 1642 | info->attrs[NL80211_ATTR_MNTR_FLAGS] : NULL, |
2095 | &flags); | 1643 | &flags); |
2096 | wdev = rdev_add_virtual_intf(rdev, | 1644 | dev = rdev->ops->add_virtual_intf(&rdev->wiphy, |
2097 | nla_data(info->attrs[NL80211_ATTR_IFNAME]), | 1645 | nla_data(info->attrs[NL80211_ATTR_IFNAME]), |
2098 | type, err ? NULL : &flags, ¶ms); | 1646 | type, err ? NULL : &flags, ¶ms); |
2099 | if (IS_ERR(wdev)) { | 1647 | if (IS_ERR(dev)) |
2100 | nlmsg_free(msg); | 1648 | return PTR_ERR(dev); |
2101 | return PTR_ERR(wdev); | 1649 | |
2102 | } | 1650 | if (type == NL80211_IFTYPE_MESH_POINT && |
1651 | info->attrs[NL80211_ATTR_MESH_ID]) { | ||
1652 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
2103 | 1653 | ||
2104 | switch (type) { | ||
2105 | case NL80211_IFTYPE_MESH_POINT: | ||
2106 | if (!info->attrs[NL80211_ATTR_MESH_ID]) | ||
2107 | break; | ||
2108 | wdev_lock(wdev); | 1654 | wdev_lock(wdev); |
2109 | BUILD_BUG_ON(IEEE80211_MAX_SSID_LEN != | 1655 | BUILD_BUG_ON(IEEE80211_MAX_SSID_LEN != |
2110 | IEEE80211_MAX_MESH_ID_LEN); | 1656 | IEEE80211_MAX_MESH_ID_LEN); |
@@ -2113,73 +1659,20 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info) | |||
2113 | memcpy(wdev->ssid, nla_data(info->attrs[NL80211_ATTR_MESH_ID]), | 1659 | memcpy(wdev->ssid, nla_data(info->attrs[NL80211_ATTR_MESH_ID]), |
2114 | wdev->mesh_id_up_len); | 1660 | wdev->mesh_id_up_len); |
2115 | wdev_unlock(wdev); | 1661 | wdev_unlock(wdev); |
2116 | break; | ||
2117 | case NL80211_IFTYPE_P2P_DEVICE: | ||
2118 | /* | ||
2119 | * P2P Device doesn't have a netdev, so doesn't go | ||
2120 | * through the netdev notifier and must be added here | ||
2121 | */ | ||
2122 | mutex_init(&wdev->mtx); | ||
2123 | INIT_LIST_HEAD(&wdev->event_list); | ||
2124 | spin_lock_init(&wdev->event_lock); | ||
2125 | INIT_LIST_HEAD(&wdev->mgmt_registrations); | ||
2126 | spin_lock_init(&wdev->mgmt_registrations_lock); | ||
2127 | |||
2128 | mutex_lock(&rdev->devlist_mtx); | ||
2129 | wdev->identifier = ++rdev->wdev_id; | ||
2130 | list_add_rcu(&wdev->list, &rdev->wdev_list); | ||
2131 | rdev->devlist_generation++; | ||
2132 | mutex_unlock(&rdev->devlist_mtx); | ||
2133 | break; | ||
2134 | default: | ||
2135 | break; | ||
2136 | } | ||
2137 | |||
2138 | if (nl80211_send_iface(msg, info->snd_portid, info->snd_seq, 0, | ||
2139 | rdev, wdev) < 0) { | ||
2140 | nlmsg_free(msg); | ||
2141 | return -ENOBUFS; | ||
2142 | } | 1662 | } |
2143 | 1663 | ||
2144 | return genlmsg_reply(msg, info); | 1664 | return 0; |
2145 | } | 1665 | } |
2146 | 1666 | ||
2147 | static int nl80211_del_interface(struct sk_buff *skb, struct genl_info *info) | 1667 | static int nl80211_del_interface(struct sk_buff *skb, struct genl_info *info) |
2148 | { | 1668 | { |
2149 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | 1669 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; |
2150 | struct wireless_dev *wdev = info->user_ptr[1]; | ||
2151 | |||
2152 | if (!rdev->ops->del_virtual_intf) | ||
2153 | return -EOPNOTSUPP; | ||
2154 | |||
2155 | /* | ||
2156 | * If we remove a wireless device without a netdev then clear | ||
2157 | * user_ptr[1] so that nl80211_post_doit won't dereference it | ||
2158 | * to check if it needs to do dev_put(). Otherwise it crashes | ||
2159 | * since the wdev has been freed, unlike with a netdev where | ||
2160 | * we need the dev_put() for the netdev to really be freed. | ||
2161 | */ | ||
2162 | if (!wdev->netdev) | ||
2163 | info->user_ptr[1] = NULL; | ||
2164 | |||
2165 | return rdev_del_virtual_intf(rdev, wdev); | ||
2166 | } | ||
2167 | |||
2168 | static int nl80211_set_noack_map(struct sk_buff *skb, struct genl_info *info) | ||
2169 | { | ||
2170 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | ||
2171 | struct net_device *dev = info->user_ptr[1]; | 1670 | struct net_device *dev = info->user_ptr[1]; |
2172 | u16 noack_map; | ||
2173 | |||
2174 | if (!info->attrs[NL80211_ATTR_NOACK_MAP]) | ||
2175 | return -EINVAL; | ||
2176 | 1671 | ||
2177 | if (!rdev->ops->set_noack_map) | 1672 | if (!rdev->ops->del_virtual_intf) |
2178 | return -EOPNOTSUPP; | 1673 | return -EOPNOTSUPP; |
2179 | 1674 | ||
2180 | noack_map = nla_get_u16(info->attrs[NL80211_ATTR_NOACK_MAP]); | 1675 | return rdev->ops->del_virtual_intf(&rdev->wiphy, dev); |
2181 | |||
2182 | return rdev_set_noack_map(rdev, dev, noack_map); | ||
2183 | } | 1676 | } |
2184 | 1677 | ||
2185 | struct get_key_cookie { | 1678 | struct get_key_cookie { |
@@ -2193,34 +1686,35 @@ static void get_key_callback(void *c, struct key_params *params) | |||
2193 | struct nlattr *key; | 1686 | struct nlattr *key; |
2194 | struct get_key_cookie *cookie = c; | 1687 | struct get_key_cookie *cookie = c; |
2195 | 1688 | ||
2196 | if ((params->key && | 1689 | if (params->key) |
2197 | nla_put(cookie->msg, NL80211_ATTR_KEY_DATA, | 1690 | NLA_PUT(cookie->msg, NL80211_ATTR_KEY_DATA, |
2198 | params->key_len, params->key)) || | 1691 | params->key_len, params->key); |
2199 | (params->seq && | 1692 | |
2200 | nla_put(cookie->msg, NL80211_ATTR_KEY_SEQ, | 1693 | if (params->seq) |
2201 | params->seq_len, params->seq)) || | 1694 | NLA_PUT(cookie->msg, NL80211_ATTR_KEY_SEQ, |
2202 | (params->cipher && | 1695 | params->seq_len, params->seq); |
2203 | nla_put_u32(cookie->msg, NL80211_ATTR_KEY_CIPHER, | 1696 | |
2204 | params->cipher))) | 1697 | if (params->cipher) |
2205 | goto nla_put_failure; | 1698 | NLA_PUT_U32(cookie->msg, NL80211_ATTR_KEY_CIPHER, |
1699 | params->cipher); | ||
2206 | 1700 | ||
2207 | key = nla_nest_start(cookie->msg, NL80211_ATTR_KEY); | 1701 | key = nla_nest_start(cookie->msg, NL80211_ATTR_KEY); |
2208 | if (!key) | 1702 | if (!key) |
2209 | goto nla_put_failure; | 1703 | goto nla_put_failure; |
2210 | 1704 | ||
2211 | if ((params->key && | 1705 | if (params->key) |
2212 | nla_put(cookie->msg, NL80211_KEY_DATA, | 1706 | NLA_PUT(cookie->msg, NL80211_KEY_DATA, |
2213 | params->key_len, params->key)) || | 1707 | params->key_len, params->key); |
2214 | (params->seq && | ||
2215 | nla_put(cookie->msg, NL80211_KEY_SEQ, | ||
2216 | params->seq_len, params->seq)) || | ||
2217 | (params->cipher && | ||
2218 | nla_put_u32(cookie->msg, NL80211_KEY_CIPHER, | ||
2219 | params->cipher))) | ||
2220 | goto nla_put_failure; | ||
2221 | 1708 | ||
2222 | if (nla_put_u8(cookie->msg, NL80211_ATTR_KEY_IDX, cookie->idx)) | 1709 | if (params->seq) |
2223 | goto nla_put_failure; | 1710 | NLA_PUT(cookie->msg, NL80211_KEY_SEQ, |
1711 | params->seq_len, params->seq); | ||
1712 | |||
1713 | if (params->cipher) | ||
1714 | NLA_PUT_U32(cookie->msg, NL80211_KEY_CIPHER, | ||
1715 | params->cipher); | ||
1716 | |||
1717 | NLA_PUT_U8(cookie->msg, NL80211_ATTR_KEY_IDX, cookie->idx); | ||
2224 | 1718 | ||
2225 | nla_nest_end(cookie->msg, key); | 1719 | nla_nest_end(cookie->msg, key); |
2226 | 1720 | ||
@@ -2270,7 +1764,7 @@ static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info) | |||
2270 | if (!msg) | 1764 | if (!msg) |
2271 | return -ENOMEM; | 1765 | return -ENOMEM; |
2272 | 1766 | ||
2273 | hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, | 1767 | hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, |
2274 | NL80211_CMD_NEW_KEY); | 1768 | NL80211_CMD_NEW_KEY); |
2275 | if (IS_ERR(hdr)) | 1769 | if (IS_ERR(hdr)) |
2276 | return PTR_ERR(hdr); | 1770 | return PTR_ERR(hdr); |
@@ -2278,19 +1772,17 @@ static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info) | |||
2278 | cookie.msg = msg; | 1772 | cookie.msg = msg; |
2279 | cookie.idx = key_idx; | 1773 | cookie.idx = key_idx; |
2280 | 1774 | ||
2281 | if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || | 1775 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); |
2282 | nla_put_u8(msg, NL80211_ATTR_KEY_IDX, key_idx)) | 1776 | NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, key_idx); |
2283 | goto nla_put_failure; | 1777 | if (mac_addr) |
2284 | if (mac_addr && | 1778 | NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr); |
2285 | nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr)) | ||
2286 | goto nla_put_failure; | ||
2287 | 1779 | ||
2288 | if (pairwise && mac_addr && | 1780 | if (pairwise && mac_addr && |
2289 | !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN)) | 1781 | !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN)) |
2290 | return -ENOENT; | 1782 | return -ENOENT; |
2291 | 1783 | ||
2292 | err = rdev_get_key(rdev, dev, key_idx, pairwise, mac_addr, &cookie, | 1784 | err = rdev->ops->get_key(&rdev->wiphy, dev, key_idx, pairwise, |
2293 | get_key_callback); | 1785 | mac_addr, &cookie, get_key_callback); |
2294 | 1786 | ||
2295 | if (err) | 1787 | if (err) |
2296 | goto free_msg; | 1788 | goto free_msg; |
@@ -2338,7 +1830,7 @@ static int nl80211_set_key(struct sk_buff *skb, struct genl_info *info) | |||
2338 | if (err) | 1830 | if (err) |
2339 | goto out; | 1831 | goto out; |
2340 | 1832 | ||
2341 | err = rdev_set_default_key(rdev, dev, key.idx, | 1833 | err = rdev->ops->set_default_key(&rdev->wiphy, dev, key.idx, |
2342 | key.def_uni, key.def_multi); | 1834 | key.def_uni, key.def_multi); |
2343 | 1835 | ||
2344 | if (err) | 1836 | if (err) |
@@ -2362,7 +1854,8 @@ static int nl80211_set_key(struct sk_buff *skb, struct genl_info *info) | |||
2362 | if (err) | 1854 | if (err) |
2363 | goto out; | 1855 | goto out; |
2364 | 1856 | ||
2365 | err = rdev_set_default_mgmt_key(rdev, dev, key.idx); | 1857 | err = rdev->ops->set_default_mgmt_key(&rdev->wiphy, |
1858 | dev, key.idx); | ||
2366 | if (err) | 1859 | if (err) |
2367 | goto out; | 1860 | goto out; |
2368 | 1861 | ||
@@ -2418,9 +1911,9 @@ static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info) | |||
2418 | wdev_lock(dev->ieee80211_ptr); | 1911 | wdev_lock(dev->ieee80211_ptr); |
2419 | err = nl80211_key_allowed(dev->ieee80211_ptr); | 1912 | err = nl80211_key_allowed(dev->ieee80211_ptr); |
2420 | if (!err) | 1913 | if (!err) |
2421 | err = rdev_add_key(rdev, dev, key.idx, | 1914 | err = rdev->ops->add_key(&rdev->wiphy, dev, key.idx, |
2422 | key.type == NL80211_KEYTYPE_PAIRWISE, | 1915 | key.type == NL80211_KEYTYPE_PAIRWISE, |
2423 | mac_addr, &key.p); | 1916 | mac_addr, &key.p); |
2424 | wdev_unlock(dev->ieee80211_ptr); | 1917 | wdev_unlock(dev->ieee80211_ptr); |
2425 | 1918 | ||
2426 | return err; | 1919 | return err; |
@@ -2464,9 +1957,9 @@ static int nl80211_del_key(struct sk_buff *skb, struct genl_info *info) | |||
2464 | err = -ENOENT; | 1957 | err = -ENOENT; |
2465 | 1958 | ||
2466 | if (!err) | 1959 | if (!err) |
2467 | err = rdev_del_key(rdev, dev, key.idx, | 1960 | err = rdev->ops->del_key(&rdev->wiphy, dev, key.idx, |
2468 | key.type == NL80211_KEYTYPE_PAIRWISE, | 1961 | key.type == NL80211_KEYTYPE_PAIRWISE, |
2469 | mac_addr); | 1962 | mac_addr); |
2470 | 1963 | ||
2471 | #ifdef CONFIG_CFG80211_WEXT | 1964 | #ifdef CONFIG_CFG80211_WEXT |
2472 | if (!err) { | 1965 | if (!err) { |
@@ -2481,291 +1974,96 @@ static int nl80211_del_key(struct sk_buff *skb, struct genl_info *info) | |||
2481 | return err; | 1974 | return err; |
2482 | } | 1975 | } |
2483 | 1976 | ||
2484 | static int nl80211_parse_beacon(struct genl_info *info, | 1977 | static int nl80211_addset_beacon(struct sk_buff *skb, struct genl_info *info) |
2485 | struct cfg80211_beacon_data *bcn) | ||
2486 | { | ||
2487 | bool haveinfo = false; | ||
2488 | |||
2489 | if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_BEACON_TAIL]) || | ||
2490 | !is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]) || | ||
2491 | !is_valid_ie_attr(info->attrs[NL80211_ATTR_IE_PROBE_RESP]) || | ||
2492 | !is_valid_ie_attr(info->attrs[NL80211_ATTR_IE_ASSOC_RESP])) | ||
2493 | return -EINVAL; | ||
2494 | |||
2495 | memset(bcn, 0, sizeof(*bcn)); | ||
2496 | |||
2497 | if (info->attrs[NL80211_ATTR_BEACON_HEAD]) { | ||
2498 | bcn->head = nla_data(info->attrs[NL80211_ATTR_BEACON_HEAD]); | ||
2499 | bcn->head_len = nla_len(info->attrs[NL80211_ATTR_BEACON_HEAD]); | ||
2500 | if (!bcn->head_len) | ||
2501 | return -EINVAL; | ||
2502 | haveinfo = true; | ||
2503 | } | ||
2504 | |||
2505 | if (info->attrs[NL80211_ATTR_BEACON_TAIL]) { | ||
2506 | bcn->tail = nla_data(info->attrs[NL80211_ATTR_BEACON_TAIL]); | ||
2507 | bcn->tail_len = | ||
2508 | nla_len(info->attrs[NL80211_ATTR_BEACON_TAIL]); | ||
2509 | haveinfo = true; | ||
2510 | } | ||
2511 | |||
2512 | if (!haveinfo) | ||
2513 | return -EINVAL; | ||
2514 | |||
2515 | if (info->attrs[NL80211_ATTR_IE]) { | ||
2516 | bcn->beacon_ies = nla_data(info->attrs[NL80211_ATTR_IE]); | ||
2517 | bcn->beacon_ies_len = nla_len(info->attrs[NL80211_ATTR_IE]); | ||
2518 | } | ||
2519 | |||
2520 | if (info->attrs[NL80211_ATTR_IE_PROBE_RESP]) { | ||
2521 | bcn->proberesp_ies = | ||
2522 | nla_data(info->attrs[NL80211_ATTR_IE_PROBE_RESP]); | ||
2523 | bcn->proberesp_ies_len = | ||
2524 | nla_len(info->attrs[NL80211_ATTR_IE_PROBE_RESP]); | ||
2525 | } | ||
2526 | |||
2527 | if (info->attrs[NL80211_ATTR_IE_ASSOC_RESP]) { | ||
2528 | bcn->assocresp_ies = | ||
2529 | nla_data(info->attrs[NL80211_ATTR_IE_ASSOC_RESP]); | ||
2530 | bcn->assocresp_ies_len = | ||
2531 | nla_len(info->attrs[NL80211_ATTR_IE_ASSOC_RESP]); | ||
2532 | } | ||
2533 | |||
2534 | if (info->attrs[NL80211_ATTR_PROBE_RESP]) { | ||
2535 | bcn->probe_resp = | ||
2536 | nla_data(info->attrs[NL80211_ATTR_PROBE_RESP]); | ||
2537 | bcn->probe_resp_len = | ||
2538 | nla_len(info->attrs[NL80211_ATTR_PROBE_RESP]); | ||
2539 | } | ||
2540 | |||
2541 | return 0; | ||
2542 | } | ||
2543 | |||
2544 | static bool nl80211_get_ap_channel(struct cfg80211_registered_device *rdev, | ||
2545 | struct cfg80211_ap_settings *params) | ||
2546 | { | ||
2547 | struct wireless_dev *wdev; | ||
2548 | bool ret = false; | ||
2549 | |||
2550 | mutex_lock(&rdev->devlist_mtx); | ||
2551 | |||
2552 | list_for_each_entry(wdev, &rdev->wdev_list, list) { | ||
2553 | if (wdev->iftype != NL80211_IFTYPE_AP && | ||
2554 | wdev->iftype != NL80211_IFTYPE_P2P_GO) | ||
2555 | continue; | ||
2556 | |||
2557 | if (!wdev->preset_chandef.chan) | ||
2558 | continue; | ||
2559 | |||
2560 | params->chandef = wdev->preset_chandef; | ||
2561 | ret = true; | ||
2562 | break; | ||
2563 | } | ||
2564 | |||
2565 | mutex_unlock(&rdev->devlist_mtx); | ||
2566 | |||
2567 | return ret; | ||
2568 | } | ||
2569 | |||
2570 | static bool nl80211_valid_auth_type(struct cfg80211_registered_device *rdev, | ||
2571 | enum nl80211_auth_type auth_type, | ||
2572 | enum nl80211_commands cmd) | ||
2573 | { | ||
2574 | if (auth_type > NL80211_AUTHTYPE_MAX) | ||
2575 | return false; | ||
2576 | |||
2577 | switch (cmd) { | ||
2578 | case NL80211_CMD_AUTHENTICATE: | ||
2579 | if (!(rdev->wiphy.features & NL80211_FEATURE_SAE) && | ||
2580 | auth_type == NL80211_AUTHTYPE_SAE) | ||
2581 | return false; | ||
2582 | return true; | ||
2583 | case NL80211_CMD_CONNECT: | ||
2584 | case NL80211_CMD_START_AP: | ||
2585 | /* SAE not supported yet */ | ||
2586 | if (auth_type == NL80211_AUTHTYPE_SAE) | ||
2587 | return false; | ||
2588 | return true; | ||
2589 | default: | ||
2590 | return false; | ||
2591 | } | ||
2592 | } | ||
2593 | |||
2594 | static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info) | ||
2595 | { | 1978 | { |
1979 | int (*call)(struct wiphy *wiphy, struct net_device *dev, | ||
1980 | struct beacon_parameters *info); | ||
2596 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | 1981 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; |
2597 | struct net_device *dev = info->user_ptr[1]; | 1982 | struct net_device *dev = info->user_ptr[1]; |
2598 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 1983 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
2599 | struct cfg80211_ap_settings params; | 1984 | struct beacon_parameters params; |
2600 | int err; | 1985 | int haveinfo = 0, err; |
1986 | |||
1987 | if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_BEACON_TAIL])) | ||
1988 | return -EINVAL; | ||
2601 | 1989 | ||
2602 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && | 1990 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && |
2603 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) | 1991 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) |
2604 | return -EOPNOTSUPP; | 1992 | return -EOPNOTSUPP; |
2605 | 1993 | ||
2606 | if (!rdev->ops->start_ap) | ||
2607 | return -EOPNOTSUPP; | ||
2608 | |||
2609 | if (wdev->beacon_interval) | ||
2610 | return -EALREADY; | ||
2611 | |||
2612 | memset(¶ms, 0, sizeof(params)); | 1994 | memset(¶ms, 0, sizeof(params)); |
2613 | 1995 | ||
2614 | /* these are required for START_AP */ | 1996 | switch (info->genlhdr->cmd) { |
2615 | if (!info->attrs[NL80211_ATTR_BEACON_INTERVAL] || | 1997 | case NL80211_CMD_NEW_BEACON: |
2616 | !info->attrs[NL80211_ATTR_DTIM_PERIOD] || | 1998 | /* these are required for NEW_BEACON */ |
2617 | !info->attrs[NL80211_ATTR_BEACON_HEAD]) | 1999 | if (!info->attrs[NL80211_ATTR_BEACON_INTERVAL] || |
2618 | return -EINVAL; | 2000 | !info->attrs[NL80211_ATTR_DTIM_PERIOD] || |
2619 | 2001 | !info->attrs[NL80211_ATTR_BEACON_HEAD]) | |
2620 | err = nl80211_parse_beacon(info, ¶ms.beacon); | ||
2621 | if (err) | ||
2622 | return err; | ||
2623 | |||
2624 | params.beacon_interval = | ||
2625 | nla_get_u32(info->attrs[NL80211_ATTR_BEACON_INTERVAL]); | ||
2626 | params.dtim_period = | ||
2627 | nla_get_u32(info->attrs[NL80211_ATTR_DTIM_PERIOD]); | ||
2628 | |||
2629 | err = cfg80211_validate_beacon_int(rdev, params.beacon_interval); | ||
2630 | if (err) | ||
2631 | return err; | ||
2632 | |||
2633 | /* | ||
2634 | * In theory, some of these attributes should be required here | ||
2635 | * but since they were not used when the command was originally | ||
2636 | * added, keep them optional for old user space programs to let | ||
2637 | * them continue to work with drivers that do not need the | ||
2638 | * additional information -- drivers must check! | ||
2639 | */ | ||
2640 | if (info->attrs[NL80211_ATTR_SSID]) { | ||
2641 | params.ssid = nla_data(info->attrs[NL80211_ATTR_SSID]); | ||
2642 | params.ssid_len = | ||
2643 | nla_len(info->attrs[NL80211_ATTR_SSID]); | ||
2644 | if (params.ssid_len == 0 || | ||
2645 | params.ssid_len > IEEE80211_MAX_SSID_LEN) | ||
2646 | return -EINVAL; | ||
2647 | } | ||
2648 | |||
2649 | if (info->attrs[NL80211_ATTR_HIDDEN_SSID]) { | ||
2650 | params.hidden_ssid = nla_get_u32( | ||
2651 | info->attrs[NL80211_ATTR_HIDDEN_SSID]); | ||
2652 | if (params.hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE && | ||
2653 | params.hidden_ssid != NL80211_HIDDEN_SSID_ZERO_LEN && | ||
2654 | params.hidden_ssid != NL80211_HIDDEN_SSID_ZERO_CONTENTS) | ||
2655 | return -EINVAL; | ||
2656 | } | ||
2657 | |||
2658 | params.privacy = !!info->attrs[NL80211_ATTR_PRIVACY]; | ||
2659 | |||
2660 | if (info->attrs[NL80211_ATTR_AUTH_TYPE]) { | ||
2661 | params.auth_type = nla_get_u32( | ||
2662 | info->attrs[NL80211_ATTR_AUTH_TYPE]); | ||
2663 | if (!nl80211_valid_auth_type(rdev, params.auth_type, | ||
2664 | NL80211_CMD_START_AP)) | ||
2665 | return -EINVAL; | 2002 | return -EINVAL; |
2666 | } else | ||
2667 | params.auth_type = NL80211_AUTHTYPE_AUTOMATIC; | ||
2668 | 2003 | ||
2669 | err = nl80211_crypto_settings(rdev, info, ¶ms.crypto, | 2004 | params.interval = |
2670 | NL80211_MAX_NR_CIPHER_SUITES); | 2005 | nla_get_u32(info->attrs[NL80211_ATTR_BEACON_INTERVAL]); |
2671 | if (err) | 2006 | params.dtim_period = |
2672 | return err; | 2007 | nla_get_u32(info->attrs[NL80211_ATTR_DTIM_PERIOD]); |
2673 | 2008 | ||
2674 | if (info->attrs[NL80211_ATTR_INACTIVITY_TIMEOUT]) { | 2009 | err = cfg80211_validate_beacon_int(rdev, params.interval); |
2675 | if (!(rdev->wiphy.features & NL80211_FEATURE_INACTIVITY_TIMER)) | 2010 | if (err) |
2676 | return -EOPNOTSUPP; | 2011 | return err; |
2677 | params.inactivity_timeout = nla_get_u16( | ||
2678 | info->attrs[NL80211_ATTR_INACTIVITY_TIMEOUT]); | ||
2679 | } | ||
2680 | 2012 | ||
2681 | if (info->attrs[NL80211_ATTR_P2P_CTWINDOW]) { | 2013 | call = rdev->ops->add_beacon; |
2682 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) | 2014 | break; |
2683 | return -EINVAL; | 2015 | case NL80211_CMD_SET_BEACON: |
2684 | params.p2p_ctwindow = | 2016 | call = rdev->ops->set_beacon; |
2685 | nla_get_u8(info->attrs[NL80211_ATTR_P2P_CTWINDOW]); | 2017 | break; |
2686 | if (params.p2p_ctwindow > 127) | 2018 | default: |
2687 | return -EINVAL; | 2019 | WARN_ON(1); |
2688 | if (params.p2p_ctwindow != 0 && | 2020 | return -EOPNOTSUPP; |
2689 | !(rdev->wiphy.features & NL80211_FEATURE_P2P_GO_CTWIN)) | ||
2690 | return -EINVAL; | ||
2691 | } | 2021 | } |
2692 | 2022 | ||
2693 | if (info->attrs[NL80211_ATTR_P2P_OPPPS]) { | 2023 | if (!call) |
2694 | u8 tmp; | 2024 | return -EOPNOTSUPP; |
2695 | 2025 | ||
2696 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) | 2026 | if (info->attrs[NL80211_ATTR_BEACON_HEAD]) { |
2697 | return -EINVAL; | 2027 | params.head = nla_data(info->attrs[NL80211_ATTR_BEACON_HEAD]); |
2698 | tmp = nla_get_u8(info->attrs[NL80211_ATTR_P2P_OPPPS]); | 2028 | params.head_len = |
2699 | if (tmp > 1) | 2029 | nla_len(info->attrs[NL80211_ATTR_BEACON_HEAD]); |
2700 | return -EINVAL; | 2030 | haveinfo = 1; |
2701 | params.p2p_opp_ps = tmp; | ||
2702 | if (params.p2p_opp_ps != 0 && | ||
2703 | !(rdev->wiphy.features & NL80211_FEATURE_P2P_GO_OPPPS)) | ||
2704 | return -EINVAL; | ||
2705 | } | 2031 | } |
2706 | 2032 | ||
2707 | if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) { | 2033 | if (info->attrs[NL80211_ATTR_BEACON_TAIL]) { |
2708 | err = nl80211_parse_chandef(rdev, info, ¶ms.chandef); | 2034 | params.tail = nla_data(info->attrs[NL80211_ATTR_BEACON_TAIL]); |
2709 | if (err) | 2035 | params.tail_len = |
2710 | return err; | 2036 | nla_len(info->attrs[NL80211_ATTR_BEACON_TAIL]); |
2711 | } else if (wdev->preset_chandef.chan) { | 2037 | haveinfo = 1; |
2712 | params.chandef = wdev->preset_chandef; | 2038 | } |
2713 | } else if (!nl80211_get_ap_channel(rdev, ¶ms)) | ||
2714 | return -EINVAL; | ||
2715 | 2039 | ||
2716 | if (!cfg80211_reg_can_beacon(&rdev->wiphy, ¶ms.chandef)) | 2040 | if (!haveinfo) |
2717 | return -EINVAL; | 2041 | return -EINVAL; |
2718 | 2042 | ||
2719 | mutex_lock(&rdev->devlist_mtx); | 2043 | err = call(&rdev->wiphy, dev, ¶ms); |
2720 | err = cfg80211_can_use_chan(rdev, wdev, params.chandef.chan, | 2044 | if (!err && params.interval) |
2721 | CHAN_MODE_SHARED); | 2045 | wdev->beacon_interval = params.interval; |
2722 | mutex_unlock(&rdev->devlist_mtx); | ||
2723 | |||
2724 | if (err) | ||
2725 | return err; | ||
2726 | |||
2727 | err = rdev_start_ap(rdev, dev, ¶ms); | ||
2728 | if (!err) { | ||
2729 | wdev->preset_chandef = params.chandef; | ||
2730 | wdev->beacon_interval = params.beacon_interval; | ||
2731 | wdev->channel = params.chandef.chan; | ||
2732 | wdev->ssid_len = params.ssid_len; | ||
2733 | memcpy(wdev->ssid, params.ssid, wdev->ssid_len); | ||
2734 | } | ||
2735 | return err; | 2046 | return err; |
2736 | } | 2047 | } |
2737 | 2048 | ||
2738 | static int nl80211_set_beacon(struct sk_buff *skb, struct genl_info *info) | 2049 | static int nl80211_del_beacon(struct sk_buff *skb, struct genl_info *info) |
2739 | { | 2050 | { |
2740 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | 2051 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; |
2741 | struct net_device *dev = info->user_ptr[1]; | 2052 | struct net_device *dev = info->user_ptr[1]; |
2742 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 2053 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
2743 | struct cfg80211_beacon_data params; | ||
2744 | int err; | 2054 | int err; |
2745 | 2055 | ||
2746 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && | 2056 | if (!rdev->ops->del_beacon) |
2747 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) | ||
2748 | return -EOPNOTSUPP; | 2057 | return -EOPNOTSUPP; |
2749 | 2058 | ||
2750 | if (!rdev->ops->change_beacon) | 2059 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && |
2060 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) | ||
2751 | return -EOPNOTSUPP; | 2061 | return -EOPNOTSUPP; |
2752 | 2062 | ||
2753 | if (!wdev->beacon_interval) | 2063 | err = rdev->ops->del_beacon(&rdev->wiphy, dev); |
2754 | return -EINVAL; | 2064 | if (!err) |
2755 | 2065 | wdev->beacon_interval = 0; | |
2756 | err = nl80211_parse_beacon(info, ¶ms); | 2066 | return err; |
2757 | if (err) | ||
2758 | return err; | ||
2759 | |||
2760 | return rdev_change_beacon(rdev, dev, ¶ms); | ||
2761 | } | ||
2762 | |||
2763 | static int nl80211_stop_ap(struct sk_buff *skb, struct genl_info *info) | ||
2764 | { | ||
2765 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | ||
2766 | struct net_device *dev = info->user_ptr[1]; | ||
2767 | |||
2768 | return cfg80211_stop_ap(rdev, dev); | ||
2769 | } | 2067 | } |
2770 | 2068 | ||
2771 | static const struct nla_policy sta_flags_policy[NL80211_STA_FLAG_MAX + 1] = { | 2069 | static const struct nla_policy sta_flags_policy[NL80211_STA_FLAG_MAX + 1] = { |
@@ -2774,11 +2072,9 @@ static const struct nla_policy sta_flags_policy[NL80211_STA_FLAG_MAX + 1] = { | |||
2774 | [NL80211_STA_FLAG_WME] = { .type = NLA_FLAG }, | 2072 | [NL80211_STA_FLAG_WME] = { .type = NLA_FLAG }, |
2775 | [NL80211_STA_FLAG_MFP] = { .type = NLA_FLAG }, | 2073 | [NL80211_STA_FLAG_MFP] = { .type = NLA_FLAG }, |
2776 | [NL80211_STA_FLAG_AUTHENTICATED] = { .type = NLA_FLAG }, | 2074 | [NL80211_STA_FLAG_AUTHENTICATED] = { .type = NLA_FLAG }, |
2777 | [NL80211_STA_FLAG_TDLS_PEER] = { .type = NLA_FLAG }, | ||
2778 | }; | 2075 | }; |
2779 | 2076 | ||
2780 | static int parse_station_flags(struct genl_info *info, | 2077 | static int parse_station_flags(struct genl_info *info, |
2781 | enum nl80211_iftype iftype, | ||
2782 | struct station_parameters *params) | 2078 | struct station_parameters *params) |
2783 | { | 2079 | { |
2784 | struct nlattr *flags[NL80211_STA_FLAG_MAX + 1]; | 2080 | struct nlattr *flags[NL80211_STA_FLAG_MAX + 1]; |
@@ -2812,44 +2108,13 @@ static int parse_station_flags(struct genl_info *info, | |||
2812 | nla, sta_flags_policy)) | 2108 | nla, sta_flags_policy)) |
2813 | return -EINVAL; | 2109 | return -EINVAL; |
2814 | 2110 | ||
2815 | /* | 2111 | params->sta_flags_mask = (1 << __NL80211_STA_FLAG_AFTER_LAST) - 1; |
2816 | * Only allow certain flags for interface types so that | 2112 | params->sta_flags_mask &= ~1; |
2817 | * other attributes are silently ignored. Remember that | ||
2818 | * this is backward compatibility code with old userspace | ||
2819 | * and shouldn't be hit in other cases anyway. | ||
2820 | */ | ||
2821 | switch (iftype) { | ||
2822 | case NL80211_IFTYPE_AP: | ||
2823 | case NL80211_IFTYPE_AP_VLAN: | ||
2824 | case NL80211_IFTYPE_P2P_GO: | ||
2825 | params->sta_flags_mask = BIT(NL80211_STA_FLAG_AUTHORIZED) | | ||
2826 | BIT(NL80211_STA_FLAG_SHORT_PREAMBLE) | | ||
2827 | BIT(NL80211_STA_FLAG_WME) | | ||
2828 | BIT(NL80211_STA_FLAG_MFP); | ||
2829 | break; | ||
2830 | case NL80211_IFTYPE_P2P_CLIENT: | ||
2831 | case NL80211_IFTYPE_STATION: | ||
2832 | params->sta_flags_mask = BIT(NL80211_STA_FLAG_AUTHORIZED) | | ||
2833 | BIT(NL80211_STA_FLAG_TDLS_PEER); | ||
2834 | break; | ||
2835 | case NL80211_IFTYPE_MESH_POINT: | ||
2836 | params->sta_flags_mask = BIT(NL80211_STA_FLAG_AUTHENTICATED) | | ||
2837 | BIT(NL80211_STA_FLAG_MFP) | | ||
2838 | BIT(NL80211_STA_FLAG_AUTHORIZED); | ||
2839 | default: | ||
2840 | return -EINVAL; | ||
2841 | } | ||
2842 | 2113 | ||
2843 | for (flag = 1; flag <= NL80211_STA_FLAG_MAX; flag++) { | 2114 | for (flag = 1; flag <= NL80211_STA_FLAG_MAX; flag++) |
2844 | if (flags[flag]) { | 2115 | if (flags[flag]) |
2845 | params->sta_flags_set |= (1<<flag); | 2116 | params->sta_flags_set |= (1<<flag); |
2846 | 2117 | ||
2847 | /* no longer support new API additions in old API */ | ||
2848 | if (flag > NL80211_STA_FLAG_MAX_OLD_API) | ||
2849 | return -EINVAL; | ||
2850 | } | ||
2851 | } | ||
2852 | |||
2853 | return 0; | 2118 | return 0; |
2854 | } | 2119 | } |
2855 | 2120 | ||
@@ -2857,120 +2122,77 @@ static bool nl80211_put_sta_rate(struct sk_buff *msg, struct rate_info *info, | |||
2857 | int attr) | 2122 | int attr) |
2858 | { | 2123 | { |
2859 | struct nlattr *rate; | 2124 | struct nlattr *rate; |
2860 | u32 bitrate; | 2125 | u16 bitrate; |
2861 | u16 bitrate_compat; | ||
2862 | 2126 | ||
2863 | rate = nla_nest_start(msg, attr); | 2127 | rate = nla_nest_start(msg, attr); |
2864 | if (!rate) | 2128 | if (!rate) |
2865 | return false; | 2129 | goto nla_put_failure; |
2866 | 2130 | ||
2867 | /* cfg80211_calculate_bitrate will return 0 for mcs >= 32 */ | 2131 | /* cfg80211_calculate_bitrate will return 0 for mcs >= 32 */ |
2868 | bitrate = cfg80211_calculate_bitrate(info); | 2132 | bitrate = cfg80211_calculate_bitrate(info); |
2869 | /* report 16-bit bitrate only if we can */ | 2133 | if (bitrate > 0) |
2870 | bitrate_compat = bitrate < (1UL << 16) ? bitrate : 0; | 2134 | NLA_PUT_U16(msg, NL80211_RATE_INFO_BITRATE, bitrate); |
2871 | if (bitrate > 0 && | 2135 | |
2872 | nla_put_u32(msg, NL80211_RATE_INFO_BITRATE32, bitrate)) | 2136 | if (info->flags & RATE_INFO_FLAGS_MCS) |
2873 | return false; | 2137 | NLA_PUT_U8(msg, NL80211_RATE_INFO_MCS, info->mcs); |
2874 | if (bitrate_compat > 0 && | 2138 | if (info->flags & RATE_INFO_FLAGS_40_MHZ_WIDTH) |
2875 | nla_put_u16(msg, NL80211_RATE_INFO_BITRATE, bitrate_compat)) | 2139 | NLA_PUT_FLAG(msg, NL80211_RATE_INFO_40_MHZ_WIDTH); |
2876 | return false; | 2140 | if (info->flags & RATE_INFO_FLAGS_SHORT_GI) |
2877 | 2141 | NLA_PUT_FLAG(msg, NL80211_RATE_INFO_SHORT_GI); | |
2878 | if (info->flags & RATE_INFO_FLAGS_MCS) { | ||
2879 | if (nla_put_u8(msg, NL80211_RATE_INFO_MCS, info->mcs)) | ||
2880 | return false; | ||
2881 | if (info->flags & RATE_INFO_FLAGS_40_MHZ_WIDTH && | ||
2882 | nla_put_flag(msg, NL80211_RATE_INFO_40_MHZ_WIDTH)) | ||
2883 | return false; | ||
2884 | if (info->flags & RATE_INFO_FLAGS_SHORT_GI && | ||
2885 | nla_put_flag(msg, NL80211_RATE_INFO_SHORT_GI)) | ||
2886 | return false; | ||
2887 | } else if (info->flags & RATE_INFO_FLAGS_VHT_MCS) { | ||
2888 | if (nla_put_u8(msg, NL80211_RATE_INFO_VHT_MCS, info->mcs)) | ||
2889 | return false; | ||
2890 | if (nla_put_u8(msg, NL80211_RATE_INFO_VHT_NSS, info->nss)) | ||
2891 | return false; | ||
2892 | if (info->flags & RATE_INFO_FLAGS_40_MHZ_WIDTH && | ||
2893 | nla_put_flag(msg, NL80211_RATE_INFO_40_MHZ_WIDTH)) | ||
2894 | return false; | ||
2895 | if (info->flags & RATE_INFO_FLAGS_80_MHZ_WIDTH && | ||
2896 | nla_put_flag(msg, NL80211_RATE_INFO_80_MHZ_WIDTH)) | ||
2897 | return false; | ||
2898 | if (info->flags & RATE_INFO_FLAGS_80P80_MHZ_WIDTH && | ||
2899 | nla_put_flag(msg, NL80211_RATE_INFO_80P80_MHZ_WIDTH)) | ||
2900 | return false; | ||
2901 | if (info->flags & RATE_INFO_FLAGS_160_MHZ_WIDTH && | ||
2902 | nla_put_flag(msg, NL80211_RATE_INFO_160_MHZ_WIDTH)) | ||
2903 | return false; | ||
2904 | if (info->flags & RATE_INFO_FLAGS_SHORT_GI && | ||
2905 | nla_put_flag(msg, NL80211_RATE_INFO_SHORT_GI)) | ||
2906 | return false; | ||
2907 | } | ||
2908 | 2142 | ||
2909 | nla_nest_end(msg, rate); | 2143 | nla_nest_end(msg, rate); |
2910 | return true; | 2144 | return true; |
2145 | |||
2146 | nla_put_failure: | ||
2147 | return false; | ||
2911 | } | 2148 | } |
2912 | 2149 | ||
2913 | static int nl80211_send_station(struct sk_buff *msg, u32 portid, u32 seq, | 2150 | static int nl80211_send_station(struct sk_buff *msg, u32 pid, u32 seq, |
2914 | int flags, | 2151 | int flags, struct net_device *dev, |
2915 | struct cfg80211_registered_device *rdev, | ||
2916 | struct net_device *dev, | ||
2917 | const u8 *mac_addr, struct station_info *sinfo) | 2152 | const u8 *mac_addr, struct station_info *sinfo) |
2918 | { | 2153 | { |
2919 | void *hdr; | 2154 | void *hdr; |
2920 | struct nlattr *sinfoattr, *bss_param; | 2155 | struct nlattr *sinfoattr, *bss_param; |
2921 | 2156 | ||
2922 | hdr = nl80211hdr_put(msg, portid, seq, flags, NL80211_CMD_NEW_STATION); | 2157 | hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_STATION); |
2923 | if (!hdr) | 2158 | if (!hdr) |
2924 | return -1; | 2159 | return -1; |
2925 | 2160 | ||
2926 | if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || | 2161 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); |
2927 | nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr) || | 2162 | NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr); |
2928 | nla_put_u32(msg, NL80211_ATTR_GENERATION, sinfo->generation)) | 2163 | |
2929 | goto nla_put_failure; | 2164 | NLA_PUT_U32(msg, NL80211_ATTR_GENERATION, sinfo->generation); |
2930 | 2165 | ||
2931 | sinfoattr = nla_nest_start(msg, NL80211_ATTR_STA_INFO); | 2166 | sinfoattr = nla_nest_start(msg, NL80211_ATTR_STA_INFO); |
2932 | if (!sinfoattr) | 2167 | if (!sinfoattr) |
2933 | goto nla_put_failure; | 2168 | goto nla_put_failure; |
2934 | if ((sinfo->filled & STATION_INFO_CONNECTED_TIME) && | 2169 | if (sinfo->filled & STATION_INFO_CONNECTED_TIME) |
2935 | nla_put_u32(msg, NL80211_STA_INFO_CONNECTED_TIME, | 2170 | NLA_PUT_U32(msg, NL80211_STA_INFO_CONNECTED_TIME, |
2936 | sinfo->connected_time)) | 2171 | sinfo->connected_time); |
2937 | goto nla_put_failure; | 2172 | if (sinfo->filled & STATION_INFO_INACTIVE_TIME) |
2938 | if ((sinfo->filled & STATION_INFO_INACTIVE_TIME) && | 2173 | NLA_PUT_U32(msg, NL80211_STA_INFO_INACTIVE_TIME, |
2939 | nla_put_u32(msg, NL80211_STA_INFO_INACTIVE_TIME, | 2174 | sinfo->inactive_time); |
2940 | sinfo->inactive_time)) | 2175 | if (sinfo->filled & STATION_INFO_RX_BYTES) |
2941 | goto nla_put_failure; | 2176 | NLA_PUT_U32(msg, NL80211_STA_INFO_RX_BYTES, |
2942 | if ((sinfo->filled & STATION_INFO_RX_BYTES) && | 2177 | sinfo->rx_bytes); |
2943 | nla_put_u32(msg, NL80211_STA_INFO_RX_BYTES, | 2178 | if (sinfo->filled & STATION_INFO_TX_BYTES) |
2944 | sinfo->rx_bytes)) | 2179 | NLA_PUT_U32(msg, NL80211_STA_INFO_TX_BYTES, |
2945 | goto nla_put_failure; | 2180 | sinfo->tx_bytes); |
2946 | if ((sinfo->filled & STATION_INFO_TX_BYTES) && | 2181 | if (sinfo->filled & STATION_INFO_LLID) |
2947 | nla_put_u32(msg, NL80211_STA_INFO_TX_BYTES, | 2182 | NLA_PUT_U16(msg, NL80211_STA_INFO_LLID, |
2948 | sinfo->tx_bytes)) | 2183 | sinfo->llid); |
2949 | goto nla_put_failure; | 2184 | if (sinfo->filled & STATION_INFO_PLID) |
2950 | if ((sinfo->filled & STATION_INFO_LLID) && | 2185 | NLA_PUT_U16(msg, NL80211_STA_INFO_PLID, |
2951 | nla_put_u16(msg, NL80211_STA_INFO_LLID, sinfo->llid)) | 2186 | sinfo->plid); |
2952 | goto nla_put_failure; | 2187 | if (sinfo->filled & STATION_INFO_PLINK_STATE) |
2953 | if ((sinfo->filled & STATION_INFO_PLID) && | 2188 | NLA_PUT_U8(msg, NL80211_STA_INFO_PLINK_STATE, |
2954 | nla_put_u16(msg, NL80211_STA_INFO_PLID, sinfo->plid)) | 2189 | sinfo->plink_state); |
2955 | goto nla_put_failure; | 2190 | if (sinfo->filled & STATION_INFO_SIGNAL) |
2956 | if ((sinfo->filled & STATION_INFO_PLINK_STATE) && | 2191 | NLA_PUT_U8(msg, NL80211_STA_INFO_SIGNAL, |
2957 | nla_put_u8(msg, NL80211_STA_INFO_PLINK_STATE, | 2192 | sinfo->signal); |
2958 | sinfo->plink_state)) | 2193 | if (sinfo->filled & STATION_INFO_SIGNAL_AVG) |
2959 | goto nla_put_failure; | 2194 | NLA_PUT_U8(msg, NL80211_STA_INFO_SIGNAL_AVG, |
2960 | switch (rdev->wiphy.signal_type) { | 2195 | sinfo->signal_avg); |
2961 | case CFG80211_SIGNAL_TYPE_MBM: | ||
2962 | if ((sinfo->filled & STATION_INFO_SIGNAL) && | ||
2963 | nla_put_u8(msg, NL80211_STA_INFO_SIGNAL, | ||
2964 | sinfo->signal)) | ||
2965 | goto nla_put_failure; | ||
2966 | if ((sinfo->filled & STATION_INFO_SIGNAL_AVG) && | ||
2967 | nla_put_u8(msg, NL80211_STA_INFO_SIGNAL_AVG, | ||
2968 | sinfo->signal_avg)) | ||
2969 | goto nla_put_failure; | ||
2970 | break; | ||
2971 | default: | ||
2972 | break; | ||
2973 | } | ||
2974 | if (sinfo->filled & STATION_INFO_TX_BITRATE) { | 2196 | if (sinfo->filled & STATION_INFO_TX_BITRATE) { |
2975 | if (!nl80211_put_sta_rate(msg, &sinfo->txrate, | 2197 | if (!nl80211_put_sta_rate(msg, &sinfo->txrate, |
2976 | NL80211_STA_INFO_TX_BITRATE)) | 2198 | NL80211_STA_INFO_TX_BITRATE)) |
@@ -2981,60 +2203,42 @@ static int nl80211_send_station(struct sk_buff *msg, u32 portid, u32 seq, | |||
2981 | NL80211_STA_INFO_RX_BITRATE)) | 2203 | NL80211_STA_INFO_RX_BITRATE)) |
2982 | goto nla_put_failure; | 2204 | goto nla_put_failure; |
2983 | } | 2205 | } |
2984 | if ((sinfo->filled & STATION_INFO_RX_PACKETS) && | 2206 | if (sinfo->filled & STATION_INFO_RX_PACKETS) |
2985 | nla_put_u32(msg, NL80211_STA_INFO_RX_PACKETS, | 2207 | NLA_PUT_U32(msg, NL80211_STA_INFO_RX_PACKETS, |
2986 | sinfo->rx_packets)) | 2208 | sinfo->rx_packets); |
2987 | goto nla_put_failure; | 2209 | if (sinfo->filled & STATION_INFO_TX_PACKETS) |
2988 | if ((sinfo->filled & STATION_INFO_TX_PACKETS) && | 2210 | NLA_PUT_U32(msg, NL80211_STA_INFO_TX_PACKETS, |
2989 | nla_put_u32(msg, NL80211_STA_INFO_TX_PACKETS, | 2211 | sinfo->tx_packets); |
2990 | sinfo->tx_packets)) | 2212 | if (sinfo->filled & STATION_INFO_TX_RETRIES) |
2991 | goto nla_put_failure; | 2213 | NLA_PUT_U32(msg, NL80211_STA_INFO_TX_RETRIES, |
2992 | if ((sinfo->filled & STATION_INFO_TX_RETRIES) && | 2214 | sinfo->tx_retries); |
2993 | nla_put_u32(msg, NL80211_STA_INFO_TX_RETRIES, | 2215 | if (sinfo->filled & STATION_INFO_TX_FAILED) |
2994 | sinfo->tx_retries)) | 2216 | NLA_PUT_U32(msg, NL80211_STA_INFO_TX_FAILED, |
2995 | goto nla_put_failure; | 2217 | sinfo->tx_failed); |
2996 | if ((sinfo->filled & STATION_INFO_TX_FAILED) && | ||
2997 | nla_put_u32(msg, NL80211_STA_INFO_TX_FAILED, | ||
2998 | sinfo->tx_failed)) | ||
2999 | goto nla_put_failure; | ||
3000 | if ((sinfo->filled & STATION_INFO_BEACON_LOSS_COUNT) && | ||
3001 | nla_put_u32(msg, NL80211_STA_INFO_BEACON_LOSS, | ||
3002 | sinfo->beacon_loss_count)) | ||
3003 | goto nla_put_failure; | ||
3004 | if (sinfo->filled & STATION_INFO_BSS_PARAM) { | 2218 | if (sinfo->filled & STATION_INFO_BSS_PARAM) { |
3005 | bss_param = nla_nest_start(msg, NL80211_STA_INFO_BSS_PARAM); | 2219 | bss_param = nla_nest_start(msg, NL80211_STA_INFO_BSS_PARAM); |
3006 | if (!bss_param) | 2220 | if (!bss_param) |
3007 | goto nla_put_failure; | 2221 | goto nla_put_failure; |
3008 | 2222 | ||
3009 | if (((sinfo->bss_param.flags & BSS_PARAM_FLAGS_CTS_PROT) && | 2223 | if (sinfo->bss_param.flags & BSS_PARAM_FLAGS_CTS_PROT) |
3010 | nla_put_flag(msg, NL80211_STA_BSS_PARAM_CTS_PROT)) || | 2224 | NLA_PUT_FLAG(msg, NL80211_STA_BSS_PARAM_CTS_PROT); |
3011 | ((sinfo->bss_param.flags & BSS_PARAM_FLAGS_SHORT_PREAMBLE) && | 2225 | if (sinfo->bss_param.flags & BSS_PARAM_FLAGS_SHORT_PREAMBLE) |
3012 | nla_put_flag(msg, NL80211_STA_BSS_PARAM_SHORT_PREAMBLE)) || | 2226 | NLA_PUT_FLAG(msg, NL80211_STA_BSS_PARAM_SHORT_PREAMBLE); |
3013 | ((sinfo->bss_param.flags & BSS_PARAM_FLAGS_SHORT_SLOT_TIME) && | 2227 | if (sinfo->bss_param.flags & BSS_PARAM_FLAGS_SHORT_SLOT_TIME) |
3014 | nla_put_flag(msg, NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME)) || | 2228 | NLA_PUT_FLAG(msg, |
3015 | nla_put_u8(msg, NL80211_STA_BSS_PARAM_DTIM_PERIOD, | 2229 | NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME); |
3016 | sinfo->bss_param.dtim_period) || | 2230 | NLA_PUT_U8(msg, NL80211_STA_BSS_PARAM_DTIM_PERIOD, |
3017 | nla_put_u16(msg, NL80211_STA_BSS_PARAM_BEACON_INTERVAL, | 2231 | sinfo->bss_param.dtim_period); |
3018 | sinfo->bss_param.beacon_interval)) | 2232 | NLA_PUT_U16(msg, NL80211_STA_BSS_PARAM_BEACON_INTERVAL, |
3019 | goto nla_put_failure; | 2233 | sinfo->bss_param.beacon_interval); |
3020 | 2234 | ||
3021 | nla_nest_end(msg, bss_param); | 2235 | nla_nest_end(msg, bss_param); |
3022 | } | 2236 | } |
3023 | if ((sinfo->filled & STATION_INFO_STA_FLAGS) && | ||
3024 | nla_put(msg, NL80211_STA_INFO_STA_FLAGS, | ||
3025 | sizeof(struct nl80211_sta_flag_update), | ||
3026 | &sinfo->sta_flags)) | ||
3027 | goto nla_put_failure; | ||
3028 | if ((sinfo->filled & STATION_INFO_T_OFFSET) && | ||
3029 | nla_put_u64(msg, NL80211_STA_INFO_T_OFFSET, | ||
3030 | sinfo->t_offset)) | ||
3031 | goto nla_put_failure; | ||
3032 | nla_nest_end(msg, sinfoattr); | 2237 | nla_nest_end(msg, sinfoattr); |
3033 | 2238 | ||
3034 | if ((sinfo->filled & STATION_INFO_ASSOC_REQ_IES) && | 2239 | if (sinfo->assoc_req_ies) |
3035 | nla_put(msg, NL80211_ATTR_IE, sinfo->assoc_req_ies_len, | 2240 | NLA_PUT(msg, NL80211_ATTR_IE, sinfo->assoc_req_ies_len, |
3036 | sinfo->assoc_req_ies)) | 2241 | sinfo->assoc_req_ies); |
3037 | goto nla_put_failure; | ||
3038 | 2242 | ||
3039 | return genlmsg_end(msg, hdr); | 2243 | return genlmsg_end(msg, hdr); |
3040 | 2244 | ||
@@ -3064,17 +2268,17 @@ static int nl80211_dump_station(struct sk_buff *skb, | |||
3064 | 2268 | ||
3065 | while (1) { | 2269 | while (1) { |
3066 | memset(&sinfo, 0, sizeof(sinfo)); | 2270 | memset(&sinfo, 0, sizeof(sinfo)); |
3067 | err = rdev_dump_station(dev, netdev, sta_idx, | 2271 | err = dev->ops->dump_station(&dev->wiphy, netdev, sta_idx, |
3068 | mac_addr, &sinfo); | 2272 | mac_addr, &sinfo); |
3069 | if (err == -ENOENT) | 2273 | if (err == -ENOENT) |
3070 | break; | 2274 | break; |
3071 | if (err) | 2275 | if (err) |
3072 | goto out_err; | 2276 | goto out_err; |
3073 | 2277 | ||
3074 | if (nl80211_send_station(skb, | 2278 | if (nl80211_send_station(skb, |
3075 | NETLINK_CB(cb->skb).portid, | 2279 | NETLINK_CB(cb->skb).pid, |
3076 | cb->nlh->nlmsg_seq, NLM_F_MULTI, | 2280 | cb->nlh->nlmsg_seq, NLM_F_MULTI, |
3077 | dev, netdev, mac_addr, | 2281 | netdev, mac_addr, |
3078 | &sinfo) < 0) | 2282 | &sinfo) < 0) |
3079 | goto out; | 2283 | goto out; |
3080 | 2284 | ||
@@ -3110,7 +2314,7 @@ static int nl80211_get_station(struct sk_buff *skb, struct genl_info *info) | |||
3110 | if (!rdev->ops->get_station) | 2314 | if (!rdev->ops->get_station) |
3111 | return -EOPNOTSUPP; | 2315 | return -EOPNOTSUPP; |
3112 | 2316 | ||
3113 | err = rdev_get_station(rdev, dev, mac_addr, &sinfo); | 2317 | err = rdev->ops->get_station(&rdev->wiphy, dev, mac_addr, &sinfo); |
3114 | if (err) | 2318 | if (err) |
3115 | return err; | 2319 | return err; |
3116 | 2320 | ||
@@ -3118,8 +2322,8 @@ static int nl80211_get_station(struct sk_buff *skb, struct genl_info *info) | |||
3118 | if (!msg) | 2322 | if (!msg) |
3119 | return -ENOMEM; | 2323 | return -ENOMEM; |
3120 | 2324 | ||
3121 | if (nl80211_send_station(msg, info->snd_portid, info->snd_seq, 0, | 2325 | if (nl80211_send_station(msg, info->snd_pid, info->snd_seq, 0, |
3122 | rdev, dev, mac_addr, &sinfo) < 0) { | 2326 | dev, mac_addr, &sinfo) < 0) { |
3123 | nlmsg_free(msg); | 2327 | nlmsg_free(msg); |
3124 | return -ENOBUFS; | 2328 | return -ENOBUFS; |
3125 | } | 2329 | } |
@@ -3130,34 +2334,26 @@ static int nl80211_get_station(struct sk_buff *skb, struct genl_info *info) | |||
3130 | /* | 2334 | /* |
3131 | * Get vlan interface making sure it is running and on the right wiphy. | 2335 | * Get vlan interface making sure it is running and on the right wiphy. |
3132 | */ | 2336 | */ |
3133 | static struct net_device *get_vlan(struct genl_info *info, | 2337 | static int get_vlan(struct genl_info *info, |
3134 | struct cfg80211_registered_device *rdev) | 2338 | struct cfg80211_registered_device *rdev, |
2339 | struct net_device **vlan) | ||
3135 | { | 2340 | { |
3136 | struct nlattr *vlanattr = info->attrs[NL80211_ATTR_STA_VLAN]; | 2341 | struct nlattr *vlanattr = info->attrs[NL80211_ATTR_STA_VLAN]; |
3137 | struct net_device *v; | 2342 | *vlan = NULL; |
3138 | int ret; | 2343 | |
3139 | 2344 | if (vlanattr) { | |
3140 | if (!vlanattr) | 2345 | *vlan = dev_get_by_index(genl_info_net(info), |
3141 | return NULL; | 2346 | nla_get_u32(vlanattr)); |
3142 | 2347 | if (!*vlan) | |
3143 | v = dev_get_by_index(genl_info_net(info), nla_get_u32(vlanattr)); | 2348 | return -ENODEV; |
3144 | if (!v) | 2349 | if (!(*vlan)->ieee80211_ptr) |
3145 | return ERR_PTR(-ENODEV); | 2350 | return -EINVAL; |
3146 | 2351 | if ((*vlan)->ieee80211_ptr->wiphy != &rdev->wiphy) | |
3147 | if (!v->ieee80211_ptr || v->ieee80211_ptr->wiphy != &rdev->wiphy) { | 2352 | return -EINVAL; |
3148 | ret = -EINVAL; | 2353 | if (!netif_running(*vlan)) |
3149 | goto error; | 2354 | return -ENETDOWN; |
3150 | } | ||
3151 | |||
3152 | if (!netif_running(v)) { | ||
3153 | ret = -ENETDOWN; | ||
3154 | goto error; | ||
3155 | } | 2355 | } |
3156 | 2356 | return 0; | |
3157 | return v; | ||
3158 | error: | ||
3159 | dev_put(v); | ||
3160 | return ERR_PTR(ret); | ||
3161 | } | 2357 | } |
3162 | 2358 | ||
3163 | static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info) | 2359 | static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info) |
@@ -3196,10 +2392,7 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info) | |||
3196 | params.ht_capa = | 2392 | params.ht_capa = |
3197 | nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]); | 2393 | nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]); |
3198 | 2394 | ||
3199 | if (!rdev->ops->change_station) | 2395 | if (parse_station_flags(info, ¶ms)) |
3200 | return -EOPNOTSUPP; | ||
3201 | |||
3202 | if (parse_station_flags(info, dev->ieee80211_ptr->iftype, ¶ms)) | ||
3203 | return -EINVAL; | 2396 | return -EINVAL; |
3204 | 2397 | ||
3205 | if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION]) | 2398 | if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION]) |
@@ -3210,97 +2403,72 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info) | |||
3210 | params.plink_state = | 2403 | params.plink_state = |
3211 | nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_STATE]); | 2404 | nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_STATE]); |
3212 | 2405 | ||
2406 | err = get_vlan(info, rdev, ¶ms.vlan); | ||
2407 | if (err) | ||
2408 | goto out; | ||
2409 | |||
2410 | /* validate settings */ | ||
2411 | err = 0; | ||
2412 | |||
3213 | switch (dev->ieee80211_ptr->iftype) { | 2413 | switch (dev->ieee80211_ptr->iftype) { |
3214 | case NL80211_IFTYPE_AP: | 2414 | case NL80211_IFTYPE_AP: |
3215 | case NL80211_IFTYPE_AP_VLAN: | 2415 | case NL80211_IFTYPE_AP_VLAN: |
3216 | case NL80211_IFTYPE_P2P_GO: | 2416 | case NL80211_IFTYPE_P2P_GO: |
3217 | /* disallow mesh-specific things */ | 2417 | /* disallow mesh-specific things */ |
3218 | if (params.plink_action) | 2418 | if (params.plink_action) |
3219 | return -EINVAL; | 2419 | err = -EINVAL; |
3220 | |||
3221 | /* TDLS can't be set, ... */ | ||
3222 | if (params.sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) | ||
3223 | return -EINVAL; | ||
3224 | /* | ||
3225 | * ... but don't bother the driver with it. This works around | ||
3226 | * a hostapd/wpa_supplicant issue -- it always includes the | ||
3227 | * TLDS_PEER flag in the mask even for AP mode. | ||
3228 | */ | ||
3229 | params.sta_flags_mask &= ~BIT(NL80211_STA_FLAG_TDLS_PEER); | ||
3230 | |||
3231 | /* accept only the listed bits */ | ||
3232 | if (params.sta_flags_mask & | ||
3233 | ~(BIT(NL80211_STA_FLAG_AUTHORIZED) | | ||
3234 | BIT(NL80211_STA_FLAG_SHORT_PREAMBLE) | | ||
3235 | BIT(NL80211_STA_FLAG_WME) | | ||
3236 | BIT(NL80211_STA_FLAG_MFP))) | ||
3237 | return -EINVAL; | ||
3238 | |||
3239 | /* must be last in here for error handling */ | ||
3240 | params.vlan = get_vlan(info, rdev); | ||
3241 | if (IS_ERR(params.vlan)) | ||
3242 | return PTR_ERR(params.vlan); | ||
3243 | break; | 2420 | break; |
3244 | case NL80211_IFTYPE_P2P_CLIENT: | 2421 | case NL80211_IFTYPE_P2P_CLIENT: |
3245 | case NL80211_IFTYPE_STATION: | 2422 | case NL80211_IFTYPE_STATION: |
3246 | /* | 2423 | /* disallow everything but AUTHORIZED flag */ |
3247 | * Don't allow userspace to change the TDLS_PEER flag, | ||
3248 | * but silently ignore attempts to change it since we | ||
3249 | * don't have state here to verify that it doesn't try | ||
3250 | * to change the flag. | ||
3251 | */ | ||
3252 | params.sta_flags_mask &= ~BIT(NL80211_STA_FLAG_TDLS_PEER); | ||
3253 | /* fall through */ | ||
3254 | case NL80211_IFTYPE_ADHOC: | ||
3255 | /* disallow things sta doesn't support */ | ||
3256 | if (params.plink_action) | 2424 | if (params.plink_action) |
3257 | return -EINVAL; | 2425 | err = -EINVAL; |
2426 | if (params.vlan) | ||
2427 | err = -EINVAL; | ||
2428 | if (params.supported_rates) | ||
2429 | err = -EINVAL; | ||
3258 | if (params.ht_capa) | 2430 | if (params.ht_capa) |
3259 | return -EINVAL; | 2431 | err = -EINVAL; |
3260 | if (params.listen_interval >= 0) | 2432 | if (params.listen_interval >= 0) |
3261 | return -EINVAL; | 2433 | err = -EINVAL; |
3262 | /* reject any changes other than AUTHORIZED */ | ||
3263 | if (params.sta_flags_mask & ~BIT(NL80211_STA_FLAG_AUTHORIZED)) | 2434 | if (params.sta_flags_mask & ~BIT(NL80211_STA_FLAG_AUTHORIZED)) |
3264 | return -EINVAL; | 2435 | err = -EINVAL; |
3265 | break; | 2436 | break; |
3266 | case NL80211_IFTYPE_MESH_POINT: | 2437 | case NL80211_IFTYPE_MESH_POINT: |
3267 | /* disallow things mesh doesn't support */ | 2438 | /* disallow things mesh doesn't support */ |
3268 | if (params.vlan) | 2439 | if (params.vlan) |
3269 | return -EINVAL; | 2440 | err = -EINVAL; |
3270 | if (params.ht_capa) | 2441 | if (params.ht_capa) |
3271 | return -EINVAL; | 2442 | err = -EINVAL; |
3272 | if (params.listen_interval >= 0) | 2443 | if (params.listen_interval >= 0) |
3273 | return -EINVAL; | 2444 | err = -EINVAL; |
3274 | /* | ||
3275 | * No special handling for TDLS here -- the userspace | ||
3276 | * mesh code doesn't have this bug. | ||
3277 | */ | ||
3278 | if (params.sta_flags_mask & | 2445 | if (params.sta_flags_mask & |
3279 | ~(BIT(NL80211_STA_FLAG_AUTHENTICATED) | | 2446 | ~(BIT(NL80211_STA_FLAG_AUTHENTICATED) | |
3280 | BIT(NL80211_STA_FLAG_MFP) | | 2447 | BIT(NL80211_STA_FLAG_MFP) | |
3281 | BIT(NL80211_STA_FLAG_AUTHORIZED))) | 2448 | BIT(NL80211_STA_FLAG_AUTHORIZED))) |
3282 | return -EINVAL; | 2449 | err = -EINVAL; |
3283 | break; | 2450 | break; |
3284 | default: | 2451 | default: |
3285 | return -EOPNOTSUPP; | 2452 | err = -EINVAL; |
3286 | } | 2453 | } |
3287 | 2454 | ||
3288 | /* be aware of params.vlan when changing code here */ | 2455 | if (err) |
2456 | goto out; | ||
2457 | |||
2458 | if (!rdev->ops->change_station) { | ||
2459 | err = -EOPNOTSUPP; | ||
2460 | goto out; | ||
2461 | } | ||
3289 | 2462 | ||
3290 | err = rdev_change_station(rdev, dev, mac_addr, ¶ms); | 2463 | err = rdev->ops->change_station(&rdev->wiphy, dev, mac_addr, ¶ms); |
3291 | 2464 | ||
2465 | out: | ||
3292 | if (params.vlan) | 2466 | if (params.vlan) |
3293 | dev_put(params.vlan); | 2467 | dev_put(params.vlan); |
3294 | 2468 | ||
3295 | return err; | 2469 | return err; |
3296 | } | 2470 | } |
3297 | 2471 | ||
3298 | static struct nla_policy | ||
3299 | nl80211_sta_wme_policy[NL80211_STA_WME_MAX + 1] __read_mostly = { | ||
3300 | [NL80211_STA_WME_UAPSD_QUEUES] = { .type = NLA_U8 }, | ||
3301 | [NL80211_STA_WME_MAX_SP] = { .type = NLA_U8 }, | ||
3302 | }; | ||
3303 | |||
3304 | static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info) | 2472 | static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info) |
3305 | { | 2473 | { |
3306 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | 2474 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; |
@@ -3339,89 +2507,34 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info) | |||
3339 | params.ht_capa = | 2507 | params.ht_capa = |
3340 | nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]); | 2508 | nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]); |
3341 | 2509 | ||
3342 | if (info->attrs[NL80211_ATTR_VHT_CAPABILITY]) | ||
3343 | params.vht_capa = | ||
3344 | nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]); | ||
3345 | |||
3346 | if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION]) | 2510 | if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION]) |
3347 | params.plink_action = | 2511 | params.plink_action = |
3348 | nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]); | 2512 | nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]); |
3349 | 2513 | ||
3350 | if (!rdev->ops->add_station) | 2514 | if (parse_station_flags(info, ¶ms)) |
3351 | return -EOPNOTSUPP; | ||
3352 | |||
3353 | if (parse_station_flags(info, dev->ieee80211_ptr->iftype, ¶ms)) | ||
3354 | return -EINVAL; | 2515 | return -EINVAL; |
3355 | 2516 | ||
3356 | switch (dev->ieee80211_ptr->iftype) { | 2517 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && |
3357 | case NL80211_IFTYPE_AP: | 2518 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP_VLAN && |
3358 | case NL80211_IFTYPE_AP_VLAN: | 2519 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT && |
3359 | case NL80211_IFTYPE_P2P_GO: | 2520 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) |
3360 | /* parse WME attributes if sta is WME capable */ | 2521 | return -EINVAL; |
3361 | if ((rdev->wiphy.flags & WIPHY_FLAG_AP_UAPSD) && | ||
3362 | (params.sta_flags_set & BIT(NL80211_STA_FLAG_WME)) && | ||
3363 | info->attrs[NL80211_ATTR_STA_WME]) { | ||
3364 | struct nlattr *tb[NL80211_STA_WME_MAX + 1]; | ||
3365 | struct nlattr *nla; | ||
3366 | |||
3367 | nla = info->attrs[NL80211_ATTR_STA_WME]; | ||
3368 | err = nla_parse_nested(tb, NL80211_STA_WME_MAX, nla, | ||
3369 | nl80211_sta_wme_policy); | ||
3370 | if (err) | ||
3371 | return err; | ||
3372 | |||
3373 | if (tb[NL80211_STA_WME_UAPSD_QUEUES]) | ||
3374 | params.uapsd_queues = | ||
3375 | nla_get_u8(tb[NL80211_STA_WME_UAPSD_QUEUES]); | ||
3376 | if (params.uapsd_queues & | ||
3377 | ~IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK) | ||
3378 | return -EINVAL; | ||
3379 | |||
3380 | if (tb[NL80211_STA_WME_MAX_SP]) | ||
3381 | params.max_sp = | ||
3382 | nla_get_u8(tb[NL80211_STA_WME_MAX_SP]); | ||
3383 | 2522 | ||
3384 | if (params.max_sp & | 2523 | err = get_vlan(info, rdev, ¶ms.vlan); |
3385 | ~IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK) | 2524 | if (err) |
3386 | return -EINVAL; | 2525 | goto out; |
3387 | 2526 | ||
3388 | params.sta_modify_mask |= STATION_PARAM_APPLY_UAPSD; | 2527 | /* validate settings */ |
3389 | } | 2528 | err = 0; |
3390 | /* TDLS peers cannot be added */ | ||
3391 | if (params.sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) | ||
3392 | return -EINVAL; | ||
3393 | /* but don't bother the driver with it */ | ||
3394 | params.sta_flags_mask &= ~BIT(NL80211_STA_FLAG_TDLS_PEER); | ||
3395 | 2529 | ||
3396 | /* must be last in here for error handling */ | 2530 | if (!rdev->ops->add_station) { |
3397 | params.vlan = get_vlan(info, rdev); | 2531 | err = -EOPNOTSUPP; |
3398 | if (IS_ERR(params.vlan)) | 2532 | goto out; |
3399 | return PTR_ERR(params.vlan); | ||
3400 | break; | ||
3401 | case NL80211_IFTYPE_MESH_POINT: | ||
3402 | /* TDLS peers cannot be added */ | ||
3403 | if (params.sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) | ||
3404 | return -EINVAL; | ||
3405 | break; | ||
3406 | case NL80211_IFTYPE_STATION: | ||
3407 | /* Only TDLS peers can be added */ | ||
3408 | if (!(params.sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))) | ||
3409 | return -EINVAL; | ||
3410 | /* Can only add if TDLS ... */ | ||
3411 | if (!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_TDLS)) | ||
3412 | return -EOPNOTSUPP; | ||
3413 | /* ... with external setup is supported */ | ||
3414 | if (!(rdev->wiphy.flags & WIPHY_FLAG_TDLS_EXTERNAL_SETUP)) | ||
3415 | return -EOPNOTSUPP; | ||
3416 | break; | ||
3417 | default: | ||
3418 | return -EOPNOTSUPP; | ||
3419 | } | 2533 | } |
3420 | 2534 | ||
3421 | /* be aware of params.vlan when changing code here */ | 2535 | err = rdev->ops->add_station(&rdev->wiphy, dev, mac_addr, ¶ms); |
3422 | |||
3423 | err = rdev_add_station(rdev, dev, mac_addr, ¶ms); | ||
3424 | 2536 | ||
2537 | out: | ||
3425 | if (params.vlan) | 2538 | if (params.vlan) |
3426 | dev_put(params.vlan); | 2539 | dev_put(params.vlan); |
3427 | return err; | 2540 | return err; |
@@ -3445,10 +2558,10 @@ static int nl80211_del_station(struct sk_buff *skb, struct genl_info *info) | |||
3445 | if (!rdev->ops->del_station) | 2558 | if (!rdev->ops->del_station) |
3446 | return -EOPNOTSUPP; | 2559 | return -EOPNOTSUPP; |
3447 | 2560 | ||
3448 | return rdev_del_station(rdev, dev, mac_addr); | 2561 | return rdev->ops->del_station(&rdev->wiphy, dev, mac_addr); |
3449 | } | 2562 | } |
3450 | 2563 | ||
3451 | static int nl80211_send_mpath(struct sk_buff *msg, u32 portid, u32 seq, | 2564 | static int nl80211_send_mpath(struct sk_buff *msg, u32 pid, u32 seq, |
3452 | int flags, struct net_device *dev, | 2565 | int flags, struct net_device *dev, |
3453 | u8 *dst, u8 *next_hop, | 2566 | u8 *dst, u8 *next_hop, |
3454 | struct mpath_info *pinfo) | 2567 | struct mpath_info *pinfo) |
@@ -3456,41 +2569,40 @@ static int nl80211_send_mpath(struct sk_buff *msg, u32 portid, u32 seq, | |||
3456 | void *hdr; | 2569 | void *hdr; |
3457 | struct nlattr *pinfoattr; | 2570 | struct nlattr *pinfoattr; |
3458 | 2571 | ||
3459 | hdr = nl80211hdr_put(msg, portid, seq, flags, NL80211_CMD_NEW_STATION); | 2572 | hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_STATION); |
3460 | if (!hdr) | 2573 | if (!hdr) |
3461 | return -1; | 2574 | return -1; |
3462 | 2575 | ||
3463 | if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || | 2576 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); |
3464 | nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, dst) || | 2577 | NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, dst); |
3465 | nla_put(msg, NL80211_ATTR_MPATH_NEXT_HOP, ETH_ALEN, next_hop) || | 2578 | NLA_PUT(msg, NL80211_ATTR_MPATH_NEXT_HOP, ETH_ALEN, next_hop); |
3466 | nla_put_u32(msg, NL80211_ATTR_GENERATION, pinfo->generation)) | 2579 | |
3467 | goto nla_put_failure; | 2580 | NLA_PUT_U32(msg, NL80211_ATTR_GENERATION, pinfo->generation); |
3468 | 2581 | ||
3469 | pinfoattr = nla_nest_start(msg, NL80211_ATTR_MPATH_INFO); | 2582 | pinfoattr = nla_nest_start(msg, NL80211_ATTR_MPATH_INFO); |
3470 | if (!pinfoattr) | 2583 | if (!pinfoattr) |
3471 | goto nla_put_failure; | 2584 | goto nla_put_failure; |
3472 | if ((pinfo->filled & MPATH_INFO_FRAME_QLEN) && | 2585 | if (pinfo->filled & MPATH_INFO_FRAME_QLEN) |
3473 | nla_put_u32(msg, NL80211_MPATH_INFO_FRAME_QLEN, | 2586 | NLA_PUT_U32(msg, NL80211_MPATH_INFO_FRAME_QLEN, |
3474 | pinfo->frame_qlen)) | 2587 | pinfo->frame_qlen); |
3475 | goto nla_put_failure; | 2588 | if (pinfo->filled & MPATH_INFO_SN) |
3476 | if (((pinfo->filled & MPATH_INFO_SN) && | 2589 | NLA_PUT_U32(msg, NL80211_MPATH_INFO_SN, |
3477 | nla_put_u32(msg, NL80211_MPATH_INFO_SN, pinfo->sn)) || | 2590 | pinfo->sn); |
3478 | ((pinfo->filled & MPATH_INFO_METRIC) && | 2591 | if (pinfo->filled & MPATH_INFO_METRIC) |
3479 | nla_put_u32(msg, NL80211_MPATH_INFO_METRIC, | 2592 | NLA_PUT_U32(msg, NL80211_MPATH_INFO_METRIC, |
3480 | pinfo->metric)) || | 2593 | pinfo->metric); |
3481 | ((pinfo->filled & MPATH_INFO_EXPTIME) && | 2594 | if (pinfo->filled & MPATH_INFO_EXPTIME) |
3482 | nla_put_u32(msg, NL80211_MPATH_INFO_EXPTIME, | 2595 | NLA_PUT_U32(msg, NL80211_MPATH_INFO_EXPTIME, |
3483 | pinfo->exptime)) || | 2596 | pinfo->exptime); |
3484 | ((pinfo->filled & MPATH_INFO_FLAGS) && | 2597 | if (pinfo->filled & MPATH_INFO_FLAGS) |
3485 | nla_put_u8(msg, NL80211_MPATH_INFO_FLAGS, | 2598 | NLA_PUT_U8(msg, NL80211_MPATH_INFO_FLAGS, |
3486 | pinfo->flags)) || | 2599 | pinfo->flags); |
3487 | ((pinfo->filled & MPATH_INFO_DISCOVERY_TIMEOUT) && | 2600 | if (pinfo->filled & MPATH_INFO_DISCOVERY_TIMEOUT) |
3488 | nla_put_u32(msg, NL80211_MPATH_INFO_DISCOVERY_TIMEOUT, | 2601 | NLA_PUT_U32(msg, NL80211_MPATH_INFO_DISCOVERY_TIMEOUT, |
3489 | pinfo->discovery_timeout)) || | 2602 | pinfo->discovery_timeout); |
3490 | ((pinfo->filled & MPATH_INFO_DISCOVERY_RETRIES) && | 2603 | if (pinfo->filled & MPATH_INFO_DISCOVERY_RETRIES) |
3491 | nla_put_u8(msg, NL80211_MPATH_INFO_DISCOVERY_RETRIES, | 2604 | NLA_PUT_U8(msg, NL80211_MPATH_INFO_DISCOVERY_RETRIES, |
3492 | pinfo->discovery_retries))) | 2605 | pinfo->discovery_retries); |
3493 | goto nla_put_failure; | ||
3494 | 2606 | ||
3495 | nla_nest_end(msg, pinfoattr); | 2607 | nla_nest_end(msg, pinfoattr); |
3496 | 2608 | ||
@@ -3527,14 +2639,14 @@ static int nl80211_dump_mpath(struct sk_buff *skb, | |||
3527 | } | 2639 | } |
3528 | 2640 | ||
3529 | while (1) { | 2641 | while (1) { |
3530 | err = rdev_dump_mpath(dev, netdev, path_idx, dst, next_hop, | 2642 | err = dev->ops->dump_mpath(&dev->wiphy, netdev, path_idx, |
3531 | &pinfo); | 2643 | dst, next_hop, &pinfo); |
3532 | if (err == -ENOENT) | 2644 | if (err == -ENOENT) |
3533 | break; | 2645 | break; |
3534 | if (err) | 2646 | if (err) |
3535 | goto out_err; | 2647 | goto out_err; |
3536 | 2648 | ||
3537 | if (nl80211_send_mpath(skb, NETLINK_CB(cb->skb).portid, | 2649 | if (nl80211_send_mpath(skb, NETLINK_CB(cb->skb).pid, |
3538 | cb->nlh->nlmsg_seq, NLM_F_MULTI, | 2650 | cb->nlh->nlmsg_seq, NLM_F_MULTI, |
3539 | netdev, dst, next_hop, | 2651 | netdev, dst, next_hop, |
3540 | &pinfo) < 0) | 2652 | &pinfo) < 0) |
@@ -3575,7 +2687,7 @@ static int nl80211_get_mpath(struct sk_buff *skb, struct genl_info *info) | |||
3575 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) | 2687 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) |
3576 | return -EOPNOTSUPP; | 2688 | return -EOPNOTSUPP; |
3577 | 2689 | ||
3578 | err = rdev_get_mpath(rdev, dev, dst, next_hop, &pinfo); | 2690 | err = rdev->ops->get_mpath(&rdev->wiphy, dev, dst, next_hop, &pinfo); |
3579 | if (err) | 2691 | if (err) |
3580 | return err; | 2692 | return err; |
3581 | 2693 | ||
@@ -3583,7 +2695,7 @@ static int nl80211_get_mpath(struct sk_buff *skb, struct genl_info *info) | |||
3583 | if (!msg) | 2695 | if (!msg) |
3584 | return -ENOMEM; | 2696 | return -ENOMEM; |
3585 | 2697 | ||
3586 | if (nl80211_send_mpath(msg, info->snd_portid, info->snd_seq, 0, | 2698 | if (nl80211_send_mpath(msg, info->snd_pid, info->snd_seq, 0, |
3587 | dev, dst, next_hop, &pinfo) < 0) { | 2699 | dev, dst, next_hop, &pinfo) < 0) { |
3588 | nlmsg_free(msg); | 2700 | nlmsg_free(msg); |
3589 | return -ENOBUFS; | 2701 | return -ENOBUFS; |
@@ -3614,7 +2726,7 @@ static int nl80211_set_mpath(struct sk_buff *skb, struct genl_info *info) | |||
3614 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) | 2726 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) |
3615 | return -EOPNOTSUPP; | 2727 | return -EOPNOTSUPP; |
3616 | 2728 | ||
3617 | return rdev_change_mpath(rdev, dev, dst, next_hop); | 2729 | return rdev->ops->change_mpath(&rdev->wiphy, dev, dst, next_hop); |
3618 | } | 2730 | } |
3619 | 2731 | ||
3620 | static int nl80211_new_mpath(struct sk_buff *skb, struct genl_info *info) | 2732 | static int nl80211_new_mpath(struct sk_buff *skb, struct genl_info *info) |
@@ -3639,7 +2751,7 @@ static int nl80211_new_mpath(struct sk_buff *skb, struct genl_info *info) | |||
3639 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) | 2751 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) |
3640 | return -EOPNOTSUPP; | 2752 | return -EOPNOTSUPP; |
3641 | 2753 | ||
3642 | return rdev_add_mpath(rdev, dev, dst, next_hop); | 2754 | return rdev->ops->add_mpath(&rdev->wiphy, dev, dst, next_hop); |
3643 | } | 2755 | } |
3644 | 2756 | ||
3645 | static int nl80211_del_mpath(struct sk_buff *skb, struct genl_info *info) | 2757 | static int nl80211_del_mpath(struct sk_buff *skb, struct genl_info *info) |
@@ -3654,7 +2766,7 @@ static int nl80211_del_mpath(struct sk_buff *skb, struct genl_info *info) | |||
3654 | if (!rdev->ops->del_mpath) | 2766 | if (!rdev->ops->del_mpath) |
3655 | return -EOPNOTSUPP; | 2767 | return -EOPNOTSUPP; |
3656 | 2768 | ||
3657 | return rdev_del_mpath(rdev, dev, dst); | 2769 | return rdev->ops->del_mpath(&rdev->wiphy, dev, dst); |
3658 | } | 2770 | } |
3659 | 2771 | ||
3660 | static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info) | 2772 | static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info) |
@@ -3670,8 +2782,6 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info) | |||
3670 | params.use_short_slot_time = -1; | 2782 | params.use_short_slot_time = -1; |
3671 | params.ap_isolate = -1; | 2783 | params.ap_isolate = -1; |
3672 | params.ht_opmode = -1; | 2784 | params.ht_opmode = -1; |
3673 | params.p2p_ctwindow = -1; | ||
3674 | params.p2p_opp_ps = -1; | ||
3675 | 2785 | ||
3676 | if (info->attrs[NL80211_ATTR_BSS_CTS_PROT]) | 2786 | if (info->attrs[NL80211_ATTR_BSS_CTS_PROT]) |
3677 | params.use_cts_prot = | 2787 | params.use_cts_prot = |
@@ -3694,32 +2804,6 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info) | |||
3694 | params.ht_opmode = | 2804 | params.ht_opmode = |
3695 | nla_get_u16(info->attrs[NL80211_ATTR_BSS_HT_OPMODE]); | 2805 | nla_get_u16(info->attrs[NL80211_ATTR_BSS_HT_OPMODE]); |
3696 | 2806 | ||
3697 | if (info->attrs[NL80211_ATTR_P2P_CTWINDOW]) { | ||
3698 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) | ||
3699 | return -EINVAL; | ||
3700 | params.p2p_ctwindow = | ||
3701 | nla_get_s8(info->attrs[NL80211_ATTR_P2P_CTWINDOW]); | ||
3702 | if (params.p2p_ctwindow < 0) | ||
3703 | return -EINVAL; | ||
3704 | if (params.p2p_ctwindow != 0 && | ||
3705 | !(rdev->wiphy.features & NL80211_FEATURE_P2P_GO_CTWIN)) | ||
3706 | return -EINVAL; | ||
3707 | } | ||
3708 | |||
3709 | if (info->attrs[NL80211_ATTR_P2P_OPPPS]) { | ||
3710 | u8 tmp; | ||
3711 | |||
3712 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) | ||
3713 | return -EINVAL; | ||
3714 | tmp = nla_get_u8(info->attrs[NL80211_ATTR_P2P_OPPPS]); | ||
3715 | if (tmp > 1) | ||
3716 | return -EINVAL; | ||
3717 | params.p2p_opp_ps = tmp; | ||
3718 | if (params.p2p_opp_ps && | ||
3719 | !(rdev->wiphy.features & NL80211_FEATURE_P2P_GO_OPPPS)) | ||
3720 | return -EINVAL; | ||
3721 | } | ||
3722 | |||
3723 | if (!rdev->ops->change_bss) | 2807 | if (!rdev->ops->change_bss) |
3724 | return -EOPNOTSUPP; | 2808 | return -EOPNOTSUPP; |
3725 | 2809 | ||
@@ -3727,7 +2811,7 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info) | |||
3727 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) | 2811 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) |
3728 | return -EOPNOTSUPP; | 2812 | return -EOPNOTSUPP; |
3729 | 2813 | ||
3730 | return rdev_change_bss(rdev, dev, ¶ms); | 2814 | return rdev->ops->change_bss(&rdev->wiphy, dev, ¶ms); |
3731 | } | 2815 | } |
3732 | 2816 | ||
3733 | static const struct nla_policy reg_rule_policy[NL80211_REG_RULE_ATTR_MAX + 1] = { | 2817 | static const struct nla_policy reg_rule_policy[NL80211_REG_RULE_ATTR_MAX + 1] = { |
@@ -3779,7 +2863,6 @@ static int nl80211_req_set_reg(struct sk_buff *skb, struct genl_info *info) | |||
3779 | { | 2863 | { |
3780 | int r; | 2864 | int r; |
3781 | char *data = NULL; | 2865 | char *data = NULL; |
3782 | enum nl80211_user_reg_hint_type user_reg_hint_type; | ||
3783 | 2866 | ||
3784 | /* | 2867 | /* |
3785 | * You should only get this when cfg80211 hasn't yet initialized | 2868 | * You should only get this when cfg80211 hasn't yet initialized |
@@ -3799,21 +2882,7 @@ static int nl80211_req_set_reg(struct sk_buff *skb, struct genl_info *info) | |||
3799 | 2882 | ||
3800 | data = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]); | 2883 | data = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]); |
3801 | 2884 | ||
3802 | if (info->attrs[NL80211_ATTR_USER_REG_HINT_TYPE]) | 2885 | r = regulatory_hint_user(data); |
3803 | user_reg_hint_type = | ||
3804 | nla_get_u32(info->attrs[NL80211_ATTR_USER_REG_HINT_TYPE]); | ||
3805 | else | ||
3806 | user_reg_hint_type = NL80211_USER_REG_HINT_USER; | ||
3807 | |||
3808 | switch (user_reg_hint_type) { | ||
3809 | case NL80211_USER_REG_HINT_USER: | ||
3810 | case NL80211_USER_REG_HINT_CELL_BASE: | ||
3811 | break; | ||
3812 | default: | ||
3813 | return -EINVAL; | ||
3814 | } | ||
3815 | |||
3816 | r = regulatory_hint_user(data, user_reg_hint_type); | ||
3817 | 2886 | ||
3818 | return r; | 2887 | return r; |
3819 | } | 2888 | } |
@@ -3841,7 +2910,8 @@ static int nl80211_get_mesh_config(struct sk_buff *skb, | |||
3841 | if (!wdev->mesh_id_len) | 2910 | if (!wdev->mesh_id_len) |
3842 | memcpy(&cur_params, &default_mesh_config, sizeof(cur_params)); | 2911 | memcpy(&cur_params, &default_mesh_config, sizeof(cur_params)); |
3843 | else | 2912 | else |
3844 | err = rdev_get_mesh_config(rdev, dev, &cur_params); | 2913 | err = rdev->ops->get_mesh_config(&rdev->wiphy, dev, |
2914 | &cur_params); | ||
3845 | wdev_unlock(wdev); | 2915 | wdev_unlock(wdev); |
3846 | 2916 | ||
3847 | if (err) | 2917 | if (err) |
@@ -3851,65 +2921,44 @@ static int nl80211_get_mesh_config(struct sk_buff *skb, | |||
3851 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | 2921 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); |
3852 | if (!msg) | 2922 | if (!msg) |
3853 | return -ENOMEM; | 2923 | return -ENOMEM; |
3854 | hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, | 2924 | hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, |
3855 | NL80211_CMD_GET_MESH_CONFIG); | 2925 | NL80211_CMD_GET_MESH_CONFIG); |
3856 | if (!hdr) | 2926 | if (!hdr) |
3857 | goto out; | 2927 | goto out; |
3858 | pinfoattr = nla_nest_start(msg, NL80211_ATTR_MESH_CONFIG); | 2928 | pinfoattr = nla_nest_start(msg, NL80211_ATTR_MESH_CONFIG); |
3859 | if (!pinfoattr) | 2929 | if (!pinfoattr) |
3860 | goto nla_put_failure; | 2930 | goto nla_put_failure; |
3861 | if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || | 2931 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); |
3862 | nla_put_u16(msg, NL80211_MESHCONF_RETRY_TIMEOUT, | 2932 | NLA_PUT_U16(msg, NL80211_MESHCONF_RETRY_TIMEOUT, |
3863 | cur_params.dot11MeshRetryTimeout) || | 2933 | cur_params.dot11MeshRetryTimeout); |
3864 | nla_put_u16(msg, NL80211_MESHCONF_CONFIRM_TIMEOUT, | 2934 | NLA_PUT_U16(msg, NL80211_MESHCONF_CONFIRM_TIMEOUT, |
3865 | cur_params.dot11MeshConfirmTimeout) || | 2935 | cur_params.dot11MeshConfirmTimeout); |
3866 | nla_put_u16(msg, NL80211_MESHCONF_HOLDING_TIMEOUT, | 2936 | NLA_PUT_U16(msg, NL80211_MESHCONF_HOLDING_TIMEOUT, |
3867 | cur_params.dot11MeshHoldingTimeout) || | 2937 | cur_params.dot11MeshHoldingTimeout); |
3868 | nla_put_u16(msg, NL80211_MESHCONF_MAX_PEER_LINKS, | 2938 | NLA_PUT_U16(msg, NL80211_MESHCONF_MAX_PEER_LINKS, |
3869 | cur_params.dot11MeshMaxPeerLinks) || | 2939 | cur_params.dot11MeshMaxPeerLinks); |
3870 | nla_put_u8(msg, NL80211_MESHCONF_MAX_RETRIES, | 2940 | NLA_PUT_U8(msg, NL80211_MESHCONF_MAX_RETRIES, |
3871 | cur_params.dot11MeshMaxRetries) || | 2941 | cur_params.dot11MeshMaxRetries); |
3872 | nla_put_u8(msg, NL80211_MESHCONF_TTL, | 2942 | NLA_PUT_U8(msg, NL80211_MESHCONF_TTL, |
3873 | cur_params.dot11MeshTTL) || | 2943 | cur_params.dot11MeshTTL); |
3874 | nla_put_u8(msg, NL80211_MESHCONF_ELEMENT_TTL, | 2944 | NLA_PUT_U8(msg, NL80211_MESHCONF_ELEMENT_TTL, |
3875 | cur_params.element_ttl) || | 2945 | cur_params.element_ttl); |
3876 | nla_put_u8(msg, NL80211_MESHCONF_AUTO_OPEN_PLINKS, | 2946 | NLA_PUT_U8(msg, NL80211_MESHCONF_AUTO_OPEN_PLINKS, |
3877 | cur_params.auto_open_plinks) || | 2947 | cur_params.auto_open_plinks); |
3878 | nla_put_u32(msg, NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, | 2948 | NLA_PUT_U8(msg, NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, |
3879 | cur_params.dot11MeshNbrOffsetMaxNeighbor) || | 2949 | cur_params.dot11MeshHWMPmaxPREQretries); |
3880 | nla_put_u8(msg, NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, | 2950 | NLA_PUT_U32(msg, NL80211_MESHCONF_PATH_REFRESH_TIME, |
3881 | cur_params.dot11MeshHWMPmaxPREQretries) || | 2951 | cur_params.path_refresh_time); |
3882 | nla_put_u32(msg, NL80211_MESHCONF_PATH_REFRESH_TIME, | 2952 | NLA_PUT_U16(msg, NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, |
3883 | cur_params.path_refresh_time) || | 2953 | cur_params.min_discovery_timeout); |
3884 | nla_put_u16(msg, NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, | 2954 | NLA_PUT_U32(msg, NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, |
3885 | cur_params.min_discovery_timeout) || | 2955 | cur_params.dot11MeshHWMPactivePathTimeout); |
3886 | nla_put_u32(msg, NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, | 2956 | NLA_PUT_U16(msg, NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, |
3887 | cur_params.dot11MeshHWMPactivePathTimeout) || | 2957 | cur_params.dot11MeshHWMPpreqMinInterval); |
3888 | nla_put_u16(msg, NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, | 2958 | NLA_PUT_U16(msg, NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME, |
3889 | cur_params.dot11MeshHWMPpreqMinInterval) || | 2959 | cur_params.dot11MeshHWMPnetDiameterTraversalTime); |
3890 | nla_put_u16(msg, NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, | 2960 | NLA_PUT_U8(msg, NL80211_MESHCONF_HWMP_ROOTMODE, |
3891 | cur_params.dot11MeshHWMPperrMinInterval) || | 2961 | cur_params.dot11MeshHWMPRootMode); |
3892 | nla_put_u16(msg, NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME, | ||
3893 | cur_params.dot11MeshHWMPnetDiameterTraversalTime) || | ||
3894 | nla_put_u8(msg, NL80211_MESHCONF_HWMP_ROOTMODE, | ||
3895 | cur_params.dot11MeshHWMPRootMode) || | ||
3896 | nla_put_u16(msg, NL80211_MESHCONF_HWMP_RANN_INTERVAL, | ||
3897 | cur_params.dot11MeshHWMPRannInterval) || | ||
3898 | nla_put_u8(msg, NL80211_MESHCONF_GATE_ANNOUNCEMENTS, | ||
3899 | cur_params.dot11MeshGateAnnouncementProtocol) || | ||
3900 | nla_put_u8(msg, NL80211_MESHCONF_FORWARDING, | ||
3901 | cur_params.dot11MeshForwarding) || | ||
3902 | nla_put_u32(msg, NL80211_MESHCONF_RSSI_THRESHOLD, | ||
3903 | cur_params.rssi_threshold) || | ||
3904 | nla_put_u32(msg, NL80211_MESHCONF_HT_OPMODE, | ||
3905 | cur_params.ht_opmode) || | ||
3906 | nla_put_u32(msg, NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT, | ||
3907 | cur_params.dot11MeshHWMPactivePathToRootTimeout) || | ||
3908 | nla_put_u16(msg, NL80211_MESHCONF_HWMP_ROOT_INTERVAL, | ||
3909 | cur_params.dot11MeshHWMProotInterval) || | ||
3910 | nla_put_u16(msg, NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, | ||
3911 | cur_params.dot11MeshHWMPconfirmationInterval)) | ||
3912 | goto nla_put_failure; | ||
3913 | nla_nest_end(msg, pinfoattr); | 2962 | nla_nest_end(msg, pinfoattr); |
3914 | genlmsg_end(msg, hdr); | 2963 | genlmsg_end(msg, hdr); |
3915 | return genlmsg_reply(msg, info); | 2964 | return genlmsg_reply(msg, info); |
@@ -3930,33 +2979,22 @@ static const struct nla_policy nl80211_meshconf_params_policy[NL80211_MESHCONF_A | |||
3930 | [NL80211_MESHCONF_TTL] = { .type = NLA_U8 }, | 2979 | [NL80211_MESHCONF_TTL] = { .type = NLA_U8 }, |
3931 | [NL80211_MESHCONF_ELEMENT_TTL] = { .type = NLA_U8 }, | 2980 | [NL80211_MESHCONF_ELEMENT_TTL] = { .type = NLA_U8 }, |
3932 | [NL80211_MESHCONF_AUTO_OPEN_PLINKS] = { .type = NLA_U8 }, | 2981 | [NL80211_MESHCONF_AUTO_OPEN_PLINKS] = { .type = NLA_U8 }, |
3933 | [NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR] = { .type = NLA_U32 }, | 2982 | |
3934 | [NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES] = { .type = NLA_U8 }, | 2983 | [NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES] = { .type = NLA_U8 }, |
3935 | [NL80211_MESHCONF_PATH_REFRESH_TIME] = { .type = NLA_U32 }, | 2984 | [NL80211_MESHCONF_PATH_REFRESH_TIME] = { .type = NLA_U32 }, |
3936 | [NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT] = { .type = NLA_U16 }, | 2985 | [NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT] = { .type = NLA_U16 }, |
3937 | [NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT] = { .type = NLA_U32 }, | 2986 | [NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT] = { .type = NLA_U32 }, |
3938 | [NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL] = { .type = NLA_U16 }, | 2987 | [NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL] = { .type = NLA_U16 }, |
3939 | [NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL] = { .type = NLA_U16 }, | ||
3940 | [NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME] = { .type = NLA_U16 }, | 2988 | [NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME] = { .type = NLA_U16 }, |
3941 | [NL80211_MESHCONF_HWMP_ROOTMODE] = { .type = NLA_U8 }, | ||
3942 | [NL80211_MESHCONF_HWMP_RANN_INTERVAL] = { .type = NLA_U16 }, | ||
3943 | [NL80211_MESHCONF_GATE_ANNOUNCEMENTS] = { .type = NLA_U8 }, | ||
3944 | [NL80211_MESHCONF_FORWARDING] = { .type = NLA_U8 }, | ||
3945 | [NL80211_MESHCONF_RSSI_THRESHOLD] = { .type = NLA_U32 }, | ||
3946 | [NL80211_MESHCONF_HT_OPMODE] = { .type = NLA_U16 }, | ||
3947 | [NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT] = { .type = NLA_U32 }, | ||
3948 | [NL80211_MESHCONF_HWMP_ROOT_INTERVAL] = { .type = NLA_U16 }, | ||
3949 | [NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL] = { .type = NLA_U16 }, | ||
3950 | }; | 2989 | }; |
3951 | 2990 | ||
3952 | static const struct nla_policy | 2991 | static const struct nla_policy |
3953 | nl80211_mesh_setup_params_policy[NL80211_MESH_SETUP_ATTR_MAX+1] = { | 2992 | nl80211_mesh_setup_params_policy[NL80211_MESH_SETUP_ATTR_MAX+1] = { |
3954 | [NL80211_MESH_SETUP_ENABLE_VENDOR_SYNC] = { .type = NLA_U8 }, | ||
3955 | [NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL] = { .type = NLA_U8 }, | 2993 | [NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL] = { .type = NLA_U8 }, |
3956 | [NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC] = { .type = NLA_U8 }, | 2994 | [NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC] = { .type = NLA_U8 }, |
3957 | [NL80211_MESH_SETUP_USERSPACE_AUTH] = { .type = NLA_FLAG }, | 2995 | [NL80211_MESH_SETUP_USERSPACE_AUTH] = { .type = NLA_FLAG }, |
3958 | [NL80211_MESH_SETUP_IE] = { .type = NLA_BINARY, | 2996 | [NL80211_MESH_SETUP_IE] = { .type = NLA_BINARY, |
3959 | .len = IEEE80211_MAX_DATA_LEN }, | 2997 | .len = IEEE80211_MAX_DATA_LEN }, |
3960 | [NL80211_MESH_SETUP_USERSPACE_AMPE] = { .type = NLA_FLAG }, | 2998 | [NL80211_MESH_SETUP_USERSPACE_AMPE] = { .type = NLA_FLAG }, |
3961 | }; | 2999 | }; |
3962 | 3000 | ||
@@ -3989,82 +3027,43 @@ do {\ | |||
3989 | 3027 | ||
3990 | /* Fill in the params struct */ | 3028 | /* Fill in the params struct */ |
3991 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshRetryTimeout, | 3029 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshRetryTimeout, |
3992 | mask, NL80211_MESHCONF_RETRY_TIMEOUT, | 3030 | mask, NL80211_MESHCONF_RETRY_TIMEOUT, nla_get_u16); |
3993 | nla_get_u16); | ||
3994 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshConfirmTimeout, | 3031 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshConfirmTimeout, |
3995 | mask, NL80211_MESHCONF_CONFIRM_TIMEOUT, | 3032 | mask, NL80211_MESHCONF_CONFIRM_TIMEOUT, nla_get_u16); |
3996 | nla_get_u16); | ||
3997 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHoldingTimeout, | 3033 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHoldingTimeout, |
3998 | mask, NL80211_MESHCONF_HOLDING_TIMEOUT, | 3034 | mask, NL80211_MESHCONF_HOLDING_TIMEOUT, nla_get_u16); |
3999 | nla_get_u16); | ||
4000 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxPeerLinks, | 3035 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxPeerLinks, |
4001 | mask, NL80211_MESHCONF_MAX_PEER_LINKS, | 3036 | mask, NL80211_MESHCONF_MAX_PEER_LINKS, nla_get_u16); |
4002 | nla_get_u16); | ||
4003 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxRetries, | 3037 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxRetries, |
4004 | mask, NL80211_MESHCONF_MAX_RETRIES, | 3038 | mask, NL80211_MESHCONF_MAX_RETRIES, nla_get_u8); |
4005 | nla_get_u8); | ||
4006 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshTTL, | 3039 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshTTL, |
4007 | mask, NL80211_MESHCONF_TTL, nla_get_u8); | 3040 | mask, NL80211_MESHCONF_TTL, nla_get_u8); |
4008 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, element_ttl, | 3041 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, element_ttl, |
4009 | mask, NL80211_MESHCONF_ELEMENT_TTL, | 3042 | mask, NL80211_MESHCONF_ELEMENT_TTL, nla_get_u8); |
4010 | nla_get_u8); | ||
4011 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, auto_open_plinks, | 3043 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, auto_open_plinks, |
4012 | mask, NL80211_MESHCONF_AUTO_OPEN_PLINKS, | 3044 | mask, NL80211_MESHCONF_AUTO_OPEN_PLINKS, nla_get_u8); |
4013 | nla_get_u8); | ||
4014 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshNbrOffsetMaxNeighbor, mask, | ||
4015 | NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, | ||
4016 | nla_get_u32); | ||
4017 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPmaxPREQretries, | 3045 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPmaxPREQretries, |
4018 | mask, NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, | 3046 | mask, NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, |
4019 | nla_get_u8); | 3047 | nla_get_u8); |
4020 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, path_refresh_time, | 3048 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, path_refresh_time, |
4021 | mask, NL80211_MESHCONF_PATH_REFRESH_TIME, | 3049 | mask, NL80211_MESHCONF_PATH_REFRESH_TIME, nla_get_u32); |
4022 | nla_get_u32); | ||
4023 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, min_discovery_timeout, | 3050 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, min_discovery_timeout, |
4024 | mask, NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, | 3051 | mask, NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, |
4025 | nla_get_u16); | 3052 | nla_get_u16); |
4026 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathTimeout, mask, | 3053 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathTimeout, |
4027 | NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, | 3054 | mask, NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, |
4028 | nla_get_u32); | 3055 | nla_get_u32); |
4029 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPpreqMinInterval, | 3056 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPpreqMinInterval, |
4030 | mask, NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, | 3057 | mask, NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, |
4031 | nla_get_u16); | 3058 | nla_get_u16); |
4032 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPperrMinInterval, | ||
4033 | mask, NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, | ||
4034 | nla_get_u16); | ||
4035 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, | ||
4036 | dot11MeshHWMPnetDiameterTraversalTime, mask, | ||
4037 | NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME, | ||
4038 | nla_get_u16); | ||
4039 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPRootMode, mask, | ||
4040 | NL80211_MESHCONF_HWMP_ROOTMODE, nla_get_u8); | ||
4041 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPRannInterval, mask, | ||
4042 | NL80211_MESHCONF_HWMP_RANN_INTERVAL, | ||
4043 | nla_get_u16); | ||
4044 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, | 3059 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, |
4045 | dot11MeshGateAnnouncementProtocol, mask, | 3060 | dot11MeshHWMPnetDiameterTraversalTime, |
4046 | NL80211_MESHCONF_GATE_ANNOUNCEMENTS, | 3061 | mask, NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME, |
4047 | nla_get_u8); | 3062 | nla_get_u16); |
4048 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshForwarding, | ||
4049 | mask, NL80211_MESHCONF_FORWARDING, | ||
4050 | nla_get_u8); | ||
4051 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold, | ||
4052 | mask, NL80211_MESHCONF_RSSI_THRESHOLD, | ||
4053 | nla_get_u32); | ||
4054 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, ht_opmode, | ||
4055 | mask, NL80211_MESHCONF_HT_OPMODE, | ||
4056 | nla_get_u16); | ||
4057 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathToRootTimeout, | ||
4058 | mask, | ||
4059 | NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT, | ||
4060 | nla_get_u32); | ||
4061 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMProotInterval, | ||
4062 | mask, NL80211_MESHCONF_HWMP_ROOT_INTERVAL, | ||
4063 | nla_get_u16); | ||
4064 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, | 3063 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, |
4065 | dot11MeshHWMPconfirmationInterval, mask, | 3064 | dot11MeshHWMPRootMode, mask, |
4066 | NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, | 3065 | NL80211_MESHCONF_HWMP_ROOTMODE, |
4067 | nla_get_u16); | 3066 | nla_get_u8); |
4068 | if (mask_out) | 3067 | if (mask_out) |
4069 | *mask_out = mask; | 3068 | *mask_out = mask; |
4070 | 3069 | ||
@@ -4085,12 +3084,6 @@ static int nl80211_parse_mesh_setup(struct genl_info *info, | |||
4085 | nl80211_mesh_setup_params_policy)) | 3084 | nl80211_mesh_setup_params_policy)) |
4086 | return -EINVAL; | 3085 | return -EINVAL; |
4087 | 3086 | ||
4088 | if (tb[NL80211_MESH_SETUP_ENABLE_VENDOR_SYNC]) | ||
4089 | setup->sync_method = | ||
4090 | (nla_get_u8(tb[NL80211_MESH_SETUP_ENABLE_VENDOR_SYNC])) ? | ||
4091 | IEEE80211_SYNC_METHOD_VENDOR : | ||
4092 | IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET; | ||
4093 | |||
4094 | if (tb[NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL]) | 3087 | if (tb[NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL]) |
4095 | setup->path_sel_proto = | 3088 | setup->path_sel_proto = |
4096 | (nla_get_u8(tb[NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL])) ? | 3089 | (nla_get_u8(tb[NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL])) ? |
@@ -4143,7 +3136,8 @@ static int nl80211_update_mesh_config(struct sk_buff *skb, | |||
4143 | err = -ENOLINK; | 3136 | err = -ENOLINK; |
4144 | 3137 | ||
4145 | if (!err) | 3138 | if (!err) |
4146 | err = rdev_update_mesh_config(rdev, dev, mask, &cfg); | 3139 | err = rdev->ops->update_mesh_config(&rdev->wiphy, dev, |
3140 | mask, &cfg); | ||
4147 | 3141 | ||
4148 | wdev_unlock(wdev); | 3142 | wdev_unlock(wdev); |
4149 | 3143 | ||
@@ -4169,22 +3163,13 @@ static int nl80211_get_reg(struct sk_buff *skb, struct genl_info *info) | |||
4169 | goto out; | 3163 | goto out; |
4170 | } | 3164 | } |
4171 | 3165 | ||
4172 | hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, | 3166 | hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, |
4173 | NL80211_CMD_GET_REG); | 3167 | NL80211_CMD_GET_REG); |
4174 | if (!hdr) | 3168 | if (!hdr) |
4175 | goto put_failure; | 3169 | goto put_failure; |
4176 | 3170 | ||
4177 | if (nla_put_string(msg, NL80211_ATTR_REG_ALPHA2, | 3171 | NLA_PUT_STRING(msg, NL80211_ATTR_REG_ALPHA2, |
4178 | cfg80211_regdomain->alpha2) || | 3172 | cfg80211_regdomain->alpha2); |
4179 | (cfg80211_regdomain->dfs_region && | ||
4180 | nla_put_u8(msg, NL80211_ATTR_DFS_REGION, | ||
4181 | cfg80211_regdomain->dfs_region))) | ||
4182 | goto nla_put_failure; | ||
4183 | |||
4184 | if (reg_last_request_cell_base() && | ||
4185 | nla_put_u32(msg, NL80211_ATTR_USER_REG_HINT_TYPE, | ||
4186 | NL80211_USER_REG_HINT_CELL_BASE)) | ||
4187 | goto nla_put_failure; | ||
4188 | 3173 | ||
4189 | nl_reg_rules = nla_nest_start(msg, NL80211_ATTR_REG_RULES); | 3174 | nl_reg_rules = nla_nest_start(msg, NL80211_ATTR_REG_RULES); |
4190 | if (!nl_reg_rules) | 3175 | if (!nl_reg_rules) |
@@ -4204,19 +3189,18 @@ static int nl80211_get_reg(struct sk_buff *skb, struct genl_info *info) | |||
4204 | if (!nl_reg_rule) | 3189 | if (!nl_reg_rule) |
4205 | goto nla_put_failure; | 3190 | goto nla_put_failure; |
4206 | 3191 | ||
4207 | if (nla_put_u32(msg, NL80211_ATTR_REG_RULE_FLAGS, | 3192 | NLA_PUT_U32(msg, NL80211_ATTR_REG_RULE_FLAGS, |
4208 | reg_rule->flags) || | 3193 | reg_rule->flags); |
4209 | nla_put_u32(msg, NL80211_ATTR_FREQ_RANGE_START, | 3194 | NLA_PUT_U32(msg, NL80211_ATTR_FREQ_RANGE_START, |
4210 | freq_range->start_freq_khz) || | 3195 | freq_range->start_freq_khz); |
4211 | nla_put_u32(msg, NL80211_ATTR_FREQ_RANGE_END, | 3196 | NLA_PUT_U32(msg, NL80211_ATTR_FREQ_RANGE_END, |
4212 | freq_range->end_freq_khz) || | 3197 | freq_range->end_freq_khz); |
4213 | nla_put_u32(msg, NL80211_ATTR_FREQ_RANGE_MAX_BW, | 3198 | NLA_PUT_U32(msg, NL80211_ATTR_FREQ_RANGE_MAX_BW, |
4214 | freq_range->max_bandwidth_khz) || | 3199 | freq_range->max_bandwidth_khz); |
4215 | nla_put_u32(msg, NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN, | 3200 | NLA_PUT_U32(msg, NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN, |
4216 | power_rule->max_antenna_gain) || | 3201 | power_rule->max_antenna_gain); |
4217 | nla_put_u32(msg, NL80211_ATTR_POWER_RULE_MAX_EIRP, | 3202 | NLA_PUT_U32(msg, NL80211_ATTR_POWER_RULE_MAX_EIRP, |
4218 | power_rule->max_eirp)) | 3203 | power_rule->max_eirp); |
4219 | goto nla_put_failure; | ||
4220 | 3204 | ||
4221 | nla_nest_end(msg, nl_reg_rule); | 3205 | nla_nest_end(msg, nl_reg_rule); |
4222 | } | 3206 | } |
@@ -4244,7 +3228,6 @@ static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info) | |||
4244 | char *alpha2 = NULL; | 3228 | char *alpha2 = NULL; |
4245 | int rem_reg_rules = 0, r = 0; | 3229 | int rem_reg_rules = 0, r = 0; |
4246 | u32 num_rules = 0, rule_idx = 0, size_of_regd; | 3230 | u32 num_rules = 0, rule_idx = 0, size_of_regd; |
4247 | u8 dfs_region = 0; | ||
4248 | struct ieee80211_regdomain *rd = NULL; | 3231 | struct ieee80211_regdomain *rd = NULL; |
4249 | 3232 | ||
4250 | if (!info->attrs[NL80211_ATTR_REG_ALPHA2]) | 3233 | if (!info->attrs[NL80211_ATTR_REG_ALPHA2]) |
@@ -4255,9 +3238,6 @@ static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info) | |||
4255 | 3238 | ||
4256 | alpha2 = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]); | 3239 | alpha2 = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]); |
4257 | 3240 | ||
4258 | if (info->attrs[NL80211_ATTR_DFS_REGION]) | ||
4259 | dfs_region = nla_get_u8(info->attrs[NL80211_ATTR_DFS_REGION]); | ||
4260 | |||
4261 | nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES], | 3241 | nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES], |
4262 | rem_reg_rules) { | 3242 | rem_reg_rules) { |
4263 | num_rules++; | 3243 | num_rules++; |
@@ -4285,13 +3265,6 @@ static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info) | |||
4285 | rd->alpha2[0] = alpha2[0]; | 3265 | rd->alpha2[0] = alpha2[0]; |
4286 | rd->alpha2[1] = alpha2[1]; | 3266 | rd->alpha2[1] = alpha2[1]; |
4287 | 3267 | ||
4288 | /* | ||
4289 | * Disable DFS master mode if the DFS region was | ||
4290 | * not supported or known on this kernel. | ||
4291 | */ | ||
4292 | if (reg_supported_dfs_region(dfs_region)) | ||
4293 | rd->dfs_region = dfs_region; | ||
4294 | |||
4295 | nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES], | 3268 | nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES], |
4296 | rem_reg_rules) { | 3269 | rem_reg_rules) { |
4297 | nla_parse(tb, NL80211_REG_RULE_ATTR_MAX, | 3270 | nla_parse(tb, NL80211_REG_RULE_ATTR_MAX, |
@@ -4351,7 +3324,7 @@ static int validate_scan_freqs(struct nlattr *freqs) | |||
4351 | static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info) | 3324 | static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info) |
4352 | { | 3325 | { |
4353 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | 3326 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; |
4354 | struct wireless_dev *wdev = info->user_ptr[1]; | 3327 | struct net_device *dev = info->user_ptr[1]; |
4355 | struct cfg80211_scan_request *request; | 3328 | struct cfg80211_scan_request *request; |
4356 | struct nlattr *attr; | 3329 | struct nlattr *attr; |
4357 | struct wiphy *wiphy; | 3330 | struct wiphy *wiphy; |
@@ -4508,32 +3481,15 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info) | |||
4508 | } | 3481 | } |
4509 | } | 3482 | } |
4510 | 3483 | ||
4511 | if (info->attrs[NL80211_ATTR_SCAN_FLAGS]) { | 3484 | request->dev = dev; |
4512 | request->flags = nla_get_u32( | ||
4513 | info->attrs[NL80211_ATTR_SCAN_FLAGS]); | ||
4514 | if (((request->flags & NL80211_SCAN_FLAG_LOW_PRIORITY) && | ||
4515 | !(wiphy->features & NL80211_FEATURE_LOW_PRIORITY_SCAN)) || | ||
4516 | ((request->flags & NL80211_SCAN_FLAG_FLUSH) && | ||
4517 | !(wiphy->features & NL80211_FEATURE_SCAN_FLUSH))) { | ||
4518 | err = -EOPNOTSUPP; | ||
4519 | goto out_free; | ||
4520 | } | ||
4521 | } | ||
4522 | |||
4523 | request->no_cck = | ||
4524 | nla_get_flag(info->attrs[NL80211_ATTR_TX_NO_CCK_RATE]); | ||
4525 | |||
4526 | request->wdev = wdev; | ||
4527 | request->wiphy = &rdev->wiphy; | 3485 | request->wiphy = &rdev->wiphy; |
4528 | request->scan_start = jiffies; | ||
4529 | 3486 | ||
4530 | rdev->scan_req = request; | 3487 | rdev->scan_req = request; |
4531 | err = rdev_scan(rdev, request); | 3488 | err = rdev->ops->scan(&rdev->wiphy, dev, request); |
4532 | 3489 | ||
4533 | if (!err) { | 3490 | if (!err) { |
4534 | nl80211_send_scan_start(rdev, wdev); | 3491 | nl80211_send_scan_start(rdev, dev); |
4535 | if (wdev->netdev) | 3492 | dev_hold(dev); |
4536 | dev_hold(wdev->netdev); | ||
4537 | } else { | 3493 | } else { |
4538 | out_free: | 3494 | out_free: |
4539 | rdev->scan_req = NULL; | 3495 | rdev->scan_req = NULL; |
@@ -4551,11 +3507,10 @@ static int nl80211_start_sched_scan(struct sk_buff *skb, | |||
4551 | struct net_device *dev = info->user_ptr[1]; | 3507 | struct net_device *dev = info->user_ptr[1]; |
4552 | struct nlattr *attr; | 3508 | struct nlattr *attr; |
4553 | struct wiphy *wiphy; | 3509 | struct wiphy *wiphy; |
4554 | int err, tmp, n_ssids = 0, n_match_sets = 0, n_channels, i; | 3510 | int err, tmp, n_ssids = 0, n_channels, i; |
4555 | u32 interval; | 3511 | u32 interval; |
4556 | enum ieee80211_band band; | 3512 | enum ieee80211_band band; |
4557 | size_t ie_len; | 3513 | size_t ie_len; |
4558 | struct nlattr *tb[NL80211_SCHED_SCAN_MATCH_ATTR_MAX + 1]; | ||
4559 | 3514 | ||
4560 | if (!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN) || | 3515 | if (!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN) || |
4561 | !rdev->ops->sched_scan_start) | 3516 | !rdev->ops->sched_scan_start) |
@@ -4594,15 +3549,6 @@ static int nl80211_start_sched_scan(struct sk_buff *skb, | |||
4594 | if (n_ssids > wiphy->max_sched_scan_ssids) | 3549 | if (n_ssids > wiphy->max_sched_scan_ssids) |
4595 | return -EINVAL; | 3550 | return -EINVAL; |
4596 | 3551 | ||
4597 | if (info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH]) | ||
4598 | nla_for_each_nested(attr, | ||
4599 | info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH], | ||
4600 | tmp) | ||
4601 | n_match_sets++; | ||
4602 | |||
4603 | if (n_match_sets > wiphy->max_match_sets) | ||
4604 | return -EINVAL; | ||
4605 | |||
4606 | if (info->attrs[NL80211_ATTR_IE]) | 3552 | if (info->attrs[NL80211_ATTR_IE]) |
4607 | ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); | 3553 | ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); |
4608 | else | 3554 | else |
@@ -4620,7 +3566,6 @@ static int nl80211_start_sched_scan(struct sk_buff *skb, | |||
4620 | 3566 | ||
4621 | request = kzalloc(sizeof(*request) | 3567 | request = kzalloc(sizeof(*request) |
4622 | + sizeof(*request->ssids) * n_ssids | 3568 | + sizeof(*request->ssids) * n_ssids |
4623 | + sizeof(*request->match_sets) * n_match_sets | ||
4624 | + sizeof(*request->channels) * n_channels | 3569 | + sizeof(*request->channels) * n_channels |
4625 | + ie_len, GFP_KERNEL); | 3570 | + ie_len, GFP_KERNEL); |
4626 | if (!request) { | 3571 | if (!request) { |
@@ -4638,18 +3583,6 @@ static int nl80211_start_sched_scan(struct sk_buff *skb, | |||
4638 | request->ie = (void *)(request->channels + n_channels); | 3583 | request->ie = (void *)(request->channels + n_channels); |
4639 | } | 3584 | } |
4640 | 3585 | ||
4641 | if (n_match_sets) { | ||
4642 | if (request->ie) | ||
4643 | request->match_sets = (void *)(request->ie + ie_len); | ||
4644 | else if (request->ssids) | ||
4645 | request->match_sets = | ||
4646 | (void *)(request->ssids + n_ssids); | ||
4647 | else | ||
4648 | request->match_sets = | ||
4649 | (void *)(request->channels + n_channels); | ||
4650 | } | ||
4651 | request->n_match_sets = n_match_sets; | ||
4652 | |||
4653 | i = 0; | 3586 | i = 0; |
4654 | if (info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]) { | 3587 | if (info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]) { |
4655 | /* user specified, bail out if channel not found */ | 3588 | /* user specified, bail out if channel not found */ |
@@ -4714,37 +3647,6 @@ static int nl80211_start_sched_scan(struct sk_buff *skb, | |||
4714 | } | 3647 | } |
4715 | } | 3648 | } |
4716 | 3649 | ||
4717 | i = 0; | ||
4718 | if (info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH]) { | ||
4719 | nla_for_each_nested(attr, | ||
4720 | info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH], | ||
4721 | tmp) { | ||
4722 | struct nlattr *ssid, *rssi; | ||
4723 | |||
4724 | nla_parse(tb, NL80211_SCHED_SCAN_MATCH_ATTR_MAX, | ||
4725 | nla_data(attr), nla_len(attr), | ||
4726 | nl80211_match_policy); | ||
4727 | ssid = tb[NL80211_SCHED_SCAN_MATCH_ATTR_SSID]; | ||
4728 | if (ssid) { | ||
4729 | if (nla_len(ssid) > IEEE80211_MAX_SSID_LEN) { | ||
4730 | err = -EINVAL; | ||
4731 | goto out_free; | ||
4732 | } | ||
4733 | memcpy(request->match_sets[i].ssid.ssid, | ||
4734 | nla_data(ssid), nla_len(ssid)); | ||
4735 | request->match_sets[i].ssid.ssid_len = | ||
4736 | nla_len(ssid); | ||
4737 | } | ||
4738 | rssi = tb[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI]; | ||
4739 | if (rssi) | ||
4740 | request->rssi_thold = nla_get_u32(rssi); | ||
4741 | else | ||
4742 | request->rssi_thold = | ||
4743 | NL80211_SCAN_RSSI_THOLD_OFF; | ||
4744 | i++; | ||
4745 | } | ||
4746 | } | ||
4747 | |||
4748 | if (info->attrs[NL80211_ATTR_IE]) { | 3650 | if (info->attrs[NL80211_ATTR_IE]) { |
4749 | request->ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); | 3651 | request->ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); |
4750 | memcpy((void *)request->ie, | 3652 | memcpy((void *)request->ie, |
@@ -4752,24 +3654,11 @@ static int nl80211_start_sched_scan(struct sk_buff *skb, | |||
4752 | request->ie_len); | 3654 | request->ie_len); |
4753 | } | 3655 | } |
4754 | 3656 | ||
4755 | if (info->attrs[NL80211_ATTR_SCAN_FLAGS]) { | ||
4756 | request->flags = nla_get_u32( | ||
4757 | info->attrs[NL80211_ATTR_SCAN_FLAGS]); | ||
4758 | if (((request->flags & NL80211_SCAN_FLAG_LOW_PRIORITY) && | ||
4759 | !(wiphy->features & NL80211_FEATURE_LOW_PRIORITY_SCAN)) || | ||
4760 | ((request->flags & NL80211_SCAN_FLAG_FLUSH) && | ||
4761 | !(wiphy->features & NL80211_FEATURE_SCAN_FLUSH))) { | ||
4762 | err = -EOPNOTSUPP; | ||
4763 | goto out_free; | ||
4764 | } | ||
4765 | } | ||
4766 | |||
4767 | request->dev = dev; | 3657 | request->dev = dev; |
4768 | request->wiphy = &rdev->wiphy; | 3658 | request->wiphy = &rdev->wiphy; |
4769 | request->interval = interval; | 3659 | request->interval = interval; |
4770 | request->scan_start = jiffies; | ||
4771 | 3660 | ||
4772 | err = rdev_sched_scan_start(rdev, dev, request); | 3661 | err = rdev->ops->sched_scan_start(&rdev->wiphy, dev, request); |
4773 | if (!err) { | 3662 | if (!err) { |
4774 | rdev->sched_scan_req = request; | 3663 | rdev->sched_scan_req = request; |
4775 | nl80211_send_sched_scan(rdev, dev, | 3664 | nl80211_send_sched_scan(rdev, dev, |
@@ -4808,65 +3697,50 @@ static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb, | |||
4808 | struct cfg80211_internal_bss *intbss) | 3697 | struct cfg80211_internal_bss *intbss) |
4809 | { | 3698 | { |
4810 | struct cfg80211_bss *res = &intbss->pub; | 3699 | struct cfg80211_bss *res = &intbss->pub; |
4811 | const struct cfg80211_bss_ies *ies; | ||
4812 | void *hdr; | 3700 | void *hdr; |
4813 | struct nlattr *bss; | 3701 | struct nlattr *bss; |
3702 | int i; | ||
4814 | 3703 | ||
4815 | ASSERT_WDEV_LOCK(wdev); | 3704 | ASSERT_WDEV_LOCK(wdev); |
4816 | 3705 | ||
4817 | hdr = nl80211hdr_put(msg, NETLINK_CB(cb->skb).portid, seq, flags, | 3706 | hdr = nl80211hdr_put(msg, NETLINK_CB(cb->skb).pid, seq, flags, |
4818 | NL80211_CMD_NEW_SCAN_RESULTS); | 3707 | NL80211_CMD_NEW_SCAN_RESULTS); |
4819 | if (!hdr) | 3708 | if (!hdr) |
4820 | return -1; | 3709 | return -1; |
4821 | 3710 | ||
4822 | genl_dump_check_consistent(cb, hdr, &nl80211_fam); | 3711 | genl_dump_check_consistent(cb, hdr, &nl80211_fam); |
4823 | 3712 | ||
4824 | if (nla_put_u32(msg, NL80211_ATTR_GENERATION, rdev->bss_generation) || | 3713 | NLA_PUT_U32(msg, NL80211_ATTR_GENERATION, rdev->bss_generation); |
4825 | nla_put_u32(msg, NL80211_ATTR_IFINDEX, wdev->netdev->ifindex)) | 3714 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, wdev->netdev->ifindex); |
4826 | goto nla_put_failure; | ||
4827 | 3715 | ||
4828 | bss = nla_nest_start(msg, NL80211_ATTR_BSS); | 3716 | bss = nla_nest_start(msg, NL80211_ATTR_BSS); |
4829 | if (!bss) | 3717 | if (!bss) |
4830 | goto nla_put_failure; | 3718 | goto nla_put_failure; |
4831 | if ((!is_zero_ether_addr(res->bssid) && | 3719 | if (!is_zero_ether_addr(res->bssid)) |
4832 | nla_put(msg, NL80211_BSS_BSSID, ETH_ALEN, res->bssid))) | 3720 | NLA_PUT(msg, NL80211_BSS_BSSID, ETH_ALEN, res->bssid); |
4833 | goto nla_put_failure; | 3721 | if (res->information_elements && res->len_information_elements) |
4834 | 3722 | NLA_PUT(msg, NL80211_BSS_INFORMATION_ELEMENTS, | |
4835 | rcu_read_lock(); | 3723 | res->len_information_elements, |
4836 | ies = rcu_dereference(res->ies); | 3724 | res->information_elements); |
4837 | if (ies && ies->len && nla_put(msg, NL80211_BSS_INFORMATION_ELEMENTS, | 3725 | if (res->beacon_ies && res->len_beacon_ies && |
4838 | ies->len, ies->data)) { | 3726 | res->beacon_ies != res->information_elements) |
4839 | rcu_read_unlock(); | 3727 | NLA_PUT(msg, NL80211_BSS_BEACON_IES, |
4840 | goto nla_put_failure; | 3728 | res->len_beacon_ies, res->beacon_ies); |
4841 | } | 3729 | if (res->tsf) |
4842 | ies = rcu_dereference(res->beacon_ies); | 3730 | NLA_PUT_U64(msg, NL80211_BSS_TSF, res->tsf); |
4843 | if (ies && ies->len && nla_put(msg, NL80211_BSS_BEACON_IES, | 3731 | if (res->beacon_interval) |
4844 | ies->len, ies->data)) { | 3732 | NLA_PUT_U16(msg, NL80211_BSS_BEACON_INTERVAL, res->beacon_interval); |
4845 | rcu_read_unlock(); | 3733 | NLA_PUT_U16(msg, NL80211_BSS_CAPABILITY, res->capability); |
4846 | goto nla_put_failure; | 3734 | NLA_PUT_U32(msg, NL80211_BSS_FREQUENCY, res->channel->center_freq); |
4847 | } | 3735 | NLA_PUT_U32(msg, NL80211_BSS_SEEN_MS_AGO, |
4848 | rcu_read_unlock(); | 3736 | jiffies_to_msecs(jiffies - intbss->ts)); |
4849 | |||
4850 | if (res->tsf && | ||
4851 | nla_put_u64(msg, NL80211_BSS_TSF, res->tsf)) | ||
4852 | goto nla_put_failure; | ||
4853 | if (res->beacon_interval && | ||
4854 | nla_put_u16(msg, NL80211_BSS_BEACON_INTERVAL, res->beacon_interval)) | ||
4855 | goto nla_put_failure; | ||
4856 | if (nla_put_u16(msg, NL80211_BSS_CAPABILITY, res->capability) || | ||
4857 | nla_put_u32(msg, NL80211_BSS_FREQUENCY, res->channel->center_freq) || | ||
4858 | nla_put_u32(msg, NL80211_BSS_SEEN_MS_AGO, | ||
4859 | jiffies_to_msecs(jiffies - intbss->ts))) | ||
4860 | goto nla_put_failure; | ||
4861 | 3737 | ||
4862 | switch (rdev->wiphy.signal_type) { | 3738 | switch (rdev->wiphy.signal_type) { |
4863 | case CFG80211_SIGNAL_TYPE_MBM: | 3739 | case CFG80211_SIGNAL_TYPE_MBM: |
4864 | if (nla_put_u32(msg, NL80211_BSS_SIGNAL_MBM, res->signal)) | 3740 | NLA_PUT_U32(msg, NL80211_BSS_SIGNAL_MBM, res->signal); |
4865 | goto nla_put_failure; | ||
4866 | break; | 3741 | break; |
4867 | case CFG80211_SIGNAL_TYPE_UNSPEC: | 3742 | case CFG80211_SIGNAL_TYPE_UNSPEC: |
4868 | if (nla_put_u8(msg, NL80211_BSS_SIGNAL_UNSPEC, res->signal)) | 3743 | NLA_PUT_U8(msg, NL80211_BSS_SIGNAL_UNSPEC, res->signal); |
4869 | goto nla_put_failure; | ||
4870 | break; | 3744 | break; |
4871 | default: | 3745 | default: |
4872 | break; | 3746 | break; |
@@ -4875,16 +3749,21 @@ static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb, | |||
4875 | switch (wdev->iftype) { | 3749 | switch (wdev->iftype) { |
4876 | case NL80211_IFTYPE_P2P_CLIENT: | 3750 | case NL80211_IFTYPE_P2P_CLIENT: |
4877 | case NL80211_IFTYPE_STATION: | 3751 | case NL80211_IFTYPE_STATION: |
4878 | if (intbss == wdev->current_bss && | 3752 | if (intbss == wdev->current_bss) |
4879 | nla_put_u32(msg, NL80211_BSS_STATUS, | 3753 | NLA_PUT_U32(msg, NL80211_BSS_STATUS, |
4880 | NL80211_BSS_STATUS_ASSOCIATED)) | 3754 | NL80211_BSS_STATUS_ASSOCIATED); |
4881 | goto nla_put_failure; | 3755 | else for (i = 0; i < MAX_AUTH_BSSES; i++) { |
3756 | if (intbss != wdev->auth_bsses[i]) | ||
3757 | continue; | ||
3758 | NLA_PUT_U32(msg, NL80211_BSS_STATUS, | ||
3759 | NL80211_BSS_STATUS_AUTHENTICATED); | ||
3760 | break; | ||
3761 | } | ||
4882 | break; | 3762 | break; |
4883 | case NL80211_IFTYPE_ADHOC: | 3763 | case NL80211_IFTYPE_ADHOC: |
4884 | if (intbss == wdev->current_bss && | 3764 | if (intbss == wdev->current_bss) |
4885 | nla_put_u32(msg, NL80211_BSS_STATUS, | 3765 | NLA_PUT_U32(msg, NL80211_BSS_STATUS, |
4886 | NL80211_BSS_STATUS_IBSS_JOINED)) | 3766 | NL80211_BSS_STATUS_IBSS_JOINED); |
4887 | goto nla_put_failure; | ||
4888 | break; | 3767 | break; |
4889 | default: | 3768 | default: |
4890 | break; | 3769 | break; |
@@ -4941,55 +3820,46 @@ static int nl80211_dump_scan(struct sk_buff *skb, | |||
4941 | return skb->len; | 3820 | return skb->len; |
4942 | } | 3821 | } |
4943 | 3822 | ||
4944 | static int nl80211_send_survey(struct sk_buff *msg, u32 portid, u32 seq, | 3823 | static int nl80211_send_survey(struct sk_buff *msg, u32 pid, u32 seq, |
4945 | int flags, struct net_device *dev, | 3824 | int flags, struct net_device *dev, |
4946 | struct survey_info *survey) | 3825 | struct survey_info *survey) |
4947 | { | 3826 | { |
4948 | void *hdr; | 3827 | void *hdr; |
4949 | struct nlattr *infoattr; | 3828 | struct nlattr *infoattr; |
4950 | 3829 | ||
4951 | hdr = nl80211hdr_put(msg, portid, seq, flags, | 3830 | hdr = nl80211hdr_put(msg, pid, seq, flags, |
4952 | NL80211_CMD_NEW_SURVEY_RESULTS); | 3831 | NL80211_CMD_NEW_SURVEY_RESULTS); |
4953 | if (!hdr) | 3832 | if (!hdr) |
4954 | return -ENOMEM; | 3833 | return -ENOMEM; |
4955 | 3834 | ||
4956 | if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex)) | 3835 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); |
4957 | goto nla_put_failure; | ||
4958 | 3836 | ||
4959 | infoattr = nla_nest_start(msg, NL80211_ATTR_SURVEY_INFO); | 3837 | infoattr = nla_nest_start(msg, NL80211_ATTR_SURVEY_INFO); |
4960 | if (!infoattr) | 3838 | if (!infoattr) |
4961 | goto nla_put_failure; | 3839 | goto nla_put_failure; |
4962 | 3840 | ||
4963 | if (nla_put_u32(msg, NL80211_SURVEY_INFO_FREQUENCY, | 3841 | NLA_PUT_U32(msg, NL80211_SURVEY_INFO_FREQUENCY, |
4964 | survey->channel->center_freq)) | 3842 | survey->channel->center_freq); |
4965 | goto nla_put_failure; | 3843 | if (survey->filled & SURVEY_INFO_NOISE_DBM) |
4966 | 3844 | NLA_PUT_U8(msg, NL80211_SURVEY_INFO_NOISE, | |
4967 | if ((survey->filled & SURVEY_INFO_NOISE_DBM) && | 3845 | survey->noise); |
4968 | nla_put_u8(msg, NL80211_SURVEY_INFO_NOISE, survey->noise)) | 3846 | if (survey->filled & SURVEY_INFO_IN_USE) |
4969 | goto nla_put_failure; | 3847 | NLA_PUT_FLAG(msg, NL80211_SURVEY_INFO_IN_USE); |
4970 | if ((survey->filled & SURVEY_INFO_IN_USE) && | 3848 | if (survey->filled & SURVEY_INFO_CHANNEL_TIME) |
4971 | nla_put_flag(msg, NL80211_SURVEY_INFO_IN_USE)) | 3849 | NLA_PUT_U64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME, |
4972 | goto nla_put_failure; | 3850 | survey->channel_time); |
4973 | if ((survey->filled & SURVEY_INFO_CHANNEL_TIME) && | 3851 | if (survey->filled & SURVEY_INFO_CHANNEL_TIME_BUSY) |
4974 | nla_put_u64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME, | 3852 | NLA_PUT_U64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY, |
4975 | survey->channel_time)) | 3853 | survey->channel_time_busy); |
4976 | goto nla_put_failure; | 3854 | if (survey->filled & SURVEY_INFO_CHANNEL_TIME_EXT_BUSY) |
4977 | if ((survey->filled & SURVEY_INFO_CHANNEL_TIME_BUSY) && | 3855 | NLA_PUT_U64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY, |
4978 | nla_put_u64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY, | 3856 | survey->channel_time_ext_busy); |
4979 | survey->channel_time_busy)) | 3857 | if (survey->filled & SURVEY_INFO_CHANNEL_TIME_RX) |
4980 | goto nla_put_failure; | 3858 | NLA_PUT_U64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME_RX, |
4981 | if ((survey->filled & SURVEY_INFO_CHANNEL_TIME_EXT_BUSY) && | 3859 | survey->channel_time_rx); |
4982 | nla_put_u64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY, | 3860 | if (survey->filled & SURVEY_INFO_CHANNEL_TIME_TX) |
4983 | survey->channel_time_ext_busy)) | 3861 | NLA_PUT_U64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME_TX, |
4984 | goto nla_put_failure; | 3862 | survey->channel_time_tx); |
4985 | if ((survey->filled & SURVEY_INFO_CHANNEL_TIME_RX) && | ||
4986 | nla_put_u64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME_RX, | ||
4987 | survey->channel_time_rx)) | ||
4988 | goto nla_put_failure; | ||
4989 | if ((survey->filled & SURVEY_INFO_CHANNEL_TIME_TX) && | ||
4990 | nla_put_u64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME_TX, | ||
4991 | survey->channel_time_tx)) | ||
4992 | goto nla_put_failure; | ||
4993 | 3863 | ||
4994 | nla_nest_end(msg, infoattr); | 3864 | nla_nest_end(msg, infoattr); |
4995 | 3865 | ||
@@ -5021,7 +3891,8 @@ static int nl80211_dump_survey(struct sk_buff *skb, | |||
5021 | while (1) { | 3891 | while (1) { |
5022 | struct ieee80211_channel *chan; | 3892 | struct ieee80211_channel *chan; |
5023 | 3893 | ||
5024 | res = rdev_dump_survey(dev, netdev, survey_idx, &survey); | 3894 | res = dev->ops->dump_survey(&dev->wiphy, netdev, survey_idx, |
3895 | &survey); | ||
5025 | if (res == -ENOENT) | 3896 | if (res == -ENOENT) |
5026 | break; | 3897 | break; |
5027 | if (res) | 3898 | if (res) |
@@ -5041,7 +3912,7 @@ static int nl80211_dump_survey(struct sk_buff *skb, | |||
5041 | } | 3912 | } |
5042 | 3913 | ||
5043 | if (nl80211_send_survey(skb, | 3914 | if (nl80211_send_survey(skb, |
5044 | NETLINK_CB(cb->skb).portid, | 3915 | NETLINK_CB(cb->skb).pid, |
5045 | cb->nlh->nlmsg_seq, NLM_F_MULTI, | 3916 | cb->nlh->nlmsg_seq, NLM_F_MULTI, |
5046 | netdev, | 3917 | netdev, |
5047 | &survey) < 0) | 3918 | &survey) < 0) |
@@ -5057,19 +3928,40 @@ static int nl80211_dump_survey(struct sk_buff *skb, | |||
5057 | return res; | 3928 | return res; |
5058 | } | 3929 | } |
5059 | 3930 | ||
3931 | static bool nl80211_valid_auth_type(enum nl80211_auth_type auth_type) | ||
3932 | { | ||
3933 | return auth_type <= NL80211_AUTHTYPE_MAX; | ||
3934 | } | ||
3935 | |||
5060 | static bool nl80211_valid_wpa_versions(u32 wpa_versions) | 3936 | static bool nl80211_valid_wpa_versions(u32 wpa_versions) |
5061 | { | 3937 | { |
5062 | return !(wpa_versions & ~(NL80211_WPA_VERSION_1 | | 3938 | return !(wpa_versions & ~(NL80211_WPA_VERSION_1 | |
5063 | NL80211_WPA_VERSION_2)); | 3939 | NL80211_WPA_VERSION_2)); |
5064 | } | 3940 | } |
5065 | 3941 | ||
3942 | static bool nl80211_valid_akm_suite(u32 akm) | ||
3943 | { | ||
3944 | return akm == WLAN_AKM_SUITE_8021X || | ||
3945 | akm == WLAN_AKM_SUITE_PSK; | ||
3946 | } | ||
3947 | |||
3948 | static bool nl80211_valid_cipher_suite(u32 cipher) | ||
3949 | { | ||
3950 | return cipher == WLAN_CIPHER_SUITE_WEP40 || | ||
3951 | cipher == WLAN_CIPHER_SUITE_WEP104 || | ||
3952 | cipher == WLAN_CIPHER_SUITE_TKIP || | ||
3953 | cipher == WLAN_CIPHER_SUITE_CCMP || | ||
3954 | cipher == WLAN_CIPHER_SUITE_AES_CMAC; | ||
3955 | } | ||
3956 | |||
3957 | |||
5066 | static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info) | 3958 | static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info) |
5067 | { | 3959 | { |
5068 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | 3960 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; |
5069 | struct net_device *dev = info->user_ptr[1]; | 3961 | struct net_device *dev = info->user_ptr[1]; |
5070 | struct ieee80211_channel *chan; | 3962 | struct ieee80211_channel *chan; |
5071 | const u8 *bssid, *ssid, *ie = NULL, *sae_data = NULL; | 3963 | const u8 *bssid, *ssid, *ie = NULL; |
5072 | int err, ssid_len, ie_len = 0, sae_data_len = 0; | 3964 | int err, ssid_len, ie_len = 0; |
5073 | enum nl80211_auth_type auth_type; | 3965 | enum nl80211_auth_type auth_type; |
5074 | struct key_parse key; | 3966 | struct key_parse key; |
5075 | bool local_state_change; | 3967 | bool local_state_change; |
@@ -5145,36 +4037,15 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info) | |||
5145 | } | 4037 | } |
5146 | 4038 | ||
5147 | auth_type = nla_get_u32(info->attrs[NL80211_ATTR_AUTH_TYPE]); | 4039 | auth_type = nla_get_u32(info->attrs[NL80211_ATTR_AUTH_TYPE]); |
5148 | if (!nl80211_valid_auth_type(rdev, auth_type, NL80211_CMD_AUTHENTICATE)) | 4040 | if (!nl80211_valid_auth_type(auth_type)) |
5149 | return -EINVAL; | ||
5150 | |||
5151 | if (auth_type == NL80211_AUTHTYPE_SAE && | ||
5152 | !info->attrs[NL80211_ATTR_SAE_DATA]) | ||
5153 | return -EINVAL; | 4041 | return -EINVAL; |
5154 | 4042 | ||
5155 | if (info->attrs[NL80211_ATTR_SAE_DATA]) { | ||
5156 | if (auth_type != NL80211_AUTHTYPE_SAE) | ||
5157 | return -EINVAL; | ||
5158 | sae_data = nla_data(info->attrs[NL80211_ATTR_SAE_DATA]); | ||
5159 | sae_data_len = nla_len(info->attrs[NL80211_ATTR_SAE_DATA]); | ||
5160 | /* need to include at least Auth Transaction and Status Code */ | ||
5161 | if (sae_data_len < 4) | ||
5162 | return -EINVAL; | ||
5163 | } | ||
5164 | |||
5165 | local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE]; | 4043 | local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE]; |
5166 | 4044 | ||
5167 | /* | ||
5168 | * Since we no longer track auth state, ignore | ||
5169 | * requests to only change local state. | ||
5170 | */ | ||
5171 | if (local_state_change) | ||
5172 | return 0; | ||
5173 | |||
5174 | return cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid, | 4045 | return cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid, |
5175 | ssid, ssid_len, ie, ie_len, | 4046 | ssid, ssid_len, ie, ie_len, |
5176 | key.p.key, key.p.key_len, key.idx, | 4047 | key.p.key, key.p.key_len, key.idx, |
5177 | sae_data, sae_data_len); | 4048 | local_state_change); |
5178 | } | 4049 | } |
5179 | 4050 | ||
5180 | static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev, | 4051 | static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev, |
@@ -5216,8 +4087,7 @@ static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev, | |||
5216 | memcpy(settings->ciphers_pairwise, data, len); | 4087 | memcpy(settings->ciphers_pairwise, data, len); |
5217 | 4088 | ||
5218 | for (i = 0; i < settings->n_ciphers_pairwise; i++) | 4089 | for (i = 0; i < settings->n_ciphers_pairwise; i++) |
5219 | if (!cfg80211_supported_cipher_suite( | 4090 | if (!nl80211_valid_cipher_suite( |
5220 | &rdev->wiphy, | ||
5221 | settings->ciphers_pairwise[i])) | 4091 | settings->ciphers_pairwise[i])) |
5222 | return -EINVAL; | 4092 | return -EINVAL; |
5223 | } | 4093 | } |
@@ -5225,8 +4095,7 @@ static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev, | |||
5225 | if (info->attrs[NL80211_ATTR_CIPHER_SUITE_GROUP]) { | 4095 | if (info->attrs[NL80211_ATTR_CIPHER_SUITE_GROUP]) { |
5226 | settings->cipher_group = | 4096 | settings->cipher_group = |
5227 | nla_get_u32(info->attrs[NL80211_ATTR_CIPHER_SUITE_GROUP]); | 4097 | nla_get_u32(info->attrs[NL80211_ATTR_CIPHER_SUITE_GROUP]); |
5228 | if (!cfg80211_supported_cipher_suite(&rdev->wiphy, | 4098 | if (!nl80211_valid_cipher_suite(settings->cipher_group)) |
5229 | settings->cipher_group)) | ||
5230 | return -EINVAL; | 4099 | return -EINVAL; |
5231 | } | 4100 | } |
5232 | 4101 | ||
@@ -5239,7 +4108,7 @@ static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev, | |||
5239 | 4108 | ||
5240 | if (info->attrs[NL80211_ATTR_AKM_SUITES]) { | 4109 | if (info->attrs[NL80211_ATTR_AKM_SUITES]) { |
5241 | void *data; | 4110 | void *data; |
5242 | int len; | 4111 | int len, i; |
5243 | 4112 | ||
5244 | data = nla_data(info->attrs[NL80211_ATTR_AKM_SUITES]); | 4113 | data = nla_data(info->attrs[NL80211_ATTR_AKM_SUITES]); |
5245 | len = nla_len(info->attrs[NL80211_ATTR_AKM_SUITES]); | 4114 | len = nla_len(info->attrs[NL80211_ATTR_AKM_SUITES]); |
@@ -5252,6 +4121,10 @@ static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev, | |||
5252 | return -EINVAL; | 4121 | return -EINVAL; |
5253 | 4122 | ||
5254 | memcpy(settings->akm_suites, data, len); | 4123 | memcpy(settings->akm_suites, data, len); |
4124 | |||
4125 | for (i = 0; i < settings->n_akm_suites; i++) | ||
4126 | if (!nl80211_valid_akm_suite(settings->akm_suites[i])) | ||
4127 | return -EINVAL; | ||
5255 | } | 4128 | } |
5256 | 4129 | ||
5257 | return 0; | 4130 | return 0; |
@@ -5266,9 +4139,6 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info) | |||
5266 | const u8 *bssid, *ssid, *ie = NULL, *prev_bssid = NULL; | 4139 | const u8 *bssid, *ssid, *ie = NULL, *prev_bssid = NULL; |
5267 | int err, ssid_len, ie_len = 0; | 4140 | int err, ssid_len, ie_len = 0; |
5268 | bool use_mfp = false; | 4141 | bool use_mfp = false; |
5269 | u32 flags = 0; | ||
5270 | struct ieee80211_ht_cap *ht_capa = NULL; | ||
5271 | struct ieee80211_ht_cap *ht_capa_mask = NULL; | ||
5272 | 4142 | ||
5273 | if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE])) | 4143 | if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE])) |
5274 | return -EINVAL; | 4144 | return -EINVAL; |
@@ -5312,25 +4182,11 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info) | |||
5312 | if (info->attrs[NL80211_ATTR_PREV_BSSID]) | 4182 | if (info->attrs[NL80211_ATTR_PREV_BSSID]) |
5313 | prev_bssid = nla_data(info->attrs[NL80211_ATTR_PREV_BSSID]); | 4183 | prev_bssid = nla_data(info->attrs[NL80211_ATTR_PREV_BSSID]); |
5314 | 4184 | ||
5315 | if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_HT])) | ||
5316 | flags |= ASSOC_REQ_DISABLE_HT; | ||
5317 | |||
5318 | if (info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]) | ||
5319 | ht_capa_mask = | ||
5320 | nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]); | ||
5321 | |||
5322 | if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) { | ||
5323 | if (!ht_capa_mask) | ||
5324 | return -EINVAL; | ||
5325 | ht_capa = nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]); | ||
5326 | } | ||
5327 | |||
5328 | err = nl80211_crypto_settings(rdev, info, &crypto, 1); | 4185 | err = nl80211_crypto_settings(rdev, info, &crypto, 1); |
5329 | if (!err) | 4186 | if (!err) |
5330 | err = cfg80211_mlme_assoc(rdev, dev, chan, bssid, prev_bssid, | 4187 | err = cfg80211_mlme_assoc(rdev, dev, chan, bssid, prev_bssid, |
5331 | ssid, ssid_len, ie, ie_len, use_mfp, | 4188 | ssid, ssid_len, ie, ie_len, use_mfp, |
5332 | &crypto, flags, ht_capa, | 4189 | &crypto); |
5333 | ht_capa_mask); | ||
5334 | 4190 | ||
5335 | return err; | 4191 | return err; |
5336 | } | 4192 | } |
@@ -5465,7 +4321,8 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info) | |||
5465 | if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE])) | 4321 | if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE])) |
5466 | return -EINVAL; | 4322 | return -EINVAL; |
5467 | 4323 | ||
5468 | if (!info->attrs[NL80211_ATTR_SSID] || | 4324 | if (!info->attrs[NL80211_ATTR_WIPHY_FREQ] || |
4325 | !info->attrs[NL80211_ATTR_SSID] || | ||
5469 | !nla_len(info->attrs[NL80211_ATTR_SSID])) | 4326 | !nla_len(info->attrs[NL80211_ATTR_SSID])) |
5470 | return -EINVAL; | 4327 | return -EINVAL; |
5471 | 4328 | ||
@@ -5486,12 +4343,8 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info) | |||
5486 | 4343 | ||
5487 | wiphy = &rdev->wiphy; | 4344 | wiphy = &rdev->wiphy; |
5488 | 4345 | ||
5489 | if (info->attrs[NL80211_ATTR_MAC]) { | 4346 | if (info->attrs[NL80211_ATTR_MAC]) |
5490 | ibss.bssid = nla_data(info->attrs[NL80211_ATTR_MAC]); | 4347 | ibss.bssid = nla_data(info->attrs[NL80211_ATTR_MAC]); |
5491 | |||
5492 | if (!is_valid_ether_addr(ibss.bssid)) | ||
5493 | return -EINVAL; | ||
5494 | } | ||
5495 | ibss.ssid = nla_data(info->attrs[NL80211_ATTR_SSID]); | 4348 | ibss.ssid = nla_data(info->attrs[NL80211_ATTR_SSID]); |
5496 | ibss.ssid_len = nla_len(info->attrs[NL80211_ATTR_SSID]); | 4349 | ibss.ssid_len = nla_len(info->attrs[NL80211_ATTR_SSID]); |
5497 | 4350 | ||
@@ -5500,17 +4353,11 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info) | |||
5500 | ibss.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); | 4353 | ibss.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); |
5501 | } | 4354 | } |
5502 | 4355 | ||
5503 | err = nl80211_parse_chandef(rdev, info, &ibss.chandef); | 4356 | ibss.channel = ieee80211_get_channel(wiphy, |
5504 | if (err) | 4357 | nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ])); |
5505 | return err; | 4358 | if (!ibss.channel || |
5506 | 4359 | ibss.channel->flags & IEEE80211_CHAN_NO_IBSS || | |
5507 | if (!cfg80211_reg_can_beacon(&rdev->wiphy, &ibss.chandef)) | 4360 | ibss.channel->flags & IEEE80211_CHAN_DISABLED) |
5508 | return -EINVAL; | ||
5509 | |||
5510 | if (ibss.chandef.width > NL80211_CHAN_WIDTH_40) | ||
5511 | return -EINVAL; | ||
5512 | if (ibss.chandef.width != NL80211_CHAN_WIDTH_20_NOHT && | ||
5513 | !(rdev->wiphy.features & NL80211_FEATURE_HT_IBSS)) | ||
5514 | return -EINVAL; | 4361 | return -EINVAL; |
5515 | 4362 | ||
5516 | ibss.channel_fixed = !!info->attrs[NL80211_ATTR_FREQ_FIXED]; | 4363 | ibss.channel_fixed = !!info->attrs[NL80211_ATTR_FREQ_FIXED]; |
@@ -5522,7 +4369,8 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info) | |||
5522 | int n_rates = | 4369 | int n_rates = |
5523 | nla_len(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]); | 4370 | nla_len(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]); |
5524 | struct ieee80211_supported_band *sband = | 4371 | struct ieee80211_supported_band *sband = |
5525 | wiphy->bands[ibss.chandef.chan->band]; | 4372 | wiphy->bands[ibss.channel->band]; |
4373 | int err; | ||
5526 | 4374 | ||
5527 | err = ieee80211_get_ratemask(sband, rates, n_rates, | 4375 | err = ieee80211_get_ratemask(sband, rates, n_rates, |
5528 | &ibss.basic_rates); | 4376 | &ibss.basic_rates); |
@@ -5536,24 +4384,12 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info) | |||
5536 | return -EINVAL; | 4384 | return -EINVAL; |
5537 | 4385 | ||
5538 | if (ibss.privacy && info->attrs[NL80211_ATTR_KEYS]) { | 4386 | if (ibss.privacy && info->attrs[NL80211_ATTR_KEYS]) { |
5539 | bool no_ht = false; | ||
5540 | |||
5541 | connkeys = nl80211_parse_connkeys(rdev, | 4387 | connkeys = nl80211_parse_connkeys(rdev, |
5542 | info->attrs[NL80211_ATTR_KEYS], | 4388 | info->attrs[NL80211_ATTR_KEYS]); |
5543 | &no_ht); | ||
5544 | if (IS_ERR(connkeys)) | 4389 | if (IS_ERR(connkeys)) |
5545 | return PTR_ERR(connkeys); | 4390 | return PTR_ERR(connkeys); |
5546 | |||
5547 | if ((ibss.chandef.width != NL80211_CHAN_WIDTH_20_NOHT) && | ||
5548 | no_ht) { | ||
5549 | kfree(connkeys); | ||
5550 | return -EINVAL; | ||
5551 | } | ||
5552 | } | 4391 | } |
5553 | 4392 | ||
5554 | ibss.control_port = | ||
5555 | nla_get_flag(info->attrs[NL80211_ATTR_CONTROL_PORT]); | ||
5556 | |||
5557 | err = cfg80211_join_ibss(rdev, dev, &ibss, connkeys); | 4393 | err = cfg80211_join_ibss(rdev, dev, &ibss, connkeys); |
5558 | if (err) | 4394 | if (err) |
5559 | kfree(connkeys); | 4395 | kfree(connkeys); |
@@ -5574,36 +4410,6 @@ static int nl80211_leave_ibss(struct sk_buff *skb, struct genl_info *info) | |||
5574 | return cfg80211_leave_ibss(rdev, dev, false); | 4410 | return cfg80211_leave_ibss(rdev, dev, false); |
5575 | } | 4411 | } |
5576 | 4412 | ||
5577 | static int nl80211_set_mcast_rate(struct sk_buff *skb, struct genl_info *info) | ||
5578 | { | ||
5579 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | ||
5580 | struct net_device *dev = info->user_ptr[1]; | ||
5581 | int mcast_rate[IEEE80211_NUM_BANDS]; | ||
5582 | u32 nla_rate; | ||
5583 | int err; | ||
5584 | |||
5585 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_ADHOC && | ||
5586 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) | ||
5587 | return -EOPNOTSUPP; | ||
5588 | |||
5589 | if (!rdev->ops->set_mcast_rate) | ||
5590 | return -EOPNOTSUPP; | ||
5591 | |||
5592 | memset(mcast_rate, 0, sizeof(mcast_rate)); | ||
5593 | |||
5594 | if (!info->attrs[NL80211_ATTR_MCAST_RATE]) | ||
5595 | return -EINVAL; | ||
5596 | |||
5597 | nla_rate = nla_get_u32(info->attrs[NL80211_ATTR_MCAST_RATE]); | ||
5598 | if (!nl80211_parse_mcast_rate(rdev, mcast_rate, nla_rate)) | ||
5599 | return -EINVAL; | ||
5600 | |||
5601 | err = rdev->ops->set_mcast_rate(&rdev->wiphy, dev, mcast_rate); | ||
5602 | |||
5603 | return err; | ||
5604 | } | ||
5605 | |||
5606 | |||
5607 | #ifdef CONFIG_NL80211_TESTMODE | 4413 | #ifdef CONFIG_NL80211_TESTMODE |
5608 | static struct genl_multicast_group nl80211_testmode_mcgrp = { | 4414 | static struct genl_multicast_group nl80211_testmode_mcgrp = { |
5609 | .name = "testmode", | 4415 | .name = "testmode", |
@@ -5620,7 +4426,7 @@ static int nl80211_testmode_do(struct sk_buff *skb, struct genl_info *info) | |||
5620 | err = -EOPNOTSUPP; | 4426 | err = -EOPNOTSUPP; |
5621 | if (rdev->ops->testmode_cmd) { | 4427 | if (rdev->ops->testmode_cmd) { |
5622 | rdev->testmode_info = info; | 4428 | rdev->testmode_info = info; |
5623 | err = rdev_testmode_cmd(rdev, | 4429 | err = rdev->ops->testmode_cmd(&rdev->wiphy, |
5624 | nla_data(info->attrs[NL80211_ATTR_TESTDATA]), | 4430 | nla_data(info->attrs[NL80211_ATTR_TESTDATA]), |
5625 | nla_len(info->attrs[NL80211_ATTR_TESTDATA])); | 4431 | nla_len(info->attrs[NL80211_ATTR_TESTDATA])); |
5626 | rdev->testmode_info = NULL; | 4432 | rdev->testmode_info = NULL; |
@@ -5632,7 +4438,7 @@ static int nl80211_testmode_do(struct sk_buff *skb, struct genl_info *info) | |||
5632 | static int nl80211_testmode_dump(struct sk_buff *skb, | 4438 | static int nl80211_testmode_dump(struct sk_buff *skb, |
5633 | struct netlink_callback *cb) | 4439 | struct netlink_callback *cb) |
5634 | { | 4440 | { |
5635 | struct cfg80211_registered_device *rdev; | 4441 | struct cfg80211_registered_device *dev; |
5636 | int err; | 4442 | int err; |
5637 | long phy_idx; | 4443 | long phy_idx; |
5638 | void *data = NULL; | 4444 | void *data = NULL; |
@@ -5650,18 +4456,9 @@ static int nl80211_testmode_dump(struct sk_buff *skb, | |||
5650 | nl80211_policy); | 4456 | nl80211_policy); |
5651 | if (err) | 4457 | if (err) |
5652 | return err; | 4458 | return err; |
5653 | 4459 | if (!nl80211_fam.attrbuf[NL80211_ATTR_WIPHY]) | |
5654 | mutex_lock(&cfg80211_mutex); | 4460 | return -EINVAL; |
5655 | rdev = __cfg80211_rdev_from_attrs(sock_net(skb->sk), | 4461 | phy_idx = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_WIPHY]); |
5656 | nl80211_fam.attrbuf); | ||
5657 | if (IS_ERR(rdev)) { | ||
5658 | mutex_unlock(&cfg80211_mutex); | ||
5659 | return PTR_ERR(rdev); | ||
5660 | } | ||
5661 | phy_idx = rdev->wiphy_idx; | ||
5662 | rdev = NULL; | ||
5663 | mutex_unlock(&cfg80211_mutex); | ||
5664 | |||
5665 | if (nl80211_fam.attrbuf[NL80211_ATTR_TESTDATA]) | 4462 | if (nl80211_fam.attrbuf[NL80211_ATTR_TESTDATA]) |
5666 | cb->args[1] = | 4463 | cb->args[1] = |
5667 | (long)nl80211_fam.attrbuf[NL80211_ATTR_TESTDATA]; | 4464 | (long)nl80211_fam.attrbuf[NL80211_ATTR_TESTDATA]; |
@@ -5673,26 +4470,26 @@ static int nl80211_testmode_dump(struct sk_buff *skb, | |||
5673 | } | 4470 | } |
5674 | 4471 | ||
5675 | mutex_lock(&cfg80211_mutex); | 4472 | mutex_lock(&cfg80211_mutex); |
5676 | rdev = cfg80211_rdev_by_wiphy_idx(phy_idx); | 4473 | dev = cfg80211_rdev_by_wiphy_idx(phy_idx); |
5677 | if (!rdev) { | 4474 | if (!dev) { |
5678 | mutex_unlock(&cfg80211_mutex); | 4475 | mutex_unlock(&cfg80211_mutex); |
5679 | return -ENOENT; | 4476 | return -ENOENT; |
5680 | } | 4477 | } |
5681 | cfg80211_lock_rdev(rdev); | 4478 | cfg80211_lock_rdev(dev); |
5682 | mutex_unlock(&cfg80211_mutex); | 4479 | mutex_unlock(&cfg80211_mutex); |
5683 | 4480 | ||
5684 | if (!rdev->ops->testmode_dump) { | 4481 | if (!dev->ops->testmode_dump) { |
5685 | err = -EOPNOTSUPP; | 4482 | err = -EOPNOTSUPP; |
5686 | goto out_err; | 4483 | goto out_err; |
5687 | } | 4484 | } |
5688 | 4485 | ||
5689 | while (1) { | 4486 | while (1) { |
5690 | void *hdr = nl80211hdr_put(skb, NETLINK_CB(cb->skb).portid, | 4487 | void *hdr = nl80211hdr_put(skb, NETLINK_CB(cb->skb).pid, |
5691 | cb->nlh->nlmsg_seq, NLM_F_MULTI, | 4488 | cb->nlh->nlmsg_seq, NLM_F_MULTI, |
5692 | NL80211_CMD_TESTMODE); | 4489 | NL80211_CMD_TESTMODE); |
5693 | struct nlattr *tmdata; | 4490 | struct nlattr *tmdata; |
5694 | 4491 | ||
5695 | if (nla_put_u32(skb, NL80211_ATTR_WIPHY, phy_idx)) { | 4492 | if (nla_put_u32(skb, NL80211_ATTR_WIPHY, dev->wiphy_idx) < 0) { |
5696 | genlmsg_cancel(skb, hdr); | 4493 | genlmsg_cancel(skb, hdr); |
5697 | break; | 4494 | break; |
5698 | } | 4495 | } |
@@ -5702,7 +4499,8 @@ static int nl80211_testmode_dump(struct sk_buff *skb, | |||
5702 | genlmsg_cancel(skb, hdr); | 4499 | genlmsg_cancel(skb, hdr); |
5703 | break; | 4500 | break; |
5704 | } | 4501 | } |
5705 | err = rdev_testmode_dump(rdev, skb, cb, data, data_len); | 4502 | err = dev->ops->testmode_dump(&dev->wiphy, skb, cb, |
4503 | data, data_len); | ||
5706 | nla_nest_end(skb, tmdata); | 4504 | nla_nest_end(skb, tmdata); |
5707 | 4505 | ||
5708 | if (err == -ENOBUFS || err == -ENOENT) { | 4506 | if (err == -ENOBUFS || err == -ENOENT) { |
@@ -5720,13 +4518,13 @@ static int nl80211_testmode_dump(struct sk_buff *skb, | |||
5720 | /* see above */ | 4518 | /* see above */ |
5721 | cb->args[0] = phy_idx + 1; | 4519 | cb->args[0] = phy_idx + 1; |
5722 | out_err: | 4520 | out_err: |
5723 | cfg80211_unlock_rdev(rdev); | 4521 | cfg80211_unlock_rdev(dev); |
5724 | return err; | 4522 | return err; |
5725 | } | 4523 | } |
5726 | 4524 | ||
5727 | static struct sk_buff * | 4525 | static struct sk_buff * |
5728 | __cfg80211_testmode_alloc_skb(struct cfg80211_registered_device *rdev, | 4526 | __cfg80211_testmode_alloc_skb(struct cfg80211_registered_device *rdev, |
5729 | int approxlen, u32 portid, u32 seq, gfp_t gfp) | 4527 | int approxlen, u32 pid, u32 seq, gfp_t gfp) |
5730 | { | 4528 | { |
5731 | struct sk_buff *skb; | 4529 | struct sk_buff *skb; |
5732 | void *hdr; | 4530 | void *hdr; |
@@ -5736,14 +4534,13 @@ __cfg80211_testmode_alloc_skb(struct cfg80211_registered_device *rdev, | |||
5736 | if (!skb) | 4534 | if (!skb) |
5737 | return NULL; | 4535 | return NULL; |
5738 | 4536 | ||
5739 | hdr = nl80211hdr_put(skb, portid, seq, 0, NL80211_CMD_TESTMODE); | 4537 | hdr = nl80211hdr_put(skb, pid, seq, 0, NL80211_CMD_TESTMODE); |
5740 | if (!hdr) { | 4538 | if (!hdr) { |
5741 | kfree_skb(skb); | 4539 | kfree_skb(skb); |
5742 | return NULL; | 4540 | return NULL; |
5743 | } | 4541 | } |
5744 | 4542 | ||
5745 | if (nla_put_u32(skb, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) | 4543 | NLA_PUT_U32(skb, NL80211_ATTR_WIPHY, rdev->wiphy_idx); |
5746 | goto nla_put_failure; | ||
5747 | data = nla_nest_start(skb, NL80211_ATTR_TESTDATA); | 4544 | data = nla_nest_start(skb, NL80211_ATTR_TESTDATA); |
5748 | 4545 | ||
5749 | ((void **)skb->cb)[0] = rdev; | 4546 | ((void **)skb->cb)[0] = rdev; |
@@ -5766,7 +4563,7 @@ struct sk_buff *cfg80211_testmode_alloc_reply_skb(struct wiphy *wiphy, | |||
5766 | return NULL; | 4563 | return NULL; |
5767 | 4564 | ||
5768 | return __cfg80211_testmode_alloc_skb(rdev, approxlen, | 4565 | return __cfg80211_testmode_alloc_skb(rdev, approxlen, |
5769 | rdev->testmode_info->snd_portid, | 4566 | rdev->testmode_info->snd_pid, |
5770 | rdev->testmode_info->snd_seq, | 4567 | rdev->testmode_info->snd_seq, |
5771 | GFP_KERNEL); | 4568 | GFP_KERNEL); |
5772 | } | 4569 | } |
@@ -5831,8 +4628,7 @@ static int nl80211_connect(struct sk_buff *skb, struct genl_info *info) | |||
5831 | if (info->attrs[NL80211_ATTR_AUTH_TYPE]) { | 4628 | if (info->attrs[NL80211_ATTR_AUTH_TYPE]) { |
5832 | connect.auth_type = | 4629 | connect.auth_type = |
5833 | nla_get_u32(info->attrs[NL80211_ATTR_AUTH_TYPE]); | 4630 | nla_get_u32(info->attrs[NL80211_ATTR_AUTH_TYPE]); |
5834 | if (!nl80211_valid_auth_type(rdev, connect.auth_type, | 4631 | if (!nl80211_valid_auth_type(connect.auth_type)) |
5835 | NL80211_CMD_CONNECT)) | ||
5836 | return -EINVAL; | 4632 | return -EINVAL; |
5837 | } else | 4633 | } else |
5838 | connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC; | 4634 | connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC; |
@@ -5850,13 +4646,6 @@ static int nl80211_connect(struct sk_buff *skb, struct genl_info *info) | |||
5850 | 4646 | ||
5851 | wiphy = &rdev->wiphy; | 4647 | wiphy = &rdev->wiphy; |
5852 | 4648 | ||
5853 | connect.bg_scan_period = -1; | ||
5854 | if (info->attrs[NL80211_ATTR_BG_SCAN_PERIOD] && | ||
5855 | (wiphy->flags & WIPHY_FLAG_SUPPORTS_FW_ROAM)) { | ||
5856 | connect.bg_scan_period = | ||
5857 | nla_get_u16(info->attrs[NL80211_ATTR_BG_SCAN_PERIOD]); | ||
5858 | } | ||
5859 | |||
5860 | if (info->attrs[NL80211_ATTR_MAC]) | 4649 | if (info->attrs[NL80211_ATTR_MAC]) |
5861 | connect.bssid = nla_data(info->attrs[NL80211_ATTR_MAC]); | 4650 | connect.bssid = nla_data(info->attrs[NL80211_ATTR_MAC]); |
5862 | connect.ssid = nla_data(info->attrs[NL80211_ATTR_SSID]); | 4651 | connect.ssid = nla_data(info->attrs[NL80211_ATTR_SSID]); |
@@ -5878,29 +4667,11 @@ static int nl80211_connect(struct sk_buff *skb, struct genl_info *info) | |||
5878 | 4667 | ||
5879 | if (connect.privacy && info->attrs[NL80211_ATTR_KEYS]) { | 4668 | if (connect.privacy && info->attrs[NL80211_ATTR_KEYS]) { |
5880 | connkeys = nl80211_parse_connkeys(rdev, | 4669 | connkeys = nl80211_parse_connkeys(rdev, |
5881 | info->attrs[NL80211_ATTR_KEYS], NULL); | 4670 | info->attrs[NL80211_ATTR_KEYS]); |
5882 | if (IS_ERR(connkeys)) | 4671 | if (IS_ERR(connkeys)) |
5883 | return PTR_ERR(connkeys); | 4672 | return PTR_ERR(connkeys); |
5884 | } | 4673 | } |
5885 | 4674 | ||
5886 | if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_HT])) | ||
5887 | connect.flags |= ASSOC_REQ_DISABLE_HT; | ||
5888 | |||
5889 | if (info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]) | ||
5890 | memcpy(&connect.ht_capa_mask, | ||
5891 | nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]), | ||
5892 | sizeof(connect.ht_capa_mask)); | ||
5893 | |||
5894 | if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) { | ||
5895 | if (!info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]) { | ||
5896 | kfree(connkeys); | ||
5897 | return -EINVAL; | ||
5898 | } | ||
5899 | memcpy(&connect.ht_capa, | ||
5900 | nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]), | ||
5901 | sizeof(connect.ht_capa)); | ||
5902 | } | ||
5903 | |||
5904 | err = cfg80211_connect(rdev, dev, &connect, connkeys); | 4675 | err = cfg80211_connect(rdev, dev, &connect, connkeys); |
5905 | if (err) | 4676 | if (err) |
5906 | kfree(connkeys); | 4677 | kfree(connkeys); |
@@ -6007,70 +4778,20 @@ static int nl80211_flush_pmksa(struct sk_buff *skb, struct genl_info *info) | |||
6007 | if (!rdev->ops->flush_pmksa) | 4778 | if (!rdev->ops->flush_pmksa) |
6008 | return -EOPNOTSUPP; | 4779 | return -EOPNOTSUPP; |
6009 | 4780 | ||
6010 | return rdev_flush_pmksa(rdev, dev); | 4781 | return rdev->ops->flush_pmksa(&rdev->wiphy, dev); |
6011 | } | ||
6012 | |||
6013 | static int nl80211_tdls_mgmt(struct sk_buff *skb, struct genl_info *info) | ||
6014 | { | ||
6015 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | ||
6016 | struct net_device *dev = info->user_ptr[1]; | ||
6017 | u8 action_code, dialog_token; | ||
6018 | u16 status_code; | ||
6019 | u8 *peer; | ||
6020 | |||
6021 | if (!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_TDLS) || | ||
6022 | !rdev->ops->tdls_mgmt) | ||
6023 | return -EOPNOTSUPP; | ||
6024 | |||
6025 | if (!info->attrs[NL80211_ATTR_TDLS_ACTION] || | ||
6026 | !info->attrs[NL80211_ATTR_STATUS_CODE] || | ||
6027 | !info->attrs[NL80211_ATTR_TDLS_DIALOG_TOKEN] || | ||
6028 | !info->attrs[NL80211_ATTR_IE] || | ||
6029 | !info->attrs[NL80211_ATTR_MAC]) | ||
6030 | return -EINVAL; | ||
6031 | |||
6032 | peer = nla_data(info->attrs[NL80211_ATTR_MAC]); | ||
6033 | action_code = nla_get_u8(info->attrs[NL80211_ATTR_TDLS_ACTION]); | ||
6034 | status_code = nla_get_u16(info->attrs[NL80211_ATTR_STATUS_CODE]); | ||
6035 | dialog_token = nla_get_u8(info->attrs[NL80211_ATTR_TDLS_DIALOG_TOKEN]); | ||
6036 | |||
6037 | return rdev_tdls_mgmt(rdev, dev, peer, action_code, | ||
6038 | dialog_token, status_code, | ||
6039 | nla_data(info->attrs[NL80211_ATTR_IE]), | ||
6040 | nla_len(info->attrs[NL80211_ATTR_IE])); | ||
6041 | } | ||
6042 | |||
6043 | static int nl80211_tdls_oper(struct sk_buff *skb, struct genl_info *info) | ||
6044 | { | ||
6045 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | ||
6046 | struct net_device *dev = info->user_ptr[1]; | ||
6047 | enum nl80211_tdls_operation operation; | ||
6048 | u8 *peer; | ||
6049 | |||
6050 | if (!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_TDLS) || | ||
6051 | !rdev->ops->tdls_oper) | ||
6052 | return -EOPNOTSUPP; | ||
6053 | |||
6054 | if (!info->attrs[NL80211_ATTR_TDLS_OPERATION] || | ||
6055 | !info->attrs[NL80211_ATTR_MAC]) | ||
6056 | return -EINVAL; | ||
6057 | |||
6058 | operation = nla_get_u8(info->attrs[NL80211_ATTR_TDLS_OPERATION]); | ||
6059 | peer = nla_data(info->attrs[NL80211_ATTR_MAC]); | ||
6060 | |||
6061 | return rdev_tdls_oper(rdev, dev, peer, operation); | ||
6062 | } | 4782 | } |
6063 | 4783 | ||
6064 | static int nl80211_remain_on_channel(struct sk_buff *skb, | 4784 | static int nl80211_remain_on_channel(struct sk_buff *skb, |
6065 | struct genl_info *info) | 4785 | struct genl_info *info) |
6066 | { | 4786 | { |
6067 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | 4787 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; |
6068 | struct wireless_dev *wdev = info->user_ptr[1]; | 4788 | struct net_device *dev = info->user_ptr[1]; |
6069 | struct cfg80211_chan_def chandef; | 4789 | struct ieee80211_channel *chan; |
6070 | struct sk_buff *msg; | 4790 | struct sk_buff *msg; |
6071 | void *hdr; | 4791 | void *hdr; |
6072 | u64 cookie; | 4792 | u64 cookie; |
6073 | u32 duration; | 4793 | enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT; |
4794 | u32 freq, duration; | ||
6074 | int err; | 4795 | int err; |
6075 | 4796 | ||
6076 | if (!info->attrs[NL80211_ATTR_WIPHY_FREQ] || | 4797 | if (!info->attrs[NL80211_ATTR_WIPHY_FREQ] || |
@@ -6079,27 +4800,37 @@ static int nl80211_remain_on_channel(struct sk_buff *skb, | |||
6079 | 4800 | ||
6080 | duration = nla_get_u32(info->attrs[NL80211_ATTR_DURATION]); | 4801 | duration = nla_get_u32(info->attrs[NL80211_ATTR_DURATION]); |
6081 | 4802 | ||
6082 | if (!rdev->ops->remain_on_channel || | ||
6083 | !(rdev->wiphy.flags & WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL)) | ||
6084 | return -EOPNOTSUPP; | ||
6085 | |||
6086 | /* | 4803 | /* |
6087 | * We should be on that channel for at least a minimum amount of | 4804 | * We should be on that channel for at least one jiffie, |
6088 | * time (10ms) but no longer than the driver supports. | 4805 | * and more than 5 seconds seems excessive. |
6089 | */ | 4806 | */ |
6090 | if (duration < NL80211_MIN_REMAIN_ON_CHANNEL_TIME || | 4807 | if (!duration || !msecs_to_jiffies(duration) || |
6091 | duration > rdev->wiphy.max_remain_on_channel_duration) | 4808 | duration > rdev->wiphy.max_remain_on_channel_duration) |
6092 | return -EINVAL; | 4809 | return -EINVAL; |
6093 | 4810 | ||
6094 | err = nl80211_parse_chandef(rdev, info, &chandef); | 4811 | if (!rdev->ops->remain_on_channel) |
6095 | if (err) | 4812 | return -EOPNOTSUPP; |
6096 | return err; | 4813 | |
4814 | if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) { | ||
4815 | channel_type = nla_get_u32( | ||
4816 | info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]); | ||
4817 | if (channel_type != NL80211_CHAN_NO_HT && | ||
4818 | channel_type != NL80211_CHAN_HT20 && | ||
4819 | channel_type != NL80211_CHAN_HT40PLUS && | ||
4820 | channel_type != NL80211_CHAN_HT40MINUS) | ||
4821 | return -EINVAL; | ||
4822 | } | ||
4823 | |||
4824 | freq = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]); | ||
4825 | chan = rdev_freq_to_chan(rdev, freq, channel_type); | ||
4826 | if (chan == NULL) | ||
4827 | return -EINVAL; | ||
6097 | 4828 | ||
6098 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | 4829 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); |
6099 | if (!msg) | 4830 | if (!msg) |
6100 | return -ENOMEM; | 4831 | return -ENOMEM; |
6101 | 4832 | ||
6102 | hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, | 4833 | hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, |
6103 | NL80211_CMD_REMAIN_ON_CHANNEL); | 4834 | NL80211_CMD_REMAIN_ON_CHANNEL); |
6104 | 4835 | ||
6105 | if (IS_ERR(hdr)) { | 4836 | if (IS_ERR(hdr)) { |
@@ -6107,14 +4838,13 @@ static int nl80211_remain_on_channel(struct sk_buff *skb, | |||
6107 | goto free_msg; | 4838 | goto free_msg; |
6108 | } | 4839 | } |
6109 | 4840 | ||
6110 | err = rdev_remain_on_channel(rdev, wdev, chandef.chan, | 4841 | err = rdev->ops->remain_on_channel(&rdev->wiphy, dev, chan, |
6111 | duration, &cookie); | 4842 | channel_type, duration, &cookie); |
6112 | 4843 | ||
6113 | if (err) | 4844 | if (err) |
6114 | goto free_msg; | 4845 | goto free_msg; |
6115 | 4846 | ||
6116 | if (nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie)) | 4847 | NLA_PUT_U64(msg, NL80211_ATTR_COOKIE, cookie); |
6117 | goto nla_put_failure; | ||
6118 | 4848 | ||
6119 | genlmsg_end(msg, hdr); | 4849 | genlmsg_end(msg, hdr); |
6120 | 4850 | ||
@@ -6131,7 +4861,7 @@ static int nl80211_cancel_remain_on_channel(struct sk_buff *skb, | |||
6131 | struct genl_info *info) | 4861 | struct genl_info *info) |
6132 | { | 4862 | { |
6133 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | 4863 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; |
6134 | struct wireless_dev *wdev = info->user_ptr[1]; | 4864 | struct net_device *dev = info->user_ptr[1]; |
6135 | u64 cookie; | 4865 | u64 cookie; |
6136 | 4866 | ||
6137 | if (!info->attrs[NL80211_ATTR_COOKIE]) | 4867 | if (!info->attrs[NL80211_ATTR_COOKIE]) |
@@ -6142,7 +4872,7 @@ static int nl80211_cancel_remain_on_channel(struct sk_buff *skb, | |||
6142 | 4872 | ||
6143 | cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]); | 4873 | cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]); |
6144 | 4874 | ||
6145 | return rdev_cancel_remain_on_channel(rdev, wdev, cookie); | 4875 | return rdev->ops->cancel_remain_on_channel(&rdev->wiphy, dev, cookie); |
6146 | } | 4876 | } |
6147 | 4877 | ||
6148 | static u32 rateset_to_mask(struct ieee80211_supported_band *sband, | 4878 | static u32 rateset_to_mask(struct ieee80211_supported_band *sband, |
@@ -6169,39 +4899,9 @@ static u32 rateset_to_mask(struct ieee80211_supported_band *sband, | |||
6169 | return mask; | 4899 | return mask; |
6170 | } | 4900 | } |
6171 | 4901 | ||
6172 | static bool ht_rateset_to_mask(struct ieee80211_supported_band *sband, | ||
6173 | u8 *rates, u8 rates_len, | ||
6174 | u8 mcs[IEEE80211_HT_MCS_MASK_LEN]) | ||
6175 | { | ||
6176 | u8 i; | ||
6177 | |||
6178 | memset(mcs, 0, IEEE80211_HT_MCS_MASK_LEN); | ||
6179 | |||
6180 | for (i = 0; i < rates_len; i++) { | ||
6181 | int ridx, rbit; | ||
6182 | |||
6183 | ridx = rates[i] / 8; | ||
6184 | rbit = BIT(rates[i] % 8); | ||
6185 | |||
6186 | /* check validity */ | ||
6187 | if ((ridx < 0) || (ridx >= IEEE80211_HT_MCS_MASK_LEN)) | ||
6188 | return false; | ||
6189 | |||
6190 | /* check availability */ | ||
6191 | if (sband->ht_cap.mcs.rx_mask[ridx] & rbit) | ||
6192 | mcs[ridx] |= rbit; | ||
6193 | else | ||
6194 | return false; | ||
6195 | } | ||
6196 | |||
6197 | return true; | ||
6198 | } | ||
6199 | |||
6200 | static const struct nla_policy nl80211_txattr_policy[NL80211_TXRATE_MAX + 1] = { | 4902 | static const struct nla_policy nl80211_txattr_policy[NL80211_TXRATE_MAX + 1] = { |
6201 | [NL80211_TXRATE_LEGACY] = { .type = NLA_BINARY, | 4903 | [NL80211_TXRATE_LEGACY] = { .type = NLA_BINARY, |
6202 | .len = NL80211_MAX_SUPP_RATES }, | 4904 | .len = NL80211_MAX_SUPP_RATES }, |
6203 | [NL80211_TXRATE_MCS] = { .type = NLA_BINARY, | ||
6204 | .len = NL80211_MAX_SUPP_HT_RATES }, | ||
6205 | }; | 4905 | }; |
6206 | 4906 | ||
6207 | static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb, | 4907 | static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb, |
@@ -6227,20 +4927,12 @@ static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb, | |||
6227 | sband = rdev->wiphy.bands[i]; | 4927 | sband = rdev->wiphy.bands[i]; |
6228 | mask.control[i].legacy = | 4928 | mask.control[i].legacy = |
6229 | sband ? (1 << sband->n_bitrates) - 1 : 0; | 4929 | sband ? (1 << sband->n_bitrates) - 1 : 0; |
6230 | if (sband) | ||
6231 | memcpy(mask.control[i].mcs, | ||
6232 | sband->ht_cap.mcs.rx_mask, | ||
6233 | sizeof(mask.control[i].mcs)); | ||
6234 | else | ||
6235 | memset(mask.control[i].mcs, 0, | ||
6236 | sizeof(mask.control[i].mcs)); | ||
6237 | } | 4930 | } |
6238 | 4931 | ||
6239 | /* | 4932 | /* |
6240 | * The nested attribute uses enum nl80211_band as the index. This maps | 4933 | * The nested attribute uses enum nl80211_band as the index. This maps |
6241 | * directly to the enum ieee80211_band values used in cfg80211. | 4934 | * directly to the enum ieee80211_band values used in cfg80211. |
6242 | */ | 4935 | */ |
6243 | BUILD_BUG_ON(NL80211_MAX_SUPP_HT_RATES > IEEE80211_HT_MCS_MASK_LEN * 8); | ||
6244 | nla_for_each_nested(tx_rates, info->attrs[NL80211_ATTR_TX_RATES], rem) | 4936 | nla_for_each_nested(tx_rates, info->attrs[NL80211_ATTR_TX_RATES], rem) |
6245 | { | 4937 | { |
6246 | enum ieee80211_band band = nla_type(tx_rates); | 4938 | enum ieee80211_band band = nla_type(tx_rates); |
@@ -6256,42 +4948,18 @@ static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb, | |||
6256 | sband, | 4948 | sband, |
6257 | nla_data(tb[NL80211_TXRATE_LEGACY]), | 4949 | nla_data(tb[NL80211_TXRATE_LEGACY]), |
6258 | nla_len(tb[NL80211_TXRATE_LEGACY])); | 4950 | nla_len(tb[NL80211_TXRATE_LEGACY])); |
6259 | if ((mask.control[band].legacy == 0) && | 4951 | if (mask.control[band].legacy == 0) |
6260 | nla_len(tb[NL80211_TXRATE_LEGACY])) | ||
6261 | return -EINVAL; | ||
6262 | } | ||
6263 | if (tb[NL80211_TXRATE_MCS]) { | ||
6264 | if (!ht_rateset_to_mask( | ||
6265 | sband, | ||
6266 | nla_data(tb[NL80211_TXRATE_MCS]), | ||
6267 | nla_len(tb[NL80211_TXRATE_MCS]), | ||
6268 | mask.control[band].mcs)) | ||
6269 | return -EINVAL; | ||
6270 | } | ||
6271 | |||
6272 | if (mask.control[band].legacy == 0) { | ||
6273 | /* don't allow empty legacy rates if HT | ||
6274 | * is not even supported. */ | ||
6275 | if (!rdev->wiphy.bands[band]->ht_cap.ht_supported) | ||
6276 | return -EINVAL; | ||
6277 | |||
6278 | for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++) | ||
6279 | if (mask.control[band].mcs[i]) | ||
6280 | break; | ||
6281 | |||
6282 | /* legacy and mcs rates may not be both empty */ | ||
6283 | if (i == IEEE80211_HT_MCS_MASK_LEN) | ||
6284 | return -EINVAL; | 4952 | return -EINVAL; |
6285 | } | 4953 | } |
6286 | } | 4954 | } |
6287 | 4955 | ||
6288 | return rdev_set_bitrate_mask(rdev, dev, NULL, &mask); | 4956 | return rdev->ops->set_bitrate_mask(&rdev->wiphy, dev, NULL, &mask); |
6289 | } | 4957 | } |
6290 | 4958 | ||
6291 | static int nl80211_register_mgmt(struct sk_buff *skb, struct genl_info *info) | 4959 | static int nl80211_register_mgmt(struct sk_buff *skb, struct genl_info *info) |
6292 | { | 4960 | { |
6293 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | 4961 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; |
6294 | struct wireless_dev *wdev = info->user_ptr[1]; | 4962 | struct net_device *dev = info->user_ptr[1]; |
6295 | u16 frame_type = IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION; | 4963 | u16 frame_type = IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION; |
6296 | 4964 | ||
6297 | if (!info->attrs[NL80211_ATTR_FRAME_MATCH]) | 4965 | if (!info->attrs[NL80211_ATTR_FRAME_MATCH]) |
@@ -6300,25 +4968,21 @@ static int nl80211_register_mgmt(struct sk_buff *skb, struct genl_info *info) | |||
6300 | if (info->attrs[NL80211_ATTR_FRAME_TYPE]) | 4968 | if (info->attrs[NL80211_ATTR_FRAME_TYPE]) |
6301 | frame_type = nla_get_u16(info->attrs[NL80211_ATTR_FRAME_TYPE]); | 4969 | frame_type = nla_get_u16(info->attrs[NL80211_ATTR_FRAME_TYPE]); |
6302 | 4970 | ||
6303 | switch (wdev->iftype) { | 4971 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION && |
6304 | case NL80211_IFTYPE_STATION: | 4972 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_ADHOC && |
6305 | case NL80211_IFTYPE_ADHOC: | 4973 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT && |
6306 | case NL80211_IFTYPE_P2P_CLIENT: | 4974 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && |
6307 | case NL80211_IFTYPE_AP: | 4975 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP_VLAN && |
6308 | case NL80211_IFTYPE_AP_VLAN: | 4976 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT && |
6309 | case NL80211_IFTYPE_MESH_POINT: | 4977 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) |
6310 | case NL80211_IFTYPE_P2P_GO: | ||
6311 | case NL80211_IFTYPE_P2P_DEVICE: | ||
6312 | break; | ||
6313 | default: | ||
6314 | return -EOPNOTSUPP; | 4978 | return -EOPNOTSUPP; |
6315 | } | ||
6316 | 4979 | ||
6317 | /* not much point in registering if we can't reply */ | 4980 | /* not much point in registering if we can't reply */ |
6318 | if (!rdev->ops->mgmt_tx) | 4981 | if (!rdev->ops->mgmt_tx) |
6319 | return -EOPNOTSUPP; | 4982 | return -EOPNOTSUPP; |
6320 | 4983 | ||
6321 | return cfg80211_mlme_register_mgmt(wdev, info->snd_portid, frame_type, | 4984 | return cfg80211_mlme_register_mgmt(dev->ieee80211_ptr, info->snd_pid, |
4985 | frame_type, | ||
6322 | nla_data(info->attrs[NL80211_ATTR_FRAME_MATCH]), | 4986 | nla_data(info->attrs[NL80211_ATTR_FRAME_MATCH]), |
6323 | nla_len(info->attrs[NL80211_ATTR_FRAME_MATCH])); | 4987 | nla_len(info->attrs[NL80211_ATTR_FRAME_MATCH])); |
6324 | } | 4988 | } |
@@ -6326,93 +4990,81 @@ static int nl80211_register_mgmt(struct sk_buff *skb, struct genl_info *info) | |||
6326 | static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info) | 4990 | static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info) |
6327 | { | 4991 | { |
6328 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | 4992 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; |
6329 | struct wireless_dev *wdev = info->user_ptr[1]; | 4993 | struct net_device *dev = info->user_ptr[1]; |
6330 | struct cfg80211_chan_def chandef; | 4994 | struct ieee80211_channel *chan; |
4995 | enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT; | ||
4996 | bool channel_type_valid = false; | ||
4997 | u32 freq; | ||
6331 | int err; | 4998 | int err; |
6332 | void *hdr = NULL; | 4999 | void *hdr; |
6333 | u64 cookie; | 5000 | u64 cookie; |
6334 | struct sk_buff *msg = NULL; | 5001 | struct sk_buff *msg; |
6335 | unsigned int wait = 0; | 5002 | unsigned int wait = 0; |
6336 | bool offchan, no_cck, dont_wait_for_ack; | 5003 | bool offchan; |
6337 | 5004 | ||
6338 | dont_wait_for_ack = info->attrs[NL80211_ATTR_DONT_WAIT_FOR_ACK]; | 5005 | if (!info->attrs[NL80211_ATTR_FRAME] || |
6339 | 5006 | !info->attrs[NL80211_ATTR_WIPHY_FREQ]) | |
6340 | if (!info->attrs[NL80211_ATTR_FRAME]) | ||
6341 | return -EINVAL; | 5007 | return -EINVAL; |
6342 | 5008 | ||
6343 | if (!rdev->ops->mgmt_tx) | 5009 | if (!rdev->ops->mgmt_tx) |
6344 | return -EOPNOTSUPP; | 5010 | return -EOPNOTSUPP; |
6345 | 5011 | ||
6346 | switch (wdev->iftype) { | 5012 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION && |
6347 | case NL80211_IFTYPE_STATION: | 5013 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_ADHOC && |
6348 | case NL80211_IFTYPE_ADHOC: | 5014 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT && |
6349 | case NL80211_IFTYPE_P2P_CLIENT: | 5015 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && |
6350 | case NL80211_IFTYPE_AP: | 5016 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP_VLAN && |
6351 | case NL80211_IFTYPE_AP_VLAN: | 5017 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT && |
6352 | case NL80211_IFTYPE_MESH_POINT: | 5018 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) |
6353 | case NL80211_IFTYPE_P2P_GO: | ||
6354 | case NL80211_IFTYPE_P2P_DEVICE: | ||
6355 | break; | ||
6356 | default: | ||
6357 | return -EOPNOTSUPP; | 5019 | return -EOPNOTSUPP; |
6358 | } | ||
6359 | 5020 | ||
6360 | if (info->attrs[NL80211_ATTR_DURATION]) { | 5021 | if (info->attrs[NL80211_ATTR_DURATION]) { |
6361 | if (!(rdev->wiphy.flags & WIPHY_FLAG_OFFCHAN_TX)) | 5022 | if (!rdev->ops->mgmt_tx_cancel_wait) |
6362 | return -EINVAL; | 5023 | return -EINVAL; |
6363 | wait = nla_get_u32(info->attrs[NL80211_ATTR_DURATION]); | 5024 | wait = nla_get_u32(info->attrs[NL80211_ATTR_DURATION]); |
5025 | } | ||
6364 | 5026 | ||
6365 | /* | 5027 | if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) { |
6366 | * We should wait on the channel for at least a minimum amount | 5028 | channel_type = nla_get_u32( |
6367 | * of time (10ms) but no longer than the driver supports. | 5029 | info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]); |
6368 | */ | 5030 | if (channel_type != NL80211_CHAN_NO_HT && |
6369 | if (wait < NL80211_MIN_REMAIN_ON_CHANNEL_TIME || | 5031 | channel_type != NL80211_CHAN_HT20 && |
6370 | wait > rdev->wiphy.max_remain_on_channel_duration) | 5032 | channel_type != NL80211_CHAN_HT40PLUS && |
5033 | channel_type != NL80211_CHAN_HT40MINUS) | ||
6371 | return -EINVAL; | 5034 | return -EINVAL; |
6372 | 5035 | channel_type_valid = true; | |
6373 | } | 5036 | } |
6374 | 5037 | ||
6375 | offchan = info->attrs[NL80211_ATTR_OFFCHANNEL_TX_OK]; | 5038 | offchan = info->attrs[NL80211_ATTR_OFFCHANNEL_TX_OK]; |
6376 | 5039 | ||
6377 | if (offchan && !(rdev->wiphy.flags & WIPHY_FLAG_OFFCHAN_TX)) | 5040 | freq = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]); |
5041 | chan = rdev_freq_to_chan(rdev, freq, channel_type); | ||
5042 | if (chan == NULL) | ||
6378 | return -EINVAL; | 5043 | return -EINVAL; |
6379 | 5044 | ||
6380 | no_cck = nla_get_flag(info->attrs[NL80211_ATTR_TX_NO_CCK_RATE]); | 5045 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); |
6381 | 5046 | if (!msg) | |
6382 | err = nl80211_parse_chandef(rdev, info, &chandef); | 5047 | return -ENOMEM; |
6383 | if (err) | ||
6384 | return err; | ||
6385 | |||
6386 | if (!dont_wait_for_ack) { | ||
6387 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | ||
6388 | if (!msg) | ||
6389 | return -ENOMEM; | ||
6390 | 5048 | ||
6391 | hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, | 5049 | hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, |
6392 | NL80211_CMD_FRAME); | 5050 | NL80211_CMD_FRAME); |
6393 | 5051 | ||
6394 | if (IS_ERR(hdr)) { | 5052 | if (IS_ERR(hdr)) { |
6395 | err = PTR_ERR(hdr); | 5053 | err = PTR_ERR(hdr); |
6396 | goto free_msg; | 5054 | goto free_msg; |
6397 | } | ||
6398 | } | 5055 | } |
6399 | 5056 | err = cfg80211_mlme_mgmt_tx(rdev, dev, chan, offchan, channel_type, | |
6400 | err = cfg80211_mlme_mgmt_tx(rdev, wdev, chandef.chan, offchan, wait, | 5057 | channel_type_valid, wait, |
6401 | nla_data(info->attrs[NL80211_ATTR_FRAME]), | 5058 | nla_data(info->attrs[NL80211_ATTR_FRAME]), |
6402 | nla_len(info->attrs[NL80211_ATTR_FRAME]), | 5059 | nla_len(info->attrs[NL80211_ATTR_FRAME]), |
6403 | no_cck, dont_wait_for_ack, &cookie); | 5060 | &cookie); |
6404 | if (err) | 5061 | if (err) |
6405 | goto free_msg; | 5062 | goto free_msg; |
6406 | 5063 | ||
6407 | if (msg) { | 5064 | NLA_PUT_U64(msg, NL80211_ATTR_COOKIE, cookie); |
6408 | if (nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie)) | ||
6409 | goto nla_put_failure; | ||
6410 | |||
6411 | genlmsg_end(msg, hdr); | ||
6412 | return genlmsg_reply(msg, info); | ||
6413 | } | ||
6414 | 5065 | ||
6415 | return 0; | 5066 | genlmsg_end(msg, hdr); |
5067 | return genlmsg_reply(msg, info); | ||
6416 | 5068 | ||
6417 | nla_put_failure: | 5069 | nla_put_failure: |
6418 | err = -ENOBUFS; | 5070 | err = -ENOBUFS; |
@@ -6424,7 +5076,7 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info) | |||
6424 | static int nl80211_tx_mgmt_cancel_wait(struct sk_buff *skb, struct genl_info *info) | 5076 | static int nl80211_tx_mgmt_cancel_wait(struct sk_buff *skb, struct genl_info *info) |
6425 | { | 5077 | { |
6426 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | 5078 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; |
6427 | struct wireless_dev *wdev = info->user_ptr[1]; | 5079 | struct net_device *dev = info->user_ptr[1]; |
6428 | u64 cookie; | 5080 | u64 cookie; |
6429 | 5081 | ||
6430 | if (!info->attrs[NL80211_ATTR_COOKIE]) | 5082 | if (!info->attrs[NL80211_ATTR_COOKIE]) |
@@ -6433,22 +5085,17 @@ static int nl80211_tx_mgmt_cancel_wait(struct sk_buff *skb, struct genl_info *in | |||
6433 | if (!rdev->ops->mgmt_tx_cancel_wait) | 5085 | if (!rdev->ops->mgmt_tx_cancel_wait) |
6434 | return -EOPNOTSUPP; | 5086 | return -EOPNOTSUPP; |
6435 | 5087 | ||
6436 | switch (wdev->iftype) { | 5088 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION && |
6437 | case NL80211_IFTYPE_STATION: | 5089 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_ADHOC && |
6438 | case NL80211_IFTYPE_ADHOC: | 5090 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT && |
6439 | case NL80211_IFTYPE_P2P_CLIENT: | 5091 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && |
6440 | case NL80211_IFTYPE_AP: | 5092 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP_VLAN && |
6441 | case NL80211_IFTYPE_AP_VLAN: | 5093 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) |
6442 | case NL80211_IFTYPE_P2P_GO: | ||
6443 | case NL80211_IFTYPE_P2P_DEVICE: | ||
6444 | break; | ||
6445 | default: | ||
6446 | return -EOPNOTSUPP; | 5094 | return -EOPNOTSUPP; |
6447 | } | ||
6448 | 5095 | ||
6449 | cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]); | 5096 | cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]); |
6450 | 5097 | ||
6451 | return rdev_mgmt_tx_cancel_wait(rdev, wdev, cookie); | 5098 | return rdev->ops->mgmt_tx_cancel_wait(&rdev->wiphy, dev, cookie); |
6452 | } | 5099 | } |
6453 | 5100 | ||
6454 | static int nl80211_set_power_save(struct sk_buff *skb, struct genl_info *info) | 5101 | static int nl80211_set_power_save(struct sk_buff *skb, struct genl_info *info) |
@@ -6478,7 +5125,8 @@ static int nl80211_set_power_save(struct sk_buff *skb, struct genl_info *info) | |||
6478 | if (state == wdev->ps) | 5125 | if (state == wdev->ps) |
6479 | return 0; | 5126 | return 0; |
6480 | 5127 | ||
6481 | err = rdev_set_power_mgmt(rdev, dev, state, wdev->ps_timeout); | 5128 | err = rdev->ops->set_power_mgmt(wdev->wiphy, dev, state, |
5129 | wdev->ps_timeout); | ||
6482 | if (!err) | 5130 | if (!err) |
6483 | wdev->ps = state; | 5131 | wdev->ps = state; |
6484 | return err; | 5132 | return err; |
@@ -6503,7 +5151,7 @@ static int nl80211_get_power_save(struct sk_buff *skb, struct genl_info *info) | |||
6503 | if (!msg) | 5151 | if (!msg) |
6504 | return -ENOMEM; | 5152 | return -ENOMEM; |
6505 | 5153 | ||
6506 | hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, | 5154 | hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, |
6507 | NL80211_CMD_GET_POWER_SAVE); | 5155 | NL80211_CMD_GET_POWER_SAVE); |
6508 | if (!hdr) { | 5156 | if (!hdr) { |
6509 | err = -ENOBUFS; | 5157 | err = -ENOBUFS; |
@@ -6515,8 +5163,7 @@ static int nl80211_get_power_save(struct sk_buff *skb, struct genl_info *info) | |||
6515 | else | 5163 | else |
6516 | ps_state = NL80211_PS_DISABLED; | 5164 | ps_state = NL80211_PS_DISABLED; |
6517 | 5165 | ||
6518 | if (nla_put_u32(msg, NL80211_ATTR_PS_STATE, ps_state)) | 5166 | NLA_PUT_U32(msg, NL80211_ATTR_PS_STATE, ps_state); |
6519 | goto nla_put_failure; | ||
6520 | 5167 | ||
6521 | genlmsg_end(msg, hdr); | 5168 | genlmsg_end(msg, hdr); |
6522 | return genlmsg_reply(msg, info); | 5169 | return genlmsg_reply(msg, info); |
@@ -6533,33 +5180,8 @@ nl80211_attr_cqm_policy[NL80211_ATTR_CQM_MAX + 1] __read_mostly = { | |||
6533 | [NL80211_ATTR_CQM_RSSI_THOLD] = { .type = NLA_U32 }, | 5180 | [NL80211_ATTR_CQM_RSSI_THOLD] = { .type = NLA_U32 }, |
6534 | [NL80211_ATTR_CQM_RSSI_HYST] = { .type = NLA_U32 }, | 5181 | [NL80211_ATTR_CQM_RSSI_HYST] = { .type = NLA_U32 }, |
6535 | [NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT] = { .type = NLA_U32 }, | 5182 | [NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT] = { .type = NLA_U32 }, |
6536 | [NL80211_ATTR_CQM_TXE_RATE] = { .type = NLA_U32 }, | ||
6537 | [NL80211_ATTR_CQM_TXE_PKTS] = { .type = NLA_U32 }, | ||
6538 | [NL80211_ATTR_CQM_TXE_INTVL] = { .type = NLA_U32 }, | ||
6539 | }; | 5183 | }; |
6540 | 5184 | ||
6541 | static int nl80211_set_cqm_txe(struct genl_info *info, | ||
6542 | u32 rate, u32 pkts, u32 intvl) | ||
6543 | { | ||
6544 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | ||
6545 | struct wireless_dev *wdev; | ||
6546 | struct net_device *dev = info->user_ptr[1]; | ||
6547 | |||
6548 | if (rate > 100 || intvl > NL80211_CQM_TXE_MAX_INTVL) | ||
6549 | return -EINVAL; | ||
6550 | |||
6551 | wdev = dev->ieee80211_ptr; | ||
6552 | |||
6553 | if (!rdev->ops->set_cqm_txe_config) | ||
6554 | return -EOPNOTSUPP; | ||
6555 | |||
6556 | if (wdev->iftype != NL80211_IFTYPE_STATION && | ||
6557 | wdev->iftype != NL80211_IFTYPE_P2P_CLIENT) | ||
6558 | return -EOPNOTSUPP; | ||
6559 | |||
6560 | return rdev_set_cqm_txe_config(rdev, dev, rate, pkts, intvl); | ||
6561 | } | ||
6562 | |||
6563 | static int nl80211_set_cqm_rssi(struct genl_info *info, | 5185 | static int nl80211_set_cqm_rssi(struct genl_info *info, |
6564 | s32 threshold, u32 hysteresis) | 5186 | s32 threshold, u32 hysteresis) |
6565 | { | 5187 | { |
@@ -6579,7 +5201,8 @@ static int nl80211_set_cqm_rssi(struct genl_info *info, | |||
6579 | wdev->iftype != NL80211_IFTYPE_P2P_CLIENT) | 5201 | wdev->iftype != NL80211_IFTYPE_P2P_CLIENT) |
6580 | return -EOPNOTSUPP; | 5202 | return -EOPNOTSUPP; |
6581 | 5203 | ||
6582 | return rdev_set_cqm_rssi_config(rdev, dev, threshold, hysteresis); | 5204 | return rdev->ops->set_cqm_rssi_config(wdev->wiphy, dev, |
5205 | threshold, hysteresis); | ||
6583 | } | 5206 | } |
6584 | 5207 | ||
6585 | static int nl80211_set_cqm(struct sk_buff *skb, struct genl_info *info) | 5208 | static int nl80211_set_cqm(struct sk_buff *skb, struct genl_info *info) |
@@ -6606,14 +5229,6 @@ static int nl80211_set_cqm(struct sk_buff *skb, struct genl_info *info) | |||
6606 | threshold = nla_get_u32(attrs[NL80211_ATTR_CQM_RSSI_THOLD]); | 5229 | threshold = nla_get_u32(attrs[NL80211_ATTR_CQM_RSSI_THOLD]); |
6607 | hysteresis = nla_get_u32(attrs[NL80211_ATTR_CQM_RSSI_HYST]); | 5230 | hysteresis = nla_get_u32(attrs[NL80211_ATTR_CQM_RSSI_HYST]); |
6608 | err = nl80211_set_cqm_rssi(info, threshold, hysteresis); | 5231 | err = nl80211_set_cqm_rssi(info, threshold, hysteresis); |
6609 | } else if (attrs[NL80211_ATTR_CQM_TXE_RATE] && | ||
6610 | attrs[NL80211_ATTR_CQM_TXE_PKTS] && | ||
6611 | attrs[NL80211_ATTR_CQM_TXE_INTVL]) { | ||
6612 | u32 rate, pkts, intvl; | ||
6613 | rate = nla_get_u32(attrs[NL80211_ATTR_CQM_TXE_RATE]); | ||
6614 | pkts = nla_get_u32(attrs[NL80211_ATTR_CQM_TXE_PKTS]); | ||
6615 | intvl = nla_get_u32(attrs[NL80211_ATTR_CQM_TXE_INTVL]); | ||
6616 | err = nl80211_set_cqm_txe(info, rate, pkts, intvl); | ||
6617 | } else | 5232 | } else |
6618 | err = -EINVAL; | 5233 | err = -EINVAL; |
6619 | 5234 | ||
@@ -6647,11 +5262,6 @@ static int nl80211_join_mesh(struct sk_buff *skb, struct genl_info *info) | |||
6647 | setup.mesh_id = nla_data(info->attrs[NL80211_ATTR_MESH_ID]); | 5262 | setup.mesh_id = nla_data(info->attrs[NL80211_ATTR_MESH_ID]); |
6648 | setup.mesh_id_len = nla_len(info->attrs[NL80211_ATTR_MESH_ID]); | 5263 | setup.mesh_id_len = nla_len(info->attrs[NL80211_ATTR_MESH_ID]); |
6649 | 5264 | ||
6650 | if (info->attrs[NL80211_ATTR_MCAST_RATE] && | ||
6651 | !nl80211_parse_mcast_rate(rdev, setup.mcast_rate, | ||
6652 | nla_get_u32(info->attrs[NL80211_ATTR_MCAST_RATE]))) | ||
6653 | return -EINVAL; | ||
6654 | |||
6655 | if (info->attrs[NL80211_ATTR_MESH_SETUP]) { | 5265 | if (info->attrs[NL80211_ATTR_MESH_SETUP]) { |
6656 | /* parse additional setup parameters if given */ | 5266 | /* parse additional setup parameters if given */ |
6657 | err = nl80211_parse_mesh_setup(info, &setup); | 5267 | err = nl80211_parse_mesh_setup(info, &setup); |
@@ -6659,15 +5269,6 @@ static int nl80211_join_mesh(struct sk_buff *skb, struct genl_info *info) | |||
6659 | return err; | 5269 | return err; |
6660 | } | 5270 | } |
6661 | 5271 | ||
6662 | if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) { | ||
6663 | err = nl80211_parse_chandef(rdev, info, &setup.chandef); | ||
6664 | if (err) | ||
6665 | return err; | ||
6666 | } else { | ||
6667 | /* cfg80211_join_mesh() will sort it out */ | ||
6668 | setup.chandef.chan = NULL; | ||
6669 | } | ||
6670 | |||
6671 | return cfg80211_join_mesh(rdev, dev, &setup, &cfg); | 5272 | return cfg80211_join_mesh(rdev, dev, &setup, &cfg); |
6672 | } | 5273 | } |
6673 | 5274 | ||
@@ -6679,7 +5280,6 @@ static int nl80211_leave_mesh(struct sk_buff *skb, struct genl_info *info) | |||
6679 | return cfg80211_leave_mesh(rdev, dev); | 5280 | return cfg80211_leave_mesh(rdev, dev); |
6680 | } | 5281 | } |
6681 | 5282 | ||
6682 | #ifdef CONFIG_PM | ||
6683 | static int nl80211_get_wowlan(struct sk_buff *skb, struct genl_info *info) | 5283 | static int nl80211_get_wowlan(struct sk_buff *skb, struct genl_info *info) |
6684 | { | 5284 | { |
6685 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | 5285 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; |
@@ -6693,7 +5293,7 @@ static int nl80211_get_wowlan(struct sk_buff *skb, struct genl_info *info) | |||
6693 | if (!msg) | 5293 | if (!msg) |
6694 | return -ENOMEM; | 5294 | return -ENOMEM; |
6695 | 5295 | ||
6696 | hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, | 5296 | hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, |
6697 | NL80211_CMD_GET_WOWLAN); | 5297 | NL80211_CMD_GET_WOWLAN); |
6698 | if (!hdr) | 5298 | if (!hdr) |
6699 | goto nla_put_failure; | 5299 | goto nla_put_failure; |
@@ -6705,21 +5305,20 @@ static int nl80211_get_wowlan(struct sk_buff *skb, struct genl_info *info) | |||
6705 | if (!nl_wowlan) | 5305 | if (!nl_wowlan) |
6706 | goto nla_put_failure; | 5306 | goto nla_put_failure; |
6707 | 5307 | ||
6708 | if ((rdev->wowlan->any && | 5308 | if (rdev->wowlan->any) |
6709 | nla_put_flag(msg, NL80211_WOWLAN_TRIG_ANY)) || | 5309 | NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_ANY); |
6710 | (rdev->wowlan->disconnect && | 5310 | if (rdev->wowlan->disconnect) |
6711 | nla_put_flag(msg, NL80211_WOWLAN_TRIG_DISCONNECT)) || | 5311 | NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_DISCONNECT); |
6712 | (rdev->wowlan->magic_pkt && | 5312 | if (rdev->wowlan->magic_pkt) |
6713 | nla_put_flag(msg, NL80211_WOWLAN_TRIG_MAGIC_PKT)) || | 5313 | NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_MAGIC_PKT); |
6714 | (rdev->wowlan->gtk_rekey_failure && | 5314 | if (rdev->wowlan->gtk_rekey_failure) |
6715 | nla_put_flag(msg, NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE)) || | 5315 | NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE); |
6716 | (rdev->wowlan->eap_identity_req && | 5316 | if (rdev->wowlan->eap_identity_req) |
6717 | nla_put_flag(msg, NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST)) || | 5317 | NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST); |
6718 | (rdev->wowlan->four_way_handshake && | 5318 | if (rdev->wowlan->four_way_handshake) |
6719 | nla_put_flag(msg, NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE)) || | 5319 | NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE); |
6720 | (rdev->wowlan->rfkill_release && | 5320 | if (rdev->wowlan->rfkill_release) |
6721 | nla_put_flag(msg, NL80211_WOWLAN_TRIG_RFKILL_RELEASE))) | 5321 | NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_RFKILL_RELEASE); |
6722 | goto nla_put_failure; | ||
6723 | if (rdev->wowlan->n_patterns) { | 5322 | if (rdev->wowlan->n_patterns) { |
6724 | struct nlattr *nl_pats, *nl_pat; | 5323 | struct nlattr *nl_pats, *nl_pat; |
6725 | int i, pat_len; | 5324 | int i, pat_len; |
@@ -6734,13 +5333,12 @@ static int nl80211_get_wowlan(struct sk_buff *skb, struct genl_info *info) | |||
6734 | if (!nl_pat) | 5333 | if (!nl_pat) |
6735 | goto nla_put_failure; | 5334 | goto nla_put_failure; |
6736 | pat_len = rdev->wowlan->patterns[i].pattern_len; | 5335 | pat_len = rdev->wowlan->patterns[i].pattern_len; |
6737 | if (nla_put(msg, NL80211_WOWLAN_PKTPAT_MASK, | 5336 | NLA_PUT(msg, NL80211_WOWLAN_PKTPAT_MASK, |
6738 | DIV_ROUND_UP(pat_len, 8), | 5337 | DIV_ROUND_UP(pat_len, 8), |
6739 | rdev->wowlan->patterns[i].mask) || | 5338 | rdev->wowlan->patterns[i].mask); |
6740 | nla_put(msg, NL80211_WOWLAN_PKTPAT_PATTERN, | 5339 | NLA_PUT(msg, NL80211_WOWLAN_PKTPAT_PATTERN, |
6741 | pat_len, | 5340 | pat_len, |
6742 | rdev->wowlan->patterns[i].pattern)) | 5341 | rdev->wowlan->patterns[i].pattern); |
6743 | goto nla_put_failure; | ||
6744 | nla_nest_end(msg, nl_pat); | 5342 | nla_nest_end(msg, nl_pat); |
6745 | } | 5343 | } |
6746 | nla_nest_end(msg, nl_pats); | 5344 | nla_nest_end(msg, nl_pats); |
@@ -6761,20 +5359,16 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info) | |||
6761 | { | 5359 | { |
6762 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | 5360 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; |
6763 | struct nlattr *tb[NUM_NL80211_WOWLAN_TRIG]; | 5361 | struct nlattr *tb[NUM_NL80211_WOWLAN_TRIG]; |
5362 | struct cfg80211_wowlan no_triggers = {}; | ||
6764 | struct cfg80211_wowlan new_triggers = {}; | 5363 | struct cfg80211_wowlan new_triggers = {}; |
6765 | struct cfg80211_wowlan *ntrig; | ||
6766 | struct wiphy_wowlan_support *wowlan = &rdev->wiphy.wowlan; | 5364 | struct wiphy_wowlan_support *wowlan = &rdev->wiphy.wowlan; |
6767 | int err, i; | 5365 | int err, i; |
6768 | bool prev_enabled = rdev->wowlan; | ||
6769 | 5366 | ||
6770 | if (!rdev->wiphy.wowlan.flags && !rdev->wiphy.wowlan.n_patterns) | 5367 | if (!rdev->wiphy.wowlan.flags && !rdev->wiphy.wowlan.n_patterns) |
6771 | return -EOPNOTSUPP; | 5368 | return -EOPNOTSUPP; |
6772 | 5369 | ||
6773 | if (!info->attrs[NL80211_ATTR_WOWLAN_TRIGGERS]) { | 5370 | if (!info->attrs[NL80211_ATTR_WOWLAN_TRIGGERS]) |
6774 | cfg80211_rdev_free_wowlan(rdev); | 5371 | goto no_triggers; |
6775 | rdev->wowlan = NULL; | ||
6776 | goto set_wakeup; | ||
6777 | } | ||
6778 | 5372 | ||
6779 | err = nla_parse(tb, MAX_NL80211_WOWLAN_TRIG, | 5373 | err = nla_parse(tb, MAX_NL80211_WOWLAN_TRIG, |
6780 | nla_data(info->attrs[NL80211_ATTR_WOWLAN_TRIGGERS]), | 5374 | nla_data(info->attrs[NL80211_ATTR_WOWLAN_TRIGGERS]), |
@@ -6885,17 +5479,21 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info) | |||
6885 | } | 5479 | } |
6886 | } | 5480 | } |
6887 | 5481 | ||
6888 | ntrig = kmemdup(&new_triggers, sizeof(new_triggers), GFP_KERNEL); | 5482 | if (memcmp(&new_triggers, &no_triggers, sizeof(new_triggers))) { |
6889 | if (!ntrig) { | 5483 | struct cfg80211_wowlan *ntrig; |
6890 | err = -ENOMEM; | 5484 | ntrig = kmemdup(&new_triggers, sizeof(new_triggers), |
6891 | goto error; | 5485 | GFP_KERNEL); |
5486 | if (!ntrig) { | ||
5487 | err = -ENOMEM; | ||
5488 | goto error; | ||
5489 | } | ||
5490 | cfg80211_rdev_free_wowlan(rdev); | ||
5491 | rdev->wowlan = ntrig; | ||
5492 | } else { | ||
5493 | no_triggers: | ||
5494 | cfg80211_rdev_free_wowlan(rdev); | ||
5495 | rdev->wowlan = NULL; | ||
6892 | } | 5496 | } |
6893 | cfg80211_rdev_free_wowlan(rdev); | ||
6894 | rdev->wowlan = ntrig; | ||
6895 | |||
6896 | set_wakeup: | ||
6897 | if (rdev->ops->set_wakeup && prev_enabled != !!rdev->wowlan) | ||
6898 | rdev_set_wakeup(rdev, rdev->wowlan); | ||
6899 | 5497 | ||
6900 | return 0; | 5498 | return 0; |
6901 | error: | 5499 | error: |
@@ -6904,7 +5502,6 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info) | |||
6904 | kfree(new_triggers.patterns); | 5502 | kfree(new_triggers.patterns); |
6905 | return err; | 5503 | return err; |
6906 | } | 5504 | } |
6907 | #endif | ||
6908 | 5505 | ||
6909 | static int nl80211_set_rekey_data(struct sk_buff *skb, struct genl_info *info) | 5506 | static int nl80211_set_rekey_data(struct sk_buff *skb, struct genl_info *info) |
6910 | { | 5507 | { |
@@ -6951,261 +5548,55 @@ static int nl80211_set_rekey_data(struct sk_buff *skb, struct genl_info *info) | |||
6951 | goto out; | 5548 | goto out; |
6952 | } | 5549 | } |
6953 | 5550 | ||
6954 | err = rdev_set_rekey_data(rdev, dev, &rekey_data); | 5551 | err = rdev->ops->set_rekey_data(&rdev->wiphy, dev, &rekey_data); |
6955 | out: | 5552 | out: |
6956 | wdev_unlock(wdev); | 5553 | wdev_unlock(wdev); |
6957 | return err; | 5554 | return err; |
6958 | } | 5555 | } |
6959 | 5556 | ||
6960 | static int nl80211_register_unexpected_frame(struct sk_buff *skb, | ||
6961 | struct genl_info *info) | ||
6962 | { | ||
6963 | struct net_device *dev = info->user_ptr[1]; | ||
6964 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
6965 | |||
6966 | if (wdev->iftype != NL80211_IFTYPE_AP && | ||
6967 | wdev->iftype != NL80211_IFTYPE_P2P_GO) | ||
6968 | return -EINVAL; | ||
6969 | |||
6970 | if (wdev->ap_unexpected_nlportid) | ||
6971 | return -EBUSY; | ||
6972 | |||
6973 | wdev->ap_unexpected_nlportid = info->snd_portid; | ||
6974 | return 0; | ||
6975 | } | ||
6976 | |||
6977 | static int nl80211_probe_client(struct sk_buff *skb, | ||
6978 | struct genl_info *info) | ||
6979 | { | ||
6980 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | ||
6981 | struct net_device *dev = info->user_ptr[1]; | ||
6982 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
6983 | struct sk_buff *msg; | ||
6984 | void *hdr; | ||
6985 | const u8 *addr; | ||
6986 | u64 cookie; | ||
6987 | int err; | ||
6988 | |||
6989 | if (wdev->iftype != NL80211_IFTYPE_AP && | ||
6990 | wdev->iftype != NL80211_IFTYPE_P2P_GO) | ||
6991 | return -EOPNOTSUPP; | ||
6992 | |||
6993 | if (!info->attrs[NL80211_ATTR_MAC]) | ||
6994 | return -EINVAL; | ||
6995 | |||
6996 | if (!rdev->ops->probe_client) | ||
6997 | return -EOPNOTSUPP; | ||
6998 | |||
6999 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | ||
7000 | if (!msg) | ||
7001 | return -ENOMEM; | ||
7002 | |||
7003 | hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, | ||
7004 | NL80211_CMD_PROBE_CLIENT); | ||
7005 | |||
7006 | if (IS_ERR(hdr)) { | ||
7007 | err = PTR_ERR(hdr); | ||
7008 | goto free_msg; | ||
7009 | } | ||
7010 | |||
7011 | addr = nla_data(info->attrs[NL80211_ATTR_MAC]); | ||
7012 | |||
7013 | err = rdev_probe_client(rdev, dev, addr, &cookie); | ||
7014 | if (err) | ||
7015 | goto free_msg; | ||
7016 | |||
7017 | if (nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie)) | ||
7018 | goto nla_put_failure; | ||
7019 | |||
7020 | genlmsg_end(msg, hdr); | ||
7021 | |||
7022 | return genlmsg_reply(msg, info); | ||
7023 | |||
7024 | nla_put_failure: | ||
7025 | err = -ENOBUFS; | ||
7026 | free_msg: | ||
7027 | nlmsg_free(msg); | ||
7028 | return err; | ||
7029 | } | ||
7030 | |||
7031 | static int nl80211_register_beacons(struct sk_buff *skb, struct genl_info *info) | ||
7032 | { | ||
7033 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | ||
7034 | struct cfg80211_beacon_registration *reg, *nreg; | ||
7035 | int rv; | ||
7036 | |||
7037 | if (!(rdev->wiphy.flags & WIPHY_FLAG_REPORTS_OBSS)) | ||
7038 | return -EOPNOTSUPP; | ||
7039 | |||
7040 | nreg = kzalloc(sizeof(*nreg), GFP_KERNEL); | ||
7041 | if (!nreg) | ||
7042 | return -ENOMEM; | ||
7043 | |||
7044 | /* First, check if already registered. */ | ||
7045 | spin_lock_bh(&rdev->beacon_registrations_lock); | ||
7046 | list_for_each_entry(reg, &rdev->beacon_registrations, list) { | ||
7047 | if (reg->nlportid == info->snd_portid) { | ||
7048 | rv = -EALREADY; | ||
7049 | goto out_err; | ||
7050 | } | ||
7051 | } | ||
7052 | /* Add it to the list */ | ||
7053 | nreg->nlportid = info->snd_portid; | ||
7054 | list_add(&nreg->list, &rdev->beacon_registrations); | ||
7055 | |||
7056 | spin_unlock_bh(&rdev->beacon_registrations_lock); | ||
7057 | |||
7058 | return 0; | ||
7059 | out_err: | ||
7060 | spin_unlock_bh(&rdev->beacon_registrations_lock); | ||
7061 | kfree(nreg); | ||
7062 | return rv; | ||
7063 | } | ||
7064 | |||
7065 | static int nl80211_start_p2p_device(struct sk_buff *skb, struct genl_info *info) | ||
7066 | { | ||
7067 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | ||
7068 | struct wireless_dev *wdev = info->user_ptr[1]; | ||
7069 | int err; | ||
7070 | |||
7071 | if (!rdev->ops->start_p2p_device) | ||
7072 | return -EOPNOTSUPP; | ||
7073 | |||
7074 | if (wdev->iftype != NL80211_IFTYPE_P2P_DEVICE) | ||
7075 | return -EOPNOTSUPP; | ||
7076 | |||
7077 | if (wdev->p2p_started) | ||
7078 | return 0; | ||
7079 | |||
7080 | mutex_lock(&rdev->devlist_mtx); | ||
7081 | err = cfg80211_can_add_interface(rdev, wdev->iftype); | ||
7082 | mutex_unlock(&rdev->devlist_mtx); | ||
7083 | if (err) | ||
7084 | return err; | ||
7085 | |||
7086 | err = rdev_start_p2p_device(rdev, wdev); | ||
7087 | if (err) | ||
7088 | return err; | ||
7089 | |||
7090 | wdev->p2p_started = true; | ||
7091 | mutex_lock(&rdev->devlist_mtx); | ||
7092 | rdev->opencount++; | ||
7093 | mutex_unlock(&rdev->devlist_mtx); | ||
7094 | |||
7095 | return 0; | ||
7096 | } | ||
7097 | |||
7098 | static int nl80211_stop_p2p_device(struct sk_buff *skb, struct genl_info *info) | ||
7099 | { | ||
7100 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | ||
7101 | struct wireless_dev *wdev = info->user_ptr[1]; | ||
7102 | |||
7103 | if (wdev->iftype != NL80211_IFTYPE_P2P_DEVICE) | ||
7104 | return -EOPNOTSUPP; | ||
7105 | |||
7106 | if (!rdev->ops->stop_p2p_device) | ||
7107 | return -EOPNOTSUPP; | ||
7108 | |||
7109 | if (!wdev->p2p_started) | ||
7110 | return 0; | ||
7111 | |||
7112 | rdev_stop_p2p_device(rdev, wdev); | ||
7113 | wdev->p2p_started = false; | ||
7114 | |||
7115 | mutex_lock(&rdev->devlist_mtx); | ||
7116 | rdev->opencount--; | ||
7117 | mutex_unlock(&rdev->devlist_mtx); | ||
7118 | |||
7119 | if (WARN_ON(rdev->scan_req && rdev->scan_req->wdev == wdev)) { | ||
7120 | rdev->scan_req->aborted = true; | ||
7121 | ___cfg80211_scan_done(rdev, true); | ||
7122 | } | ||
7123 | |||
7124 | return 0; | ||
7125 | } | ||
7126 | |||
7127 | #define NL80211_FLAG_NEED_WIPHY 0x01 | 5557 | #define NL80211_FLAG_NEED_WIPHY 0x01 |
7128 | #define NL80211_FLAG_NEED_NETDEV 0x02 | 5558 | #define NL80211_FLAG_NEED_NETDEV 0x02 |
7129 | #define NL80211_FLAG_NEED_RTNL 0x04 | 5559 | #define NL80211_FLAG_NEED_RTNL 0x04 |
7130 | #define NL80211_FLAG_CHECK_NETDEV_UP 0x08 | 5560 | #define NL80211_FLAG_CHECK_NETDEV_UP 0x08 |
7131 | #define NL80211_FLAG_NEED_NETDEV_UP (NL80211_FLAG_NEED_NETDEV |\ | 5561 | #define NL80211_FLAG_NEED_NETDEV_UP (NL80211_FLAG_NEED_NETDEV |\ |
7132 | NL80211_FLAG_CHECK_NETDEV_UP) | 5562 | NL80211_FLAG_CHECK_NETDEV_UP) |
7133 | #define NL80211_FLAG_NEED_WDEV 0x10 | ||
7134 | /* If a netdev is associated, it must be UP, P2P must be started */ | ||
7135 | #define NL80211_FLAG_NEED_WDEV_UP (NL80211_FLAG_NEED_WDEV |\ | ||
7136 | NL80211_FLAG_CHECK_NETDEV_UP) | ||
7137 | 5563 | ||
7138 | static int nl80211_pre_doit(struct genl_ops *ops, struct sk_buff *skb, | 5564 | static int nl80211_pre_doit(struct genl_ops *ops, struct sk_buff *skb, |
7139 | struct genl_info *info) | 5565 | struct genl_info *info) |
7140 | { | 5566 | { |
7141 | struct cfg80211_registered_device *rdev; | 5567 | struct cfg80211_registered_device *rdev; |
7142 | struct wireless_dev *wdev; | ||
7143 | struct net_device *dev; | 5568 | struct net_device *dev; |
5569 | int err; | ||
7144 | bool rtnl = ops->internal_flags & NL80211_FLAG_NEED_RTNL; | 5570 | bool rtnl = ops->internal_flags & NL80211_FLAG_NEED_RTNL; |
7145 | 5571 | ||
7146 | if (rtnl) | 5572 | if (rtnl) |
7147 | rtnl_lock(); | 5573 | rtnl_lock(); |
7148 | 5574 | ||
7149 | if (ops->internal_flags & NL80211_FLAG_NEED_WIPHY) { | 5575 | if (ops->internal_flags & NL80211_FLAG_NEED_WIPHY) { |
7150 | rdev = cfg80211_get_dev_from_info(genl_info_net(info), info); | 5576 | rdev = cfg80211_get_dev_from_info(info); |
7151 | if (IS_ERR(rdev)) { | 5577 | if (IS_ERR(rdev)) { |
7152 | if (rtnl) | 5578 | if (rtnl) |
7153 | rtnl_unlock(); | 5579 | rtnl_unlock(); |
7154 | return PTR_ERR(rdev); | 5580 | return PTR_ERR(rdev); |
7155 | } | 5581 | } |
7156 | info->user_ptr[0] = rdev; | 5582 | info->user_ptr[0] = rdev; |
7157 | } else if (ops->internal_flags & NL80211_FLAG_NEED_NETDEV || | 5583 | } else if (ops->internal_flags & NL80211_FLAG_NEED_NETDEV) { |
7158 | ops->internal_flags & NL80211_FLAG_NEED_WDEV) { | 5584 | err = get_rdev_dev_by_info_ifindex(info, &rdev, &dev); |
7159 | mutex_lock(&cfg80211_mutex); | 5585 | if (err) { |
7160 | wdev = __cfg80211_wdev_from_attrs(genl_info_net(info), | ||
7161 | info->attrs); | ||
7162 | if (IS_ERR(wdev)) { | ||
7163 | mutex_unlock(&cfg80211_mutex); | ||
7164 | if (rtnl) | 5586 | if (rtnl) |
7165 | rtnl_unlock(); | 5587 | rtnl_unlock(); |
7166 | return PTR_ERR(wdev); | 5588 | return err; |
7167 | } | ||
7168 | |||
7169 | dev = wdev->netdev; | ||
7170 | rdev = wiphy_to_dev(wdev->wiphy); | ||
7171 | |||
7172 | if (ops->internal_flags & NL80211_FLAG_NEED_NETDEV) { | ||
7173 | if (!dev) { | ||
7174 | mutex_unlock(&cfg80211_mutex); | ||
7175 | if (rtnl) | ||
7176 | rtnl_unlock(); | ||
7177 | return -EINVAL; | ||
7178 | } | ||
7179 | |||
7180 | info->user_ptr[1] = dev; | ||
7181 | } else { | ||
7182 | info->user_ptr[1] = wdev; | ||
7183 | } | 5589 | } |
7184 | 5590 | if (ops->internal_flags & NL80211_FLAG_CHECK_NETDEV_UP && | |
7185 | if (dev) { | 5591 | !netif_running(dev)) { |
7186 | if (ops->internal_flags & NL80211_FLAG_CHECK_NETDEV_UP && | 5592 | cfg80211_unlock_rdev(rdev); |
7187 | !netif_running(dev)) { | 5593 | dev_put(dev); |
7188 | mutex_unlock(&cfg80211_mutex); | 5594 | if (rtnl) |
7189 | if (rtnl) | 5595 | rtnl_unlock(); |
7190 | rtnl_unlock(); | 5596 | return -ENETDOWN; |
7191 | return -ENETDOWN; | ||
7192 | } | ||
7193 | |||
7194 | dev_hold(dev); | ||
7195 | } else if (ops->internal_flags & NL80211_FLAG_CHECK_NETDEV_UP) { | ||
7196 | if (!wdev->p2p_started) { | ||
7197 | mutex_unlock(&cfg80211_mutex); | ||
7198 | if (rtnl) | ||
7199 | rtnl_unlock(); | ||
7200 | return -ENETDOWN; | ||
7201 | } | ||
7202 | } | 5597 | } |
7203 | |||
7204 | cfg80211_lock_rdev(rdev); | ||
7205 | |||
7206 | mutex_unlock(&cfg80211_mutex); | ||
7207 | |||
7208 | info->user_ptr[0] = rdev; | 5598 | info->user_ptr[0] = rdev; |
5599 | info->user_ptr[1] = dev; | ||
7209 | } | 5600 | } |
7210 | 5601 | ||
7211 | return 0; | 5602 | return 0; |
@@ -7216,16 +5607,8 @@ static void nl80211_post_doit(struct genl_ops *ops, struct sk_buff *skb, | |||
7216 | { | 5607 | { |
7217 | if (info->user_ptr[0]) | 5608 | if (info->user_ptr[0]) |
7218 | cfg80211_unlock_rdev(info->user_ptr[0]); | 5609 | cfg80211_unlock_rdev(info->user_ptr[0]); |
7219 | if (info->user_ptr[1]) { | 5610 | if (info->user_ptr[1]) |
7220 | if (ops->internal_flags & NL80211_FLAG_NEED_WDEV) { | 5611 | dev_put(info->user_ptr[1]); |
7221 | struct wireless_dev *wdev = info->user_ptr[1]; | ||
7222 | |||
7223 | if (wdev->netdev) | ||
7224 | dev_put(wdev->netdev); | ||
7225 | } else { | ||
7226 | dev_put(info->user_ptr[1]); | ||
7227 | } | ||
7228 | } | ||
7229 | if (ops->internal_flags & NL80211_FLAG_NEED_RTNL) | 5612 | if (ops->internal_flags & NL80211_FLAG_NEED_RTNL) |
7230 | rtnl_unlock(); | 5613 | rtnl_unlock(); |
7231 | } | 5614 | } |
@@ -7252,7 +5635,7 @@ static struct genl_ops nl80211_ops[] = { | |||
7252 | .dumpit = nl80211_dump_interface, | 5635 | .dumpit = nl80211_dump_interface, |
7253 | .policy = nl80211_policy, | 5636 | .policy = nl80211_policy, |
7254 | /* can be retrieved by unprivileged users */ | 5637 | /* can be retrieved by unprivileged users */ |
7255 | .internal_flags = NL80211_FLAG_NEED_WDEV, | 5638 | .internal_flags = NL80211_FLAG_NEED_NETDEV, |
7256 | }, | 5639 | }, |
7257 | { | 5640 | { |
7258 | .cmd = NL80211_CMD_SET_INTERFACE, | 5641 | .cmd = NL80211_CMD_SET_INTERFACE, |
@@ -7275,7 +5658,7 @@ static struct genl_ops nl80211_ops[] = { | |||
7275 | .doit = nl80211_del_interface, | 5658 | .doit = nl80211_del_interface, |
7276 | .policy = nl80211_policy, | 5659 | .policy = nl80211_policy, |
7277 | .flags = GENL_ADMIN_PERM, | 5660 | .flags = GENL_ADMIN_PERM, |
7278 | .internal_flags = NL80211_FLAG_NEED_WDEV | | 5661 | .internal_flags = NL80211_FLAG_NEED_NETDEV | |
7279 | NL80211_FLAG_NEED_RTNL, | 5662 | NL80211_FLAG_NEED_RTNL, |
7280 | }, | 5663 | }, |
7281 | { | 5664 | { |
@@ -7283,7 +5666,7 @@ static struct genl_ops nl80211_ops[] = { | |||
7283 | .doit = nl80211_get_key, | 5666 | .doit = nl80211_get_key, |
7284 | .policy = nl80211_policy, | 5667 | .policy = nl80211_policy, |
7285 | .flags = GENL_ADMIN_PERM, | 5668 | .flags = GENL_ADMIN_PERM, |
7286 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | | 5669 | .internal_flags = NL80211_FLAG_NEED_NETDEV | |
7287 | NL80211_FLAG_NEED_RTNL, | 5670 | NL80211_FLAG_NEED_RTNL, |
7288 | }, | 5671 | }, |
7289 | { | 5672 | { |
@@ -7314,24 +5697,24 @@ static struct genl_ops nl80211_ops[] = { | |||
7314 | .cmd = NL80211_CMD_SET_BEACON, | 5697 | .cmd = NL80211_CMD_SET_BEACON, |
7315 | .policy = nl80211_policy, | 5698 | .policy = nl80211_policy, |
7316 | .flags = GENL_ADMIN_PERM, | 5699 | .flags = GENL_ADMIN_PERM, |
7317 | .doit = nl80211_set_beacon, | 5700 | .doit = nl80211_addset_beacon, |
7318 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | | 5701 | .internal_flags = NL80211_FLAG_NEED_NETDEV | |
7319 | NL80211_FLAG_NEED_RTNL, | 5702 | NL80211_FLAG_NEED_RTNL, |
7320 | }, | 5703 | }, |
7321 | { | 5704 | { |
7322 | .cmd = NL80211_CMD_START_AP, | 5705 | .cmd = NL80211_CMD_NEW_BEACON, |
7323 | .policy = nl80211_policy, | 5706 | .policy = nl80211_policy, |
7324 | .flags = GENL_ADMIN_PERM, | 5707 | .flags = GENL_ADMIN_PERM, |
7325 | .doit = nl80211_start_ap, | 5708 | .doit = nl80211_addset_beacon, |
7326 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | | 5709 | .internal_flags = NL80211_FLAG_NEED_NETDEV | |
7327 | NL80211_FLAG_NEED_RTNL, | 5710 | NL80211_FLAG_NEED_RTNL, |
7328 | }, | 5711 | }, |
7329 | { | 5712 | { |
7330 | .cmd = NL80211_CMD_STOP_AP, | 5713 | .cmd = NL80211_CMD_DEL_BEACON, |
7331 | .policy = nl80211_policy, | 5714 | .policy = nl80211_policy, |
7332 | .flags = GENL_ADMIN_PERM, | 5715 | .flags = GENL_ADMIN_PERM, |
7333 | .doit = nl80211_stop_ap, | 5716 | .doit = nl80211_del_beacon, |
7334 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | | 5717 | .internal_flags = NL80211_FLAG_NEED_NETDEV | |
7335 | NL80211_FLAG_NEED_RTNL, | 5718 | NL80211_FLAG_NEED_RTNL, |
7336 | }, | 5719 | }, |
7337 | { | 5720 | { |
@@ -7347,7 +5730,7 @@ static struct genl_ops nl80211_ops[] = { | |||
7347 | .doit = nl80211_set_station, | 5730 | .doit = nl80211_set_station, |
7348 | .policy = nl80211_policy, | 5731 | .policy = nl80211_policy, |
7349 | .flags = GENL_ADMIN_PERM, | 5732 | .flags = GENL_ADMIN_PERM, |
7350 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | | 5733 | .internal_flags = NL80211_FLAG_NEED_NETDEV | |
7351 | NL80211_FLAG_NEED_RTNL, | 5734 | NL80211_FLAG_NEED_RTNL, |
7352 | }, | 5735 | }, |
7353 | { | 5736 | { |
@@ -7363,7 +5746,7 @@ static struct genl_ops nl80211_ops[] = { | |||
7363 | .doit = nl80211_del_station, | 5746 | .doit = nl80211_del_station, |
7364 | .policy = nl80211_policy, | 5747 | .policy = nl80211_policy, |
7365 | .flags = GENL_ADMIN_PERM, | 5748 | .flags = GENL_ADMIN_PERM, |
7366 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | | 5749 | .internal_flags = NL80211_FLAG_NEED_NETDEV | |
7367 | NL80211_FLAG_NEED_RTNL, | 5750 | NL80211_FLAG_NEED_RTNL, |
7368 | }, | 5751 | }, |
7369 | { | 5752 | { |
@@ -7396,7 +5779,7 @@ static struct genl_ops nl80211_ops[] = { | |||
7396 | .doit = nl80211_del_mpath, | 5779 | .doit = nl80211_del_mpath, |
7397 | .policy = nl80211_policy, | 5780 | .policy = nl80211_policy, |
7398 | .flags = GENL_ADMIN_PERM, | 5781 | .flags = GENL_ADMIN_PERM, |
7399 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | | 5782 | .internal_flags = NL80211_FLAG_NEED_NETDEV | |
7400 | NL80211_FLAG_NEED_RTNL, | 5783 | NL80211_FLAG_NEED_RTNL, |
7401 | }, | 5784 | }, |
7402 | { | 5785 | { |
@@ -7404,7 +5787,7 @@ static struct genl_ops nl80211_ops[] = { | |||
7404 | .doit = nl80211_set_bss, | 5787 | .doit = nl80211_set_bss, |
7405 | .policy = nl80211_policy, | 5788 | .policy = nl80211_policy, |
7406 | .flags = GENL_ADMIN_PERM, | 5789 | .flags = GENL_ADMIN_PERM, |
7407 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | | 5790 | .internal_flags = NL80211_FLAG_NEED_NETDEV | |
7408 | NL80211_FLAG_NEED_RTNL, | 5791 | NL80211_FLAG_NEED_RTNL, |
7409 | }, | 5792 | }, |
7410 | { | 5793 | { |
@@ -7430,7 +5813,7 @@ static struct genl_ops nl80211_ops[] = { | |||
7430 | .doit = nl80211_get_mesh_config, | 5813 | .doit = nl80211_get_mesh_config, |
7431 | .policy = nl80211_policy, | 5814 | .policy = nl80211_policy, |
7432 | /* can be retrieved by unprivileged users */ | 5815 | /* can be retrieved by unprivileged users */ |
7433 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | | 5816 | .internal_flags = NL80211_FLAG_NEED_NETDEV | |
7434 | NL80211_FLAG_NEED_RTNL, | 5817 | NL80211_FLAG_NEED_RTNL, |
7435 | }, | 5818 | }, |
7436 | { | 5819 | { |
@@ -7446,7 +5829,7 @@ static struct genl_ops nl80211_ops[] = { | |||
7446 | .doit = nl80211_trigger_scan, | 5829 | .doit = nl80211_trigger_scan, |
7447 | .policy = nl80211_policy, | 5830 | .policy = nl80211_policy, |
7448 | .flags = GENL_ADMIN_PERM, | 5831 | .flags = GENL_ADMIN_PERM, |
7449 | .internal_flags = NL80211_FLAG_NEED_WDEV_UP | | 5832 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | |
7450 | NL80211_FLAG_NEED_RTNL, | 5833 | NL80211_FLAG_NEED_RTNL, |
7451 | }, | 5834 | }, |
7452 | { | 5835 | { |
@@ -7563,7 +5946,7 @@ static struct genl_ops nl80211_ops[] = { | |||
7563 | .doit = nl80211_setdel_pmksa, | 5946 | .doit = nl80211_setdel_pmksa, |
7564 | .policy = nl80211_policy, | 5947 | .policy = nl80211_policy, |
7565 | .flags = GENL_ADMIN_PERM, | 5948 | .flags = GENL_ADMIN_PERM, |
7566 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | | 5949 | .internal_flags = NL80211_FLAG_NEED_NETDEV | |
7567 | NL80211_FLAG_NEED_RTNL, | 5950 | NL80211_FLAG_NEED_RTNL, |
7568 | }, | 5951 | }, |
7569 | { | 5952 | { |
@@ -7571,7 +5954,7 @@ static struct genl_ops nl80211_ops[] = { | |||
7571 | .doit = nl80211_setdel_pmksa, | 5954 | .doit = nl80211_setdel_pmksa, |
7572 | .policy = nl80211_policy, | 5955 | .policy = nl80211_policy, |
7573 | .flags = GENL_ADMIN_PERM, | 5956 | .flags = GENL_ADMIN_PERM, |
7574 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | | 5957 | .internal_flags = NL80211_FLAG_NEED_NETDEV | |
7575 | NL80211_FLAG_NEED_RTNL, | 5958 | NL80211_FLAG_NEED_RTNL, |
7576 | }, | 5959 | }, |
7577 | { | 5960 | { |
@@ -7579,7 +5962,7 @@ static struct genl_ops nl80211_ops[] = { | |||
7579 | .doit = nl80211_flush_pmksa, | 5962 | .doit = nl80211_flush_pmksa, |
7580 | .policy = nl80211_policy, | 5963 | .policy = nl80211_policy, |
7581 | .flags = GENL_ADMIN_PERM, | 5964 | .flags = GENL_ADMIN_PERM, |
7582 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | | 5965 | .internal_flags = NL80211_FLAG_NEED_NETDEV | |
7583 | NL80211_FLAG_NEED_RTNL, | 5966 | NL80211_FLAG_NEED_RTNL, |
7584 | }, | 5967 | }, |
7585 | { | 5968 | { |
@@ -7587,7 +5970,7 @@ static struct genl_ops nl80211_ops[] = { | |||
7587 | .doit = nl80211_remain_on_channel, | 5970 | .doit = nl80211_remain_on_channel, |
7588 | .policy = nl80211_policy, | 5971 | .policy = nl80211_policy, |
7589 | .flags = GENL_ADMIN_PERM, | 5972 | .flags = GENL_ADMIN_PERM, |
7590 | .internal_flags = NL80211_FLAG_NEED_WDEV_UP | | 5973 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | |
7591 | NL80211_FLAG_NEED_RTNL, | 5974 | NL80211_FLAG_NEED_RTNL, |
7592 | }, | 5975 | }, |
7593 | { | 5976 | { |
@@ -7595,7 +5978,7 @@ static struct genl_ops nl80211_ops[] = { | |||
7595 | .doit = nl80211_cancel_remain_on_channel, | 5978 | .doit = nl80211_cancel_remain_on_channel, |
7596 | .policy = nl80211_policy, | 5979 | .policy = nl80211_policy, |
7597 | .flags = GENL_ADMIN_PERM, | 5980 | .flags = GENL_ADMIN_PERM, |
7598 | .internal_flags = NL80211_FLAG_NEED_WDEV_UP | | 5981 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | |
7599 | NL80211_FLAG_NEED_RTNL, | 5982 | NL80211_FLAG_NEED_RTNL, |
7600 | }, | 5983 | }, |
7601 | { | 5984 | { |
@@ -7611,7 +5994,7 @@ static struct genl_ops nl80211_ops[] = { | |||
7611 | .doit = nl80211_register_mgmt, | 5994 | .doit = nl80211_register_mgmt, |
7612 | .policy = nl80211_policy, | 5995 | .policy = nl80211_policy, |
7613 | .flags = GENL_ADMIN_PERM, | 5996 | .flags = GENL_ADMIN_PERM, |
7614 | .internal_flags = NL80211_FLAG_NEED_WDEV | | 5997 | .internal_flags = NL80211_FLAG_NEED_NETDEV | |
7615 | NL80211_FLAG_NEED_RTNL, | 5998 | NL80211_FLAG_NEED_RTNL, |
7616 | }, | 5999 | }, |
7617 | { | 6000 | { |
@@ -7619,7 +6002,7 @@ static struct genl_ops nl80211_ops[] = { | |||
7619 | .doit = nl80211_tx_mgmt, | 6002 | .doit = nl80211_tx_mgmt, |
7620 | .policy = nl80211_policy, | 6003 | .policy = nl80211_policy, |
7621 | .flags = GENL_ADMIN_PERM, | 6004 | .flags = GENL_ADMIN_PERM, |
7622 | .internal_flags = NL80211_FLAG_NEED_WDEV_UP | | 6005 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | |
7623 | NL80211_FLAG_NEED_RTNL, | 6006 | NL80211_FLAG_NEED_RTNL, |
7624 | }, | 6007 | }, |
7625 | { | 6008 | { |
@@ -7627,7 +6010,7 @@ static struct genl_ops nl80211_ops[] = { | |||
7627 | .doit = nl80211_tx_mgmt_cancel_wait, | 6010 | .doit = nl80211_tx_mgmt_cancel_wait, |
7628 | .policy = nl80211_policy, | 6011 | .policy = nl80211_policy, |
7629 | .flags = GENL_ADMIN_PERM, | 6012 | .flags = GENL_ADMIN_PERM, |
7630 | .internal_flags = NL80211_FLAG_NEED_WDEV_UP | | 6013 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | |
7631 | NL80211_FLAG_NEED_RTNL, | 6014 | NL80211_FLAG_NEED_RTNL, |
7632 | }, | 6015 | }, |
7633 | { | 6016 | { |
@@ -7686,7 +6069,6 @@ static struct genl_ops nl80211_ops[] = { | |||
7686 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | | 6069 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | |
7687 | NL80211_FLAG_NEED_RTNL, | 6070 | NL80211_FLAG_NEED_RTNL, |
7688 | }, | 6071 | }, |
7689 | #ifdef CONFIG_PM | ||
7690 | { | 6072 | { |
7691 | .cmd = NL80211_CMD_GET_WOWLAN, | 6073 | .cmd = NL80211_CMD_GET_WOWLAN, |
7692 | .doit = nl80211_get_wowlan, | 6074 | .doit = nl80211_get_wowlan, |
@@ -7703,7 +6085,6 @@ static struct genl_ops nl80211_ops[] = { | |||
7703 | .internal_flags = NL80211_FLAG_NEED_WIPHY | | 6085 | .internal_flags = NL80211_FLAG_NEED_WIPHY | |
7704 | NL80211_FLAG_NEED_RTNL, | 6086 | NL80211_FLAG_NEED_RTNL, |
7705 | }, | 6087 | }, |
7706 | #endif | ||
7707 | { | 6088 | { |
7708 | .cmd = NL80211_CMD_SET_REKEY_OFFLOAD, | 6089 | .cmd = NL80211_CMD_SET_REKEY_OFFLOAD, |
7709 | .doit = nl80211_set_rekey_data, | 6090 | .doit = nl80211_set_rekey_data, |
@@ -7712,78 +6093,6 @@ static struct genl_ops nl80211_ops[] = { | |||
7712 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | | 6093 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | |
7713 | NL80211_FLAG_NEED_RTNL, | 6094 | NL80211_FLAG_NEED_RTNL, |
7714 | }, | 6095 | }, |
7715 | { | ||
7716 | .cmd = NL80211_CMD_TDLS_MGMT, | ||
7717 | .doit = nl80211_tdls_mgmt, | ||
7718 | .policy = nl80211_policy, | ||
7719 | .flags = GENL_ADMIN_PERM, | ||
7720 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | | ||
7721 | NL80211_FLAG_NEED_RTNL, | ||
7722 | }, | ||
7723 | { | ||
7724 | .cmd = NL80211_CMD_TDLS_OPER, | ||
7725 | .doit = nl80211_tdls_oper, | ||
7726 | .policy = nl80211_policy, | ||
7727 | .flags = GENL_ADMIN_PERM, | ||
7728 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | | ||
7729 | NL80211_FLAG_NEED_RTNL, | ||
7730 | }, | ||
7731 | { | ||
7732 | .cmd = NL80211_CMD_UNEXPECTED_FRAME, | ||
7733 | .doit = nl80211_register_unexpected_frame, | ||
7734 | .policy = nl80211_policy, | ||
7735 | .flags = GENL_ADMIN_PERM, | ||
7736 | .internal_flags = NL80211_FLAG_NEED_NETDEV | | ||
7737 | NL80211_FLAG_NEED_RTNL, | ||
7738 | }, | ||
7739 | { | ||
7740 | .cmd = NL80211_CMD_PROBE_CLIENT, | ||
7741 | .doit = nl80211_probe_client, | ||
7742 | .policy = nl80211_policy, | ||
7743 | .flags = GENL_ADMIN_PERM, | ||
7744 | .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | | ||
7745 | NL80211_FLAG_NEED_RTNL, | ||
7746 | }, | ||
7747 | { | ||
7748 | .cmd = NL80211_CMD_REGISTER_BEACONS, | ||
7749 | .doit = nl80211_register_beacons, | ||
7750 | .policy = nl80211_policy, | ||
7751 | .flags = GENL_ADMIN_PERM, | ||
7752 | .internal_flags = NL80211_FLAG_NEED_WIPHY | | ||
7753 | NL80211_FLAG_NEED_RTNL, | ||
7754 | }, | ||
7755 | { | ||
7756 | .cmd = NL80211_CMD_SET_NOACK_MAP, | ||
7757 | .doit = nl80211_set_noack_map, | ||
7758 | .policy = nl80211_policy, | ||
7759 | .flags = GENL_ADMIN_PERM, | ||
7760 | .internal_flags = NL80211_FLAG_NEED_NETDEV | | ||
7761 | NL80211_FLAG_NEED_RTNL, | ||
7762 | }, | ||
7763 | { | ||
7764 | .cmd = NL80211_CMD_START_P2P_DEVICE, | ||
7765 | .doit = nl80211_start_p2p_device, | ||
7766 | .policy = nl80211_policy, | ||
7767 | .flags = GENL_ADMIN_PERM, | ||
7768 | .internal_flags = NL80211_FLAG_NEED_WDEV | | ||
7769 | NL80211_FLAG_NEED_RTNL, | ||
7770 | }, | ||
7771 | { | ||
7772 | .cmd = NL80211_CMD_STOP_P2P_DEVICE, | ||
7773 | .doit = nl80211_stop_p2p_device, | ||
7774 | .policy = nl80211_policy, | ||
7775 | .flags = GENL_ADMIN_PERM, | ||
7776 | .internal_flags = NL80211_FLAG_NEED_WDEV_UP | | ||
7777 | NL80211_FLAG_NEED_RTNL, | ||
7778 | }, | ||
7779 | { | ||
7780 | .cmd = NL80211_CMD_SET_MCAST_RATE, | ||
7781 | .doit = nl80211_set_mcast_rate, | ||
7782 | .policy = nl80211_policy, | ||
7783 | .flags = GENL_ADMIN_PERM, | ||
7784 | .internal_flags = NL80211_FLAG_NEED_NETDEV | | ||
7785 | NL80211_FLAG_NEED_RTNL, | ||
7786 | }, | ||
7787 | }; | 6096 | }; |
7788 | 6097 | ||
7789 | static struct genl_multicast_group nl80211_mlme_mcgrp = { | 6098 | static struct genl_multicast_group nl80211_mlme_mcgrp = { |
@@ -7835,27 +6144,19 @@ static int nl80211_add_scan_req(struct sk_buff *msg, | |||
7835 | nest = nla_nest_start(msg, NL80211_ATTR_SCAN_SSIDS); | 6144 | nest = nla_nest_start(msg, NL80211_ATTR_SCAN_SSIDS); |
7836 | if (!nest) | 6145 | if (!nest) |
7837 | goto nla_put_failure; | 6146 | goto nla_put_failure; |
7838 | for (i = 0; i < req->n_ssids; i++) { | 6147 | for (i = 0; i < req->n_ssids; i++) |
7839 | if (nla_put(msg, i, req->ssids[i].ssid_len, req->ssids[i].ssid)) | 6148 | NLA_PUT(msg, i, req->ssids[i].ssid_len, req->ssids[i].ssid); |
7840 | goto nla_put_failure; | ||
7841 | } | ||
7842 | nla_nest_end(msg, nest); | 6149 | nla_nest_end(msg, nest); |
7843 | 6150 | ||
7844 | nest = nla_nest_start(msg, NL80211_ATTR_SCAN_FREQUENCIES); | 6151 | nest = nla_nest_start(msg, NL80211_ATTR_SCAN_FREQUENCIES); |
7845 | if (!nest) | 6152 | if (!nest) |
7846 | goto nla_put_failure; | 6153 | goto nla_put_failure; |
7847 | for (i = 0; i < req->n_channels; i++) { | 6154 | for (i = 0; i < req->n_channels; i++) |
7848 | if (nla_put_u32(msg, i, req->channels[i]->center_freq)) | 6155 | NLA_PUT_U32(msg, i, req->channels[i]->center_freq); |
7849 | goto nla_put_failure; | ||
7850 | } | ||
7851 | nla_nest_end(msg, nest); | 6156 | nla_nest_end(msg, nest); |
7852 | 6157 | ||
7853 | if (req->ie && | 6158 | if (req->ie) |
7854 | nla_put(msg, NL80211_ATTR_IE, req->ie_len, req->ie)) | 6159 | NLA_PUT(msg, NL80211_ATTR_IE, req->ie_len, req->ie); |
7855 | goto nla_put_failure; | ||
7856 | |||
7857 | if (req->flags) | ||
7858 | nla_put_u32(msg, NL80211_ATTR_SCAN_FLAGS, req->flags); | ||
7859 | 6160 | ||
7860 | return 0; | 6161 | return 0; |
7861 | nla_put_failure: | 6162 | nla_put_failure: |
@@ -7864,21 +6165,18 @@ static int nl80211_add_scan_req(struct sk_buff *msg, | |||
7864 | 6165 | ||
7865 | static int nl80211_send_scan_msg(struct sk_buff *msg, | 6166 | static int nl80211_send_scan_msg(struct sk_buff *msg, |
7866 | struct cfg80211_registered_device *rdev, | 6167 | struct cfg80211_registered_device *rdev, |
7867 | struct wireless_dev *wdev, | 6168 | struct net_device *netdev, |
7868 | u32 portid, u32 seq, int flags, | 6169 | u32 pid, u32 seq, int flags, |
7869 | u32 cmd) | 6170 | u32 cmd) |
7870 | { | 6171 | { |
7871 | void *hdr; | 6172 | void *hdr; |
7872 | 6173 | ||
7873 | hdr = nl80211hdr_put(msg, portid, seq, flags, cmd); | 6174 | hdr = nl80211hdr_put(msg, pid, seq, flags, cmd); |
7874 | if (!hdr) | 6175 | if (!hdr) |
7875 | return -1; | 6176 | return -1; |
7876 | 6177 | ||
7877 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | 6178 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); |
7878 | (wdev->netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX, | 6179 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); |
7879 | wdev->netdev->ifindex)) || | ||
7880 | nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev))) | ||
7881 | goto nla_put_failure; | ||
7882 | 6180 | ||
7883 | /* ignore errors and send incomplete event anyway */ | 6181 | /* ignore errors and send incomplete event anyway */ |
7884 | nl80211_add_scan_req(msg, rdev); | 6182 | nl80211_add_scan_req(msg, rdev); |
@@ -7894,17 +6192,16 @@ static int | |||
7894 | nl80211_send_sched_scan_msg(struct sk_buff *msg, | 6192 | nl80211_send_sched_scan_msg(struct sk_buff *msg, |
7895 | struct cfg80211_registered_device *rdev, | 6193 | struct cfg80211_registered_device *rdev, |
7896 | struct net_device *netdev, | 6194 | struct net_device *netdev, |
7897 | u32 portid, u32 seq, int flags, u32 cmd) | 6195 | u32 pid, u32 seq, int flags, u32 cmd) |
7898 | { | 6196 | { |
7899 | void *hdr; | 6197 | void *hdr; |
7900 | 6198 | ||
7901 | hdr = nl80211hdr_put(msg, portid, seq, flags, cmd); | 6199 | hdr = nl80211hdr_put(msg, pid, seq, flags, cmd); |
7902 | if (!hdr) | 6200 | if (!hdr) |
7903 | return -1; | 6201 | return -1; |
7904 | 6202 | ||
7905 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | 6203 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); |
7906 | nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) | 6204 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); |
7907 | goto nla_put_failure; | ||
7908 | 6205 | ||
7909 | return genlmsg_end(msg, hdr); | 6206 | return genlmsg_end(msg, hdr); |
7910 | 6207 | ||
@@ -7914,15 +6211,15 @@ nl80211_send_sched_scan_msg(struct sk_buff *msg, | |||
7914 | } | 6211 | } |
7915 | 6212 | ||
7916 | void nl80211_send_scan_start(struct cfg80211_registered_device *rdev, | 6213 | void nl80211_send_scan_start(struct cfg80211_registered_device *rdev, |
7917 | struct wireless_dev *wdev) | 6214 | struct net_device *netdev) |
7918 | { | 6215 | { |
7919 | struct sk_buff *msg; | 6216 | struct sk_buff *msg; |
7920 | 6217 | ||
7921 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | 6218 | msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); |
7922 | if (!msg) | 6219 | if (!msg) |
7923 | return; | 6220 | return; |
7924 | 6221 | ||
7925 | if (nl80211_send_scan_msg(msg, rdev, wdev, 0, 0, 0, | 6222 | if (nl80211_send_scan_msg(msg, rdev, netdev, 0, 0, 0, |
7926 | NL80211_CMD_TRIGGER_SCAN) < 0) { | 6223 | NL80211_CMD_TRIGGER_SCAN) < 0) { |
7927 | nlmsg_free(msg); | 6224 | nlmsg_free(msg); |
7928 | return; | 6225 | return; |
@@ -7933,7 +6230,7 @@ void nl80211_send_scan_start(struct cfg80211_registered_device *rdev, | |||
7933 | } | 6230 | } |
7934 | 6231 | ||
7935 | void nl80211_send_scan_done(struct cfg80211_registered_device *rdev, | 6232 | void nl80211_send_scan_done(struct cfg80211_registered_device *rdev, |
7936 | struct wireless_dev *wdev) | 6233 | struct net_device *netdev) |
7937 | { | 6234 | { |
7938 | struct sk_buff *msg; | 6235 | struct sk_buff *msg; |
7939 | 6236 | ||
@@ -7941,7 +6238,7 @@ void nl80211_send_scan_done(struct cfg80211_registered_device *rdev, | |||
7941 | if (!msg) | 6238 | if (!msg) |
7942 | return; | 6239 | return; |
7943 | 6240 | ||
7944 | if (nl80211_send_scan_msg(msg, rdev, wdev, 0, 0, 0, | 6241 | if (nl80211_send_scan_msg(msg, rdev, netdev, 0, 0, 0, |
7945 | NL80211_CMD_NEW_SCAN_RESULTS) < 0) { | 6242 | NL80211_CMD_NEW_SCAN_RESULTS) < 0) { |
7946 | nlmsg_free(msg); | 6243 | nlmsg_free(msg); |
7947 | return; | 6244 | return; |
@@ -7952,7 +6249,7 @@ void nl80211_send_scan_done(struct cfg80211_registered_device *rdev, | |||
7952 | } | 6249 | } |
7953 | 6250 | ||
7954 | void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev, | 6251 | void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev, |
7955 | struct wireless_dev *wdev) | 6252 | struct net_device *netdev) |
7956 | { | 6253 | { |
7957 | struct sk_buff *msg; | 6254 | struct sk_buff *msg; |
7958 | 6255 | ||
@@ -7960,7 +6257,7 @@ void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev, | |||
7960 | if (!msg) | 6257 | if (!msg) |
7961 | return; | 6258 | return; |
7962 | 6259 | ||
7963 | if (nl80211_send_scan_msg(msg, rdev, wdev, 0, 0, 0, | 6260 | if (nl80211_send_scan_msg(msg, rdev, netdev, 0, 0, 0, |
7964 | NL80211_CMD_SCAN_ABORTED) < 0) { | 6261 | NL80211_CMD_SCAN_ABORTED) < 0) { |
7965 | nlmsg_free(msg); | 6262 | nlmsg_free(msg); |
7966 | return; | 6263 | return; |
@@ -7994,7 +6291,7 @@ void nl80211_send_sched_scan(struct cfg80211_registered_device *rdev, | |||
7994 | { | 6291 | { |
7995 | struct sk_buff *msg; | 6292 | struct sk_buff *msg; |
7996 | 6293 | ||
7997 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | 6294 | msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); |
7998 | if (!msg) | 6295 | if (!msg) |
7999 | return; | 6296 | return; |
8000 | 6297 | ||
@@ -8027,36 +6324,32 @@ void nl80211_send_reg_change_event(struct regulatory_request *request) | |||
8027 | } | 6324 | } |
8028 | 6325 | ||
8029 | /* Userspace can always count this one always being set */ | 6326 | /* Userspace can always count this one always being set */ |
8030 | if (nla_put_u8(msg, NL80211_ATTR_REG_INITIATOR, request->initiator)) | 6327 | NLA_PUT_U8(msg, NL80211_ATTR_REG_INITIATOR, request->initiator); |
8031 | goto nla_put_failure; | 6328 | |
8032 | 6329 | if (request->alpha2[0] == '0' && request->alpha2[1] == '0') | |
8033 | if (request->alpha2[0] == '0' && request->alpha2[1] == '0') { | 6330 | NLA_PUT_U8(msg, NL80211_ATTR_REG_TYPE, |
8034 | if (nla_put_u8(msg, NL80211_ATTR_REG_TYPE, | 6331 | NL80211_REGDOM_TYPE_WORLD); |
8035 | NL80211_REGDOM_TYPE_WORLD)) | 6332 | else if (request->alpha2[0] == '9' && request->alpha2[1] == '9') |
8036 | goto nla_put_failure; | 6333 | NLA_PUT_U8(msg, NL80211_ATTR_REG_TYPE, |
8037 | } else if (request->alpha2[0] == '9' && request->alpha2[1] == '9') { | 6334 | NL80211_REGDOM_TYPE_CUSTOM_WORLD); |
8038 | if (nla_put_u8(msg, NL80211_ATTR_REG_TYPE, | 6335 | else if ((request->alpha2[0] == '9' && request->alpha2[1] == '8') || |
8039 | NL80211_REGDOM_TYPE_CUSTOM_WORLD)) | 6336 | request->intersect) |
8040 | goto nla_put_failure; | 6337 | NLA_PUT_U8(msg, NL80211_ATTR_REG_TYPE, |
8041 | } else if ((request->alpha2[0] == '9' && request->alpha2[1] == '8') || | 6338 | NL80211_REGDOM_TYPE_INTERSECTION); |
8042 | request->intersect) { | 6339 | else { |
8043 | if (nla_put_u8(msg, NL80211_ATTR_REG_TYPE, | 6340 | NLA_PUT_U8(msg, NL80211_ATTR_REG_TYPE, |
8044 | NL80211_REGDOM_TYPE_INTERSECTION)) | 6341 | NL80211_REGDOM_TYPE_COUNTRY); |
8045 | goto nla_put_failure; | 6342 | NLA_PUT_STRING(msg, NL80211_ATTR_REG_ALPHA2, request->alpha2); |
8046 | } else { | 6343 | } |
8047 | if (nla_put_u8(msg, NL80211_ATTR_REG_TYPE, | 6344 | |
8048 | NL80211_REGDOM_TYPE_COUNTRY) || | 6345 | if (wiphy_idx_valid(request->wiphy_idx)) |
8049 | nla_put_string(msg, NL80211_ATTR_REG_ALPHA2, | 6346 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, request->wiphy_idx); |
8050 | request->alpha2)) | 6347 | |
8051 | goto nla_put_failure; | 6348 | if (genlmsg_end(msg, hdr) < 0) { |
6349 | nlmsg_free(msg); | ||
6350 | return; | ||
8052 | } | 6351 | } |
8053 | 6352 | ||
8054 | if (wiphy_idx_valid(request->wiphy_idx) && | ||
8055 | nla_put_u32(msg, NL80211_ATTR_WIPHY, request->wiphy_idx)) | ||
8056 | goto nla_put_failure; | ||
8057 | |||
8058 | genlmsg_end(msg, hdr); | ||
8059 | |||
8060 | rcu_read_lock(); | 6353 | rcu_read_lock(); |
8061 | genlmsg_multicast_allns(msg, 0, nl80211_regulatory_mcgrp.id, | 6354 | genlmsg_multicast_allns(msg, 0, nl80211_regulatory_mcgrp.id, |
8062 | GFP_ATOMIC); | 6355 | GFP_ATOMIC); |
@@ -8087,12 +6380,14 @@ static void nl80211_send_mlme_event(struct cfg80211_registered_device *rdev, | |||
8087 | return; | 6380 | return; |
8088 | } | 6381 | } |
8089 | 6382 | ||
8090 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | 6383 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); |
8091 | nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || | 6384 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); |
8092 | nla_put(msg, NL80211_ATTR_FRAME, len, buf)) | 6385 | NLA_PUT(msg, NL80211_ATTR_FRAME, len, buf); |
8093 | goto nla_put_failure; | ||
8094 | 6386 | ||
8095 | genlmsg_end(msg, hdr); | 6387 | if (genlmsg_end(msg, hdr) < 0) { |
6388 | nlmsg_free(msg); | ||
6389 | return; | ||
6390 | } | ||
8096 | 6391 | ||
8097 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, | 6392 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, |
8098 | nl80211_mlme_mcgrp.id, gfp); | 6393 | nl80211_mlme_mcgrp.id, gfp); |
@@ -8168,13 +6463,15 @@ static void nl80211_send_mlme_timeout(struct cfg80211_registered_device *rdev, | |||
8168 | return; | 6463 | return; |
8169 | } | 6464 | } |
8170 | 6465 | ||
8171 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | 6466 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); |
8172 | nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || | 6467 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); |
8173 | nla_put_flag(msg, NL80211_ATTR_TIMED_OUT) || | 6468 | NLA_PUT_FLAG(msg, NL80211_ATTR_TIMED_OUT); |
8174 | nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr)) | 6469 | NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr); |
8175 | goto nla_put_failure; | ||
8176 | 6470 | ||
8177 | genlmsg_end(msg, hdr); | 6471 | if (genlmsg_end(msg, hdr) < 0) { |
6472 | nlmsg_free(msg); | ||
6473 | return; | ||
6474 | } | ||
8178 | 6475 | ||
8179 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, | 6476 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, |
8180 | nl80211_mlme_mcgrp.id, gfp); | 6477 | nl80211_mlme_mcgrp.id, gfp); |
@@ -8210,7 +6507,7 @@ void nl80211_send_connect_result(struct cfg80211_registered_device *rdev, | |||
8210 | struct sk_buff *msg; | 6507 | struct sk_buff *msg; |
8211 | void *hdr; | 6508 | void *hdr; |
8212 | 6509 | ||
8213 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); | 6510 | msg = nlmsg_new(NLMSG_GOODSIZE, gfp); |
8214 | if (!msg) | 6511 | if (!msg) |
8215 | return; | 6512 | return; |
8216 | 6513 | ||
@@ -8220,17 +6517,20 @@ void nl80211_send_connect_result(struct cfg80211_registered_device *rdev, | |||
8220 | return; | 6517 | return; |
8221 | } | 6518 | } |
8222 | 6519 | ||
8223 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | 6520 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); |
8224 | nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || | 6521 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); |
8225 | (bssid && nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid)) || | 6522 | if (bssid) |
8226 | nla_put_u16(msg, NL80211_ATTR_STATUS_CODE, status) || | 6523 | NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid); |
8227 | (req_ie && | 6524 | NLA_PUT_U16(msg, NL80211_ATTR_STATUS_CODE, status); |
8228 | nla_put(msg, NL80211_ATTR_REQ_IE, req_ie_len, req_ie)) || | 6525 | if (req_ie) |
8229 | (resp_ie && | 6526 | NLA_PUT(msg, NL80211_ATTR_REQ_IE, req_ie_len, req_ie); |
8230 | nla_put(msg, NL80211_ATTR_RESP_IE, resp_ie_len, resp_ie))) | 6527 | if (resp_ie) |
8231 | goto nla_put_failure; | 6528 | NLA_PUT(msg, NL80211_ATTR_RESP_IE, resp_ie_len, resp_ie); |
8232 | 6529 | ||
8233 | genlmsg_end(msg, hdr); | 6530 | if (genlmsg_end(msg, hdr) < 0) { |
6531 | nlmsg_free(msg); | ||
6532 | return; | ||
6533 | } | ||
8234 | 6534 | ||
8235 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, | 6535 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, |
8236 | nl80211_mlme_mcgrp.id, gfp); | 6536 | nl80211_mlme_mcgrp.id, gfp); |
@@ -8250,7 +6550,7 @@ void nl80211_send_roamed(struct cfg80211_registered_device *rdev, | |||
8250 | struct sk_buff *msg; | 6550 | struct sk_buff *msg; |
8251 | void *hdr; | 6551 | void *hdr; |
8252 | 6552 | ||
8253 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); | 6553 | msg = nlmsg_new(NLMSG_GOODSIZE, gfp); |
8254 | if (!msg) | 6554 | if (!msg) |
8255 | return; | 6555 | return; |
8256 | 6556 | ||
@@ -8260,16 +6560,18 @@ void nl80211_send_roamed(struct cfg80211_registered_device *rdev, | |||
8260 | return; | 6560 | return; |
8261 | } | 6561 | } |
8262 | 6562 | ||
8263 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | 6563 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); |
8264 | nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || | 6564 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); |
8265 | nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid) || | 6565 | NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid); |
8266 | (req_ie && | 6566 | if (req_ie) |
8267 | nla_put(msg, NL80211_ATTR_REQ_IE, req_ie_len, req_ie)) || | 6567 | NLA_PUT(msg, NL80211_ATTR_REQ_IE, req_ie_len, req_ie); |
8268 | (resp_ie && | 6568 | if (resp_ie) |
8269 | nla_put(msg, NL80211_ATTR_RESP_IE, resp_ie_len, resp_ie))) | 6569 | NLA_PUT(msg, NL80211_ATTR_RESP_IE, resp_ie_len, resp_ie); |
8270 | goto nla_put_failure; | ||
8271 | 6570 | ||
8272 | genlmsg_end(msg, hdr); | 6571 | if (genlmsg_end(msg, hdr) < 0) { |
6572 | nlmsg_free(msg); | ||
6573 | return; | ||
6574 | } | ||
8273 | 6575 | ||
8274 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, | 6576 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, |
8275 | nl80211_mlme_mcgrp.id, gfp); | 6577 | nl80211_mlme_mcgrp.id, gfp); |
@@ -8288,7 +6590,7 @@ void nl80211_send_disconnected(struct cfg80211_registered_device *rdev, | |||
8288 | struct sk_buff *msg; | 6590 | struct sk_buff *msg; |
8289 | void *hdr; | 6591 | void *hdr; |
8290 | 6592 | ||
8291 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | 6593 | msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); |
8292 | if (!msg) | 6594 | if (!msg) |
8293 | return; | 6595 | return; |
8294 | 6596 | ||
@@ -8298,16 +6600,19 @@ void nl80211_send_disconnected(struct cfg80211_registered_device *rdev, | |||
8298 | return; | 6600 | return; |
8299 | } | 6601 | } |
8300 | 6602 | ||
8301 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | 6603 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); |
8302 | nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || | 6604 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); |
8303 | (from_ap && reason && | 6605 | if (from_ap && reason) |
8304 | nla_put_u16(msg, NL80211_ATTR_REASON_CODE, reason)) || | 6606 | NLA_PUT_U16(msg, NL80211_ATTR_REASON_CODE, reason); |
8305 | (from_ap && | 6607 | if (from_ap) |
8306 | nla_put_flag(msg, NL80211_ATTR_DISCONNECTED_BY_AP)) || | 6608 | NLA_PUT_FLAG(msg, NL80211_ATTR_DISCONNECTED_BY_AP); |
8307 | (ie && nla_put(msg, NL80211_ATTR_IE, ie_len, ie))) | 6609 | if (ie) |
8308 | goto nla_put_failure; | 6610 | NLA_PUT(msg, NL80211_ATTR_IE, ie_len, ie); |
8309 | 6611 | ||
8310 | genlmsg_end(msg, hdr); | 6612 | if (genlmsg_end(msg, hdr) < 0) { |
6613 | nlmsg_free(msg); | ||
6614 | return; | ||
6615 | } | ||
8311 | 6616 | ||
8312 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, | 6617 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, |
8313 | nl80211_mlme_mcgrp.id, GFP_KERNEL); | 6618 | nl80211_mlme_mcgrp.id, GFP_KERNEL); |
@@ -8336,12 +6641,14 @@ void nl80211_send_ibss_bssid(struct cfg80211_registered_device *rdev, | |||
8336 | return; | 6641 | return; |
8337 | } | 6642 | } |
8338 | 6643 | ||
8339 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | 6644 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); |
8340 | nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || | 6645 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); |
8341 | nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid)) | 6646 | NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid); |
8342 | goto nla_put_failure; | ||
8343 | 6647 | ||
8344 | genlmsg_end(msg, hdr); | 6648 | if (genlmsg_end(msg, hdr) < 0) { |
6649 | nlmsg_free(msg); | ||
6650 | return; | ||
6651 | } | ||
8345 | 6652 | ||
8346 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, | 6653 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, |
8347 | nl80211_mlme_mcgrp.id, gfp); | 6654 | nl80211_mlme_mcgrp.id, gfp); |
@@ -8370,14 +6677,16 @@ void nl80211_send_new_peer_candidate(struct cfg80211_registered_device *rdev, | |||
8370 | return; | 6677 | return; |
8371 | } | 6678 | } |
8372 | 6679 | ||
8373 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | 6680 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); |
8374 | nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || | 6681 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); |
8375 | nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, macaddr) || | 6682 | NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, macaddr); |
8376 | (ie_len && ie && | 6683 | if (ie_len && ie) |
8377 | nla_put(msg, NL80211_ATTR_IE, ie_len , ie))) | 6684 | NLA_PUT(msg, NL80211_ATTR_IE, ie_len , ie); |
8378 | goto nla_put_failure; | ||
8379 | 6685 | ||
8380 | genlmsg_end(msg, hdr); | 6686 | if (genlmsg_end(msg, hdr) < 0) { |
6687 | nlmsg_free(msg); | ||
6688 | return; | ||
6689 | } | ||
8381 | 6690 | ||
8382 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, | 6691 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, |
8383 | nl80211_mlme_mcgrp.id, gfp); | 6692 | nl80211_mlme_mcgrp.id, gfp); |
@@ -8406,16 +6715,20 @@ void nl80211_michael_mic_failure(struct cfg80211_registered_device *rdev, | |||
8406 | return; | 6715 | return; |
8407 | } | 6716 | } |
8408 | 6717 | ||
8409 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | 6718 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); |
8410 | nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || | 6719 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); |
8411 | (addr && nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr)) || | 6720 | if (addr) |
8412 | nla_put_u32(msg, NL80211_ATTR_KEY_TYPE, key_type) || | 6721 | NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr); |
8413 | (key_id != -1 && | 6722 | NLA_PUT_U32(msg, NL80211_ATTR_KEY_TYPE, key_type); |
8414 | nla_put_u8(msg, NL80211_ATTR_KEY_IDX, key_id)) || | 6723 | if (key_id != -1) |
8415 | (tsc && nla_put(msg, NL80211_ATTR_KEY_SEQ, 6, tsc))) | 6724 | NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, key_id); |
8416 | goto nla_put_failure; | 6725 | if (tsc) |
6726 | NLA_PUT(msg, NL80211_ATTR_KEY_SEQ, 6, tsc); | ||
8417 | 6727 | ||
8418 | genlmsg_end(msg, hdr); | 6728 | if (genlmsg_end(msg, hdr) < 0) { |
6729 | nlmsg_free(msg); | ||
6730 | return; | ||
6731 | } | ||
8419 | 6732 | ||
8420 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, | 6733 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, |
8421 | nl80211_mlme_mcgrp.id, gfp); | 6734 | nl80211_mlme_mcgrp.id, gfp); |
@@ -8448,8 +6761,7 @@ void nl80211_send_beacon_hint_event(struct wiphy *wiphy, | |||
8448 | * Since we are applying the beacon hint to a wiphy we know its | 6761 | * Since we are applying the beacon hint to a wiphy we know its |
8449 | * wiphy_idx is valid | 6762 | * wiphy_idx is valid |
8450 | */ | 6763 | */ |
8451 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, get_wiphy_idx(wiphy))) | 6764 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, get_wiphy_idx(wiphy)); |
8452 | goto nla_put_failure; | ||
8453 | 6765 | ||
8454 | /* Before */ | 6766 | /* Before */ |
8455 | nl_freq = nla_nest_start(msg, NL80211_ATTR_FREQ_BEFORE); | 6767 | nl_freq = nla_nest_start(msg, NL80211_ATTR_FREQ_BEFORE); |
@@ -8467,7 +6779,10 @@ void nl80211_send_beacon_hint_event(struct wiphy *wiphy, | |||
8467 | goto nla_put_failure; | 6779 | goto nla_put_failure; |
8468 | nla_nest_end(msg, nl_freq); | 6780 | nla_nest_end(msg, nl_freq); |
8469 | 6781 | ||
8470 | genlmsg_end(msg, hdr); | 6782 | if (genlmsg_end(msg, hdr) < 0) { |
6783 | nlmsg_free(msg); | ||
6784 | return; | ||
6785 | } | ||
8471 | 6786 | ||
8472 | rcu_read_lock(); | 6787 | rcu_read_lock(); |
8473 | genlmsg_multicast_allns(msg, 0, nl80211_regulatory_mcgrp.id, | 6788 | genlmsg_multicast_allns(msg, 0, nl80211_regulatory_mcgrp.id, |
@@ -8483,8 +6798,9 @@ nla_put_failure: | |||
8483 | 6798 | ||
8484 | static void nl80211_send_remain_on_chan_event( | 6799 | static void nl80211_send_remain_on_chan_event( |
8485 | int cmd, struct cfg80211_registered_device *rdev, | 6800 | int cmd, struct cfg80211_registered_device *rdev, |
8486 | struct wireless_dev *wdev, u64 cookie, | 6801 | struct net_device *netdev, u64 cookie, |
8487 | struct ieee80211_channel *chan, | 6802 | struct ieee80211_channel *chan, |
6803 | enum nl80211_channel_type channel_type, | ||
8488 | unsigned int duration, gfp_t gfp) | 6804 | unsigned int duration, gfp_t gfp) |
8489 | { | 6805 | { |
8490 | struct sk_buff *msg; | 6806 | struct sk_buff *msg; |
@@ -8500,21 +6816,19 @@ static void nl80211_send_remain_on_chan_event( | |||
8500 | return; | 6816 | return; |
8501 | } | 6817 | } |
8502 | 6818 | ||
8503 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | 6819 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); |
8504 | (wdev->netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX, | 6820 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); |
8505 | wdev->netdev->ifindex)) || | 6821 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, chan->center_freq); |
8506 | nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)) || | 6822 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, channel_type); |
8507 | nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, chan->center_freq) || | 6823 | NLA_PUT_U64(msg, NL80211_ATTR_COOKIE, cookie); |
8508 | nla_put_u32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, | ||
8509 | NL80211_CHAN_NO_HT) || | ||
8510 | nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie)) | ||
8511 | goto nla_put_failure; | ||
8512 | 6824 | ||
8513 | if (cmd == NL80211_CMD_REMAIN_ON_CHANNEL && | 6825 | if (cmd == NL80211_CMD_REMAIN_ON_CHANNEL) |
8514 | nla_put_u32(msg, NL80211_ATTR_DURATION, duration)) | 6826 | NLA_PUT_U32(msg, NL80211_ATTR_DURATION, duration); |
8515 | goto nla_put_failure; | ||
8516 | 6827 | ||
8517 | genlmsg_end(msg, hdr); | 6828 | if (genlmsg_end(msg, hdr) < 0) { |
6829 | nlmsg_free(msg); | ||
6830 | return; | ||
6831 | } | ||
8518 | 6832 | ||
8519 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, | 6833 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, |
8520 | nl80211_mlme_mcgrp.id, gfp); | 6834 | nl80211_mlme_mcgrp.id, gfp); |
@@ -8526,22 +6840,24 @@ static void nl80211_send_remain_on_chan_event( | |||
8526 | } | 6840 | } |
8527 | 6841 | ||
8528 | void nl80211_send_remain_on_channel(struct cfg80211_registered_device *rdev, | 6842 | void nl80211_send_remain_on_channel(struct cfg80211_registered_device *rdev, |
8529 | struct wireless_dev *wdev, u64 cookie, | 6843 | struct net_device *netdev, u64 cookie, |
8530 | struct ieee80211_channel *chan, | 6844 | struct ieee80211_channel *chan, |
6845 | enum nl80211_channel_type channel_type, | ||
8531 | unsigned int duration, gfp_t gfp) | 6846 | unsigned int duration, gfp_t gfp) |
8532 | { | 6847 | { |
8533 | nl80211_send_remain_on_chan_event(NL80211_CMD_REMAIN_ON_CHANNEL, | 6848 | nl80211_send_remain_on_chan_event(NL80211_CMD_REMAIN_ON_CHANNEL, |
8534 | rdev, wdev, cookie, chan, | 6849 | rdev, netdev, cookie, chan, |
8535 | duration, gfp); | 6850 | channel_type, duration, gfp); |
8536 | } | 6851 | } |
8537 | 6852 | ||
8538 | void nl80211_send_remain_on_channel_cancel( | 6853 | void nl80211_send_remain_on_channel_cancel( |
8539 | struct cfg80211_registered_device *rdev, | 6854 | struct cfg80211_registered_device *rdev, struct net_device *netdev, |
8540 | struct wireless_dev *wdev, | 6855 | u64 cookie, struct ieee80211_channel *chan, |
8541 | u64 cookie, struct ieee80211_channel *chan, gfp_t gfp) | 6856 | enum nl80211_channel_type channel_type, gfp_t gfp) |
8542 | { | 6857 | { |
8543 | nl80211_send_remain_on_chan_event(NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL, | 6858 | nl80211_send_remain_on_chan_event(NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL, |
8544 | rdev, wdev, cookie, chan, 0, gfp); | 6859 | rdev, netdev, cookie, chan, |
6860 | channel_type, 0, gfp); | ||
8545 | } | 6861 | } |
8546 | 6862 | ||
8547 | void nl80211_send_sta_event(struct cfg80211_registered_device *rdev, | 6863 | void nl80211_send_sta_event(struct cfg80211_registered_device *rdev, |
@@ -8550,12 +6866,11 @@ void nl80211_send_sta_event(struct cfg80211_registered_device *rdev, | |||
8550 | { | 6866 | { |
8551 | struct sk_buff *msg; | 6867 | struct sk_buff *msg; |
8552 | 6868 | ||
8553 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); | 6869 | msg = nlmsg_new(NLMSG_GOODSIZE, gfp); |
8554 | if (!msg) | 6870 | if (!msg) |
8555 | return; | 6871 | return; |
8556 | 6872 | ||
8557 | if (nl80211_send_station(msg, 0, 0, 0, | 6873 | if (nl80211_send_station(msg, 0, 0, 0, dev, mac_addr, sinfo) < 0) { |
8558 | rdev, dev, mac_addr, sinfo) < 0) { | ||
8559 | nlmsg_free(msg); | 6874 | nlmsg_free(msg); |
8560 | return; | 6875 | return; |
8561 | } | 6876 | } |
@@ -8571,7 +6886,7 @@ void nl80211_send_sta_del_event(struct cfg80211_registered_device *rdev, | |||
8571 | struct sk_buff *msg; | 6886 | struct sk_buff *msg; |
8572 | void *hdr; | 6887 | void *hdr; |
8573 | 6888 | ||
8574 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); | 6889 | msg = nlmsg_new(NLMSG_GOODSIZE, gfp); |
8575 | if (!msg) | 6890 | if (!msg) |
8576 | return; | 6891 | return; |
8577 | 6892 | ||
@@ -8581,46 +6896,14 @@ void nl80211_send_sta_del_event(struct cfg80211_registered_device *rdev, | |||
8581 | return; | 6896 | return; |
8582 | } | 6897 | } |
8583 | 6898 | ||
8584 | if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || | 6899 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); |
8585 | nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr)) | 6900 | NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr); |
8586 | goto nla_put_failure; | ||
8587 | |||
8588 | genlmsg_end(msg, hdr); | ||
8589 | |||
8590 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, | ||
8591 | nl80211_mlme_mcgrp.id, gfp); | ||
8592 | return; | ||
8593 | |||
8594 | nla_put_failure: | ||
8595 | genlmsg_cancel(msg, hdr); | ||
8596 | nlmsg_free(msg); | ||
8597 | } | ||
8598 | |||
8599 | void nl80211_send_conn_failed_event(struct cfg80211_registered_device *rdev, | ||
8600 | struct net_device *dev, const u8 *mac_addr, | ||
8601 | enum nl80211_connect_failed_reason reason, | ||
8602 | gfp_t gfp) | ||
8603 | { | ||
8604 | struct sk_buff *msg; | ||
8605 | void *hdr; | ||
8606 | |||
8607 | msg = nlmsg_new(NLMSG_GOODSIZE, gfp); | ||
8608 | if (!msg) | ||
8609 | return; | ||
8610 | 6901 | ||
8611 | hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_CONN_FAILED); | 6902 | if (genlmsg_end(msg, hdr) < 0) { |
8612 | if (!hdr) { | ||
8613 | nlmsg_free(msg); | 6903 | nlmsg_free(msg); |
8614 | return; | 6904 | return; |
8615 | } | 6905 | } |
8616 | 6906 | ||
8617 | if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || | ||
8618 | nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr) || | ||
8619 | nla_put_u32(msg, NL80211_ATTR_CONN_FAILED_REASON, reason)) | ||
8620 | goto nla_put_failure; | ||
8621 | |||
8622 | genlmsg_end(msg, hdr); | ||
8623 | |||
8624 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, | 6907 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, |
8625 | nl80211_mlme_mcgrp.id, gfp); | 6908 | nl80211_mlme_mcgrp.id, gfp); |
8626 | return; | 6909 | return; |
@@ -8630,71 +6913,13 @@ void nl80211_send_conn_failed_event(struct cfg80211_registered_device *rdev, | |||
8630 | nlmsg_free(msg); | 6913 | nlmsg_free(msg); |
8631 | } | 6914 | } |
8632 | 6915 | ||
8633 | static bool __nl80211_unexpected_frame(struct net_device *dev, u8 cmd, | ||
8634 | const u8 *addr, gfp_t gfp) | ||
8635 | { | ||
8636 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
8637 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | ||
8638 | struct sk_buff *msg; | ||
8639 | void *hdr; | ||
8640 | int err; | ||
8641 | u32 nlportid = ACCESS_ONCE(wdev->ap_unexpected_nlportid); | ||
8642 | |||
8643 | if (!nlportid) | ||
8644 | return false; | ||
8645 | |||
8646 | msg = nlmsg_new(100, gfp); | ||
8647 | if (!msg) | ||
8648 | return true; | ||
8649 | |||
8650 | hdr = nl80211hdr_put(msg, 0, 0, 0, cmd); | ||
8651 | if (!hdr) { | ||
8652 | nlmsg_free(msg); | ||
8653 | return true; | ||
8654 | } | ||
8655 | |||
8656 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | ||
8657 | nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || | ||
8658 | nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr)) | ||
8659 | goto nla_put_failure; | ||
8660 | |||
8661 | err = genlmsg_end(msg, hdr); | ||
8662 | if (err < 0) { | ||
8663 | nlmsg_free(msg); | ||
8664 | return true; | ||
8665 | } | ||
8666 | |||
8667 | genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlportid); | ||
8668 | return true; | ||
8669 | |||
8670 | nla_put_failure: | ||
8671 | genlmsg_cancel(msg, hdr); | ||
8672 | nlmsg_free(msg); | ||
8673 | return true; | ||
8674 | } | ||
8675 | |||
8676 | bool nl80211_unexpected_frame(struct net_device *dev, const u8 *addr, gfp_t gfp) | ||
8677 | { | ||
8678 | return __nl80211_unexpected_frame(dev, NL80211_CMD_UNEXPECTED_FRAME, | ||
8679 | addr, gfp); | ||
8680 | } | ||
8681 | |||
8682 | bool nl80211_unexpected_4addr_frame(struct net_device *dev, | ||
8683 | const u8 *addr, gfp_t gfp) | ||
8684 | { | ||
8685 | return __nl80211_unexpected_frame(dev, | ||
8686 | NL80211_CMD_UNEXPECTED_4ADDR_FRAME, | ||
8687 | addr, gfp); | ||
8688 | } | ||
8689 | |||
8690 | int nl80211_send_mgmt(struct cfg80211_registered_device *rdev, | 6916 | int nl80211_send_mgmt(struct cfg80211_registered_device *rdev, |
8691 | struct wireless_dev *wdev, u32 nlportid, | 6917 | struct net_device *netdev, u32 nlpid, |
8692 | int freq, int sig_dbm, | 6918 | int freq, const u8 *buf, size_t len, gfp_t gfp) |
8693 | const u8 *buf, size_t len, gfp_t gfp) | ||
8694 | { | 6919 | { |
8695 | struct net_device *netdev = wdev->netdev; | ||
8696 | struct sk_buff *msg; | 6920 | struct sk_buff *msg; |
8697 | void *hdr; | 6921 | void *hdr; |
6922 | int err; | ||
8698 | 6923 | ||
8699 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); | 6924 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); |
8700 | if (!msg) | 6925 | if (!msg) |
@@ -8706,18 +6931,21 @@ int nl80211_send_mgmt(struct cfg80211_registered_device *rdev, | |||
8706 | return -ENOMEM; | 6931 | return -ENOMEM; |
8707 | } | 6932 | } |
8708 | 6933 | ||
8709 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | 6934 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); |
8710 | (netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX, | 6935 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); |
8711 | netdev->ifindex)) || | 6936 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq); |
8712 | nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, freq) || | 6937 | NLA_PUT(msg, NL80211_ATTR_FRAME, len, buf); |
8713 | (sig_dbm && | ||
8714 | nla_put_u32(msg, NL80211_ATTR_RX_SIGNAL_DBM, sig_dbm)) || | ||
8715 | nla_put(msg, NL80211_ATTR_FRAME, len, buf)) | ||
8716 | goto nla_put_failure; | ||
8717 | 6938 | ||
8718 | genlmsg_end(msg, hdr); | 6939 | err = genlmsg_end(msg, hdr); |
6940 | if (err < 0) { | ||
6941 | nlmsg_free(msg); | ||
6942 | return err; | ||
6943 | } | ||
8719 | 6944 | ||
8720 | return genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlportid); | 6945 | err = genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlpid); |
6946 | if (err < 0) | ||
6947 | return err; | ||
6948 | return 0; | ||
8721 | 6949 | ||
8722 | nla_put_failure: | 6950 | nla_put_failure: |
8723 | genlmsg_cancel(msg, hdr); | 6951 | genlmsg_cancel(msg, hdr); |
@@ -8726,11 +6954,10 @@ int nl80211_send_mgmt(struct cfg80211_registered_device *rdev, | |||
8726 | } | 6954 | } |
8727 | 6955 | ||
8728 | void nl80211_send_mgmt_tx_status(struct cfg80211_registered_device *rdev, | 6956 | void nl80211_send_mgmt_tx_status(struct cfg80211_registered_device *rdev, |
8729 | struct wireless_dev *wdev, u64 cookie, | 6957 | struct net_device *netdev, u64 cookie, |
8730 | const u8 *buf, size_t len, bool ack, | 6958 | const u8 *buf, size_t len, bool ack, |
8731 | gfp_t gfp) | 6959 | gfp_t gfp) |
8732 | { | 6960 | { |
8733 | struct net_device *netdev = wdev->netdev; | ||
8734 | struct sk_buff *msg; | 6961 | struct sk_buff *msg; |
8735 | void *hdr; | 6962 | void *hdr; |
8736 | 6963 | ||
@@ -8744,15 +6971,17 @@ void nl80211_send_mgmt_tx_status(struct cfg80211_registered_device *rdev, | |||
8744 | return; | 6971 | return; |
8745 | } | 6972 | } |
8746 | 6973 | ||
8747 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | 6974 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); |
8748 | (netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX, | 6975 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); |
8749 | netdev->ifindex)) || | 6976 | NLA_PUT(msg, NL80211_ATTR_FRAME, len, buf); |
8750 | nla_put(msg, NL80211_ATTR_FRAME, len, buf) || | 6977 | NLA_PUT_U64(msg, NL80211_ATTR_COOKIE, cookie); |
8751 | nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie) || | 6978 | if (ack) |
8752 | (ack && nla_put_flag(msg, NL80211_ATTR_ACK))) | 6979 | NLA_PUT_FLAG(msg, NL80211_ATTR_ACK); |
8753 | goto nla_put_failure; | ||
8754 | 6980 | ||
8755 | genlmsg_end(msg, hdr); | 6981 | if (genlmsg_end(msg, hdr) < 0) { |
6982 | nlmsg_free(msg); | ||
6983 | return; | ||
6984 | } | ||
8756 | 6985 | ||
8757 | genlmsg_multicast(msg, 0, nl80211_mlme_mcgrp.id, gfp); | 6986 | genlmsg_multicast(msg, 0, nl80211_mlme_mcgrp.id, gfp); |
8758 | return; | 6987 | return; |
@@ -8772,7 +7001,7 @@ nl80211_send_cqm_rssi_notify(struct cfg80211_registered_device *rdev, | |||
8772 | struct nlattr *pinfoattr; | 7001 | struct nlattr *pinfoattr; |
8773 | void *hdr; | 7002 | void *hdr; |
8774 | 7003 | ||
8775 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); | 7004 | msg = nlmsg_new(NLMSG_GOODSIZE, gfp); |
8776 | if (!msg) | 7005 | if (!msg) |
8777 | return; | 7006 | return; |
8778 | 7007 | ||
@@ -8782,21 +7011,22 @@ nl80211_send_cqm_rssi_notify(struct cfg80211_registered_device *rdev, | |||
8782 | return; | 7011 | return; |
8783 | } | 7012 | } |
8784 | 7013 | ||
8785 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | 7014 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); |
8786 | nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) | 7015 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); |
8787 | goto nla_put_failure; | ||
8788 | 7016 | ||
8789 | pinfoattr = nla_nest_start(msg, NL80211_ATTR_CQM); | 7017 | pinfoattr = nla_nest_start(msg, NL80211_ATTR_CQM); |
8790 | if (!pinfoattr) | 7018 | if (!pinfoattr) |
8791 | goto nla_put_failure; | 7019 | goto nla_put_failure; |
8792 | 7020 | ||
8793 | if (nla_put_u32(msg, NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT, | 7021 | NLA_PUT_U32(msg, NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT, |
8794 | rssi_event)) | 7022 | rssi_event); |
8795 | goto nla_put_failure; | ||
8796 | 7023 | ||
8797 | nla_nest_end(msg, pinfoattr); | 7024 | nla_nest_end(msg, pinfoattr); |
8798 | 7025 | ||
8799 | genlmsg_end(msg, hdr); | 7026 | if (genlmsg_end(msg, hdr) < 0) { |
7027 | nlmsg_free(msg); | ||
7028 | return; | ||
7029 | } | ||
8800 | 7030 | ||
8801 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, | 7031 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, |
8802 | nl80211_mlme_mcgrp.id, gfp); | 7032 | nl80211_mlme_mcgrp.id, gfp); |
@@ -8815,7 +7045,7 @@ void nl80211_gtk_rekey_notify(struct cfg80211_registered_device *rdev, | |||
8815 | struct nlattr *rekey_attr; | 7045 | struct nlattr *rekey_attr; |
8816 | void *hdr; | 7046 | void *hdr; |
8817 | 7047 | ||
8818 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); | 7048 | msg = nlmsg_new(NLMSG_GOODSIZE, gfp); |
8819 | if (!msg) | 7049 | if (!msg) |
8820 | return; | 7050 | return; |
8821 | 7051 | ||
@@ -8825,152 +7055,24 @@ void nl80211_gtk_rekey_notify(struct cfg80211_registered_device *rdev, | |||
8825 | return; | 7055 | return; |
8826 | } | 7056 | } |
8827 | 7057 | ||
8828 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | 7058 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); |
8829 | nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || | 7059 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); |
8830 | nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid)) | 7060 | NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid); |
8831 | goto nla_put_failure; | ||
8832 | 7061 | ||
8833 | rekey_attr = nla_nest_start(msg, NL80211_ATTR_REKEY_DATA); | 7062 | rekey_attr = nla_nest_start(msg, NL80211_ATTR_REKEY_DATA); |
8834 | if (!rekey_attr) | 7063 | if (!rekey_attr) |
8835 | goto nla_put_failure; | 7064 | goto nla_put_failure; |
8836 | 7065 | ||
8837 | if (nla_put(msg, NL80211_REKEY_DATA_REPLAY_CTR, | 7066 | NLA_PUT(msg, NL80211_REKEY_DATA_REPLAY_CTR, |
8838 | NL80211_REPLAY_CTR_LEN, replay_ctr)) | 7067 | NL80211_REPLAY_CTR_LEN, replay_ctr); |
8839 | goto nla_put_failure; | ||
8840 | 7068 | ||
8841 | nla_nest_end(msg, rekey_attr); | 7069 | nla_nest_end(msg, rekey_attr); |
8842 | 7070 | ||
8843 | genlmsg_end(msg, hdr); | 7071 | if (genlmsg_end(msg, hdr) < 0) { |
8844 | |||
8845 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, | ||
8846 | nl80211_mlme_mcgrp.id, gfp); | ||
8847 | return; | ||
8848 | |||
8849 | nla_put_failure: | ||
8850 | genlmsg_cancel(msg, hdr); | ||
8851 | nlmsg_free(msg); | ||
8852 | } | ||
8853 | |||
8854 | void nl80211_pmksa_candidate_notify(struct cfg80211_registered_device *rdev, | ||
8855 | struct net_device *netdev, int index, | ||
8856 | const u8 *bssid, bool preauth, gfp_t gfp) | ||
8857 | { | ||
8858 | struct sk_buff *msg; | ||
8859 | struct nlattr *attr; | ||
8860 | void *hdr; | ||
8861 | |||
8862 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); | ||
8863 | if (!msg) | ||
8864 | return; | ||
8865 | |||
8866 | hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_PMKSA_CANDIDATE); | ||
8867 | if (!hdr) { | ||
8868 | nlmsg_free(msg); | 7072 | nlmsg_free(msg); |
8869 | return; | 7073 | return; |
8870 | } | 7074 | } |
8871 | 7075 | ||
8872 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | ||
8873 | nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) | ||
8874 | goto nla_put_failure; | ||
8875 | |||
8876 | attr = nla_nest_start(msg, NL80211_ATTR_PMKSA_CANDIDATE); | ||
8877 | if (!attr) | ||
8878 | goto nla_put_failure; | ||
8879 | |||
8880 | if (nla_put_u32(msg, NL80211_PMKSA_CANDIDATE_INDEX, index) || | ||
8881 | nla_put(msg, NL80211_PMKSA_CANDIDATE_BSSID, ETH_ALEN, bssid) || | ||
8882 | (preauth && | ||
8883 | nla_put_flag(msg, NL80211_PMKSA_CANDIDATE_PREAUTH))) | ||
8884 | goto nla_put_failure; | ||
8885 | |||
8886 | nla_nest_end(msg, attr); | ||
8887 | |||
8888 | genlmsg_end(msg, hdr); | ||
8889 | |||
8890 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, | ||
8891 | nl80211_mlme_mcgrp.id, gfp); | ||
8892 | return; | ||
8893 | |||
8894 | nla_put_failure: | ||
8895 | genlmsg_cancel(msg, hdr); | ||
8896 | nlmsg_free(msg); | ||
8897 | } | ||
8898 | |||
8899 | void nl80211_ch_switch_notify(struct cfg80211_registered_device *rdev, | ||
8900 | struct net_device *netdev, | ||
8901 | struct cfg80211_chan_def *chandef, gfp_t gfp) | ||
8902 | { | ||
8903 | struct sk_buff *msg; | ||
8904 | void *hdr; | ||
8905 | |||
8906 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); | ||
8907 | if (!msg) | ||
8908 | return; | ||
8909 | |||
8910 | hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_CH_SWITCH_NOTIFY); | ||
8911 | if (!hdr) { | ||
8912 | nlmsg_free(msg); | ||
8913 | return; | ||
8914 | } | ||
8915 | |||
8916 | if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) | ||
8917 | goto nla_put_failure; | ||
8918 | |||
8919 | if (nl80211_send_chandef(msg, chandef)) | ||
8920 | goto nla_put_failure; | ||
8921 | |||
8922 | genlmsg_end(msg, hdr); | ||
8923 | |||
8924 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, | ||
8925 | nl80211_mlme_mcgrp.id, gfp); | ||
8926 | return; | ||
8927 | |||
8928 | nla_put_failure: | ||
8929 | genlmsg_cancel(msg, hdr); | ||
8930 | nlmsg_free(msg); | ||
8931 | } | ||
8932 | |||
8933 | void | ||
8934 | nl80211_send_cqm_txe_notify(struct cfg80211_registered_device *rdev, | ||
8935 | struct net_device *netdev, const u8 *peer, | ||
8936 | u32 num_packets, u32 rate, u32 intvl, gfp_t gfp) | ||
8937 | { | ||
8938 | struct sk_buff *msg; | ||
8939 | struct nlattr *pinfoattr; | ||
8940 | void *hdr; | ||
8941 | |||
8942 | msg = nlmsg_new(NLMSG_GOODSIZE, gfp); | ||
8943 | if (!msg) | ||
8944 | return; | ||
8945 | |||
8946 | hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_NOTIFY_CQM); | ||
8947 | if (!hdr) { | ||
8948 | nlmsg_free(msg); | ||
8949 | return; | ||
8950 | } | ||
8951 | |||
8952 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | ||
8953 | nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || | ||
8954 | nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, peer)) | ||
8955 | goto nla_put_failure; | ||
8956 | |||
8957 | pinfoattr = nla_nest_start(msg, NL80211_ATTR_CQM); | ||
8958 | if (!pinfoattr) | ||
8959 | goto nla_put_failure; | ||
8960 | |||
8961 | if (nla_put_u32(msg, NL80211_ATTR_CQM_TXE_PKTS, num_packets)) | ||
8962 | goto nla_put_failure; | ||
8963 | |||
8964 | if (nla_put_u32(msg, NL80211_ATTR_CQM_TXE_RATE, rate)) | ||
8965 | goto nla_put_failure; | ||
8966 | |||
8967 | if (nla_put_u32(msg, NL80211_ATTR_CQM_TXE_INTVL, intvl)) | ||
8968 | goto nla_put_failure; | ||
8969 | |||
8970 | nla_nest_end(msg, pinfoattr); | ||
8971 | |||
8972 | genlmsg_end(msg, hdr); | ||
8973 | |||
8974 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, | 7076 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, |
8975 | nl80211_mlme_mcgrp.id, gfp); | 7077 | nl80211_mlme_mcgrp.id, gfp); |
8976 | return; | 7078 | return; |
@@ -8989,7 +7091,7 @@ nl80211_send_cqm_pktloss_notify(struct cfg80211_registered_device *rdev, | |||
8989 | struct nlattr *pinfoattr; | 7091 | struct nlattr *pinfoattr; |
8990 | void *hdr; | 7092 | void *hdr; |
8991 | 7093 | ||
8992 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); | 7094 | msg = nlmsg_new(NLMSG_GOODSIZE, gfp); |
8993 | if (!msg) | 7095 | if (!msg) |
8994 | return; | 7096 | return; |
8995 | 7097 | ||
@@ -8999,62 +7101,19 @@ nl80211_send_cqm_pktloss_notify(struct cfg80211_registered_device *rdev, | |||
8999 | return; | 7101 | return; |
9000 | } | 7102 | } |
9001 | 7103 | ||
9002 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | 7104 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); |
9003 | nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || | 7105 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); |
9004 | nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, peer)) | 7106 | NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, peer); |
9005 | goto nla_put_failure; | ||
9006 | 7107 | ||
9007 | pinfoattr = nla_nest_start(msg, NL80211_ATTR_CQM); | 7108 | pinfoattr = nla_nest_start(msg, NL80211_ATTR_CQM); |
9008 | if (!pinfoattr) | 7109 | if (!pinfoattr) |
9009 | goto nla_put_failure; | 7110 | goto nla_put_failure; |
9010 | 7111 | ||
9011 | if (nla_put_u32(msg, NL80211_ATTR_CQM_PKT_LOSS_EVENT, num_packets)) | 7112 | NLA_PUT_U32(msg, NL80211_ATTR_CQM_PKT_LOSS_EVENT, num_packets); |
9012 | goto nla_put_failure; | ||
9013 | 7113 | ||
9014 | nla_nest_end(msg, pinfoattr); | 7114 | nla_nest_end(msg, pinfoattr); |
9015 | 7115 | ||
9016 | genlmsg_end(msg, hdr); | 7116 | if (genlmsg_end(msg, hdr) < 0) { |
9017 | |||
9018 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, | ||
9019 | nl80211_mlme_mcgrp.id, gfp); | ||
9020 | return; | ||
9021 | |||
9022 | nla_put_failure: | ||
9023 | genlmsg_cancel(msg, hdr); | ||
9024 | nlmsg_free(msg); | ||
9025 | } | ||
9026 | |||
9027 | void cfg80211_probe_status(struct net_device *dev, const u8 *addr, | ||
9028 | u64 cookie, bool acked, gfp_t gfp) | ||
9029 | { | ||
9030 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
9031 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | ||
9032 | struct sk_buff *msg; | ||
9033 | void *hdr; | ||
9034 | int err; | ||
9035 | |||
9036 | trace_cfg80211_probe_status(dev, addr, cookie, acked); | ||
9037 | |||
9038 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); | ||
9039 | |||
9040 | if (!msg) | ||
9041 | return; | ||
9042 | |||
9043 | hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_PROBE_CLIENT); | ||
9044 | if (!hdr) { | ||
9045 | nlmsg_free(msg); | ||
9046 | return; | ||
9047 | } | ||
9048 | |||
9049 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | ||
9050 | nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || | ||
9051 | nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr) || | ||
9052 | nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie) || | ||
9053 | (acked && nla_put_flag(msg, NL80211_ATTR_ACK))) | ||
9054 | goto nla_put_failure; | ||
9055 | |||
9056 | err = genlmsg_end(msg, hdr); | ||
9057 | if (err < 0) { | ||
9058 | nlmsg_free(msg); | 7117 | nlmsg_free(msg); |
9059 | return; | 7118 | return; |
9060 | } | 7119 | } |
@@ -9067,100 +7126,6 @@ void cfg80211_probe_status(struct net_device *dev, const u8 *addr, | |||
9067 | genlmsg_cancel(msg, hdr); | 7126 | genlmsg_cancel(msg, hdr); |
9068 | nlmsg_free(msg); | 7127 | nlmsg_free(msg); |
9069 | } | 7128 | } |
9070 | EXPORT_SYMBOL(cfg80211_probe_status); | ||
9071 | |||
9072 | void cfg80211_report_obss_beacon(struct wiphy *wiphy, | ||
9073 | const u8 *frame, size_t len, | ||
9074 | int freq, int sig_dbm) | ||
9075 | { | ||
9076 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | ||
9077 | struct sk_buff *msg; | ||
9078 | void *hdr; | ||
9079 | struct cfg80211_beacon_registration *reg; | ||
9080 | |||
9081 | trace_cfg80211_report_obss_beacon(wiphy, frame, len, freq, sig_dbm); | ||
9082 | |||
9083 | spin_lock_bh(&rdev->beacon_registrations_lock); | ||
9084 | list_for_each_entry(reg, &rdev->beacon_registrations, list) { | ||
9085 | msg = nlmsg_new(len + 100, GFP_ATOMIC); | ||
9086 | if (!msg) { | ||
9087 | spin_unlock_bh(&rdev->beacon_registrations_lock); | ||
9088 | return; | ||
9089 | } | ||
9090 | |||
9091 | hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_FRAME); | ||
9092 | if (!hdr) | ||
9093 | goto nla_put_failure; | ||
9094 | |||
9095 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | ||
9096 | (freq && | ||
9097 | nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, freq)) || | ||
9098 | (sig_dbm && | ||
9099 | nla_put_u32(msg, NL80211_ATTR_RX_SIGNAL_DBM, sig_dbm)) || | ||
9100 | nla_put(msg, NL80211_ATTR_FRAME, len, frame)) | ||
9101 | goto nla_put_failure; | ||
9102 | |||
9103 | genlmsg_end(msg, hdr); | ||
9104 | |||
9105 | genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, reg->nlportid); | ||
9106 | } | ||
9107 | spin_unlock_bh(&rdev->beacon_registrations_lock); | ||
9108 | return; | ||
9109 | |||
9110 | nla_put_failure: | ||
9111 | spin_unlock_bh(&rdev->beacon_registrations_lock); | ||
9112 | if (hdr) | ||
9113 | genlmsg_cancel(msg, hdr); | ||
9114 | nlmsg_free(msg); | ||
9115 | } | ||
9116 | EXPORT_SYMBOL(cfg80211_report_obss_beacon); | ||
9117 | |||
9118 | void cfg80211_tdls_oper_request(struct net_device *dev, const u8 *peer, | ||
9119 | enum nl80211_tdls_operation oper, | ||
9120 | u16 reason_code, gfp_t gfp) | ||
9121 | { | ||
9122 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
9123 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | ||
9124 | struct sk_buff *msg; | ||
9125 | void *hdr; | ||
9126 | int err; | ||
9127 | |||
9128 | trace_cfg80211_tdls_oper_request(wdev->wiphy, dev, peer, oper, | ||
9129 | reason_code); | ||
9130 | |||
9131 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); | ||
9132 | if (!msg) | ||
9133 | return; | ||
9134 | |||
9135 | hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_TDLS_OPER); | ||
9136 | if (!hdr) { | ||
9137 | nlmsg_free(msg); | ||
9138 | return; | ||
9139 | } | ||
9140 | |||
9141 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | ||
9142 | nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || | ||
9143 | nla_put_u8(msg, NL80211_ATTR_TDLS_OPERATION, oper) || | ||
9144 | nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, peer) || | ||
9145 | (reason_code > 0 && | ||
9146 | nla_put_u16(msg, NL80211_ATTR_REASON_CODE, reason_code))) | ||
9147 | goto nla_put_failure; | ||
9148 | |||
9149 | err = genlmsg_end(msg, hdr); | ||
9150 | if (err < 0) { | ||
9151 | nlmsg_free(msg); | ||
9152 | return; | ||
9153 | } | ||
9154 | |||
9155 | genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, | ||
9156 | nl80211_mlme_mcgrp.id, gfp); | ||
9157 | return; | ||
9158 | |||
9159 | nla_put_failure: | ||
9160 | genlmsg_cancel(msg, hdr); | ||
9161 | nlmsg_free(msg); | ||
9162 | } | ||
9163 | EXPORT_SYMBOL(cfg80211_tdls_oper_request); | ||
9164 | 7129 | ||
9165 | static int nl80211_netlink_notify(struct notifier_block * nb, | 7130 | static int nl80211_netlink_notify(struct notifier_block * nb, |
9166 | unsigned long state, | 7131 | unsigned long state, |
@@ -9169,28 +7134,15 @@ static int nl80211_netlink_notify(struct notifier_block * nb, | |||
9169 | struct netlink_notify *notify = _notify; | 7134 | struct netlink_notify *notify = _notify; |
9170 | struct cfg80211_registered_device *rdev; | 7135 | struct cfg80211_registered_device *rdev; |
9171 | struct wireless_dev *wdev; | 7136 | struct wireless_dev *wdev; |
9172 | struct cfg80211_beacon_registration *reg, *tmp; | ||
9173 | 7137 | ||
9174 | if (state != NETLINK_URELEASE) | 7138 | if (state != NETLINK_URELEASE) |
9175 | return NOTIFY_DONE; | 7139 | return NOTIFY_DONE; |
9176 | 7140 | ||
9177 | rcu_read_lock(); | 7141 | rcu_read_lock(); |
9178 | 7142 | ||
9179 | list_for_each_entry_rcu(rdev, &cfg80211_rdev_list, list) { | 7143 | list_for_each_entry_rcu(rdev, &cfg80211_rdev_list, list) |
9180 | list_for_each_entry_rcu(wdev, &rdev->wdev_list, list) | 7144 | list_for_each_entry_rcu(wdev, &rdev->netdev_list, list) |
9181 | cfg80211_mlme_unregister_socket(wdev, notify->portid); | 7145 | cfg80211_mlme_unregister_socket(wdev, notify->pid); |
9182 | |||
9183 | spin_lock_bh(&rdev->beacon_registrations_lock); | ||
9184 | list_for_each_entry_safe(reg, tmp, &rdev->beacon_registrations, | ||
9185 | list) { | ||
9186 | if (reg->nlportid == notify->portid) { | ||
9187 | list_del(®->list); | ||
9188 | kfree(reg); | ||
9189 | break; | ||
9190 | } | ||
9191 | } | ||
9192 | spin_unlock_bh(&rdev->beacon_registrations_lock); | ||
9193 | } | ||
9194 | 7146 | ||
9195 | rcu_read_unlock(); | 7147 | rcu_read_unlock(); |
9196 | 7148 | ||
diff --git a/net/wireless/nl80211.h b/net/wireless/nl80211.h index 2acba8477e9..5d69c56400a 100644 --- a/net/wireless/nl80211.h +++ b/net/wireless/nl80211.h | |||
@@ -7,11 +7,11 @@ int nl80211_init(void); | |||
7 | void nl80211_exit(void); | 7 | void nl80211_exit(void); |
8 | void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev); | 8 | void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev); |
9 | void nl80211_send_scan_start(struct cfg80211_registered_device *rdev, | 9 | void nl80211_send_scan_start(struct cfg80211_registered_device *rdev, |
10 | struct wireless_dev *wdev); | 10 | struct net_device *netdev); |
11 | void nl80211_send_scan_done(struct cfg80211_registered_device *rdev, | 11 | void nl80211_send_scan_done(struct cfg80211_registered_device *rdev, |
12 | struct wireless_dev *wdev); | 12 | struct net_device *netdev); |
13 | void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev, | 13 | void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev, |
14 | struct wireless_dev *wdev); | 14 | struct net_device *netdev); |
15 | void nl80211_send_sched_scan(struct cfg80211_registered_device *rdev, | 15 | void nl80211_send_sched_scan(struct cfg80211_registered_device *rdev, |
16 | struct net_device *netdev, u32 cmd); | 16 | struct net_device *netdev, u32 cmd); |
17 | void nl80211_send_sched_scan_results(struct cfg80211_registered_device *rdev, | 17 | void nl80211_send_sched_scan_results(struct cfg80211_registered_device *rdev, |
@@ -74,13 +74,15 @@ void nl80211_send_ibss_bssid(struct cfg80211_registered_device *rdev, | |||
74 | gfp_t gfp); | 74 | gfp_t gfp); |
75 | 75 | ||
76 | void nl80211_send_remain_on_channel(struct cfg80211_registered_device *rdev, | 76 | void nl80211_send_remain_on_channel(struct cfg80211_registered_device *rdev, |
77 | struct wireless_dev *wdev, u64 cookie, | 77 | struct net_device *netdev, |
78 | u64 cookie, | ||
78 | struct ieee80211_channel *chan, | 79 | struct ieee80211_channel *chan, |
80 | enum nl80211_channel_type channel_type, | ||
79 | unsigned int duration, gfp_t gfp); | 81 | unsigned int duration, gfp_t gfp); |
80 | void nl80211_send_remain_on_channel_cancel( | 82 | void nl80211_send_remain_on_channel_cancel( |
81 | struct cfg80211_registered_device *rdev, | 83 | struct cfg80211_registered_device *rdev, struct net_device *netdev, |
82 | struct wireless_dev *wdev, | 84 | u64 cookie, struct ieee80211_channel *chan, |
83 | u64 cookie, struct ieee80211_channel *chan, gfp_t gfp); | 85 | enum nl80211_channel_type channel_type, gfp_t gfp); |
84 | 86 | ||
85 | void nl80211_send_sta_event(struct cfg80211_registered_device *rdev, | 87 | void nl80211_send_sta_event(struct cfg80211_registered_device *rdev, |
86 | struct net_device *dev, const u8 *mac_addr, | 88 | struct net_device *dev, const u8 *mac_addr, |
@@ -89,17 +91,11 @@ void nl80211_send_sta_del_event(struct cfg80211_registered_device *rdev, | |||
89 | struct net_device *dev, const u8 *mac_addr, | 91 | struct net_device *dev, const u8 *mac_addr, |
90 | gfp_t gfp); | 92 | gfp_t gfp); |
91 | 93 | ||
92 | void nl80211_send_conn_failed_event(struct cfg80211_registered_device *rdev, | ||
93 | struct net_device *dev, const u8 *mac_addr, | ||
94 | enum nl80211_connect_failed_reason reason, | ||
95 | gfp_t gfp); | ||
96 | |||
97 | int nl80211_send_mgmt(struct cfg80211_registered_device *rdev, | 94 | int nl80211_send_mgmt(struct cfg80211_registered_device *rdev, |
98 | struct wireless_dev *wdev, u32 nlpid, | 95 | struct net_device *netdev, u32 nlpid, int freq, |
99 | int freq, int sig_dbm, | ||
100 | const u8 *buf, size_t len, gfp_t gfp); | 96 | const u8 *buf, size_t len, gfp_t gfp); |
101 | void nl80211_send_mgmt_tx_status(struct cfg80211_registered_device *rdev, | 97 | void nl80211_send_mgmt_tx_status(struct cfg80211_registered_device *rdev, |
102 | struct wireless_dev *wdev, u64 cookie, | 98 | struct net_device *netdev, u64 cookie, |
103 | const u8 *buf, size_t len, bool ack, | 99 | const u8 *buf, size_t len, bool ack, |
104 | gfp_t gfp); | 100 | gfp_t gfp); |
105 | 101 | ||
@@ -113,26 +109,8 @@ nl80211_send_cqm_pktloss_notify(struct cfg80211_registered_device *rdev, | |||
113 | struct net_device *netdev, const u8 *peer, | 109 | struct net_device *netdev, const u8 *peer, |
114 | u32 num_packets, gfp_t gfp); | 110 | u32 num_packets, gfp_t gfp); |
115 | 111 | ||
116 | void | ||
117 | nl80211_send_cqm_txe_notify(struct cfg80211_registered_device *rdev, | ||
118 | struct net_device *netdev, const u8 *peer, | ||
119 | u32 num_packets, u32 rate, u32 intvl, gfp_t gfp); | ||
120 | |||
121 | void nl80211_gtk_rekey_notify(struct cfg80211_registered_device *rdev, | 112 | void nl80211_gtk_rekey_notify(struct cfg80211_registered_device *rdev, |
122 | struct net_device *netdev, const u8 *bssid, | 113 | struct net_device *netdev, const u8 *bssid, |
123 | const u8 *replay_ctr, gfp_t gfp); | 114 | const u8 *replay_ctr, gfp_t gfp); |
124 | 115 | ||
125 | void nl80211_pmksa_candidate_notify(struct cfg80211_registered_device *rdev, | ||
126 | struct net_device *netdev, int index, | ||
127 | const u8 *bssid, bool preauth, gfp_t gfp); | ||
128 | |||
129 | void nl80211_ch_switch_notify(struct cfg80211_registered_device *rdev, | ||
130 | struct net_device *dev, | ||
131 | struct cfg80211_chan_def *chandef, gfp_t gfp); | ||
132 | |||
133 | bool nl80211_unexpected_frame(struct net_device *dev, | ||
134 | const u8 *addr, gfp_t gfp); | ||
135 | bool nl80211_unexpected_4addr_frame(struct net_device *dev, | ||
136 | const u8 *addr, gfp_t gfp); | ||
137 | |||
138 | #endif /* __NET_WIRELESS_NL80211_H */ | 116 | #endif /* __NET_WIRELESS_NL80211_H */ |
diff --git a/net/wireless/radiotap.c b/net/wireless/radiotap.c index 7d604c06c3d..dbe35e138e9 100644 --- a/net/wireless/radiotap.c +++ b/net/wireless/radiotap.c | |||
@@ -15,7 +15,6 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
18 | #include <linux/export.h> | ||
19 | #include <net/cfg80211.h> | 18 | #include <net/cfg80211.h> |
20 | #include <net/ieee80211_radiotap.h> | 19 | #include <net/ieee80211_radiotap.h> |
21 | #include <asm/unaligned.h> | 20 | #include <asm/unaligned.h> |
@@ -41,8 +40,6 @@ static const struct radiotap_align_size rtap_namespace_sizes[] = { | |||
41 | [IEEE80211_RADIOTAP_TX_FLAGS] = { .align = 2, .size = 2, }, | 40 | [IEEE80211_RADIOTAP_TX_FLAGS] = { .align = 2, .size = 2, }, |
42 | [IEEE80211_RADIOTAP_RTS_RETRIES] = { .align = 1, .size = 1, }, | 41 | [IEEE80211_RADIOTAP_RTS_RETRIES] = { .align = 1, .size = 1, }, |
43 | [IEEE80211_RADIOTAP_DATA_RETRIES] = { .align = 1, .size = 1, }, | 42 | [IEEE80211_RADIOTAP_DATA_RETRIES] = { .align = 1, .size = 1, }, |
44 | [IEEE80211_RADIOTAP_MCS] = { .align = 1, .size = 3, }, | ||
45 | [IEEE80211_RADIOTAP_AMPDU_STATUS] = { .align = 4, .size = 8, }, | ||
46 | /* | 43 | /* |
47 | * add more here as they are defined in radiotap.h | 44 | * add more here as they are defined in radiotap.h |
48 | */ | 45 | */ |
diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h deleted file mode 100644 index 6c0c8191f83..00000000000 --- a/net/wireless/rdev-ops.h +++ /dev/null | |||
@@ -1,878 +0,0 @@ | |||
1 | #ifndef __CFG80211_RDEV_OPS | ||
2 | #define __CFG80211_RDEV_OPS | ||
3 | |||
4 | #include <linux/rtnetlink.h> | ||
5 | #include <net/cfg80211.h> | ||
6 | #include "core.h" | ||
7 | #include "trace.h" | ||
8 | |||
9 | static inline int rdev_suspend(struct cfg80211_registered_device *rdev) | ||
10 | { | ||
11 | int ret; | ||
12 | trace_rdev_suspend(&rdev->wiphy, rdev->wowlan); | ||
13 | ret = rdev->ops->suspend(&rdev->wiphy, rdev->wowlan); | ||
14 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
15 | return ret; | ||
16 | } | ||
17 | |||
18 | static inline int rdev_resume(struct cfg80211_registered_device *rdev) | ||
19 | { | ||
20 | int ret; | ||
21 | trace_rdev_resume(&rdev->wiphy); | ||
22 | ret = rdev->ops->resume(&rdev->wiphy); | ||
23 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
24 | return ret; | ||
25 | } | ||
26 | |||
27 | static inline void rdev_set_wakeup(struct cfg80211_registered_device *rdev, | ||
28 | bool enabled) | ||
29 | { | ||
30 | trace_rdev_set_wakeup(&rdev->wiphy, enabled); | ||
31 | rdev->ops->set_wakeup(&rdev->wiphy, enabled); | ||
32 | trace_rdev_return_void(&rdev->wiphy); | ||
33 | } | ||
34 | |||
35 | static inline struct wireless_dev | ||
36 | *rdev_add_virtual_intf(struct cfg80211_registered_device *rdev, char *name, | ||
37 | enum nl80211_iftype type, u32 *flags, | ||
38 | struct vif_params *params) | ||
39 | { | ||
40 | struct wireless_dev *ret; | ||
41 | trace_rdev_add_virtual_intf(&rdev->wiphy, name, type); | ||
42 | ret = rdev->ops->add_virtual_intf(&rdev->wiphy, name, type, flags, | ||
43 | params); | ||
44 | trace_rdev_return_wdev(&rdev->wiphy, ret); | ||
45 | return ret; | ||
46 | } | ||
47 | |||
48 | static inline int | ||
49 | rdev_del_virtual_intf(struct cfg80211_registered_device *rdev, | ||
50 | struct wireless_dev *wdev) | ||
51 | { | ||
52 | int ret; | ||
53 | trace_rdev_del_virtual_intf(&rdev->wiphy, wdev); | ||
54 | ret = rdev->ops->del_virtual_intf(&rdev->wiphy, wdev); | ||
55 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
56 | return ret; | ||
57 | } | ||
58 | |||
59 | static inline int | ||
60 | rdev_change_virtual_intf(struct cfg80211_registered_device *rdev, | ||
61 | struct net_device *dev, enum nl80211_iftype type, | ||
62 | u32 *flags, struct vif_params *params) | ||
63 | { | ||
64 | int ret; | ||
65 | trace_rdev_change_virtual_intf(&rdev->wiphy, dev, type); | ||
66 | ret = rdev->ops->change_virtual_intf(&rdev->wiphy, dev, type, flags, | ||
67 | params); | ||
68 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
69 | return ret; | ||
70 | } | ||
71 | |||
72 | static inline int rdev_add_key(struct cfg80211_registered_device *rdev, | ||
73 | struct net_device *netdev, u8 key_index, | ||
74 | bool pairwise, const u8 *mac_addr, | ||
75 | struct key_params *params) | ||
76 | { | ||
77 | int ret; | ||
78 | trace_rdev_add_key(&rdev->wiphy, netdev, key_index, pairwise, mac_addr); | ||
79 | ret = rdev->ops->add_key(&rdev->wiphy, netdev, key_index, pairwise, | ||
80 | mac_addr, params); | ||
81 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
82 | return ret; | ||
83 | } | ||
84 | |||
85 | static inline int | ||
86 | rdev_get_key(struct cfg80211_registered_device *rdev, struct net_device *netdev, | ||
87 | u8 key_index, bool pairwise, const u8 *mac_addr, void *cookie, | ||
88 | void (*callback)(void *cookie, struct key_params*)) | ||
89 | { | ||
90 | int ret; | ||
91 | trace_rdev_get_key(&rdev->wiphy, netdev, key_index, pairwise, mac_addr); | ||
92 | ret = rdev->ops->get_key(&rdev->wiphy, netdev, key_index, pairwise, | ||
93 | mac_addr, cookie, callback); | ||
94 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
95 | return ret; | ||
96 | } | ||
97 | |||
98 | static inline int rdev_del_key(struct cfg80211_registered_device *rdev, | ||
99 | struct net_device *netdev, u8 key_index, | ||
100 | bool pairwise, const u8 *mac_addr) | ||
101 | { | ||
102 | int ret; | ||
103 | trace_rdev_del_key(&rdev->wiphy, netdev, key_index, pairwise, mac_addr); | ||
104 | ret = rdev->ops->del_key(&rdev->wiphy, netdev, key_index, pairwise, | ||
105 | mac_addr); | ||
106 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
107 | return ret; | ||
108 | } | ||
109 | |||
110 | static inline int | ||
111 | rdev_set_default_key(struct cfg80211_registered_device *rdev, | ||
112 | struct net_device *netdev, u8 key_index, bool unicast, | ||
113 | bool multicast) | ||
114 | { | ||
115 | int ret; | ||
116 | trace_rdev_set_default_key(&rdev->wiphy, netdev, key_index, | ||
117 | unicast, multicast); | ||
118 | ret = rdev->ops->set_default_key(&rdev->wiphy, netdev, key_index, | ||
119 | unicast, multicast); | ||
120 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
121 | return ret; | ||
122 | } | ||
123 | |||
124 | static inline int | ||
125 | rdev_set_default_mgmt_key(struct cfg80211_registered_device *rdev, | ||
126 | struct net_device *netdev, u8 key_index) | ||
127 | { | ||
128 | int ret; | ||
129 | trace_rdev_set_default_mgmt_key(&rdev->wiphy, netdev, key_index); | ||
130 | ret = rdev->ops->set_default_mgmt_key(&rdev->wiphy, netdev, | ||
131 | key_index); | ||
132 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
133 | return ret; | ||
134 | } | ||
135 | |||
136 | static inline int rdev_start_ap(struct cfg80211_registered_device *rdev, | ||
137 | struct net_device *dev, | ||
138 | struct cfg80211_ap_settings *settings) | ||
139 | { | ||
140 | int ret; | ||
141 | trace_rdev_start_ap(&rdev->wiphy, dev, settings); | ||
142 | ret = rdev->ops->start_ap(&rdev->wiphy, dev, settings); | ||
143 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
144 | return ret; | ||
145 | } | ||
146 | |||
147 | static inline int rdev_change_beacon(struct cfg80211_registered_device *rdev, | ||
148 | struct net_device *dev, | ||
149 | struct cfg80211_beacon_data *info) | ||
150 | { | ||
151 | int ret; | ||
152 | trace_rdev_change_beacon(&rdev->wiphy, dev, info); | ||
153 | ret = rdev->ops->change_beacon(&rdev->wiphy, dev, info); | ||
154 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
155 | return ret; | ||
156 | } | ||
157 | |||
158 | static inline int rdev_stop_ap(struct cfg80211_registered_device *rdev, | ||
159 | struct net_device *dev) | ||
160 | { | ||
161 | int ret; | ||
162 | trace_rdev_stop_ap(&rdev->wiphy, dev); | ||
163 | ret = rdev->ops->stop_ap(&rdev->wiphy, dev); | ||
164 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
165 | return ret; | ||
166 | } | ||
167 | |||
168 | static inline int rdev_add_station(struct cfg80211_registered_device *rdev, | ||
169 | struct net_device *dev, u8 *mac, | ||
170 | struct station_parameters *params) | ||
171 | { | ||
172 | int ret; | ||
173 | trace_rdev_add_station(&rdev->wiphy, dev, mac, params); | ||
174 | ret = rdev->ops->add_station(&rdev->wiphy, dev, mac, params); | ||
175 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
176 | return ret; | ||
177 | } | ||
178 | |||
179 | static inline int rdev_del_station(struct cfg80211_registered_device *rdev, | ||
180 | struct net_device *dev, u8 *mac) | ||
181 | { | ||
182 | int ret; | ||
183 | trace_rdev_del_station(&rdev->wiphy, dev, mac); | ||
184 | ret = rdev->ops->del_station(&rdev->wiphy, dev, mac); | ||
185 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
186 | return ret; | ||
187 | } | ||
188 | |||
189 | static inline int rdev_change_station(struct cfg80211_registered_device *rdev, | ||
190 | struct net_device *dev, u8 *mac, | ||
191 | struct station_parameters *params) | ||
192 | { | ||
193 | int ret; | ||
194 | trace_rdev_change_station(&rdev->wiphy, dev, mac, params); | ||
195 | ret = rdev->ops->change_station(&rdev->wiphy, dev, mac, params); | ||
196 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
197 | return ret; | ||
198 | } | ||
199 | |||
200 | static inline int rdev_get_station(struct cfg80211_registered_device *rdev, | ||
201 | struct net_device *dev, u8 *mac, | ||
202 | struct station_info *sinfo) | ||
203 | { | ||
204 | int ret; | ||
205 | trace_rdev_get_station(&rdev->wiphy, dev, mac); | ||
206 | ret = rdev->ops->get_station(&rdev->wiphy, dev, mac, sinfo); | ||
207 | trace_rdev_return_int_station_info(&rdev->wiphy, ret, sinfo); | ||
208 | return ret; | ||
209 | } | ||
210 | |||
211 | static inline int rdev_dump_station(struct cfg80211_registered_device *rdev, | ||
212 | struct net_device *dev, int idx, u8 *mac, | ||
213 | struct station_info *sinfo) | ||
214 | { | ||
215 | int ret; | ||
216 | trace_rdev_dump_station(&rdev->wiphy, dev, idx, mac); | ||
217 | ret = rdev->ops->dump_station(&rdev->wiphy, dev, idx, mac, sinfo); | ||
218 | trace_rdev_return_int_station_info(&rdev->wiphy, ret, sinfo); | ||
219 | return ret; | ||
220 | } | ||
221 | |||
222 | static inline int rdev_add_mpath(struct cfg80211_registered_device *rdev, | ||
223 | struct net_device *dev, u8 *dst, u8 *next_hop) | ||
224 | { | ||
225 | int ret; | ||
226 | trace_rdev_add_mpath(&rdev->wiphy, dev, dst, next_hop); | ||
227 | ret = rdev->ops->add_mpath(&rdev->wiphy, dev, dst, next_hop); | ||
228 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
229 | return ret; | ||
230 | } | ||
231 | |||
232 | static inline int rdev_del_mpath(struct cfg80211_registered_device *rdev, | ||
233 | struct net_device *dev, u8 *dst) | ||
234 | { | ||
235 | int ret; | ||
236 | trace_rdev_del_mpath(&rdev->wiphy, dev, dst); | ||
237 | ret = rdev->ops->del_mpath(&rdev->wiphy, dev, dst); | ||
238 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
239 | return ret; | ||
240 | } | ||
241 | |||
242 | static inline int rdev_change_mpath(struct cfg80211_registered_device *rdev, | ||
243 | struct net_device *dev, u8 *dst, | ||
244 | u8 *next_hop) | ||
245 | { | ||
246 | int ret; | ||
247 | trace_rdev_change_mpath(&rdev->wiphy, dev, dst, next_hop); | ||
248 | ret = rdev->ops->change_mpath(&rdev->wiphy, dev, dst, next_hop); | ||
249 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
250 | return ret; | ||
251 | } | ||
252 | |||
253 | static inline int rdev_get_mpath(struct cfg80211_registered_device *rdev, | ||
254 | struct net_device *dev, u8 *dst, u8 *next_hop, | ||
255 | struct mpath_info *pinfo) | ||
256 | { | ||
257 | int ret; | ||
258 | trace_rdev_get_mpath(&rdev->wiphy, dev, dst, next_hop); | ||
259 | ret = rdev->ops->get_mpath(&rdev->wiphy, dev, dst, next_hop, pinfo); | ||
260 | trace_rdev_return_int_mpath_info(&rdev->wiphy, ret, pinfo); | ||
261 | return ret; | ||
262 | |||
263 | } | ||
264 | |||
265 | static inline int rdev_dump_mpath(struct cfg80211_registered_device *rdev, | ||
266 | struct net_device *dev, int idx, u8 *dst, | ||
267 | u8 *next_hop, struct mpath_info *pinfo) | ||
268 | |||
269 | { | ||
270 | int ret; | ||
271 | trace_rdev_dump_mpath(&rdev->wiphy, dev, idx, dst, next_hop); | ||
272 | ret = rdev->ops->dump_mpath(&rdev->wiphy, dev, idx, dst, next_hop, | ||
273 | pinfo); | ||
274 | trace_rdev_return_int_mpath_info(&rdev->wiphy, ret, pinfo); | ||
275 | return ret; | ||
276 | } | ||
277 | |||
278 | static inline int | ||
279 | rdev_get_mesh_config(struct cfg80211_registered_device *rdev, | ||
280 | struct net_device *dev, struct mesh_config *conf) | ||
281 | { | ||
282 | int ret; | ||
283 | trace_rdev_get_mesh_config(&rdev->wiphy, dev); | ||
284 | ret = rdev->ops->get_mesh_config(&rdev->wiphy, dev, conf); | ||
285 | trace_rdev_return_int_mesh_config(&rdev->wiphy, ret, conf); | ||
286 | return ret; | ||
287 | } | ||
288 | |||
289 | static inline int | ||
290 | rdev_update_mesh_config(struct cfg80211_registered_device *rdev, | ||
291 | struct net_device *dev, u32 mask, | ||
292 | const struct mesh_config *nconf) | ||
293 | { | ||
294 | int ret; | ||
295 | trace_rdev_update_mesh_config(&rdev->wiphy, dev, mask, nconf); | ||
296 | ret = rdev->ops->update_mesh_config(&rdev->wiphy, dev, mask, nconf); | ||
297 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
298 | return ret; | ||
299 | } | ||
300 | |||
301 | static inline int rdev_join_mesh(struct cfg80211_registered_device *rdev, | ||
302 | struct net_device *dev, | ||
303 | const struct mesh_config *conf, | ||
304 | const struct mesh_setup *setup) | ||
305 | { | ||
306 | int ret; | ||
307 | trace_rdev_join_mesh(&rdev->wiphy, dev, conf, setup); | ||
308 | ret = rdev->ops->join_mesh(&rdev->wiphy, dev, conf, setup); | ||
309 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
310 | return ret; | ||
311 | } | ||
312 | |||
313 | |||
314 | static inline int rdev_leave_mesh(struct cfg80211_registered_device *rdev, | ||
315 | struct net_device *dev) | ||
316 | { | ||
317 | int ret; | ||
318 | trace_rdev_leave_mesh(&rdev->wiphy, dev); | ||
319 | ret = rdev->ops->leave_mesh(&rdev->wiphy, dev); | ||
320 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
321 | return ret; | ||
322 | } | ||
323 | |||
324 | static inline int rdev_change_bss(struct cfg80211_registered_device *rdev, | ||
325 | struct net_device *dev, | ||
326 | struct bss_parameters *params) | ||
327 | |||
328 | { | ||
329 | int ret; | ||
330 | trace_rdev_change_bss(&rdev->wiphy, dev, params); | ||
331 | ret = rdev->ops->change_bss(&rdev->wiphy, dev, params); | ||
332 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
333 | return ret; | ||
334 | } | ||
335 | |||
336 | static inline int rdev_set_txq_params(struct cfg80211_registered_device *rdev, | ||
337 | struct net_device *dev, | ||
338 | struct ieee80211_txq_params *params) | ||
339 | |||
340 | { | ||
341 | int ret; | ||
342 | trace_rdev_set_txq_params(&rdev->wiphy, dev, params); | ||
343 | ret = rdev->ops->set_txq_params(&rdev->wiphy, dev, params); | ||
344 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
345 | return ret; | ||
346 | } | ||
347 | |||
348 | static inline int | ||
349 | rdev_libertas_set_mesh_channel(struct cfg80211_registered_device *rdev, | ||
350 | struct net_device *dev, | ||
351 | struct ieee80211_channel *chan) | ||
352 | { | ||
353 | int ret; | ||
354 | trace_rdev_libertas_set_mesh_channel(&rdev->wiphy, dev, chan); | ||
355 | ret = rdev->ops->libertas_set_mesh_channel(&rdev->wiphy, dev, chan); | ||
356 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
357 | return ret; | ||
358 | } | ||
359 | |||
360 | static inline int | ||
361 | rdev_set_monitor_channel(struct cfg80211_registered_device *rdev, | ||
362 | struct cfg80211_chan_def *chandef) | ||
363 | { | ||
364 | int ret; | ||
365 | trace_rdev_set_monitor_channel(&rdev->wiphy, chandef); | ||
366 | ret = rdev->ops->set_monitor_channel(&rdev->wiphy, chandef); | ||
367 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
368 | return ret; | ||
369 | } | ||
370 | |||
371 | static inline int rdev_scan(struct cfg80211_registered_device *rdev, | ||
372 | struct cfg80211_scan_request *request) | ||
373 | { | ||
374 | int ret; | ||
375 | trace_rdev_scan(&rdev->wiphy, request); | ||
376 | ret = rdev->ops->scan(&rdev->wiphy, request); | ||
377 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
378 | return ret; | ||
379 | } | ||
380 | |||
381 | static inline int rdev_auth(struct cfg80211_registered_device *rdev, | ||
382 | struct net_device *dev, | ||
383 | struct cfg80211_auth_request *req) | ||
384 | { | ||
385 | int ret; | ||
386 | trace_rdev_auth(&rdev->wiphy, dev, req); | ||
387 | ret = rdev->ops->auth(&rdev->wiphy, dev, req); | ||
388 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
389 | return ret; | ||
390 | } | ||
391 | |||
392 | static inline int rdev_assoc(struct cfg80211_registered_device *rdev, | ||
393 | struct net_device *dev, | ||
394 | struct cfg80211_assoc_request *req) | ||
395 | { | ||
396 | int ret; | ||
397 | trace_rdev_assoc(&rdev->wiphy, dev, req); | ||
398 | ret = rdev->ops->assoc(&rdev->wiphy, dev, req); | ||
399 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
400 | return ret; | ||
401 | } | ||
402 | |||
403 | static inline int rdev_deauth(struct cfg80211_registered_device *rdev, | ||
404 | struct net_device *dev, | ||
405 | struct cfg80211_deauth_request *req) | ||
406 | { | ||
407 | int ret; | ||
408 | trace_rdev_deauth(&rdev->wiphy, dev, req); | ||
409 | ret = rdev->ops->deauth(&rdev->wiphy, dev, req); | ||
410 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
411 | return ret; | ||
412 | } | ||
413 | |||
414 | static inline int rdev_disassoc(struct cfg80211_registered_device *rdev, | ||
415 | struct net_device *dev, | ||
416 | struct cfg80211_disassoc_request *req) | ||
417 | { | ||
418 | int ret; | ||
419 | trace_rdev_disassoc(&rdev->wiphy, dev, req); | ||
420 | ret = rdev->ops->disassoc(&rdev->wiphy, dev, req); | ||
421 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
422 | return ret; | ||
423 | } | ||
424 | |||
425 | static inline int rdev_connect(struct cfg80211_registered_device *rdev, | ||
426 | struct net_device *dev, | ||
427 | struct cfg80211_connect_params *sme) | ||
428 | { | ||
429 | int ret; | ||
430 | trace_rdev_connect(&rdev->wiphy, dev, sme); | ||
431 | ret = rdev->ops->connect(&rdev->wiphy, dev, sme); | ||
432 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
433 | return ret; | ||
434 | } | ||
435 | |||
436 | static inline int rdev_disconnect(struct cfg80211_registered_device *rdev, | ||
437 | struct net_device *dev, u16 reason_code) | ||
438 | { | ||
439 | int ret; | ||
440 | trace_rdev_disconnect(&rdev->wiphy, dev, reason_code); | ||
441 | ret = rdev->ops->disconnect(&rdev->wiphy, dev, reason_code); | ||
442 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
443 | return ret; | ||
444 | } | ||
445 | |||
446 | static inline int rdev_join_ibss(struct cfg80211_registered_device *rdev, | ||
447 | struct net_device *dev, | ||
448 | struct cfg80211_ibss_params *params) | ||
449 | { | ||
450 | int ret; | ||
451 | trace_rdev_join_ibss(&rdev->wiphy, dev, params); | ||
452 | ret = rdev->ops->join_ibss(&rdev->wiphy, dev, params); | ||
453 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
454 | return ret; | ||
455 | } | ||
456 | |||
457 | static inline int rdev_leave_ibss(struct cfg80211_registered_device *rdev, | ||
458 | struct net_device *dev) | ||
459 | { | ||
460 | int ret; | ||
461 | trace_rdev_leave_ibss(&rdev->wiphy, dev); | ||
462 | ret = rdev->ops->leave_ibss(&rdev->wiphy, dev); | ||
463 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
464 | return ret; | ||
465 | } | ||
466 | |||
467 | static inline int | ||
468 | rdev_set_wiphy_params(struct cfg80211_registered_device *rdev, u32 changed) | ||
469 | { | ||
470 | int ret; | ||
471 | trace_rdev_set_wiphy_params(&rdev->wiphy, changed); | ||
472 | ret = rdev->ops->set_wiphy_params(&rdev->wiphy, changed); | ||
473 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
474 | return ret; | ||
475 | } | ||
476 | |||
477 | static inline int rdev_set_tx_power(struct cfg80211_registered_device *rdev, | ||
478 | struct wireless_dev *wdev, | ||
479 | enum nl80211_tx_power_setting type, int mbm) | ||
480 | { | ||
481 | int ret; | ||
482 | trace_rdev_set_tx_power(&rdev->wiphy, wdev, type, mbm); | ||
483 | ret = rdev->ops->set_tx_power(&rdev->wiphy, wdev, type, mbm); | ||
484 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
485 | return ret; | ||
486 | } | ||
487 | |||
488 | static inline int rdev_get_tx_power(struct cfg80211_registered_device *rdev, | ||
489 | struct wireless_dev *wdev, int *dbm) | ||
490 | { | ||
491 | int ret; | ||
492 | trace_rdev_get_tx_power(&rdev->wiphy, wdev); | ||
493 | ret = rdev->ops->get_tx_power(&rdev->wiphy, wdev, dbm); | ||
494 | trace_rdev_return_int_int(&rdev->wiphy, ret, *dbm); | ||
495 | return ret; | ||
496 | } | ||
497 | |||
498 | static inline int rdev_set_wds_peer(struct cfg80211_registered_device *rdev, | ||
499 | struct net_device *dev, const u8 *addr) | ||
500 | { | ||
501 | int ret; | ||
502 | trace_rdev_set_wds_peer(&rdev->wiphy, dev, addr); | ||
503 | ret = rdev->ops->set_wds_peer(&rdev->wiphy, dev, addr); | ||
504 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
505 | return ret; | ||
506 | } | ||
507 | |||
508 | static inline void rdev_rfkill_poll(struct cfg80211_registered_device *rdev) | ||
509 | { | ||
510 | trace_rdev_rfkill_poll(&rdev->wiphy); | ||
511 | rdev->ops->rfkill_poll(&rdev->wiphy); | ||
512 | trace_rdev_return_void(&rdev->wiphy); | ||
513 | } | ||
514 | |||
515 | |||
516 | #ifdef CONFIG_NL80211_TESTMODE | ||
517 | static inline int rdev_testmode_cmd(struct cfg80211_registered_device *rdev, | ||
518 | void *data, int len) | ||
519 | { | ||
520 | int ret; | ||
521 | trace_rdev_testmode_cmd(&rdev->wiphy); | ||
522 | ret = rdev->ops->testmode_cmd(&rdev->wiphy, data, len); | ||
523 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
524 | return ret; | ||
525 | } | ||
526 | |||
527 | static inline int rdev_testmode_dump(struct cfg80211_registered_device *rdev, | ||
528 | struct sk_buff *skb, | ||
529 | struct netlink_callback *cb, void *data, | ||
530 | int len) | ||
531 | { | ||
532 | int ret; | ||
533 | trace_rdev_testmode_dump(&rdev->wiphy); | ||
534 | ret = rdev->ops->testmode_dump(&rdev->wiphy, skb, cb, data, len); | ||
535 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
536 | return ret; | ||
537 | } | ||
538 | #endif | ||
539 | |||
540 | static inline int | ||
541 | rdev_set_bitrate_mask(struct cfg80211_registered_device *rdev, | ||
542 | struct net_device *dev, const u8 *peer, | ||
543 | const struct cfg80211_bitrate_mask *mask) | ||
544 | { | ||
545 | int ret; | ||
546 | trace_rdev_set_bitrate_mask(&rdev->wiphy, dev, peer, mask); | ||
547 | ret = rdev->ops->set_bitrate_mask(&rdev->wiphy, dev, peer, mask); | ||
548 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
549 | return ret; | ||
550 | } | ||
551 | |||
552 | static inline int rdev_dump_survey(struct cfg80211_registered_device *rdev, | ||
553 | struct net_device *netdev, int idx, | ||
554 | struct survey_info *info) | ||
555 | { | ||
556 | int ret; | ||
557 | trace_rdev_dump_survey(&rdev->wiphy, netdev, idx); | ||
558 | ret = rdev->ops->dump_survey(&rdev->wiphy, netdev, idx, info); | ||
559 | if (ret < 0) | ||
560 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
561 | else | ||
562 | trace_rdev_return_int_survey_info(&rdev->wiphy, ret, info); | ||
563 | return ret; | ||
564 | } | ||
565 | |||
566 | static inline int rdev_set_pmksa(struct cfg80211_registered_device *rdev, | ||
567 | struct net_device *netdev, | ||
568 | struct cfg80211_pmksa *pmksa) | ||
569 | { | ||
570 | int ret; | ||
571 | trace_rdev_set_pmksa(&rdev->wiphy, netdev, pmksa); | ||
572 | ret = rdev->ops->set_pmksa(&rdev->wiphy, netdev, pmksa); | ||
573 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
574 | return ret; | ||
575 | } | ||
576 | |||
577 | static inline int rdev_del_pmksa(struct cfg80211_registered_device *rdev, | ||
578 | struct net_device *netdev, | ||
579 | struct cfg80211_pmksa *pmksa) | ||
580 | { | ||
581 | int ret; | ||
582 | trace_rdev_del_pmksa(&rdev->wiphy, netdev, pmksa); | ||
583 | ret = rdev->ops->del_pmksa(&rdev->wiphy, netdev, pmksa); | ||
584 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
585 | return ret; | ||
586 | } | ||
587 | |||
588 | static inline int rdev_flush_pmksa(struct cfg80211_registered_device *rdev, | ||
589 | struct net_device *netdev) | ||
590 | { | ||
591 | int ret; | ||
592 | trace_rdev_flush_pmksa(&rdev->wiphy, netdev); | ||
593 | ret = rdev->ops->flush_pmksa(&rdev->wiphy, netdev); | ||
594 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
595 | return ret; | ||
596 | } | ||
597 | |||
598 | static inline int | ||
599 | rdev_remain_on_channel(struct cfg80211_registered_device *rdev, | ||
600 | struct wireless_dev *wdev, | ||
601 | struct ieee80211_channel *chan, | ||
602 | unsigned int duration, u64 *cookie) | ||
603 | { | ||
604 | int ret; | ||
605 | trace_rdev_remain_on_channel(&rdev->wiphy, wdev, chan, duration); | ||
606 | ret = rdev->ops->remain_on_channel(&rdev->wiphy, wdev, chan, | ||
607 | duration, cookie); | ||
608 | trace_rdev_return_int_cookie(&rdev->wiphy, ret, *cookie); | ||
609 | return ret; | ||
610 | } | ||
611 | |||
612 | static inline int | ||
613 | rdev_cancel_remain_on_channel(struct cfg80211_registered_device *rdev, | ||
614 | struct wireless_dev *wdev, u64 cookie) | ||
615 | { | ||
616 | int ret; | ||
617 | trace_rdev_cancel_remain_on_channel(&rdev->wiphy, wdev, cookie); | ||
618 | ret = rdev->ops->cancel_remain_on_channel(&rdev->wiphy, wdev, cookie); | ||
619 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
620 | return ret; | ||
621 | } | ||
622 | |||
623 | static inline int rdev_mgmt_tx(struct cfg80211_registered_device *rdev, | ||
624 | struct wireless_dev *wdev, | ||
625 | struct ieee80211_channel *chan, bool offchan, | ||
626 | unsigned int wait, const u8 *buf, size_t len, | ||
627 | bool no_cck, bool dont_wait_for_ack, u64 *cookie) | ||
628 | { | ||
629 | int ret; | ||
630 | trace_rdev_mgmt_tx(&rdev->wiphy, wdev, chan, offchan, | ||
631 | wait, no_cck, dont_wait_for_ack); | ||
632 | ret = rdev->ops->mgmt_tx(&rdev->wiphy, wdev, chan, offchan, | ||
633 | wait, buf, len, no_cck, | ||
634 | dont_wait_for_ack, cookie); | ||
635 | trace_rdev_return_int_cookie(&rdev->wiphy, ret, *cookie); | ||
636 | return ret; | ||
637 | } | ||
638 | |||
639 | static inline int | ||
640 | rdev_mgmt_tx_cancel_wait(struct cfg80211_registered_device *rdev, | ||
641 | struct wireless_dev *wdev, u64 cookie) | ||
642 | { | ||
643 | int ret; | ||
644 | trace_rdev_mgmt_tx_cancel_wait(&rdev->wiphy, wdev, cookie); | ||
645 | ret = rdev->ops->mgmt_tx_cancel_wait(&rdev->wiphy, wdev, cookie); | ||
646 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
647 | return ret; | ||
648 | } | ||
649 | |||
650 | static inline int rdev_set_power_mgmt(struct cfg80211_registered_device *rdev, | ||
651 | struct net_device *dev, bool enabled, | ||
652 | int timeout) | ||
653 | { | ||
654 | int ret; | ||
655 | trace_rdev_set_power_mgmt(&rdev->wiphy, dev, enabled, timeout); | ||
656 | ret = rdev->ops->set_power_mgmt(&rdev->wiphy, dev, enabled, timeout); | ||
657 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
658 | return ret; | ||
659 | } | ||
660 | |||
661 | static inline int | ||
662 | rdev_set_cqm_rssi_config(struct cfg80211_registered_device *rdev, | ||
663 | struct net_device *dev, s32 rssi_thold, u32 rssi_hyst) | ||
664 | { | ||
665 | int ret; | ||
666 | trace_rdev_set_cqm_rssi_config(&rdev->wiphy, dev, rssi_thold, | ||
667 | rssi_hyst); | ||
668 | ret = rdev->ops->set_cqm_rssi_config(&rdev->wiphy, dev, rssi_thold, | ||
669 | rssi_hyst); | ||
670 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
671 | return ret; | ||
672 | } | ||
673 | |||
674 | static inline int | ||
675 | rdev_set_cqm_txe_config(struct cfg80211_registered_device *rdev, | ||
676 | struct net_device *dev, u32 rate, u32 pkts, u32 intvl) | ||
677 | { | ||
678 | int ret; | ||
679 | trace_rdev_set_cqm_txe_config(&rdev->wiphy, dev, rate, pkts, intvl); | ||
680 | ret = rdev->ops->set_cqm_txe_config(&rdev->wiphy, dev, rate, pkts, | ||
681 | intvl); | ||
682 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
683 | return ret; | ||
684 | } | ||
685 | |||
686 | static inline void | ||
687 | rdev_mgmt_frame_register(struct cfg80211_registered_device *rdev, | ||
688 | struct wireless_dev *wdev, u16 frame_type, bool reg) | ||
689 | { | ||
690 | trace_rdev_mgmt_frame_register(&rdev->wiphy, wdev , frame_type, reg); | ||
691 | rdev->ops->mgmt_frame_register(&rdev->wiphy, wdev , frame_type, reg); | ||
692 | trace_rdev_return_void(&rdev->wiphy); | ||
693 | } | ||
694 | |||
695 | static inline int rdev_set_antenna(struct cfg80211_registered_device *rdev, | ||
696 | u32 tx_ant, u32 rx_ant) | ||
697 | { | ||
698 | int ret; | ||
699 | trace_rdev_set_antenna(&rdev->wiphy, tx_ant, rx_ant); | ||
700 | ret = rdev->ops->set_antenna(&rdev->wiphy, tx_ant, rx_ant); | ||
701 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
702 | return ret; | ||
703 | } | ||
704 | |||
705 | static inline int rdev_get_antenna(struct cfg80211_registered_device *rdev, | ||
706 | u32 *tx_ant, u32 *rx_ant) | ||
707 | { | ||
708 | int ret; | ||
709 | trace_rdev_get_antenna(&rdev->wiphy); | ||
710 | ret = rdev->ops->get_antenna(&rdev->wiphy, tx_ant, rx_ant); | ||
711 | if (ret) | ||
712 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
713 | else | ||
714 | trace_rdev_return_int_tx_rx(&rdev->wiphy, ret, *tx_ant, | ||
715 | *rx_ant); | ||
716 | return ret; | ||
717 | } | ||
718 | |||
719 | static inline int rdev_set_ringparam(struct cfg80211_registered_device *rdev, | ||
720 | u32 tx, u32 rx) | ||
721 | { | ||
722 | int ret; | ||
723 | trace_rdev_set_ringparam(&rdev->wiphy, tx, rx); | ||
724 | ret = rdev->ops->set_ringparam(&rdev->wiphy, tx, rx); | ||
725 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
726 | return ret; | ||
727 | } | ||
728 | |||
729 | static inline void rdev_get_ringparam(struct cfg80211_registered_device *rdev, | ||
730 | u32 *tx, u32 *tx_max, u32 *rx, | ||
731 | u32 *rx_max) | ||
732 | { | ||
733 | trace_rdev_get_ringparam(&rdev->wiphy); | ||
734 | rdev->ops->get_ringparam(&rdev->wiphy, tx, tx_max, rx, rx_max); | ||
735 | trace_rdev_return_void_tx_rx(&rdev->wiphy, *tx, *tx_max, *rx, *rx_max); | ||
736 | } | ||
737 | |||
738 | static inline int | ||
739 | rdev_sched_scan_start(struct cfg80211_registered_device *rdev, | ||
740 | struct net_device *dev, | ||
741 | struct cfg80211_sched_scan_request *request) | ||
742 | { | ||
743 | int ret; | ||
744 | trace_rdev_sched_scan_start(&rdev->wiphy, dev, request); | ||
745 | ret = rdev->ops->sched_scan_start(&rdev->wiphy, dev, request); | ||
746 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
747 | return ret; | ||
748 | } | ||
749 | |||
750 | static inline int rdev_sched_scan_stop(struct cfg80211_registered_device *rdev, | ||
751 | struct net_device *dev) | ||
752 | { | ||
753 | int ret; | ||
754 | trace_rdev_sched_scan_stop(&rdev->wiphy, dev); | ||
755 | ret = rdev->ops->sched_scan_stop(&rdev->wiphy, dev); | ||
756 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
757 | return ret; | ||
758 | } | ||
759 | |||
760 | static inline int rdev_set_rekey_data(struct cfg80211_registered_device *rdev, | ||
761 | struct net_device *dev, | ||
762 | struct cfg80211_gtk_rekey_data *data) | ||
763 | { | ||
764 | int ret; | ||
765 | trace_rdev_set_rekey_data(&rdev->wiphy, dev); | ||
766 | ret = rdev->ops->set_rekey_data(&rdev->wiphy, dev, data); | ||
767 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
768 | return ret; | ||
769 | } | ||
770 | |||
771 | static inline int rdev_tdls_mgmt(struct cfg80211_registered_device *rdev, | ||
772 | struct net_device *dev, u8 *peer, | ||
773 | u8 action_code, u8 dialog_token, | ||
774 | u16 status_code, const u8 *buf, size_t len) | ||
775 | { | ||
776 | int ret; | ||
777 | trace_rdev_tdls_mgmt(&rdev->wiphy, dev, peer, action_code, | ||
778 | dialog_token, status_code, buf, len); | ||
779 | ret = rdev->ops->tdls_mgmt(&rdev->wiphy, dev, peer, action_code, | ||
780 | dialog_token, status_code, buf, len); | ||
781 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
782 | return ret; | ||
783 | } | ||
784 | |||
785 | static inline int rdev_tdls_oper(struct cfg80211_registered_device *rdev, | ||
786 | struct net_device *dev, u8 *peer, | ||
787 | enum nl80211_tdls_operation oper) | ||
788 | { | ||
789 | int ret; | ||
790 | trace_rdev_tdls_oper(&rdev->wiphy, dev, peer, oper); | ||
791 | ret = rdev->ops->tdls_oper(&rdev->wiphy, dev, peer, oper); | ||
792 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
793 | return ret; | ||
794 | } | ||
795 | |||
796 | static inline int rdev_probe_client(struct cfg80211_registered_device *rdev, | ||
797 | struct net_device *dev, const u8 *peer, | ||
798 | u64 *cookie) | ||
799 | { | ||
800 | int ret; | ||
801 | trace_rdev_probe_client(&rdev->wiphy, dev, peer); | ||
802 | ret = rdev->ops->probe_client(&rdev->wiphy, dev, peer, cookie); | ||
803 | trace_rdev_return_int_cookie(&rdev->wiphy, ret, *cookie); | ||
804 | return ret; | ||
805 | } | ||
806 | |||
807 | static inline int rdev_set_noack_map(struct cfg80211_registered_device *rdev, | ||
808 | struct net_device *dev, u16 noack_map) | ||
809 | { | ||
810 | int ret; | ||
811 | trace_rdev_set_noack_map(&rdev->wiphy, dev, noack_map); | ||
812 | ret = rdev->ops->set_noack_map(&rdev->wiphy, dev, noack_map); | ||
813 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
814 | return ret; | ||
815 | } | ||
816 | |||
817 | static inline int | ||
818 | rdev_get_et_sset_count(struct cfg80211_registered_device *rdev, | ||
819 | struct net_device *dev, int sset) | ||
820 | { | ||
821 | int ret; | ||
822 | trace_rdev_get_et_sset_count(&rdev->wiphy, dev, sset); | ||
823 | ret = rdev->ops->get_et_sset_count(&rdev->wiphy, dev, sset); | ||
824 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
825 | return ret; | ||
826 | } | ||
827 | |||
828 | static inline void rdev_get_et_stats(struct cfg80211_registered_device *rdev, | ||
829 | struct net_device *dev, | ||
830 | struct ethtool_stats *stats, u64 *data) | ||
831 | { | ||
832 | trace_rdev_get_et_stats(&rdev->wiphy, dev); | ||
833 | rdev->ops->get_et_stats(&rdev->wiphy, dev, stats, data); | ||
834 | trace_rdev_return_void(&rdev->wiphy); | ||
835 | } | ||
836 | |||
837 | static inline void rdev_get_et_strings(struct cfg80211_registered_device *rdev, | ||
838 | struct net_device *dev, u32 sset, | ||
839 | u8 *data) | ||
840 | { | ||
841 | trace_rdev_get_et_strings(&rdev->wiphy, dev, sset); | ||
842 | rdev->ops->get_et_strings(&rdev->wiphy, dev, sset, data); | ||
843 | trace_rdev_return_void(&rdev->wiphy); | ||
844 | } | ||
845 | |||
846 | static inline int | ||
847 | rdev_get_channel(struct cfg80211_registered_device *rdev, | ||
848 | struct wireless_dev *wdev, | ||
849 | struct cfg80211_chan_def *chandef) | ||
850 | { | ||
851 | int ret; | ||
852 | |||
853 | trace_rdev_get_channel(&rdev->wiphy, wdev); | ||
854 | ret = rdev->ops->get_channel(&rdev->wiphy, wdev, chandef); | ||
855 | trace_rdev_return_chandef(&rdev->wiphy, ret, chandef); | ||
856 | |||
857 | return ret; | ||
858 | } | ||
859 | |||
860 | static inline int rdev_start_p2p_device(struct cfg80211_registered_device *rdev, | ||
861 | struct wireless_dev *wdev) | ||
862 | { | ||
863 | int ret; | ||
864 | |||
865 | trace_rdev_start_p2p_device(&rdev->wiphy, wdev); | ||
866 | ret = rdev->ops->start_p2p_device(&rdev->wiphy, wdev); | ||
867 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
868 | return ret; | ||
869 | } | ||
870 | |||
871 | static inline void rdev_stop_p2p_device(struct cfg80211_registered_device *rdev, | ||
872 | struct wireless_dev *wdev) | ||
873 | { | ||
874 | trace_rdev_stop_p2p_device(&rdev->wiphy, wdev); | ||
875 | rdev->ops->stop_p2p_device(&rdev->wiphy, wdev); | ||
876 | trace_rdev_return_void(&rdev->wiphy); | ||
877 | } | ||
878 | #endif /* __CFG80211_RDEV_OPS */ | ||
diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 82c4fc7c994..ca754451e76 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c | |||
@@ -2,22 +2,13 @@ | |||
2 | * Copyright 2002-2005, Instant802 Networks, Inc. | 2 | * Copyright 2002-2005, Instant802 Networks, Inc. |
3 | * Copyright 2005-2006, Devicescape Software, Inc. | 3 | * Copyright 2005-2006, Devicescape Software, Inc. |
4 | * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> | 4 | * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> |
5 | * Copyright 2008-2011 Luis R. Rodriguez <mcgrof@qca.qualcomm.com> | 5 | * Copyright 2008 Luis R. Rodriguez <lrodriguz@atheros.com> |
6 | * | 6 | * |
7 | * Permission to use, copy, modify, and/or distribute this software for any | 7 | * This program is free software; you can redistribute it and/or modify |
8 | * purpose with or without fee is hereby granted, provided that the above | 8 | * it under the terms of the GNU General Public License version 2 as |
9 | * copyright notice and this permission notice appear in all copies. | 9 | * published by the Free Software Foundation. |
10 | * | ||
11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
18 | */ | 10 | */ |
19 | 11 | ||
20 | |||
21 | /** | 12 | /** |
22 | * DOC: Wireless regulatory infrastructure | 13 | * DOC: Wireless regulatory infrastructure |
23 | * | 14 | * |
@@ -45,14 +36,12 @@ | |||
45 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 36 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
46 | 37 | ||
47 | #include <linux/kernel.h> | 38 | #include <linux/kernel.h> |
48 | #include <linux/export.h> | ||
49 | #include <linux/slab.h> | 39 | #include <linux/slab.h> |
50 | #include <linux/list.h> | 40 | #include <linux/list.h> |
51 | #include <linux/random.h> | 41 | #include <linux/random.h> |
52 | #include <linux/ctype.h> | 42 | #include <linux/ctype.h> |
53 | #include <linux/nl80211.h> | 43 | #include <linux/nl80211.h> |
54 | #include <linux/platform_device.h> | 44 | #include <linux/platform_device.h> |
55 | #include <linux/moduleparam.h> | ||
56 | #include <net/cfg80211.h> | 45 | #include <net/cfg80211.h> |
57 | #include "core.h" | 46 | #include "core.h" |
58 | #include "reg.h" | 47 | #include "reg.h" |
@@ -60,8 +49,10 @@ | |||
60 | #include "nl80211.h" | 49 | #include "nl80211.h" |
61 | 50 | ||
62 | #ifdef CONFIG_CFG80211_REG_DEBUG | 51 | #ifdef CONFIG_CFG80211_REG_DEBUG |
63 | #define REG_DBG_PRINT(format, args...) \ | 52 | #define REG_DBG_PRINT(format, args...) \ |
64 | printk(KERN_DEBUG pr_fmt(format), ##args) | 53 | do { \ |
54 | printk(KERN_DEBUG pr_fmt(format), ##args); \ | ||
55 | } while (0) | ||
65 | #else | 56 | #else |
66 | #define REG_DBG_PRINT(args...) | 57 | #define REG_DBG_PRINT(args...) |
67 | #endif | 58 | #endif |
@@ -97,16 +88,9 @@ const struct ieee80211_regdomain *cfg80211_regdomain; | |||
97 | * - cfg80211_world_regdom | 88 | * - cfg80211_world_regdom |
98 | * - cfg80211_regdom | 89 | * - cfg80211_regdom |
99 | * - last_request | 90 | * - last_request |
100 | * - reg_num_devs_support_basehint | ||
101 | */ | 91 | */ |
102 | static DEFINE_MUTEX(reg_mutex); | 92 | static DEFINE_MUTEX(reg_mutex); |
103 | 93 | ||
104 | /* | ||
105 | * Number of devices that registered to the core | ||
106 | * that support cellular base station regulatory hints | ||
107 | */ | ||
108 | static int reg_num_devs_support_basehint; | ||
109 | |||
110 | static inline void assert_reg_lock(void) | 94 | static inline void assert_reg_lock(void) |
111 | { | 95 | { |
112 | lockdep_assert_held(®_mutex); | 96 | lockdep_assert_held(®_mutex); |
@@ -136,13 +120,14 @@ static DECLARE_DELAYED_WORK(reg_timeout, reg_timeout_work); | |||
136 | 120 | ||
137 | /* We keep a static world regulatory domain in case of the absence of CRDA */ | 121 | /* We keep a static world regulatory domain in case of the absence of CRDA */ |
138 | static const struct ieee80211_regdomain world_regdom = { | 122 | static const struct ieee80211_regdomain world_regdom = { |
139 | .n_reg_rules = 6, | 123 | .n_reg_rules = 5, |
140 | .alpha2 = "00", | 124 | .alpha2 = "00", |
141 | .reg_rules = { | 125 | .reg_rules = { |
142 | /* IEEE 802.11b/g, channels 1..11 */ | 126 | /* IEEE 802.11b/g, channels 1..11 */ |
143 | REG_RULE(2412-10, 2462+10, 40, 6, 20, 0), | 127 | REG_RULE(2412-10, 2462+10, 40, 6, 20, 0), |
144 | /* IEEE 802.11b/g, channels 12..13. */ | 128 | /* IEEE 802.11b/g, channels 12..13. No HT40 |
145 | REG_RULE(2467-10, 2472+10, 40, 6, 20, | 129 | * channel fits here. */ |
130 | REG_RULE(2467-10, 2472+10, 20, 6, 20, | ||
146 | NL80211_RRF_PASSIVE_SCAN | | 131 | NL80211_RRF_PASSIVE_SCAN | |
147 | NL80211_RRF_NO_IBSS), | 132 | NL80211_RRF_NO_IBSS), |
148 | /* IEEE 802.11 channel 14 - Only JP enables | 133 | /* IEEE 802.11 channel 14 - Only JP enables |
@@ -162,9 +147,6 @@ static const struct ieee80211_regdomain world_regdom = { | |||
162 | REG_RULE(5745-10, 5825+10, 40, 6, 20, | 147 | REG_RULE(5745-10, 5825+10, 40, 6, 20, |
163 | NL80211_RRF_PASSIVE_SCAN | | 148 | NL80211_RRF_PASSIVE_SCAN | |
164 | NL80211_RRF_NO_IBSS), | 149 | NL80211_RRF_NO_IBSS), |
165 | |||
166 | /* IEEE 802.11ad (60gHz), channels 1..3 */ | ||
167 | REG_RULE(56160+2160*1-1080, 56160+2160*3+1080, 2160, 0, 0, 0), | ||
168 | } | 150 | } |
169 | }; | 151 | }; |
170 | 152 | ||
@@ -349,9 +331,6 @@ static void reg_regdb_search(struct work_struct *work) | |||
349 | struct reg_regdb_search_request *request; | 331 | struct reg_regdb_search_request *request; |
350 | const struct ieee80211_regdomain *curdom, *regdom; | 332 | const struct ieee80211_regdomain *curdom, *regdom; |
351 | int i, r; | 333 | int i, r; |
352 | bool set_reg = false; | ||
353 | |||
354 | mutex_lock(&cfg80211_mutex); | ||
355 | 334 | ||
356 | mutex_lock(®_regdb_search_mutex); | 335 | mutex_lock(®_regdb_search_mutex); |
357 | while (!list_empty(®_regdb_search_list)) { | 336 | while (!list_empty(®_regdb_search_list)) { |
@@ -367,7 +346,9 @@ static void reg_regdb_search(struct work_struct *work) | |||
367 | r = reg_copy_regd(®dom, curdom); | 346 | r = reg_copy_regd(®dom, curdom); |
368 | if (r) | 347 | if (r) |
369 | break; | 348 | break; |
370 | set_reg = true; | 349 | mutex_lock(&cfg80211_mutex); |
350 | set_regdom(regdom); | ||
351 | mutex_unlock(&cfg80211_mutex); | ||
371 | break; | 352 | break; |
372 | } | 353 | } |
373 | } | 354 | } |
@@ -375,11 +356,6 @@ static void reg_regdb_search(struct work_struct *work) | |||
375 | kfree(request); | 356 | kfree(request); |
376 | } | 357 | } |
377 | mutex_unlock(®_regdb_search_mutex); | 358 | mutex_unlock(®_regdb_search_mutex); |
378 | |||
379 | if (set_reg) | ||
380 | set_regdom(regdom); | ||
381 | |||
382 | mutex_unlock(&cfg80211_mutex); | ||
383 | } | 359 | } |
384 | 360 | ||
385 | static DECLARE_WORK(reg_regdb_work, reg_regdb_search); | 361 | static DECLARE_WORK(reg_regdb_work, reg_regdb_search); |
@@ -403,15 +379,7 @@ static void reg_regdb_query(const char *alpha2) | |||
403 | 379 | ||
404 | schedule_work(®_regdb_work); | 380 | schedule_work(®_regdb_work); |
405 | } | 381 | } |
406 | |||
407 | /* Feel free to add any other sanity checks here */ | ||
408 | static void reg_regdb_size_check(void) | ||
409 | { | ||
410 | /* We should ideally BUILD_BUG_ON() but then random builds would fail */ | ||
411 | WARN_ONCE(!reg_regdb_size, "db.txt is empty, you should update it..."); | ||
412 | } | ||
413 | #else | 382 | #else |
414 | static inline void reg_regdb_size_check(void) {} | ||
415 | static inline void reg_regdb_query(const char *alpha2) {} | 383 | static inline void reg_regdb_query(const char *alpha2) {} |
416 | #endif /* CONFIG_CFG80211_INTERNAL_REGDB */ | 384 | #endif /* CONFIG_CFG80211_INTERNAL_REGDB */ |
417 | 385 | ||
@@ -509,11 +477,9 @@ static bool reg_does_bw_fit(const struct ieee80211_freq_range *freq_range, | |||
509 | * | 477 | * |
510 | * This lets us know if a specific frequency rule is or is not relevant to | 478 | * This lets us know if a specific frequency rule is or is not relevant to |
511 | * a specific frequency's band. Bands are device specific and artificial | 479 | * a specific frequency's band. Bands are device specific and artificial |
512 | * definitions (the "2.4 GHz band", the "5 GHz band" and the "60GHz band"), | 480 | * definitions (the "2.4 GHz band" and the "5 GHz band"), however it is |
513 | * however it is safe for now to assume that a frequency rule should not be | 481 | * safe for now to assume that a frequency rule should not be part of a |
514 | * part of a frequency's band if the start freq or end freq are off by more | 482 | * frequency's band if the start freq or end freq are off by more than 2 GHz. |
515 | * than 2 GHz for the 2.4 and 5 GHz bands, and by more than 10 GHz for the | ||
516 | * 60 GHz band. | ||
517 | * This resolution can be lowered and should be considered as we add | 483 | * This resolution can be lowered and should be considered as we add |
518 | * regulatory rule support for other "bands". | 484 | * regulatory rule support for other "bands". |
519 | **/ | 485 | **/ |
@@ -521,16 +487,9 @@ static bool freq_in_rule_band(const struct ieee80211_freq_range *freq_range, | |||
521 | u32 freq_khz) | 487 | u32 freq_khz) |
522 | { | 488 | { |
523 | #define ONE_GHZ_IN_KHZ 1000000 | 489 | #define ONE_GHZ_IN_KHZ 1000000 |
524 | /* | 490 | if (abs(freq_khz - freq_range->start_freq_khz) <= (2 * ONE_GHZ_IN_KHZ)) |
525 | * From 802.11ad: directional multi-gigabit (DMG): | ||
526 | * Pertaining to operation in a frequency band containing a channel | ||
527 | * with the Channel starting frequency above 45 GHz. | ||
528 | */ | ||
529 | u32 limit = freq_khz > 45 * ONE_GHZ_IN_KHZ ? | ||
530 | 10 * ONE_GHZ_IN_KHZ : 2 * ONE_GHZ_IN_KHZ; | ||
531 | if (abs(freq_khz - freq_range->start_freq_khz) <= limit) | ||
532 | return true; | 491 | return true; |
533 | if (abs(freq_khz - freq_range->end_freq_khz) <= limit) | 492 | if (abs(freq_khz - freq_range->end_freq_khz) <= (2 * ONE_GHZ_IN_KHZ)) |
534 | return true; | 493 | return true; |
535 | return false; | 494 | return false; |
536 | #undef ONE_GHZ_IN_KHZ | 495 | #undef ONE_GHZ_IN_KHZ |
@@ -694,8 +653,6 @@ static u32 map_regdom_flags(u32 rd_flags) | |||
694 | channel_flags |= IEEE80211_CHAN_NO_IBSS; | 653 | channel_flags |= IEEE80211_CHAN_NO_IBSS; |
695 | if (rd_flags & NL80211_RRF_DFS) | 654 | if (rd_flags & NL80211_RRF_DFS) |
696 | channel_flags |= IEEE80211_CHAN_RADAR; | 655 | channel_flags |= IEEE80211_CHAN_RADAR; |
697 | if (rd_flags & NL80211_RRF_NO_OFDM) | ||
698 | channel_flags |= IEEE80211_CHAN_NO_OFDM; | ||
699 | return channel_flags; | 656 | return channel_flags; |
700 | } | 657 | } |
701 | 658 | ||
@@ -812,10 +769,9 @@ static void chan_reg_rule_print_dbg(struct ieee80211_channel *chan, | |||
812 | chan->center_freq, | 769 | chan->center_freq, |
813 | KHZ_TO_MHZ(desired_bw_khz)); | 770 | KHZ_TO_MHZ(desired_bw_khz)); |
814 | 771 | ||
815 | REG_DBG_PRINT("%d KHz - %d KHz @ %d KHz), (%s mBi, %d mBm)\n", | 772 | REG_DBG_PRINT("%d KHz - %d KHz @ KHz), (%s mBi, %d mBm)\n", |
816 | freq_range->start_freq_khz, | 773 | freq_range->start_freq_khz, |
817 | freq_range->end_freq_khz, | 774 | freq_range->end_freq_khz, |
818 | freq_range->max_bandwidth_khz, | ||
819 | max_antenna_gain, | 775 | max_antenna_gain, |
820 | power_rule->max_eirp); | 776 | power_rule->max_eirp); |
821 | } | 777 | } |
@@ -907,7 +863,7 @@ static void handle_channel(struct wiphy *wiphy, | |||
907 | map_regdom_flags(reg_rule->flags) | bw_flags; | 863 | map_regdom_flags(reg_rule->flags) | bw_flags; |
908 | chan->max_antenna_gain = chan->orig_mag = | 864 | chan->max_antenna_gain = chan->orig_mag = |
909 | (int) MBI_TO_DBI(power_rule->max_antenna_gain); | 865 | (int) MBI_TO_DBI(power_rule->max_antenna_gain); |
910 | chan->max_reg_power = chan->max_power = chan->orig_mpwr = | 866 | chan->max_power = chan->orig_mpwr = |
911 | (int) MBM_TO_DBM(power_rule->max_eirp); | 867 | (int) MBM_TO_DBM(power_rule->max_eirp); |
912 | return; | 868 | return; |
913 | } | 869 | } |
@@ -916,22 +872,11 @@ static void handle_channel(struct wiphy *wiphy, | |||
916 | chan->flags = flags | bw_flags | map_regdom_flags(reg_rule->flags); | 872 | chan->flags = flags | bw_flags | map_regdom_flags(reg_rule->flags); |
917 | chan->max_antenna_gain = min(chan->orig_mag, | 873 | chan->max_antenna_gain = min(chan->orig_mag, |
918 | (int) MBI_TO_DBI(power_rule->max_antenna_gain)); | 874 | (int) MBI_TO_DBI(power_rule->max_antenna_gain)); |
919 | chan->max_reg_power = (int) MBM_TO_DBM(power_rule->max_eirp); | 875 | if (chan->orig_mpwr) |
920 | if (chan->orig_mpwr) { | 876 | chan->max_power = min(chan->orig_mpwr, |
921 | /* | 877 | (int) MBM_TO_DBM(power_rule->max_eirp)); |
922 | * Devices that have their own custom regulatory domain | 878 | else |
923 | * but also use WIPHY_FLAG_STRICT_REGULATORY will follow the | 879 | chan->max_power = (int) MBM_TO_DBM(power_rule->max_eirp); |
924 | * passed country IE power settings. | ||
925 | */ | ||
926 | if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE && | ||
927 | wiphy->flags & WIPHY_FLAG_CUSTOM_REGULATORY && | ||
928 | wiphy->flags & WIPHY_FLAG_STRICT_REGULATORY) | ||
929 | chan->max_power = chan->max_reg_power; | ||
930 | else | ||
931 | chan->max_power = min(chan->orig_mpwr, | ||
932 | chan->max_reg_power); | ||
933 | } else | ||
934 | chan->max_power = chan->max_reg_power; | ||
935 | } | 880 | } |
936 | 881 | ||
937 | static void handle_band(struct wiphy *wiphy, | 882 | static void handle_band(struct wiphy *wiphy, |
@@ -948,61 +893,6 @@ static void handle_band(struct wiphy *wiphy, | |||
948 | handle_channel(wiphy, initiator, band, i); | 893 | handle_channel(wiphy, initiator, band, i); |
949 | } | 894 | } |
950 | 895 | ||
951 | static bool reg_request_cell_base(struct regulatory_request *request) | ||
952 | { | ||
953 | if (request->initiator != NL80211_REGDOM_SET_BY_USER) | ||
954 | return false; | ||
955 | if (request->user_reg_hint_type != NL80211_USER_REG_HINT_CELL_BASE) | ||
956 | return false; | ||
957 | return true; | ||
958 | } | ||
959 | |||
960 | bool reg_last_request_cell_base(void) | ||
961 | { | ||
962 | bool val; | ||
963 | assert_cfg80211_lock(); | ||
964 | |||
965 | mutex_lock(®_mutex); | ||
966 | val = reg_request_cell_base(last_request); | ||
967 | mutex_unlock(®_mutex); | ||
968 | return val; | ||
969 | } | ||
970 | |||
971 | #ifdef CONFIG_CFG80211_CERTIFICATION_ONUS | ||
972 | |||
973 | /* Core specific check */ | ||
974 | static int reg_ignore_cell_hint(struct regulatory_request *pending_request) | ||
975 | { | ||
976 | if (!reg_num_devs_support_basehint) | ||
977 | return -EOPNOTSUPP; | ||
978 | |||
979 | if (reg_request_cell_base(last_request)) { | ||
980 | if (!regdom_changes(pending_request->alpha2)) | ||
981 | return -EALREADY; | ||
982 | return 0; | ||
983 | } | ||
984 | return 0; | ||
985 | } | ||
986 | |||
987 | /* Device specific check */ | ||
988 | static bool reg_dev_ignore_cell_hint(struct wiphy *wiphy) | ||
989 | { | ||
990 | if (!(wiphy->features & NL80211_FEATURE_CELL_BASE_REG_HINTS)) | ||
991 | return true; | ||
992 | return false; | ||
993 | } | ||
994 | #else | ||
995 | static int reg_ignore_cell_hint(struct regulatory_request *pending_request) | ||
996 | { | ||
997 | return -EOPNOTSUPP; | ||
998 | } | ||
999 | static int reg_dev_ignore_cell_hint(struct wiphy *wiphy) | ||
1000 | { | ||
1001 | return true; | ||
1002 | } | ||
1003 | #endif | ||
1004 | |||
1005 | |||
1006 | static bool ignore_reg_update(struct wiphy *wiphy, | 896 | static bool ignore_reg_update(struct wiphy *wiphy, |
1007 | enum nl80211_reg_initiator initiator) | 897 | enum nl80211_reg_initiator initiator) |
1008 | { | 898 | { |
@@ -1017,7 +907,7 @@ static bool ignore_reg_update(struct wiphy *wiphy, | |||
1017 | wiphy->flags & WIPHY_FLAG_CUSTOM_REGULATORY) { | 907 | wiphy->flags & WIPHY_FLAG_CUSTOM_REGULATORY) { |
1018 | REG_DBG_PRINT("Ignoring regulatory request %s " | 908 | REG_DBG_PRINT("Ignoring regulatory request %s " |
1019 | "since the driver uses its own custom " | 909 | "since the driver uses its own custom " |
1020 | "regulatory domain\n", | 910 | "regulatory domain ", |
1021 | reg_initiator_name(initiator)); | 911 | reg_initiator_name(initiator)); |
1022 | return true; | 912 | return true; |
1023 | } | 913 | } |
@@ -1031,17 +921,22 @@ static bool ignore_reg_update(struct wiphy *wiphy, | |||
1031 | !is_world_regdom(last_request->alpha2)) { | 921 | !is_world_regdom(last_request->alpha2)) { |
1032 | REG_DBG_PRINT("Ignoring regulatory request %s " | 922 | REG_DBG_PRINT("Ignoring regulatory request %s " |
1033 | "since the driver requires its own regulatory " | 923 | "since the driver requires its own regulatory " |
1034 | "domain to be set first\n", | 924 | "domain to be set first", |
1035 | reg_initiator_name(initiator)); | 925 | reg_initiator_name(initiator)); |
1036 | return true; | 926 | return true; |
1037 | } | 927 | } |
1038 | 928 | ||
1039 | if (reg_request_cell_base(last_request)) | ||
1040 | return reg_dev_ignore_cell_hint(wiphy); | ||
1041 | |||
1042 | return false; | 929 | return false; |
1043 | } | 930 | } |
1044 | 931 | ||
932 | static void update_all_wiphy_regulatory(enum nl80211_reg_initiator initiator) | ||
933 | { | ||
934 | struct cfg80211_registered_device *rdev; | ||
935 | |||
936 | list_for_each_entry(rdev, &cfg80211_rdev_list, list) | ||
937 | wiphy_update_regulatory(&rdev->wiphy, initiator); | ||
938 | } | ||
939 | |||
1045 | static void handle_reg_beacon(struct wiphy *wiphy, | 940 | static void handle_reg_beacon(struct wiphy *wiphy, |
1046 | unsigned int chan_idx, | 941 | unsigned int chan_idx, |
1047 | struct reg_beacon *reg_beacon) | 942 | struct reg_beacon *reg_beacon) |
@@ -1241,18 +1136,14 @@ static void reg_process_ht_flags(struct wiphy *wiphy) | |||
1241 | 1136 | ||
1242 | } | 1137 | } |
1243 | 1138 | ||
1244 | static void wiphy_update_regulatory(struct wiphy *wiphy, | 1139 | void wiphy_update_regulatory(struct wiphy *wiphy, |
1245 | enum nl80211_reg_initiator initiator) | 1140 | enum nl80211_reg_initiator initiator) |
1246 | { | 1141 | { |
1247 | enum ieee80211_band band; | 1142 | enum ieee80211_band band; |
1248 | 1143 | ||
1249 | assert_reg_lock(); | ||
1250 | |||
1251 | if (ignore_reg_update(wiphy, initiator)) | 1144 | if (ignore_reg_update(wiphy, initiator)) |
1252 | return; | 1145 | return; |
1253 | 1146 | ||
1254 | last_request->dfs_region = cfg80211_regdomain->dfs_region; | ||
1255 | |||
1256 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) { | 1147 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) { |
1257 | if (wiphy->bands[band]) | 1148 | if (wiphy->bands[band]) |
1258 | handle_band(wiphy, band, initiator); | 1149 | handle_band(wiphy, band, initiator); |
@@ -1264,26 +1155,6 @@ static void wiphy_update_regulatory(struct wiphy *wiphy, | |||
1264 | wiphy->reg_notifier(wiphy, last_request); | 1155 | wiphy->reg_notifier(wiphy, last_request); |
1265 | } | 1156 | } |
1266 | 1157 | ||
1267 | static void update_all_wiphy_regulatory(enum nl80211_reg_initiator initiator) | ||
1268 | { | ||
1269 | struct cfg80211_registered_device *rdev; | ||
1270 | struct wiphy *wiphy; | ||
1271 | |||
1272 | list_for_each_entry(rdev, &cfg80211_rdev_list, list) { | ||
1273 | wiphy = &rdev->wiphy; | ||
1274 | wiphy_update_regulatory(wiphy, initiator); | ||
1275 | /* | ||
1276 | * Regulatory updates set by CORE are ignored for custom | ||
1277 | * regulatory cards. Let us notify the changes to the driver, | ||
1278 | * as some drivers used this to restore its orig_* reg domain. | ||
1279 | */ | ||
1280 | if (initiator == NL80211_REGDOM_SET_BY_CORE && | ||
1281 | wiphy->flags & WIPHY_FLAG_CUSTOM_REGULATORY && | ||
1282 | wiphy->reg_notifier) | ||
1283 | wiphy->reg_notifier(wiphy, last_request); | ||
1284 | } | ||
1285 | } | ||
1286 | |||
1287 | static void handle_channel_custom(struct wiphy *wiphy, | 1158 | static void handle_channel_custom(struct wiphy *wiphy, |
1288 | enum ieee80211_band band, | 1159 | enum ieee80211_band band, |
1289 | unsigned int chan_idx, | 1160 | unsigned int chan_idx, |
@@ -1330,8 +1201,7 @@ static void handle_channel_custom(struct wiphy *wiphy, | |||
1330 | 1201 | ||
1331 | chan->flags |= map_regdom_flags(reg_rule->flags) | bw_flags; | 1202 | chan->flags |= map_regdom_flags(reg_rule->flags) | bw_flags; |
1332 | chan->max_antenna_gain = (int) MBI_TO_DBI(power_rule->max_antenna_gain); | 1203 | chan->max_antenna_gain = (int) MBI_TO_DBI(power_rule->max_antenna_gain); |
1333 | chan->max_reg_power = chan->max_power = | 1204 | chan->max_power = (int) MBM_TO_DBM(power_rule->max_eirp); |
1334 | (int) MBM_TO_DBM(power_rule->max_eirp); | ||
1335 | } | 1205 | } |
1336 | 1206 | ||
1337 | static void handle_band_custom(struct wiphy *wiphy, enum ieee80211_band band, | 1207 | static void handle_band_custom(struct wiphy *wiphy, enum ieee80211_band band, |
@@ -1395,13 +1265,6 @@ static int ignore_request(struct wiphy *wiphy, | |||
1395 | return 0; | 1265 | return 0; |
1396 | case NL80211_REGDOM_SET_BY_COUNTRY_IE: | 1266 | case NL80211_REGDOM_SET_BY_COUNTRY_IE: |
1397 | 1267 | ||
1398 | if (reg_request_cell_base(last_request)) { | ||
1399 | /* Trust a Cell base station over the AP's country IE */ | ||
1400 | if (regdom_changes(pending_request->alpha2)) | ||
1401 | return -EOPNOTSUPP; | ||
1402 | return -EALREADY; | ||
1403 | } | ||
1404 | |||
1405 | last_wiphy = wiphy_idx_to_wiphy(last_request->wiphy_idx); | 1268 | last_wiphy = wiphy_idx_to_wiphy(last_request->wiphy_idx); |
1406 | 1269 | ||
1407 | if (unlikely(!is_an_alpha2(pending_request->alpha2))) | 1270 | if (unlikely(!is_an_alpha2(pending_request->alpha2))) |
@@ -1446,12 +1309,6 @@ static int ignore_request(struct wiphy *wiphy, | |||
1446 | 1309 | ||
1447 | return REG_INTERSECT; | 1310 | return REG_INTERSECT; |
1448 | case NL80211_REGDOM_SET_BY_USER: | 1311 | case NL80211_REGDOM_SET_BY_USER: |
1449 | if (reg_request_cell_base(pending_request)) | ||
1450 | return reg_ignore_cell_hint(pending_request); | ||
1451 | |||
1452 | if (reg_request_cell_base(last_request)) | ||
1453 | return -EOPNOTSUPP; | ||
1454 | |||
1455 | if (last_request->initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) | 1312 | if (last_request->initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) |
1456 | return REG_INTERSECT; | 1313 | return REG_INTERSECT; |
1457 | /* | 1314 | /* |
@@ -1493,7 +1350,7 @@ static void reg_set_request_processed(void) | |||
1493 | spin_unlock(®_requests_lock); | 1350 | spin_unlock(®_requests_lock); |
1494 | 1351 | ||
1495 | if (last_request->initiator == NL80211_REGDOM_SET_BY_USER) | 1352 | if (last_request->initiator == NL80211_REGDOM_SET_BY_USER) |
1496 | cancel_delayed_work(®_timeout); | 1353 | cancel_delayed_work_sync(®_timeout); |
1497 | 1354 | ||
1498 | if (need_more_processing) | 1355 | if (need_more_processing) |
1499 | schedule_work(®_work); | 1356 | schedule_work(®_work); |
@@ -1586,18 +1443,18 @@ new_request: | |||
1586 | } | 1443 | } |
1587 | 1444 | ||
1588 | /* This processes *all* regulatory hints */ | 1445 | /* This processes *all* regulatory hints */ |
1589 | static void reg_process_hint(struct regulatory_request *reg_request, | 1446 | static void reg_process_hint(struct regulatory_request *reg_request) |
1590 | enum nl80211_reg_initiator reg_initiator) | ||
1591 | { | 1447 | { |
1592 | int r = 0; | 1448 | int r = 0; |
1593 | struct wiphy *wiphy = NULL; | 1449 | struct wiphy *wiphy = NULL; |
1450 | enum nl80211_reg_initiator initiator = reg_request->initiator; | ||
1594 | 1451 | ||
1595 | BUG_ON(!reg_request->alpha2); | 1452 | BUG_ON(!reg_request->alpha2); |
1596 | 1453 | ||
1597 | if (wiphy_idx_valid(reg_request->wiphy_idx)) | 1454 | if (wiphy_idx_valid(reg_request->wiphy_idx)) |
1598 | wiphy = wiphy_idx_to_wiphy(reg_request->wiphy_idx); | 1455 | wiphy = wiphy_idx_to_wiphy(reg_request->wiphy_idx); |
1599 | 1456 | ||
1600 | if (reg_initiator == NL80211_REGDOM_SET_BY_DRIVER && | 1457 | if (reg_request->initiator == NL80211_REGDOM_SET_BY_DRIVER && |
1601 | !wiphy) { | 1458 | !wiphy) { |
1602 | kfree(reg_request); | 1459 | kfree(reg_request); |
1603 | return; | 1460 | return; |
@@ -1607,7 +1464,7 @@ static void reg_process_hint(struct regulatory_request *reg_request, | |||
1607 | /* This is required so that the orig_* parameters are saved */ | 1464 | /* This is required so that the orig_* parameters are saved */ |
1608 | if (r == -EALREADY && wiphy && | 1465 | if (r == -EALREADY && wiphy && |
1609 | wiphy->flags & WIPHY_FLAG_STRICT_REGULATORY) { | 1466 | wiphy->flags & WIPHY_FLAG_STRICT_REGULATORY) { |
1610 | wiphy_update_regulatory(wiphy, reg_initiator); | 1467 | wiphy_update_regulatory(wiphy, initiator); |
1611 | return; | 1468 | return; |
1612 | } | 1469 | } |
1613 | 1470 | ||
@@ -1616,7 +1473,7 @@ static void reg_process_hint(struct regulatory_request *reg_request, | |||
1616 | * source of bogus requests. | 1473 | * source of bogus requests. |
1617 | */ | 1474 | */ |
1618 | if (r != -EALREADY && | 1475 | if (r != -EALREADY && |
1619 | reg_initiator == NL80211_REGDOM_SET_BY_USER) | 1476 | reg_request->initiator == NL80211_REGDOM_SET_BY_USER) |
1620 | schedule_delayed_work(®_timeout, msecs_to_jiffies(3142)); | 1477 | schedule_delayed_work(®_timeout, msecs_to_jiffies(3142)); |
1621 | } | 1478 | } |
1622 | 1479 | ||
@@ -1635,7 +1492,7 @@ static void reg_process_pending_hints(void) | |||
1635 | /* When last_request->processed becomes true this will be rescheduled */ | 1492 | /* When last_request->processed becomes true this will be rescheduled */ |
1636 | if (last_request && !last_request->processed) { | 1493 | if (last_request && !last_request->processed) { |
1637 | REG_DBG_PRINT("Pending regulatory request, waiting " | 1494 | REG_DBG_PRINT("Pending regulatory request, waiting " |
1638 | "for it to be processed...\n"); | 1495 | "for it to be processed..."); |
1639 | goto out; | 1496 | goto out; |
1640 | } | 1497 | } |
1641 | 1498 | ||
@@ -1653,7 +1510,7 @@ static void reg_process_pending_hints(void) | |||
1653 | 1510 | ||
1654 | spin_unlock(®_requests_lock); | 1511 | spin_unlock(®_requests_lock); |
1655 | 1512 | ||
1656 | reg_process_hint(reg_request, reg_request->initiator); | 1513 | reg_process_hint(reg_request); |
1657 | 1514 | ||
1658 | out: | 1515 | out: |
1659 | mutex_unlock(®_mutex); | 1516 | mutex_unlock(®_mutex); |
@@ -1741,8 +1598,7 @@ static int regulatory_hint_core(const char *alpha2) | |||
1741 | } | 1598 | } |
1742 | 1599 | ||
1743 | /* User hints */ | 1600 | /* User hints */ |
1744 | int regulatory_hint_user(const char *alpha2, | 1601 | int regulatory_hint_user(const char *alpha2) |
1745 | enum nl80211_user_reg_hint_type user_reg_hint_type) | ||
1746 | { | 1602 | { |
1747 | struct regulatory_request *request; | 1603 | struct regulatory_request *request; |
1748 | 1604 | ||
@@ -1756,7 +1612,6 @@ int regulatory_hint_user(const char *alpha2, | |||
1756 | request->alpha2[0] = alpha2[0]; | 1612 | request->alpha2[0] = alpha2[0]; |
1757 | request->alpha2[1] = alpha2[1]; | 1613 | request->alpha2[1] = alpha2[1]; |
1758 | request->initiator = NL80211_REGDOM_SET_BY_USER; | 1614 | request->initiator = NL80211_REGDOM_SET_BY_USER; |
1759 | request->user_reg_hint_type = user_reg_hint_type; | ||
1760 | 1615 | ||
1761 | queue_regulatory_request(request); | 1616 | queue_regulatory_request(request); |
1762 | 1617 | ||
@@ -1796,7 +1651,7 @@ EXPORT_SYMBOL(regulatory_hint); | |||
1796 | */ | 1651 | */ |
1797 | void regulatory_hint_11d(struct wiphy *wiphy, | 1652 | void regulatory_hint_11d(struct wiphy *wiphy, |
1798 | enum ieee80211_band band, | 1653 | enum ieee80211_band band, |
1799 | const u8 *country_ie, | 1654 | u8 *country_ie, |
1800 | u8 country_ie_len) | 1655 | u8 country_ie_len) |
1801 | { | 1656 | { |
1802 | char alpha2[2]; | 1657 | char alpha2[2]; |
@@ -1900,27 +1755,6 @@ static void restore_alpha2(char *alpha2, bool reset_user) | |||
1900 | REG_DBG_PRINT("Restoring regulatory settings\n"); | 1755 | REG_DBG_PRINT("Restoring regulatory settings\n"); |
1901 | } | 1756 | } |
1902 | 1757 | ||
1903 | static void restore_custom_reg_settings(struct wiphy *wiphy) | ||
1904 | { | ||
1905 | struct ieee80211_supported_band *sband; | ||
1906 | enum ieee80211_band band; | ||
1907 | struct ieee80211_channel *chan; | ||
1908 | int i; | ||
1909 | |||
1910 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) { | ||
1911 | sband = wiphy->bands[band]; | ||
1912 | if (!sband) | ||
1913 | continue; | ||
1914 | for (i = 0; i < sband->n_channels; i++) { | ||
1915 | chan = &sband->channels[i]; | ||
1916 | chan->flags = chan->orig_flags; | ||
1917 | chan->max_antenna_gain = chan->orig_mag; | ||
1918 | chan->max_power = chan->orig_mpwr; | ||
1919 | chan->beacon_found = false; | ||
1920 | } | ||
1921 | } | ||
1922 | } | ||
1923 | |||
1924 | /* | 1758 | /* |
1925 | * Restoring regulatory settings involves ingoring any | 1759 | * Restoring regulatory settings involves ingoring any |
1926 | * possibly stale country IE information and user regulatory | 1760 | * possibly stale country IE information and user regulatory |
@@ -1943,7 +1777,6 @@ static void restore_regulatory_settings(bool reset_user) | |||
1943 | struct reg_beacon *reg_beacon, *btmp; | 1777 | struct reg_beacon *reg_beacon, *btmp; |
1944 | struct regulatory_request *reg_request, *tmp; | 1778 | struct regulatory_request *reg_request, *tmp; |
1945 | LIST_HEAD(tmp_reg_req_list); | 1779 | LIST_HEAD(tmp_reg_req_list); |
1946 | struct cfg80211_registered_device *rdev; | ||
1947 | 1780 | ||
1948 | mutex_lock(&cfg80211_mutex); | 1781 | mutex_lock(&cfg80211_mutex); |
1949 | mutex_lock(®_mutex); | 1782 | mutex_lock(®_mutex); |
@@ -1964,7 +1797,8 @@ static void restore_regulatory_settings(bool reset_user) | |||
1964 | if (reg_request->initiator != | 1797 | if (reg_request->initiator != |
1965 | NL80211_REGDOM_SET_BY_USER) | 1798 | NL80211_REGDOM_SET_BY_USER) |
1966 | continue; | 1799 | continue; |
1967 | list_move_tail(®_request->list, &tmp_reg_req_list); | 1800 | list_del(®_request->list); |
1801 | list_add_tail(®_request->list, &tmp_reg_req_list); | ||
1968 | } | 1802 | } |
1969 | } | 1803 | } |
1970 | spin_unlock(®_requests_lock); | 1804 | spin_unlock(®_requests_lock); |
@@ -1993,11 +1827,6 @@ static void restore_regulatory_settings(bool reset_user) | |||
1993 | world_alpha2[0] = cfg80211_regdomain->alpha2[0]; | 1827 | world_alpha2[0] = cfg80211_regdomain->alpha2[0]; |
1994 | world_alpha2[1] = cfg80211_regdomain->alpha2[1]; | 1828 | world_alpha2[1] = cfg80211_regdomain->alpha2[1]; |
1995 | 1829 | ||
1996 | list_for_each_entry(rdev, &cfg80211_rdev_list, list) { | ||
1997 | if (rdev->wiphy.flags & WIPHY_FLAG_CUSTOM_REGULATORY) | ||
1998 | restore_custom_reg_settings(&rdev->wiphy); | ||
1999 | } | ||
2000 | |||
2001 | mutex_unlock(®_mutex); | 1830 | mutex_unlock(®_mutex); |
2002 | mutex_unlock(&cfg80211_mutex); | 1831 | mutex_unlock(&cfg80211_mutex); |
2003 | 1832 | ||
@@ -2009,7 +1838,7 @@ static void restore_regulatory_settings(bool reset_user) | |||
2009 | * settings, user regulatory settings takes precedence. | 1838 | * settings, user regulatory settings takes precedence. |
2010 | */ | 1839 | */ |
2011 | if (is_an_alpha2(alpha2)) | 1840 | if (is_an_alpha2(alpha2)) |
2012 | regulatory_hint_user(user_alpha2, NL80211_USER_REG_HINT_USER); | 1841 | regulatory_hint_user(user_alpha2); |
2013 | 1842 | ||
2014 | if (list_empty(&tmp_reg_req_list)) | 1843 | if (list_empty(&tmp_reg_req_list)) |
2015 | return; | 1844 | return; |
@@ -2023,7 +1852,8 @@ static void restore_regulatory_settings(bool reset_user) | |||
2023 | "into the queue\n", | 1852 | "into the queue\n", |
2024 | reg_request->alpha2[0], | 1853 | reg_request->alpha2[0], |
2025 | reg_request->alpha2[1]); | 1854 | reg_request->alpha2[1]); |
2026 | list_move_tail(®_request->list, ®_requests_list); | 1855 | list_del(®_request->list); |
1856 | list_add_tail(®_request->list, ®_requests_list); | ||
2027 | } | 1857 | } |
2028 | spin_unlock(®_requests_lock); | 1858 | spin_unlock(®_requests_lock); |
2029 | 1859 | ||
@@ -2097,7 +1927,7 @@ static void print_rd_rules(const struct ieee80211_regdomain *rd) | |||
2097 | const struct ieee80211_freq_range *freq_range = NULL; | 1927 | const struct ieee80211_freq_range *freq_range = NULL; |
2098 | const struct ieee80211_power_rule *power_rule = NULL; | 1928 | const struct ieee80211_power_rule *power_rule = NULL; |
2099 | 1929 | ||
2100 | pr_info(" (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)\n"); | 1930 | pr_info(" (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)\n"); |
2101 | 1931 | ||
2102 | for (i = 0; i < rd->n_reg_rules; i++) { | 1932 | for (i = 0; i < rd->n_reg_rules; i++) { |
2103 | reg_rule = &rd->reg_rules[i]; | 1933 | reg_rule = &rd->reg_rules[i]; |
@@ -2109,14 +1939,14 @@ static void print_rd_rules(const struct ieee80211_regdomain *rd) | |||
2109 | * in certain regions | 1939 | * in certain regions |
2110 | */ | 1940 | */ |
2111 | if (power_rule->max_antenna_gain) | 1941 | if (power_rule->max_antenna_gain) |
2112 | pr_info(" (%d KHz - %d KHz @ %d KHz), (%d mBi, %d mBm)\n", | 1942 | pr_info(" (%d KHz - %d KHz @ %d KHz), (%d mBi, %d mBm)\n", |
2113 | freq_range->start_freq_khz, | 1943 | freq_range->start_freq_khz, |
2114 | freq_range->end_freq_khz, | 1944 | freq_range->end_freq_khz, |
2115 | freq_range->max_bandwidth_khz, | 1945 | freq_range->max_bandwidth_khz, |
2116 | power_rule->max_antenna_gain, | 1946 | power_rule->max_antenna_gain, |
2117 | power_rule->max_eirp); | 1947 | power_rule->max_eirp); |
2118 | else | 1948 | else |
2119 | pr_info(" (%d KHz - %d KHz @ %d KHz), (N/A, %d mBm)\n", | 1949 | pr_info(" (%d KHz - %d KHz @ %d KHz), (N/A, %d mBm)\n", |
2120 | freq_range->start_freq_khz, | 1950 | freq_range->start_freq_khz, |
2121 | freq_range->end_freq_khz, | 1951 | freq_range->end_freq_khz, |
2122 | freq_range->max_bandwidth_khz, | 1952 | freq_range->max_bandwidth_khz, |
@@ -2124,42 +1954,6 @@ static void print_rd_rules(const struct ieee80211_regdomain *rd) | |||
2124 | } | 1954 | } |
2125 | } | 1955 | } |
2126 | 1956 | ||
2127 | bool reg_supported_dfs_region(u8 dfs_region) | ||
2128 | { | ||
2129 | switch (dfs_region) { | ||
2130 | case NL80211_DFS_UNSET: | ||
2131 | case NL80211_DFS_FCC: | ||
2132 | case NL80211_DFS_ETSI: | ||
2133 | case NL80211_DFS_JP: | ||
2134 | return true; | ||
2135 | default: | ||
2136 | REG_DBG_PRINT("Ignoring uknown DFS master region: %d\n", | ||
2137 | dfs_region); | ||
2138 | return false; | ||
2139 | } | ||
2140 | } | ||
2141 | |||
2142 | static void print_dfs_region(u8 dfs_region) | ||
2143 | { | ||
2144 | if (!dfs_region) | ||
2145 | return; | ||
2146 | |||
2147 | switch (dfs_region) { | ||
2148 | case NL80211_DFS_FCC: | ||
2149 | pr_info(" DFS Master region FCC"); | ||
2150 | break; | ||
2151 | case NL80211_DFS_ETSI: | ||
2152 | pr_info(" DFS Master region ETSI"); | ||
2153 | break; | ||
2154 | case NL80211_DFS_JP: | ||
2155 | pr_info(" DFS Master region JP"); | ||
2156 | break; | ||
2157 | default: | ||
2158 | pr_info(" DFS Master region Uknown"); | ||
2159 | break; | ||
2160 | } | ||
2161 | } | ||
2162 | |||
2163 | static void print_regdomain(const struct ieee80211_regdomain *rd) | 1957 | static void print_regdomain(const struct ieee80211_regdomain *rd) |
2164 | { | 1958 | { |
2165 | 1959 | ||
@@ -2183,18 +1977,10 @@ static void print_regdomain(const struct ieee80211_regdomain *rd) | |||
2183 | else { | 1977 | else { |
2184 | if (is_unknown_alpha2(rd->alpha2)) | 1978 | if (is_unknown_alpha2(rd->alpha2)) |
2185 | pr_info("Regulatory domain changed to driver built-in settings (unknown country)\n"); | 1979 | pr_info("Regulatory domain changed to driver built-in settings (unknown country)\n"); |
2186 | else { | 1980 | else |
2187 | if (reg_request_cell_base(last_request)) | 1981 | pr_info("Regulatory domain changed to country: %c%c\n", |
2188 | pr_info("Regulatory domain changed " | 1982 | rd->alpha2[0], rd->alpha2[1]); |
2189 | "to country: %c%c by Cell Station\n", | ||
2190 | rd->alpha2[0], rd->alpha2[1]); | ||
2191 | else | ||
2192 | pr_info("Regulatory domain changed " | ||
2193 | "to country: %c%c\n", | ||
2194 | rd->alpha2[0], rd->alpha2[1]); | ||
2195 | } | ||
2196 | } | 1983 | } |
2197 | print_dfs_region(rd->dfs_region); | ||
2198 | print_rd_rules(rd); | 1984 | print_rd_rules(rd); |
2199 | } | 1985 | } |
2200 | 1986 | ||
@@ -2208,6 +1994,7 @@ static void print_regdomain_info(const struct ieee80211_regdomain *rd) | |||
2208 | static int __set_regdom(const struct ieee80211_regdomain *rd) | 1994 | static int __set_regdom(const struct ieee80211_regdomain *rd) |
2209 | { | 1995 | { |
2210 | const struct ieee80211_regdomain *intersected_rd = NULL; | 1996 | const struct ieee80211_regdomain *intersected_rd = NULL; |
1997 | struct cfg80211_registered_device *rdev = NULL; | ||
2211 | struct wiphy *request_wiphy; | 1998 | struct wiphy *request_wiphy; |
2212 | /* Some basic sanity checks first */ | 1999 | /* Some basic sanity checks first */ |
2213 | 2000 | ||
@@ -2236,7 +2023,7 @@ static int __set_regdom(const struct ieee80211_regdomain *rd) | |||
2236 | * checking if the alpha2 changes if CRDA was already called | 2023 | * checking if the alpha2 changes if CRDA was already called |
2237 | */ | 2024 | */ |
2238 | if (!regdom_changes(rd->alpha2)) | 2025 | if (!regdom_changes(rd->alpha2)) |
2239 | return -EALREADY; | 2026 | return -EINVAL; |
2240 | } | 2027 | } |
2241 | 2028 | ||
2242 | /* | 2029 | /* |
@@ -2319,7 +2106,24 @@ static int __set_regdom(const struct ieee80211_regdomain *rd) | |||
2319 | return 0; | 2106 | return 0; |
2320 | } | 2107 | } |
2321 | 2108 | ||
2322 | return -EINVAL; | 2109 | if (!intersected_rd) |
2110 | return -EINVAL; | ||
2111 | |||
2112 | rdev = wiphy_to_dev(request_wiphy); | ||
2113 | |||
2114 | rdev->country_ie_alpha2[0] = rd->alpha2[0]; | ||
2115 | rdev->country_ie_alpha2[1] = rd->alpha2[1]; | ||
2116 | rdev->env = last_request->country_ie_env; | ||
2117 | |||
2118 | BUG_ON(intersected_rd == rd); | ||
2119 | |||
2120 | kfree(rd); | ||
2121 | rd = NULL; | ||
2122 | |||
2123 | reset_regdomains(false); | ||
2124 | cfg80211_regdomain = intersected_rd; | ||
2125 | |||
2126 | return 0; | ||
2323 | } | 2127 | } |
2324 | 2128 | ||
2325 | 2129 | ||
@@ -2339,9 +2143,6 @@ int set_regdom(const struct ieee80211_regdomain *rd) | |||
2339 | /* Note that this doesn't update the wiphys, this is done below */ | 2143 | /* Note that this doesn't update the wiphys, this is done below */ |
2340 | r = __set_regdom(rd); | 2144 | r = __set_regdom(rd); |
2341 | if (r) { | 2145 | if (r) { |
2342 | if (r == -EALREADY) | ||
2343 | reg_set_request_processed(); | ||
2344 | |||
2345 | kfree(rd); | 2146 | kfree(rd); |
2346 | mutex_unlock(®_mutex); | 2147 | mutex_unlock(®_mutex); |
2347 | return r; | 2148 | return r; |
@@ -2365,6 +2166,7 @@ int set_regdom(const struct ieee80211_regdomain *rd) | |||
2365 | return r; | 2166 | return r; |
2366 | } | 2167 | } |
2367 | 2168 | ||
2169 | #ifdef CONFIG_HOTPLUG | ||
2368 | int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env) | 2170 | int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env) |
2369 | { | 2171 | { |
2370 | if (last_request && !last_request->processed) { | 2172 | if (last_request && !last_request->processed) { |
@@ -2376,23 +2178,15 @@ int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
2376 | 2178 | ||
2377 | return 0; | 2179 | return 0; |
2378 | } | 2180 | } |
2379 | 2181 | #else | |
2380 | void wiphy_regulatory_register(struct wiphy *wiphy) | 2182 | int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env) |
2381 | { | 2183 | { |
2382 | assert_cfg80211_lock(); | 2184 | return -ENODEV; |
2383 | |||
2384 | mutex_lock(®_mutex); | ||
2385 | |||
2386 | if (!reg_dev_ignore_cell_hint(wiphy)) | ||
2387 | reg_num_devs_support_basehint++; | ||
2388 | |||
2389 | wiphy_update_regulatory(wiphy, NL80211_REGDOM_SET_BY_CORE); | ||
2390 | |||
2391 | mutex_unlock(®_mutex); | ||
2392 | } | 2185 | } |
2186 | #endif /* CONFIG_HOTPLUG */ | ||
2393 | 2187 | ||
2394 | /* Caller must hold cfg80211_mutex */ | 2188 | /* Caller must hold cfg80211_mutex */ |
2395 | void wiphy_regulatory_deregister(struct wiphy *wiphy) | 2189 | void reg_device_remove(struct wiphy *wiphy) |
2396 | { | 2190 | { |
2397 | struct wiphy *request_wiphy = NULL; | 2191 | struct wiphy *request_wiphy = NULL; |
2398 | 2192 | ||
@@ -2400,9 +2194,6 @@ void wiphy_regulatory_deregister(struct wiphy *wiphy) | |||
2400 | 2194 | ||
2401 | mutex_lock(®_mutex); | 2195 | mutex_lock(®_mutex); |
2402 | 2196 | ||
2403 | if (!reg_dev_ignore_cell_hint(wiphy)) | ||
2404 | reg_num_devs_support_basehint--; | ||
2405 | |||
2406 | kfree(wiphy->regd); | 2197 | kfree(wiphy->regd); |
2407 | 2198 | ||
2408 | if (last_request) | 2199 | if (last_request) |
@@ -2420,7 +2211,7 @@ out: | |||
2420 | static void reg_timeout_work(struct work_struct *work) | 2211 | static void reg_timeout_work(struct work_struct *work) |
2421 | { | 2212 | { |
2422 | REG_DBG_PRINT("Timeout while waiting for CRDA to reply, " | 2213 | REG_DBG_PRINT("Timeout while waiting for CRDA to reply, " |
2423 | "restoring regulatory settings\n"); | 2214 | "restoring regulatory settings"); |
2424 | restore_regulatory_settings(true); | 2215 | restore_regulatory_settings(true); |
2425 | } | 2216 | } |
2426 | 2217 | ||
@@ -2437,8 +2228,6 @@ int __init regulatory_init(void) | |||
2437 | spin_lock_init(®_requests_lock); | 2228 | spin_lock_init(®_requests_lock); |
2438 | spin_lock_init(®_pending_beacons_lock); | 2229 | spin_lock_init(®_pending_beacons_lock); |
2439 | 2230 | ||
2440 | reg_regdb_size_check(); | ||
2441 | |||
2442 | cfg80211_regdomain = cfg80211_world_regdom; | 2231 | cfg80211_regdomain = cfg80211_world_regdom; |
2443 | 2232 | ||
2444 | user_alpha2[0] = '9'; | 2233 | user_alpha2[0] = '9'; |
@@ -2468,8 +2257,7 @@ int __init regulatory_init(void) | |||
2468 | * as a user hint. | 2257 | * as a user hint. |
2469 | */ | 2258 | */ |
2470 | if (!is_world_regdom(ieee80211_regdom)) | 2259 | if (!is_world_regdom(ieee80211_regdom)) |
2471 | regulatory_hint_user(ieee80211_regdom, | 2260 | regulatory_hint_user(ieee80211_regdom); |
2472 | NL80211_USER_REG_HINT_USER); | ||
2473 | 2261 | ||
2474 | return 0; | 2262 | return 0; |
2475 | } | 2263 | } |
diff --git a/net/wireless/reg.h b/net/wireless/reg.h index 4c0a32ffd53..b67d1c3a2fb 100644 --- a/net/wireless/reg.h +++ b/net/wireless/reg.h | |||
@@ -1,41 +1,21 @@ | |||
1 | #ifndef __NET_WIRELESS_REG_H | 1 | #ifndef __NET_WIRELESS_REG_H |
2 | #define __NET_WIRELESS_REG_H | 2 | #define __NET_WIRELESS_REG_H |
3 | /* | ||
4 | * Copyright 2008-2011 Luis R. Rodriguez <mcgrof@qca.qualcomm.com> | ||
5 | * | ||
6 | * Permission to use, copy, modify, and/or distribute this software for any | ||
7 | * purpose with or without fee is hereby granted, provided that the above | ||
8 | * copyright notice and this permission notice appear in all copies. | ||
9 | * | ||
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
17 | */ | ||
18 | 3 | ||
19 | extern const struct ieee80211_regdomain *cfg80211_regdomain; | 4 | extern const struct ieee80211_regdomain *cfg80211_regdomain; |
20 | 5 | ||
21 | bool is_world_regdom(const char *alpha2); | 6 | bool is_world_regdom(const char *alpha2); |
22 | bool reg_is_valid_request(const char *alpha2); | 7 | bool reg_is_valid_request(const char *alpha2); |
23 | bool reg_supported_dfs_region(u8 dfs_region); | ||
24 | 8 | ||
25 | int regulatory_hint_user(const char *alpha2, | 9 | int regulatory_hint_user(const char *alpha2); |
26 | enum nl80211_user_reg_hint_type user_reg_hint_type); | ||
27 | 10 | ||
28 | int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env); | 11 | int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env); |
29 | void wiphy_regulatory_register(struct wiphy *wiphy); | 12 | void reg_device_remove(struct wiphy *wiphy); |
30 | void wiphy_regulatory_deregister(struct wiphy *wiphy); | ||
31 | 13 | ||
32 | int __init regulatory_init(void); | 14 | int __init regulatory_init(void); |
33 | void regulatory_exit(void); | 15 | void regulatory_exit(void); |
34 | 16 | ||
35 | int set_regdom(const struct ieee80211_regdomain *rd); | 17 | int set_regdom(const struct ieee80211_regdomain *rd); |
36 | 18 | ||
37 | bool reg_last_request_cell_base(void); | ||
38 | |||
39 | /** | 19 | /** |
40 | * regulatory_hint_found_beacon - hints a beacon was found on a channel | 20 | * regulatory_hint_found_beacon - hints a beacon was found on a channel |
41 | * @wiphy: the wireless device where the beacon was found on | 21 | * @wiphy: the wireless device where the beacon was found on |
@@ -81,7 +61,7 @@ int regulatory_hint_found_beacon(struct wiphy *wiphy, | |||
81 | */ | 61 | */ |
82 | void regulatory_hint_11d(struct wiphy *wiphy, | 62 | void regulatory_hint_11d(struct wiphy *wiphy, |
83 | enum ieee80211_band band, | 63 | enum ieee80211_band band, |
84 | const u8 *country_ie, | 64 | u8 *country_ie, |
85 | u8 country_ie_len); | 65 | u8 country_ie_len); |
86 | 66 | ||
87 | /** | 67 | /** |
diff --git a/net/wireless/regdb.h b/net/wireless/regdb.h index 3279cfcefb0..818222c9251 100644 --- a/net/wireless/regdb.h +++ b/net/wireless/regdb.h | |||
@@ -1,22 +1,6 @@ | |||
1 | #ifndef __REGDB_H__ | 1 | #ifndef __REGDB_H__ |
2 | #define __REGDB_H__ | 2 | #define __REGDB_H__ |
3 | 3 | ||
4 | /* | ||
5 | * Copyright 2009 John W. Linville <linville@tuxdriver.com> | ||
6 | * | ||
7 | * Permission to use, copy, modify, and/or distribute this software for any | ||
8 | * purpose with or without fee is hereby granted, provided that the above | ||
9 | * copyright notice and this permission notice appear in all copies. | ||
10 | * | ||
11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
18 | */ | ||
19 | |||
20 | extern const struct ieee80211_regdomain *reg_regdb[]; | 4 | extern const struct ieee80211_regdomain *reg_regdb[]; |
21 | extern int reg_regdb_size; | 5 | extern int reg_regdb_size; |
22 | 6 | ||
diff --git a/net/wireless/scan.c b/net/wireless/scan.c index 01592d7d478..1c100d331e1 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c | |||
@@ -12,72 +12,17 @@ | |||
12 | #include <linux/etherdevice.h> | 12 | #include <linux/etherdevice.h> |
13 | #include <net/arp.h> | 13 | #include <net/arp.h> |
14 | #include <net/cfg80211.h> | 14 | #include <net/cfg80211.h> |
15 | #include <net/cfg80211-wext.h> | ||
16 | #include <net/iw_handler.h> | 15 | #include <net/iw_handler.h> |
17 | #include "core.h" | 16 | #include "core.h" |
18 | #include "nl80211.h" | 17 | #include "nl80211.h" |
19 | #include "wext-compat.h" | 18 | #include "wext-compat.h" |
20 | #include "rdev-ops.h" | ||
21 | 19 | ||
22 | #define IEEE80211_SCAN_RESULT_EXPIRE (30 * HZ) | 20 | #define IEEE80211_SCAN_RESULT_EXPIRE (3 * HZ) |
23 | |||
24 | static void bss_release(struct kref *ref) | ||
25 | { | ||
26 | struct cfg80211_bss_ies *ies; | ||
27 | struct cfg80211_internal_bss *bss; | ||
28 | |||
29 | bss = container_of(ref, struct cfg80211_internal_bss, ref); | ||
30 | |||
31 | if (WARN_ON(atomic_read(&bss->hold))) | ||
32 | return; | ||
33 | |||
34 | if (bss->pub.free_priv) | ||
35 | bss->pub.free_priv(&bss->pub); | ||
36 | |||
37 | ies = (void *)rcu_access_pointer(bss->pub.beacon_ies); | ||
38 | if (ies) | ||
39 | kfree_rcu(ies, rcu_head); | ||
40 | ies = (void *)rcu_access_pointer(bss->pub.proberesp_ies); | ||
41 | if (ies) | ||
42 | kfree_rcu(ies, rcu_head); | ||
43 | |||
44 | kfree(bss); | ||
45 | } | ||
46 | |||
47 | /* must hold dev->bss_lock! */ | ||
48 | static void __cfg80211_unlink_bss(struct cfg80211_registered_device *dev, | ||
49 | struct cfg80211_internal_bss *bss) | ||
50 | { | ||
51 | list_del_init(&bss->list); | ||
52 | rb_erase(&bss->rbn, &dev->bss_tree); | ||
53 | kref_put(&bss->ref, bss_release); | ||
54 | } | ||
55 | |||
56 | /* must hold dev->bss_lock! */ | ||
57 | static void __cfg80211_bss_expire(struct cfg80211_registered_device *dev, | ||
58 | unsigned long expire_time) | ||
59 | { | ||
60 | struct cfg80211_internal_bss *bss, *tmp; | ||
61 | bool expired = false; | ||
62 | |||
63 | list_for_each_entry_safe(bss, tmp, &dev->bss_list, list) { | ||
64 | if (atomic_read(&bss->hold)) | ||
65 | continue; | ||
66 | if (!time_after(expire_time, bss->ts)) | ||
67 | continue; | ||
68 | |||
69 | __cfg80211_unlink_bss(dev, bss); | ||
70 | expired = true; | ||
71 | } | ||
72 | |||
73 | if (expired) | ||
74 | dev->bss_generation++; | ||
75 | } | ||
76 | 21 | ||
77 | void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak) | 22 | void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak) |
78 | { | 23 | { |
79 | struct cfg80211_scan_request *request; | 24 | struct cfg80211_scan_request *request; |
80 | struct wireless_dev *wdev; | 25 | struct net_device *dev; |
81 | #ifdef CONFIG_CFG80211_WEXT | 26 | #ifdef CONFIG_CFG80211_WEXT |
82 | union iwreq_data wrqu; | 27 | union iwreq_data wrqu; |
83 | #endif | 28 | #endif |
@@ -89,38 +34,29 @@ void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak) | |||
89 | if (!request) | 34 | if (!request) |
90 | return; | 35 | return; |
91 | 36 | ||
92 | wdev = request->wdev; | 37 | dev = request->dev; |
93 | 38 | ||
94 | /* | 39 | /* |
95 | * This must be before sending the other events! | 40 | * This must be before sending the other events! |
96 | * Otherwise, wpa_supplicant gets completely confused with | 41 | * Otherwise, wpa_supplicant gets completely confused with |
97 | * wext events. | 42 | * wext events. |
98 | */ | 43 | */ |
99 | if (wdev->netdev) | 44 | cfg80211_sme_scan_done(dev); |
100 | cfg80211_sme_scan_done(wdev->netdev); | ||
101 | 45 | ||
102 | if (request->aborted) { | 46 | if (request->aborted) |
103 | nl80211_send_scan_aborted(rdev, wdev); | 47 | nl80211_send_scan_aborted(rdev, dev); |
104 | } else { | 48 | else |
105 | if (request->flags & NL80211_SCAN_FLAG_FLUSH) { | 49 | nl80211_send_scan_done(rdev, dev); |
106 | /* flush entries from previous scans */ | ||
107 | spin_lock_bh(&rdev->bss_lock); | ||
108 | __cfg80211_bss_expire(rdev, request->scan_start); | ||
109 | spin_unlock_bh(&rdev->bss_lock); | ||
110 | } | ||
111 | nl80211_send_scan_done(rdev, wdev); | ||
112 | } | ||
113 | 50 | ||
114 | #ifdef CONFIG_CFG80211_WEXT | 51 | #ifdef CONFIG_CFG80211_WEXT |
115 | if (wdev->netdev && !request->aborted) { | 52 | if (!request->aborted) { |
116 | memset(&wrqu, 0, sizeof(wrqu)); | 53 | memset(&wrqu, 0, sizeof(wrqu)); |
117 | 54 | ||
118 | wireless_send_event(wdev->netdev, SIOCGIWSCAN, &wrqu, NULL); | 55 | wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL); |
119 | } | 56 | } |
120 | #endif | 57 | #endif |
121 | 58 | ||
122 | if (wdev->netdev) | 59 | dev_put(dev); |
123 | dev_put(wdev->netdev); | ||
124 | 60 | ||
125 | rdev->scan_req = NULL; | 61 | rdev->scan_req = NULL; |
126 | 62 | ||
@@ -150,7 +86,6 @@ void __cfg80211_scan_done(struct work_struct *wk) | |||
150 | 86 | ||
151 | void cfg80211_scan_done(struct cfg80211_scan_request *request, bool aborted) | 87 | void cfg80211_scan_done(struct cfg80211_scan_request *request, bool aborted) |
152 | { | 88 | { |
153 | trace_cfg80211_scan_done(request, aborted); | ||
154 | WARN_ON(request != wiphy_to_dev(request->wiphy)->scan_req); | 89 | WARN_ON(request != wiphy_to_dev(request->wiphy)->scan_req); |
155 | 90 | ||
156 | request->aborted = aborted; | 91 | request->aborted = aborted; |
@@ -161,34 +96,22 @@ EXPORT_SYMBOL(cfg80211_scan_done); | |||
161 | void __cfg80211_sched_scan_results(struct work_struct *wk) | 96 | void __cfg80211_sched_scan_results(struct work_struct *wk) |
162 | { | 97 | { |
163 | struct cfg80211_registered_device *rdev; | 98 | struct cfg80211_registered_device *rdev; |
164 | struct cfg80211_sched_scan_request *request; | ||
165 | 99 | ||
166 | rdev = container_of(wk, struct cfg80211_registered_device, | 100 | rdev = container_of(wk, struct cfg80211_registered_device, |
167 | sched_scan_results_wk); | 101 | sched_scan_results_wk); |
168 | 102 | ||
169 | request = rdev->sched_scan_req; | ||
170 | |||
171 | mutex_lock(&rdev->sched_scan_mtx); | 103 | mutex_lock(&rdev->sched_scan_mtx); |
172 | 104 | ||
173 | /* we don't have sched_scan_req anymore if the scan is stopping */ | 105 | /* we don't have sched_scan_req anymore if the scan is stopping */ |
174 | if (request) { | 106 | if (rdev->sched_scan_req) |
175 | if (request->flags & NL80211_SCAN_FLAG_FLUSH) { | 107 | nl80211_send_sched_scan_results(rdev, |
176 | /* flush entries from previous scans */ | 108 | rdev->sched_scan_req->dev); |
177 | spin_lock_bh(&rdev->bss_lock); | ||
178 | __cfg80211_bss_expire(rdev, request->scan_start); | ||
179 | spin_unlock_bh(&rdev->bss_lock); | ||
180 | request->scan_start = | ||
181 | jiffies + msecs_to_jiffies(request->interval); | ||
182 | } | ||
183 | nl80211_send_sched_scan_results(rdev, request->dev); | ||
184 | } | ||
185 | 109 | ||
186 | mutex_unlock(&rdev->sched_scan_mtx); | 110 | mutex_unlock(&rdev->sched_scan_mtx); |
187 | } | 111 | } |
188 | 112 | ||
189 | void cfg80211_sched_scan_results(struct wiphy *wiphy) | 113 | void cfg80211_sched_scan_results(struct wiphy *wiphy) |
190 | { | 114 | { |
191 | trace_cfg80211_sched_scan_results(wiphy); | ||
192 | /* ignore if we're not scanning */ | 115 | /* ignore if we're not scanning */ |
193 | if (wiphy_to_dev(wiphy)->sched_scan_req) | 116 | if (wiphy_to_dev(wiphy)->sched_scan_req) |
194 | queue_work(cfg80211_wq, | 117 | queue_work(cfg80211_wq, |
@@ -200,8 +123,6 @@ void cfg80211_sched_scan_stopped(struct wiphy *wiphy) | |||
200 | { | 123 | { |
201 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 124 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
202 | 125 | ||
203 | trace_cfg80211_sched_scan_stopped(wiphy); | ||
204 | |||
205 | mutex_lock(&rdev->sched_scan_mtx); | 126 | mutex_lock(&rdev->sched_scan_mtx); |
206 | __cfg80211_stop_sched_scan(rdev, true); | 127 | __cfg80211_stop_sched_scan(rdev, true); |
207 | mutex_unlock(&rdev->sched_scan_mtx); | 128 | mutex_unlock(&rdev->sched_scan_mtx); |
@@ -221,7 +142,7 @@ int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev, | |||
221 | dev = rdev->sched_scan_req->dev; | 142 | dev = rdev->sched_scan_req->dev; |
222 | 143 | ||
223 | if (!driver_initiated) { | 144 | if (!driver_initiated) { |
224 | int err = rdev_sched_scan_stop(rdev, dev); | 145 | int err = rdev->ops->sched_scan_stop(&rdev->wiphy, dev); |
225 | if (err) | 146 | if (err) |
226 | return err; | 147 | return err; |
227 | } | 148 | } |
@@ -234,6 +155,24 @@ int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev, | |||
234 | return 0; | 155 | return 0; |
235 | } | 156 | } |
236 | 157 | ||
158 | static void bss_release(struct kref *ref) | ||
159 | { | ||
160 | struct cfg80211_internal_bss *bss; | ||
161 | |||
162 | bss = container_of(ref, struct cfg80211_internal_bss, ref); | ||
163 | if (bss->pub.free_priv) | ||
164 | bss->pub.free_priv(&bss->pub); | ||
165 | |||
166 | if (bss->beacon_ies_allocated) | ||
167 | kfree(bss->pub.beacon_ies); | ||
168 | if (bss->proberesp_ies_allocated) | ||
169 | kfree(bss->pub.proberesp_ies); | ||
170 | |||
171 | BUG_ON(atomic_read(&bss->hold)); | ||
172 | |||
173 | kfree(bss); | ||
174 | } | ||
175 | |||
237 | /* must hold dev->bss_lock! */ | 176 | /* must hold dev->bss_lock! */ |
238 | void cfg80211_bss_age(struct cfg80211_registered_device *dev, | 177 | void cfg80211_bss_age(struct cfg80211_registered_device *dev, |
239 | unsigned long age_secs) | 178 | unsigned long age_secs) |
@@ -241,13 +180,37 @@ void cfg80211_bss_age(struct cfg80211_registered_device *dev, | |||
241 | struct cfg80211_internal_bss *bss; | 180 | struct cfg80211_internal_bss *bss; |
242 | unsigned long age_jiffies = msecs_to_jiffies(age_secs * MSEC_PER_SEC); | 181 | unsigned long age_jiffies = msecs_to_jiffies(age_secs * MSEC_PER_SEC); |
243 | 182 | ||
244 | list_for_each_entry(bss, &dev->bss_list, list) | 183 | list_for_each_entry(bss, &dev->bss_list, list) { |
245 | bss->ts -= age_jiffies; | 184 | bss->ts -= age_jiffies; |
185 | } | ||
246 | } | 186 | } |
247 | 187 | ||
188 | /* must hold dev->bss_lock! */ | ||
189 | static void __cfg80211_unlink_bss(struct cfg80211_registered_device *dev, | ||
190 | struct cfg80211_internal_bss *bss) | ||
191 | { | ||
192 | list_del_init(&bss->list); | ||
193 | rb_erase(&bss->rbn, &dev->bss_tree); | ||
194 | kref_put(&bss->ref, bss_release); | ||
195 | } | ||
196 | |||
197 | /* must hold dev->bss_lock! */ | ||
248 | void cfg80211_bss_expire(struct cfg80211_registered_device *dev) | 198 | void cfg80211_bss_expire(struct cfg80211_registered_device *dev) |
249 | { | 199 | { |
250 | __cfg80211_bss_expire(dev, jiffies - IEEE80211_SCAN_RESULT_EXPIRE); | 200 | struct cfg80211_internal_bss *bss, *tmp; |
201 | bool expired = false; | ||
202 | |||
203 | list_for_each_entry_safe(bss, tmp, &dev->bss_list, list) { | ||
204 | if (atomic_read(&bss->hold)) | ||
205 | continue; | ||
206 | if (!time_after(jiffies, bss->ts + IEEE80211_SCAN_RESULT_EXPIRE)) | ||
207 | continue; | ||
208 | __cfg80211_unlink_bss(dev, bss); | ||
209 | expired = true; | ||
210 | } | ||
211 | |||
212 | if (expired) | ||
213 | dev->bss_generation++; | ||
251 | } | 214 | } |
252 | 215 | ||
253 | const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len) | 216 | const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len) |
@@ -264,69 +227,38 @@ const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len) | |||
264 | } | 227 | } |
265 | EXPORT_SYMBOL(cfg80211_find_ie); | 228 | EXPORT_SYMBOL(cfg80211_find_ie); |
266 | 229 | ||
267 | const u8 *cfg80211_find_vendor_ie(unsigned int oui, u8 oui_type, | 230 | static int cmp_ies(u8 num, u8 *ies1, size_t len1, u8 *ies2, size_t len2) |
268 | const u8 *ies, int len) | ||
269 | { | ||
270 | struct ieee80211_vendor_ie *ie; | ||
271 | const u8 *pos = ies, *end = ies + len; | ||
272 | int ie_oui; | ||
273 | |||
274 | while (pos < end) { | ||
275 | pos = cfg80211_find_ie(WLAN_EID_VENDOR_SPECIFIC, pos, | ||
276 | end - pos); | ||
277 | if (!pos) | ||
278 | return NULL; | ||
279 | |||
280 | if (end - pos < sizeof(*ie)) | ||
281 | return NULL; | ||
282 | |||
283 | ie = (struct ieee80211_vendor_ie *)pos; | ||
284 | ie_oui = ie->oui[0] << 16 | ie->oui[1] << 8 | ie->oui[2]; | ||
285 | if (ie_oui == oui && ie->oui_type == oui_type) | ||
286 | return pos; | ||
287 | |||
288 | pos += 2 + ie->len; | ||
289 | } | ||
290 | return NULL; | ||
291 | } | ||
292 | EXPORT_SYMBOL(cfg80211_find_vendor_ie); | ||
293 | |||
294 | static int cmp_ies(u8 num, const u8 *ies1, int len1, const u8 *ies2, int len2) | ||
295 | { | 231 | { |
296 | const u8 *ie1 = cfg80211_find_ie(num, ies1, len1); | 232 | const u8 *ie1 = cfg80211_find_ie(num, ies1, len1); |
297 | const u8 *ie2 = cfg80211_find_ie(num, ies2, len2); | 233 | const u8 *ie2 = cfg80211_find_ie(num, ies2, len2); |
234 | int r; | ||
298 | 235 | ||
299 | /* equal if both missing */ | ||
300 | if (!ie1 && !ie2) | 236 | if (!ie1 && !ie2) |
301 | return 0; | 237 | return 0; |
302 | /* sort missing IE before (left of) present IE */ | 238 | if (!ie1 || !ie2) |
303 | if (!ie1) | ||
304 | return -1; | 239 | return -1; |
305 | if (!ie2) | ||
306 | return 1; | ||
307 | 240 | ||
308 | /* sort by length first, then by contents */ | 241 | r = memcmp(ie1 + 2, ie2 + 2, min(ie1[1], ie2[1])); |
309 | if (ie1[1] != ie2[1]) | 242 | if (r == 0 && ie1[1] != ie2[1]) |
310 | return ie2[1] - ie1[1]; | 243 | return ie2[1] - ie1[1]; |
311 | return memcmp(ie1 + 2, ie2 + 2, ie1[1]); | 244 | return r; |
312 | } | 245 | } |
313 | 246 | ||
314 | static bool is_bss(struct cfg80211_bss *a, const u8 *bssid, | 247 | static bool is_bss(struct cfg80211_bss *a, |
248 | const u8 *bssid, | ||
315 | const u8 *ssid, size_t ssid_len) | 249 | const u8 *ssid, size_t ssid_len) |
316 | { | 250 | { |
317 | const struct cfg80211_bss_ies *ies; | ||
318 | const u8 *ssidie; | 251 | const u8 *ssidie; |
319 | 252 | ||
320 | if (bssid && !ether_addr_equal(a->bssid, bssid)) | 253 | if (bssid && compare_ether_addr(a->bssid, bssid)) |
321 | return false; | 254 | return false; |
322 | 255 | ||
323 | if (!ssid) | 256 | if (!ssid) |
324 | return true; | 257 | return true; |
325 | 258 | ||
326 | ies = rcu_access_pointer(a->ies); | 259 | ssidie = cfg80211_find_ie(WLAN_EID_SSID, |
327 | if (!ies) | 260 | a->information_elements, |
328 | return false; | 261 | a->len_information_elements); |
329 | ssidie = cfg80211_find_ie(WLAN_EID_SSID, ies->data, ies->len); | ||
330 | if (!ssidie) | 262 | if (!ssidie) |
331 | return false; | 263 | return false; |
332 | if (ssidie[1] != ssid_len) | 264 | if (ssidie[1] != ssid_len) |
@@ -336,21 +268,20 @@ static bool is_bss(struct cfg80211_bss *a, const u8 *bssid, | |||
336 | 268 | ||
337 | static bool is_mesh_bss(struct cfg80211_bss *a) | 269 | static bool is_mesh_bss(struct cfg80211_bss *a) |
338 | { | 270 | { |
339 | const struct cfg80211_bss_ies *ies; | ||
340 | const u8 *ie; | 271 | const u8 *ie; |
341 | 272 | ||
342 | if (!WLAN_CAPABILITY_IS_STA_BSS(a->capability)) | 273 | if (!WLAN_CAPABILITY_IS_STA_BSS(a->capability)) |
343 | return false; | 274 | return false; |
344 | 275 | ||
345 | ies = rcu_access_pointer(a->ies); | 276 | ie = cfg80211_find_ie(WLAN_EID_MESH_ID, |
346 | if (!ies) | 277 | a->information_elements, |
347 | return false; | 278 | a->len_information_elements); |
348 | |||
349 | ie = cfg80211_find_ie(WLAN_EID_MESH_ID, ies->data, ies->len); | ||
350 | if (!ie) | 279 | if (!ie) |
351 | return false; | 280 | return false; |
352 | 281 | ||
353 | ie = cfg80211_find_ie(WLAN_EID_MESH_CONFIG, ies->data, ies->len); | 282 | ie = cfg80211_find_ie(WLAN_EID_MESH_CONFIG, |
283 | a->information_elements, | ||
284 | a->len_information_elements); | ||
354 | if (!ie) | 285 | if (!ie) |
355 | return false; | 286 | return false; |
356 | 287 | ||
@@ -361,17 +292,14 @@ static bool is_mesh(struct cfg80211_bss *a, | |||
361 | const u8 *meshid, size_t meshidlen, | 292 | const u8 *meshid, size_t meshidlen, |
362 | const u8 *meshcfg) | 293 | const u8 *meshcfg) |
363 | { | 294 | { |
364 | const struct cfg80211_bss_ies *ies; | ||
365 | const u8 *ie; | 295 | const u8 *ie; |
366 | 296 | ||
367 | if (!WLAN_CAPABILITY_IS_STA_BSS(a->capability)) | 297 | if (!WLAN_CAPABILITY_IS_STA_BSS(a->capability)) |
368 | return false; | 298 | return false; |
369 | 299 | ||
370 | ies = rcu_access_pointer(a->ies); | 300 | ie = cfg80211_find_ie(WLAN_EID_MESH_ID, |
371 | if (!ies) | 301 | a->information_elements, |
372 | return false; | 302 | a->len_information_elements); |
373 | |||
374 | ie = cfg80211_find_ie(WLAN_EID_MESH_ID, ies->data, ies->len); | ||
375 | if (!ie) | 303 | if (!ie) |
376 | return false; | 304 | return false; |
377 | if (ie[1] != meshidlen) | 305 | if (ie[1] != meshidlen) |
@@ -379,7 +307,9 @@ static bool is_mesh(struct cfg80211_bss *a, | |||
379 | if (memcmp(ie + 2, meshid, meshidlen)) | 307 | if (memcmp(ie + 2, meshid, meshidlen)) |
380 | return false; | 308 | return false; |
381 | 309 | ||
382 | ie = cfg80211_find_ie(WLAN_EID_MESH_CONFIG, ies->data, ies->len); | 310 | ie = cfg80211_find_ie(WLAN_EID_MESH_CONFIG, |
311 | a->information_elements, | ||
312 | a->len_information_elements); | ||
383 | if (!ie) | 313 | if (!ie) |
384 | return false; | 314 | return false; |
385 | if (ie[1] != sizeof(struct ieee80211_meshconf_ie)) | 315 | if (ie[1] != sizeof(struct ieee80211_meshconf_ie)) |
@@ -391,121 +321,41 @@ static bool is_mesh(struct cfg80211_bss *a, | |||
391 | * part in the same mesh. | 321 | * part in the same mesh. |
392 | */ | 322 | */ |
393 | return memcmp(ie + 2, meshcfg, | 323 | return memcmp(ie + 2, meshcfg, |
394 | sizeof(struct ieee80211_meshconf_ie) - 2) == 0; | 324 | sizeof(struct ieee80211_meshconf_ie) - 2) == 0; |
395 | } | 325 | } |
396 | 326 | ||
397 | static int cmp_bss_core(struct cfg80211_bss *a, struct cfg80211_bss *b) | 327 | static int cmp_bss(struct cfg80211_bss *a, |
328 | struct cfg80211_bss *b) | ||
398 | { | 329 | { |
399 | const struct cfg80211_bss_ies *a_ies, *b_ies; | ||
400 | int r; | 330 | int r; |
401 | 331 | ||
402 | if (a->channel != b->channel) | 332 | if (a->channel != b->channel) |
403 | return b->channel->center_freq - a->channel->center_freq; | 333 | return b->channel->center_freq - a->channel->center_freq; |
404 | 334 | ||
405 | if (is_mesh_bss(a) && is_mesh_bss(b)) { | 335 | if (is_mesh_bss(a) && is_mesh_bss(b)) { |
406 | a_ies = rcu_access_pointer(a->ies); | ||
407 | if (!a_ies) | ||
408 | return -1; | ||
409 | b_ies = rcu_access_pointer(b->ies); | ||
410 | if (!b_ies) | ||
411 | return 1; | ||
412 | |||
413 | r = cmp_ies(WLAN_EID_MESH_ID, | 336 | r = cmp_ies(WLAN_EID_MESH_ID, |
414 | a_ies->data, a_ies->len, | 337 | a->information_elements, |
415 | b_ies->data, b_ies->len); | 338 | a->len_information_elements, |
339 | b->information_elements, | ||
340 | b->len_information_elements); | ||
416 | if (r) | 341 | if (r) |
417 | return r; | 342 | return r; |
418 | return cmp_ies(WLAN_EID_MESH_CONFIG, | 343 | return cmp_ies(WLAN_EID_MESH_CONFIG, |
419 | a_ies->data, a_ies->len, | 344 | a->information_elements, |
420 | b_ies->data, b_ies->len); | 345 | a->len_information_elements, |
346 | b->information_elements, | ||
347 | b->len_information_elements); | ||
421 | } | 348 | } |
422 | 349 | ||
423 | /* | 350 | r = memcmp(a->bssid, b->bssid, ETH_ALEN); |
424 | * we can't use compare_ether_addr here since we need a < > operator. | ||
425 | * The binary return value of compare_ether_addr isn't enough | ||
426 | */ | ||
427 | return memcmp(a->bssid, b->bssid, sizeof(a->bssid)); | ||
428 | } | ||
429 | |||
430 | static int cmp_bss(struct cfg80211_bss *a, | ||
431 | struct cfg80211_bss *b) | ||
432 | { | ||
433 | const struct cfg80211_bss_ies *a_ies, *b_ies; | ||
434 | int r; | ||
435 | |||
436 | r = cmp_bss_core(a, b); | ||
437 | if (r) | 351 | if (r) |
438 | return r; | 352 | return r; |
439 | 353 | ||
440 | a_ies = rcu_access_pointer(a->ies); | ||
441 | if (!a_ies) | ||
442 | return -1; | ||
443 | b_ies = rcu_access_pointer(b->ies); | ||
444 | if (!b_ies) | ||
445 | return 1; | ||
446 | |||
447 | return cmp_ies(WLAN_EID_SSID, | 354 | return cmp_ies(WLAN_EID_SSID, |
448 | a_ies->data, a_ies->len, | 355 | a->information_elements, |
449 | b_ies->data, b_ies->len); | 356 | a->len_information_elements, |
450 | } | 357 | b->information_elements, |
451 | 358 | b->len_information_elements); | |
452 | static int cmp_hidden_bss(struct cfg80211_bss *a, struct cfg80211_bss *b) | ||
453 | { | ||
454 | const struct cfg80211_bss_ies *a_ies, *b_ies; | ||
455 | const u8 *ie1; | ||
456 | const u8 *ie2; | ||
457 | int i; | ||
458 | int r; | ||
459 | |||
460 | r = cmp_bss_core(a, b); | ||
461 | if (r) | ||
462 | return r; | ||
463 | |||
464 | a_ies = rcu_access_pointer(a->ies); | ||
465 | if (!a_ies) | ||
466 | return -1; | ||
467 | b_ies = rcu_access_pointer(b->ies); | ||
468 | if (!b_ies) | ||
469 | return 1; | ||
470 | |||
471 | ie1 = cfg80211_find_ie(WLAN_EID_SSID, a_ies->data, a_ies->len); | ||
472 | ie2 = cfg80211_find_ie(WLAN_EID_SSID, b_ies->data, b_ies->len); | ||
473 | |||
474 | /* | ||
475 | * Key comparator must use same algorithm in any rb-tree | ||
476 | * search function (order is important), otherwise ordering | ||
477 | * of items in the tree is broken and search gives incorrect | ||
478 | * results. This code uses same order as cmp_ies() does. | ||
479 | * | ||
480 | * Note that due to the differring behaviour with hidden SSIDs | ||
481 | * this function only works when "b" is the tree element and | ||
482 | * "a" is the key we're looking for. | ||
483 | */ | ||
484 | |||
485 | /* sort missing IE before (left of) present IE */ | ||
486 | if (!ie1) | ||
487 | return -1; | ||
488 | if (!ie2) | ||
489 | return 1; | ||
490 | |||
491 | /* zero-size SSID is used as an indication of the hidden bss */ | ||
492 | if (!ie2[1]) | ||
493 | return 0; | ||
494 | |||
495 | /* sort by length first, then by contents */ | ||
496 | if (ie1[1] != ie2[1]) | ||
497 | return ie2[1] - ie1[1]; | ||
498 | |||
499 | /* | ||
500 | * zeroed SSID ie is another indication of a hidden bss; | ||
501 | * if it isn't zeroed just return the regular sort value | ||
502 | * to find the next candidate | ||
503 | */ | ||
504 | for (i = 0; i < ie2[1]; i++) | ||
505 | if (ie2[i + 2]) | ||
506 | return memcmp(ie1 + 2, ie2 + 2, ie1[1]); | ||
507 | |||
508 | return 0; | ||
509 | } | 359 | } |
510 | 360 | ||
511 | struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy, | 361 | struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy, |
@@ -518,9 +368,6 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy, | |||
518 | struct cfg80211_internal_bss *bss, *res = NULL; | 368 | struct cfg80211_internal_bss *bss, *res = NULL; |
519 | unsigned long now = jiffies; | 369 | unsigned long now = jiffies; |
520 | 370 | ||
521 | trace_cfg80211_get_bss(wiphy, channel, bssid, ssid, ssid_len, capa_mask, | ||
522 | capa_val); | ||
523 | |||
524 | spin_lock_bh(&dev->bss_lock); | 371 | spin_lock_bh(&dev->bss_lock); |
525 | 372 | ||
526 | list_for_each_entry(bss, &dev->bss_list, list) { | 373 | list_for_each_entry(bss, &dev->bss_list, list) { |
@@ -542,7 +389,6 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy, | |||
542 | spin_unlock_bh(&dev->bss_lock); | 389 | spin_unlock_bh(&dev->bss_lock); |
543 | if (!res) | 390 | if (!res) |
544 | return NULL; | 391 | return NULL; |
545 | trace_cfg80211_return_bss(&res->pub); | ||
546 | return &res->pub; | 392 | return &res->pub; |
547 | } | 393 | } |
548 | EXPORT_SYMBOL(cfg80211_get_bss); | 394 | EXPORT_SYMBOL(cfg80211_get_bss); |
@@ -628,146 +474,112 @@ rb_find_bss(struct cfg80211_registered_device *dev, | |||
628 | } | 474 | } |
629 | 475 | ||
630 | static struct cfg80211_internal_bss * | 476 | static struct cfg80211_internal_bss * |
631 | rb_find_hidden_bss(struct cfg80211_registered_device *dev, | ||
632 | struct cfg80211_internal_bss *res) | ||
633 | { | ||
634 | struct rb_node *n = dev->bss_tree.rb_node; | ||
635 | struct cfg80211_internal_bss *bss; | ||
636 | int r; | ||
637 | |||
638 | while (n) { | ||
639 | bss = rb_entry(n, struct cfg80211_internal_bss, rbn); | ||
640 | r = cmp_hidden_bss(&res->pub, &bss->pub); | ||
641 | |||
642 | if (r == 0) | ||
643 | return bss; | ||
644 | else if (r < 0) | ||
645 | n = n->rb_left; | ||
646 | else | ||
647 | n = n->rb_right; | ||
648 | } | ||
649 | |||
650 | return NULL; | ||
651 | } | ||
652 | |||
653 | static void | ||
654 | copy_hidden_ies(struct cfg80211_internal_bss *res, | ||
655 | struct cfg80211_internal_bss *hidden) | ||
656 | { | ||
657 | const struct cfg80211_bss_ies *ies; | ||
658 | |||
659 | if (rcu_access_pointer(res->pub.beacon_ies)) | ||
660 | return; | ||
661 | |||
662 | ies = rcu_access_pointer(hidden->pub.beacon_ies); | ||
663 | if (WARN_ON(!ies)) | ||
664 | return; | ||
665 | |||
666 | ies = kmemdup(ies, sizeof(*ies) + ies->len, GFP_ATOMIC); | ||
667 | if (unlikely(!ies)) | ||
668 | return; | ||
669 | rcu_assign_pointer(res->pub.beacon_ies, ies); | ||
670 | } | ||
671 | |||
672 | static struct cfg80211_internal_bss * | ||
673 | cfg80211_bss_update(struct cfg80211_registered_device *dev, | 477 | cfg80211_bss_update(struct cfg80211_registered_device *dev, |
674 | struct cfg80211_internal_bss *tmp) | 478 | struct cfg80211_internal_bss *res) |
675 | { | 479 | { |
676 | struct cfg80211_internal_bss *found = NULL; | 480 | struct cfg80211_internal_bss *found = NULL; |
677 | 481 | ||
678 | if (WARN_ON(!tmp->pub.channel)) | 482 | /* |
483 | * The reference to "res" is donated to this function. | ||
484 | */ | ||
485 | |||
486 | if (WARN_ON(!res->pub.channel)) { | ||
487 | kref_put(&res->ref, bss_release); | ||
679 | return NULL; | 488 | return NULL; |
489 | } | ||
680 | 490 | ||
681 | tmp->ts = jiffies; | 491 | res->ts = jiffies; |
682 | 492 | ||
683 | spin_lock_bh(&dev->bss_lock); | 493 | spin_lock_bh(&dev->bss_lock); |
684 | 494 | ||
685 | if (WARN_ON(!rcu_access_pointer(tmp->pub.ies))) { | 495 | found = rb_find_bss(dev, res); |
686 | spin_unlock_bh(&dev->bss_lock); | ||
687 | return NULL; | ||
688 | } | ||
689 | |||
690 | found = rb_find_bss(dev, tmp); | ||
691 | 496 | ||
692 | if (found) { | 497 | if (found) { |
693 | found->pub.beacon_interval = tmp->pub.beacon_interval; | 498 | found->pub.beacon_interval = res->pub.beacon_interval; |
694 | found->pub.tsf = tmp->pub.tsf; | 499 | found->pub.tsf = res->pub.tsf; |
695 | found->pub.signal = tmp->pub.signal; | 500 | found->pub.signal = res->pub.signal; |
696 | found->pub.capability = tmp->pub.capability; | 501 | found->pub.capability = res->pub.capability; |
697 | found->ts = tmp->ts; | 502 | found->ts = res->ts; |
698 | 503 | ||
699 | /* Update IEs */ | 504 | /* Update IEs */ |
700 | if (rcu_access_pointer(tmp->pub.proberesp_ies)) { | 505 | if (res->pub.proberesp_ies) { |
701 | const struct cfg80211_bss_ies *old; | 506 | size_t used = dev->wiphy.bss_priv_size + sizeof(*res); |
702 | 507 | size_t ielen = res->pub.len_proberesp_ies; | |
703 | old = rcu_access_pointer(found->pub.proberesp_ies); | 508 | |
509 | if (found->pub.proberesp_ies && | ||
510 | !found->proberesp_ies_allocated && | ||
511 | ksize(found) >= used + ielen) { | ||
512 | memcpy(found->pub.proberesp_ies, | ||
513 | res->pub.proberesp_ies, ielen); | ||
514 | found->pub.len_proberesp_ies = ielen; | ||
515 | } else { | ||
516 | u8 *ies = found->pub.proberesp_ies; | ||
517 | |||
518 | if (found->proberesp_ies_allocated) | ||
519 | ies = krealloc(ies, ielen, GFP_ATOMIC); | ||
520 | else | ||
521 | ies = kmalloc(ielen, GFP_ATOMIC); | ||
522 | |||
523 | if (ies) { | ||
524 | memcpy(ies, res->pub.proberesp_ies, | ||
525 | ielen); | ||
526 | found->proberesp_ies_allocated = true; | ||
527 | found->pub.proberesp_ies = ies; | ||
528 | found->pub.len_proberesp_ies = ielen; | ||
529 | } | ||
530 | } | ||
704 | 531 | ||
705 | rcu_assign_pointer(found->pub.proberesp_ies, | ||
706 | tmp->pub.proberesp_ies); | ||
707 | /* Override possible earlier Beacon frame IEs */ | 532 | /* Override possible earlier Beacon frame IEs */ |
708 | rcu_assign_pointer(found->pub.ies, | 533 | found->pub.information_elements = |
709 | tmp->pub.proberesp_ies); | 534 | found->pub.proberesp_ies; |
710 | if (old) | 535 | found->pub.len_information_elements = |
711 | kfree_rcu((struct cfg80211_bss_ies *)old, | 536 | found->pub.len_proberesp_ies; |
712 | rcu_head); | 537 | } |
713 | } else if (rcu_access_pointer(tmp->pub.beacon_ies)) { | 538 | if (res->pub.beacon_ies) { |
714 | const struct cfg80211_bss_ies *old, *ies; | 539 | size_t used = dev->wiphy.bss_priv_size + sizeof(*res); |
715 | 540 | size_t ielen = res->pub.len_beacon_ies; | |
716 | old = rcu_access_pointer(found->pub.beacon_ies); | 541 | bool information_elements_is_beacon_ies = |
717 | ies = rcu_access_pointer(found->pub.ies); | 542 | (found->pub.information_elements == |
718 | 543 | found->pub.beacon_ies); | |
719 | rcu_assign_pointer(found->pub.beacon_ies, | 544 | |
720 | tmp->pub.beacon_ies); | 545 | if (found->pub.beacon_ies && |
546 | !found->beacon_ies_allocated && | ||
547 | ksize(found) >= used + ielen) { | ||
548 | memcpy(found->pub.beacon_ies, | ||
549 | res->pub.beacon_ies, ielen); | ||
550 | found->pub.len_beacon_ies = ielen; | ||
551 | } else { | ||
552 | u8 *ies = found->pub.beacon_ies; | ||
553 | |||
554 | if (found->beacon_ies_allocated) | ||
555 | ies = krealloc(ies, ielen, GFP_ATOMIC); | ||
556 | else | ||
557 | ies = kmalloc(ielen, GFP_ATOMIC); | ||
558 | |||
559 | if (ies) { | ||
560 | memcpy(ies, res->pub.beacon_ies, | ||
561 | ielen); | ||
562 | found->beacon_ies_allocated = true; | ||
563 | found->pub.beacon_ies = ies; | ||
564 | found->pub.len_beacon_ies = ielen; | ||
565 | } | ||
566 | } | ||
721 | 567 | ||
722 | /* Override IEs if they were from a beacon before */ | 568 | /* Override IEs if they were from a beacon before */ |
723 | if (old == ies) | 569 | if (information_elements_is_beacon_ies) { |
724 | rcu_assign_pointer(found->pub.ies, | 570 | found->pub.information_elements = |
725 | tmp->pub.beacon_ies); | 571 | found->pub.beacon_ies; |
726 | 572 | found->pub.len_information_elements = | |
727 | if (old) | 573 | found->pub.len_beacon_ies; |
728 | kfree_rcu((struct cfg80211_bss_ies *)old, | 574 | } |
729 | rcu_head); | ||
730 | } | 575 | } |
576 | |||
577 | kref_put(&res->ref, bss_release); | ||
731 | } else { | 578 | } else { |
732 | struct cfg80211_internal_bss *new; | 579 | /* this "consumes" the reference */ |
733 | struct cfg80211_internal_bss *hidden; | 580 | list_add_tail(&res->list, &dev->bss_list); |
734 | struct cfg80211_bss_ies *ies; | 581 | rb_insert_bss(dev, res); |
735 | 582 | found = res; | |
736 | /* First check if the beacon is a probe response from | ||
737 | * a hidden bss. If so, copy beacon ies (with nullified | ||
738 | * ssid) into the probe response bss entry (with real ssid). | ||
739 | * It is required basically for PSM implementation | ||
740 | * (probe responses do not contain tim ie) */ | ||
741 | |||
742 | /* TODO: The code is not trying to update existing probe | ||
743 | * response bss entries when beacon ies are | ||
744 | * getting changed. */ | ||
745 | hidden = rb_find_hidden_bss(dev, tmp); | ||
746 | if (hidden) | ||
747 | copy_hidden_ies(tmp, hidden); | ||
748 | |||
749 | /* | ||
750 | * create a copy -- the "res" variable that is passed in | ||
751 | * is allocated on the stack since it's not needed in the | ||
752 | * more common case of an update | ||
753 | */ | ||
754 | new = kzalloc(sizeof(*new) + dev->wiphy.bss_priv_size, | ||
755 | GFP_ATOMIC); | ||
756 | if (!new) { | ||
757 | ies = (void *)rcu_dereference(tmp->pub.beacon_ies); | ||
758 | if (ies) | ||
759 | kfree_rcu(ies, rcu_head); | ||
760 | ies = (void *)rcu_dereference(tmp->pub.proberesp_ies); | ||
761 | if (ies) | ||
762 | kfree_rcu(ies, rcu_head); | ||
763 | spin_unlock_bh(&dev->bss_lock); | ||
764 | return NULL; | ||
765 | } | ||
766 | memcpy(new, tmp, sizeof(*new)); | ||
767 | kref_init(&new->ref); | ||
768 | list_add_tail(&new->list, &dev->bss_list); | ||
769 | rb_insert_bss(dev, new); | ||
770 | found = new; | ||
771 | } | 583 | } |
772 | 584 | ||
773 | dev->bss_generation++; | 585 | dev->bss_generation++; |
@@ -777,93 +589,62 @@ cfg80211_bss_update(struct cfg80211_registered_device *dev, | |||
777 | return found; | 589 | return found; |
778 | } | 590 | } |
779 | 591 | ||
780 | static struct ieee80211_channel * | ||
781 | cfg80211_get_bss_channel(struct wiphy *wiphy, const u8 *ie, size_t ielen, | ||
782 | struct ieee80211_channel *channel) | ||
783 | { | ||
784 | const u8 *tmp; | ||
785 | u32 freq; | ||
786 | int channel_number = -1; | ||
787 | |||
788 | tmp = cfg80211_find_ie(WLAN_EID_DS_PARAMS, ie, ielen); | ||
789 | if (tmp && tmp[1] == 1) { | ||
790 | channel_number = tmp[2]; | ||
791 | } else { | ||
792 | tmp = cfg80211_find_ie(WLAN_EID_HT_OPERATION, ie, ielen); | ||
793 | if (tmp && tmp[1] >= sizeof(struct ieee80211_ht_operation)) { | ||
794 | struct ieee80211_ht_operation *htop = (void *)(tmp + 2); | ||
795 | |||
796 | channel_number = htop->primary_chan; | ||
797 | } | ||
798 | } | ||
799 | |||
800 | if (channel_number < 0) | ||
801 | return channel; | ||
802 | |||
803 | freq = ieee80211_channel_to_frequency(channel_number, channel->band); | ||
804 | channel = ieee80211_get_channel(wiphy, freq); | ||
805 | if (!channel) | ||
806 | return NULL; | ||
807 | if (channel->flags & IEEE80211_CHAN_DISABLED) | ||
808 | return NULL; | ||
809 | return channel; | ||
810 | } | ||
811 | |||
812 | struct cfg80211_bss* | 592 | struct cfg80211_bss* |
813 | cfg80211_inform_bss(struct wiphy *wiphy, | 593 | cfg80211_inform_bss(struct wiphy *wiphy, |
814 | struct ieee80211_channel *channel, | 594 | struct ieee80211_channel *channel, |
815 | const u8 *bssid, u64 tsf, u16 capability, | 595 | const u8 *bssid, |
816 | u16 beacon_interval, const u8 *ie, size_t ielen, | 596 | u64 timestamp, u16 capability, u16 beacon_interval, |
597 | const u8 *ie, size_t ielen, | ||
817 | s32 signal, gfp_t gfp) | 598 | s32 signal, gfp_t gfp) |
818 | { | 599 | { |
819 | struct cfg80211_bss_ies *ies; | 600 | struct cfg80211_internal_bss *res; |
820 | struct cfg80211_internal_bss tmp = {}, *res; | 601 | size_t privsz; |
821 | 602 | ||
822 | if (WARN_ON(!wiphy)) | 603 | if (WARN_ON(!wiphy)) |
823 | return NULL; | 604 | return NULL; |
824 | 605 | ||
606 | privsz = wiphy->bss_priv_size; | ||
607 | |||
825 | if (WARN_ON(wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC && | 608 | if (WARN_ON(wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC && |
826 | (signal < 0 || signal > 100))) | 609 | (signal < 0 || signal > 100))) |
827 | return NULL; | 610 | return NULL; |
828 | 611 | ||
829 | channel = cfg80211_get_bss_channel(wiphy, ie, ielen, channel); | 612 | res = kzalloc(sizeof(*res) + privsz + ielen, gfp); |
830 | if (!channel) | 613 | if (!res) |
831 | return NULL; | 614 | return NULL; |
832 | 615 | ||
833 | memcpy(tmp.pub.bssid, bssid, ETH_ALEN); | 616 | memcpy(res->pub.bssid, bssid, ETH_ALEN); |
834 | tmp.pub.channel = channel; | 617 | res->pub.channel = channel; |
835 | tmp.pub.signal = signal; | 618 | res->pub.signal = signal; |
836 | tmp.pub.tsf = tsf; | 619 | res->pub.tsf = timestamp; |
837 | tmp.pub.beacon_interval = beacon_interval; | 620 | res->pub.beacon_interval = beacon_interval; |
838 | tmp.pub.capability = capability; | 621 | res->pub.capability = capability; |
839 | /* | 622 | /* |
840 | * Since we do not know here whether the IEs are from a Beacon or Probe | 623 | * Since we do not know here whether the IEs are from a Beacon or Probe |
841 | * Response frame, we need to pick one of the options and only use it | 624 | * Response frame, we need to pick one of the options and only use it |
842 | * with the driver that does not provide the full Beacon/Probe Response | 625 | * with the driver that does not provide the full Beacon/Probe Response |
843 | * frame. Use Beacon frame pointer to avoid indicating that this should | 626 | * frame. Use Beacon frame pointer to avoid indicating that this should |
844 | * override the iies pointer should we have received an earlier | 627 | * override the information_elements pointer should we have received an |
845 | * indication of Probe Response data. | 628 | * earlier indication of Probe Response data. |
846 | * | 629 | * |
847 | * The initial buffer for the IEs is allocated with the BSS entry and | 630 | * The initial buffer for the IEs is allocated with the BSS entry and |
848 | * is located after the private area. | 631 | * is located after the private area. |
849 | */ | 632 | */ |
850 | ies = kmalloc(sizeof(*ies) + ielen, gfp); | 633 | res->pub.beacon_ies = (u8 *)res + sizeof(*res) + privsz; |
851 | if (!ies) | 634 | memcpy(res->pub.beacon_ies, ie, ielen); |
852 | return NULL; | 635 | res->pub.len_beacon_ies = ielen; |
853 | ies->len = ielen; | 636 | res->pub.information_elements = res->pub.beacon_ies; |
854 | memcpy(ies->data, ie, ielen); | 637 | res->pub.len_information_elements = res->pub.len_beacon_ies; |
855 | 638 | ||
856 | rcu_assign_pointer(tmp.pub.beacon_ies, ies); | 639 | kref_init(&res->ref); |
857 | rcu_assign_pointer(tmp.pub.ies, ies); | ||
858 | 640 | ||
859 | res = cfg80211_bss_update(wiphy_to_dev(wiphy), &tmp); | 641 | res = cfg80211_bss_update(wiphy_to_dev(wiphy), res); |
860 | if (!res) | 642 | if (!res) |
861 | return NULL; | 643 | return NULL; |
862 | 644 | ||
863 | if (res->pub.capability & WLAN_CAPABILITY_ESS) | 645 | if (res->pub.capability & WLAN_CAPABILITY_ESS) |
864 | regulatory_hint_found_beacon(wiphy, channel, gfp); | 646 | regulatory_hint_found_beacon(wiphy, channel, gfp); |
865 | 647 | ||
866 | trace_cfg80211_return_bss(&res->pub); | ||
867 | /* cfg80211_bss_update gives us a referenced result */ | 648 | /* cfg80211_bss_update gives us a referenced result */ |
868 | return &res->pub; | 649 | return &res->pub; |
869 | } | 650 | } |
@@ -875,15 +656,10 @@ cfg80211_inform_bss_frame(struct wiphy *wiphy, | |||
875 | struct ieee80211_mgmt *mgmt, size_t len, | 656 | struct ieee80211_mgmt *mgmt, size_t len, |
876 | s32 signal, gfp_t gfp) | 657 | s32 signal, gfp_t gfp) |
877 | { | 658 | { |
878 | struct cfg80211_internal_bss tmp = {}, *res; | 659 | struct cfg80211_internal_bss *res; |
879 | struct cfg80211_bss_ies *ies; | ||
880 | size_t ielen = len - offsetof(struct ieee80211_mgmt, | 660 | size_t ielen = len - offsetof(struct ieee80211_mgmt, |
881 | u.probe_resp.variable); | 661 | u.probe_resp.variable); |
882 | 662 | size_t privsz; | |
883 | BUILD_BUG_ON(offsetof(struct ieee80211_mgmt, u.probe_resp.variable) != | ||
884 | offsetof(struct ieee80211_mgmt, u.beacon.variable)); | ||
885 | |||
886 | trace_cfg80211_inform_bss_frame(wiphy, channel, mgmt, len, signal); | ||
887 | 663 | ||
888 | if (WARN_ON(!mgmt)) | 664 | if (WARN_ON(!mgmt)) |
889 | return NULL; | 665 | return NULL; |
@@ -892,61 +668,57 @@ cfg80211_inform_bss_frame(struct wiphy *wiphy, | |||
892 | return NULL; | 668 | return NULL; |
893 | 669 | ||
894 | if (WARN_ON(wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC && | 670 | if (WARN_ON(wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC && |
895 | (signal < 0 || signal > 100))) | 671 | (signal < 0 || signal > 100))) |
896 | return NULL; | 672 | return NULL; |
897 | 673 | ||
898 | if (WARN_ON(len < offsetof(struct ieee80211_mgmt, u.probe_resp.variable))) | 674 | if (WARN_ON(len < offsetof(struct ieee80211_mgmt, u.probe_resp.variable))) |
899 | return NULL; | 675 | return NULL; |
900 | 676 | ||
901 | channel = cfg80211_get_bss_channel(wiphy, mgmt->u.beacon.variable, | 677 | privsz = wiphy->bss_priv_size; |
902 | ielen, channel); | ||
903 | if (!channel) | ||
904 | return NULL; | ||
905 | 678 | ||
906 | ies = kmalloc(sizeof(*ies) + ielen, gfp); | 679 | res = kzalloc(sizeof(*res) + privsz + ielen, gfp); |
907 | if (!ies) | 680 | if (!res) |
908 | return NULL; | 681 | return NULL; |
909 | ies->len = ielen; | ||
910 | memcpy(ies->data, mgmt->u.probe_resp.variable, ielen); | ||
911 | 682 | ||
912 | if (ieee80211_is_probe_resp(mgmt->frame_control)) | 683 | memcpy(res->pub.bssid, mgmt->bssid, ETH_ALEN); |
913 | rcu_assign_pointer(tmp.pub.proberesp_ies, ies); | 684 | res->pub.channel = channel; |
914 | else | 685 | res->pub.signal = signal; |
915 | rcu_assign_pointer(tmp.pub.beacon_ies, ies); | 686 | res->pub.tsf = le64_to_cpu(mgmt->u.probe_resp.timestamp); |
916 | rcu_assign_pointer(tmp.pub.ies, ies); | 687 | res->pub.beacon_interval = le16_to_cpu(mgmt->u.probe_resp.beacon_int); |
917 | 688 | res->pub.capability = le16_to_cpu(mgmt->u.probe_resp.capab_info); | |
918 | memcpy(tmp.pub.bssid, mgmt->bssid, ETH_ALEN); | 689 | /* |
919 | tmp.pub.channel = channel; | 690 | * The initial buffer for the IEs is allocated with the BSS entry and |
920 | tmp.pub.signal = signal; | 691 | * is located after the private area. |
921 | tmp.pub.tsf = le64_to_cpu(mgmt->u.probe_resp.timestamp); | 692 | */ |
922 | tmp.pub.beacon_interval = le16_to_cpu(mgmt->u.probe_resp.beacon_int); | 693 | if (ieee80211_is_probe_resp(mgmt->frame_control)) { |
923 | tmp.pub.capability = le16_to_cpu(mgmt->u.probe_resp.capab_info); | 694 | res->pub.proberesp_ies = (u8 *) res + sizeof(*res) + privsz; |
924 | 695 | memcpy(res->pub.proberesp_ies, mgmt->u.probe_resp.variable, | |
925 | res = cfg80211_bss_update(wiphy_to_dev(wiphy), &tmp); | 696 | ielen); |
697 | res->pub.len_proberesp_ies = ielen; | ||
698 | res->pub.information_elements = res->pub.proberesp_ies; | ||
699 | res->pub.len_information_elements = res->pub.len_proberesp_ies; | ||
700 | } else { | ||
701 | res->pub.beacon_ies = (u8 *) res + sizeof(*res) + privsz; | ||
702 | memcpy(res->pub.beacon_ies, mgmt->u.beacon.variable, ielen); | ||
703 | res->pub.len_beacon_ies = ielen; | ||
704 | res->pub.information_elements = res->pub.beacon_ies; | ||
705 | res->pub.len_information_elements = res->pub.len_beacon_ies; | ||
706 | } | ||
707 | |||
708 | kref_init(&res->ref); | ||
709 | |||
710 | res = cfg80211_bss_update(wiphy_to_dev(wiphy), res); | ||
926 | if (!res) | 711 | if (!res) |
927 | return NULL; | 712 | return NULL; |
928 | 713 | ||
929 | if (res->pub.capability & WLAN_CAPABILITY_ESS) | 714 | if (res->pub.capability & WLAN_CAPABILITY_ESS) |
930 | regulatory_hint_found_beacon(wiphy, channel, gfp); | 715 | regulatory_hint_found_beacon(wiphy, channel, gfp); |
931 | 716 | ||
932 | trace_cfg80211_return_bss(&res->pub); | ||
933 | /* cfg80211_bss_update gives us a referenced result */ | 717 | /* cfg80211_bss_update gives us a referenced result */ |
934 | return &res->pub; | 718 | return &res->pub; |
935 | } | 719 | } |
936 | EXPORT_SYMBOL(cfg80211_inform_bss_frame); | 720 | EXPORT_SYMBOL(cfg80211_inform_bss_frame); |
937 | 721 | ||
938 | void cfg80211_ref_bss(struct cfg80211_bss *pub) | ||
939 | { | ||
940 | struct cfg80211_internal_bss *bss; | ||
941 | |||
942 | if (!pub) | ||
943 | return; | ||
944 | |||
945 | bss = container_of(pub, struct cfg80211_internal_bss, pub); | ||
946 | kref_get(&bss->ref); | ||
947 | } | ||
948 | EXPORT_SYMBOL(cfg80211_ref_bss); | ||
949 | |||
950 | void cfg80211_put_bss(struct cfg80211_bss *pub) | 722 | void cfg80211_put_bss(struct cfg80211_bss *pub) |
951 | { | 723 | { |
952 | struct cfg80211_internal_bss *bss; | 724 | struct cfg80211_internal_bss *bss; |
@@ -1026,12 +798,11 @@ int cfg80211_wext_siwscan(struct net_device *dev, | |||
1026 | } | 798 | } |
1027 | 799 | ||
1028 | creq->wiphy = wiphy; | 800 | creq->wiphy = wiphy; |
1029 | creq->wdev = dev->ieee80211_ptr; | 801 | creq->dev = dev; |
1030 | /* SSIDs come after channels */ | 802 | /* SSIDs come after channels */ |
1031 | creq->ssids = (void *)&creq->channels[n_channels]; | 803 | creq->ssids = (void *)&creq->channels[n_channels]; |
1032 | creq->n_channels = n_channels; | 804 | creq->n_channels = n_channels; |
1033 | creq->n_ssids = 1; | 805 | creq->n_ssids = 1; |
1034 | creq->scan_start = jiffies; | ||
1035 | 806 | ||
1036 | /* translate "Scan on frequencies" request */ | 807 | /* translate "Scan on frequencies" request */ |
1037 | i = 0; | 808 | i = 0; |
@@ -1096,12 +867,12 @@ int cfg80211_wext_siwscan(struct net_device *dev, | |||
1096 | creq->rates[i] = (1 << wiphy->bands[i]->n_bitrates) - 1; | 867 | creq->rates[i] = (1 << wiphy->bands[i]->n_bitrates) - 1; |
1097 | 868 | ||
1098 | rdev->scan_req = creq; | 869 | rdev->scan_req = creq; |
1099 | err = rdev_scan(rdev, creq); | 870 | err = rdev->ops->scan(wiphy, dev, creq); |
1100 | if (err) { | 871 | if (err) { |
1101 | rdev->scan_req = NULL; | 872 | rdev->scan_req = NULL; |
1102 | /* creq will be freed below */ | 873 | /* creq will be freed below */ |
1103 | } else { | 874 | } else { |
1104 | nl80211_send_scan_start(rdev, dev->ieee80211_ptr); | 875 | nl80211_send_scan_start(rdev, dev); |
1105 | /* creq now owned by driver */ | 876 | /* creq now owned by driver */ |
1106 | creq = NULL; | 877 | creq = NULL; |
1107 | dev_hold(dev); | 878 | dev_hold(dev); |
@@ -1114,21 +885,22 @@ int cfg80211_wext_siwscan(struct net_device *dev, | |||
1114 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwscan); | 885 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwscan); |
1115 | 886 | ||
1116 | static void ieee80211_scan_add_ies(struct iw_request_info *info, | 887 | static void ieee80211_scan_add_ies(struct iw_request_info *info, |
1117 | const struct cfg80211_bss_ies *ies, | 888 | struct cfg80211_bss *bss, |
1118 | char **current_ev, char *end_buf) | 889 | char **current_ev, char *end_buf) |
1119 | { | 890 | { |
1120 | const u8 *pos, *end, *next; | 891 | u8 *pos, *end, *next; |
1121 | struct iw_event iwe; | 892 | struct iw_event iwe; |
1122 | 893 | ||
1123 | if (!ies) | 894 | if (!bss->information_elements || |
895 | !bss->len_information_elements) | ||
1124 | return; | 896 | return; |
1125 | 897 | ||
1126 | /* | 898 | /* |
1127 | * If needed, fragment the IEs buffer (at IE boundaries) into short | 899 | * If needed, fragment the IEs buffer (at IE boundaries) into short |
1128 | * enough fragments to fit into IW_GENERIC_IE_MAX octet messages. | 900 | * enough fragments to fit into IW_GENERIC_IE_MAX octet messages. |
1129 | */ | 901 | */ |
1130 | pos = ies->data; | 902 | pos = bss->information_elements; |
1131 | end = pos + ies->len; | 903 | end = pos + bss->len_information_elements; |
1132 | 904 | ||
1133 | while (end - pos > IW_GENERIC_IE_MAX) { | 905 | while (end - pos > IW_GENERIC_IE_MAX) { |
1134 | next = pos + 2 + pos[1]; | 906 | next = pos + 2 + pos[1]; |
@@ -1139,8 +911,7 @@ static void ieee80211_scan_add_ies(struct iw_request_info *info, | |||
1139 | iwe.cmd = IWEVGENIE; | 911 | iwe.cmd = IWEVGENIE; |
1140 | iwe.u.data.length = next - pos; | 912 | iwe.u.data.length = next - pos; |
1141 | *current_ev = iwe_stream_add_point(info, *current_ev, | 913 | *current_ev = iwe_stream_add_point(info, *current_ev, |
1142 | end_buf, &iwe, | 914 | end_buf, &iwe, pos); |
1143 | (void *)pos); | ||
1144 | 915 | ||
1145 | pos = next; | 916 | pos = next; |
1146 | } | 917 | } |
@@ -1150,8 +921,7 @@ static void ieee80211_scan_add_ies(struct iw_request_info *info, | |||
1150 | iwe.cmd = IWEVGENIE; | 921 | iwe.cmd = IWEVGENIE; |
1151 | iwe.u.data.length = end - pos; | 922 | iwe.u.data.length = end - pos; |
1152 | *current_ev = iwe_stream_add_point(info, *current_ev, | 923 | *current_ev = iwe_stream_add_point(info, *current_ev, |
1153 | end_buf, &iwe, | 924 | end_buf, &iwe, pos); |
1154 | (void *)pos); | ||
1155 | } | 925 | } |
1156 | } | 926 | } |
1157 | 927 | ||
@@ -1170,11 +940,10 @@ ieee80211_bss(struct wiphy *wiphy, struct iw_request_info *info, | |||
1170 | struct cfg80211_internal_bss *bss, char *current_ev, | 940 | struct cfg80211_internal_bss *bss, char *current_ev, |
1171 | char *end_buf) | 941 | char *end_buf) |
1172 | { | 942 | { |
1173 | const struct cfg80211_bss_ies *ies; | ||
1174 | struct iw_event iwe; | 943 | struct iw_event iwe; |
1175 | const u8 *ie; | ||
1176 | u8 *buf, *cfg, *p; | 944 | u8 *buf, *cfg, *p; |
1177 | int rem, i, sig; | 945 | u8 *ie = bss->pub.information_elements; |
946 | int rem = bss->pub.len_information_elements, i, sig; | ||
1178 | bool ismesh = false; | 947 | bool ismesh = false; |
1179 | 948 | ||
1180 | memset(&iwe, 0, sizeof(iwe)); | 949 | memset(&iwe, 0, sizeof(iwe)); |
@@ -1239,17 +1008,7 @@ ieee80211_bss(struct wiphy *wiphy, struct iw_request_info *info, | |||
1239 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | 1008 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, |
1240 | &iwe, ""); | 1009 | &iwe, ""); |
1241 | 1010 | ||
1242 | rcu_read_lock(); | 1011 | while (rem >= 2) { |
1243 | ies = rcu_dereference(bss->pub.ies); | ||
1244 | if (ies) { | ||
1245 | rem = ies->len; | ||
1246 | ie = ies->data; | ||
1247 | } else { | ||
1248 | rem = 0; | ||
1249 | ie = NULL; | ||
1250 | } | ||
1251 | |||
1252 | while (ies && rem >= 2) { | ||
1253 | /* invalid data */ | 1012 | /* invalid data */ |
1254 | if (ie[1] > rem - 2) | 1013 | if (ie[1] > rem - 2) |
1255 | break; | 1014 | break; |
@@ -1261,7 +1020,7 @@ ieee80211_bss(struct wiphy *wiphy, struct iw_request_info *info, | |||
1261 | iwe.u.data.length = ie[1]; | 1020 | iwe.u.data.length = ie[1]; |
1262 | iwe.u.data.flags = 1; | 1021 | iwe.u.data.flags = 1; |
1263 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | 1022 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, |
1264 | &iwe, (u8 *)ie + 2); | 1023 | &iwe, ie + 2); |
1265 | break; | 1024 | break; |
1266 | case WLAN_EID_MESH_ID: | 1025 | case WLAN_EID_MESH_ID: |
1267 | memset(&iwe, 0, sizeof(iwe)); | 1026 | memset(&iwe, 0, sizeof(iwe)); |
@@ -1269,7 +1028,7 @@ ieee80211_bss(struct wiphy *wiphy, struct iw_request_info *info, | |||
1269 | iwe.u.data.length = ie[1]; | 1028 | iwe.u.data.length = ie[1]; |
1270 | iwe.u.data.flags = 1; | 1029 | iwe.u.data.flags = 1; |
1271 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | 1030 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, |
1272 | &iwe, (u8 *)ie + 2); | 1031 | &iwe, ie + 2); |
1273 | break; | 1032 | break; |
1274 | case WLAN_EID_MESH_CONFIG: | 1033 | case WLAN_EID_MESH_CONFIG: |
1275 | ismesh = true; | 1034 | ismesh = true; |
@@ -1278,7 +1037,7 @@ ieee80211_bss(struct wiphy *wiphy, struct iw_request_info *info, | |||
1278 | buf = kmalloc(50, GFP_ATOMIC); | 1037 | buf = kmalloc(50, GFP_ATOMIC); |
1279 | if (!buf) | 1038 | if (!buf) |
1280 | break; | 1039 | break; |
1281 | cfg = (u8 *)ie + 2; | 1040 | cfg = ie + 2; |
1282 | memset(&iwe, 0, sizeof(iwe)); | 1041 | memset(&iwe, 0, sizeof(iwe)); |
1283 | iwe.cmd = IWEVCUSTOM; | 1042 | iwe.cmd = IWEVCUSTOM; |
1284 | sprintf(buf, "Mesh Network Path Selection Protocol ID: " | 1043 | sprintf(buf, "Mesh Network Path Selection Protocol ID: " |
@@ -1376,8 +1135,7 @@ ieee80211_bss(struct wiphy *wiphy, struct iw_request_info *info, | |||
1376 | kfree(buf); | 1135 | kfree(buf); |
1377 | } | 1136 | } |
1378 | 1137 | ||
1379 | ieee80211_scan_add_ies(info, ies, ¤t_ev, end_buf); | 1138 | ieee80211_scan_add_ies(info, &bss->pub, ¤t_ev, end_buf); |
1380 | rcu_read_unlock(); | ||
1381 | 1139 | ||
1382 | return current_ev; | 1140 | return current_ev; |
1383 | } | 1141 | } |
diff --git a/net/wireless/sme.c b/net/wireless/sme.c index f2431e41a37..c0fe1a8a6ee 100644 --- a/net/wireless/sme.c +++ b/net/wireless/sme.c | |||
@@ -10,13 +10,11 @@ | |||
10 | #include <linux/slab.h> | 10 | #include <linux/slab.h> |
11 | #include <linux/workqueue.h> | 11 | #include <linux/workqueue.h> |
12 | #include <linux/wireless.h> | 12 | #include <linux/wireless.h> |
13 | #include <linux/export.h> | ||
14 | #include <net/iw_handler.h> | 13 | #include <net/iw_handler.h> |
15 | #include <net/cfg80211.h> | 14 | #include <net/cfg80211.h> |
16 | #include <net/rtnetlink.h> | 15 | #include <net/rtnetlink.h> |
17 | #include "nl80211.h" | 16 | #include "nl80211.h" |
18 | #include "reg.h" | 17 | #include "reg.h" |
19 | #include "rdev-ops.h" | ||
20 | 18 | ||
21 | struct cfg80211_conn { | 19 | struct cfg80211_conn { |
22 | struct cfg80211_connect_params params; | 20 | struct cfg80211_connect_params params; |
@@ -52,7 +50,7 @@ static bool cfg80211_is_all_idle(void) | |||
52 | */ | 50 | */ |
53 | list_for_each_entry(rdev, &cfg80211_rdev_list, list) { | 51 | list_for_each_entry(rdev, &cfg80211_rdev_list, list) { |
54 | cfg80211_lock_rdev(rdev); | 52 | cfg80211_lock_rdev(rdev); |
55 | list_for_each_entry(wdev, &rdev->wdev_list, list) { | 53 | list_for_each_entry(wdev, &rdev->netdev_list, list) { |
56 | wdev_lock(wdev); | 54 | wdev_lock(wdev); |
57 | if (wdev->sme_state != CFG80211_SME_IDLE) | 55 | if (wdev->sme_state != CFG80211_SME_IDLE) |
58 | is_all_idle = false; | 56 | is_all_idle = false; |
@@ -112,22 +110,17 @@ static int cfg80211_conn_scan(struct wireless_dev *wdev) | |||
112 | else { | 110 | else { |
113 | int i = 0, j; | 111 | int i = 0, j; |
114 | enum ieee80211_band band; | 112 | enum ieee80211_band band; |
115 | struct ieee80211_supported_band *bands; | ||
116 | struct ieee80211_channel *channel; | ||
117 | 113 | ||
118 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) { | 114 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) { |
119 | bands = wdev->wiphy->bands[band]; | 115 | if (!wdev->wiphy->bands[band]) |
120 | if (!bands) | ||
121 | continue; | 116 | continue; |
122 | for (j = 0; j < bands->n_channels; j++) { | 117 | for (j = 0; j < wdev->wiphy->bands[band]->n_channels; |
123 | channel = &bands->channels[j]; | 118 | i++, j++) |
124 | if (channel->flags & IEEE80211_CHAN_DISABLED) | 119 | request->channels[i] = |
125 | continue; | 120 | &wdev->wiphy->bands[band]->channels[j]; |
126 | request->channels[i++] = channel; | 121 | request->rates[band] = |
127 | } | 122 | (1 << wdev->wiphy->bands[band]->n_bitrates) - 1; |
128 | request->rates[band] = (1 << bands->n_bitrates) - 1; | ||
129 | } | 123 | } |
130 | n_channels = i; | ||
131 | } | 124 | } |
132 | request->n_channels = n_channels; | 125 | request->n_channels = n_channels; |
133 | request->ssids = (void *)&request->channels[n_channels]; | 126 | request->ssids = (void *)&request->channels[n_channels]; |
@@ -137,16 +130,15 @@ static int cfg80211_conn_scan(struct wireless_dev *wdev) | |||
137 | wdev->conn->params.ssid_len); | 130 | wdev->conn->params.ssid_len); |
138 | request->ssids[0].ssid_len = wdev->conn->params.ssid_len; | 131 | request->ssids[0].ssid_len = wdev->conn->params.ssid_len; |
139 | 132 | ||
140 | request->wdev = wdev; | 133 | request->dev = wdev->netdev; |
141 | request->wiphy = &rdev->wiphy; | 134 | request->wiphy = &rdev->wiphy; |
142 | request->scan_start = jiffies; | ||
143 | 135 | ||
144 | rdev->scan_req = request; | 136 | rdev->scan_req = request; |
145 | 137 | ||
146 | err = rdev_scan(rdev, request); | 138 | err = rdev->ops->scan(wdev->wiphy, wdev->netdev, request); |
147 | if (!err) { | 139 | if (!err) { |
148 | wdev->conn->state = CFG80211_CONN_SCANNING; | 140 | wdev->conn->state = CFG80211_CONN_SCANNING; |
149 | nl80211_send_scan_start(rdev, wdev); | 141 | nl80211_send_scan_start(rdev, wdev->netdev); |
150 | dev_hold(wdev->netdev); | 142 | dev_hold(wdev->netdev); |
151 | } else { | 143 | } else { |
152 | rdev->scan_req = NULL; | 144 | rdev->scan_req = NULL; |
@@ -181,7 +173,7 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev) | |||
181 | params->ssid, params->ssid_len, | 173 | params->ssid, params->ssid_len, |
182 | NULL, 0, | 174 | NULL, 0, |
183 | params->key, params->key_len, | 175 | params->key, params->key_len, |
184 | params->key_idx, NULL, 0); | 176 | params->key_idx, false); |
185 | case CFG80211_CONN_ASSOCIATE_NEXT: | 177 | case CFG80211_CONN_ASSOCIATE_NEXT: |
186 | BUG_ON(!rdev->ops->assoc); | 178 | BUG_ON(!rdev->ops->assoc); |
187 | wdev->conn->state = CFG80211_CONN_ASSOCIATING; | 179 | wdev->conn->state = CFG80211_CONN_ASSOCIATING; |
@@ -192,9 +184,7 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev) | |||
192 | prev_bssid, | 184 | prev_bssid, |
193 | params->ssid, params->ssid_len, | 185 | params->ssid, params->ssid_len, |
194 | params->ie, params->ie_len, | 186 | params->ie, params->ie_len, |
195 | false, ¶ms->crypto, | 187 | false, ¶ms->crypto); |
196 | params->flags, ¶ms->ht_capa, | ||
197 | ¶ms->ht_capa_mask); | ||
198 | if (err) | 188 | if (err) |
199 | __cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid, | 189 | __cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid, |
200 | NULL, 0, | 190 | NULL, 0, |
@@ -223,7 +213,7 @@ void cfg80211_conn_work(struct work_struct *work) | |||
223 | cfg80211_lock_rdev(rdev); | 213 | cfg80211_lock_rdev(rdev); |
224 | mutex_lock(&rdev->devlist_mtx); | 214 | mutex_lock(&rdev->devlist_mtx); |
225 | 215 | ||
226 | list_for_each_entry(wdev, &rdev->wdev_list, list) { | 216 | list_for_each_entry(wdev, &rdev->netdev_list, list) { |
227 | wdev_lock(wdev); | 217 | wdev_lock(wdev); |
228 | if (!netif_running(wdev->netdev)) { | 218 | if (!netif_running(wdev->netdev)) { |
229 | wdev_unlock(wdev); | 219 | wdev_unlock(wdev); |
@@ -417,7 +407,7 @@ void __cfg80211_connect_result(struct net_device *dev, const u8 *bssid, | |||
417 | struct cfg80211_bss *bss) | 407 | struct cfg80211_bss *bss) |
418 | { | 408 | { |
419 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 409 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
420 | const u8 *country_ie; | 410 | u8 *country_ie; |
421 | #ifdef CONFIG_CFG80211_WEXT | 411 | #ifdef CONFIG_CFG80211_WEXT |
422 | union iwreq_data wrqu; | 412 | union iwreq_data wrqu; |
423 | #endif | 413 | #endif |
@@ -479,7 +469,6 @@ void __cfg80211_connect_result(struct net_device *dev, const u8 *bssid, | |||
479 | kfree(wdev->connect_keys); | 469 | kfree(wdev->connect_keys); |
480 | wdev->connect_keys = NULL; | 470 | wdev->connect_keys = NULL; |
481 | wdev->ssid_len = 0; | 471 | wdev->ssid_len = 0; |
482 | cfg80211_put_bss(bss); | ||
483 | return; | 472 | return; |
484 | } | 473 | } |
485 | 474 | ||
@@ -501,15 +490,7 @@ void __cfg80211_connect_result(struct net_device *dev, const u8 *bssid, | |||
501 | wdev->sme_state = CFG80211_SME_CONNECTED; | 490 | wdev->sme_state = CFG80211_SME_CONNECTED; |
502 | cfg80211_upload_connect_keys(wdev); | 491 | cfg80211_upload_connect_keys(wdev); |
503 | 492 | ||
504 | rcu_read_lock(); | 493 | country_ie = (u8 *) ieee80211_bss_get_ie(bss, WLAN_EID_COUNTRY); |
505 | country_ie = ieee80211_bss_get_ie(bss, WLAN_EID_COUNTRY); | ||
506 | if (!country_ie) { | ||
507 | rcu_read_unlock(); | ||
508 | return; | ||
509 | } | ||
510 | |||
511 | country_ie = kmemdup(country_ie, 2 + country_ie[1], GFP_ATOMIC); | ||
512 | rcu_read_unlock(); | ||
513 | 494 | ||
514 | if (!country_ie) | 495 | if (!country_ie) |
515 | return; | 496 | return; |
@@ -523,7 +504,6 @@ void __cfg80211_connect_result(struct net_device *dev, const u8 *bssid, | |||
523 | bss->channel->band, | 504 | bss->channel->band, |
524 | country_ie + 2, | 505 | country_ie + 2, |
525 | country_ie[1]); | 506 | country_ie[1]); |
526 | kfree(country_ie); | ||
527 | } | 507 | } |
528 | 508 | ||
529 | void cfg80211_connect_result(struct net_device *dev, const u8 *bssid, | 509 | void cfg80211_connect_result(struct net_device *dev, const u8 *bssid, |
@@ -565,35 +545,45 @@ void cfg80211_connect_result(struct net_device *dev, const u8 *bssid, | |||
565 | EXPORT_SYMBOL(cfg80211_connect_result); | 545 | EXPORT_SYMBOL(cfg80211_connect_result); |
566 | 546 | ||
567 | void __cfg80211_roamed(struct wireless_dev *wdev, | 547 | void __cfg80211_roamed(struct wireless_dev *wdev, |
568 | struct cfg80211_bss *bss, | 548 | struct ieee80211_channel *channel, |
549 | const u8 *bssid, | ||
569 | const u8 *req_ie, size_t req_ie_len, | 550 | const u8 *req_ie, size_t req_ie_len, |
570 | const u8 *resp_ie, size_t resp_ie_len) | 551 | const u8 *resp_ie, size_t resp_ie_len) |
571 | { | 552 | { |
553 | struct cfg80211_bss *bss; | ||
572 | #ifdef CONFIG_CFG80211_WEXT | 554 | #ifdef CONFIG_CFG80211_WEXT |
573 | union iwreq_data wrqu; | 555 | union iwreq_data wrqu; |
574 | #endif | 556 | #endif |
557 | |||
575 | ASSERT_WDEV_LOCK(wdev); | 558 | ASSERT_WDEV_LOCK(wdev); |
576 | 559 | ||
577 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION && | 560 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION && |
578 | wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)) | 561 | wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)) |
579 | goto out; | 562 | return; |
580 | 563 | ||
581 | if (wdev->sme_state != CFG80211_SME_CONNECTED) | 564 | if (wdev->sme_state != CFG80211_SME_CONNECTED) |
582 | goto out; | 565 | return; |
583 | 566 | ||
584 | /* internal error -- how did we get to CONNECTED w/o BSS? */ | 567 | /* internal error -- how did we get to CONNECTED w/o BSS? */ |
585 | if (WARN_ON(!wdev->current_bss)) { | 568 | if (WARN_ON(!wdev->current_bss)) { |
586 | goto out; | 569 | return; |
587 | } | 570 | } |
588 | 571 | ||
589 | cfg80211_unhold_bss(wdev->current_bss); | 572 | cfg80211_unhold_bss(wdev->current_bss); |
590 | cfg80211_put_bss(&wdev->current_bss->pub); | 573 | cfg80211_put_bss(&wdev->current_bss->pub); |
591 | wdev->current_bss = NULL; | 574 | wdev->current_bss = NULL; |
592 | 575 | ||
576 | bss = cfg80211_get_bss(wdev->wiphy, channel, bssid, | ||
577 | wdev->ssid, wdev->ssid_len, | ||
578 | WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); | ||
579 | |||
580 | if (WARN_ON(!bss)) | ||
581 | return; | ||
582 | |||
593 | cfg80211_hold_bss(bss_from_pub(bss)); | 583 | cfg80211_hold_bss(bss_from_pub(bss)); |
594 | wdev->current_bss = bss_from_pub(bss); | 584 | wdev->current_bss = bss_from_pub(bss); |
595 | 585 | ||
596 | nl80211_send_roamed(wiphy_to_dev(wdev->wiphy), wdev->netdev, bss->bssid, | 586 | nl80211_send_roamed(wiphy_to_dev(wdev->wiphy), wdev->netdev, bssid, |
597 | req_ie, req_ie_len, resp_ie, resp_ie_len, | 587 | req_ie, req_ie_len, resp_ie, resp_ie_len, |
598 | GFP_KERNEL); | 588 | GFP_KERNEL); |
599 | 589 | ||
@@ -614,15 +604,11 @@ void __cfg80211_roamed(struct wireless_dev *wdev, | |||
614 | 604 | ||
615 | memset(&wrqu, 0, sizeof(wrqu)); | 605 | memset(&wrqu, 0, sizeof(wrqu)); |
616 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; | 606 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
617 | memcpy(wrqu.ap_addr.sa_data, bss->bssid, ETH_ALEN); | 607 | memcpy(wrqu.ap_addr.sa_data, bssid, ETH_ALEN); |
618 | memcpy(wdev->wext.prev_bssid, bss->bssid, ETH_ALEN); | 608 | memcpy(wdev->wext.prev_bssid, bssid, ETH_ALEN); |
619 | wdev->wext.prev_bssid_valid = true; | 609 | wdev->wext.prev_bssid_valid = true; |
620 | wireless_send_event(wdev->netdev, SIOCGIWAP, &wrqu, NULL); | 610 | wireless_send_event(wdev->netdev, SIOCGIWAP, &wrqu, NULL); |
621 | #endif | 611 | #endif |
622 | |||
623 | return; | ||
624 | out: | ||
625 | cfg80211_put_bss(bss); | ||
626 | } | 612 | } |
627 | 613 | ||
628 | void cfg80211_roamed(struct net_device *dev, | 614 | void cfg80211_roamed(struct net_device *dev, |
@@ -632,57 +618,32 @@ void cfg80211_roamed(struct net_device *dev, | |||
632 | const u8 *resp_ie, size_t resp_ie_len, gfp_t gfp) | 618 | const u8 *resp_ie, size_t resp_ie_len, gfp_t gfp) |
633 | { | 619 | { |
634 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 620 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
635 | struct cfg80211_bss *bss; | ||
636 | |||
637 | CFG80211_DEV_WARN_ON(wdev->sme_state != CFG80211_SME_CONNECTED); | ||
638 | |||
639 | bss = cfg80211_get_bss(wdev->wiphy, channel, bssid, wdev->ssid, | ||
640 | wdev->ssid_len, WLAN_CAPABILITY_ESS, | ||
641 | WLAN_CAPABILITY_ESS); | ||
642 | if (WARN_ON(!bss)) | ||
643 | return; | ||
644 | |||
645 | cfg80211_roamed_bss(dev, bss, req_ie, req_ie_len, resp_ie, | ||
646 | resp_ie_len, gfp); | ||
647 | } | ||
648 | EXPORT_SYMBOL(cfg80211_roamed); | ||
649 | |||
650 | void cfg80211_roamed_bss(struct net_device *dev, | ||
651 | struct cfg80211_bss *bss, const u8 *req_ie, | ||
652 | size_t req_ie_len, const u8 *resp_ie, | ||
653 | size_t resp_ie_len, gfp_t gfp) | ||
654 | { | ||
655 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
656 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | 621 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
657 | struct cfg80211_event *ev; | 622 | struct cfg80211_event *ev; |
658 | unsigned long flags; | 623 | unsigned long flags; |
659 | 624 | ||
660 | CFG80211_DEV_WARN_ON(wdev->sme_state != CFG80211_SME_CONNECTED); | 625 | CFG80211_DEV_WARN_ON(wdev->sme_state != CFG80211_SME_CONNECTED); |
661 | 626 | ||
662 | if (WARN_ON(!bss)) | ||
663 | return; | ||
664 | |||
665 | ev = kzalloc(sizeof(*ev) + req_ie_len + resp_ie_len, gfp); | 627 | ev = kzalloc(sizeof(*ev) + req_ie_len + resp_ie_len, gfp); |
666 | if (!ev) { | 628 | if (!ev) |
667 | cfg80211_put_bss(bss); | ||
668 | return; | 629 | return; |
669 | } | ||
670 | 630 | ||
671 | ev->type = EVENT_ROAMED; | 631 | ev->type = EVENT_ROAMED; |
632 | ev->rm.channel = channel; | ||
633 | memcpy(ev->rm.bssid, bssid, ETH_ALEN); | ||
672 | ev->rm.req_ie = ((u8 *)ev) + sizeof(*ev); | 634 | ev->rm.req_ie = ((u8 *)ev) + sizeof(*ev); |
673 | ev->rm.req_ie_len = req_ie_len; | 635 | ev->rm.req_ie_len = req_ie_len; |
674 | memcpy((void *)ev->rm.req_ie, req_ie, req_ie_len); | 636 | memcpy((void *)ev->rm.req_ie, req_ie, req_ie_len); |
675 | ev->rm.resp_ie = ((u8 *)ev) + sizeof(*ev) + req_ie_len; | 637 | ev->rm.resp_ie = ((u8 *)ev) + sizeof(*ev) + req_ie_len; |
676 | ev->rm.resp_ie_len = resp_ie_len; | 638 | ev->rm.resp_ie_len = resp_ie_len; |
677 | memcpy((void *)ev->rm.resp_ie, resp_ie, resp_ie_len); | 639 | memcpy((void *)ev->rm.resp_ie, resp_ie, resp_ie_len); |
678 | ev->rm.bss = bss; | ||
679 | 640 | ||
680 | spin_lock_irqsave(&wdev->event_lock, flags); | 641 | spin_lock_irqsave(&wdev->event_lock, flags); |
681 | list_add_tail(&ev->list, &wdev->event_list); | 642 | list_add_tail(&ev->list, &wdev->event_list); |
682 | spin_unlock_irqrestore(&wdev->event_lock, flags); | 643 | spin_unlock_irqrestore(&wdev->event_lock, flags); |
683 | queue_work(cfg80211_wq, &rdev->event_work); | 644 | queue_work(cfg80211_wq, &rdev->event_work); |
684 | } | 645 | } |
685 | EXPORT_SYMBOL(cfg80211_roamed_bss); | 646 | EXPORT_SYMBOL(cfg80211_roamed); |
686 | 647 | ||
687 | void __cfg80211_disconnected(struct net_device *dev, const u8 *ie, | 648 | void __cfg80211_disconnected(struct net_device *dev, const u8 *ie, |
688 | size_t ie_len, u16 reason, bool from_ap) | 649 | size_t ie_len, u16 reason, bool from_ap) |
@@ -700,8 +661,10 @@ void __cfg80211_disconnected(struct net_device *dev, const u8 *ie, | |||
700 | wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)) | 661 | wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)) |
701 | return; | 662 | return; |
702 | 663 | ||
664 | #ifndef CONFIG_CFG80211_ALLOW_RECONNECT | ||
703 | if (wdev->sme_state != CFG80211_SME_CONNECTED) | 665 | if (wdev->sme_state != CFG80211_SME_CONNECTED) |
704 | return; | 666 | return; |
667 | #endif | ||
705 | 668 | ||
706 | if (wdev->current_bss) { | 669 | if (wdev->current_bss) { |
707 | cfg80211_unhold_bss(wdev->current_bss); | 670 | cfg80211_unhold_bss(wdev->current_bss); |
@@ -713,10 +676,31 @@ void __cfg80211_disconnected(struct net_device *dev, const u8 *ie, | |||
713 | wdev->ssid_len = 0; | 676 | wdev->ssid_len = 0; |
714 | 677 | ||
715 | if (wdev->conn) { | 678 | if (wdev->conn) { |
679 | const u8 *bssid; | ||
680 | int ret; | ||
681 | |||
716 | kfree(wdev->conn->ie); | 682 | kfree(wdev->conn->ie); |
717 | wdev->conn->ie = NULL; | 683 | wdev->conn->ie = NULL; |
718 | kfree(wdev->conn); | 684 | kfree(wdev->conn); |
719 | wdev->conn = NULL; | 685 | wdev->conn = NULL; |
686 | |||
687 | /* | ||
688 | * If this disconnect was due to a disassoc, we | ||
689 | * we might still have an auth BSS around. For | ||
690 | * the userspace SME that's currently expected, | ||
691 | * but for the kernel SME (nl80211 CONNECT or | ||
692 | * wireless extensions) we want to clear up all | ||
693 | * state. | ||
694 | */ | ||
695 | for (i = 0; i < MAX_AUTH_BSSES; i++) { | ||
696 | if (!wdev->auth_bsses[i]) | ||
697 | continue; | ||
698 | bssid = wdev->auth_bsses[i]->pub.bssid; | ||
699 | ret = __cfg80211_mlme_deauth(rdev, dev, bssid, NULL, 0, | ||
700 | WLAN_REASON_DEAUTH_LEAVING, | ||
701 | false); | ||
702 | WARN(ret, "deauth failed: %d\n", ret); | ||
703 | } | ||
720 | } | 704 | } |
721 | 705 | ||
722 | nl80211_send_disconnected(rdev, dev, reason, ie, ie_len, from_ap); | 706 | nl80211_send_disconnected(rdev, dev, reason, ie, ie_len, from_ap); |
@@ -727,7 +711,7 @@ void __cfg80211_disconnected(struct net_device *dev, const u8 *ie, | |||
727 | */ | 711 | */ |
728 | if (rdev->ops->del_key) | 712 | if (rdev->ops->del_key) |
729 | for (i = 0; i < 6; i++) | 713 | for (i = 0; i < 6; i++) |
730 | rdev_del_key(rdev, dev, i, false, NULL); | 714 | rdev->ops->del_key(wdev->wiphy, dev, i, false, NULL); |
731 | 715 | ||
732 | #ifdef CONFIG_CFG80211_WEXT | 716 | #ifdef CONFIG_CFG80211_WEXT |
733 | memset(&wrqu, 0, sizeof(wrqu)); | 717 | memset(&wrqu, 0, sizeof(wrqu)); |
@@ -778,17 +762,18 @@ int __cfg80211_connect(struct cfg80211_registered_device *rdev, | |||
778 | 762 | ||
779 | ASSERT_WDEV_LOCK(wdev); | 763 | ASSERT_WDEV_LOCK(wdev); |
780 | 764 | ||
765 | #ifndef CONFIG_CFG80211_ALLOW_RECONNECT | ||
781 | if (wdev->sme_state != CFG80211_SME_IDLE) | 766 | if (wdev->sme_state != CFG80211_SME_IDLE) |
782 | return -EALREADY; | 767 | return -EALREADY; |
783 | 768 | ||
784 | if (WARN_ON(wdev->connect_keys)) { | 769 | if (WARN_ON(wdev->connect_keys)) { |
770 | #else | ||
771 | if (wdev->connect_keys) { | ||
772 | #endif | ||
785 | kfree(wdev->connect_keys); | 773 | kfree(wdev->connect_keys); |
786 | wdev->connect_keys = NULL; | 774 | wdev->connect_keys = NULL; |
787 | } | 775 | } |
788 | 776 | ||
789 | cfg80211_oper_and_ht_capa(&connect->ht_capa_mask, | ||
790 | rdev->wiphy.ht_capa_mod_mask); | ||
791 | |||
792 | if (connkeys && connkeys->def >= 0) { | 777 | if (connkeys && connkeys->def >= 0) { |
793 | int idx; | 778 | int idx; |
794 | u32 cipher; | 779 | u32 cipher; |
@@ -903,7 +888,7 @@ int __cfg80211_connect(struct cfg80211_registered_device *rdev, | |||
903 | } else { | 888 | } else { |
904 | wdev->sme_state = CFG80211_SME_CONNECTING; | 889 | wdev->sme_state = CFG80211_SME_CONNECTING; |
905 | wdev->connect_keys = connkeys; | 890 | wdev->connect_keys = connkeys; |
906 | err = rdev_connect(rdev, dev, connect); | 891 | err = rdev->ops->connect(&rdev->wiphy, dev, connect); |
907 | if (err) { | 892 | if (err) { |
908 | wdev->connect_keys = NULL; | 893 | wdev->connect_keys = NULL; |
909 | wdev->sme_state = CFG80211_SME_IDLE; | 894 | wdev->sme_state = CFG80211_SME_IDLE; |
@@ -975,7 +960,7 @@ int __cfg80211_disconnect(struct cfg80211_registered_device *rdev, | |||
975 | if (err) | 960 | if (err) |
976 | return err; | 961 | return err; |
977 | } else { | 962 | } else { |
978 | err = rdev_disconnect(rdev, dev, reason); | 963 | err = rdev->ops->disconnect(&rdev->wiphy, dev, reason); |
979 | if (err) | 964 | if (err) |
980 | return err; | 965 | return err; |
981 | } | 966 | } |
@@ -1003,8 +988,7 @@ int cfg80211_disconnect(struct cfg80211_registered_device *rdev, | |||
1003 | return err; | 988 | return err; |
1004 | } | 989 | } |
1005 | 990 | ||
1006 | void cfg80211_sme_disassoc(struct net_device *dev, | 991 | void cfg80211_sme_disassoc(struct net_device *dev, int idx) |
1007 | struct cfg80211_internal_bss *bss) | ||
1008 | { | 992 | { |
1009 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 993 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
1010 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | 994 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
@@ -1023,8 +1007,16 @@ void cfg80211_sme_disassoc(struct net_device *dev, | |||
1023 | * want it any more so deauthenticate too. | 1007 | * want it any more so deauthenticate too. |
1024 | */ | 1008 | */ |
1025 | 1009 | ||
1026 | memcpy(bssid, bss->pub.bssid, ETH_ALEN); | 1010 | if (!wdev->auth_bsses[idx]) |
1011 | return; | ||
1027 | 1012 | ||
1028 | __cfg80211_mlme_deauth(rdev, dev, bssid, NULL, 0, | 1013 | memcpy(bssid, wdev->auth_bsses[idx]->pub.bssid, ETH_ALEN); |
1029 | WLAN_REASON_DEAUTH_LEAVING, false); | 1014 | if (__cfg80211_mlme_deauth(rdev, dev, bssid, |
1015 | NULL, 0, WLAN_REASON_DEAUTH_LEAVING, | ||
1016 | false)) { | ||
1017 | /* whatever -- assume gone anyway */ | ||
1018 | cfg80211_unhold_bss(wdev->auth_bsses[idx]); | ||
1019 | cfg80211_put_bss(&wdev->auth_bsses[idx]->pub); | ||
1020 | wdev->auth_bsses[idx] = NULL; | ||
1021 | } | ||
1030 | } | 1022 | } |
diff --git a/net/wireless/sysfs.c b/net/wireless/sysfs.c index 1f6f01e2dc4..ff574597a85 100644 --- a/net/wireless/sysfs.c +++ b/net/wireless/sysfs.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <net/cfg80211.h> | 16 | #include <net/cfg80211.h> |
17 | #include "sysfs.h" | 17 | #include "sysfs.h" |
18 | #include "core.h" | 18 | #include "core.h" |
19 | #include "rdev-ops.h" | ||
20 | 19 | ||
21 | static inline struct cfg80211_registered_device *dev_to_rdev( | 20 | static inline struct cfg80211_registered_device *dev_to_rdev( |
22 | struct device *dev) | 21 | struct device *dev) |
@@ -77,11 +76,13 @@ static void wiphy_dev_release(struct device *dev) | |||
77 | cfg80211_dev_free(rdev); | 76 | cfg80211_dev_free(rdev); |
78 | } | 77 | } |
79 | 78 | ||
79 | #ifdef CONFIG_HOTPLUG | ||
80 | static int wiphy_uevent(struct device *dev, struct kobj_uevent_env *env) | 80 | static int wiphy_uevent(struct device *dev, struct kobj_uevent_env *env) |
81 | { | 81 | { |
82 | /* TODO, we probably need stuff here */ | 82 | /* TODO, we probably need stuff here */ |
83 | return 0; | 83 | return 0; |
84 | } | 84 | } |
85 | #endif | ||
85 | 86 | ||
86 | static int wiphy_suspend(struct device *dev, pm_message_t state) | 87 | static int wiphy_suspend(struct device *dev, pm_message_t state) |
87 | { | 88 | { |
@@ -93,7 +94,7 @@ static int wiphy_suspend(struct device *dev, pm_message_t state) | |||
93 | if (rdev->ops->suspend) { | 94 | if (rdev->ops->suspend) { |
94 | rtnl_lock(); | 95 | rtnl_lock(); |
95 | if (rdev->wiphy.registered) | 96 | if (rdev->wiphy.registered) |
96 | ret = rdev_suspend(rdev); | 97 | ret = rdev->ops->suspend(&rdev->wiphy, rdev->wowlan); |
97 | rtnl_unlock(); | 98 | rtnl_unlock(); |
98 | } | 99 | } |
99 | 100 | ||
@@ -113,7 +114,7 @@ static int wiphy_resume(struct device *dev) | |||
113 | if (rdev->ops->resume) { | 114 | if (rdev->ops->resume) { |
114 | rtnl_lock(); | 115 | rtnl_lock(); |
115 | if (rdev->wiphy.registered) | 116 | if (rdev->wiphy.registered) |
116 | ret = rdev_resume(rdev); | 117 | ret = rdev->ops->resume(&rdev->wiphy); |
117 | rtnl_unlock(); | 118 | rtnl_unlock(); |
118 | } | 119 | } |
119 | 120 | ||
@@ -132,7 +133,9 @@ struct class ieee80211_class = { | |||
132 | .owner = THIS_MODULE, | 133 | .owner = THIS_MODULE, |
133 | .dev_release = wiphy_dev_release, | 134 | .dev_release = wiphy_dev_release, |
134 | .dev_attrs = ieee80211_dev_attrs, | 135 | .dev_attrs = ieee80211_dev_attrs, |
136 | #ifdef CONFIG_HOTPLUG | ||
135 | .dev_uevent = wiphy_uevent, | 137 | .dev_uevent = wiphy_uevent, |
138 | #endif | ||
136 | .suspend = wiphy_suspend, | 139 | .suspend = wiphy_suspend, |
137 | .resume = wiphy_resume, | 140 | .resume = wiphy_resume, |
138 | .ns_type = &net_ns_type_operations, | 141 | .ns_type = &net_ns_type_operations, |
diff --git a/net/wireless/trace.c b/net/wireless/trace.c deleted file mode 100644 index 95f997fad75..00000000000 --- a/net/wireless/trace.c +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | #include <linux/module.h> | ||
2 | |||
3 | #ifndef __CHECKER__ | ||
4 | #define CREATE_TRACE_POINTS | ||
5 | #include "trace.h" | ||
6 | |||
7 | #endif | ||
diff --git a/net/wireless/trace.h b/net/wireless/trace.h deleted file mode 100644 index 2134576f426..00000000000 --- a/net/wireless/trace.h +++ /dev/null | |||
@@ -1,2324 +0,0 @@ | |||
1 | #undef TRACE_SYSTEM | ||
2 | #define TRACE_SYSTEM cfg80211 | ||
3 | |||
4 | #if !defined(__RDEV_OPS_TRACE) || defined(TRACE_HEADER_MULTI_READ) | ||
5 | #define __RDEV_OPS_TRACE | ||
6 | |||
7 | #include <linux/tracepoint.h> | ||
8 | |||
9 | #include <linux/rtnetlink.h> | ||
10 | #include <net/cfg80211.h> | ||
11 | #include "core.h" | ||
12 | |||
13 | #define MAC_ENTRY(entry_mac) __array(u8, entry_mac, ETH_ALEN) | ||
14 | #define MAC_ASSIGN(entry_mac, given_mac) do { \ | ||
15 | if (given_mac) \ | ||
16 | memcpy(__entry->entry_mac, given_mac, ETH_ALEN); \ | ||
17 | else \ | ||
18 | memset(__entry->entry_mac, 0, ETH_ALEN); \ | ||
19 | } while (0) | ||
20 | #define MAC_PR_FMT "%pM" | ||
21 | #define MAC_PR_ARG(entry_mac) (__entry->entry_mac) | ||
22 | |||
23 | #define MAXNAME 32 | ||
24 | #define WIPHY_ENTRY __array(char, wiphy_name, 32) | ||
25 | #define WIPHY_ASSIGN strlcpy(__entry->wiphy_name, wiphy_name(wiphy), MAXNAME) | ||
26 | #define WIPHY_PR_FMT "%s" | ||
27 | #define WIPHY_PR_ARG __entry->wiphy_name | ||
28 | |||
29 | #define WDEV_ENTRY __field(u32, id) | ||
30 | #define WDEV_ASSIGN (__entry->id) = (wdev ? wdev->identifier : 0) | ||
31 | #define WDEV_PR_FMT "wdev(%u)" | ||
32 | #define WDEV_PR_ARG (__entry->id) | ||
33 | |||
34 | #define NETDEV_ENTRY __array(char, name, IFNAMSIZ) \ | ||
35 | __field(int, ifindex) | ||
36 | #define NETDEV_ASSIGN \ | ||
37 | do { \ | ||
38 | memcpy(__entry->name, netdev->name, IFNAMSIZ); \ | ||
39 | (__entry->ifindex) = (netdev->ifindex); \ | ||
40 | } while (0) | ||
41 | #define NETDEV_PR_FMT "netdev:%s(%d)" | ||
42 | #define NETDEV_PR_ARG __entry->name, __entry->ifindex | ||
43 | |||
44 | #define MESH_CFG_ENTRY __field(u16, dot11MeshRetryTimeout) \ | ||
45 | __field(u16, dot11MeshConfirmTimeout) \ | ||
46 | __field(u16, dot11MeshHoldingTimeout) \ | ||
47 | __field(u16, dot11MeshMaxPeerLinks) \ | ||
48 | __field(u8, dot11MeshMaxRetries) \ | ||
49 | __field(u8, dot11MeshTTL) \ | ||
50 | __field(u8, element_ttl) \ | ||
51 | __field(bool, auto_open_plinks) \ | ||
52 | __field(u32, dot11MeshNbrOffsetMaxNeighbor) \ | ||
53 | __field(u8, dot11MeshHWMPmaxPREQretries) \ | ||
54 | __field(u32, path_refresh_time) \ | ||
55 | __field(u32, dot11MeshHWMPactivePathTimeout) \ | ||
56 | __field(u16, min_discovery_timeout) \ | ||
57 | __field(u16, dot11MeshHWMPpreqMinInterval) \ | ||
58 | __field(u16, dot11MeshHWMPperrMinInterval) \ | ||
59 | __field(u16, dot11MeshHWMPnetDiameterTraversalTime) \ | ||
60 | __field(u8, dot11MeshHWMPRootMode) \ | ||
61 | __field(u16, dot11MeshHWMPRannInterval) \ | ||
62 | __field(bool, dot11MeshGateAnnouncementProtocol) \ | ||
63 | __field(bool, dot11MeshForwarding) \ | ||
64 | __field(s32, rssi_threshold) \ | ||
65 | __field(u16, ht_opmode) \ | ||
66 | __field(u32, dot11MeshHWMPactivePathToRootTimeout) \ | ||
67 | __field(u16, dot11MeshHWMProotInterval) \ | ||
68 | __field(u16, dot11MeshHWMPconfirmationInterval) | ||
69 | #define MESH_CFG_ASSIGN \ | ||
70 | do { \ | ||
71 | __entry->dot11MeshRetryTimeout = conf->dot11MeshRetryTimeout; \ | ||
72 | __entry->dot11MeshConfirmTimeout = \ | ||
73 | conf->dot11MeshConfirmTimeout; \ | ||
74 | __entry->dot11MeshHoldingTimeout = \ | ||
75 | conf->dot11MeshHoldingTimeout; \ | ||
76 | __entry->dot11MeshMaxPeerLinks = conf->dot11MeshMaxPeerLinks; \ | ||
77 | __entry->dot11MeshMaxRetries = conf->dot11MeshMaxRetries; \ | ||
78 | __entry->dot11MeshTTL = conf->dot11MeshTTL; \ | ||
79 | __entry->element_ttl = conf->element_ttl; \ | ||
80 | __entry->auto_open_plinks = conf->auto_open_plinks; \ | ||
81 | __entry->dot11MeshNbrOffsetMaxNeighbor = \ | ||
82 | conf->dot11MeshNbrOffsetMaxNeighbor; \ | ||
83 | __entry->dot11MeshHWMPmaxPREQretries = \ | ||
84 | conf->dot11MeshHWMPmaxPREQretries; \ | ||
85 | __entry->path_refresh_time = conf->path_refresh_time; \ | ||
86 | __entry->dot11MeshHWMPactivePathTimeout = \ | ||
87 | conf->dot11MeshHWMPactivePathTimeout; \ | ||
88 | __entry->min_discovery_timeout = conf->min_discovery_timeout; \ | ||
89 | __entry->dot11MeshHWMPpreqMinInterval = \ | ||
90 | conf->dot11MeshHWMPpreqMinInterval; \ | ||
91 | __entry->dot11MeshHWMPperrMinInterval = \ | ||
92 | conf->dot11MeshHWMPperrMinInterval; \ | ||
93 | __entry->dot11MeshHWMPnetDiameterTraversalTime = \ | ||
94 | conf->dot11MeshHWMPnetDiameterTraversalTime; \ | ||
95 | __entry->dot11MeshHWMPRootMode = conf->dot11MeshHWMPRootMode; \ | ||
96 | __entry->dot11MeshHWMPRannInterval = \ | ||
97 | conf->dot11MeshHWMPRannInterval; \ | ||
98 | __entry->dot11MeshGateAnnouncementProtocol = \ | ||
99 | conf->dot11MeshGateAnnouncementProtocol; \ | ||
100 | __entry->dot11MeshForwarding = conf->dot11MeshForwarding; \ | ||
101 | __entry->rssi_threshold = conf->rssi_threshold; \ | ||
102 | __entry->ht_opmode = conf->ht_opmode; \ | ||
103 | __entry->dot11MeshHWMPactivePathToRootTimeout = \ | ||
104 | conf->dot11MeshHWMPactivePathToRootTimeout; \ | ||
105 | __entry->dot11MeshHWMProotInterval = \ | ||
106 | conf->dot11MeshHWMProotInterval; \ | ||
107 | __entry->dot11MeshHWMPconfirmationInterval = \ | ||
108 | conf->dot11MeshHWMPconfirmationInterval; \ | ||
109 | } while (0) | ||
110 | |||
111 | #define CHAN_ENTRY __field(enum ieee80211_band, band) \ | ||
112 | __field(u16, center_freq) | ||
113 | #define CHAN_ASSIGN(chan) \ | ||
114 | do { \ | ||
115 | if (chan) { \ | ||
116 | __entry->band = chan->band; \ | ||
117 | __entry->center_freq = chan->center_freq; \ | ||
118 | } else { \ | ||
119 | __entry->band = 0; \ | ||
120 | __entry->center_freq = 0; \ | ||
121 | } \ | ||
122 | } while (0) | ||
123 | #define CHAN_PR_FMT "band: %d, freq: %u" | ||
124 | #define CHAN_PR_ARG __entry->band, __entry->center_freq | ||
125 | |||
126 | #define CHAN_DEF_ENTRY __field(enum ieee80211_band, band) \ | ||
127 | __field(u32, control_freq) \ | ||
128 | __field(u32, width) \ | ||
129 | __field(u32, center_freq1) \ | ||
130 | __field(u32, center_freq2) | ||
131 | #define CHAN_DEF_ASSIGN(chandef) \ | ||
132 | do { \ | ||
133 | if ((chandef) && (chandef)->chan) { \ | ||
134 | __entry->band = (chandef)->chan->band; \ | ||
135 | __entry->control_freq = \ | ||
136 | (chandef)->chan->center_freq; \ | ||
137 | __entry->width = (chandef)->width; \ | ||
138 | __entry->center_freq1 = (chandef)->center_freq1;\ | ||
139 | __entry->center_freq2 = (chandef)->center_freq2;\ | ||
140 | } else { \ | ||
141 | __entry->band = 0; \ | ||
142 | __entry->control_freq = 0; \ | ||
143 | __entry->width = 0; \ | ||
144 | __entry->center_freq1 = 0; \ | ||
145 | __entry->center_freq2 = 0; \ | ||
146 | } \ | ||
147 | } while (0) | ||
148 | #define CHAN_DEF_PR_FMT \ | ||
149 | "band: %d, control freq: %u, width: %d, cf1: %u, cf2: %u" | ||
150 | #define CHAN_DEF_PR_ARG __entry->band, __entry->control_freq, \ | ||
151 | __entry->width, __entry->center_freq1, \ | ||
152 | __entry->center_freq2 | ||
153 | |||
154 | #define SINFO_ENTRY __field(int, generation) \ | ||
155 | __field(u32, connected_time) \ | ||
156 | __field(u32, inactive_time) \ | ||
157 | __field(u32, rx_bytes) \ | ||
158 | __field(u32, tx_bytes) \ | ||
159 | __field(u32, rx_packets) \ | ||
160 | __field(u32, tx_packets) \ | ||
161 | __field(u32, tx_retries) \ | ||
162 | __field(u32, tx_failed) \ | ||
163 | __field(u32, rx_dropped_misc) \ | ||
164 | __field(u32, beacon_loss_count) \ | ||
165 | __field(u16, llid) \ | ||
166 | __field(u16, plid) \ | ||
167 | __field(u8, plink_state) | ||
168 | #define SINFO_ASSIGN \ | ||
169 | do { \ | ||
170 | __entry->generation = sinfo->generation; \ | ||
171 | __entry->connected_time = sinfo->connected_time; \ | ||
172 | __entry->inactive_time = sinfo->inactive_time; \ | ||
173 | __entry->rx_bytes = sinfo->rx_bytes; \ | ||
174 | __entry->tx_bytes = sinfo->tx_bytes; \ | ||
175 | __entry->rx_packets = sinfo->rx_packets; \ | ||
176 | __entry->tx_packets = sinfo->tx_packets; \ | ||
177 | __entry->tx_retries = sinfo->tx_retries; \ | ||
178 | __entry->tx_failed = sinfo->tx_failed; \ | ||
179 | __entry->rx_dropped_misc = sinfo->rx_dropped_misc; \ | ||
180 | __entry->beacon_loss_count = sinfo->beacon_loss_count; \ | ||
181 | __entry->llid = sinfo->llid; \ | ||
182 | __entry->plid = sinfo->plid; \ | ||
183 | __entry->plink_state = sinfo->plink_state; \ | ||
184 | } while (0) | ||
185 | |||
186 | #define BOOL_TO_STR(bo) (bo) ? "true" : "false" | ||
187 | |||
188 | /************************************************************* | ||
189 | * rdev->ops traces * | ||
190 | *************************************************************/ | ||
191 | |||
192 | TRACE_EVENT(rdev_suspend, | ||
193 | TP_PROTO(struct wiphy *wiphy, struct cfg80211_wowlan *wow), | ||
194 | TP_ARGS(wiphy, wow), | ||
195 | TP_STRUCT__entry( | ||
196 | WIPHY_ENTRY | ||
197 | __field(bool, any) | ||
198 | __field(bool, disconnect) | ||
199 | __field(bool, magic_pkt) | ||
200 | __field(bool, gtk_rekey_failure) | ||
201 | __field(bool, eap_identity_req) | ||
202 | __field(bool, four_way_handshake) | ||
203 | __field(bool, rfkill_release) | ||
204 | __field(bool, valid_wow) | ||
205 | ), | ||
206 | TP_fast_assign( | ||
207 | WIPHY_ASSIGN; | ||
208 | if (wow) { | ||
209 | __entry->any = wow->any; | ||
210 | __entry->disconnect = wow->disconnect; | ||
211 | __entry->magic_pkt = wow->magic_pkt; | ||
212 | __entry->gtk_rekey_failure = wow->gtk_rekey_failure; | ||
213 | __entry->eap_identity_req = wow->eap_identity_req; | ||
214 | __entry->four_way_handshake = wow->four_way_handshake; | ||
215 | __entry->rfkill_release = wow->rfkill_release; | ||
216 | __entry->valid_wow = true; | ||
217 | } else { | ||
218 | __entry->valid_wow = false; | ||
219 | } | ||
220 | ), | ||
221 | TP_printk(WIPHY_PR_FMT ", wow%s - any: %d, disconnect: %d, " | ||
222 | "magic pkt: %d, gtk rekey failure: %d, eap identify req: %d, " | ||
223 | "four way handshake: %d, rfkill release: %d.", | ||
224 | WIPHY_PR_ARG, __entry->valid_wow ? "" : "(Not configured!)", | ||
225 | __entry->any, __entry->disconnect, __entry->magic_pkt, | ||
226 | __entry->gtk_rekey_failure, __entry->eap_identity_req, | ||
227 | __entry->four_way_handshake, __entry->rfkill_release) | ||
228 | ); | ||
229 | |||
230 | TRACE_EVENT(rdev_return_int, | ||
231 | TP_PROTO(struct wiphy *wiphy, int ret), | ||
232 | TP_ARGS(wiphy, ret), | ||
233 | TP_STRUCT__entry( | ||
234 | WIPHY_ENTRY | ||
235 | __field(int, ret) | ||
236 | ), | ||
237 | TP_fast_assign( | ||
238 | WIPHY_ASSIGN; | ||
239 | __entry->ret = ret; | ||
240 | ), | ||
241 | TP_printk(WIPHY_PR_FMT ", returned: %d", WIPHY_PR_ARG, __entry->ret) | ||
242 | ); | ||
243 | |||
244 | TRACE_EVENT(rdev_scan, | ||
245 | TP_PROTO(struct wiphy *wiphy, struct cfg80211_scan_request *request), | ||
246 | TP_ARGS(wiphy, request), | ||
247 | TP_STRUCT__entry( | ||
248 | WIPHY_ENTRY | ||
249 | ), | ||
250 | TP_fast_assign( | ||
251 | WIPHY_ASSIGN; | ||
252 | ), | ||
253 | TP_printk(WIPHY_PR_FMT, WIPHY_PR_ARG) | ||
254 | ); | ||
255 | |||
256 | DECLARE_EVENT_CLASS(wiphy_only_evt, | ||
257 | TP_PROTO(struct wiphy *wiphy), | ||
258 | TP_ARGS(wiphy), | ||
259 | TP_STRUCT__entry( | ||
260 | WIPHY_ENTRY | ||
261 | ), | ||
262 | TP_fast_assign( | ||
263 | WIPHY_ASSIGN; | ||
264 | ), | ||
265 | TP_printk(WIPHY_PR_FMT, WIPHY_PR_ARG) | ||
266 | ); | ||
267 | |||
268 | DEFINE_EVENT(wiphy_only_evt, rdev_resume, | ||
269 | TP_PROTO(struct wiphy *wiphy), | ||
270 | TP_ARGS(wiphy) | ||
271 | ); | ||
272 | |||
273 | DEFINE_EVENT(wiphy_only_evt, rdev_return_void, | ||
274 | TP_PROTO(struct wiphy *wiphy), | ||
275 | TP_ARGS(wiphy) | ||
276 | ); | ||
277 | |||
278 | DEFINE_EVENT(wiphy_only_evt, rdev_get_ringparam, | ||
279 | TP_PROTO(struct wiphy *wiphy), | ||
280 | TP_ARGS(wiphy) | ||
281 | ); | ||
282 | |||
283 | DEFINE_EVENT(wiphy_only_evt, rdev_get_antenna, | ||
284 | TP_PROTO(struct wiphy *wiphy), | ||
285 | TP_ARGS(wiphy) | ||
286 | ); | ||
287 | |||
288 | DEFINE_EVENT(wiphy_only_evt, rdev_rfkill_poll, | ||
289 | TP_PROTO(struct wiphy *wiphy), | ||
290 | TP_ARGS(wiphy) | ||
291 | ); | ||
292 | |||
293 | DECLARE_EVENT_CLASS(wiphy_enabled_evt, | ||
294 | TP_PROTO(struct wiphy *wiphy, bool enabled), | ||
295 | TP_ARGS(wiphy, enabled), | ||
296 | TP_STRUCT__entry( | ||
297 | WIPHY_ENTRY | ||
298 | __field(bool, enabled) | ||
299 | ), | ||
300 | TP_fast_assign( | ||
301 | WIPHY_ASSIGN; | ||
302 | __entry->enabled = enabled; | ||
303 | ), | ||
304 | TP_printk(WIPHY_PR_FMT ", %senabled ", | ||
305 | WIPHY_PR_ARG, __entry->enabled ? "" : "not ") | ||
306 | ); | ||
307 | |||
308 | DEFINE_EVENT(wiphy_enabled_evt, rdev_set_wakeup, | ||
309 | TP_PROTO(struct wiphy *wiphy, bool enabled), | ||
310 | TP_ARGS(wiphy, enabled) | ||
311 | ); | ||
312 | |||
313 | TRACE_EVENT(rdev_add_virtual_intf, | ||
314 | TP_PROTO(struct wiphy *wiphy, char *name, enum nl80211_iftype type), | ||
315 | TP_ARGS(wiphy, name, type), | ||
316 | TP_STRUCT__entry( | ||
317 | WIPHY_ENTRY | ||
318 | __string(vir_intf_name, name ? name : "<noname>") | ||
319 | __field(enum nl80211_iftype, type) | ||
320 | ), | ||
321 | TP_fast_assign( | ||
322 | WIPHY_ASSIGN; | ||
323 | __assign_str(vir_intf_name, name ? name : "<noname>"); | ||
324 | __entry->type = type; | ||
325 | ), | ||
326 | TP_printk(WIPHY_PR_FMT ", virtual intf name: %s, type: %d", | ||
327 | WIPHY_PR_ARG, __get_str(vir_intf_name), __entry->type) | ||
328 | ); | ||
329 | |||
330 | DECLARE_EVENT_CLASS(wiphy_wdev_evt, | ||
331 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev), | ||
332 | TP_ARGS(wiphy, wdev), | ||
333 | TP_STRUCT__entry( | ||
334 | WIPHY_ENTRY | ||
335 | WDEV_ENTRY | ||
336 | ), | ||
337 | TP_fast_assign( | ||
338 | WIPHY_ASSIGN; | ||
339 | WDEV_ASSIGN; | ||
340 | ), | ||
341 | TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT, WIPHY_PR_ARG, WDEV_PR_ARG) | ||
342 | ); | ||
343 | |||
344 | DEFINE_EVENT(wiphy_wdev_evt, rdev_return_wdev, | ||
345 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev), | ||
346 | TP_ARGS(wiphy, wdev) | ||
347 | ); | ||
348 | |||
349 | DEFINE_EVENT(wiphy_wdev_evt, rdev_del_virtual_intf, | ||
350 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev), | ||
351 | TP_ARGS(wiphy, wdev) | ||
352 | ); | ||
353 | |||
354 | TRACE_EVENT(rdev_change_virtual_intf, | ||
355 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
356 | enum nl80211_iftype type), | ||
357 | TP_ARGS(wiphy, netdev, type), | ||
358 | TP_STRUCT__entry( | ||
359 | WIPHY_ENTRY | ||
360 | NETDEV_ENTRY | ||
361 | __field(enum nl80211_iftype, type) | ||
362 | ), | ||
363 | TP_fast_assign( | ||
364 | WIPHY_ASSIGN; | ||
365 | NETDEV_ASSIGN; | ||
366 | __entry->type = type; | ||
367 | ), | ||
368 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", type: %d", | ||
369 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->type) | ||
370 | ); | ||
371 | |||
372 | DECLARE_EVENT_CLASS(key_handle, | ||
373 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, | ||
374 | bool pairwise, const u8 *mac_addr), | ||
375 | TP_ARGS(wiphy, netdev, key_index, pairwise, mac_addr), | ||
376 | TP_STRUCT__entry( | ||
377 | WIPHY_ENTRY | ||
378 | NETDEV_ENTRY | ||
379 | MAC_ENTRY(mac_addr) | ||
380 | __field(u8, key_index) | ||
381 | __field(bool, pairwise) | ||
382 | ), | ||
383 | TP_fast_assign( | ||
384 | WIPHY_ASSIGN; | ||
385 | NETDEV_ASSIGN; | ||
386 | MAC_ASSIGN(mac_addr, mac_addr); | ||
387 | __entry->key_index = key_index; | ||
388 | __entry->pairwise = pairwise; | ||
389 | ), | ||
390 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", key_index: %u, pairwise: %s, mac addr: " MAC_PR_FMT, | ||
391 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->key_index, | ||
392 | BOOL_TO_STR(__entry->pairwise), MAC_PR_ARG(mac_addr)) | ||
393 | ); | ||
394 | |||
395 | DEFINE_EVENT(key_handle, rdev_add_key, | ||
396 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, | ||
397 | bool pairwise, const u8 *mac_addr), | ||
398 | TP_ARGS(wiphy, netdev, key_index, pairwise, mac_addr) | ||
399 | ); | ||
400 | |||
401 | DEFINE_EVENT(key_handle, rdev_get_key, | ||
402 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, | ||
403 | bool pairwise, const u8 *mac_addr), | ||
404 | TP_ARGS(wiphy, netdev, key_index, pairwise, mac_addr) | ||
405 | ); | ||
406 | |||
407 | DEFINE_EVENT(key_handle, rdev_del_key, | ||
408 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, | ||
409 | bool pairwise, const u8 *mac_addr), | ||
410 | TP_ARGS(wiphy, netdev, key_index, pairwise, mac_addr) | ||
411 | ); | ||
412 | |||
413 | TRACE_EVENT(rdev_set_default_key, | ||
414 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, | ||
415 | bool unicast, bool multicast), | ||
416 | TP_ARGS(wiphy, netdev, key_index, unicast, multicast), | ||
417 | TP_STRUCT__entry( | ||
418 | WIPHY_ENTRY | ||
419 | NETDEV_ENTRY | ||
420 | __field(u8, key_index) | ||
421 | __field(bool, unicast) | ||
422 | __field(bool, multicast) | ||
423 | ), | ||
424 | TP_fast_assign( | ||
425 | WIPHY_ASSIGN; | ||
426 | NETDEV_ASSIGN; | ||
427 | __entry->key_index = key_index; | ||
428 | __entry->unicast = unicast; | ||
429 | __entry->multicast = multicast; | ||
430 | ), | ||
431 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", key index: %u, unicast: %s, multicast: %s", | ||
432 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->key_index, | ||
433 | BOOL_TO_STR(__entry->unicast), | ||
434 | BOOL_TO_STR(__entry->multicast)) | ||
435 | ); | ||
436 | |||
437 | TRACE_EVENT(rdev_set_default_mgmt_key, | ||
438 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 key_index), | ||
439 | TP_ARGS(wiphy, netdev, key_index), | ||
440 | TP_STRUCT__entry( | ||
441 | WIPHY_ENTRY | ||
442 | NETDEV_ENTRY | ||
443 | __field(u8, key_index) | ||
444 | ), | ||
445 | TP_fast_assign( | ||
446 | WIPHY_ASSIGN; | ||
447 | NETDEV_ASSIGN; | ||
448 | __entry->key_index = key_index; | ||
449 | ), | ||
450 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", key index: %u", | ||
451 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->key_index) | ||
452 | ); | ||
453 | |||
454 | TRACE_EVENT(rdev_start_ap, | ||
455 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
456 | struct cfg80211_ap_settings *settings), | ||
457 | TP_ARGS(wiphy, netdev, settings), | ||
458 | TP_STRUCT__entry( | ||
459 | WIPHY_ENTRY | ||
460 | NETDEV_ENTRY | ||
461 | CHAN_DEF_ENTRY | ||
462 | __field(int, beacon_interval) | ||
463 | __field(int, dtim_period) | ||
464 | __array(char, ssid, IEEE80211_MAX_SSID_LEN + 1) | ||
465 | __field(enum nl80211_hidden_ssid, hidden_ssid) | ||
466 | __field(u32, wpa_ver) | ||
467 | __field(bool, privacy) | ||
468 | __field(enum nl80211_auth_type, auth_type) | ||
469 | __field(int, inactivity_timeout) | ||
470 | ), | ||
471 | TP_fast_assign( | ||
472 | WIPHY_ASSIGN; | ||
473 | NETDEV_ASSIGN; | ||
474 | CHAN_DEF_ASSIGN(&settings->chandef); | ||
475 | __entry->beacon_interval = settings->beacon_interval; | ||
476 | __entry->dtim_period = settings->dtim_period; | ||
477 | __entry->hidden_ssid = settings->hidden_ssid; | ||
478 | __entry->wpa_ver = settings->crypto.wpa_versions; | ||
479 | __entry->privacy = settings->privacy; | ||
480 | __entry->auth_type = settings->auth_type; | ||
481 | __entry->inactivity_timeout = settings->inactivity_timeout; | ||
482 | memset(__entry->ssid, 0, IEEE80211_MAX_SSID_LEN + 1); | ||
483 | memcpy(__entry->ssid, settings->ssid, settings->ssid_len); | ||
484 | ), | ||
485 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", AP settings - ssid: %s, " | ||
486 | CHAN_DEF_PR_FMT ", beacon interval: %d, dtim period: %d, " | ||
487 | "hidden ssid: %d, wpa versions: %u, privacy: %s, " | ||
488 | "auth type: %d, inactivity timeout: %d", | ||
489 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->ssid, CHAN_DEF_PR_ARG, | ||
490 | __entry->beacon_interval, __entry->dtim_period, | ||
491 | __entry->hidden_ssid, __entry->wpa_ver, | ||
492 | BOOL_TO_STR(__entry->privacy), __entry->auth_type, | ||
493 | __entry->inactivity_timeout) | ||
494 | ); | ||
495 | |||
496 | TRACE_EVENT(rdev_change_beacon, | ||
497 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
498 | struct cfg80211_beacon_data *info), | ||
499 | TP_ARGS(wiphy, netdev, info), | ||
500 | TP_STRUCT__entry( | ||
501 | WIPHY_ENTRY | ||
502 | NETDEV_ENTRY | ||
503 | __dynamic_array(u8, head, info ? info->head_len : 0) | ||
504 | __dynamic_array(u8, tail, info ? info->tail_len : 0) | ||
505 | __dynamic_array(u8, beacon_ies, info ? info->beacon_ies_len : 0) | ||
506 | __dynamic_array(u8, proberesp_ies, | ||
507 | info ? info->proberesp_ies_len : 0) | ||
508 | __dynamic_array(u8, assocresp_ies, | ||
509 | info ? info->assocresp_ies_len : 0) | ||
510 | __dynamic_array(u8, probe_resp, info ? info->probe_resp_len : 0) | ||
511 | ), | ||
512 | TP_fast_assign( | ||
513 | WIPHY_ASSIGN; | ||
514 | NETDEV_ASSIGN; | ||
515 | if (info) { | ||
516 | if (info->head) | ||
517 | memcpy(__get_dynamic_array(head), info->head, | ||
518 | info->head_len); | ||
519 | if (info->tail) | ||
520 | memcpy(__get_dynamic_array(tail), info->tail, | ||
521 | info->tail_len); | ||
522 | if (info->beacon_ies) | ||
523 | memcpy(__get_dynamic_array(beacon_ies), | ||
524 | info->beacon_ies, info->beacon_ies_len); | ||
525 | if (info->proberesp_ies) | ||
526 | memcpy(__get_dynamic_array(proberesp_ies), | ||
527 | info->proberesp_ies, | ||
528 | info->proberesp_ies_len); | ||
529 | if (info->assocresp_ies) | ||
530 | memcpy(__get_dynamic_array(assocresp_ies), | ||
531 | info->assocresp_ies, | ||
532 | info->assocresp_ies_len); | ||
533 | if (info->probe_resp) | ||
534 | memcpy(__get_dynamic_array(probe_resp), | ||
535 | info->probe_resp, info->probe_resp_len); | ||
536 | } | ||
537 | ), | ||
538 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT, WIPHY_PR_ARG, NETDEV_PR_ARG) | ||
539 | ); | ||
540 | |||
541 | DECLARE_EVENT_CLASS(wiphy_netdev_evt, | ||
542 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev), | ||
543 | TP_ARGS(wiphy, netdev), | ||
544 | TP_STRUCT__entry( | ||
545 | WIPHY_ENTRY | ||
546 | NETDEV_ENTRY | ||
547 | ), | ||
548 | TP_fast_assign( | ||
549 | WIPHY_ASSIGN; | ||
550 | NETDEV_ASSIGN; | ||
551 | ), | ||
552 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT, WIPHY_PR_ARG, NETDEV_PR_ARG) | ||
553 | ); | ||
554 | |||
555 | DEFINE_EVENT(wiphy_netdev_evt, rdev_stop_ap, | ||
556 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev), | ||
557 | TP_ARGS(wiphy, netdev) | ||
558 | ); | ||
559 | |||
560 | DEFINE_EVENT(wiphy_netdev_evt, rdev_get_et_stats, | ||
561 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev), | ||
562 | TP_ARGS(wiphy, netdev) | ||
563 | ); | ||
564 | |||
565 | DEFINE_EVENT(wiphy_netdev_evt, rdev_sched_scan_stop, | ||
566 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev), | ||
567 | TP_ARGS(wiphy, netdev) | ||
568 | ); | ||
569 | |||
570 | DEFINE_EVENT(wiphy_netdev_evt, rdev_set_rekey_data, | ||
571 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev), | ||
572 | TP_ARGS(wiphy, netdev) | ||
573 | ); | ||
574 | |||
575 | DEFINE_EVENT(wiphy_netdev_evt, rdev_get_mesh_config, | ||
576 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev), | ||
577 | TP_ARGS(wiphy, netdev) | ||
578 | ); | ||
579 | |||
580 | DEFINE_EVENT(wiphy_netdev_evt, rdev_leave_mesh, | ||
581 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev), | ||
582 | TP_ARGS(wiphy, netdev) | ||
583 | ); | ||
584 | |||
585 | DEFINE_EVENT(wiphy_netdev_evt, rdev_leave_ibss, | ||
586 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev), | ||
587 | TP_ARGS(wiphy, netdev) | ||
588 | ); | ||
589 | |||
590 | DEFINE_EVENT(wiphy_netdev_evt, rdev_flush_pmksa, | ||
591 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev), | ||
592 | TP_ARGS(wiphy, netdev) | ||
593 | ); | ||
594 | |||
595 | DECLARE_EVENT_CLASS(station_add_change, | ||
596 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *mac, | ||
597 | struct station_parameters *params), | ||
598 | TP_ARGS(wiphy, netdev, mac, params), | ||
599 | TP_STRUCT__entry( | ||
600 | WIPHY_ENTRY | ||
601 | NETDEV_ENTRY | ||
602 | MAC_ENTRY(sta_mac) | ||
603 | __field(u32, sta_flags_mask) | ||
604 | __field(u32, sta_flags_set) | ||
605 | __field(u32, sta_modify_mask) | ||
606 | __field(int, listen_interval) | ||
607 | __field(u16, aid) | ||
608 | __field(u8, plink_action) | ||
609 | __field(u8, plink_state) | ||
610 | __field(u8, uapsd_queues) | ||
611 | __array(u8, ht_capa, (int)sizeof(struct ieee80211_ht_cap)) | ||
612 | ), | ||
613 | TP_fast_assign( | ||
614 | WIPHY_ASSIGN; | ||
615 | NETDEV_ASSIGN; | ||
616 | MAC_ASSIGN(sta_mac, mac); | ||
617 | __entry->sta_flags_mask = params->sta_flags_mask; | ||
618 | __entry->sta_flags_set = params->sta_flags_set; | ||
619 | __entry->sta_modify_mask = params->sta_modify_mask; | ||
620 | __entry->listen_interval = params->listen_interval; | ||
621 | __entry->aid = params->aid; | ||
622 | __entry->plink_action = params->plink_action; | ||
623 | __entry->plink_state = params->plink_state; | ||
624 | __entry->uapsd_queues = params->uapsd_queues; | ||
625 | memset(__entry->ht_capa, 0, sizeof(struct ieee80211_ht_cap)); | ||
626 | if (params->ht_capa) | ||
627 | memcpy(__entry->ht_capa, params->ht_capa, | ||
628 | sizeof(struct ieee80211_ht_cap)); | ||
629 | ), | ||
630 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", station mac: " MAC_PR_FMT | ||
631 | ", station flags mask: %u, station flags set: %u, " | ||
632 | "station modify mask: %u, listen interval: %d, aid: %u, " | ||
633 | "plink action: %u, plink state: %u, uapsd queues: %u", | ||
634 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(sta_mac), | ||
635 | __entry->sta_flags_mask, __entry->sta_flags_set, | ||
636 | __entry->sta_modify_mask, __entry->listen_interval, | ||
637 | __entry->aid, __entry->plink_action, __entry->plink_state, | ||
638 | __entry->uapsd_queues) | ||
639 | ); | ||
640 | |||
641 | DEFINE_EVENT(station_add_change, rdev_add_station, | ||
642 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *mac, | ||
643 | struct station_parameters *params), | ||
644 | TP_ARGS(wiphy, netdev, mac, params) | ||
645 | ); | ||
646 | |||
647 | DEFINE_EVENT(station_add_change, rdev_change_station, | ||
648 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *mac, | ||
649 | struct station_parameters *params), | ||
650 | TP_ARGS(wiphy, netdev, mac, params) | ||
651 | ); | ||
652 | |||
653 | DECLARE_EVENT_CLASS(wiphy_netdev_mac_evt, | ||
654 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, const u8 *mac), | ||
655 | TP_ARGS(wiphy, netdev, mac), | ||
656 | TP_STRUCT__entry( | ||
657 | WIPHY_ENTRY | ||
658 | NETDEV_ENTRY | ||
659 | MAC_ENTRY(sta_mac) | ||
660 | ), | ||
661 | TP_fast_assign( | ||
662 | WIPHY_ASSIGN; | ||
663 | NETDEV_ASSIGN; | ||
664 | MAC_ASSIGN(sta_mac, mac); | ||
665 | ), | ||
666 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", mac: " MAC_PR_FMT, | ||
667 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(sta_mac)) | ||
668 | ); | ||
669 | |||
670 | DEFINE_EVENT(wiphy_netdev_mac_evt, rdev_del_station, | ||
671 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, const u8 *mac), | ||
672 | TP_ARGS(wiphy, netdev, mac) | ||
673 | ); | ||
674 | |||
675 | DEFINE_EVENT(wiphy_netdev_mac_evt, rdev_get_station, | ||
676 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, const u8 *mac), | ||
677 | TP_ARGS(wiphy, netdev, mac) | ||
678 | ); | ||
679 | |||
680 | DEFINE_EVENT(wiphy_netdev_mac_evt, rdev_del_mpath, | ||
681 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, const u8 *mac), | ||
682 | TP_ARGS(wiphy, netdev, mac) | ||
683 | ); | ||
684 | |||
685 | DEFINE_EVENT(wiphy_netdev_mac_evt, rdev_set_wds_peer, | ||
686 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, const u8 *mac), | ||
687 | TP_ARGS(wiphy, netdev, mac) | ||
688 | ); | ||
689 | |||
690 | TRACE_EVENT(rdev_dump_station, | ||
691 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, int idx, | ||
692 | u8 *mac), | ||
693 | TP_ARGS(wiphy, netdev, idx, mac), | ||
694 | TP_STRUCT__entry( | ||
695 | WIPHY_ENTRY | ||
696 | NETDEV_ENTRY | ||
697 | MAC_ENTRY(sta_mac) | ||
698 | __field(int, idx) | ||
699 | ), | ||
700 | TP_fast_assign( | ||
701 | WIPHY_ASSIGN; | ||
702 | NETDEV_ASSIGN; | ||
703 | MAC_ASSIGN(sta_mac, mac); | ||
704 | __entry->idx = idx; | ||
705 | ), | ||
706 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", station mac: " MAC_PR_FMT ", idx: %d", | ||
707 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(sta_mac), | ||
708 | __entry->idx) | ||
709 | ); | ||
710 | |||
711 | TRACE_EVENT(rdev_return_int_station_info, | ||
712 | TP_PROTO(struct wiphy *wiphy, int ret, struct station_info *sinfo), | ||
713 | TP_ARGS(wiphy, ret, sinfo), | ||
714 | TP_STRUCT__entry( | ||
715 | WIPHY_ENTRY | ||
716 | __field(int, ret) | ||
717 | SINFO_ENTRY | ||
718 | ), | ||
719 | TP_fast_assign( | ||
720 | WIPHY_ASSIGN; | ||
721 | __entry->ret = ret; | ||
722 | SINFO_ASSIGN; | ||
723 | ), | ||
724 | TP_printk(WIPHY_PR_FMT ", returned %d" , | ||
725 | WIPHY_PR_ARG, __entry->ret) | ||
726 | ); | ||
727 | |||
728 | DECLARE_EVENT_CLASS(mpath_evt, | ||
729 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *dst, | ||
730 | u8 *next_hop), | ||
731 | TP_ARGS(wiphy, netdev, dst, next_hop), | ||
732 | TP_STRUCT__entry( | ||
733 | WIPHY_ENTRY | ||
734 | NETDEV_ENTRY | ||
735 | MAC_ENTRY(dst) | ||
736 | MAC_ENTRY(next_hop) | ||
737 | ), | ||
738 | TP_fast_assign( | ||
739 | WIPHY_ASSIGN; | ||
740 | NETDEV_ASSIGN; | ||
741 | MAC_ASSIGN(dst, dst); | ||
742 | MAC_ASSIGN(next_hop, next_hop); | ||
743 | ), | ||
744 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", destination: " MAC_PR_FMT ", next hop: " MAC_PR_FMT, | ||
745 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(dst), | ||
746 | MAC_PR_ARG(next_hop)) | ||
747 | ); | ||
748 | |||
749 | DEFINE_EVENT(mpath_evt, rdev_add_mpath, | ||
750 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *dst, | ||
751 | u8 *next_hop), | ||
752 | TP_ARGS(wiphy, netdev, dst, next_hop) | ||
753 | ); | ||
754 | |||
755 | DEFINE_EVENT(mpath_evt, rdev_change_mpath, | ||
756 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *dst, | ||
757 | u8 *next_hop), | ||
758 | TP_ARGS(wiphy, netdev, dst, next_hop) | ||
759 | ); | ||
760 | |||
761 | DEFINE_EVENT(mpath_evt, rdev_get_mpath, | ||
762 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *dst, | ||
763 | u8 *next_hop), | ||
764 | TP_ARGS(wiphy, netdev, dst, next_hop) | ||
765 | ); | ||
766 | |||
767 | TRACE_EVENT(rdev_dump_mpath, | ||
768 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, int idx, | ||
769 | u8 *dst, u8 *next_hop), | ||
770 | TP_ARGS(wiphy, netdev, idx, dst, next_hop), | ||
771 | TP_STRUCT__entry( | ||
772 | WIPHY_ENTRY | ||
773 | NETDEV_ENTRY | ||
774 | MAC_ENTRY(dst) | ||
775 | MAC_ENTRY(next_hop) | ||
776 | __field(int, idx) | ||
777 | ), | ||
778 | TP_fast_assign( | ||
779 | WIPHY_ASSIGN; | ||
780 | NETDEV_ASSIGN; | ||
781 | MAC_ASSIGN(dst, dst); | ||
782 | MAC_ASSIGN(next_hop, next_hop); | ||
783 | __entry->idx = idx; | ||
784 | ), | ||
785 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", index: %d, destination: " | ||
786 | MAC_PR_FMT ", next hop: " MAC_PR_FMT, | ||
787 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->idx, MAC_PR_ARG(dst), | ||
788 | MAC_PR_ARG(next_hop)) | ||
789 | ); | ||
790 | |||
791 | TRACE_EVENT(rdev_return_int_mpath_info, | ||
792 | TP_PROTO(struct wiphy *wiphy, int ret, struct mpath_info *pinfo), | ||
793 | TP_ARGS(wiphy, ret, pinfo), | ||
794 | TP_STRUCT__entry( | ||
795 | WIPHY_ENTRY | ||
796 | __field(int, ret) | ||
797 | __field(int, generation) | ||
798 | __field(u32, filled) | ||
799 | __field(u32, frame_qlen) | ||
800 | __field(u32, sn) | ||
801 | __field(u32, metric) | ||
802 | __field(u32, exptime) | ||
803 | __field(u32, discovery_timeout) | ||
804 | __field(u8, discovery_retries) | ||
805 | __field(u8, flags) | ||
806 | ), | ||
807 | TP_fast_assign( | ||
808 | WIPHY_ASSIGN; | ||
809 | __entry->ret = ret; | ||
810 | __entry->generation = pinfo->generation; | ||
811 | __entry->filled = pinfo->filled; | ||
812 | __entry->frame_qlen = pinfo->frame_qlen; | ||
813 | __entry->sn = pinfo->sn; | ||
814 | __entry->metric = pinfo->metric; | ||
815 | __entry->exptime = pinfo->exptime; | ||
816 | __entry->discovery_timeout = pinfo->discovery_timeout; | ||
817 | __entry->discovery_retries = pinfo->discovery_retries; | ||
818 | __entry->flags = pinfo->flags; | ||
819 | ), | ||
820 | TP_printk(WIPHY_PR_FMT ", returned %d. mpath info - generation: %d, " | ||
821 | "filled: %u, frame qlen: %u, sn: %u, metric: %u, exptime: %u," | ||
822 | " discovery timeout: %u, discovery retries: %u, flags: %u", | ||
823 | WIPHY_PR_ARG, __entry->ret, __entry->generation, | ||
824 | __entry->filled, __entry->frame_qlen, __entry->sn, | ||
825 | __entry->metric, __entry->exptime, __entry->discovery_timeout, | ||
826 | __entry->discovery_retries, __entry->flags) | ||
827 | ); | ||
828 | |||
829 | TRACE_EVENT(rdev_return_int_mesh_config, | ||
830 | TP_PROTO(struct wiphy *wiphy, int ret, struct mesh_config *conf), | ||
831 | TP_ARGS(wiphy, ret, conf), | ||
832 | TP_STRUCT__entry( | ||
833 | WIPHY_ENTRY | ||
834 | MESH_CFG_ENTRY | ||
835 | __field(int, ret) | ||
836 | ), | ||
837 | TP_fast_assign( | ||
838 | WIPHY_ASSIGN; | ||
839 | MESH_CFG_ASSIGN; | ||
840 | __entry->ret = ret; | ||
841 | ), | ||
842 | TP_printk(WIPHY_PR_FMT ", returned: %d", | ||
843 | WIPHY_PR_ARG, __entry->ret) | ||
844 | ); | ||
845 | |||
846 | TRACE_EVENT(rdev_update_mesh_config, | ||
847 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u32 mask, | ||
848 | const struct mesh_config *conf), | ||
849 | TP_ARGS(wiphy, netdev, mask, conf), | ||
850 | TP_STRUCT__entry( | ||
851 | WIPHY_ENTRY | ||
852 | NETDEV_ENTRY | ||
853 | MESH_CFG_ENTRY | ||
854 | __field(u32, mask) | ||
855 | ), | ||
856 | TP_fast_assign( | ||
857 | WIPHY_ASSIGN; | ||
858 | NETDEV_ASSIGN; | ||
859 | MESH_CFG_ASSIGN; | ||
860 | __entry->mask = mask; | ||
861 | ), | ||
862 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", mask: %u", | ||
863 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->mask) | ||
864 | ); | ||
865 | |||
866 | TRACE_EVENT(rdev_join_mesh, | ||
867 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
868 | const struct mesh_config *conf, | ||
869 | const struct mesh_setup *setup), | ||
870 | TP_ARGS(wiphy, netdev, conf, setup), | ||
871 | TP_STRUCT__entry( | ||
872 | WIPHY_ENTRY | ||
873 | NETDEV_ENTRY | ||
874 | MESH_CFG_ENTRY | ||
875 | ), | ||
876 | TP_fast_assign( | ||
877 | WIPHY_ASSIGN; | ||
878 | NETDEV_ASSIGN; | ||
879 | MESH_CFG_ASSIGN; | ||
880 | ), | ||
881 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT, | ||
882 | WIPHY_PR_ARG, NETDEV_PR_ARG) | ||
883 | ); | ||
884 | |||
885 | TRACE_EVENT(rdev_change_bss, | ||
886 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
887 | struct bss_parameters *params), | ||
888 | TP_ARGS(wiphy, netdev, params), | ||
889 | TP_STRUCT__entry( | ||
890 | WIPHY_ENTRY | ||
891 | NETDEV_ENTRY | ||
892 | __field(int, use_cts_prot) | ||
893 | __field(int, use_short_preamble) | ||
894 | __field(int, use_short_slot_time) | ||
895 | __field(int, ap_isolate) | ||
896 | __field(int, ht_opmode) | ||
897 | ), | ||
898 | TP_fast_assign( | ||
899 | WIPHY_ASSIGN; | ||
900 | NETDEV_ASSIGN; | ||
901 | __entry->use_cts_prot = params->use_cts_prot; | ||
902 | __entry->use_short_preamble = params->use_short_preamble; | ||
903 | __entry->use_short_slot_time = params->use_short_slot_time; | ||
904 | __entry->ap_isolate = params->ap_isolate; | ||
905 | __entry->ht_opmode = params->ht_opmode; | ||
906 | ), | ||
907 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", use cts prot: %d, " | ||
908 | "use short preamble: %d, use short slot time: %d, " | ||
909 | "ap isolate: %d, ht opmode: %d", | ||
910 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->use_cts_prot, | ||
911 | __entry->use_short_preamble, __entry->use_short_slot_time, | ||
912 | __entry->ap_isolate, __entry->ht_opmode) | ||
913 | ); | ||
914 | |||
915 | TRACE_EVENT(rdev_set_txq_params, | ||
916 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
917 | struct ieee80211_txq_params *params), | ||
918 | TP_ARGS(wiphy, netdev, params), | ||
919 | TP_STRUCT__entry( | ||
920 | WIPHY_ENTRY | ||
921 | NETDEV_ENTRY | ||
922 | __field(enum nl80211_ac, ac) | ||
923 | __field(u16, txop) | ||
924 | __field(u16, cwmin) | ||
925 | __field(u16, cwmax) | ||
926 | __field(u8, aifs) | ||
927 | ), | ||
928 | TP_fast_assign( | ||
929 | WIPHY_ASSIGN; | ||
930 | NETDEV_ASSIGN; | ||
931 | __entry->ac = params->ac; | ||
932 | __entry->txop = params->txop; | ||
933 | __entry->cwmin = params->cwmin; | ||
934 | __entry->cwmax = params->cwmax; | ||
935 | __entry->aifs = params->aifs; | ||
936 | ), | ||
937 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", ac: %d, txop: %u, cwmin: %u, cwmax: %u, aifs: %u", | ||
938 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->ac, __entry->txop, | ||
939 | __entry->cwmin, __entry->cwmax, __entry->aifs) | ||
940 | ); | ||
941 | |||
942 | TRACE_EVENT(rdev_libertas_set_mesh_channel, | ||
943 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
944 | struct ieee80211_channel *chan), | ||
945 | TP_ARGS(wiphy, netdev, chan), | ||
946 | TP_STRUCT__entry( | ||
947 | WIPHY_ENTRY | ||
948 | NETDEV_ENTRY | ||
949 | CHAN_ENTRY | ||
950 | ), | ||
951 | TP_fast_assign( | ||
952 | WIPHY_ASSIGN; | ||
953 | NETDEV_ASSIGN; | ||
954 | CHAN_ASSIGN(chan); | ||
955 | ), | ||
956 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", " CHAN_PR_FMT, WIPHY_PR_ARG, | ||
957 | NETDEV_PR_ARG, CHAN_PR_ARG) | ||
958 | ); | ||
959 | |||
960 | TRACE_EVENT(rdev_set_monitor_channel, | ||
961 | TP_PROTO(struct wiphy *wiphy, | ||
962 | struct cfg80211_chan_def *chandef), | ||
963 | TP_ARGS(wiphy, chandef), | ||
964 | TP_STRUCT__entry( | ||
965 | WIPHY_ENTRY | ||
966 | CHAN_DEF_ENTRY | ||
967 | ), | ||
968 | TP_fast_assign( | ||
969 | WIPHY_ASSIGN; | ||
970 | CHAN_DEF_ASSIGN(chandef); | ||
971 | ), | ||
972 | TP_printk(WIPHY_PR_FMT ", " CHAN_DEF_PR_FMT, | ||
973 | WIPHY_PR_ARG, CHAN_DEF_PR_ARG) | ||
974 | ); | ||
975 | |||
976 | TRACE_EVENT(rdev_auth, | ||
977 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
978 | struct cfg80211_auth_request *req), | ||
979 | TP_ARGS(wiphy, netdev, req), | ||
980 | TP_STRUCT__entry( | ||
981 | WIPHY_ENTRY | ||
982 | NETDEV_ENTRY | ||
983 | MAC_ENTRY(bssid) | ||
984 | __field(enum nl80211_auth_type, auth_type) | ||
985 | ), | ||
986 | TP_fast_assign( | ||
987 | WIPHY_ASSIGN; | ||
988 | NETDEV_ASSIGN; | ||
989 | if (req->bss) | ||
990 | MAC_ASSIGN(bssid, req->bss->bssid); | ||
991 | else | ||
992 | memset(__entry->bssid, 0, ETH_ALEN); | ||
993 | __entry->auth_type = req->auth_type; | ||
994 | ), | ||
995 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", auth type: %d, bssid: " MAC_PR_FMT, | ||
996 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->auth_type, | ||
997 | MAC_PR_ARG(bssid)) | ||
998 | ); | ||
999 | |||
1000 | TRACE_EVENT(rdev_assoc, | ||
1001 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1002 | struct cfg80211_assoc_request *req), | ||
1003 | TP_ARGS(wiphy, netdev, req), | ||
1004 | TP_STRUCT__entry( | ||
1005 | WIPHY_ENTRY | ||
1006 | NETDEV_ENTRY | ||
1007 | MAC_ENTRY(bssid) | ||
1008 | MAC_ENTRY(prev_bssid) | ||
1009 | __field(bool, use_mfp) | ||
1010 | __field(u32, flags) | ||
1011 | ), | ||
1012 | TP_fast_assign( | ||
1013 | WIPHY_ASSIGN; | ||
1014 | NETDEV_ASSIGN; | ||
1015 | if (req->bss) | ||
1016 | MAC_ASSIGN(bssid, req->bss->bssid); | ||
1017 | else | ||
1018 | memset(__entry->bssid, 0, ETH_ALEN); | ||
1019 | MAC_ASSIGN(prev_bssid, req->prev_bssid); | ||
1020 | __entry->use_mfp = req->use_mfp; | ||
1021 | __entry->flags = req->flags; | ||
1022 | ), | ||
1023 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", bssid: " MAC_PR_FMT | ||
1024 | ", previous bssid: " MAC_PR_FMT ", use mfp: %s, flags: %u", | ||
1025 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(bssid), | ||
1026 | MAC_PR_ARG(prev_bssid), BOOL_TO_STR(__entry->use_mfp), | ||
1027 | __entry->flags) | ||
1028 | ); | ||
1029 | |||
1030 | TRACE_EVENT(rdev_deauth, | ||
1031 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1032 | struct cfg80211_deauth_request *req), | ||
1033 | TP_ARGS(wiphy, netdev, req), | ||
1034 | TP_STRUCT__entry( | ||
1035 | WIPHY_ENTRY | ||
1036 | NETDEV_ENTRY | ||
1037 | MAC_ENTRY(bssid) | ||
1038 | __field(u16, reason_code) | ||
1039 | ), | ||
1040 | TP_fast_assign( | ||
1041 | WIPHY_ASSIGN; | ||
1042 | NETDEV_ASSIGN; | ||
1043 | MAC_ASSIGN(bssid, req->bssid); | ||
1044 | __entry->reason_code = req->reason_code; | ||
1045 | ), | ||
1046 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", bssid: " MAC_PR_FMT ", reason: %u", | ||
1047 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(bssid), | ||
1048 | __entry->reason_code) | ||
1049 | ); | ||
1050 | |||
1051 | TRACE_EVENT(rdev_disassoc, | ||
1052 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1053 | struct cfg80211_disassoc_request *req), | ||
1054 | TP_ARGS(wiphy, netdev, req), | ||
1055 | TP_STRUCT__entry( | ||
1056 | WIPHY_ENTRY | ||
1057 | NETDEV_ENTRY | ||
1058 | MAC_ENTRY(bssid) | ||
1059 | __field(u16, reason_code) | ||
1060 | __field(bool, local_state_change) | ||
1061 | ), | ||
1062 | TP_fast_assign( | ||
1063 | WIPHY_ASSIGN; | ||
1064 | NETDEV_ASSIGN; | ||
1065 | if (req->bss) | ||
1066 | MAC_ASSIGN(bssid, req->bss->bssid); | ||
1067 | else | ||
1068 | memset(__entry->bssid, 0, ETH_ALEN); | ||
1069 | __entry->reason_code = req->reason_code; | ||
1070 | __entry->local_state_change = req->local_state_change; | ||
1071 | ), | ||
1072 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", bssid: " MAC_PR_FMT | ||
1073 | ", reason: %u, local state change: %s", | ||
1074 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(bssid), | ||
1075 | __entry->reason_code, | ||
1076 | BOOL_TO_STR(__entry->local_state_change)) | ||
1077 | ); | ||
1078 | |||
1079 | TRACE_EVENT(rdev_mgmt_tx_cancel_wait, | ||
1080 | TP_PROTO(struct wiphy *wiphy, | ||
1081 | struct wireless_dev *wdev, u64 cookie), | ||
1082 | TP_ARGS(wiphy, wdev, cookie), | ||
1083 | TP_STRUCT__entry( | ||
1084 | WIPHY_ENTRY | ||
1085 | WDEV_ENTRY | ||
1086 | __field(u64, cookie) | ||
1087 | ), | ||
1088 | TP_fast_assign( | ||
1089 | WIPHY_ASSIGN; | ||
1090 | WDEV_ASSIGN; | ||
1091 | __entry->cookie = cookie; | ||
1092 | ), | ||
1093 | TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT ", cookie: %llu ", | ||
1094 | WIPHY_PR_ARG, WDEV_PR_ARG, __entry->cookie) | ||
1095 | ); | ||
1096 | |||
1097 | TRACE_EVENT(rdev_set_power_mgmt, | ||
1098 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1099 | bool enabled, int timeout), | ||
1100 | TP_ARGS(wiphy, netdev, enabled, timeout), | ||
1101 | TP_STRUCT__entry( | ||
1102 | WIPHY_ENTRY | ||
1103 | NETDEV_ENTRY | ||
1104 | __field(bool, enabled) | ||
1105 | __field(int, timeout) | ||
1106 | ), | ||
1107 | TP_fast_assign( | ||
1108 | WIPHY_ASSIGN; | ||
1109 | NETDEV_ASSIGN; | ||
1110 | __entry->enabled = enabled; | ||
1111 | __entry->timeout = timeout; | ||
1112 | ), | ||
1113 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", %senabled, timeout: %d ", | ||
1114 | WIPHY_PR_ARG, NETDEV_PR_ARG, | ||
1115 | __entry->enabled ? "" : "not ", __entry->timeout) | ||
1116 | ); | ||
1117 | |||
1118 | TRACE_EVENT(rdev_connect, | ||
1119 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1120 | struct cfg80211_connect_params *sme), | ||
1121 | TP_ARGS(wiphy, netdev, sme), | ||
1122 | TP_STRUCT__entry( | ||
1123 | WIPHY_ENTRY | ||
1124 | NETDEV_ENTRY | ||
1125 | MAC_ENTRY(bssid) | ||
1126 | __array(char, ssid, IEEE80211_MAX_SSID_LEN + 1) | ||
1127 | __field(enum nl80211_auth_type, auth_type) | ||
1128 | __field(bool, privacy) | ||
1129 | __field(u32, wpa_versions) | ||
1130 | __field(u32, flags) | ||
1131 | ), | ||
1132 | TP_fast_assign( | ||
1133 | WIPHY_ASSIGN; | ||
1134 | NETDEV_ASSIGN; | ||
1135 | MAC_ASSIGN(bssid, sme->bssid); | ||
1136 | memset(__entry->ssid, 0, IEEE80211_MAX_SSID_LEN + 1); | ||
1137 | memcpy(__entry->ssid, sme->ssid, sme->ssid_len); | ||
1138 | __entry->auth_type = sme->auth_type; | ||
1139 | __entry->privacy = sme->privacy; | ||
1140 | __entry->wpa_versions = sme->crypto.wpa_versions; | ||
1141 | __entry->flags = sme->flags; | ||
1142 | ), | ||
1143 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", bssid: " MAC_PR_FMT | ||
1144 | ", ssid: %s, auth type: %d, privacy: %s, wpa versions: %u, " | ||
1145 | "flags: %u", | ||
1146 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(bssid), __entry->ssid, | ||
1147 | __entry->auth_type, BOOL_TO_STR(__entry->privacy), | ||
1148 | __entry->wpa_versions, __entry->flags) | ||
1149 | ); | ||
1150 | |||
1151 | TRACE_EVENT(rdev_set_cqm_rssi_config, | ||
1152 | TP_PROTO(struct wiphy *wiphy, | ||
1153 | struct net_device *netdev, s32 rssi_thold, | ||
1154 | u32 rssi_hyst), | ||
1155 | TP_ARGS(wiphy, netdev, rssi_thold, rssi_hyst), | ||
1156 | TP_STRUCT__entry( | ||
1157 | WIPHY_ENTRY | ||
1158 | NETDEV_ENTRY | ||
1159 | __field(s32, rssi_thold) | ||
1160 | __field(u32, rssi_hyst) | ||
1161 | ), | ||
1162 | TP_fast_assign( | ||
1163 | WIPHY_ASSIGN; | ||
1164 | NETDEV_ASSIGN; | ||
1165 | __entry->rssi_thold = rssi_thold; | ||
1166 | __entry->rssi_hyst = rssi_hyst; | ||
1167 | ), | ||
1168 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT | ||
1169 | ", rssi_thold: %d, rssi_hyst: %u ", | ||
1170 | WIPHY_PR_ARG, NETDEV_PR_ARG, | ||
1171 | __entry->rssi_thold, __entry->rssi_hyst) | ||
1172 | ); | ||
1173 | |||
1174 | TRACE_EVENT(rdev_set_cqm_txe_config, | ||
1175 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u32 rate, | ||
1176 | u32 pkts, u32 intvl), | ||
1177 | TP_ARGS(wiphy, netdev, rate, pkts, intvl), | ||
1178 | TP_STRUCT__entry( | ||
1179 | WIPHY_ENTRY | ||
1180 | NETDEV_ENTRY | ||
1181 | __field(u32, rate) | ||
1182 | __field(u32, pkts) | ||
1183 | __field(u32, intvl) | ||
1184 | ), | ||
1185 | TP_fast_assign( | ||
1186 | WIPHY_ASSIGN; | ||
1187 | NETDEV_ASSIGN; | ||
1188 | __entry->rate = rate; | ||
1189 | __entry->pkts = pkts; | ||
1190 | __entry->intvl = intvl; | ||
1191 | ), | ||
1192 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", rate: %u, packets: %u, interval: %u", | ||
1193 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->rate, __entry->pkts, | ||
1194 | __entry->intvl) | ||
1195 | ); | ||
1196 | |||
1197 | TRACE_EVENT(rdev_disconnect, | ||
1198 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1199 | u16 reason_code), | ||
1200 | TP_ARGS(wiphy, netdev, reason_code), | ||
1201 | TP_STRUCT__entry( | ||
1202 | WIPHY_ENTRY | ||
1203 | NETDEV_ENTRY | ||
1204 | __field(u16, reason_code) | ||
1205 | ), | ||
1206 | TP_fast_assign( | ||
1207 | WIPHY_ASSIGN; | ||
1208 | NETDEV_ASSIGN; | ||
1209 | __entry->reason_code = reason_code; | ||
1210 | ), | ||
1211 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", reason code: %u", WIPHY_PR_ARG, | ||
1212 | NETDEV_PR_ARG, __entry->reason_code) | ||
1213 | ); | ||
1214 | |||
1215 | TRACE_EVENT(rdev_join_ibss, | ||
1216 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1217 | struct cfg80211_ibss_params *params), | ||
1218 | TP_ARGS(wiphy, netdev, params), | ||
1219 | TP_STRUCT__entry( | ||
1220 | WIPHY_ENTRY | ||
1221 | NETDEV_ENTRY | ||
1222 | MAC_ENTRY(bssid) | ||
1223 | __array(char, ssid, IEEE80211_MAX_SSID_LEN + 1) | ||
1224 | ), | ||
1225 | TP_fast_assign( | ||
1226 | WIPHY_ASSIGN; | ||
1227 | NETDEV_ASSIGN; | ||
1228 | MAC_ASSIGN(bssid, params->bssid); | ||
1229 | memset(__entry->ssid, 0, IEEE80211_MAX_SSID_LEN + 1); | ||
1230 | memcpy(__entry->ssid, params->ssid, params->ssid_len); | ||
1231 | ), | ||
1232 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", bssid: " MAC_PR_FMT ", ssid: %s", | ||
1233 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(bssid), __entry->ssid) | ||
1234 | ); | ||
1235 | |||
1236 | TRACE_EVENT(rdev_set_wiphy_params, | ||
1237 | TP_PROTO(struct wiphy *wiphy, u32 changed), | ||
1238 | TP_ARGS(wiphy, changed), | ||
1239 | TP_STRUCT__entry( | ||
1240 | WIPHY_ENTRY | ||
1241 | __field(u32, changed) | ||
1242 | ), | ||
1243 | TP_fast_assign( | ||
1244 | WIPHY_ASSIGN; | ||
1245 | __entry->changed = changed; | ||
1246 | ), | ||
1247 | TP_printk(WIPHY_PR_FMT ", changed: %u", | ||
1248 | WIPHY_PR_ARG, __entry->changed) | ||
1249 | ); | ||
1250 | |||
1251 | DEFINE_EVENT(wiphy_wdev_evt, rdev_get_tx_power, | ||
1252 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev), | ||
1253 | TP_ARGS(wiphy, wdev) | ||
1254 | ); | ||
1255 | |||
1256 | TRACE_EVENT(rdev_set_tx_power, | ||
1257 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev, | ||
1258 | enum nl80211_tx_power_setting type, int mbm), | ||
1259 | TP_ARGS(wiphy, wdev, type, mbm), | ||
1260 | TP_STRUCT__entry( | ||
1261 | WIPHY_ENTRY | ||
1262 | WDEV_ENTRY | ||
1263 | __field(enum nl80211_tx_power_setting, type) | ||
1264 | __field(int, mbm) | ||
1265 | ), | ||
1266 | TP_fast_assign( | ||
1267 | WIPHY_ASSIGN; | ||
1268 | WDEV_ASSIGN; | ||
1269 | __entry->type = type; | ||
1270 | __entry->mbm = mbm; | ||
1271 | ), | ||
1272 | TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT ", type: %u, mbm: %d", | ||
1273 | WIPHY_PR_ARG, WDEV_PR_ARG,__entry->type, __entry->mbm) | ||
1274 | ); | ||
1275 | |||
1276 | TRACE_EVENT(rdev_return_int_int, | ||
1277 | TP_PROTO(struct wiphy *wiphy, int func_ret, int func_fill), | ||
1278 | TP_ARGS(wiphy, func_ret, func_fill), | ||
1279 | TP_STRUCT__entry( | ||
1280 | WIPHY_ENTRY | ||
1281 | __field(int, func_ret) | ||
1282 | __field(int, func_fill) | ||
1283 | ), | ||
1284 | TP_fast_assign( | ||
1285 | WIPHY_ASSIGN; | ||
1286 | __entry->func_ret = func_ret; | ||
1287 | __entry->func_fill = func_fill; | ||
1288 | ), | ||
1289 | TP_printk(WIPHY_PR_FMT ", function returns: %d, function filled: %d", | ||
1290 | WIPHY_PR_ARG, __entry->func_ret, __entry->func_fill) | ||
1291 | ); | ||
1292 | |||
1293 | #ifdef CONFIG_NL80211_TESTMODE | ||
1294 | TRACE_EVENT(rdev_testmode_cmd, | ||
1295 | TP_PROTO(struct wiphy *wiphy), | ||
1296 | TP_ARGS(wiphy), | ||
1297 | TP_STRUCT__entry( | ||
1298 | WIPHY_ENTRY | ||
1299 | ), | ||
1300 | TP_fast_assign( | ||
1301 | WIPHY_ASSIGN; | ||
1302 | ), | ||
1303 | TP_printk(WIPHY_PR_FMT, WIPHY_PR_ARG) | ||
1304 | ); | ||
1305 | |||
1306 | TRACE_EVENT(rdev_testmode_dump, | ||
1307 | TP_PROTO(struct wiphy *wiphy), | ||
1308 | TP_ARGS(wiphy), | ||
1309 | TP_STRUCT__entry( | ||
1310 | WIPHY_ENTRY | ||
1311 | ), | ||
1312 | TP_fast_assign( | ||
1313 | WIPHY_ASSIGN; | ||
1314 | ), | ||
1315 | TP_printk(WIPHY_PR_FMT, WIPHY_PR_ARG) | ||
1316 | ); | ||
1317 | #endif /* CONFIG_NL80211_TESTMODE */ | ||
1318 | |||
1319 | TRACE_EVENT(rdev_set_bitrate_mask, | ||
1320 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1321 | const u8 *peer, const struct cfg80211_bitrate_mask *mask), | ||
1322 | TP_ARGS(wiphy, netdev, peer, mask), | ||
1323 | TP_STRUCT__entry( | ||
1324 | WIPHY_ENTRY | ||
1325 | NETDEV_ENTRY | ||
1326 | MAC_ENTRY(peer) | ||
1327 | ), | ||
1328 | TP_fast_assign( | ||
1329 | WIPHY_ASSIGN; | ||
1330 | NETDEV_ASSIGN; | ||
1331 | MAC_ASSIGN(peer, peer); | ||
1332 | ), | ||
1333 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", peer: " MAC_PR_FMT, | ||
1334 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer)) | ||
1335 | ); | ||
1336 | |||
1337 | TRACE_EVENT(rdev_mgmt_frame_register, | ||
1338 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev, | ||
1339 | u16 frame_type, bool reg), | ||
1340 | TP_ARGS(wiphy, wdev, frame_type, reg), | ||
1341 | TP_STRUCT__entry( | ||
1342 | WIPHY_ENTRY | ||
1343 | WDEV_ENTRY | ||
1344 | __field(u16, frame_type) | ||
1345 | __field(bool, reg) | ||
1346 | ), | ||
1347 | TP_fast_assign( | ||
1348 | WIPHY_ASSIGN; | ||
1349 | WDEV_ASSIGN; | ||
1350 | __entry->frame_type = frame_type; | ||
1351 | __entry->reg = reg; | ||
1352 | ), | ||
1353 | TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT ", frame_type: 0x%.2x, reg: %s ", | ||
1354 | WIPHY_PR_ARG, WDEV_PR_ARG, __entry->frame_type, | ||
1355 | __entry->reg ? "true" : "false") | ||
1356 | ); | ||
1357 | |||
1358 | TRACE_EVENT(rdev_return_int_tx_rx, | ||
1359 | TP_PROTO(struct wiphy *wiphy, int ret, u32 tx, u32 rx), | ||
1360 | TP_ARGS(wiphy, ret, tx, rx), | ||
1361 | TP_STRUCT__entry( | ||
1362 | WIPHY_ENTRY | ||
1363 | __field(int, ret) | ||
1364 | __field(u32, tx) | ||
1365 | __field(u32, rx) | ||
1366 | ), | ||
1367 | TP_fast_assign( | ||
1368 | WIPHY_ASSIGN; | ||
1369 | __entry->ret = ret; | ||
1370 | __entry->tx = tx; | ||
1371 | __entry->rx = rx; | ||
1372 | ), | ||
1373 | TP_printk(WIPHY_PR_FMT ", returned %d, tx: %u, rx: %u", | ||
1374 | WIPHY_PR_ARG, __entry->ret, __entry->tx, __entry->rx) | ||
1375 | ); | ||
1376 | |||
1377 | TRACE_EVENT(rdev_return_void_tx_rx, | ||
1378 | TP_PROTO(struct wiphy *wiphy, u32 tx, u32 tx_max, | ||
1379 | u32 rx, u32 rx_max), | ||
1380 | TP_ARGS(wiphy, tx, tx_max, rx, rx_max), | ||
1381 | TP_STRUCT__entry( | ||
1382 | WIPHY_ENTRY | ||
1383 | __field(u32, tx) | ||
1384 | __field(u32, tx_max) | ||
1385 | __field(u32, rx) | ||
1386 | __field(u32, rx_max) | ||
1387 | ), | ||
1388 | TP_fast_assign( | ||
1389 | WIPHY_ASSIGN; | ||
1390 | __entry->tx = tx; | ||
1391 | __entry->tx_max = tx_max; | ||
1392 | __entry->rx = rx; | ||
1393 | __entry->rx_max = rx_max; | ||
1394 | ), | ||
1395 | TP_printk(WIPHY_PR_FMT ", tx: %u, tx_max: %u, rx: %u, rx_max: %u ", | ||
1396 | WIPHY_PR_ARG, __entry->tx, __entry->tx_max, __entry->rx, | ||
1397 | __entry->rx_max) | ||
1398 | ); | ||
1399 | |||
1400 | DECLARE_EVENT_CLASS(tx_rx_evt, | ||
1401 | TP_PROTO(struct wiphy *wiphy, u32 tx, u32 rx), | ||
1402 | TP_ARGS(wiphy, rx, tx), | ||
1403 | TP_STRUCT__entry( | ||
1404 | WIPHY_ENTRY | ||
1405 | __field(u32, tx) | ||
1406 | __field(u32, rx) | ||
1407 | ), | ||
1408 | TP_fast_assign( | ||
1409 | WIPHY_ASSIGN; | ||
1410 | __entry->tx = tx; | ||
1411 | __entry->rx = rx; | ||
1412 | ), | ||
1413 | TP_printk(WIPHY_PR_FMT ", tx: %u, rx: %u ", | ||
1414 | WIPHY_PR_ARG, __entry->tx, __entry->rx) | ||
1415 | ); | ||
1416 | |||
1417 | DEFINE_EVENT(tx_rx_evt, rdev_set_ringparam, | ||
1418 | TP_PROTO(struct wiphy *wiphy, u32 tx, u32 rx), | ||
1419 | TP_ARGS(wiphy, rx, tx) | ||
1420 | ); | ||
1421 | |||
1422 | DEFINE_EVENT(tx_rx_evt, rdev_set_antenna, | ||
1423 | TP_PROTO(struct wiphy *wiphy, u32 tx, u32 rx), | ||
1424 | TP_ARGS(wiphy, rx, tx) | ||
1425 | ); | ||
1426 | |||
1427 | TRACE_EVENT(rdev_sched_scan_start, | ||
1428 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1429 | struct cfg80211_sched_scan_request *request), | ||
1430 | TP_ARGS(wiphy, netdev, request), | ||
1431 | TP_STRUCT__entry( | ||
1432 | WIPHY_ENTRY | ||
1433 | NETDEV_ENTRY | ||
1434 | ), | ||
1435 | TP_fast_assign( | ||
1436 | WIPHY_ASSIGN; | ||
1437 | NETDEV_ASSIGN; | ||
1438 | ), | ||
1439 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT, | ||
1440 | WIPHY_PR_ARG, NETDEV_PR_ARG) | ||
1441 | ); | ||
1442 | |||
1443 | TRACE_EVENT(rdev_tdls_mgmt, | ||
1444 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1445 | u8 *peer, u8 action_code, u8 dialog_token, | ||
1446 | u16 status_code, const u8 *buf, size_t len), | ||
1447 | TP_ARGS(wiphy, netdev, peer, action_code, dialog_token, status_code, | ||
1448 | buf, len), | ||
1449 | TP_STRUCT__entry( | ||
1450 | WIPHY_ENTRY | ||
1451 | NETDEV_ENTRY | ||
1452 | MAC_ENTRY(peer) | ||
1453 | __field(u8, action_code) | ||
1454 | __field(u8, dialog_token) | ||
1455 | __field(u16, status_code) | ||
1456 | __dynamic_array(u8, buf, len) | ||
1457 | ), | ||
1458 | TP_fast_assign( | ||
1459 | WIPHY_ASSIGN; | ||
1460 | NETDEV_ASSIGN; | ||
1461 | MAC_ASSIGN(peer, peer); | ||
1462 | __entry->action_code = action_code; | ||
1463 | __entry->dialog_token = dialog_token; | ||
1464 | __entry->status_code = status_code; | ||
1465 | memcpy(__get_dynamic_array(buf), buf, len); | ||
1466 | ), | ||
1467 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", " MAC_PR_FMT ", action_code: %u, " | ||
1468 | "dialog_token: %u, status_code: %u, buf: %#.2x ", | ||
1469 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer), | ||
1470 | __entry->action_code, __entry->dialog_token, | ||
1471 | __entry->status_code, ((u8 *)__get_dynamic_array(buf))[0]) | ||
1472 | ); | ||
1473 | |||
1474 | TRACE_EVENT(rdev_dump_survey, | ||
1475 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, int idx), | ||
1476 | TP_ARGS(wiphy, netdev, idx), | ||
1477 | TP_STRUCT__entry( | ||
1478 | WIPHY_ENTRY | ||
1479 | NETDEV_ENTRY | ||
1480 | __field(int, idx) | ||
1481 | ), | ||
1482 | TP_fast_assign( | ||
1483 | WIPHY_ASSIGN; | ||
1484 | NETDEV_ASSIGN; | ||
1485 | __entry->idx = idx; | ||
1486 | ), | ||
1487 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", index: %d", | ||
1488 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->idx) | ||
1489 | ); | ||
1490 | |||
1491 | TRACE_EVENT(rdev_return_int_survey_info, | ||
1492 | TP_PROTO(struct wiphy *wiphy, int ret, struct survey_info *info), | ||
1493 | TP_ARGS(wiphy, ret, info), | ||
1494 | TP_STRUCT__entry( | ||
1495 | WIPHY_ENTRY | ||
1496 | CHAN_ENTRY | ||
1497 | __field(int, ret) | ||
1498 | __field(u64, channel_time) | ||
1499 | __field(u64, channel_time_busy) | ||
1500 | __field(u64, channel_time_ext_busy) | ||
1501 | __field(u64, channel_time_rx) | ||
1502 | __field(u64, channel_time_tx) | ||
1503 | __field(u32, filled) | ||
1504 | __field(s8, noise) | ||
1505 | ), | ||
1506 | TP_fast_assign( | ||
1507 | WIPHY_ASSIGN; | ||
1508 | CHAN_ASSIGN(info->channel); | ||
1509 | __entry->ret = ret; | ||
1510 | __entry->channel_time = info->channel_time; | ||
1511 | __entry->channel_time_busy = info->channel_time_busy; | ||
1512 | __entry->channel_time_ext_busy = info->channel_time_ext_busy; | ||
1513 | __entry->channel_time_rx = info->channel_time_rx; | ||
1514 | __entry->channel_time_tx = info->channel_time_tx; | ||
1515 | __entry->filled = info->filled; | ||
1516 | __entry->noise = info->noise; | ||
1517 | ), | ||
1518 | TP_printk(WIPHY_PR_FMT ", returned: %d, " CHAN_PR_FMT | ||
1519 | ", channel time: %llu, channel time busy: %llu, " | ||
1520 | "channel time extension busy: %llu, channel time rx: %llu, " | ||
1521 | "channel time tx: %llu, filled: %u, noise: %d", | ||
1522 | WIPHY_PR_ARG, __entry->ret, CHAN_PR_ARG, | ||
1523 | __entry->channel_time, __entry->channel_time_busy, | ||
1524 | __entry->channel_time_ext_busy, __entry->channel_time_rx, | ||
1525 | __entry->channel_time_tx, __entry->filled, __entry->noise) | ||
1526 | ); | ||
1527 | |||
1528 | TRACE_EVENT(rdev_tdls_oper, | ||
1529 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1530 | u8 *peer, enum nl80211_tdls_operation oper), | ||
1531 | TP_ARGS(wiphy, netdev, peer, oper), | ||
1532 | TP_STRUCT__entry( | ||
1533 | WIPHY_ENTRY | ||
1534 | NETDEV_ENTRY | ||
1535 | MAC_ENTRY(peer) | ||
1536 | __field(enum nl80211_tdls_operation, oper) | ||
1537 | ), | ||
1538 | TP_fast_assign( | ||
1539 | WIPHY_ASSIGN; | ||
1540 | NETDEV_ASSIGN; | ||
1541 | MAC_ASSIGN(peer, peer); | ||
1542 | __entry->oper = oper; | ||
1543 | ), | ||
1544 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", " MAC_PR_FMT ", oper: %d", | ||
1545 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer), __entry->oper) | ||
1546 | ); | ||
1547 | |||
1548 | DECLARE_EVENT_CLASS(rdev_pmksa, | ||
1549 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1550 | struct cfg80211_pmksa *pmksa), | ||
1551 | TP_ARGS(wiphy, netdev, pmksa), | ||
1552 | TP_STRUCT__entry( | ||
1553 | WIPHY_ENTRY | ||
1554 | NETDEV_ENTRY | ||
1555 | MAC_ENTRY(bssid) | ||
1556 | ), | ||
1557 | TP_fast_assign( | ||
1558 | WIPHY_ASSIGN; | ||
1559 | NETDEV_ASSIGN; | ||
1560 | MAC_ASSIGN(bssid, pmksa->bssid); | ||
1561 | ), | ||
1562 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", bssid: " MAC_PR_FMT, | ||
1563 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(bssid)) | ||
1564 | ); | ||
1565 | |||
1566 | TRACE_EVENT(rdev_probe_client, | ||
1567 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1568 | const u8 *peer), | ||
1569 | TP_ARGS(wiphy, netdev, peer), | ||
1570 | TP_STRUCT__entry( | ||
1571 | WIPHY_ENTRY | ||
1572 | NETDEV_ENTRY | ||
1573 | MAC_ENTRY(peer) | ||
1574 | ), | ||
1575 | TP_fast_assign( | ||
1576 | WIPHY_ASSIGN; | ||
1577 | NETDEV_ASSIGN; | ||
1578 | MAC_ASSIGN(peer, peer); | ||
1579 | ), | ||
1580 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", " MAC_PR_FMT, | ||
1581 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer)) | ||
1582 | ); | ||
1583 | |||
1584 | DEFINE_EVENT(rdev_pmksa, rdev_set_pmksa, | ||
1585 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1586 | struct cfg80211_pmksa *pmksa), | ||
1587 | TP_ARGS(wiphy, netdev, pmksa) | ||
1588 | ); | ||
1589 | |||
1590 | DEFINE_EVENT(rdev_pmksa, rdev_del_pmksa, | ||
1591 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1592 | struct cfg80211_pmksa *pmksa), | ||
1593 | TP_ARGS(wiphy, netdev, pmksa) | ||
1594 | ); | ||
1595 | |||
1596 | TRACE_EVENT(rdev_remain_on_channel, | ||
1597 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev, | ||
1598 | struct ieee80211_channel *chan, | ||
1599 | unsigned int duration), | ||
1600 | TP_ARGS(wiphy, wdev, chan, duration), | ||
1601 | TP_STRUCT__entry( | ||
1602 | WIPHY_ENTRY | ||
1603 | WDEV_ENTRY | ||
1604 | CHAN_ENTRY | ||
1605 | __field(unsigned int, duration) | ||
1606 | ), | ||
1607 | TP_fast_assign( | ||
1608 | WIPHY_ASSIGN; | ||
1609 | WDEV_ASSIGN; | ||
1610 | CHAN_ASSIGN(chan); | ||
1611 | __entry->duration = duration; | ||
1612 | ), | ||
1613 | TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT ", " CHAN_PR_FMT ", duration: %u", | ||
1614 | WIPHY_PR_ARG, WDEV_PR_ARG, CHAN_PR_ARG, __entry->duration) | ||
1615 | ); | ||
1616 | |||
1617 | TRACE_EVENT(rdev_return_int_cookie, | ||
1618 | TP_PROTO(struct wiphy *wiphy, int ret, u64 cookie), | ||
1619 | TP_ARGS(wiphy, ret, cookie), | ||
1620 | TP_STRUCT__entry( | ||
1621 | WIPHY_ENTRY | ||
1622 | __field(int, ret) | ||
1623 | __field(u64, cookie) | ||
1624 | ), | ||
1625 | TP_fast_assign( | ||
1626 | WIPHY_ASSIGN; | ||
1627 | __entry->ret = ret; | ||
1628 | __entry->cookie = cookie; | ||
1629 | ), | ||
1630 | TP_printk(WIPHY_PR_FMT ", returned %d, cookie: %llu", | ||
1631 | WIPHY_PR_ARG, __entry->ret, __entry->cookie) | ||
1632 | ); | ||
1633 | |||
1634 | TRACE_EVENT(rdev_cancel_remain_on_channel, | ||
1635 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev, u64 cookie), | ||
1636 | TP_ARGS(wiphy, wdev, cookie), | ||
1637 | TP_STRUCT__entry( | ||
1638 | WIPHY_ENTRY | ||
1639 | WDEV_ENTRY | ||
1640 | __field(u64, cookie) | ||
1641 | ), | ||
1642 | TP_fast_assign( | ||
1643 | WIPHY_ASSIGN; | ||
1644 | WDEV_ASSIGN; | ||
1645 | __entry->cookie = cookie; | ||
1646 | ), | ||
1647 | TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT ", cookie: %llu", | ||
1648 | WIPHY_PR_ARG, WDEV_PR_ARG, __entry->cookie) | ||
1649 | ); | ||
1650 | |||
1651 | TRACE_EVENT(rdev_mgmt_tx, | ||
1652 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev, | ||
1653 | struct ieee80211_channel *chan, bool offchan, | ||
1654 | unsigned int wait, bool no_cck, bool dont_wait_for_ack), | ||
1655 | TP_ARGS(wiphy, wdev, chan, offchan, wait, no_cck, dont_wait_for_ack), | ||
1656 | TP_STRUCT__entry( | ||
1657 | WIPHY_ENTRY | ||
1658 | WDEV_ENTRY | ||
1659 | CHAN_ENTRY | ||
1660 | __field(bool, offchan) | ||
1661 | __field(unsigned int, wait) | ||
1662 | __field(bool, no_cck) | ||
1663 | __field(bool, dont_wait_for_ack) | ||
1664 | ), | ||
1665 | TP_fast_assign( | ||
1666 | WIPHY_ASSIGN; | ||
1667 | WDEV_ASSIGN; | ||
1668 | CHAN_ASSIGN(chan); | ||
1669 | __entry->offchan = offchan; | ||
1670 | __entry->wait = wait; | ||
1671 | __entry->no_cck = no_cck; | ||
1672 | __entry->dont_wait_for_ack = dont_wait_for_ack; | ||
1673 | ), | ||
1674 | TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT ", " CHAN_PR_FMT ", offchan: %s," | ||
1675 | " wait: %u, no cck: %s, dont wait for ack: %s", | ||
1676 | WIPHY_PR_ARG, WDEV_PR_ARG, CHAN_PR_ARG, | ||
1677 | BOOL_TO_STR(__entry->offchan), __entry->wait, | ||
1678 | BOOL_TO_STR(__entry->no_cck), | ||
1679 | BOOL_TO_STR(__entry->dont_wait_for_ack)) | ||
1680 | ); | ||
1681 | |||
1682 | TRACE_EVENT(rdev_set_noack_map, | ||
1683 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1684 | u16 noack_map), | ||
1685 | TP_ARGS(wiphy, netdev, noack_map), | ||
1686 | TP_STRUCT__entry( | ||
1687 | WIPHY_ENTRY | ||
1688 | NETDEV_ENTRY | ||
1689 | __field(u16, noack_map) | ||
1690 | ), | ||
1691 | TP_fast_assign( | ||
1692 | WIPHY_ASSIGN; | ||
1693 | NETDEV_ASSIGN; | ||
1694 | __entry->noack_map = noack_map; | ||
1695 | ), | ||
1696 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", noack_map: %u", | ||
1697 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->noack_map) | ||
1698 | ); | ||
1699 | |||
1700 | TRACE_EVENT(rdev_get_et_sset_count, | ||
1701 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, int sset), | ||
1702 | TP_ARGS(wiphy, netdev, sset), | ||
1703 | TP_STRUCT__entry( | ||
1704 | WIPHY_ENTRY | ||
1705 | NETDEV_ENTRY | ||
1706 | __field(int, sset) | ||
1707 | ), | ||
1708 | TP_fast_assign( | ||
1709 | WIPHY_ASSIGN; | ||
1710 | NETDEV_ASSIGN; | ||
1711 | __entry->sset = sset; | ||
1712 | ), | ||
1713 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", sset: %d", | ||
1714 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->sset) | ||
1715 | ); | ||
1716 | |||
1717 | TRACE_EVENT(rdev_get_et_strings, | ||
1718 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u32 sset), | ||
1719 | TP_ARGS(wiphy, netdev, sset), | ||
1720 | TP_STRUCT__entry( | ||
1721 | WIPHY_ENTRY | ||
1722 | NETDEV_ENTRY | ||
1723 | __field(u32, sset) | ||
1724 | ), | ||
1725 | TP_fast_assign( | ||
1726 | WIPHY_ASSIGN; | ||
1727 | NETDEV_ASSIGN; | ||
1728 | __entry->sset = sset; | ||
1729 | ), | ||
1730 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", sset: %u", | ||
1731 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->sset) | ||
1732 | ); | ||
1733 | |||
1734 | DEFINE_EVENT(wiphy_wdev_evt, rdev_get_channel, | ||
1735 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev), | ||
1736 | TP_ARGS(wiphy, wdev) | ||
1737 | ); | ||
1738 | |||
1739 | TRACE_EVENT(rdev_return_chandef, | ||
1740 | TP_PROTO(struct wiphy *wiphy, int ret, | ||
1741 | struct cfg80211_chan_def *chandef), | ||
1742 | TP_ARGS(wiphy, ret, chandef), | ||
1743 | TP_STRUCT__entry( | ||
1744 | WIPHY_ENTRY | ||
1745 | __field(int, ret) | ||
1746 | CHAN_DEF_ENTRY | ||
1747 | ), | ||
1748 | TP_fast_assign( | ||
1749 | WIPHY_ASSIGN; | ||
1750 | if (ret == 0) | ||
1751 | CHAN_DEF_ASSIGN(chandef); | ||
1752 | else | ||
1753 | CHAN_DEF_ASSIGN((struct cfg80211_chan_def *)NULL); | ||
1754 | __entry->ret = ret; | ||
1755 | ), | ||
1756 | TP_printk(WIPHY_PR_FMT ", " CHAN_DEF_PR_FMT ", ret: %d", | ||
1757 | WIPHY_PR_ARG, CHAN_DEF_PR_ARG, __entry->ret) | ||
1758 | ); | ||
1759 | |||
1760 | DEFINE_EVENT(wiphy_wdev_evt, rdev_start_p2p_device, | ||
1761 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev), | ||
1762 | TP_ARGS(wiphy, wdev) | ||
1763 | ); | ||
1764 | |||
1765 | DEFINE_EVENT(wiphy_wdev_evt, rdev_stop_p2p_device, | ||
1766 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev), | ||
1767 | TP_ARGS(wiphy, wdev) | ||
1768 | ); | ||
1769 | |||
1770 | /************************************************************* | ||
1771 | * cfg80211 exported functions traces * | ||
1772 | *************************************************************/ | ||
1773 | |||
1774 | TRACE_EVENT(cfg80211_return_bool, | ||
1775 | TP_PROTO(bool ret), | ||
1776 | TP_ARGS(ret), | ||
1777 | TP_STRUCT__entry( | ||
1778 | __field(bool, ret) | ||
1779 | ), | ||
1780 | TP_fast_assign( | ||
1781 | __entry->ret = ret; | ||
1782 | ), | ||
1783 | TP_printk("returned %s", BOOL_TO_STR(__entry->ret)) | ||
1784 | ); | ||
1785 | |||
1786 | DECLARE_EVENT_CLASS(cfg80211_netdev_mac_evt, | ||
1787 | TP_PROTO(struct net_device *netdev, const u8 *macaddr), | ||
1788 | TP_ARGS(netdev, macaddr), | ||
1789 | TP_STRUCT__entry( | ||
1790 | NETDEV_ENTRY | ||
1791 | MAC_ENTRY(macaddr) | ||
1792 | ), | ||
1793 | TP_fast_assign( | ||
1794 | NETDEV_ASSIGN; | ||
1795 | MAC_ASSIGN(macaddr, macaddr); | ||
1796 | ), | ||
1797 | TP_printk(NETDEV_PR_FMT ", mac: " MAC_PR_FMT, | ||
1798 | NETDEV_PR_ARG, MAC_PR_ARG(macaddr)) | ||
1799 | ); | ||
1800 | |||
1801 | DEFINE_EVENT(cfg80211_netdev_mac_evt, cfg80211_notify_new_peer_candidate, | ||
1802 | TP_PROTO(struct net_device *netdev, const u8 *macaddr), | ||
1803 | TP_ARGS(netdev, macaddr) | ||
1804 | ); | ||
1805 | |||
1806 | DECLARE_EVENT_CLASS(netdev_evt_only, | ||
1807 | TP_PROTO(struct net_device *netdev), | ||
1808 | TP_ARGS(netdev), | ||
1809 | TP_STRUCT__entry( | ||
1810 | NETDEV_ENTRY | ||
1811 | ), | ||
1812 | TP_fast_assign( | ||
1813 | NETDEV_ASSIGN; | ||
1814 | ), | ||
1815 | TP_printk(NETDEV_PR_FMT , NETDEV_PR_ARG) | ||
1816 | ); | ||
1817 | |||
1818 | DEFINE_EVENT(netdev_evt_only, cfg80211_send_rx_auth, | ||
1819 | TP_PROTO(struct net_device *netdev), | ||
1820 | TP_ARGS(netdev) | ||
1821 | ); | ||
1822 | |||
1823 | TRACE_EVENT(cfg80211_send_rx_assoc, | ||
1824 | TP_PROTO(struct net_device *netdev, struct cfg80211_bss *bss), | ||
1825 | TP_ARGS(netdev, bss), | ||
1826 | TP_STRUCT__entry( | ||
1827 | NETDEV_ENTRY | ||
1828 | MAC_ENTRY(bssid) | ||
1829 | CHAN_ENTRY | ||
1830 | ), | ||
1831 | TP_fast_assign( | ||
1832 | NETDEV_ASSIGN; | ||
1833 | MAC_ASSIGN(bssid, bss->bssid); | ||
1834 | CHAN_ASSIGN(bss->channel); | ||
1835 | ), | ||
1836 | TP_printk(NETDEV_PR_FMT ", " MAC_PR_FMT ", " CHAN_PR_FMT, | ||
1837 | NETDEV_PR_ARG, MAC_PR_ARG(bssid), CHAN_PR_ARG) | ||
1838 | ); | ||
1839 | |||
1840 | DEFINE_EVENT(netdev_evt_only, __cfg80211_send_deauth, | ||
1841 | TP_PROTO(struct net_device *netdev), | ||
1842 | TP_ARGS(netdev) | ||
1843 | ); | ||
1844 | |||
1845 | DEFINE_EVENT(netdev_evt_only, __cfg80211_send_disassoc, | ||
1846 | TP_PROTO(struct net_device *netdev), | ||
1847 | TP_ARGS(netdev) | ||
1848 | ); | ||
1849 | |||
1850 | DEFINE_EVENT(netdev_evt_only, cfg80211_send_unprot_deauth, | ||
1851 | TP_PROTO(struct net_device *netdev), | ||
1852 | TP_ARGS(netdev) | ||
1853 | ); | ||
1854 | |||
1855 | DEFINE_EVENT(netdev_evt_only, cfg80211_send_unprot_disassoc, | ||
1856 | TP_PROTO(struct net_device *netdev), | ||
1857 | TP_ARGS(netdev) | ||
1858 | ); | ||
1859 | |||
1860 | DECLARE_EVENT_CLASS(netdev_mac_evt, | ||
1861 | TP_PROTO(struct net_device *netdev, const u8 *mac), | ||
1862 | TP_ARGS(netdev, mac), | ||
1863 | TP_STRUCT__entry( | ||
1864 | NETDEV_ENTRY | ||
1865 | MAC_ENTRY(mac) | ||
1866 | ), | ||
1867 | TP_fast_assign( | ||
1868 | NETDEV_ASSIGN; | ||
1869 | MAC_ASSIGN(mac, mac) | ||
1870 | ), | ||
1871 | TP_printk(NETDEV_PR_FMT ", mac: " MAC_PR_FMT, | ||
1872 | NETDEV_PR_ARG, MAC_PR_ARG(mac)) | ||
1873 | ); | ||
1874 | |||
1875 | DEFINE_EVENT(netdev_mac_evt, cfg80211_send_auth_timeout, | ||
1876 | TP_PROTO(struct net_device *netdev, const u8 *mac), | ||
1877 | TP_ARGS(netdev, mac) | ||
1878 | ); | ||
1879 | |||
1880 | DEFINE_EVENT(netdev_mac_evt, cfg80211_send_assoc_timeout, | ||
1881 | TP_PROTO(struct net_device *netdev, const u8 *mac), | ||
1882 | TP_ARGS(netdev, mac) | ||
1883 | ); | ||
1884 | |||
1885 | TRACE_EVENT(cfg80211_michael_mic_failure, | ||
1886 | TP_PROTO(struct net_device *netdev, const u8 *addr, | ||
1887 | enum nl80211_key_type key_type, int key_id, const u8 *tsc), | ||
1888 | TP_ARGS(netdev, addr, key_type, key_id, tsc), | ||
1889 | TP_STRUCT__entry( | ||
1890 | NETDEV_ENTRY | ||
1891 | MAC_ENTRY(addr) | ||
1892 | __field(enum nl80211_key_type, key_type) | ||
1893 | __field(int, key_id) | ||
1894 | __array(u8, tsc, 6) | ||
1895 | ), | ||
1896 | TP_fast_assign( | ||
1897 | NETDEV_ASSIGN; | ||
1898 | MAC_ASSIGN(addr, addr); | ||
1899 | __entry->key_type = key_type; | ||
1900 | __entry->key_id = key_id; | ||
1901 | memcpy(__entry->tsc, tsc, 6); | ||
1902 | ), | ||
1903 | TP_printk(NETDEV_PR_FMT ", " MAC_PR_FMT ", key type: %d, key id: %d, tsc: %pm", | ||
1904 | NETDEV_PR_ARG, MAC_PR_ARG(addr), __entry->key_type, | ||
1905 | __entry->key_id, __entry->tsc) | ||
1906 | ); | ||
1907 | |||
1908 | TRACE_EVENT(cfg80211_ready_on_channel, | ||
1909 | TP_PROTO(struct wireless_dev *wdev, u64 cookie, | ||
1910 | struct ieee80211_channel *chan, | ||
1911 | unsigned int duration), | ||
1912 | TP_ARGS(wdev, cookie, chan, duration), | ||
1913 | TP_STRUCT__entry( | ||
1914 | WDEV_ENTRY | ||
1915 | __field(u64, cookie) | ||
1916 | CHAN_ENTRY | ||
1917 | __field(unsigned int, duration) | ||
1918 | ), | ||
1919 | TP_fast_assign( | ||
1920 | WDEV_ASSIGN; | ||
1921 | __entry->cookie = cookie; | ||
1922 | CHAN_ASSIGN(chan); | ||
1923 | __entry->duration = duration; | ||
1924 | ), | ||
1925 | TP_printk(WDEV_PR_FMT ", cookie: %llu, " CHAN_PR_FMT ", duration: %u", | ||
1926 | WDEV_PR_ARG, __entry->cookie, CHAN_PR_ARG, | ||
1927 | __entry->duration) | ||
1928 | ); | ||
1929 | |||
1930 | TRACE_EVENT(cfg80211_ready_on_channel_expired, | ||
1931 | TP_PROTO(struct wireless_dev *wdev, u64 cookie, | ||
1932 | struct ieee80211_channel *chan), | ||
1933 | TP_ARGS(wdev, cookie, chan), | ||
1934 | TP_STRUCT__entry( | ||
1935 | WDEV_ENTRY | ||
1936 | __field(u64, cookie) | ||
1937 | CHAN_ENTRY | ||
1938 | ), | ||
1939 | TP_fast_assign( | ||
1940 | WDEV_ASSIGN; | ||
1941 | __entry->cookie = cookie; | ||
1942 | CHAN_ASSIGN(chan); | ||
1943 | ), | ||
1944 | TP_printk(WDEV_PR_FMT ", cookie: %llu, " CHAN_PR_FMT, | ||
1945 | WDEV_PR_ARG, __entry->cookie, CHAN_PR_ARG) | ||
1946 | ); | ||
1947 | |||
1948 | TRACE_EVENT(cfg80211_new_sta, | ||
1949 | TP_PROTO(struct net_device *netdev, const u8 *mac_addr, | ||
1950 | struct station_info *sinfo), | ||
1951 | TP_ARGS(netdev, mac_addr, sinfo), | ||
1952 | TP_STRUCT__entry( | ||
1953 | NETDEV_ENTRY | ||
1954 | MAC_ENTRY(mac_addr) | ||
1955 | SINFO_ENTRY | ||
1956 | ), | ||
1957 | TP_fast_assign( | ||
1958 | NETDEV_ASSIGN; | ||
1959 | MAC_ASSIGN(mac_addr, mac_addr); | ||
1960 | SINFO_ASSIGN; | ||
1961 | ), | ||
1962 | TP_printk(NETDEV_PR_FMT ", " MAC_PR_FMT, | ||
1963 | NETDEV_PR_ARG, MAC_PR_ARG(mac_addr)) | ||
1964 | ); | ||
1965 | |||
1966 | DEFINE_EVENT(cfg80211_netdev_mac_evt, cfg80211_del_sta, | ||
1967 | TP_PROTO(struct net_device *netdev, const u8 *macaddr), | ||
1968 | TP_ARGS(netdev, macaddr) | ||
1969 | ); | ||
1970 | |||
1971 | TRACE_EVENT(cfg80211_rx_mgmt, | ||
1972 | TP_PROTO(struct wireless_dev *wdev, int freq, int sig_mbm), | ||
1973 | TP_ARGS(wdev, freq, sig_mbm), | ||
1974 | TP_STRUCT__entry( | ||
1975 | WDEV_ENTRY | ||
1976 | __field(int, freq) | ||
1977 | __field(int, sig_mbm) | ||
1978 | ), | ||
1979 | TP_fast_assign( | ||
1980 | WDEV_ASSIGN; | ||
1981 | __entry->freq = freq; | ||
1982 | __entry->sig_mbm = sig_mbm; | ||
1983 | ), | ||
1984 | TP_printk(WDEV_PR_FMT ", freq: %d, sig mbm: %d", | ||
1985 | WDEV_PR_ARG, __entry->freq, __entry->sig_mbm) | ||
1986 | ); | ||
1987 | |||
1988 | TRACE_EVENT(cfg80211_mgmt_tx_status, | ||
1989 | TP_PROTO(struct wireless_dev *wdev, u64 cookie, bool ack), | ||
1990 | TP_ARGS(wdev, cookie, ack), | ||
1991 | TP_STRUCT__entry( | ||
1992 | WDEV_ENTRY | ||
1993 | __field(u64, cookie) | ||
1994 | __field(bool, ack) | ||
1995 | ), | ||
1996 | TP_fast_assign( | ||
1997 | WDEV_ASSIGN; | ||
1998 | __entry->cookie = cookie; | ||
1999 | __entry->ack = ack; | ||
2000 | ), | ||
2001 | TP_printk(WDEV_PR_FMT", cookie: %llu, ack: %s", | ||
2002 | WDEV_PR_ARG, __entry->cookie, BOOL_TO_STR(__entry->ack)) | ||
2003 | ); | ||
2004 | |||
2005 | TRACE_EVENT(cfg80211_cqm_rssi_notify, | ||
2006 | TP_PROTO(struct net_device *netdev, | ||
2007 | enum nl80211_cqm_rssi_threshold_event rssi_event), | ||
2008 | TP_ARGS(netdev, rssi_event), | ||
2009 | TP_STRUCT__entry( | ||
2010 | NETDEV_ENTRY | ||
2011 | __field(enum nl80211_cqm_rssi_threshold_event, rssi_event) | ||
2012 | ), | ||
2013 | TP_fast_assign( | ||
2014 | NETDEV_ASSIGN; | ||
2015 | __entry->rssi_event = rssi_event; | ||
2016 | ), | ||
2017 | TP_printk(NETDEV_PR_FMT ", rssi event: %d", | ||
2018 | NETDEV_PR_ARG, __entry->rssi_event) | ||
2019 | ); | ||
2020 | |||
2021 | TRACE_EVENT(cfg80211_reg_can_beacon, | ||
2022 | TP_PROTO(struct wiphy *wiphy, struct cfg80211_chan_def *chandef), | ||
2023 | TP_ARGS(wiphy, chandef), | ||
2024 | TP_STRUCT__entry( | ||
2025 | WIPHY_ENTRY | ||
2026 | CHAN_DEF_ENTRY | ||
2027 | ), | ||
2028 | TP_fast_assign( | ||
2029 | WIPHY_ASSIGN; | ||
2030 | CHAN_DEF_ASSIGN(chandef); | ||
2031 | ), | ||
2032 | TP_printk(WIPHY_PR_FMT ", " CHAN_DEF_PR_FMT, | ||
2033 | WIPHY_PR_ARG, CHAN_DEF_PR_ARG) | ||
2034 | ); | ||
2035 | |||
2036 | TRACE_EVENT(cfg80211_ch_switch_notify, | ||
2037 | TP_PROTO(struct net_device *netdev, | ||
2038 | struct cfg80211_chan_def *chandef), | ||
2039 | TP_ARGS(netdev, chandef), | ||
2040 | TP_STRUCT__entry( | ||
2041 | NETDEV_ENTRY | ||
2042 | CHAN_DEF_ENTRY | ||
2043 | ), | ||
2044 | TP_fast_assign( | ||
2045 | NETDEV_ASSIGN; | ||
2046 | CHAN_DEF_ASSIGN(chandef); | ||
2047 | ), | ||
2048 | TP_printk(NETDEV_PR_FMT ", " CHAN_DEF_PR_FMT, | ||
2049 | NETDEV_PR_ARG, CHAN_DEF_PR_ARG) | ||
2050 | ); | ||
2051 | |||
2052 | DECLARE_EVENT_CLASS(cfg80211_rx_evt, | ||
2053 | TP_PROTO(struct net_device *netdev, const u8 *addr), | ||
2054 | TP_ARGS(netdev, addr), | ||
2055 | TP_STRUCT__entry( | ||
2056 | NETDEV_ENTRY | ||
2057 | MAC_ENTRY(addr) | ||
2058 | ), | ||
2059 | TP_fast_assign( | ||
2060 | NETDEV_ASSIGN; | ||
2061 | MAC_ASSIGN(addr, addr); | ||
2062 | ), | ||
2063 | TP_printk(NETDEV_PR_FMT ", " MAC_PR_FMT, NETDEV_PR_ARG, MAC_PR_ARG(addr)) | ||
2064 | ); | ||
2065 | |||
2066 | DEFINE_EVENT(cfg80211_rx_evt, cfg80211_ibss_joined, | ||
2067 | TP_PROTO(struct net_device *netdev, const u8 *addr), | ||
2068 | TP_ARGS(netdev, addr) | ||
2069 | ); | ||
2070 | |||
2071 | DEFINE_EVENT(cfg80211_rx_evt, cfg80211_rx_spurious_frame, | ||
2072 | TP_PROTO(struct net_device *netdev, const u8 *addr), | ||
2073 | TP_ARGS(netdev, addr) | ||
2074 | ); | ||
2075 | |||
2076 | DEFINE_EVENT(cfg80211_rx_evt, cfg80211_rx_unexpected_4addr_frame, | ||
2077 | TP_PROTO(struct net_device *netdev, const u8 *addr), | ||
2078 | TP_ARGS(netdev, addr) | ||
2079 | ); | ||
2080 | |||
2081 | TRACE_EVENT(cfg80211_probe_status, | ||
2082 | TP_PROTO(struct net_device *netdev, const u8 *addr, u64 cookie, | ||
2083 | bool acked), | ||
2084 | TP_ARGS(netdev, addr, cookie, acked), | ||
2085 | TP_STRUCT__entry( | ||
2086 | NETDEV_ENTRY | ||
2087 | MAC_ENTRY(addr) | ||
2088 | __field(u64, cookie) | ||
2089 | __field(bool, acked) | ||
2090 | ), | ||
2091 | TP_fast_assign( | ||
2092 | NETDEV_ASSIGN; | ||
2093 | MAC_ASSIGN(addr, addr); | ||
2094 | __entry->cookie = cookie; | ||
2095 | __entry->acked = acked; | ||
2096 | ), | ||
2097 | TP_printk(NETDEV_PR_FMT " addr:" MAC_PR_FMT ", cookie: %llu, acked: %s", | ||
2098 | NETDEV_PR_ARG, MAC_PR_ARG(addr), __entry->cookie, | ||
2099 | BOOL_TO_STR(__entry->acked)) | ||
2100 | ); | ||
2101 | |||
2102 | TRACE_EVENT(cfg80211_cqm_pktloss_notify, | ||
2103 | TP_PROTO(struct net_device *netdev, const u8 *peer, u32 num_packets), | ||
2104 | TP_ARGS(netdev, peer, num_packets), | ||
2105 | TP_STRUCT__entry( | ||
2106 | NETDEV_ENTRY | ||
2107 | MAC_ENTRY(peer) | ||
2108 | __field(u32, num_packets) | ||
2109 | ), | ||
2110 | TP_fast_assign( | ||
2111 | NETDEV_ASSIGN; | ||
2112 | MAC_ASSIGN(peer, peer); | ||
2113 | __entry->num_packets = num_packets; | ||
2114 | ), | ||
2115 | TP_printk(NETDEV_PR_FMT ", peer: " MAC_PR_FMT ", num of lost packets: %u", | ||
2116 | NETDEV_PR_ARG, MAC_PR_ARG(peer), __entry->num_packets) | ||
2117 | ); | ||
2118 | |||
2119 | DEFINE_EVENT(cfg80211_netdev_mac_evt, cfg80211_gtk_rekey_notify, | ||
2120 | TP_PROTO(struct net_device *netdev, const u8 *macaddr), | ||
2121 | TP_ARGS(netdev, macaddr) | ||
2122 | ); | ||
2123 | |||
2124 | TRACE_EVENT(cfg80211_pmksa_candidate_notify, | ||
2125 | TP_PROTO(struct net_device *netdev, int index, const u8 *bssid, | ||
2126 | bool preauth), | ||
2127 | TP_ARGS(netdev, index, bssid, preauth), | ||
2128 | TP_STRUCT__entry( | ||
2129 | NETDEV_ENTRY | ||
2130 | __field(int, index) | ||
2131 | MAC_ENTRY(bssid) | ||
2132 | __field(bool, preauth) | ||
2133 | ), | ||
2134 | TP_fast_assign( | ||
2135 | NETDEV_ASSIGN; | ||
2136 | __entry->index = index; | ||
2137 | MAC_ASSIGN(bssid, bssid); | ||
2138 | __entry->preauth = preauth; | ||
2139 | ), | ||
2140 | TP_printk(NETDEV_PR_FMT ", index:%d, bssid: " MAC_PR_FMT ", pre auth: %s", | ||
2141 | NETDEV_PR_ARG, __entry->index, MAC_PR_ARG(bssid), | ||
2142 | BOOL_TO_STR(__entry->preauth)) | ||
2143 | ); | ||
2144 | |||
2145 | TRACE_EVENT(cfg80211_report_obss_beacon, | ||
2146 | TP_PROTO(struct wiphy *wiphy, const u8 *frame, size_t len, | ||
2147 | int freq, int sig_dbm), | ||
2148 | TP_ARGS(wiphy, frame, len, freq, sig_dbm), | ||
2149 | TP_STRUCT__entry( | ||
2150 | WIPHY_ENTRY | ||
2151 | __field(int, freq) | ||
2152 | __field(int, sig_dbm) | ||
2153 | ), | ||
2154 | TP_fast_assign( | ||
2155 | WIPHY_ASSIGN; | ||
2156 | __entry->freq = freq; | ||
2157 | __entry->sig_dbm = sig_dbm; | ||
2158 | ), | ||
2159 | TP_printk(WIPHY_PR_FMT ", freq: %d, sig_dbm: %d", | ||
2160 | WIPHY_PR_ARG, __entry->freq, __entry->sig_dbm) | ||
2161 | ); | ||
2162 | |||
2163 | TRACE_EVENT(cfg80211_tdls_oper_request, | ||
2164 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, const u8 *peer, | ||
2165 | enum nl80211_tdls_operation oper, u16 reason_code), | ||
2166 | TP_ARGS(wiphy, netdev, peer, oper, reason_code), | ||
2167 | TP_STRUCT__entry( | ||
2168 | WIPHY_ENTRY | ||
2169 | NETDEV_ENTRY | ||
2170 | MAC_ENTRY(peer) | ||
2171 | __field(enum nl80211_tdls_operation, oper) | ||
2172 | __field(u16, reason_code) | ||
2173 | ), | ||
2174 | TP_fast_assign( | ||
2175 | WIPHY_ASSIGN; | ||
2176 | NETDEV_ASSIGN; | ||
2177 | MAC_ASSIGN(peer, peer); | ||
2178 | __entry->oper = oper; | ||
2179 | __entry->reason_code = reason_code; | ||
2180 | ), | ||
2181 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", peer: " MAC_PR_FMT ", oper: %d, reason_code %u", | ||
2182 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer), __entry->oper, | ||
2183 | __entry->reason_code) | ||
2184 | ); | ||
2185 | |||
2186 | TRACE_EVENT(cfg80211_scan_done, | ||
2187 | TP_PROTO(struct cfg80211_scan_request *request, bool aborted), | ||
2188 | TP_ARGS(request, aborted), | ||
2189 | TP_STRUCT__entry( | ||
2190 | __field(u32, n_channels) | ||
2191 | __dynamic_array(u8, ie, request ? request->ie_len : 0) | ||
2192 | __array(u32, rates, IEEE80211_NUM_BANDS) | ||
2193 | __field(u32, wdev_id) | ||
2194 | MAC_ENTRY(wiphy_mac) | ||
2195 | __field(bool, no_cck) | ||
2196 | __field(bool, aborted) | ||
2197 | ), | ||
2198 | TP_fast_assign( | ||
2199 | if (request) { | ||
2200 | memcpy(__get_dynamic_array(ie), request->ie, | ||
2201 | request->ie_len); | ||
2202 | memcpy(__entry->rates, request->rates, | ||
2203 | IEEE80211_NUM_BANDS); | ||
2204 | __entry->wdev_id = request->wdev ? | ||
2205 | request->wdev->identifier : 0; | ||
2206 | if (request->wiphy) | ||
2207 | MAC_ASSIGN(wiphy_mac, | ||
2208 | request->wiphy->perm_addr); | ||
2209 | __entry->no_cck = request->no_cck; | ||
2210 | } | ||
2211 | __entry->aborted = aborted; | ||
2212 | ), | ||
2213 | TP_printk("aborted: %s", BOOL_TO_STR(__entry->aborted)) | ||
2214 | ); | ||
2215 | |||
2216 | DEFINE_EVENT(wiphy_only_evt, cfg80211_sched_scan_results, | ||
2217 | TP_PROTO(struct wiphy *wiphy), | ||
2218 | TP_ARGS(wiphy) | ||
2219 | ); | ||
2220 | |||
2221 | DEFINE_EVENT(wiphy_only_evt, cfg80211_sched_scan_stopped, | ||
2222 | TP_PROTO(struct wiphy *wiphy), | ||
2223 | TP_ARGS(wiphy) | ||
2224 | ); | ||
2225 | |||
2226 | TRACE_EVENT(cfg80211_get_bss, | ||
2227 | TP_PROTO(struct wiphy *wiphy, struct ieee80211_channel *channel, | ||
2228 | const u8 *bssid, const u8 *ssid, size_t ssid_len, | ||
2229 | u16 capa_mask, u16 capa_val), | ||
2230 | TP_ARGS(wiphy, channel, bssid, ssid, ssid_len, capa_mask, capa_val), | ||
2231 | TP_STRUCT__entry( | ||
2232 | WIPHY_ENTRY | ||
2233 | CHAN_ENTRY | ||
2234 | MAC_ENTRY(bssid) | ||
2235 | __dynamic_array(u8, ssid, ssid_len) | ||
2236 | __field(u16, capa_mask) | ||
2237 | __field(u16, capa_val) | ||
2238 | ), | ||
2239 | TP_fast_assign( | ||
2240 | WIPHY_ASSIGN; | ||
2241 | CHAN_ASSIGN(channel); | ||
2242 | MAC_ASSIGN(bssid, bssid); | ||
2243 | memcpy(__get_dynamic_array(ssid), ssid, ssid_len); | ||
2244 | __entry->capa_mask = capa_mask; | ||
2245 | __entry->capa_val = capa_val; | ||
2246 | ), | ||
2247 | TP_printk(WIPHY_PR_FMT ", " CHAN_PR_FMT ", " MAC_PR_FMT ", buf: %#.2x, " | ||
2248 | "capa_mask: %d, capa_val: %u", WIPHY_PR_ARG, CHAN_PR_ARG, | ||
2249 | MAC_PR_ARG(bssid), ((u8 *)__get_dynamic_array(ssid))[0], | ||
2250 | __entry->capa_mask, __entry->capa_val) | ||
2251 | ); | ||
2252 | |||
2253 | TRACE_EVENT(cfg80211_inform_bss_frame, | ||
2254 | TP_PROTO(struct wiphy *wiphy, struct ieee80211_channel *channel, | ||
2255 | struct ieee80211_mgmt *mgmt, size_t len, | ||
2256 | s32 signal), | ||
2257 | TP_ARGS(wiphy, channel, mgmt, len, signal), | ||
2258 | TP_STRUCT__entry( | ||
2259 | WIPHY_ENTRY | ||
2260 | CHAN_ENTRY | ||
2261 | __dynamic_array(u8, mgmt, len) | ||
2262 | __field(s32, signal) | ||
2263 | ), | ||
2264 | TP_fast_assign( | ||
2265 | WIPHY_ASSIGN; | ||
2266 | CHAN_ASSIGN(channel); | ||
2267 | if (mgmt) | ||
2268 | memcpy(__get_dynamic_array(mgmt), mgmt, len); | ||
2269 | __entry->signal = signal; | ||
2270 | ), | ||
2271 | TP_printk(WIPHY_PR_FMT ", " CHAN_PR_FMT "signal: %d", | ||
2272 | WIPHY_PR_ARG, CHAN_PR_ARG, __entry->signal) | ||
2273 | ); | ||
2274 | |||
2275 | DECLARE_EVENT_CLASS(cfg80211_bss_evt, | ||
2276 | TP_PROTO(struct cfg80211_bss *pub), | ||
2277 | TP_ARGS(pub), | ||
2278 | TP_STRUCT__entry( | ||
2279 | MAC_ENTRY(bssid) | ||
2280 | CHAN_ENTRY | ||
2281 | ), | ||
2282 | TP_fast_assign( | ||
2283 | MAC_ASSIGN(bssid, pub->bssid); | ||
2284 | CHAN_ASSIGN(pub->channel); | ||
2285 | ), | ||
2286 | TP_printk(MAC_PR_FMT ", " CHAN_PR_FMT, MAC_PR_ARG(bssid), CHAN_PR_ARG) | ||
2287 | ); | ||
2288 | |||
2289 | DEFINE_EVENT(cfg80211_bss_evt, cfg80211_return_bss, | ||
2290 | TP_PROTO(struct cfg80211_bss *pub), | ||
2291 | TP_ARGS(pub) | ||
2292 | ); | ||
2293 | |||
2294 | TRACE_EVENT(cfg80211_return_uint, | ||
2295 | TP_PROTO(unsigned int ret), | ||
2296 | TP_ARGS(ret), | ||
2297 | TP_STRUCT__entry( | ||
2298 | __field(unsigned int, ret) | ||
2299 | ), | ||
2300 | TP_fast_assign( | ||
2301 | __entry->ret = ret; | ||
2302 | ), | ||
2303 | TP_printk("ret: %d", __entry->ret) | ||
2304 | ); | ||
2305 | |||
2306 | TRACE_EVENT(cfg80211_return_u32, | ||
2307 | TP_PROTO(u32 ret), | ||
2308 | TP_ARGS(ret), | ||
2309 | TP_STRUCT__entry( | ||
2310 | __field(u32, ret) | ||
2311 | ), | ||
2312 | TP_fast_assign( | ||
2313 | __entry->ret = ret; | ||
2314 | ), | ||
2315 | TP_printk("ret: %u", __entry->ret) | ||
2316 | ); | ||
2317 | |||
2318 | #endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */ | ||
2319 | |||
2320 | #undef TRACE_INCLUDE_PATH | ||
2321 | #define TRACE_INCLUDE_PATH . | ||
2322 | #undef TRACE_INCLUDE_FILE | ||
2323 | #define TRACE_INCLUDE_FILE trace | ||
2324 | #include <trace/define_trace.h> | ||
diff --git a/net/wireless/util.c b/net/wireless/util.c index 16d76a807c2..be75a3a0424 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c | |||
@@ -3,16 +3,12 @@ | |||
3 | * | 3 | * |
4 | * Copyright 2007-2009 Johannes Berg <johannes@sipsolutions.net> | 4 | * Copyright 2007-2009 Johannes Berg <johannes@sipsolutions.net> |
5 | */ | 5 | */ |
6 | #include <linux/export.h> | ||
7 | #include <linux/bitops.h> | 6 | #include <linux/bitops.h> |
8 | #include <linux/etherdevice.h> | 7 | #include <linux/etherdevice.h> |
9 | #include <linux/slab.h> | 8 | #include <linux/slab.h> |
10 | #include <net/cfg80211.h> | 9 | #include <net/cfg80211.h> |
11 | #include <net/ip.h> | 10 | #include <net/ip.h> |
12 | #include <net/dsfield.h> | ||
13 | #include "core.h" | 11 | #include "core.h" |
14 | #include "rdev-ops.h" | ||
15 | |||
16 | 12 | ||
17 | struct ieee80211_rate * | 13 | struct ieee80211_rate * |
18 | ieee80211_get_response_rate(struct ieee80211_supported_band *sband, | 14 | ieee80211_get_response_rate(struct ieee80211_supported_band *sband, |
@@ -37,29 +33,19 @@ int ieee80211_channel_to_frequency(int chan, enum ieee80211_band band) | |||
37 | { | 33 | { |
38 | /* see 802.11 17.3.8.3.2 and Annex J | 34 | /* see 802.11 17.3.8.3.2 and Annex J |
39 | * there are overlapping channel numbers in 5GHz and 2GHz bands */ | 35 | * there are overlapping channel numbers in 5GHz and 2GHz bands */ |
40 | if (chan <= 0) | 36 | if (band == IEEE80211_BAND_5GHZ) { |
41 | return 0; /* not supported */ | 37 | if (chan >= 182 && chan <= 196) |
42 | switch (band) { | 38 | return 4000 + chan * 5; |
43 | case IEEE80211_BAND_2GHZ: | 39 | else |
40 | return 5000 + chan * 5; | ||
41 | } else { /* IEEE80211_BAND_2GHZ */ | ||
44 | if (chan == 14) | 42 | if (chan == 14) |
45 | return 2484; | 43 | return 2484; |
46 | else if (chan < 14) | 44 | else if (chan < 14) |
47 | return 2407 + chan * 5; | 45 | return 2407 + chan * 5; |
48 | break; | ||
49 | case IEEE80211_BAND_5GHZ: | ||
50 | if (chan >= 182 && chan <= 196) | ||
51 | return 4000 + chan * 5; | ||
52 | else | 46 | else |
53 | return 5000 + chan * 5; | 47 | return 0; /* not supported */ |
54 | break; | ||
55 | case IEEE80211_BAND_60GHZ: | ||
56 | if (chan < 5) | ||
57 | return 56160 + chan * 2160; | ||
58 | break; | ||
59 | default: | ||
60 | ; | ||
61 | } | 48 | } |
62 | return 0; /* not supported */ | ||
63 | } | 49 | } |
64 | EXPORT_SYMBOL(ieee80211_channel_to_frequency); | 50 | EXPORT_SYMBOL(ieee80211_channel_to_frequency); |
65 | 51 | ||
@@ -72,12 +58,8 @@ int ieee80211_frequency_to_channel(int freq) | |||
72 | return (freq - 2407) / 5; | 58 | return (freq - 2407) / 5; |
73 | else if (freq >= 4910 && freq <= 4980) | 59 | else if (freq >= 4910 && freq <= 4980) |
74 | return (freq - 4000) / 5; | 60 | return (freq - 4000) / 5; |
75 | else if (freq <= 45000) /* DMG band lower limit */ | ||
76 | return (freq - 5000) / 5; | ||
77 | else if (freq >= 58320 && freq <= 64800) | ||
78 | return (freq - 56160) / 2160; | ||
79 | else | 61 | else |
80 | return 0; | 62 | return (freq - 5000) / 5; |
81 | } | 63 | } |
82 | EXPORT_SYMBOL(ieee80211_frequency_to_channel); | 64 | EXPORT_SYMBOL(ieee80211_frequency_to_channel); |
83 | 65 | ||
@@ -153,11 +135,6 @@ static void set_mandatory_flags_band(struct ieee80211_supported_band *sband, | |||
153 | } | 135 | } |
154 | WARN_ON(want != 0 && want != 3 && want != 6); | 136 | WARN_ON(want != 0 && want != 3 && want != 6); |
155 | break; | 137 | break; |
156 | case IEEE80211_BAND_60GHZ: | ||
157 | /* check for mandatory HT MCS 1..4 */ | ||
158 | WARN_ON(!sband->ht_cap.ht_supported); | ||
159 | WARN_ON((sband->ht_cap.mcs.rx_mask[0] & 0x1e) != 0x1e); | ||
160 | break; | ||
161 | case IEEE80211_NUM_BANDS: | 138 | case IEEE80211_NUM_BANDS: |
162 | WARN_ON(1); | 139 | WARN_ON(1); |
163 | break; | 140 | break; |
@@ -173,19 +150,12 @@ void ieee80211_set_bitrate_flags(struct wiphy *wiphy) | |||
173 | set_mandatory_flags_band(wiphy->bands[band], band); | 150 | set_mandatory_flags_band(wiphy->bands[band], band); |
174 | } | 151 | } |
175 | 152 | ||
176 | bool cfg80211_supported_cipher_suite(struct wiphy *wiphy, u32 cipher) | ||
177 | { | ||
178 | int i; | ||
179 | for (i = 0; i < wiphy->n_cipher_suites; i++) | ||
180 | if (cipher == wiphy->cipher_suites[i]) | ||
181 | return true; | ||
182 | return false; | ||
183 | } | ||
184 | |||
185 | int cfg80211_validate_key_settings(struct cfg80211_registered_device *rdev, | 153 | int cfg80211_validate_key_settings(struct cfg80211_registered_device *rdev, |
186 | struct key_params *params, int key_idx, | 154 | struct key_params *params, int key_idx, |
187 | bool pairwise, const u8 *mac_addr) | 155 | bool pairwise, const u8 *mac_addr) |
188 | { | 156 | { |
157 | int i; | ||
158 | |||
189 | if (key_idx > 5) | 159 | if (key_idx > 5) |
190 | return -EINVAL; | 160 | return -EINVAL; |
191 | 161 | ||
@@ -255,12 +225,26 @@ int cfg80211_validate_key_settings(struct cfg80211_registered_device *rdev, | |||
255 | } | 225 | } |
256 | } | 226 | } |
257 | 227 | ||
258 | if (!cfg80211_supported_cipher_suite(&rdev->wiphy, params->cipher)) | 228 | for (i = 0; i < rdev->wiphy.n_cipher_suites; i++) |
229 | if (params->cipher == rdev->wiphy.cipher_suites[i]) | ||
230 | break; | ||
231 | if (i == rdev->wiphy.n_cipher_suites) | ||
259 | return -EINVAL; | 232 | return -EINVAL; |
260 | 233 | ||
261 | return 0; | 234 | return 0; |
262 | } | 235 | } |
263 | 236 | ||
237 | /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ | ||
238 | /* Ethernet-II snap header (RFC1042 for most EtherTypes) */ | ||
239 | const unsigned char rfc1042_header[] __aligned(2) = | ||
240 | { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; | ||
241 | EXPORT_SYMBOL(rfc1042_header); | ||
242 | |||
243 | /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */ | ||
244 | const unsigned char bridge_tunnel_header[] __aligned(2) = | ||
245 | { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 }; | ||
246 | EXPORT_SYMBOL(bridge_tunnel_header); | ||
247 | |||
264 | unsigned int __attribute_const__ ieee80211_hdrlen(__le16 fc) | 248 | unsigned int __attribute_const__ ieee80211_hdrlen(__le16 fc) |
265 | { | 249 | { |
266 | unsigned int hdrlen = 24; | 250 | unsigned int hdrlen = 24; |
@@ -311,21 +295,23 @@ unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb) | |||
311 | } | 295 | } |
312 | EXPORT_SYMBOL(ieee80211_get_hdrlen_from_skb); | 296 | EXPORT_SYMBOL(ieee80211_get_hdrlen_from_skb); |
313 | 297 | ||
314 | unsigned int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr) | 298 | static int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr) |
315 | { | 299 | { |
316 | int ae = meshhdr->flags & MESH_FLAGS_AE; | 300 | int ae = meshhdr->flags & MESH_FLAGS_AE; |
317 | /* 802.11-2012, 8.2.4.7.3 */ | 301 | /* 7.1.3.5a.2 */ |
318 | switch (ae) { | 302 | switch (ae) { |
319 | default: | ||
320 | case 0: | 303 | case 0: |
321 | return 6; | 304 | return 6; |
322 | case MESH_FLAGS_AE_A4: | 305 | case MESH_FLAGS_AE_A4: |
323 | return 12; | 306 | return 12; |
324 | case MESH_FLAGS_AE_A5_A6: | 307 | case MESH_FLAGS_AE_A5_A6: |
325 | return 18; | 308 | return 18; |
309 | case (MESH_FLAGS_AE_A4 | MESH_FLAGS_AE_A5_A6): | ||
310 | return 24; | ||
311 | default: | ||
312 | return 6; | ||
326 | } | 313 | } |
327 | } | 314 | } |
328 | EXPORT_SYMBOL(ieee80211_get_mesh_hdrlen); | ||
329 | 315 | ||
330 | int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr, | 316 | int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr, |
331 | enum nl80211_iftype iftype) | 317 | enum nl80211_iftype iftype) |
@@ -373,8 +359,6 @@ int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr, | |||
373 | /* make sure meshdr->flags is on the linear part */ | 359 | /* make sure meshdr->flags is on the linear part */ |
374 | if (!pskb_may_pull(skb, hdrlen + 1)) | 360 | if (!pskb_may_pull(skb, hdrlen + 1)) |
375 | return -1; | 361 | return -1; |
376 | if (meshdr->flags & MESH_FLAGS_AE_A4) | ||
377 | return -1; | ||
378 | if (meshdr->flags & MESH_FLAGS_AE_A5_A6) { | 362 | if (meshdr->flags & MESH_FLAGS_AE_A5_A6) { |
379 | skb_copy_bits(skb, hdrlen + | 363 | skb_copy_bits(skb, hdrlen + |
380 | offsetof(struct ieee80211s_hdr, eaddr1), | 364 | offsetof(struct ieee80211s_hdr, eaddr1), |
@@ -391,7 +375,7 @@ int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr, | |||
391 | iftype != NL80211_IFTYPE_P2P_CLIENT && | 375 | iftype != NL80211_IFTYPE_P2P_CLIENT && |
392 | iftype != NL80211_IFTYPE_MESH_POINT) || | 376 | iftype != NL80211_IFTYPE_MESH_POINT) || |
393 | (is_multicast_ether_addr(dst) && | 377 | (is_multicast_ether_addr(dst) && |
394 | ether_addr_equal(src, addr))) | 378 | !compare_ether_addr(src, addr))) |
395 | return -1; | 379 | return -1; |
396 | if (iftype == NL80211_IFTYPE_MESH_POINT) { | 380 | if (iftype == NL80211_IFTYPE_MESH_POINT) { |
397 | struct ieee80211s_hdr *meshdr = | 381 | struct ieee80211s_hdr *meshdr = |
@@ -399,8 +383,6 @@ int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr, | |||
399 | /* make sure meshdr->flags is on the linear part */ | 383 | /* make sure meshdr->flags is on the linear part */ |
400 | if (!pskb_may_pull(skb, hdrlen + 1)) | 384 | if (!pskb_may_pull(skb, hdrlen + 1)) |
401 | return -1; | 385 | return -1; |
402 | if (meshdr->flags & MESH_FLAGS_AE_A5_A6) | ||
403 | return -1; | ||
404 | if (meshdr->flags & MESH_FLAGS_AE_A4) | 386 | if (meshdr->flags & MESH_FLAGS_AE_A4) |
405 | skb_copy_bits(skb, hdrlen + | 387 | skb_copy_bits(skb, hdrlen + |
406 | offsetof(struct ieee80211s_hdr, eaddr1), | 388 | offsetof(struct ieee80211s_hdr, eaddr1), |
@@ -409,9 +391,8 @@ int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr, | |||
409 | } | 391 | } |
410 | break; | 392 | break; |
411 | case cpu_to_le16(0): | 393 | case cpu_to_le16(0): |
412 | if (iftype != NL80211_IFTYPE_ADHOC && | 394 | if (iftype != NL80211_IFTYPE_ADHOC) |
413 | iftype != NL80211_IFTYPE_STATION) | 395 | return -1; |
414 | return -1; | ||
415 | break; | 396 | break; |
416 | } | 397 | } |
417 | 398 | ||
@@ -421,9 +402,9 @@ int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr, | |||
421 | payload = skb->data + hdrlen; | 402 | payload = skb->data + hdrlen; |
422 | ethertype = (payload[6] << 8) | payload[7]; | 403 | ethertype = (payload[6] << 8) | payload[7]; |
423 | 404 | ||
424 | if (likely((ether_addr_equal(payload, rfc1042_header) && | 405 | if (likely((compare_ether_addr(payload, rfc1042_header) == 0 && |
425 | ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || | 406 | ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || |
426 | ether_addr_equal(payload, bridge_tunnel_header))) { | 407 | compare_ether_addr(payload, bridge_tunnel_header) == 0)) { |
427 | /* remove RFC1042 or Bridge-Tunnel encapsulation and | 408 | /* remove RFC1042 or Bridge-Tunnel encapsulation and |
428 | * replace EtherType */ | 409 | * replace EtherType */ |
429 | skb_pull(skb, hdrlen + 6); | 410 | skb_pull(skb, hdrlen + 6); |
@@ -531,9 +512,10 @@ int ieee80211_data_from_8023(struct sk_buff *skb, const u8 *addr, | |||
531 | if (head_need) | 512 | if (head_need) |
532 | skb_orphan(skb); | 513 | skb_orphan(skb); |
533 | 514 | ||
534 | if (pskb_expand_head(skb, head_need, 0, GFP_ATOMIC)) | 515 | if (pskb_expand_head(skb, head_need, 0, GFP_ATOMIC)) { |
516 | pr_err("failed to reallocate Tx buffer\n"); | ||
535 | return -ENOMEM; | 517 | return -ENOMEM; |
536 | 518 | } | |
537 | skb->truesize += head_need; | 519 | skb->truesize += head_need; |
538 | } | 520 | } |
539 | 521 | ||
@@ -632,9 +614,10 @@ void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list, | |||
632 | payload = frame->data; | 614 | payload = frame->data; |
633 | ethertype = (payload[6] << 8) | payload[7]; | 615 | ethertype = (payload[6] << 8) | payload[7]; |
634 | 616 | ||
635 | if (likely((ether_addr_equal(payload, rfc1042_header) && | 617 | if (likely((compare_ether_addr(payload, rfc1042_header) == 0 && |
636 | ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || | 618 | ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || |
637 | ether_addr_equal(payload, bridge_tunnel_header))) { | 619 | compare_ether_addr(payload, |
620 | bridge_tunnel_header) == 0)) { | ||
638 | /* remove RFC1042 or Bridge-Tunnel | 621 | /* remove RFC1042 or Bridge-Tunnel |
639 | * encapsulation and replace EtherType */ | 622 | * encapsulation and replace EtherType */ |
640 | skb_pull(frame, 6); | 623 | skb_pull(frame, 6); |
@@ -673,10 +656,7 @@ unsigned int cfg80211_classify8021d(struct sk_buff *skb) | |||
673 | 656 | ||
674 | switch (skb->protocol) { | 657 | switch (skb->protocol) { |
675 | case htons(ETH_P_IP): | 658 | case htons(ETH_P_IP): |
676 | dscp = ipv4_get_dsfield(ip_hdr(skb)) & 0xfc; | 659 | dscp = ip_hdr(skb)->tos & 0xfc; |
677 | break; | ||
678 | case htons(ETH_P_IPV6): | ||
679 | dscp = ipv6_get_dsfield(ipv6_hdr(skb)) & 0xfc; | ||
680 | break; | 660 | break; |
681 | default: | 661 | default: |
682 | return 0; | 662 | return 0; |
@@ -688,13 +668,22 @@ EXPORT_SYMBOL(cfg80211_classify8021d); | |||
688 | 668 | ||
689 | const u8 *ieee80211_bss_get_ie(struct cfg80211_bss *bss, u8 ie) | 669 | const u8 *ieee80211_bss_get_ie(struct cfg80211_bss *bss, u8 ie) |
690 | { | 670 | { |
691 | const struct cfg80211_bss_ies *ies; | 671 | u8 *end, *pos; |
692 | 672 | ||
693 | ies = rcu_dereference(bss->ies); | 673 | pos = bss->information_elements; |
694 | if (!ies) | 674 | if (pos == NULL) |
695 | return NULL; | 675 | return NULL; |
676 | end = pos + bss->len_information_elements; | ||
677 | |||
678 | while (pos + 1 < end) { | ||
679 | if (pos + 2 + pos[1] > end) | ||
680 | break; | ||
681 | if (pos[0] == ie) | ||
682 | return pos; | ||
683 | pos += 2 + pos[1]; | ||
684 | } | ||
696 | 685 | ||
697 | return cfg80211_find_ie(ie, ies->data, ies->len); | 686 | return NULL; |
698 | } | 687 | } |
699 | EXPORT_SYMBOL(ieee80211_bss_get_ie); | 688 | EXPORT_SYMBOL(ieee80211_bss_get_ie); |
700 | 689 | ||
@@ -710,18 +699,19 @@ void cfg80211_upload_connect_keys(struct wireless_dev *wdev) | |||
710 | for (i = 0; i < 6; i++) { | 699 | for (i = 0; i < 6; i++) { |
711 | if (!wdev->connect_keys->params[i].cipher) | 700 | if (!wdev->connect_keys->params[i].cipher) |
712 | continue; | 701 | continue; |
713 | if (rdev_add_key(rdev, dev, i, false, NULL, | 702 | if (rdev->ops->add_key(wdev->wiphy, dev, i, false, NULL, |
714 | &wdev->connect_keys->params[i])) { | 703 | &wdev->connect_keys->params[i])) { |
715 | netdev_err(dev, "failed to set key %d\n", i); | 704 | netdev_err(dev, "failed to set key %d\n", i); |
716 | continue; | 705 | continue; |
717 | } | 706 | } |
718 | if (wdev->connect_keys->def == i) | 707 | if (wdev->connect_keys->def == i) |
719 | if (rdev_set_default_key(rdev, dev, i, true, true)) { | 708 | if (rdev->ops->set_default_key(wdev->wiphy, dev, |
709 | i, true, true)) { | ||
720 | netdev_err(dev, "failed to set defkey %d\n", i); | 710 | netdev_err(dev, "failed to set defkey %d\n", i); |
721 | continue; | 711 | continue; |
722 | } | 712 | } |
723 | if (wdev->connect_keys->defmgmt == i) | 713 | if (wdev->connect_keys->defmgmt == i) |
724 | if (rdev_set_default_mgmt_key(rdev, dev, i)) | 714 | if (rdev->ops->set_default_mgmt_key(wdev->wiphy, dev, i)) |
725 | netdev_err(dev, "failed to set mgtdef %d\n", i); | 715 | netdev_err(dev, "failed to set mgtdef %d\n", i); |
726 | } | 716 | } |
727 | 717 | ||
@@ -729,7 +719,7 @@ void cfg80211_upload_connect_keys(struct wireless_dev *wdev) | |||
729 | wdev->connect_keys = NULL; | 719 | wdev->connect_keys = NULL; |
730 | } | 720 | } |
731 | 721 | ||
732 | void cfg80211_process_wdev_events(struct wireless_dev *wdev) | 722 | static void cfg80211_process_wdev_events(struct wireless_dev *wdev) |
733 | { | 723 | { |
734 | struct cfg80211_event *ev; | 724 | struct cfg80211_event *ev; |
735 | unsigned long flags; | 725 | unsigned long flags; |
@@ -756,9 +746,9 @@ void cfg80211_process_wdev_events(struct wireless_dev *wdev) | |||
756 | NULL); | 746 | NULL); |
757 | break; | 747 | break; |
758 | case EVENT_ROAMED: | 748 | case EVENT_ROAMED: |
759 | __cfg80211_roamed(wdev, ev->rm.bss, ev->rm.req_ie, | 749 | __cfg80211_roamed(wdev, ev->rm.channel, ev->rm.bssid, |
760 | ev->rm.req_ie_len, ev->rm.resp_ie, | 750 | ev->rm.req_ie, ev->rm.req_ie_len, |
761 | ev->rm.resp_ie_len); | 751 | ev->rm.resp_ie, ev->rm.resp_ie_len); |
762 | break; | 752 | break; |
763 | case EVENT_DISCONNECTED: | 753 | case EVENT_DISCONNECTED: |
764 | __cfg80211_disconnected(wdev->netdev, | 754 | __cfg80211_disconnected(wdev->netdev, |
@@ -787,7 +777,7 @@ void cfg80211_process_rdev_events(struct cfg80211_registered_device *rdev) | |||
787 | 777 | ||
788 | mutex_lock(&rdev->devlist_mtx); | 778 | mutex_lock(&rdev->devlist_mtx); |
789 | 779 | ||
790 | list_for_each_entry(wdev, &rdev->wdev_list, list) | 780 | list_for_each_entry(wdev, &rdev->netdev_list, list) |
791 | cfg80211_process_wdev_events(wdev); | 781 | cfg80211_process_wdev_events(wdev); |
792 | 782 | ||
793 | mutex_unlock(&rdev->devlist_mtx); | 783 | mutex_unlock(&rdev->devlist_mtx); |
@@ -806,10 +796,6 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev, | |||
806 | if (otype == NL80211_IFTYPE_AP_VLAN) | 796 | if (otype == NL80211_IFTYPE_AP_VLAN) |
807 | return -EOPNOTSUPP; | 797 | return -EOPNOTSUPP; |
808 | 798 | ||
809 | /* cannot change into P2P device type */ | ||
810 | if (ntype == NL80211_IFTYPE_P2P_DEVICE) | ||
811 | return -EOPNOTSUPP; | ||
812 | |||
813 | if (!rdev->ops->change_virtual_intf || | 799 | if (!rdev->ops->change_virtual_intf || |
814 | !(rdev->wiphy.interface_modes & (1 << ntype))) | 800 | !(rdev->wiphy.interface_modes & (1 << ntype))) |
815 | return -EOPNOTSUPP; | 801 | return -EOPNOTSUPP; |
@@ -821,11 +807,9 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev, | |||
821 | ntype == NL80211_IFTYPE_P2P_CLIENT)) | 807 | ntype == NL80211_IFTYPE_P2P_CLIENT)) |
822 | return -EBUSY; | 808 | return -EBUSY; |
823 | 809 | ||
824 | if (ntype != otype && netif_running(dev)) { | 810 | if (ntype != otype) { |
825 | mutex_lock(&rdev->devlist_mtx); | ||
826 | err = cfg80211_can_change_interface(rdev, dev->ieee80211_ptr, | 811 | err = cfg80211_can_change_interface(rdev, dev->ieee80211_ptr, |
827 | ntype); | 812 | ntype); |
828 | mutex_unlock(&rdev->devlist_mtx); | ||
829 | if (err) | 813 | if (err) |
830 | return err; | 814 | return err; |
831 | 815 | ||
@@ -833,9 +817,6 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev, | |||
833 | dev->ieee80211_ptr->mesh_id_up_len = 0; | 817 | dev->ieee80211_ptr->mesh_id_up_len = 0; |
834 | 818 | ||
835 | switch (otype) { | 819 | switch (otype) { |
836 | case NL80211_IFTYPE_AP: | ||
837 | cfg80211_stop_ap(rdev, dev); | ||
838 | break; | ||
839 | case NL80211_IFTYPE_ADHOC: | 820 | case NL80211_IFTYPE_ADHOC: |
840 | cfg80211_leave_ibss(rdev, dev, false); | 821 | cfg80211_leave_ibss(rdev, dev, false); |
841 | break; | 822 | break; |
@@ -854,7 +835,8 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev, | |||
854 | cfg80211_process_rdev_events(rdev); | 835 | cfg80211_process_rdev_events(rdev); |
855 | } | 836 | } |
856 | 837 | ||
857 | err = rdev_change_virtual_intf(rdev, dev, ntype, flags, params); | 838 | err = rdev->ops->change_virtual_intf(&rdev->wiphy, dev, |
839 | ntype, flags, params); | ||
858 | 840 | ||
859 | WARN_ON(!err && dev->ieee80211_ptr->iftype != ntype); | 841 | WARN_ON(!err && dev->ieee80211_ptr->iftype != ntype); |
860 | 842 | ||
@@ -886,150 +868,21 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev, | |||
886 | case NUM_NL80211_IFTYPES: | 868 | case NUM_NL80211_IFTYPES: |
887 | /* not happening */ | 869 | /* not happening */ |
888 | break; | 870 | break; |
889 | case NL80211_IFTYPE_P2P_DEVICE: | ||
890 | WARN_ON(1); | ||
891 | break; | ||
892 | } | 871 | } |
893 | } | 872 | } |
894 | 873 | ||
895 | if (!err && ntype != otype && netif_running(dev)) { | ||
896 | cfg80211_update_iface_num(rdev, ntype, 1); | ||
897 | cfg80211_update_iface_num(rdev, otype, -1); | ||
898 | } | ||
899 | |||
900 | return err; | 874 | return err; |
901 | } | 875 | } |
902 | 876 | ||
903 | static u32 cfg80211_calculate_bitrate_60g(struct rate_info *rate) | 877 | u16 cfg80211_calculate_bitrate(struct rate_info *rate) |
904 | { | ||
905 | static const u32 __mcs2bitrate[] = { | ||
906 | /* control PHY */ | ||
907 | [0] = 275, | ||
908 | /* SC PHY */ | ||
909 | [1] = 3850, | ||
910 | [2] = 7700, | ||
911 | [3] = 9625, | ||
912 | [4] = 11550, | ||
913 | [5] = 12512, /* 1251.25 mbps */ | ||
914 | [6] = 15400, | ||
915 | [7] = 19250, | ||
916 | [8] = 23100, | ||
917 | [9] = 25025, | ||
918 | [10] = 30800, | ||
919 | [11] = 38500, | ||
920 | [12] = 46200, | ||
921 | /* OFDM PHY */ | ||
922 | [13] = 6930, | ||
923 | [14] = 8662, /* 866.25 mbps */ | ||
924 | [15] = 13860, | ||
925 | [16] = 17325, | ||
926 | [17] = 20790, | ||
927 | [18] = 27720, | ||
928 | [19] = 34650, | ||
929 | [20] = 41580, | ||
930 | [21] = 45045, | ||
931 | [22] = 51975, | ||
932 | [23] = 62370, | ||
933 | [24] = 67568, /* 6756.75 mbps */ | ||
934 | /* LP-SC PHY */ | ||
935 | [25] = 6260, | ||
936 | [26] = 8340, | ||
937 | [27] = 11120, | ||
938 | [28] = 12510, | ||
939 | [29] = 16680, | ||
940 | [30] = 22240, | ||
941 | [31] = 25030, | ||
942 | }; | ||
943 | |||
944 | if (WARN_ON_ONCE(rate->mcs >= ARRAY_SIZE(__mcs2bitrate))) | ||
945 | return 0; | ||
946 | |||
947 | return __mcs2bitrate[rate->mcs]; | ||
948 | } | ||
949 | |||
950 | static u32 cfg80211_calculate_bitrate_vht(struct rate_info *rate) | ||
951 | { | ||
952 | static const u32 base[4][10] = { | ||
953 | { 6500000, | ||
954 | 13000000, | ||
955 | 19500000, | ||
956 | 26000000, | ||
957 | 39000000, | ||
958 | 52000000, | ||
959 | 58500000, | ||
960 | 65000000, | ||
961 | 78000000, | ||
962 | 0, | ||
963 | }, | ||
964 | { 13500000, | ||
965 | 27000000, | ||
966 | 40500000, | ||
967 | 54000000, | ||
968 | 81000000, | ||
969 | 108000000, | ||
970 | 121500000, | ||
971 | 135000000, | ||
972 | 162000000, | ||
973 | 180000000, | ||
974 | }, | ||
975 | { 29300000, | ||
976 | 58500000, | ||
977 | 87800000, | ||
978 | 117000000, | ||
979 | 175500000, | ||
980 | 234000000, | ||
981 | 263300000, | ||
982 | 292500000, | ||
983 | 351000000, | ||
984 | 390000000, | ||
985 | }, | ||
986 | { 58500000, | ||
987 | 117000000, | ||
988 | 175500000, | ||
989 | 234000000, | ||
990 | 351000000, | ||
991 | 468000000, | ||
992 | 526500000, | ||
993 | 585000000, | ||
994 | 702000000, | ||
995 | 780000000, | ||
996 | }, | ||
997 | }; | ||
998 | u32 bitrate; | ||
999 | int idx; | ||
1000 | |||
1001 | if (WARN_ON_ONCE(rate->mcs > 9)) | ||
1002 | return 0; | ||
1003 | |||
1004 | idx = rate->flags & (RATE_INFO_FLAGS_160_MHZ_WIDTH | | ||
1005 | RATE_INFO_FLAGS_80P80_MHZ_WIDTH) ? 3 : | ||
1006 | rate->flags & RATE_INFO_FLAGS_80_MHZ_WIDTH ? 2 : | ||
1007 | rate->flags & RATE_INFO_FLAGS_40_MHZ_WIDTH ? 1 : 0; | ||
1008 | |||
1009 | bitrate = base[idx][rate->mcs]; | ||
1010 | bitrate *= rate->nss; | ||
1011 | |||
1012 | if (rate->flags & RATE_INFO_FLAGS_SHORT_GI) | ||
1013 | bitrate = (bitrate / 9) * 10; | ||
1014 | |||
1015 | /* do NOT round down here */ | ||
1016 | return (bitrate + 50000) / 100000; | ||
1017 | } | ||
1018 | |||
1019 | u32 cfg80211_calculate_bitrate(struct rate_info *rate) | ||
1020 | { | 878 | { |
1021 | int modulation, streams, bitrate; | 879 | int modulation, streams, bitrate; |
1022 | 880 | ||
1023 | if (!(rate->flags & RATE_INFO_FLAGS_MCS) && | 881 | if (!(rate->flags & RATE_INFO_FLAGS_MCS)) |
1024 | !(rate->flags & RATE_INFO_FLAGS_VHT_MCS)) | ||
1025 | return rate->legacy; | 882 | return rate->legacy; |
1026 | if (rate->flags & RATE_INFO_FLAGS_60G) | ||
1027 | return cfg80211_calculate_bitrate_60g(rate); | ||
1028 | if (rate->flags & RATE_INFO_FLAGS_VHT_MCS) | ||
1029 | return cfg80211_calculate_bitrate_vht(rate); | ||
1030 | 883 | ||
1031 | /* the formula below does only work for MCS values smaller than 32 */ | 884 | /* the formula below does only work for MCS values smaller than 32 */ |
1032 | if (WARN_ON_ONCE(rate->mcs >= 32)) | 885 | if (rate->mcs >= 32) |
1033 | return 0; | 886 | return 0; |
1034 | 887 | ||
1035 | modulation = rate->mcs & 7; | 888 | modulation = rate->mcs & 7; |
@@ -1053,107 +906,6 @@ u32 cfg80211_calculate_bitrate(struct rate_info *rate) | |||
1053 | /* do NOT round down here */ | 906 | /* do NOT round down here */ |
1054 | return (bitrate + 50000) / 100000; | 907 | return (bitrate + 50000) / 100000; |
1055 | } | 908 | } |
1056 | EXPORT_SYMBOL(cfg80211_calculate_bitrate); | ||
1057 | |||
1058 | int cfg80211_get_p2p_attr(const u8 *ies, unsigned int len, | ||
1059 | enum ieee80211_p2p_attr_id attr, | ||
1060 | u8 *buf, unsigned int bufsize) | ||
1061 | { | ||
1062 | u8 *out = buf; | ||
1063 | u16 attr_remaining = 0; | ||
1064 | bool desired_attr = false; | ||
1065 | u16 desired_len = 0; | ||
1066 | |||
1067 | while (len > 0) { | ||
1068 | unsigned int iedatalen; | ||
1069 | unsigned int copy; | ||
1070 | const u8 *iedata; | ||
1071 | |||
1072 | if (len < 2) | ||
1073 | return -EILSEQ; | ||
1074 | iedatalen = ies[1]; | ||
1075 | if (iedatalen + 2 > len) | ||
1076 | return -EILSEQ; | ||
1077 | |||
1078 | if (ies[0] != WLAN_EID_VENDOR_SPECIFIC) | ||
1079 | goto cont; | ||
1080 | |||
1081 | if (iedatalen < 4) | ||
1082 | goto cont; | ||
1083 | |||
1084 | iedata = ies + 2; | ||
1085 | |||
1086 | /* check WFA OUI, P2P subtype */ | ||
1087 | if (iedata[0] != 0x50 || iedata[1] != 0x6f || | ||
1088 | iedata[2] != 0x9a || iedata[3] != 0x09) | ||
1089 | goto cont; | ||
1090 | |||
1091 | iedatalen -= 4; | ||
1092 | iedata += 4; | ||
1093 | |||
1094 | /* check attribute continuation into this IE */ | ||
1095 | copy = min_t(unsigned int, attr_remaining, iedatalen); | ||
1096 | if (copy && desired_attr) { | ||
1097 | desired_len += copy; | ||
1098 | if (out) { | ||
1099 | memcpy(out, iedata, min(bufsize, copy)); | ||
1100 | out += min(bufsize, copy); | ||
1101 | bufsize -= min(bufsize, copy); | ||
1102 | } | ||
1103 | |||
1104 | |||
1105 | if (copy == attr_remaining) | ||
1106 | return desired_len; | ||
1107 | } | ||
1108 | |||
1109 | attr_remaining -= copy; | ||
1110 | if (attr_remaining) | ||
1111 | goto cont; | ||
1112 | |||
1113 | iedatalen -= copy; | ||
1114 | iedata += copy; | ||
1115 | |||
1116 | while (iedatalen > 0) { | ||
1117 | u16 attr_len; | ||
1118 | |||
1119 | /* P2P attribute ID & size must fit */ | ||
1120 | if (iedatalen < 3) | ||
1121 | return -EILSEQ; | ||
1122 | desired_attr = iedata[0] == attr; | ||
1123 | attr_len = get_unaligned_le16(iedata + 1); | ||
1124 | iedatalen -= 3; | ||
1125 | iedata += 3; | ||
1126 | |||
1127 | copy = min_t(unsigned int, attr_len, iedatalen); | ||
1128 | |||
1129 | if (desired_attr) { | ||
1130 | desired_len += copy; | ||
1131 | if (out) { | ||
1132 | memcpy(out, iedata, min(bufsize, copy)); | ||
1133 | out += min(bufsize, copy); | ||
1134 | bufsize -= min(bufsize, copy); | ||
1135 | } | ||
1136 | |||
1137 | if (copy == attr_len) | ||
1138 | return desired_len; | ||
1139 | } | ||
1140 | |||
1141 | iedata += copy; | ||
1142 | iedatalen -= copy; | ||
1143 | attr_remaining = attr_len - copy; | ||
1144 | } | ||
1145 | |||
1146 | cont: | ||
1147 | len -= ies[1] + 2; | ||
1148 | ies += ies[1] + 2; | ||
1149 | } | ||
1150 | |||
1151 | if (attr_remaining && desired_attr) | ||
1152 | return -EILSEQ; | ||
1153 | |||
1154 | return -ENOENT; | ||
1155 | } | ||
1156 | EXPORT_SYMBOL(cfg80211_get_p2p_attr); | ||
1157 | 909 | ||
1158 | int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev, | 910 | int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev, |
1159 | u32 beacon_int) | 911 | u32 beacon_int) |
@@ -1166,7 +918,7 @@ int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev, | |||
1166 | 918 | ||
1167 | mutex_lock(&rdev->devlist_mtx); | 919 | mutex_lock(&rdev->devlist_mtx); |
1168 | 920 | ||
1169 | list_for_each_entry(wdev, &rdev->wdev_list, list) { | 921 | list_for_each_entry(wdev, &rdev->netdev_list, list) { |
1170 | if (!wdev->beacon_interval) | 922 | if (!wdev->beacon_interval) |
1171 | continue; | 923 | continue; |
1172 | if (wdev->beacon_interval != beacon_int) { | 924 | if (wdev->beacon_interval != beacon_int) { |
@@ -1180,147 +932,72 @@ int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev, | |||
1180 | return res; | 932 | return res; |
1181 | } | 933 | } |
1182 | 934 | ||
1183 | int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev, | 935 | int cfg80211_can_change_interface(struct cfg80211_registered_device *rdev, |
1184 | struct wireless_dev *wdev, | 936 | struct wireless_dev *wdev, |
1185 | enum nl80211_iftype iftype, | 937 | enum nl80211_iftype iftype) |
1186 | struct ieee80211_channel *chan, | ||
1187 | enum cfg80211_chan_mode chanmode) | ||
1188 | { | 938 | { |
1189 | struct wireless_dev *wdev_iter; | 939 | struct wireless_dev *wdev_iter; |
1190 | u32 used_iftypes = BIT(iftype); | ||
1191 | int num[NUM_NL80211_IFTYPES]; | 940 | int num[NUM_NL80211_IFTYPES]; |
1192 | struct ieee80211_channel | ||
1193 | *used_channels[CFG80211_MAX_NUM_DIFFERENT_CHANNELS]; | ||
1194 | struct ieee80211_channel *ch; | ||
1195 | enum cfg80211_chan_mode chmode; | ||
1196 | int num_different_channels = 0; | ||
1197 | int total = 1; | 941 | int total = 1; |
1198 | int i, j; | 942 | int i, j; |
1199 | 943 | ||
1200 | ASSERT_RTNL(); | 944 | ASSERT_RTNL(); |
1201 | lockdep_assert_held(&rdev->devlist_mtx); | ||
1202 | 945 | ||
1203 | /* Always allow software iftypes */ | 946 | /* Always allow software iftypes */ |
1204 | if (rdev->wiphy.software_iftypes & BIT(iftype)) | 947 | if (rdev->wiphy.software_iftypes & BIT(iftype)) |
1205 | return 0; | 948 | return 0; |
1206 | 949 | ||
950 | /* | ||
951 | * Drivers will gradually all set this flag, until all | ||
952 | * have it we only enforce for those that set it. | ||
953 | */ | ||
954 | if (!(rdev->wiphy.flags & WIPHY_FLAG_ENFORCE_COMBINATIONS)) | ||
955 | return 0; | ||
956 | |||
1207 | memset(num, 0, sizeof(num)); | 957 | memset(num, 0, sizeof(num)); |
1208 | memset(used_channels, 0, sizeof(used_channels)); | ||
1209 | 958 | ||
1210 | num[iftype] = 1; | 959 | num[iftype] = 1; |
1211 | 960 | ||
1212 | switch (chanmode) { | 961 | mutex_lock(&rdev->devlist_mtx); |
1213 | case CHAN_MODE_UNDEFINED: | 962 | list_for_each_entry(wdev_iter, &rdev->netdev_list, list) { |
1214 | break; | ||
1215 | case CHAN_MODE_SHARED: | ||
1216 | WARN_ON(!chan); | ||
1217 | used_channels[0] = chan; | ||
1218 | num_different_channels++; | ||
1219 | break; | ||
1220 | case CHAN_MODE_EXCLUSIVE: | ||
1221 | num_different_channels++; | ||
1222 | break; | ||
1223 | } | ||
1224 | |||
1225 | list_for_each_entry(wdev_iter, &rdev->wdev_list, list) { | ||
1226 | if (wdev_iter == wdev) | 963 | if (wdev_iter == wdev) |
1227 | continue; | 964 | continue; |
1228 | if (wdev_iter->netdev) { | 965 | if (!netif_running(wdev_iter->netdev)) |
1229 | if (!netif_running(wdev_iter->netdev)) | 966 | continue; |
1230 | continue; | ||
1231 | } else if (wdev_iter->iftype == NL80211_IFTYPE_P2P_DEVICE) { | ||
1232 | if (!wdev_iter->p2p_started) | ||
1233 | continue; | ||
1234 | } else { | ||
1235 | WARN_ON(1); | ||
1236 | } | ||
1237 | 967 | ||
1238 | if (rdev->wiphy.software_iftypes & BIT(wdev_iter->iftype)) | 968 | if (rdev->wiphy.software_iftypes & BIT(wdev_iter->iftype)) |
1239 | continue; | 969 | continue; |
1240 | 970 | ||
1241 | /* | ||
1242 | * We may be holding the "wdev" mutex, but now need to lock | ||
1243 | * wdev_iter. This is OK because once we get here wdev_iter | ||
1244 | * is not wdev (tested above), but we need to use the nested | ||
1245 | * locking for lockdep. | ||
1246 | */ | ||
1247 | mutex_lock_nested(&wdev_iter->mtx, 1); | ||
1248 | __acquire(wdev_iter->mtx); | ||
1249 | cfg80211_get_chan_state(wdev_iter, &ch, &chmode); | ||
1250 | wdev_unlock(wdev_iter); | ||
1251 | |||
1252 | switch (chmode) { | ||
1253 | case CHAN_MODE_UNDEFINED: | ||
1254 | break; | ||
1255 | case CHAN_MODE_SHARED: | ||
1256 | for (i = 0; i < CFG80211_MAX_NUM_DIFFERENT_CHANNELS; i++) | ||
1257 | if (!used_channels[i] || used_channels[i] == ch) | ||
1258 | break; | ||
1259 | |||
1260 | if (i == CFG80211_MAX_NUM_DIFFERENT_CHANNELS) | ||
1261 | return -EBUSY; | ||
1262 | |||
1263 | if (used_channels[i] == NULL) { | ||
1264 | used_channels[i] = ch; | ||
1265 | num_different_channels++; | ||
1266 | } | ||
1267 | break; | ||
1268 | case CHAN_MODE_EXCLUSIVE: | ||
1269 | num_different_channels++; | ||
1270 | break; | ||
1271 | } | ||
1272 | |||
1273 | num[wdev_iter->iftype]++; | 971 | num[wdev_iter->iftype]++; |
1274 | total++; | 972 | total++; |
1275 | used_iftypes |= BIT(wdev_iter->iftype); | ||
1276 | } | 973 | } |
1277 | 974 | mutex_unlock(&rdev->devlist_mtx); | |
1278 | if (total == 1) | ||
1279 | return 0; | ||
1280 | 975 | ||
1281 | for (i = 0; i < rdev->wiphy.n_iface_combinations; i++) { | 976 | for (i = 0; i < rdev->wiphy.n_iface_combinations; i++) { |
1282 | const struct ieee80211_iface_combination *c; | 977 | const struct ieee80211_iface_combination *c; |
1283 | struct ieee80211_iface_limit *limits; | 978 | struct ieee80211_iface_limit *limits; |
1284 | u32 all_iftypes = 0; | ||
1285 | 979 | ||
1286 | c = &rdev->wiphy.iface_combinations[i]; | 980 | c = &rdev->wiphy.iface_combinations[i]; |
1287 | 981 | ||
1288 | if (total > c->max_interfaces) | ||
1289 | continue; | ||
1290 | if (num_different_channels > c->num_different_channels) | ||
1291 | continue; | ||
1292 | |||
1293 | limits = kmemdup(c->limits, sizeof(limits[0]) * c->n_limits, | 982 | limits = kmemdup(c->limits, sizeof(limits[0]) * c->n_limits, |
1294 | GFP_KERNEL); | 983 | GFP_KERNEL); |
1295 | if (!limits) | 984 | if (!limits) |
1296 | return -ENOMEM; | 985 | return -ENOMEM; |
986 | if (total > c->max_interfaces) | ||
987 | goto cont; | ||
1297 | 988 | ||
1298 | for (iftype = 0; iftype < NUM_NL80211_IFTYPES; iftype++) { | 989 | for (iftype = 0; iftype < NUM_NL80211_IFTYPES; iftype++) { |
1299 | if (rdev->wiphy.software_iftypes & BIT(iftype)) | 990 | if (rdev->wiphy.software_iftypes & BIT(iftype)) |
1300 | continue; | 991 | continue; |
1301 | for (j = 0; j < c->n_limits; j++) { | 992 | for (j = 0; j < c->n_limits; j++) { |
1302 | all_iftypes |= limits[j].types; | 993 | if (!(limits[j].types & iftype)) |
1303 | if (!(limits[j].types & BIT(iftype))) | ||
1304 | continue; | 994 | continue; |
1305 | if (limits[j].max < num[iftype]) | 995 | if (limits[j].max < num[iftype]) |
1306 | goto cont; | 996 | goto cont; |
1307 | limits[j].max -= num[iftype]; | 997 | limits[j].max -= num[iftype]; |
1308 | } | 998 | } |
1309 | } | 999 | } |
1310 | 1000 | /* yay, it fits */ | |
1311 | /* | ||
1312 | * Finally check that all iftypes that we're currently | ||
1313 | * using are actually part of this combination. If they | ||
1314 | * aren't then we can't use this combination and have | ||
1315 | * to continue to the next. | ||
1316 | */ | ||
1317 | if ((all_iftypes & used_iftypes) != used_iftypes) | ||
1318 | goto cont; | ||
1319 | |||
1320 | /* | ||
1321 | * This combination covered all interface types and | ||
1322 | * supported the requested numbers, so we're good. | ||
1323 | */ | ||
1324 | kfree(limits); | 1001 | kfree(limits); |
1325 | return 0; | 1002 | return 0; |
1326 | cont: | 1003 | cont: |
@@ -1367,14 +1044,3 @@ int ieee80211_get_ratemask(struct ieee80211_supported_band *sband, | |||
1367 | 1044 | ||
1368 | return 0; | 1045 | return 0; |
1369 | } | 1046 | } |
1370 | |||
1371 | /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ | ||
1372 | /* Ethernet-II snap header (RFC1042 for most EtherTypes) */ | ||
1373 | const unsigned char rfc1042_header[] __aligned(2) = | ||
1374 | { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; | ||
1375 | EXPORT_SYMBOL(rfc1042_header); | ||
1376 | |||
1377 | /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */ | ||
1378 | const unsigned char bridge_tunnel_header[] __aligned(2) = | ||
1379 | { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 }; | ||
1380 | EXPORT_SYMBOL(bridge_tunnel_header); | ||
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c index d997d0f0c54..0bf169bb770 100644 --- a/net/wireless/wext-compat.c +++ b/net/wireless/wext-compat.c | |||
@@ -8,7 +8,6 @@ | |||
8 | * Copyright 2008-2009 Johannes Berg <johannes@sipsolutions.net> | 8 | * Copyright 2008-2009 Johannes Berg <johannes@sipsolutions.net> |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/export.h> | ||
12 | #include <linux/wireless.h> | 11 | #include <linux/wireless.h> |
13 | #include <linux/nl80211.h> | 12 | #include <linux/nl80211.h> |
14 | #include <linux/if_arp.h> | 13 | #include <linux/if_arp.h> |
@@ -16,10 +15,8 @@ | |||
16 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
17 | #include <net/iw_handler.h> | 16 | #include <net/iw_handler.h> |
18 | #include <net/cfg80211.h> | 17 | #include <net/cfg80211.h> |
19 | #include <net/cfg80211-wext.h> | ||
20 | #include "wext-compat.h" | 18 | #include "wext-compat.h" |
21 | #include "core.h" | 19 | #include "core.h" |
22 | #include "rdev-ops.h" | ||
23 | 20 | ||
24 | int cfg80211_wext_giwname(struct net_device *dev, | 21 | int cfg80211_wext_giwname(struct net_device *dev, |
25 | struct iw_request_info *info, | 22 | struct iw_request_info *info, |
@@ -176,7 +173,7 @@ int cfg80211_wext_giwrange(struct net_device *dev, | |||
176 | case CFG80211_SIGNAL_TYPE_NONE: | 173 | case CFG80211_SIGNAL_TYPE_NONE: |
177 | break; | 174 | break; |
178 | case CFG80211_SIGNAL_TYPE_MBM: | 175 | case CFG80211_SIGNAL_TYPE_MBM: |
179 | range->max_qual.level = (u8)-110; | 176 | range->max_qual.level = -110; |
180 | range->max_qual.qual = 70; | 177 | range->max_qual.qual = 70; |
181 | range->avg_qual.qual = 35; | 178 | range->avg_qual.qual = 35; |
182 | range->max_qual.updated |= IW_QUAL_DBM; | 179 | range->max_qual.updated |= IW_QUAL_DBM; |
@@ -302,7 +299,8 @@ int cfg80211_wext_siwrts(struct net_device *dev, | |||
302 | else | 299 | else |
303 | wdev->wiphy->rts_threshold = rts->value; | 300 | wdev->wiphy->rts_threshold = rts->value; |
304 | 301 | ||
305 | err = rdev_set_wiphy_params(rdev, WIPHY_PARAM_RTS_THRESHOLD); | 302 | err = rdev->ops->set_wiphy_params(wdev->wiphy, |
303 | WIPHY_PARAM_RTS_THRESHOLD); | ||
306 | if (err) | 304 | if (err) |
307 | wdev->wiphy->rts_threshold = orts; | 305 | wdev->wiphy->rts_threshold = orts; |
308 | 306 | ||
@@ -342,7 +340,8 @@ int cfg80211_wext_siwfrag(struct net_device *dev, | |||
342 | wdev->wiphy->frag_threshold = frag->value & ~0x1; | 340 | wdev->wiphy->frag_threshold = frag->value & ~0x1; |
343 | } | 341 | } |
344 | 342 | ||
345 | err = rdev_set_wiphy_params(rdev, WIPHY_PARAM_FRAG_THRESHOLD); | 343 | err = rdev->ops->set_wiphy_params(wdev->wiphy, |
344 | WIPHY_PARAM_FRAG_THRESHOLD); | ||
346 | if (err) | 345 | if (err) |
347 | wdev->wiphy->frag_threshold = ofrag; | 346 | wdev->wiphy->frag_threshold = ofrag; |
348 | 347 | ||
@@ -364,9 +363,9 @@ int cfg80211_wext_giwfrag(struct net_device *dev, | |||
364 | } | 363 | } |
365 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwfrag); | 364 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwfrag); |
366 | 365 | ||
367 | static int cfg80211_wext_siwretry(struct net_device *dev, | 366 | int cfg80211_wext_siwretry(struct net_device *dev, |
368 | struct iw_request_info *info, | 367 | struct iw_request_info *info, |
369 | struct iw_param *retry, char *extra) | 368 | struct iw_param *retry, char *extra) |
370 | { | 369 | { |
371 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 370 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
372 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | 371 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
@@ -395,7 +394,7 @@ static int cfg80211_wext_siwretry(struct net_device *dev, | |||
395 | if (!changed) | 394 | if (!changed) |
396 | return 0; | 395 | return 0; |
397 | 396 | ||
398 | err = rdev_set_wiphy_params(rdev, changed); | 397 | err = rdev->ops->set_wiphy_params(wdev->wiphy, changed); |
399 | if (err) { | 398 | if (err) { |
400 | wdev->wiphy->retry_short = oshort; | 399 | wdev->wiphy->retry_short = oshort; |
401 | wdev->wiphy->retry_long = olong; | 400 | wdev->wiphy->retry_long = olong; |
@@ -403,6 +402,7 @@ static int cfg80211_wext_siwretry(struct net_device *dev, | |||
403 | 402 | ||
404 | return err; | 403 | return err; |
405 | } | 404 | } |
405 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwretry); | ||
406 | 406 | ||
407 | int cfg80211_wext_giwretry(struct net_device *dev, | 407 | int cfg80211_wext_giwretry(struct net_device *dev, |
408 | struct iw_request_info *info, | 408 | struct iw_request_info *info, |
@@ -489,8 +489,8 @@ static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev, | |||
489 | !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN)) | 489 | !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN)) |
490 | err = -ENOENT; | 490 | err = -ENOENT; |
491 | else | 491 | else |
492 | err = rdev_del_key(rdev, dev, idx, pairwise, | 492 | err = rdev->ops->del_key(&rdev->wiphy, dev, idx, |
493 | addr); | 493 | pairwise, addr); |
494 | } | 494 | } |
495 | wdev->wext.connect.privacy = false; | 495 | wdev->wext.connect.privacy = false; |
496 | /* | 496 | /* |
@@ -524,7 +524,8 @@ static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev, | |||
524 | 524 | ||
525 | err = 0; | 525 | err = 0; |
526 | if (wdev->current_bss) | 526 | if (wdev->current_bss) |
527 | err = rdev_add_key(rdev, dev, idx, pairwise, addr, params); | 527 | err = rdev->ops->add_key(&rdev->wiphy, dev, idx, |
528 | pairwise, addr, params); | ||
528 | if (err) | 529 | if (err) |
529 | return err; | 530 | return err; |
530 | 531 | ||
@@ -550,7 +551,8 @@ static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev, | |||
550 | __cfg80211_leave_ibss(rdev, wdev->netdev, true); | 551 | __cfg80211_leave_ibss(rdev, wdev->netdev, true); |
551 | rejoin = true; | 552 | rejoin = true; |
552 | } | 553 | } |
553 | err = rdev_set_default_key(rdev, dev, idx, true, true); | 554 | err = rdev->ops->set_default_key(&rdev->wiphy, dev, |
555 | idx, true, true); | ||
554 | } | 556 | } |
555 | if (!err) { | 557 | if (!err) { |
556 | wdev->wext.default_key = idx; | 558 | wdev->wext.default_key = idx; |
@@ -563,7 +565,8 @@ static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev, | |||
563 | if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC && | 565 | if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC && |
564 | (tx_key || (!addr && wdev->wext.default_mgmt_key == -1))) { | 566 | (tx_key || (!addr && wdev->wext.default_mgmt_key == -1))) { |
565 | if (wdev->current_bss) | 567 | if (wdev->current_bss) |
566 | err = rdev_set_default_mgmt_key(rdev, dev, idx); | 568 | err = rdev->ops->set_default_mgmt_key(&rdev->wiphy, |
569 | dev, idx); | ||
567 | if (!err) | 570 | if (!err) |
568 | wdev->wext.default_mgmt_key = idx; | 571 | wdev->wext.default_mgmt_key = idx; |
569 | return err; | 572 | return err; |
@@ -590,9 +593,9 @@ static int cfg80211_set_encryption(struct cfg80211_registered_device *rdev, | |||
590 | return err; | 593 | return err; |
591 | } | 594 | } |
592 | 595 | ||
593 | static int cfg80211_wext_siwencode(struct net_device *dev, | 596 | int cfg80211_wext_siwencode(struct net_device *dev, |
594 | struct iw_request_info *info, | 597 | struct iw_request_info *info, |
595 | struct iw_point *erq, char *keybuf) | 598 | struct iw_point *erq, char *keybuf) |
596 | { | 599 | { |
597 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 600 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
598 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | 601 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
@@ -627,8 +630,8 @@ static int cfg80211_wext_siwencode(struct net_device *dev, | |||
627 | err = 0; | 630 | err = 0; |
628 | wdev_lock(wdev); | 631 | wdev_lock(wdev); |
629 | if (wdev->current_bss) | 632 | if (wdev->current_bss) |
630 | err = rdev_set_default_key(rdev, dev, idx, true, | 633 | err = rdev->ops->set_default_key(&rdev->wiphy, dev, |
631 | true); | 634 | idx, true, true); |
632 | if (!err) | 635 | if (!err) |
633 | wdev->wext.default_key = idx; | 636 | wdev->wext.default_key = idx; |
634 | wdev_unlock(wdev); | 637 | wdev_unlock(wdev); |
@@ -649,10 +652,11 @@ static int cfg80211_wext_siwencode(struct net_device *dev, | |||
649 | wdev->wext.default_key == -1, | 652 | wdev->wext.default_key == -1, |
650 | idx, ¶ms); | 653 | idx, ¶ms); |
651 | } | 654 | } |
655 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwencode); | ||
652 | 656 | ||
653 | static int cfg80211_wext_siwencodeext(struct net_device *dev, | 657 | int cfg80211_wext_siwencodeext(struct net_device *dev, |
654 | struct iw_request_info *info, | 658 | struct iw_request_info *info, |
655 | struct iw_point *erq, char *extra) | 659 | struct iw_point *erq, char *extra) |
656 | { | 660 | { |
657 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 661 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
658 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | 662 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
@@ -740,10 +744,11 @@ static int cfg80211_wext_siwencodeext(struct net_device *dev, | |||
740 | ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY, | 744 | ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY, |
741 | idx, ¶ms); | 745 | idx, ¶ms); |
742 | } | 746 | } |
747 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwencodeext); | ||
743 | 748 | ||
744 | static int cfg80211_wext_giwencode(struct net_device *dev, | 749 | int cfg80211_wext_giwencode(struct net_device *dev, |
745 | struct iw_request_info *info, | 750 | struct iw_request_info *info, |
746 | struct iw_point *erq, char *keybuf) | 751 | struct iw_point *erq, char *keybuf) |
747 | { | 752 | { |
748 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 753 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
749 | int idx; | 754 | int idx; |
@@ -777,16 +782,14 @@ static int cfg80211_wext_giwencode(struct net_device *dev, | |||
777 | 782 | ||
778 | return 0; | 783 | return 0; |
779 | } | 784 | } |
785 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwencode); | ||
780 | 786 | ||
781 | static int cfg80211_wext_siwfreq(struct net_device *dev, | 787 | int cfg80211_wext_siwfreq(struct net_device *dev, |
782 | struct iw_request_info *info, | 788 | struct iw_request_info *info, |
783 | struct iw_freq *wextfreq, char *extra) | 789 | struct iw_freq *wextfreq, char *extra) |
784 | { | 790 | { |
785 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 791 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
786 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | 792 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
787 | struct cfg80211_chan_def chandef = { | ||
788 | .width = NL80211_CHAN_WIDTH_20_NOHT, | ||
789 | }; | ||
790 | int freq, err; | 793 | int freq, err; |
791 | 794 | ||
792 | switch (wdev->iftype) { | 795 | switch (wdev->iftype) { |
@@ -795,70 +798,49 @@ static int cfg80211_wext_siwfreq(struct net_device *dev, | |||
795 | case NL80211_IFTYPE_ADHOC: | 798 | case NL80211_IFTYPE_ADHOC: |
796 | return cfg80211_ibss_wext_siwfreq(dev, info, wextfreq, extra); | 799 | return cfg80211_ibss_wext_siwfreq(dev, info, wextfreq, extra); |
797 | case NL80211_IFTYPE_MONITOR: | 800 | case NL80211_IFTYPE_MONITOR: |
798 | freq = cfg80211_wext_freq(wdev->wiphy, wextfreq); | 801 | case NL80211_IFTYPE_WDS: |
799 | if (freq < 0) | ||
800 | return freq; | ||
801 | if (freq == 0) | ||
802 | return -EINVAL; | ||
803 | chandef.center_freq1 = freq; | ||
804 | chandef.chan = ieee80211_get_channel(&rdev->wiphy, freq); | ||
805 | if (!chandef.chan) | ||
806 | return -EINVAL; | ||
807 | mutex_lock(&rdev->devlist_mtx); | ||
808 | err = cfg80211_set_monitor_channel(rdev, &chandef); | ||
809 | mutex_unlock(&rdev->devlist_mtx); | ||
810 | return err; | ||
811 | case NL80211_IFTYPE_MESH_POINT: | 802 | case NL80211_IFTYPE_MESH_POINT: |
812 | freq = cfg80211_wext_freq(wdev->wiphy, wextfreq); | 803 | freq = cfg80211_wext_freq(wdev->wiphy, wextfreq); |
813 | if (freq < 0) | 804 | if (freq < 0) |
814 | return freq; | 805 | return freq; |
815 | if (freq == 0) | 806 | if (freq == 0) |
816 | return -EINVAL; | 807 | return -EINVAL; |
817 | chandef.center_freq1 = freq; | ||
818 | chandef.chan = ieee80211_get_channel(&rdev->wiphy, freq); | ||
819 | if (!chandef.chan) | ||
820 | return -EINVAL; | ||
821 | mutex_lock(&rdev->devlist_mtx); | 808 | mutex_lock(&rdev->devlist_mtx); |
822 | err = cfg80211_set_mesh_channel(rdev, wdev, &chandef); | 809 | wdev_lock(wdev); |
810 | err = cfg80211_set_freq(rdev, wdev, freq, NL80211_CHAN_NO_HT); | ||
811 | wdev_unlock(wdev); | ||
823 | mutex_unlock(&rdev->devlist_mtx); | 812 | mutex_unlock(&rdev->devlist_mtx); |
824 | return err; | 813 | return err; |
825 | default: | 814 | default: |
826 | return -EOPNOTSUPP; | 815 | return -EOPNOTSUPP; |
827 | } | 816 | } |
828 | } | 817 | } |
818 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwfreq); | ||
829 | 819 | ||
830 | static int cfg80211_wext_giwfreq(struct net_device *dev, | 820 | int cfg80211_wext_giwfreq(struct net_device *dev, |
831 | struct iw_request_info *info, | 821 | struct iw_request_info *info, |
832 | struct iw_freq *freq, char *extra) | 822 | struct iw_freq *freq, char *extra) |
833 | { | 823 | { |
834 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 824 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
835 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | ||
836 | struct cfg80211_chan_def chandef; | ||
837 | int ret; | ||
838 | 825 | ||
839 | switch (wdev->iftype) { | 826 | switch (wdev->iftype) { |
840 | case NL80211_IFTYPE_STATION: | 827 | case NL80211_IFTYPE_STATION: |
841 | return cfg80211_mgd_wext_giwfreq(dev, info, freq, extra); | 828 | return cfg80211_mgd_wext_giwfreq(dev, info, freq, extra); |
842 | case NL80211_IFTYPE_ADHOC: | 829 | case NL80211_IFTYPE_ADHOC: |
843 | return cfg80211_ibss_wext_giwfreq(dev, info, freq, extra); | 830 | return cfg80211_ibss_wext_giwfreq(dev, info, freq, extra); |
844 | case NL80211_IFTYPE_MONITOR: | 831 | default: |
845 | if (!rdev->ops->get_channel) | 832 | if (!wdev->channel) |
846 | return -EINVAL; | 833 | return -EINVAL; |
847 | 834 | freq->m = wdev->channel->center_freq; | |
848 | ret = rdev_get_channel(rdev, wdev, &chandef); | ||
849 | if (ret) | ||
850 | return ret; | ||
851 | freq->m = chandef.chan->center_freq; | ||
852 | freq->e = 6; | 835 | freq->e = 6; |
853 | return 0; | 836 | return 0; |
854 | default: | ||
855 | return -EINVAL; | ||
856 | } | 837 | } |
857 | } | 838 | } |
839 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwfreq); | ||
858 | 840 | ||
859 | static int cfg80211_wext_siwtxpower(struct net_device *dev, | 841 | int cfg80211_wext_siwtxpower(struct net_device *dev, |
860 | struct iw_request_info *info, | 842 | struct iw_request_info *info, |
861 | union iwreq_data *data, char *extra) | 843 | union iwreq_data *data, char *extra) |
862 | { | 844 | { |
863 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 845 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
864 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | 846 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
@@ -905,12 +887,13 @@ static int cfg80211_wext_siwtxpower(struct net_device *dev, | |||
905 | return 0; | 887 | return 0; |
906 | } | 888 | } |
907 | 889 | ||
908 | return rdev_set_tx_power(rdev, wdev, type, DBM_TO_MBM(dbm)); | 890 | return rdev->ops->set_tx_power(wdev->wiphy, type, DBM_TO_MBM(dbm)); |
909 | } | 891 | } |
892 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwtxpower); | ||
910 | 893 | ||
911 | static int cfg80211_wext_giwtxpower(struct net_device *dev, | 894 | int cfg80211_wext_giwtxpower(struct net_device *dev, |
912 | struct iw_request_info *info, | 895 | struct iw_request_info *info, |
913 | union iwreq_data *data, char *extra) | 896 | union iwreq_data *data, char *extra) |
914 | { | 897 | { |
915 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 898 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
916 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | 899 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
@@ -924,7 +907,7 @@ static int cfg80211_wext_giwtxpower(struct net_device *dev, | |||
924 | if (!rdev->ops->get_tx_power) | 907 | if (!rdev->ops->get_tx_power) |
925 | return -EOPNOTSUPP; | 908 | return -EOPNOTSUPP; |
926 | 909 | ||
927 | err = rdev_get_tx_power(rdev, wdev, &val); | 910 | err = rdev->ops->get_tx_power(wdev->wiphy, &val); |
928 | if (err) | 911 | if (err) |
929 | return err; | 912 | return err; |
930 | 913 | ||
@@ -936,6 +919,7 @@ static int cfg80211_wext_giwtxpower(struct net_device *dev, | |||
936 | 919 | ||
937 | return 0; | 920 | return 0; |
938 | } | 921 | } |
922 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwtxpower); | ||
939 | 923 | ||
940 | static int cfg80211_set_auth_alg(struct wireless_dev *wdev, | 924 | static int cfg80211_set_auth_alg(struct wireless_dev *wdev, |
941 | s32 auth_alg) | 925 | s32 auth_alg) |
@@ -1086,9 +1070,9 @@ static int cfg80211_set_key_mgt(struct wireless_dev *wdev, u32 key_mgt) | |||
1086 | return 0; | 1070 | return 0; |
1087 | } | 1071 | } |
1088 | 1072 | ||
1089 | static int cfg80211_wext_siwauth(struct net_device *dev, | 1073 | int cfg80211_wext_siwauth(struct net_device *dev, |
1090 | struct iw_request_info *info, | 1074 | struct iw_request_info *info, |
1091 | struct iw_param *data, char *extra) | 1075 | struct iw_param *data, char *extra) |
1092 | { | 1076 | { |
1093 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 1077 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
1094 | 1078 | ||
@@ -1118,19 +1102,21 @@ static int cfg80211_wext_siwauth(struct net_device *dev, | |||
1118 | return -EOPNOTSUPP; | 1102 | return -EOPNOTSUPP; |
1119 | } | 1103 | } |
1120 | } | 1104 | } |
1105 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwauth); | ||
1121 | 1106 | ||
1122 | static int cfg80211_wext_giwauth(struct net_device *dev, | 1107 | int cfg80211_wext_giwauth(struct net_device *dev, |
1123 | struct iw_request_info *info, | 1108 | struct iw_request_info *info, |
1124 | struct iw_param *data, char *extra) | 1109 | struct iw_param *data, char *extra) |
1125 | { | 1110 | { |
1126 | /* XXX: what do we need? */ | 1111 | /* XXX: what do we need? */ |
1127 | 1112 | ||
1128 | return -EOPNOTSUPP; | 1113 | return -EOPNOTSUPP; |
1129 | } | 1114 | } |
1115 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwauth); | ||
1130 | 1116 | ||
1131 | static int cfg80211_wext_siwpower(struct net_device *dev, | 1117 | int cfg80211_wext_siwpower(struct net_device *dev, |
1132 | struct iw_request_info *info, | 1118 | struct iw_request_info *info, |
1133 | struct iw_param *wrq, char *extra) | 1119 | struct iw_param *wrq, char *extra) |
1134 | { | 1120 | { |
1135 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 1121 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
1136 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | 1122 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
@@ -1164,7 +1150,7 @@ static int cfg80211_wext_siwpower(struct net_device *dev, | |||
1164 | timeout = wrq->value / 1000; | 1150 | timeout = wrq->value / 1000; |
1165 | } | 1151 | } |
1166 | 1152 | ||
1167 | err = rdev_set_power_mgmt(rdev, dev, ps, timeout); | 1153 | err = rdev->ops->set_power_mgmt(wdev->wiphy, dev, ps, timeout); |
1168 | if (err) | 1154 | if (err) |
1169 | return err; | 1155 | return err; |
1170 | 1156 | ||
@@ -1174,10 +1160,11 @@ static int cfg80211_wext_siwpower(struct net_device *dev, | |||
1174 | return 0; | 1160 | return 0; |
1175 | 1161 | ||
1176 | } | 1162 | } |
1163 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwpower); | ||
1177 | 1164 | ||
1178 | static int cfg80211_wext_giwpower(struct net_device *dev, | 1165 | int cfg80211_wext_giwpower(struct net_device *dev, |
1179 | struct iw_request_info *info, | 1166 | struct iw_request_info *info, |
1180 | struct iw_param *wrq, char *extra) | 1167 | struct iw_param *wrq, char *extra) |
1181 | { | 1168 | { |
1182 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 1169 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
1183 | 1170 | ||
@@ -1185,6 +1172,7 @@ static int cfg80211_wext_giwpower(struct net_device *dev, | |||
1185 | 1172 | ||
1186 | return 0; | 1173 | return 0; |
1187 | } | 1174 | } |
1175 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwpower); | ||
1188 | 1176 | ||
1189 | static int cfg80211_wds_wext_siwap(struct net_device *dev, | 1177 | static int cfg80211_wds_wext_siwap(struct net_device *dev, |
1190 | struct iw_request_info *info, | 1178 | struct iw_request_info *info, |
@@ -1206,7 +1194,7 @@ static int cfg80211_wds_wext_siwap(struct net_device *dev, | |||
1206 | if (!rdev->ops->set_wds_peer) | 1194 | if (!rdev->ops->set_wds_peer) |
1207 | return -EOPNOTSUPP; | 1195 | return -EOPNOTSUPP; |
1208 | 1196 | ||
1209 | err = rdev_set_wds_peer(rdev, dev, (u8 *)&addr->sa_data); | 1197 | err = rdev->ops->set_wds_peer(wdev->wiphy, dev, (u8 *) &addr->sa_data); |
1210 | if (err) | 1198 | if (err) |
1211 | return err; | 1199 | return err; |
1212 | 1200 | ||
@@ -1230,9 +1218,9 @@ static int cfg80211_wds_wext_giwap(struct net_device *dev, | |||
1230 | return 0; | 1218 | return 0; |
1231 | } | 1219 | } |
1232 | 1220 | ||
1233 | static int cfg80211_wext_siwrate(struct net_device *dev, | 1221 | int cfg80211_wext_siwrate(struct net_device *dev, |
1234 | struct iw_request_info *info, | 1222 | struct iw_request_info *info, |
1235 | struct iw_param *rate, char *extra) | 1223 | struct iw_param *rate, char *extra) |
1236 | { | 1224 | { |
1237 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 1225 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
1238 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | 1226 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
@@ -1278,12 +1266,13 @@ static int cfg80211_wext_siwrate(struct net_device *dev, | |||
1278 | if (!match) | 1266 | if (!match) |
1279 | return -EINVAL; | 1267 | return -EINVAL; |
1280 | 1268 | ||
1281 | return rdev_set_bitrate_mask(rdev, dev, NULL, &mask); | 1269 | return rdev->ops->set_bitrate_mask(wdev->wiphy, dev, NULL, &mask); |
1282 | } | 1270 | } |
1271 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwrate); | ||
1283 | 1272 | ||
1284 | static int cfg80211_wext_giwrate(struct net_device *dev, | 1273 | int cfg80211_wext_giwrate(struct net_device *dev, |
1285 | struct iw_request_info *info, | 1274 | struct iw_request_info *info, |
1286 | struct iw_param *rate, char *extra) | 1275 | struct iw_param *rate, char *extra) |
1287 | { | 1276 | { |
1288 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 1277 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
1289 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | 1278 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
@@ -1308,7 +1297,7 @@ static int cfg80211_wext_giwrate(struct net_device *dev, | |||
1308 | if (err) | 1297 | if (err) |
1309 | return err; | 1298 | return err; |
1310 | 1299 | ||
1311 | err = rdev_get_station(rdev, dev, addr, &sinfo); | 1300 | err = rdev->ops->get_station(&rdev->wiphy, dev, addr, &sinfo); |
1312 | if (err) | 1301 | if (err) |
1313 | return err; | 1302 | return err; |
1314 | 1303 | ||
@@ -1319,9 +1308,10 @@ static int cfg80211_wext_giwrate(struct net_device *dev, | |||
1319 | 1308 | ||
1320 | return 0; | 1309 | return 0; |
1321 | } | 1310 | } |
1311 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwrate); | ||
1322 | 1312 | ||
1323 | /* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */ | 1313 | /* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */ |
1324 | static struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev) | 1314 | struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev) |
1325 | { | 1315 | { |
1326 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 1316 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
1327 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | 1317 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
@@ -1345,7 +1335,7 @@ static struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev) | |||
1345 | memcpy(bssid, wdev->current_bss->pub.bssid, ETH_ALEN); | 1335 | memcpy(bssid, wdev->current_bss->pub.bssid, ETH_ALEN); |
1346 | wdev_unlock(wdev); | 1336 | wdev_unlock(wdev); |
1347 | 1337 | ||
1348 | if (rdev_get_station(rdev, dev, bssid, &sinfo)) | 1338 | if (rdev->ops->get_station(&rdev->wiphy, dev, bssid, &sinfo)) |
1349 | return NULL; | 1339 | return NULL; |
1350 | 1340 | ||
1351 | memset(&wstats, 0, sizeof(wstats)); | 1341 | memset(&wstats, 0, sizeof(wstats)); |
@@ -1386,10 +1376,11 @@ static struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev) | |||
1386 | 1376 | ||
1387 | return &wstats; | 1377 | return &wstats; |
1388 | } | 1378 | } |
1379 | EXPORT_SYMBOL_GPL(cfg80211_wireless_stats); | ||
1389 | 1380 | ||
1390 | static int cfg80211_wext_siwap(struct net_device *dev, | 1381 | int cfg80211_wext_siwap(struct net_device *dev, |
1391 | struct iw_request_info *info, | 1382 | struct iw_request_info *info, |
1392 | struct sockaddr *ap_addr, char *extra) | 1383 | struct sockaddr *ap_addr, char *extra) |
1393 | { | 1384 | { |
1394 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 1385 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
1395 | 1386 | ||
@@ -1404,10 +1395,11 @@ static int cfg80211_wext_siwap(struct net_device *dev, | |||
1404 | return -EOPNOTSUPP; | 1395 | return -EOPNOTSUPP; |
1405 | } | 1396 | } |
1406 | } | 1397 | } |
1398 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwap); | ||
1407 | 1399 | ||
1408 | static int cfg80211_wext_giwap(struct net_device *dev, | 1400 | int cfg80211_wext_giwap(struct net_device *dev, |
1409 | struct iw_request_info *info, | 1401 | struct iw_request_info *info, |
1410 | struct sockaddr *ap_addr, char *extra) | 1402 | struct sockaddr *ap_addr, char *extra) |
1411 | { | 1403 | { |
1412 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 1404 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
1413 | 1405 | ||
@@ -1422,10 +1414,11 @@ static int cfg80211_wext_giwap(struct net_device *dev, | |||
1422 | return -EOPNOTSUPP; | 1414 | return -EOPNOTSUPP; |
1423 | } | 1415 | } |
1424 | } | 1416 | } |
1417 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwap); | ||
1425 | 1418 | ||
1426 | static int cfg80211_wext_siwessid(struct net_device *dev, | 1419 | int cfg80211_wext_siwessid(struct net_device *dev, |
1427 | struct iw_request_info *info, | 1420 | struct iw_request_info *info, |
1428 | struct iw_point *data, char *ssid) | 1421 | struct iw_point *data, char *ssid) |
1429 | { | 1422 | { |
1430 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 1423 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
1431 | 1424 | ||
@@ -1438,10 +1431,11 @@ static int cfg80211_wext_siwessid(struct net_device *dev, | |||
1438 | return -EOPNOTSUPP; | 1431 | return -EOPNOTSUPP; |
1439 | } | 1432 | } |
1440 | } | 1433 | } |
1434 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwessid); | ||
1441 | 1435 | ||
1442 | static int cfg80211_wext_giwessid(struct net_device *dev, | 1436 | int cfg80211_wext_giwessid(struct net_device *dev, |
1443 | struct iw_request_info *info, | 1437 | struct iw_request_info *info, |
1444 | struct iw_point *data, char *ssid) | 1438 | struct iw_point *data, char *ssid) |
1445 | { | 1439 | { |
1446 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 1440 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
1447 | 1441 | ||
@@ -1457,10 +1451,11 @@ static int cfg80211_wext_giwessid(struct net_device *dev, | |||
1457 | return -EOPNOTSUPP; | 1451 | return -EOPNOTSUPP; |
1458 | } | 1452 | } |
1459 | } | 1453 | } |
1454 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwessid); | ||
1460 | 1455 | ||
1461 | static int cfg80211_wext_siwpmksa(struct net_device *dev, | 1456 | int cfg80211_wext_siwpmksa(struct net_device *dev, |
1462 | struct iw_request_info *info, | 1457 | struct iw_request_info *info, |
1463 | struct iw_point *data, char *extra) | 1458 | struct iw_point *data, char *extra) |
1464 | { | 1459 | { |
1465 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 1460 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
1466 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | 1461 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
@@ -1480,24 +1475,25 @@ static int cfg80211_wext_siwpmksa(struct net_device *dev, | |||
1480 | if (!rdev->ops->set_pmksa) | 1475 | if (!rdev->ops->set_pmksa) |
1481 | return -EOPNOTSUPP; | 1476 | return -EOPNOTSUPP; |
1482 | 1477 | ||
1483 | return rdev_set_pmksa(rdev, dev, &cfg_pmksa); | 1478 | return rdev->ops->set_pmksa(&rdev->wiphy, dev, &cfg_pmksa); |
1484 | 1479 | ||
1485 | case IW_PMKSA_REMOVE: | 1480 | case IW_PMKSA_REMOVE: |
1486 | if (!rdev->ops->del_pmksa) | 1481 | if (!rdev->ops->del_pmksa) |
1487 | return -EOPNOTSUPP; | 1482 | return -EOPNOTSUPP; |
1488 | 1483 | ||
1489 | return rdev_del_pmksa(rdev, dev, &cfg_pmksa); | 1484 | return rdev->ops->del_pmksa(&rdev->wiphy, dev, &cfg_pmksa); |
1490 | 1485 | ||
1491 | case IW_PMKSA_FLUSH: | 1486 | case IW_PMKSA_FLUSH: |
1492 | if (!rdev->ops->flush_pmksa) | 1487 | if (!rdev->ops->flush_pmksa) |
1493 | return -EOPNOTSUPP; | 1488 | return -EOPNOTSUPP; |
1494 | 1489 | ||
1495 | return rdev_flush_pmksa(rdev, dev); | 1490 | return rdev->ops->flush_pmksa(&rdev->wiphy, dev); |
1496 | 1491 | ||
1497 | default: | 1492 | default: |
1498 | return -EOPNOTSUPP; | 1493 | return -EOPNOTSUPP; |
1499 | } | 1494 | } |
1500 | } | 1495 | } |
1496 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwpmksa); | ||
1501 | 1497 | ||
1502 | static const iw_handler cfg80211_handlers[] = { | 1498 | static const iw_handler cfg80211_handlers[] = { |
1503 | [IW_IOCTL_IDX(SIOCGIWNAME)] = (iw_handler) cfg80211_wext_giwname, | 1499 | [IW_IOCTL_IDX(SIOCGIWNAME)] = (iw_handler) cfg80211_wext_giwname, |
diff --git a/net/wireless/wext-compat.h b/net/wireless/wext-compat.h index 5d766b0118e..20b3daef696 100644 --- a/net/wireless/wext-compat.h +++ b/net/wireless/wext-compat.h | |||
@@ -42,14 +42,6 @@ int cfg80211_mgd_wext_giwessid(struct net_device *dev, | |||
42 | struct iw_request_info *info, | 42 | struct iw_request_info *info, |
43 | struct iw_point *data, char *ssid); | 43 | struct iw_point *data, char *ssid); |
44 | 44 | ||
45 | int cfg80211_wext_siwmlme(struct net_device *dev, | ||
46 | struct iw_request_info *info, | ||
47 | struct iw_point *data, char *extra); | ||
48 | int cfg80211_wext_siwgenie(struct net_device *dev, | ||
49 | struct iw_request_info *info, | ||
50 | struct iw_point *data, char *extra); | ||
51 | |||
52 | |||
53 | int cfg80211_wext_freq(struct wiphy *wiphy, struct iw_freq *freq); | 45 | int cfg80211_wext_freq(struct wiphy *wiphy, struct iw_freq *freq); |
54 | 46 | ||
55 | 47 | ||
diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c index c8717c1d082..fdbc23c10d8 100644 --- a/net/wireless/wext-core.c +++ b/net/wireless/wext-core.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
14 | #include <linux/wireless.h> | 14 | #include <linux/wireless.h> |
15 | #include <linux/uaccess.h> | 15 | #include <linux/uaccess.h> |
16 | #include <linux/export.h> | ||
17 | #include <net/cfg80211.h> | 16 | #include <net/cfg80211.h> |
18 | #include <net/iw_handler.h> | 17 | #include <net/iw_handler.h> |
19 | #include <net/netlink.h> | 18 | #include <net/netlink.h> |
@@ -256,7 +255,7 @@ static const struct iw_ioctl_description standard_ioctl[] = { | |||
256 | .max_tokens = sizeof(struct iw_pmksa), | 255 | .max_tokens = sizeof(struct iw_pmksa), |
257 | }, | 256 | }, |
258 | }; | 257 | }; |
259 | static const unsigned int standard_ioctl_num = ARRAY_SIZE(standard_ioctl); | 258 | static const unsigned standard_ioctl_num = ARRAY_SIZE(standard_ioctl); |
260 | 259 | ||
261 | /* | 260 | /* |
262 | * Meta-data about all the additional standard Wireless Extension events | 261 | * Meta-data about all the additional standard Wireless Extension events |
@@ -306,7 +305,7 @@ static const struct iw_ioctl_description standard_event[] = { | |||
306 | .max_tokens = sizeof(struct iw_pmkid_cand), | 305 | .max_tokens = sizeof(struct iw_pmkid_cand), |
307 | }, | 306 | }, |
308 | }; | 307 | }; |
309 | static const unsigned int standard_event_num = ARRAY_SIZE(standard_event); | 308 | static const unsigned standard_event_num = ARRAY_SIZE(standard_event); |
310 | 309 | ||
311 | /* Size (in bytes) of various events */ | 310 | /* Size (in bytes) of various events */ |
312 | static const int event_type_size[] = { | 311 | static const int event_type_size[] = { |
@@ -402,8 +401,7 @@ static struct nlmsghdr *rtnetlink_ifinfo_prep(struct net_device *dev, | |||
402 | r->ifi_flags = dev_get_flags(dev); | 401 | r->ifi_flags = dev_get_flags(dev); |
403 | r->ifi_change = 0; /* Wireless changes don't affect those flags */ | 402 | r->ifi_change = 0; /* Wireless changes don't affect those flags */ |
404 | 403 | ||
405 | if (nla_put_string(skb, IFLA_IFNAME, dev->name)) | 404 | NLA_PUT_STRING(skb, IFLA_IFNAME, dev->name); |
406 | goto nla_put_failure; | ||
407 | 405 | ||
408 | return nlh; | 406 | return nlh; |
409 | nla_put_failure: | 407 | nla_put_failure: |
@@ -429,7 +427,7 @@ void wireless_send_event(struct net_device * dev, | |||
429 | int hdr_len; /* Size of the event header */ | 427 | int hdr_len; /* Size of the event header */ |
430 | int wrqu_off = 0; /* Offset in wrqu */ | 428 | int wrqu_off = 0; /* Offset in wrqu */ |
431 | /* Don't "optimise" the following variable, it will crash */ | 429 | /* Don't "optimise" the following variable, it will crash */ |
432 | unsigned int cmd_index; /* *MUST* be unsigned */ | 430 | unsigned cmd_index; /* *MUST* be unsigned */ |
433 | struct sk_buff *skb; | 431 | struct sk_buff *skb; |
434 | struct nlmsghdr *nlh; | 432 | struct nlmsghdr *nlh; |
435 | struct nlattr *nla; | 433 | struct nlattr *nla; |
@@ -478,13 +476,13 @@ void wireless_send_event(struct net_device * dev, | |||
478 | if (descr->header_type == IW_HEADER_TYPE_POINT) { | 476 | if (descr->header_type == IW_HEADER_TYPE_POINT) { |
479 | /* Check if number of token fits within bounds */ | 477 | /* Check if number of token fits within bounds */ |
480 | if (wrqu->data.length > descr->max_tokens) { | 478 | if (wrqu->data.length > descr->max_tokens) { |
481 | netdev_err(dev, "(WE) : Wireless Event (cmd=0x%04X) too big (%d)\n", | 479 | netdev_err(dev, "(WE) : Wireless Event too big (%d)\n", |
482 | cmd, wrqu->data.length); | 480 | wrqu->data.length); |
483 | return; | 481 | return; |
484 | } | 482 | } |
485 | if (wrqu->data.length < descr->min_tokens) { | 483 | if (wrqu->data.length < descr->min_tokens) { |
486 | netdev_err(dev, "(WE) : Wireless Event (cmd=0x%04X) too small (%d)\n", | 484 | netdev_err(dev, "(WE) : Wireless Event too small (%d)\n", |
487 | cmd, wrqu->data.length); | 485 | wrqu->data.length); |
488 | return; | 486 | return; |
489 | } | 487 | } |
490 | /* Calculate extra_len - extra is NULL for restricted events */ | 488 | /* Calculate extra_len - extra is NULL for restricted events */ |
@@ -781,10 +779,8 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd, | |||
781 | if (cmd == SIOCSIWENCODEEXT) { | 779 | if (cmd == SIOCSIWENCODEEXT) { |
782 | struct iw_encode_ext *ee = (void *) extra; | 780 | struct iw_encode_ext *ee = (void *) extra; |
783 | 781 | ||
784 | if (iwp->length < sizeof(*ee) + ee->key_len) { | 782 | if (iwp->length < sizeof(*ee) + ee->key_len) |
785 | err = -EFAULT; | 783 | return -EFAULT; |
786 | goto out; | ||
787 | } | ||
788 | } | 784 | } |
789 | } | 785 | } |
790 | 786 | ||
diff --git a/net/wireless/wext-sme.c b/net/wireless/wext-sme.c index fb9622f6d99..6fffe62d7c2 100644 --- a/net/wireless/wext-sme.c +++ b/net/wireless/wext-sme.c | |||
@@ -5,12 +5,10 @@ | |||
5 | * Copyright (C) 2009 Intel Corporation. All rights reserved. | 5 | * Copyright (C) 2009 Intel Corporation. All rights reserved. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include <linux/export.h> | ||
9 | #include <linux/etherdevice.h> | 8 | #include <linux/etherdevice.h> |
10 | #include <linux/if_arp.h> | 9 | #include <linux/if_arp.h> |
11 | #include <linux/slab.h> | 10 | #include <linux/slab.h> |
12 | #include <net/cfg80211.h> | 11 | #include <net/cfg80211.h> |
13 | #include <net/cfg80211-wext.h> | ||
14 | #include "wext-compat.h" | 12 | #include "wext-compat.h" |
15 | #include "nl80211.h" | 13 | #include "nl80211.h" |
16 | 14 | ||
@@ -30,9 +28,6 @@ int cfg80211_mgd_wext_connect(struct cfg80211_registered_device *rdev, | |||
30 | wdev->wext.connect.ie = wdev->wext.ie; | 28 | wdev->wext.connect.ie = wdev->wext.ie; |
31 | wdev->wext.connect.ie_len = wdev->wext.ie_len; | 29 | wdev->wext.connect.ie_len = wdev->wext.ie_len; |
32 | 30 | ||
33 | /* Use default background scan period */ | ||
34 | wdev->wext.connect.bg_scan_period = -1; | ||
35 | |||
36 | if (wdev->wext.keys) { | 31 | if (wdev->wext.keys) { |
37 | wdev->wext.keys->def = wdev->wext.default_key; | 32 | wdev->wext.keys->def = wdev->wext.default_key; |
38 | wdev->wext.keys->defmgmt = wdev->wext.default_mgmt_key; | 33 | wdev->wext.keys->defmgmt = wdev->wext.default_mgmt_key; |
@@ -111,24 +106,9 @@ int cfg80211_mgd_wext_siwfreq(struct net_device *dev, | |||
111 | 106 | ||
112 | wdev->wext.connect.channel = chan; | 107 | wdev->wext.connect.channel = chan; |
113 | 108 | ||
114 | /* | 109 | /* SSID is not set, we just want to switch channel */ |
115 | * SSID is not set, we just want to switch monitor channel, | ||
116 | * this is really just backward compatibility, if the SSID | ||
117 | * is set then we use the channel to select the BSS to use | ||
118 | * to connect to instead. If we were connected on another | ||
119 | * channel we disconnected above and reconnect below. | ||
120 | */ | ||
121 | if (chan && !wdev->wext.connect.ssid_len) { | 110 | if (chan && !wdev->wext.connect.ssid_len) { |
122 | struct cfg80211_chan_def chandef = { | 111 | err = cfg80211_set_freq(rdev, wdev, freq, NL80211_CHAN_NO_HT); |
123 | .width = NL80211_CHAN_WIDTH_20_NOHT, | ||
124 | .center_freq1 = freq, | ||
125 | }; | ||
126 | |||
127 | chandef.chan = ieee80211_get_channel(&rdev->wiphy, freq); | ||
128 | if (chandef.chan) | ||
129 | err = cfg80211_set_monitor_channel(rdev, &chandef); | ||
130 | else | ||
131 | err = -EINVAL; | ||
132 | goto out; | 112 | goto out; |
133 | } | 113 | } |
134 | 114 | ||
@@ -242,17 +222,13 @@ int cfg80211_mgd_wext_giwessid(struct net_device *dev, | |||
242 | 222 | ||
243 | wdev_lock(wdev); | 223 | wdev_lock(wdev); |
244 | if (wdev->current_bss) { | 224 | if (wdev->current_bss) { |
245 | const u8 *ie; | 225 | const u8 *ie = ieee80211_bss_get_ie(&wdev->current_bss->pub, |
246 | 226 | WLAN_EID_SSID); | |
247 | rcu_read_lock(); | ||
248 | ie = ieee80211_bss_get_ie(&wdev->current_bss->pub, | ||
249 | WLAN_EID_SSID); | ||
250 | if (ie) { | 227 | if (ie) { |
251 | data->flags = 1; | 228 | data->flags = 1; |
252 | data->length = ie[1]; | 229 | data->length = ie[1]; |
253 | memcpy(ssid, ie + 2, data->length); | 230 | memcpy(ssid, ie + 2, data->length); |
254 | } | 231 | } |
255 | rcu_read_unlock(); | ||
256 | } else if (wdev->wext.connect.ssid && wdev->wext.connect.ssid_len) { | 232 | } else if (wdev->wext.connect.ssid && wdev->wext.connect.ssid_len) { |
257 | data->flags = 1; | 233 | data->flags = 1; |
258 | data->length = wdev->wext.connect.ssid_len; | 234 | data->length = wdev->wext.connect.ssid_len; |
@@ -295,7 +271,7 @@ int cfg80211_mgd_wext_siwap(struct net_device *dev, | |||
295 | 271 | ||
296 | /* fixed already - and no change */ | 272 | /* fixed already - and no change */ |
297 | if (wdev->wext.connect.bssid && bssid && | 273 | if (wdev->wext.connect.bssid && bssid && |
298 | ether_addr_equal(bssid, wdev->wext.connect.bssid)) | 274 | compare_ether_addr(bssid, wdev->wext.connect.bssid) == 0) |
299 | goto out; | 275 | goto out; |
300 | 276 | ||
301 | err = __cfg80211_disconnect(rdev, dev, | 277 | err = __cfg80211_disconnect(rdev, dev, |
@@ -389,6 +365,7 @@ int cfg80211_wext_siwgenie(struct net_device *dev, | |||
389 | wdev_unlock(wdev); | 365 | wdev_unlock(wdev); |
390 | return err; | 366 | return err; |
391 | } | 367 | } |
368 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwgenie); | ||
392 | 369 | ||
393 | int cfg80211_wext_siwmlme(struct net_device *dev, | 370 | int cfg80211_wext_siwmlme(struct net_device *dev, |
394 | struct iw_request_info *info, | 371 | struct iw_request_info *info, |
@@ -425,3 +402,4 @@ int cfg80211_wext_siwmlme(struct net_device *dev, | |||
425 | 402 | ||
426 | return err; | 403 | return err; |
427 | } | 404 | } |
405 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwmlme); | ||
diff --git a/net/wireless/wext-spy.c b/net/wireless/wext-spy.c index 33bef22e44e..6dcfe65a2d1 100644 --- a/net/wireless/wext-spy.c +++ b/net/wireless/wext-spy.c | |||
@@ -10,7 +10,6 @@ | |||
10 | #include <linux/wireless.h> | 10 | #include <linux/wireless.h> |
11 | #include <linux/netdevice.h> | 11 | #include <linux/netdevice.h> |
12 | #include <linux/etherdevice.h> | 12 | #include <linux/etherdevice.h> |
13 | #include <linux/export.h> | ||
14 | #include <net/iw_handler.h> | 13 | #include <net/iw_handler.h> |
15 | #include <net/arp.h> | 14 | #include <net/arp.h> |
16 | #include <net/wext.h> | 15 | #include <net/wext.h> |
@@ -203,7 +202,7 @@ void wireless_spy_update(struct net_device * dev, | |||
203 | 202 | ||
204 | /* Update all records that match */ | 203 | /* Update all records that match */ |
205 | for (i = 0; i < spydata->spy_number; i++) | 204 | for (i = 0; i < spydata->spy_number; i++) |
206 | if (ether_addr_equal(address, spydata->spy_address[i])) { | 205 | if (!compare_ether_addr(address, spydata->spy_address[i])) { |
207 | memcpy(&(spydata->spy_stat[i]), wstats, | 206 | memcpy(&(spydata->spy_stat[i]), wstats, |
208 | sizeof(struct iw_quality)); | 207 | sizeof(struct iw_quality)); |
209 | match = i; | 208 | match = i; |