Commit | Line | Data |
---|---|---|
d2912cb1 | 1 | // SPDX-License-Identifier: GPL-2.0-only |
e9f207f0 JB |
2 | /* |
3 | * Copyright 2003-2005 Devicescape Software, Inc. | |
4 | * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz> | |
5 | * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> | |
d0a77c65 | 6 | * Copyright (C) 2015 Intel Deutschland GmbH |
e9f207f0 JB |
7 | */ |
8 | ||
9 | #include <linux/kobject.h> | |
5a0e3ad6 | 10 | #include <linux/slab.h> |
e9f207f0 | 11 | #include "ieee80211_i.h" |
2c8dccc7 | 12 | #include "key.h" |
e9f207f0 JB |
13 | #include "debugfs.h" |
14 | #include "debugfs_key.h" | |
15 | ||
07caf9d6 | 16 | #define KEY_READ(name, prop, format_string) \ |
e9f207f0 JB |
17 | static ssize_t key_##name##_read(struct file *file, \ |
18 | char __user *userbuf, \ | |
19 | size_t count, loff_t *ppos) \ | |
20 | { \ | |
e9f207f0 | 21 | struct ieee80211_key *key = file->private_data; \ |
07caf9d6 EP |
22 | return mac80211_format_buffer(userbuf, count, ppos, \ |
23 | format_string, key->prop); \ | |
e9f207f0 | 24 | } |
07caf9d6 EP |
25 | #define KEY_READ_D(name) KEY_READ(name, name, "%d\n") |
26 | #define KEY_READ_X(name) KEY_READ(name, name, "0x%x\n") | |
e9f207f0 JB |
27 | |
28 | #define KEY_OPS(name) \ | |
29 | static const struct file_operations key_ ##name## _ops = { \ | |
30 | .read = key_##name##_read, \ | |
234e3405 | 31 | .open = simple_open, \ |
2b18ab36 | 32 | .llseek = generic_file_llseek, \ |
e9f207f0 JB |
33 | } |
34 | ||
d0a77c65 JB |
35 | #define KEY_OPS_W(name) \ |
36 | static const struct file_operations key_ ##name## _ops = { \ | |
37 | .read = key_##name##_read, \ | |
38 | .write = key_##name##_write, \ | |
39 | .open = simple_open, \ | |
40 | .llseek = generic_file_llseek, \ | |
41 | } | |
42 | ||
e9f207f0 JB |
43 | #define KEY_FILE(name, format) \ |
44 | KEY_READ_##format(name) \ | |
45 | KEY_OPS(name) | |
46 | ||
07caf9d6 EP |
47 | #define KEY_CONF_READ(name, format_string) \ |
48 | KEY_READ(conf_##name, conf.name, format_string) | |
49 | #define KEY_CONF_READ_D(name) KEY_CONF_READ(name, "%d\n") | |
8f20fc24 JB |
50 | |
51 | #define KEY_CONF_OPS(name) \ | |
52 | static const struct file_operations key_ ##name## _ops = { \ | |
53 | .read = key_conf_##name##_read, \ | |
234e3405 | 54 | .open = simple_open, \ |
2b18ab36 | 55 | .llseek = generic_file_llseek, \ |
8f20fc24 JB |
56 | } |
57 | ||
58 | #define KEY_CONF_FILE(name, format) \ | |
59 | KEY_CONF_READ_##format(name) \ | |
60 | KEY_CONF_OPS(name) | |
61 | ||
62 | KEY_CONF_FILE(keylen, D); | |
63 | KEY_CONF_FILE(keyidx, D); | |
64 | KEY_CONF_FILE(hw_key_idx, D); | |
11a843b7 | 65 | KEY_FILE(flags, X); |
07caf9d6 | 66 | KEY_READ(ifindex, sdata->name, "%s\n"); |
e7a64f12 | 67 | KEY_OPS(ifindex); |
e9f207f0 JB |
68 | |
69 | static ssize_t key_algorithm_read(struct file *file, | |
70 | char __user *userbuf, | |
71 | size_t count, loff_t *ppos) | |
72 | { | |
97359d12 | 73 | char buf[15]; |
e9f207f0 | 74 | struct ieee80211_key *key = file->private_data; |
97359d12 | 75 | u32 c = key->conf.cipher; |
e9f207f0 | 76 | |
97359d12 JB |
77 | sprintf(buf, "%.2x-%.2x-%.2x:%d\n", |
78 | c >> 24, (c >> 16) & 0xff, (c >> 8) & 0xff, c & 0xff); | |
79 | return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf)); | |
e9f207f0 JB |
80 | } |
81 | KEY_OPS(algorithm); | |
82 | ||
d0a77c65 JB |
83 | static ssize_t key_tx_spec_write(struct file *file, const char __user *userbuf, |
84 | size_t count, loff_t *ppos) | |
85 | { | |
86 | struct ieee80211_key *key = file->private_data; | |
87 | u64 pn; | |
88 | int ret; | |
89 | ||
90 | switch (key->conf.cipher) { | |
91 | case WLAN_CIPHER_SUITE_WEP40: | |
92 | case WLAN_CIPHER_SUITE_WEP104: | |
93 | return -EINVAL; | |
94 | case WLAN_CIPHER_SUITE_TKIP: | |
95 | /* not supported yet */ | |
96 | return -EOPNOTSUPP; | |
97 | case WLAN_CIPHER_SUITE_CCMP: | |
98 | case WLAN_CIPHER_SUITE_CCMP_256: | |
99 | case WLAN_CIPHER_SUITE_AES_CMAC: | |
100 | case WLAN_CIPHER_SUITE_BIP_CMAC_256: | |
101 | case WLAN_CIPHER_SUITE_BIP_GMAC_128: | |
102 | case WLAN_CIPHER_SUITE_BIP_GMAC_256: | |
103 | case WLAN_CIPHER_SUITE_GCMP: | |
104 | case WLAN_CIPHER_SUITE_GCMP_256: | |
105 | ret = kstrtou64_from_user(userbuf, count, 16, &pn); | |
106 | if (ret) | |
107 | return ret; | |
108 | /* PN is a 48-bit counter */ | |
109 | if (pn >= (1ULL << 48)) | |
110 | return -ERANGE; | |
111 | atomic64_set(&key->conf.tx_pn, pn); | |
112 | return count; | |
113 | default: | |
114 | return 0; | |
115 | } | |
116 | } | |
117 | ||
e9f207f0 JB |
118 | static ssize_t key_tx_spec_read(struct file *file, char __user *userbuf, |
119 | size_t count, loff_t *ppos) | |
120 | { | |
aba83a0b | 121 | u64 pn; |
e9f207f0 JB |
122 | char buf[20]; |
123 | int len; | |
124 | struct ieee80211_key *key = file->private_data; | |
125 | ||
97359d12 JB |
126 | switch (key->conf.cipher) { |
127 | case WLAN_CIPHER_SUITE_WEP40: | |
128 | case WLAN_CIPHER_SUITE_WEP104: | |
e9f207f0 | 129 | len = scnprintf(buf, sizeof(buf), "\n"); |
50339a67 | 130 | break; |
97359d12 | 131 | case WLAN_CIPHER_SUITE_TKIP: |
f8079d43 | 132 | pn = atomic64_read(&key->conf.tx_pn); |
e9f207f0 | 133 | len = scnprintf(buf, sizeof(buf), "%08x %04x\n", |
f8079d43 EP |
134 | TKIP_PN_TO_IV32(pn), |
135 | TKIP_PN_TO_IV16(pn)); | |
50339a67 | 136 | break; |
97359d12 | 137 | case WLAN_CIPHER_SUITE_CCMP: |
2b2ba0db | 138 | case WLAN_CIPHER_SUITE_CCMP_256: |
97359d12 | 139 | case WLAN_CIPHER_SUITE_AES_CMAC: |
56c52da2 | 140 | case WLAN_CIPHER_SUITE_BIP_CMAC_256: |
8ade538b JM |
141 | case WLAN_CIPHER_SUITE_BIP_GMAC_128: |
142 | case WLAN_CIPHER_SUITE_BIP_GMAC_256: | |
00b9cfa3 JM |
143 | case WLAN_CIPHER_SUITE_GCMP: |
144 | case WLAN_CIPHER_SUITE_GCMP_256: | |
db388a56 | 145 | pn = atomic64_read(&key->conf.tx_pn); |
00b9cfa3 JM |
146 | len = scnprintf(buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x\n", |
147 | (u8)(pn >> 40), (u8)(pn >> 32), (u8)(pn >> 24), | |
148 | (u8)(pn >> 16), (u8)(pn >> 8), (u8)pn); | |
149 | break; | |
e9f207f0 JB |
150 | default: |
151 | return 0; | |
152 | } | |
153 | return simple_read_from_buffer(userbuf, count, ppos, buf, len); | |
154 | } | |
d0a77c65 | 155 | KEY_OPS_W(tx_spec); |
e9f207f0 JB |
156 | |
157 | static ssize_t key_rx_spec_read(struct file *file, char __user *userbuf, | |
158 | size_t count, loff_t *ppos) | |
159 | { | |
160 | struct ieee80211_key *key = file->private_data; | |
5a306f58 | 161 | char buf[14*IEEE80211_NUM_TIDS+1], *p = buf; |
e9f207f0 JB |
162 | int i, len; |
163 | const u8 *rpn; | |
164 | ||
97359d12 JB |
165 | switch (key->conf.cipher) { |
166 | case WLAN_CIPHER_SUITE_WEP40: | |
167 | case WLAN_CIPHER_SUITE_WEP104: | |
e9f207f0 | 168 | len = scnprintf(buf, sizeof(buf), "\n"); |
50339a67 | 169 | break; |
97359d12 | 170 | case WLAN_CIPHER_SUITE_TKIP: |
5a306f58 | 171 | for (i = 0; i < IEEE80211_NUM_TIDS; i++) |
e9f207f0 JB |
172 | p += scnprintf(p, sizeof(buf)+buf-p, |
173 | "%08x %04x\n", | |
b0f76b33 HH |
174 | key->u.tkip.rx[i].iv32, |
175 | key->u.tkip.rx[i].iv16); | |
e9f207f0 | 176 | len = p - buf; |
50339a67 | 177 | break; |
97359d12 | 178 | case WLAN_CIPHER_SUITE_CCMP: |
2b2ba0db | 179 | case WLAN_CIPHER_SUITE_CCMP_256: |
5a306f58 | 180 | for (i = 0; i < IEEE80211_NUM_TIDS + 1; i++) { |
e9f207f0 JB |
181 | rpn = key->u.ccmp.rx_pn[i]; |
182 | p += scnprintf(p, sizeof(buf)+buf-p, | |
183 | "%02x%02x%02x%02x%02x%02x\n", | |
184 | rpn[0], rpn[1], rpn[2], | |
185 | rpn[3], rpn[4], rpn[5]); | |
186 | } | |
187 | len = p - buf; | |
50339a67 | 188 | break; |
97359d12 | 189 | case WLAN_CIPHER_SUITE_AES_CMAC: |
56c52da2 | 190 | case WLAN_CIPHER_SUITE_BIP_CMAC_256: |
3cfcf6ac JM |
191 | rpn = key->u.aes_cmac.rx_pn; |
192 | p += scnprintf(p, sizeof(buf)+buf-p, | |
193 | "%02x%02x%02x%02x%02x%02x\n", | |
194 | rpn[0], rpn[1], rpn[2], | |
195 | rpn[3], rpn[4], rpn[5]); | |
196 | len = p - buf; | |
197 | break; | |
8ade538b JM |
198 | case WLAN_CIPHER_SUITE_BIP_GMAC_128: |
199 | case WLAN_CIPHER_SUITE_BIP_GMAC_256: | |
200 | rpn = key->u.aes_gmac.rx_pn; | |
201 | p += scnprintf(p, sizeof(buf)+buf-p, | |
202 | "%02x%02x%02x%02x%02x%02x\n", | |
203 | rpn[0], rpn[1], rpn[2], | |
204 | rpn[3], rpn[4], rpn[5]); | |
205 | len = p - buf; | |
206 | break; | |
00b9cfa3 JM |
207 | case WLAN_CIPHER_SUITE_GCMP: |
208 | case WLAN_CIPHER_SUITE_GCMP_256: | |
209 | for (i = 0; i < IEEE80211_NUM_TIDS + 1; i++) { | |
210 | rpn = key->u.gcmp.rx_pn[i]; | |
211 | p += scnprintf(p, sizeof(buf)+buf-p, | |
212 | "%02x%02x%02x%02x%02x%02x\n", | |
213 | rpn[0], rpn[1], rpn[2], | |
214 | rpn[3], rpn[4], rpn[5]); | |
215 | } | |
216 | len = p - buf; | |
217 | break; | |
e9f207f0 JB |
218 | default: |
219 | return 0; | |
220 | } | |
221 | return simple_read_from_buffer(userbuf, count, ppos, buf, len); | |
222 | } | |
223 | KEY_OPS(rx_spec); | |
224 | ||
225 | static ssize_t key_replays_read(struct file *file, char __user *userbuf, | |
226 | size_t count, loff_t *ppos) | |
227 | { | |
228 | struct ieee80211_key *key = file->private_data; | |
229 | char buf[20]; | |
230 | int len; | |
231 | ||
97359d12 JB |
232 | switch (key->conf.cipher) { |
233 | case WLAN_CIPHER_SUITE_CCMP: | |
2b2ba0db | 234 | case WLAN_CIPHER_SUITE_CCMP_256: |
3cfcf6ac JM |
235 | len = scnprintf(buf, sizeof(buf), "%u\n", key->u.ccmp.replays); |
236 | break; | |
97359d12 | 237 | case WLAN_CIPHER_SUITE_AES_CMAC: |
56c52da2 | 238 | case WLAN_CIPHER_SUITE_BIP_CMAC_256: |
3cfcf6ac JM |
239 | len = scnprintf(buf, sizeof(buf), "%u\n", |
240 | key->u.aes_cmac.replays); | |
241 | break; | |
8ade538b JM |
242 | case WLAN_CIPHER_SUITE_BIP_GMAC_128: |
243 | case WLAN_CIPHER_SUITE_BIP_GMAC_256: | |
244 | len = scnprintf(buf, sizeof(buf), "%u\n", | |
245 | key->u.aes_gmac.replays); | |
246 | break; | |
00b9cfa3 JM |
247 | case WLAN_CIPHER_SUITE_GCMP: |
248 | case WLAN_CIPHER_SUITE_GCMP_256: | |
249 | len = scnprintf(buf, sizeof(buf), "%u\n", key->u.gcmp.replays); | |
250 | break; | |
3cfcf6ac | 251 | default: |
e9f207f0 | 252 | return 0; |
3cfcf6ac | 253 | } |
e9f207f0 JB |
254 | return simple_read_from_buffer(userbuf, count, ppos, buf, len); |
255 | } | |
256 | KEY_OPS(replays); | |
257 | ||
3cfcf6ac JM |
258 | static ssize_t key_icverrors_read(struct file *file, char __user *userbuf, |
259 | size_t count, loff_t *ppos) | |
260 | { | |
261 | struct ieee80211_key *key = file->private_data; | |
262 | char buf[20]; | |
263 | int len; | |
264 | ||
97359d12 JB |
265 | switch (key->conf.cipher) { |
266 | case WLAN_CIPHER_SUITE_AES_CMAC: | |
56c52da2 | 267 | case WLAN_CIPHER_SUITE_BIP_CMAC_256: |
3cfcf6ac JM |
268 | len = scnprintf(buf, sizeof(buf), "%u\n", |
269 | key->u.aes_cmac.icverrors); | |
270 | break; | |
8ade538b JM |
271 | case WLAN_CIPHER_SUITE_BIP_GMAC_128: |
272 | case WLAN_CIPHER_SUITE_BIP_GMAC_256: | |
273 | len = scnprintf(buf, sizeof(buf), "%u\n", | |
274 | key->u.aes_gmac.icverrors); | |
275 | break; | |
3cfcf6ac JM |
276 | default: |
277 | return 0; | |
278 | } | |
279 | return simple_read_from_buffer(userbuf, count, ppos, buf, len); | |
280 | } | |
281 | KEY_OPS(icverrors); | |
282 | ||
b98ea058 S |
283 | static ssize_t key_mic_failures_read(struct file *file, char __user *userbuf, |
284 | size_t count, loff_t *ppos) | |
285 | { | |
286 | struct ieee80211_key *key = file->private_data; | |
287 | char buf[20]; | |
288 | int len; | |
289 | ||
290 | if (key->conf.cipher != WLAN_CIPHER_SUITE_TKIP) | |
291 | return -EINVAL; | |
292 | ||
293 | len = scnprintf(buf, sizeof(buf), "%u\n", key->u.tkip.mic_failures); | |
294 | ||
295 | return simple_read_from_buffer(userbuf, count, ppos, buf, len); | |
296 | } | |
297 | KEY_OPS(mic_failures); | |
298 | ||
e9f207f0 JB |
299 | static ssize_t key_key_read(struct file *file, char __user *userbuf, |
300 | size_t count, loff_t *ppos) | |
301 | { | |
302 | struct ieee80211_key *key = file->private_data; | |
520efd1a | 303 | int i, bufsize = 2 * key->conf.keylen + 2; |
e9f207f0 JB |
304 | char *buf = kmalloc(bufsize, GFP_KERNEL); |
305 | char *p = buf; | |
520efd1a JJ |
306 | ssize_t res; |
307 | ||
308 | if (!buf) | |
309 | return -ENOMEM; | |
e9f207f0 | 310 | |
8f20fc24 JB |
311 | for (i = 0; i < key->conf.keylen; i++) |
312 | p += scnprintf(p, bufsize + buf - p, "%02x", key->conf.key[i]); | |
e9f207f0 JB |
313 | p += scnprintf(p, bufsize+buf-p, "\n"); |
314 | res = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf); | |
315 | kfree(buf); | |
316 | return res; | |
317 | } | |
318 | KEY_OPS(key); | |
319 | ||
320 | #define DEBUGFS_ADD(name) \ | |
7bcfaf2f | 321 | debugfs_create_file(#name, 0400, key->debugfs.dir, \ |
84674ef4 | 322 | key, &key_##name##_ops) |
d0a77c65 JB |
323 | #define DEBUGFS_ADD_W(name) \ |
324 | debugfs_create_file(#name, 0600, key->debugfs.dir, \ | |
325 | key, &key_##name##_ops); | |
e9f207f0 | 326 | |
3b96766f | 327 | void ieee80211_debugfs_key_add(struct ieee80211_key *key) |
9446f3ef | 328 | { |
50339a67 | 329 | static int keycount; |
9446f3ef | 330 | char buf[100]; |
3b96766f | 331 | struct sta_info *sta; |
e9f207f0 | 332 | |
3b96766f | 333 | if (!key->local->debugfs.keys) |
e9f207f0 JB |
334 | return; |
335 | ||
50339a67 | 336 | sprintf(buf, "%d", keycount); |
d9c58f30 | 337 | key->debugfs.cnt = keycount; |
50339a67 | 338 | keycount++; |
e9f207f0 | 339 | key->debugfs.dir = debugfs_create_dir(buf, |
3b96766f | 340 | key->local->debugfs.keys); |
e9f207f0 | 341 | |
40b275b6 JB |
342 | sta = key->sta; |
343 | if (sta) { | |
9446f3ef JB |
344 | sprintf(buf, "../../netdev:%s/stations/%pM", |
345 | sta->sdata->name, sta->sta.addr); | |
3b96766f JB |
346 | key->debugfs.stalink = |
347 | debugfs_create_symlink("station", key->debugfs.dir, buf); | |
40b275b6 | 348 | } |
3b96766f | 349 | |
e9f207f0 | 350 | DEBUGFS_ADD(keylen); |
8f20fc24 | 351 | DEBUGFS_ADD(flags); |
e9f207f0 JB |
352 | DEBUGFS_ADD(keyidx); |
353 | DEBUGFS_ADD(hw_key_idx); | |
e9f207f0 | 354 | DEBUGFS_ADD(algorithm); |
d0a77c65 | 355 | DEBUGFS_ADD_W(tx_spec); |
e9f207f0 JB |
356 | DEBUGFS_ADD(rx_spec); |
357 | DEBUGFS_ADD(replays); | |
3cfcf6ac | 358 | DEBUGFS_ADD(icverrors); |
b98ea058 | 359 | DEBUGFS_ADD(mic_failures); |
e9f207f0 | 360 | DEBUGFS_ADD(key); |
e7a64f12 | 361 | DEBUGFS_ADD(ifindex); |
e9f207f0 JB |
362 | }; |
363 | ||
e9f207f0 JB |
364 | void ieee80211_debugfs_key_remove(struct ieee80211_key *key) |
365 | { | |
366 | if (!key) | |
367 | return; | |
368 | ||
7bcfaf2f | 369 | debugfs_remove_recursive(key->debugfs.dir); |
e9f207f0 JB |
370 | key->debugfs.dir = NULL; |
371 | } | |
f7e0104c JB |
372 | |
373 | void ieee80211_debugfs_key_update_default(struct ieee80211_sub_if_data *sdata) | |
e9f207f0 JB |
374 | { |
375 | char buf[50]; | |
78520cad | 376 | struct ieee80211_key *key; |
e9f207f0 | 377 | |
ddbfe860 | 378 | if (!sdata->vif.debugfs_dir) |
e9f207f0 JB |
379 | return; |
380 | ||
f7e0104c | 381 | lockdep_assert_held(&sdata->local->key_mtx); |
78520cad | 382 | |
5c6761ad FF |
383 | debugfs_remove(sdata->debugfs.default_unicast_key); |
384 | sdata->debugfs.default_unicast_key = NULL; | |
135792ec | 385 | |
f7e0104c | 386 | if (sdata->default_unicast_key) { |
40b275b6 JB |
387 | key = key_mtx_dereference(sdata->local, |
388 | sdata->default_unicast_key); | |
78520cad | 389 | sprintf(buf, "../keys/%d", key->debugfs.cnt); |
f7e0104c JB |
390 | sdata->debugfs.default_unicast_key = |
391 | debugfs_create_symlink("default_unicast_key", | |
ddbfe860 | 392 | sdata->vif.debugfs_dir, buf); |
135792ec JB |
393 | } |
394 | ||
5c6761ad FF |
395 | debugfs_remove(sdata->debugfs.default_multicast_key); |
396 | sdata->debugfs.default_multicast_key = NULL; | |
e9f207f0 | 397 | |
f7e0104c | 398 | if (sdata->default_multicast_key) { |
40b275b6 JB |
399 | key = key_mtx_dereference(sdata->local, |
400 | sdata->default_multicast_key); | |
f7e0104c JB |
401 | sprintf(buf, "../keys/%d", key->debugfs.cnt); |
402 | sdata->debugfs.default_multicast_key = | |
403 | debugfs_create_symlink("default_multicast_key", | |
ddbfe860 | 404 | sdata->vif.debugfs_dir, buf); |
f7e0104c | 405 | } |
e9f207f0 | 406 | } |
e9f207f0 | 407 | |
3cfcf6ac JM |
408 | void ieee80211_debugfs_key_add_mgmt_default(struct ieee80211_sub_if_data *sdata) |
409 | { | |
410 | char buf[50]; | |
411 | struct ieee80211_key *key; | |
412 | ||
ddbfe860 | 413 | if (!sdata->vif.debugfs_dir) |
3cfcf6ac JM |
414 | return; |
415 | ||
40b275b6 JB |
416 | key = key_mtx_dereference(sdata->local, |
417 | sdata->default_mgmt_key); | |
3cfcf6ac JM |
418 | if (key) { |
419 | sprintf(buf, "../keys/%d", key->debugfs.cnt); | |
7bcfaf2f | 420 | sdata->debugfs.default_mgmt_key = |
3cfcf6ac | 421 | debugfs_create_symlink("default_mgmt_key", |
ddbfe860 | 422 | sdata->vif.debugfs_dir, buf); |
3cfcf6ac JM |
423 | } else |
424 | ieee80211_debugfs_key_remove_mgmt_default(sdata); | |
425 | } | |
426 | ||
427 | void ieee80211_debugfs_key_remove_mgmt_default(struct ieee80211_sub_if_data *sdata) | |
428 | { | |
429 | if (!sdata) | |
430 | return; | |
431 | ||
7bcfaf2f JB |
432 | debugfs_remove(sdata->debugfs.default_mgmt_key); |
433 | sdata->debugfs.default_mgmt_key = NULL; | |
3cfcf6ac JM |
434 | } |
435 | ||
e5473e80 JM |
436 | void |
437 | ieee80211_debugfs_key_add_beacon_default(struct ieee80211_sub_if_data *sdata) | |
438 | { | |
439 | char buf[50]; | |
440 | struct ieee80211_key *key; | |
441 | ||
442 | if (!sdata->vif.debugfs_dir) | |
443 | return; | |
444 | ||
445 | key = key_mtx_dereference(sdata->local, | |
446 | sdata->default_beacon_key); | |
447 | if (key) { | |
448 | sprintf(buf, "../keys/%d", key->debugfs.cnt); | |
449 | sdata->debugfs.default_beacon_key = | |
450 | debugfs_create_symlink("default_beacon_key", | |
451 | sdata->vif.debugfs_dir, buf); | |
452 | } else { | |
453 | ieee80211_debugfs_key_remove_beacon_default(sdata); | |
454 | } | |
455 | } | |
456 | ||
457 | void | |
458 | ieee80211_debugfs_key_remove_beacon_default(struct ieee80211_sub_if_data *sdata) | |
459 | { | |
460 | if (!sdata) | |
461 | return; | |
462 | ||
463 | debugfs_remove(sdata->debugfs.default_beacon_key); | |
464 | sdata->debugfs.default_beacon_key = NULL; | |
465 | } | |
466 | ||
e9f207f0 JB |
467 | void ieee80211_debugfs_key_sta_del(struct ieee80211_key *key, |
468 | struct sta_info *sta) | |
469 | { | |
470 | debugfs_remove(key->debugfs.stalink); | |
471 | key->debugfs.stalink = NULL; | |
472 | } |