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