blob: 702ca122c498938691842d95db7732d6d8c6d6bb [file] [log] [blame]
Jiri Bence9f207f2007-05-05 11:46:38 -07001/*
2 * Copyright 2003-2005 Devicescape Software, Inc.
3 * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
4 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/kobject.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090012#include <linux/slab.h>
Jiri Bence9f207f2007-05-05 11:46:38 -070013#include "ieee80211_i.h"
Johannes Berg2c8dccc2008-04-08 15:14:40 -040014#include "key.h"
Jiri Bence9f207f2007-05-05 11:46:38 -070015#include "debugfs.h"
16#include "debugfs_key.h"
17
Eliad Peller07caf9d2010-10-27 14:58:29 +020018#define KEY_READ(name, prop, format_string) \
Jiri Bence9f207f2007-05-05 11:46:38 -070019static ssize_t key_##name##_read(struct file *file, \
20 char __user *userbuf, \
21 size_t count, loff_t *ppos) \
22{ \
Jiri Bence9f207f2007-05-05 11:46:38 -070023 struct ieee80211_key *key = file->private_data; \
Eliad Peller07caf9d2010-10-27 14:58:29 +020024 return mac80211_format_buffer(userbuf, count, ppos, \
25 format_string, key->prop); \
Jiri Bence9f207f2007-05-05 11:46:38 -070026}
Eliad Peller07caf9d2010-10-27 14:58:29 +020027#define KEY_READ_D(name) KEY_READ(name, name, "%d\n")
28#define KEY_READ_X(name) KEY_READ(name, name, "0x%x\n")
Jiri Bence9f207f2007-05-05 11:46:38 -070029
30#define KEY_OPS(name) \
31static const struct file_operations key_ ##name## _ops = { \
32 .read = key_##name##_read, \
Stephen Boyd234e3402012-04-05 14:25:11 -070033 .open = simple_open, \
Arnd Bergmann2b18ab362010-07-06 19:05:31 +020034 .llseek = generic_file_llseek, \
Jiri Bence9f207f2007-05-05 11:46:38 -070035}
36
37#define KEY_FILE(name, format) \
38 KEY_READ_##format(name) \
39 KEY_OPS(name)
40
Eliad Peller07caf9d2010-10-27 14:58:29 +020041#define KEY_CONF_READ(name, format_string) \
42 KEY_READ(conf_##name, conf.name, format_string)
43#define KEY_CONF_READ_D(name) KEY_CONF_READ(name, "%d\n")
Johannes Berg8f20fc22007-08-28 17:01:54 -040044
45#define KEY_CONF_OPS(name) \
46static const struct file_operations key_ ##name## _ops = { \
47 .read = key_conf_##name##_read, \
Stephen Boyd234e3402012-04-05 14:25:11 -070048 .open = simple_open, \
Arnd Bergmann2b18ab362010-07-06 19:05:31 +020049 .llseek = generic_file_llseek, \
Johannes Berg8f20fc22007-08-28 17:01:54 -040050}
51
52#define KEY_CONF_FILE(name, format) \
53 KEY_CONF_READ_##format(name) \
54 KEY_CONF_OPS(name)
55
56KEY_CONF_FILE(keylen, D);
57KEY_CONF_FILE(keyidx, D);
58KEY_CONF_FILE(hw_key_idx, D);
Johannes Berg11a843b2007-08-28 17:01:55 -040059KEY_FILE(flags, X);
Eliad Peller07caf9d2010-10-27 14:58:29 +020060KEY_READ(ifindex, sdata->name, "%s\n");
Johannes Berge7a64f12007-08-28 17:01:55 -040061KEY_OPS(ifindex);
Jiri Bence9f207f2007-05-05 11:46:38 -070062
63static ssize_t key_algorithm_read(struct file *file,
64 char __user *userbuf,
65 size_t count, loff_t *ppos)
66{
Johannes Berg97359d12010-08-10 09:46:38 +020067 char buf[15];
Jiri Bence9f207f2007-05-05 11:46:38 -070068 struct ieee80211_key *key = file->private_data;
Johannes Berg97359d12010-08-10 09:46:38 +020069 u32 c = key->conf.cipher;
Jiri Bence9f207f2007-05-05 11:46:38 -070070
Johannes Berg97359d12010-08-10 09:46:38 +020071 sprintf(buf, "%.2x-%.2x-%.2x:%d\n",
72 c >> 24, (c >> 16) & 0xff, (c >> 8) & 0xff, c & 0xff);
73 return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf));
Jiri Bence9f207f2007-05-05 11:46:38 -070074}
75KEY_OPS(algorithm);
76
77static ssize_t key_tx_spec_read(struct file *file, char __user *userbuf,
78 size_t count, loff_t *ppos)
79{
Johannes Bergaba83a0b2011-07-06 21:59:39 +020080 u64 pn;
Jiri Bence9f207f2007-05-05 11:46:38 -070081 char buf[20];
82 int len;
83 struct ieee80211_key *key = file->private_data;
84
Johannes Berg97359d12010-08-10 09:46:38 +020085 switch (key->conf.cipher) {
86 case WLAN_CIPHER_SUITE_WEP40:
87 case WLAN_CIPHER_SUITE_WEP104:
Jiri Bence9f207f2007-05-05 11:46:38 -070088 len = scnprintf(buf, sizeof(buf), "\n");
Johannes Berg50339a62007-08-28 17:01:52 -040089 break;
Johannes Berg97359d12010-08-10 09:46:38 +020090 case WLAN_CIPHER_SUITE_TKIP:
Jiri Bence9f207f2007-05-05 11:46:38 -070091 len = scnprintf(buf, sizeof(buf), "%08x %04x\n",
Harvey Harrisonb0f76b32008-05-14 16:26:19 -070092 key->u.tkip.tx.iv32,
93 key->u.tkip.tx.iv16);
Johannes Berg50339a62007-08-28 17:01:52 -040094 break;
Johannes Berg97359d12010-08-10 09:46:38 +020095 case WLAN_CIPHER_SUITE_CCMP:
Jouni Malinen2b2ba0d2015-01-24 19:52:07 +020096 case WLAN_CIPHER_SUITE_CCMP_256:
Johannes Berg97359d12010-08-10 09:46:38 +020097 case WLAN_CIPHER_SUITE_AES_CMAC:
Jouni Malinen56c52da2015-01-24 19:52:08 +020098 case WLAN_CIPHER_SUITE_BIP_CMAC_256:
Jouni Malinen8ade5382015-01-24 19:52:09 +020099 case WLAN_CIPHER_SUITE_BIP_GMAC_128:
100 case WLAN_CIPHER_SUITE_BIP_GMAC_256:
Jouni Malinen00b9cfa2015-01-24 19:52:06 +0200101 case WLAN_CIPHER_SUITE_GCMP:
102 case WLAN_CIPHER_SUITE_GCMP_256:
Johannes Bergdb388a52015-06-01 15:36:51 +0200103 pn = atomic64_read(&key->conf.tx_pn);
Jouni Malinen00b9cfa2015-01-24 19:52:06 +0200104 len = scnprintf(buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x\n",
105 (u8)(pn >> 40), (u8)(pn >> 32), (u8)(pn >> 24),
106 (u8)(pn >> 16), (u8)(pn >> 8), (u8)pn);
107 break;
Jiri Bence9f207f2007-05-05 11:46:38 -0700108 default:
109 return 0;
110 }
111 return simple_read_from_buffer(userbuf, count, ppos, buf, len);
112}
113KEY_OPS(tx_spec);
114
115static ssize_t key_rx_spec_read(struct file *file, char __user *userbuf,
116 size_t count, loff_t *ppos)
117{
118 struct ieee80211_key *key = file->private_data;
Johannes Berg5a306f52012-11-14 23:22:21 +0100119 char buf[14*IEEE80211_NUM_TIDS+1], *p = buf;
Jiri Bence9f207f2007-05-05 11:46:38 -0700120 int i, len;
121 const u8 *rpn;
122
Johannes Berg97359d12010-08-10 09:46:38 +0200123 switch (key->conf.cipher) {
124 case WLAN_CIPHER_SUITE_WEP40:
125 case WLAN_CIPHER_SUITE_WEP104:
Jiri Bence9f207f2007-05-05 11:46:38 -0700126 len = scnprintf(buf, sizeof(buf), "\n");
Johannes Berg50339a62007-08-28 17:01:52 -0400127 break;
Johannes Berg97359d12010-08-10 09:46:38 +0200128 case WLAN_CIPHER_SUITE_TKIP:
Johannes Berg5a306f52012-11-14 23:22:21 +0100129 for (i = 0; i < IEEE80211_NUM_TIDS; i++)
Jiri Bence9f207f2007-05-05 11:46:38 -0700130 p += scnprintf(p, sizeof(buf)+buf-p,
131 "%08x %04x\n",
Harvey Harrisonb0f76b32008-05-14 16:26:19 -0700132 key->u.tkip.rx[i].iv32,
133 key->u.tkip.rx[i].iv16);
Jiri Bence9f207f2007-05-05 11:46:38 -0700134 len = p - buf;
Johannes Berg50339a62007-08-28 17:01:52 -0400135 break;
Johannes Berg97359d12010-08-10 09:46:38 +0200136 case WLAN_CIPHER_SUITE_CCMP:
Jouni Malinen2b2ba0d2015-01-24 19:52:07 +0200137 case WLAN_CIPHER_SUITE_CCMP_256:
Johannes Berg5a306f52012-11-14 23:22:21 +0100138 for (i = 0; i < IEEE80211_NUM_TIDS + 1; i++) {
Jiri Bence9f207f2007-05-05 11:46:38 -0700139 rpn = key->u.ccmp.rx_pn[i];
140 p += scnprintf(p, sizeof(buf)+buf-p,
141 "%02x%02x%02x%02x%02x%02x\n",
142 rpn[0], rpn[1], rpn[2],
143 rpn[3], rpn[4], rpn[5]);
144 }
145 len = p - buf;
Johannes Berg50339a62007-08-28 17:01:52 -0400146 break;
Johannes Berg97359d12010-08-10 09:46:38 +0200147 case WLAN_CIPHER_SUITE_AES_CMAC:
Jouni Malinen56c52da2015-01-24 19:52:08 +0200148 case WLAN_CIPHER_SUITE_BIP_CMAC_256:
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200149 rpn = key->u.aes_cmac.rx_pn;
150 p += scnprintf(p, sizeof(buf)+buf-p,
151 "%02x%02x%02x%02x%02x%02x\n",
152 rpn[0], rpn[1], rpn[2],
153 rpn[3], rpn[4], rpn[5]);
154 len = p - buf;
155 break;
Jouni Malinen8ade5382015-01-24 19:52:09 +0200156 case WLAN_CIPHER_SUITE_BIP_GMAC_128:
157 case WLAN_CIPHER_SUITE_BIP_GMAC_256:
158 rpn = key->u.aes_gmac.rx_pn;
159 p += scnprintf(p, sizeof(buf)+buf-p,
160 "%02x%02x%02x%02x%02x%02x\n",
161 rpn[0], rpn[1], rpn[2],
162 rpn[3], rpn[4], rpn[5]);
163 len = p - buf;
164 break;
Jouni Malinen00b9cfa2015-01-24 19:52:06 +0200165 case WLAN_CIPHER_SUITE_GCMP:
166 case WLAN_CIPHER_SUITE_GCMP_256:
167 for (i = 0; i < IEEE80211_NUM_TIDS + 1; i++) {
168 rpn = key->u.gcmp.rx_pn[i];
169 p += scnprintf(p, sizeof(buf)+buf-p,
170 "%02x%02x%02x%02x%02x%02x\n",
171 rpn[0], rpn[1], rpn[2],
172 rpn[3], rpn[4], rpn[5]);
173 }
174 len = p - buf;
175 break;
Jiri Bence9f207f2007-05-05 11:46:38 -0700176 default:
177 return 0;
178 }
179 return simple_read_from_buffer(userbuf, count, ppos, buf, len);
180}
181KEY_OPS(rx_spec);
182
183static ssize_t key_replays_read(struct file *file, char __user *userbuf,
184 size_t count, loff_t *ppos)
185{
186 struct ieee80211_key *key = file->private_data;
187 char buf[20];
188 int len;
189
Johannes Berg97359d12010-08-10 09:46:38 +0200190 switch (key->conf.cipher) {
191 case WLAN_CIPHER_SUITE_CCMP:
Jouni Malinen2b2ba0d2015-01-24 19:52:07 +0200192 case WLAN_CIPHER_SUITE_CCMP_256:
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200193 len = scnprintf(buf, sizeof(buf), "%u\n", key->u.ccmp.replays);
194 break;
Johannes Berg97359d12010-08-10 09:46:38 +0200195 case WLAN_CIPHER_SUITE_AES_CMAC:
Jouni Malinen56c52da2015-01-24 19:52:08 +0200196 case WLAN_CIPHER_SUITE_BIP_CMAC_256:
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200197 len = scnprintf(buf, sizeof(buf), "%u\n",
198 key->u.aes_cmac.replays);
199 break;
Jouni Malinen8ade5382015-01-24 19:52:09 +0200200 case WLAN_CIPHER_SUITE_BIP_GMAC_128:
201 case WLAN_CIPHER_SUITE_BIP_GMAC_256:
202 len = scnprintf(buf, sizeof(buf), "%u\n",
203 key->u.aes_gmac.replays);
204 break;
Jouni Malinen00b9cfa2015-01-24 19:52:06 +0200205 case WLAN_CIPHER_SUITE_GCMP:
206 case WLAN_CIPHER_SUITE_GCMP_256:
207 len = scnprintf(buf, sizeof(buf), "%u\n", key->u.gcmp.replays);
208 break;
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200209 default:
Jiri Bence9f207f2007-05-05 11:46:38 -0700210 return 0;
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200211 }
Jiri Bence9f207f2007-05-05 11:46:38 -0700212 return simple_read_from_buffer(userbuf, count, ppos, buf, len);
213}
214KEY_OPS(replays);
215
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200216static ssize_t key_icverrors_read(struct file *file, char __user *userbuf,
217 size_t count, loff_t *ppos)
218{
219 struct ieee80211_key *key = file->private_data;
220 char buf[20];
221 int len;
222
Johannes Berg97359d12010-08-10 09:46:38 +0200223 switch (key->conf.cipher) {
224 case WLAN_CIPHER_SUITE_AES_CMAC:
Jouni Malinen56c52da2015-01-24 19:52:08 +0200225 case WLAN_CIPHER_SUITE_BIP_CMAC_256:
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200226 len = scnprintf(buf, sizeof(buf), "%u\n",
227 key->u.aes_cmac.icverrors);
228 break;
Jouni Malinen8ade5382015-01-24 19:52:09 +0200229 case WLAN_CIPHER_SUITE_BIP_GMAC_128:
230 case WLAN_CIPHER_SUITE_BIP_GMAC_256:
231 len = scnprintf(buf, sizeof(buf), "%u\n",
232 key->u.aes_gmac.icverrors);
233 break;
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200234 default:
235 return 0;
236 }
237 return simple_read_from_buffer(userbuf, count, ppos, buf, len);
238}
239KEY_OPS(icverrors);
240
Saravanab98ea052012-12-04 19:47:42 +0530241static ssize_t key_mic_failures_read(struct file *file, char __user *userbuf,
242 size_t count, loff_t *ppos)
243{
244 struct ieee80211_key *key = file->private_data;
245 char buf[20];
246 int len;
247
248 if (key->conf.cipher != WLAN_CIPHER_SUITE_TKIP)
249 return -EINVAL;
250
251 len = scnprintf(buf, sizeof(buf), "%u\n", key->u.tkip.mic_failures);
252
253 return simple_read_from_buffer(userbuf, count, ppos, buf, len);
254}
255KEY_OPS(mic_failures);
256
Jiri Bence9f207f2007-05-05 11:46:38 -0700257static ssize_t key_key_read(struct file *file, char __user *userbuf,
258 size_t count, loff_t *ppos)
259{
260 struct ieee80211_key *key = file->private_data;
Jesper Juhl520efd12010-10-29 16:10:26 +0200261 int i, bufsize = 2 * key->conf.keylen + 2;
Jiri Bence9f207f2007-05-05 11:46:38 -0700262 char *buf = kmalloc(bufsize, GFP_KERNEL);
263 char *p = buf;
Jesper Juhl520efd12010-10-29 16:10:26 +0200264 ssize_t res;
265
266 if (!buf)
267 return -ENOMEM;
Jiri Bence9f207f2007-05-05 11:46:38 -0700268
Johannes Berg8f20fc22007-08-28 17:01:54 -0400269 for (i = 0; i < key->conf.keylen; i++)
270 p += scnprintf(p, bufsize + buf - p, "%02x", key->conf.key[i]);
Jiri Bence9f207f2007-05-05 11:46:38 -0700271 p += scnprintf(p, bufsize+buf-p, "\n");
272 res = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
273 kfree(buf);
274 return res;
275}
276KEY_OPS(key);
277
278#define DEBUGFS_ADD(name) \
Johannes Berg7bcfaf22009-10-27 12:59:03 +0100279 debugfs_create_file(#name, 0400, key->debugfs.dir, \
280 key, &key_##name##_ops);
Jiri Bence9f207f2007-05-05 11:46:38 -0700281
Johannes Berg3b967662008-04-08 17:56:52 +0200282void ieee80211_debugfs_key_add(struct ieee80211_key *key)
Johannes Berg9446f3e2012-01-17 10:32:01 +0100283{
Johannes Berg50339a62007-08-28 17:01:52 -0400284 static int keycount;
Johannes Berg9446f3e2012-01-17 10:32:01 +0100285 char buf[100];
Johannes Berg3b967662008-04-08 17:56:52 +0200286 struct sta_info *sta;
Jiri Bence9f207f2007-05-05 11:46:38 -0700287
Johannes Berg3b967662008-04-08 17:56:52 +0200288 if (!key->local->debugfs.keys)
Jiri Bence9f207f2007-05-05 11:46:38 -0700289 return;
290
Johannes Berg50339a62007-08-28 17:01:52 -0400291 sprintf(buf, "%d", keycount);
Johannes Bergd9c58f32008-04-08 16:46:36 -0400292 key->debugfs.cnt = keycount;
Johannes Berg50339a62007-08-28 17:01:52 -0400293 keycount++;
Jiri Bence9f207f2007-05-05 11:46:38 -0700294 key->debugfs.dir = debugfs_create_dir(buf,
Johannes Berg3b967662008-04-08 17:56:52 +0200295 key->local->debugfs.keys);
Jiri Bence9f207f2007-05-05 11:46:38 -0700296
297 if (!key->debugfs.dir)
298 return;
299
Johannes Berg40b275b2011-05-13 14:15:49 +0200300 sta = key->sta;
301 if (sta) {
Johannes Berg9446f3e2012-01-17 10:32:01 +0100302 sprintf(buf, "../../netdev:%s/stations/%pM",
303 sta->sdata->name, sta->sta.addr);
Johannes Berg3b967662008-04-08 17:56:52 +0200304 key->debugfs.stalink =
305 debugfs_create_symlink("station", key->debugfs.dir, buf);
Johannes Berg40b275b2011-05-13 14:15:49 +0200306 }
Johannes Berg3b967662008-04-08 17:56:52 +0200307
Jiri Bence9f207f2007-05-05 11:46:38 -0700308 DEBUGFS_ADD(keylen);
Johannes Berg8f20fc22007-08-28 17:01:54 -0400309 DEBUGFS_ADD(flags);
Jiri Bence9f207f2007-05-05 11:46:38 -0700310 DEBUGFS_ADD(keyidx);
311 DEBUGFS_ADD(hw_key_idx);
Jiri Bence9f207f2007-05-05 11:46:38 -0700312 DEBUGFS_ADD(algorithm);
313 DEBUGFS_ADD(tx_spec);
314 DEBUGFS_ADD(rx_spec);
315 DEBUGFS_ADD(replays);
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200316 DEBUGFS_ADD(icverrors);
Saravanab98ea052012-12-04 19:47:42 +0530317 DEBUGFS_ADD(mic_failures);
Jiri Bence9f207f2007-05-05 11:46:38 -0700318 DEBUGFS_ADD(key);
Johannes Berge7a64f12007-08-28 17:01:55 -0400319 DEBUGFS_ADD(ifindex);
Jiri Bence9f207f2007-05-05 11:46:38 -0700320};
321
Jiri Bence9f207f2007-05-05 11:46:38 -0700322void ieee80211_debugfs_key_remove(struct ieee80211_key *key)
323{
324 if (!key)
325 return;
326
Johannes Berg7bcfaf22009-10-27 12:59:03 +0100327 debugfs_remove_recursive(key->debugfs.dir);
Jiri Bence9f207f2007-05-05 11:46:38 -0700328 key->debugfs.dir = NULL;
329}
Johannes Bergf7e01042010-12-09 19:49:02 +0100330
331void ieee80211_debugfs_key_update_default(struct ieee80211_sub_if_data *sdata)
Jiri Bence9f207f2007-05-05 11:46:38 -0700332{
333 char buf[50];
Johannes Berg78520ca2008-05-03 01:04:47 +0200334 struct ieee80211_key *key;
Jiri Bence9f207f2007-05-05 11:46:38 -0700335
Stanislaw Gruszkaddbfe862013-03-08 14:46:14 +0100336 if (!sdata->vif.debugfs_dir)
Jiri Bence9f207f2007-05-05 11:46:38 -0700337 return;
338
Johannes Bergf7e01042010-12-09 19:49:02 +0100339 lockdep_assert_held(&sdata->local->key_mtx);
Johannes Berg78520ca2008-05-03 01:04:47 +0200340
Fabian Frederick5c6761a2014-10-21 18:20:12 +0200341 debugfs_remove(sdata->debugfs.default_unicast_key);
342 sdata->debugfs.default_unicast_key = NULL;
Johannes Berg135792e2012-07-05 21:37:05 +0200343
Johannes Bergf7e01042010-12-09 19:49:02 +0100344 if (sdata->default_unicast_key) {
Johannes Berg40b275b2011-05-13 14:15:49 +0200345 key = key_mtx_dereference(sdata->local,
346 sdata->default_unicast_key);
Johannes Berg78520ca2008-05-03 01:04:47 +0200347 sprintf(buf, "../keys/%d", key->debugfs.cnt);
Johannes Bergf7e01042010-12-09 19:49:02 +0100348 sdata->debugfs.default_unicast_key =
349 debugfs_create_symlink("default_unicast_key",
Stanislaw Gruszkaddbfe862013-03-08 14:46:14 +0100350 sdata->vif.debugfs_dir, buf);
Johannes Berg135792e2012-07-05 21:37:05 +0200351 }
352
Fabian Frederick5c6761a2014-10-21 18:20:12 +0200353 debugfs_remove(sdata->debugfs.default_multicast_key);
354 sdata->debugfs.default_multicast_key = NULL;
Johannes Berg78520ca2008-05-03 01:04:47 +0200355
Johannes Bergf7e01042010-12-09 19:49:02 +0100356 if (sdata->default_multicast_key) {
Johannes Berg40b275b2011-05-13 14:15:49 +0200357 key = key_mtx_dereference(sdata->local,
358 sdata->default_multicast_key);
Johannes Bergf7e01042010-12-09 19:49:02 +0100359 sprintf(buf, "../keys/%d", key->debugfs.cnt);
360 sdata->debugfs.default_multicast_key =
361 debugfs_create_symlink("default_multicast_key",
Stanislaw Gruszkaddbfe862013-03-08 14:46:14 +0100362 sdata->vif.debugfs_dir, buf);
Johannes Bergf7e01042010-12-09 19:49:02 +0100363 }
Jiri Bence9f207f2007-05-05 11:46:38 -0700364}
Jiri Bence9f207f2007-05-05 11:46:38 -0700365
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200366void ieee80211_debugfs_key_add_mgmt_default(struct ieee80211_sub_if_data *sdata)
367{
368 char buf[50];
369 struct ieee80211_key *key;
370
Stanislaw Gruszkaddbfe862013-03-08 14:46:14 +0100371 if (!sdata->vif.debugfs_dir)
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200372 return;
373
Johannes Berg40b275b2011-05-13 14:15:49 +0200374 key = key_mtx_dereference(sdata->local,
375 sdata->default_mgmt_key);
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200376 if (key) {
377 sprintf(buf, "../keys/%d", key->debugfs.cnt);
Johannes Berg7bcfaf22009-10-27 12:59:03 +0100378 sdata->debugfs.default_mgmt_key =
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200379 debugfs_create_symlink("default_mgmt_key",
Stanislaw Gruszkaddbfe862013-03-08 14:46:14 +0100380 sdata->vif.debugfs_dir, buf);
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200381 } else
382 ieee80211_debugfs_key_remove_mgmt_default(sdata);
383}
384
385void ieee80211_debugfs_key_remove_mgmt_default(struct ieee80211_sub_if_data *sdata)
386{
387 if (!sdata)
388 return;
389
Johannes Berg7bcfaf22009-10-27 12:59:03 +0100390 debugfs_remove(sdata->debugfs.default_mgmt_key);
391 sdata->debugfs.default_mgmt_key = NULL;
Jouni Malinen3cfcf6ac2009-01-08 13:32:02 +0200392}
393
Jiri Bence9f207f2007-05-05 11:46:38 -0700394void ieee80211_debugfs_key_sta_del(struct ieee80211_key *key,
395 struct sta_info *sta)
396{
397 debugfs_remove(key->debugfs.stalink);
398 key->debugfs.stalink = NULL;
399}