Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 1 | /* |
| 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 Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 12 | #include <linux/slab.h> |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 13 | #include "ieee80211_i.h" |
Johannes Berg | 2c8dccc | 2008-04-08 15:14:40 -0400 | [diff] [blame] | 14 | #include "key.h" |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 15 | #include "debugfs.h" |
| 16 | #include "debugfs_key.h" |
| 17 | |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 18 | #define KEY_READ(name, prop, buflen, format_string) \ |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 19 | static ssize_t key_##name##_read(struct file *file, \ |
| 20 | char __user *userbuf, \ |
| 21 | size_t count, loff_t *ppos) \ |
| 22 | { \ |
| 23 | char buf[buflen]; \ |
| 24 | struct ieee80211_key *key = file->private_data; \ |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 25 | int res = scnprintf(buf, buflen, format_string, key->prop); \ |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 26 | return simple_read_from_buffer(userbuf, count, ppos, buf, res); \ |
| 27 | } |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 28 | #define KEY_READ_D(name) KEY_READ(name, name, 20, "%d\n") |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 29 | #define KEY_READ_X(name) KEY_READ(name, name, 20, "0x%x\n") |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 30 | |
| 31 | #define KEY_OPS(name) \ |
| 32 | static const struct file_operations key_ ##name## _ops = { \ |
| 33 | .read = key_##name##_read, \ |
| 34 | .open = mac80211_open_file_generic, \ |
| 35 | } |
| 36 | |
| 37 | #define KEY_FILE(name, format) \ |
| 38 | KEY_READ_##format(name) \ |
| 39 | KEY_OPS(name) |
| 40 | |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 41 | #define KEY_CONF_READ(name, buflen, format_string) \ |
| 42 | KEY_READ(conf_##name, conf.name, buflen, format_string) |
| 43 | #define KEY_CONF_READ_D(name) KEY_CONF_READ(name, 20, "%d\n") |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 44 | |
| 45 | #define KEY_CONF_OPS(name) \ |
| 46 | static const struct file_operations key_ ##name## _ops = { \ |
| 47 | .read = key_conf_##name##_read, \ |
| 48 | .open = mac80211_open_file_generic, \ |
| 49 | } |
| 50 | |
| 51 | #define KEY_CONF_FILE(name, format) \ |
| 52 | KEY_CONF_READ_##format(name) \ |
| 53 | KEY_CONF_OPS(name) |
| 54 | |
| 55 | KEY_CONF_FILE(keylen, D); |
| 56 | KEY_CONF_FILE(keyidx, D); |
| 57 | KEY_CONF_FILE(hw_key_idx, D); |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 58 | KEY_FILE(flags, X); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 59 | KEY_FILE(tx_rx_count, D); |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 60 | KEY_READ(ifindex, sdata->name, IFNAMSIZ + 2, "%s\n"); |
Johannes Berg | e7a64f1 | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 61 | KEY_OPS(ifindex); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 62 | |
| 63 | static ssize_t key_algorithm_read(struct file *file, |
| 64 | char __user *userbuf, |
| 65 | size_t count, loff_t *ppos) |
| 66 | { |
| 67 | char *alg; |
| 68 | struct ieee80211_key *key = file->private_data; |
| 69 | |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 70 | switch (key->conf.alg) { |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 71 | case ALG_WEP: |
| 72 | alg = "WEP\n"; |
| 73 | break; |
| 74 | case ALG_TKIP: |
| 75 | alg = "TKIP\n"; |
| 76 | break; |
| 77 | case ALG_CCMP: |
| 78 | alg = "CCMP\n"; |
| 79 | break; |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 80 | case ALG_AES_CMAC: |
| 81 | alg = "AES-128-CMAC\n"; |
| 82 | break; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 83 | default: |
| 84 | return 0; |
| 85 | } |
| 86 | return simple_read_from_buffer(userbuf, count, ppos, alg, strlen(alg)); |
| 87 | } |
| 88 | KEY_OPS(algorithm); |
| 89 | |
| 90 | static ssize_t key_tx_spec_read(struct file *file, char __user *userbuf, |
| 91 | size_t count, loff_t *ppos) |
| 92 | { |
| 93 | const u8 *tpn; |
| 94 | char buf[20]; |
| 95 | int len; |
| 96 | struct ieee80211_key *key = file->private_data; |
| 97 | |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 98 | switch (key->conf.alg) { |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 99 | case ALG_WEP: |
| 100 | len = scnprintf(buf, sizeof(buf), "\n"); |
Johannes Berg | 50339a6 | 2007-08-28 17:01:52 -0400 | [diff] [blame] | 101 | break; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 102 | case ALG_TKIP: |
| 103 | len = scnprintf(buf, sizeof(buf), "%08x %04x\n", |
Harvey Harrison | b0f76b3 | 2008-05-14 16:26:19 -0700 | [diff] [blame] | 104 | key->u.tkip.tx.iv32, |
| 105 | key->u.tkip.tx.iv16); |
Johannes Berg | 50339a6 | 2007-08-28 17:01:52 -0400 | [diff] [blame] | 106 | break; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 107 | case ALG_CCMP: |
| 108 | tpn = key->u.ccmp.tx_pn; |
| 109 | len = scnprintf(buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x\n", |
| 110 | tpn[0], tpn[1], tpn[2], tpn[3], tpn[4], tpn[5]); |
Johannes Berg | 50339a6 | 2007-08-28 17:01:52 -0400 | [diff] [blame] | 111 | break; |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 112 | case ALG_AES_CMAC: |
| 113 | tpn = key->u.aes_cmac.tx_pn; |
| 114 | len = scnprintf(buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x\n", |
| 115 | tpn[0], tpn[1], tpn[2], tpn[3], tpn[4], |
| 116 | tpn[5]); |
| 117 | break; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 118 | default: |
| 119 | return 0; |
| 120 | } |
| 121 | return simple_read_from_buffer(userbuf, count, ppos, buf, len); |
| 122 | } |
| 123 | KEY_OPS(tx_spec); |
| 124 | |
| 125 | static ssize_t key_rx_spec_read(struct file *file, char __user *userbuf, |
| 126 | size_t count, loff_t *ppos) |
| 127 | { |
| 128 | struct ieee80211_key *key = file->private_data; |
| 129 | char buf[14*NUM_RX_DATA_QUEUES+1], *p = buf; |
| 130 | int i, len; |
| 131 | const u8 *rpn; |
| 132 | |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 133 | switch (key->conf.alg) { |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 134 | case ALG_WEP: |
| 135 | len = scnprintf(buf, sizeof(buf), "\n"); |
Johannes Berg | 50339a6 | 2007-08-28 17:01:52 -0400 | [diff] [blame] | 136 | break; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 137 | case ALG_TKIP: |
| 138 | for (i = 0; i < NUM_RX_DATA_QUEUES; i++) |
| 139 | p += scnprintf(p, sizeof(buf)+buf-p, |
| 140 | "%08x %04x\n", |
Harvey Harrison | b0f76b3 | 2008-05-14 16:26:19 -0700 | [diff] [blame] | 141 | key->u.tkip.rx[i].iv32, |
| 142 | key->u.tkip.rx[i].iv16); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 143 | len = p - buf; |
Johannes Berg | 50339a6 | 2007-08-28 17:01:52 -0400 | [diff] [blame] | 144 | break; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 145 | case ALG_CCMP: |
| 146 | for (i = 0; i < NUM_RX_DATA_QUEUES; i++) { |
| 147 | rpn = key->u.ccmp.rx_pn[i]; |
| 148 | p += scnprintf(p, sizeof(buf)+buf-p, |
| 149 | "%02x%02x%02x%02x%02x%02x\n", |
| 150 | rpn[0], rpn[1], rpn[2], |
| 151 | rpn[3], rpn[4], rpn[5]); |
| 152 | } |
| 153 | len = p - buf; |
Johannes Berg | 50339a6 | 2007-08-28 17:01:52 -0400 | [diff] [blame] | 154 | break; |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 155 | case ALG_AES_CMAC: |
| 156 | rpn = key->u.aes_cmac.rx_pn; |
| 157 | p += scnprintf(p, sizeof(buf)+buf-p, |
| 158 | "%02x%02x%02x%02x%02x%02x\n", |
| 159 | rpn[0], rpn[1], rpn[2], |
| 160 | rpn[3], rpn[4], rpn[5]); |
| 161 | len = p - buf; |
| 162 | break; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 163 | default: |
| 164 | return 0; |
| 165 | } |
| 166 | return simple_read_from_buffer(userbuf, count, ppos, buf, len); |
| 167 | } |
| 168 | KEY_OPS(rx_spec); |
| 169 | |
| 170 | static ssize_t key_replays_read(struct file *file, char __user *userbuf, |
| 171 | size_t count, loff_t *ppos) |
| 172 | { |
| 173 | struct ieee80211_key *key = file->private_data; |
| 174 | char buf[20]; |
| 175 | int len; |
| 176 | |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 177 | switch (key->conf.alg) { |
| 178 | case ALG_CCMP: |
| 179 | len = scnprintf(buf, sizeof(buf), "%u\n", key->u.ccmp.replays); |
| 180 | break; |
| 181 | case ALG_AES_CMAC: |
| 182 | len = scnprintf(buf, sizeof(buf), "%u\n", |
| 183 | key->u.aes_cmac.replays); |
| 184 | break; |
| 185 | default: |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 186 | return 0; |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 187 | } |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 188 | return simple_read_from_buffer(userbuf, count, ppos, buf, len); |
| 189 | } |
| 190 | KEY_OPS(replays); |
| 191 | |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 192 | static ssize_t key_icverrors_read(struct file *file, char __user *userbuf, |
| 193 | size_t count, loff_t *ppos) |
| 194 | { |
| 195 | struct ieee80211_key *key = file->private_data; |
| 196 | char buf[20]; |
| 197 | int len; |
| 198 | |
| 199 | switch (key->conf.alg) { |
| 200 | case ALG_AES_CMAC: |
| 201 | len = scnprintf(buf, sizeof(buf), "%u\n", |
| 202 | key->u.aes_cmac.icverrors); |
| 203 | break; |
| 204 | default: |
| 205 | return 0; |
| 206 | } |
| 207 | return simple_read_from_buffer(userbuf, count, ppos, buf, len); |
| 208 | } |
| 209 | KEY_OPS(icverrors); |
| 210 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 211 | static ssize_t key_key_read(struct file *file, char __user *userbuf, |
| 212 | size_t count, loff_t *ppos) |
| 213 | { |
| 214 | struct ieee80211_key *key = file->private_data; |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 215 | int i, res, bufsize = 2 * key->conf.keylen + 2; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 216 | char *buf = kmalloc(bufsize, GFP_KERNEL); |
| 217 | char *p = buf; |
| 218 | |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 219 | for (i = 0; i < key->conf.keylen; i++) |
| 220 | p += scnprintf(p, bufsize + buf - p, "%02x", key->conf.key[i]); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 221 | p += scnprintf(p, bufsize+buf-p, "\n"); |
| 222 | res = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf); |
| 223 | kfree(buf); |
| 224 | return res; |
| 225 | } |
| 226 | KEY_OPS(key); |
| 227 | |
| 228 | #define DEBUGFS_ADD(name) \ |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 229 | debugfs_create_file(#name, 0400, key->debugfs.dir, \ |
| 230 | key, &key_##name##_ops); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 231 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 232 | void ieee80211_debugfs_key_add(struct ieee80211_key *key) |
| 233 | { |
Johannes Berg | 50339a6 | 2007-08-28 17:01:52 -0400 | [diff] [blame] | 234 | static int keycount; |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 235 | char buf[50]; |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 236 | struct sta_info *sta; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 237 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 238 | if (!key->local->debugfs.keys) |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 239 | return; |
| 240 | |
Johannes Berg | 50339a6 | 2007-08-28 17:01:52 -0400 | [diff] [blame] | 241 | sprintf(buf, "%d", keycount); |
Johannes Berg | d9c58f3 | 2008-04-08 16:46:36 -0400 | [diff] [blame] | 242 | key->debugfs.cnt = keycount; |
Johannes Berg | 50339a6 | 2007-08-28 17:01:52 -0400 | [diff] [blame] | 243 | keycount++; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 244 | key->debugfs.dir = debugfs_create_dir(buf, |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 245 | key->local->debugfs.keys); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 246 | |
| 247 | if (!key->debugfs.dir) |
| 248 | return; |
| 249 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 250 | rcu_read_lock(); |
| 251 | sta = rcu_dereference(key->sta); |
| 252 | if (sta) |
Johannes Berg | 0c68ae26 | 2008-10-27 15:56:10 -0700 | [diff] [blame] | 253 | sprintf(buf, "../../stations/%pM", sta->sta.addr); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 254 | rcu_read_unlock(); |
| 255 | |
| 256 | /* using sta as a boolean is fine outside RCU lock */ |
| 257 | if (sta) |
| 258 | key->debugfs.stalink = |
| 259 | debugfs_create_symlink("station", key->debugfs.dir, buf); |
| 260 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 261 | DEBUGFS_ADD(keylen); |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 262 | DEBUGFS_ADD(flags); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 263 | DEBUGFS_ADD(keyidx); |
| 264 | DEBUGFS_ADD(hw_key_idx); |
| 265 | DEBUGFS_ADD(tx_rx_count); |
| 266 | DEBUGFS_ADD(algorithm); |
| 267 | DEBUGFS_ADD(tx_spec); |
| 268 | DEBUGFS_ADD(rx_spec); |
| 269 | DEBUGFS_ADD(replays); |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 270 | DEBUGFS_ADD(icverrors); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 271 | DEBUGFS_ADD(key); |
Johannes Berg | e7a64f1 | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 272 | DEBUGFS_ADD(ifindex); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 273 | }; |
| 274 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 275 | void ieee80211_debugfs_key_remove(struct ieee80211_key *key) |
| 276 | { |
| 277 | if (!key) |
| 278 | return; |
| 279 | |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 280 | debugfs_remove_recursive(key->debugfs.dir); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 281 | key->debugfs.dir = NULL; |
| 282 | } |
| 283 | void ieee80211_debugfs_key_add_default(struct ieee80211_sub_if_data *sdata) |
| 284 | { |
| 285 | char buf[50]; |
Johannes Berg | 78520ca | 2008-05-03 01:04:47 +0200 | [diff] [blame] | 286 | struct ieee80211_key *key; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 287 | |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 288 | if (!sdata->debugfs.dir) |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 289 | return; |
| 290 | |
Johannes Berg | 78520ca | 2008-05-03 01:04:47 +0200 | [diff] [blame] | 291 | /* this is running under the key lock */ |
| 292 | |
| 293 | key = sdata->default_key; |
| 294 | if (key) { |
| 295 | sprintf(buf, "../keys/%d", key->debugfs.cnt); |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 296 | sdata->debugfs.default_key = |
Johannes Berg | 78520ca | 2008-05-03 01:04:47 +0200 | [diff] [blame] | 297 | debugfs_create_symlink("default_key", |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 298 | sdata->debugfs.dir, buf); |
Johannes Berg | 78520ca | 2008-05-03 01:04:47 +0200 | [diff] [blame] | 299 | } else |
| 300 | ieee80211_debugfs_key_remove_default(sdata); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 301 | } |
Johannes Berg | 78520ca | 2008-05-03 01:04:47 +0200 | [diff] [blame] | 302 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 303 | void ieee80211_debugfs_key_remove_default(struct ieee80211_sub_if_data *sdata) |
| 304 | { |
| 305 | if (!sdata) |
| 306 | return; |
| 307 | |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 308 | debugfs_remove(sdata->debugfs.default_key); |
| 309 | sdata->debugfs.default_key = NULL; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 310 | } |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 311 | |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 312 | void ieee80211_debugfs_key_add_mgmt_default(struct ieee80211_sub_if_data *sdata) |
| 313 | { |
| 314 | char buf[50]; |
| 315 | struct ieee80211_key *key; |
| 316 | |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 317 | if (!sdata->debugfs.dir) |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 318 | return; |
| 319 | |
| 320 | /* this is running under the key lock */ |
| 321 | |
| 322 | key = sdata->default_mgmt_key; |
| 323 | if (key) { |
| 324 | sprintf(buf, "../keys/%d", key->debugfs.cnt); |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 325 | sdata->debugfs.default_mgmt_key = |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 326 | debugfs_create_symlink("default_mgmt_key", |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 327 | sdata->debugfs.dir, buf); |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 328 | } else |
| 329 | ieee80211_debugfs_key_remove_mgmt_default(sdata); |
| 330 | } |
| 331 | |
| 332 | void ieee80211_debugfs_key_remove_mgmt_default(struct ieee80211_sub_if_data *sdata) |
| 333 | { |
| 334 | if (!sdata) |
| 335 | return; |
| 336 | |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 337 | debugfs_remove(sdata->debugfs.default_mgmt_key); |
| 338 | sdata->debugfs.default_mgmt_key = NULL; |
Jouni Malinen | 3cfcf6a | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 339 | } |
| 340 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 341 | void ieee80211_debugfs_key_sta_del(struct ieee80211_key *key, |
| 342 | struct sta_info *sta) |
| 343 | { |
| 344 | debugfs_remove(key->debugfs.stalink); |
| 345 | key->debugfs.stalink = NULL; |
| 346 | } |