aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/debugfs_key.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2007-08-28 17:01:54 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:48:51 -0400
commit8f20fc24986a083228823d9b68adca20714b254e (patch)
treeb5d7638b913649c7a181d6703ccd72e35ca06de9 /net/mac80211/debugfs_key.c
parent13262ffd4902805acad2618c12b41fcaa6c50791 (diff)
[MAC80211]: embed key conf in key, fix driver interface
This patch embeds the struct ieee80211_key_conf into struct ieee80211_key and thus avoids allocations and having data present twice. This required some more changes: 1) The removal of the IEEE80211_KEY_DEFAULT_TX_KEY key flag. This flag isn't used by drivers nor should it be since we have a set_key_idx() callback. Maybe that callback needs to be extended to include the key conf, but only a driver that requires it will tell. 2) The removal of the IEEE80211_KEY_DEFAULT_WEP_ONLY key flag. This flag is global, so it shouldn't be passed in the key conf structure. Pass it to the function instead. Also, this patch removes the AID parameter to the set_key() callback because it is currently unused and the hardware currently cannot know about the AID anyway. I suspect this was used with some hardware that actually selected the AID itself, but that functionality was removed. Additionally, I've removed the ALG_NULL key algorithm since we have ALG_NONE. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Acked-by: Michael Wu <flamingice@sourmilk.net> Signed-off-by: John W. Linville <linville@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/mac80211/debugfs_key.c')
-rw-r--r--net/mac80211/debugfs_key.c49
1 files changed, 32 insertions, 17 deletions
diff --git a/net/mac80211/debugfs_key.c b/net/mac80211/debugfs_key.c
index 077f907271cf..246938c32d4d 100644
--- a/net/mac80211/debugfs_key.c
+++ b/net/mac80211/debugfs_key.c
@@ -14,17 +14,17 @@
14#include "debugfs.h" 14#include "debugfs.h"
15#include "debugfs_key.h" 15#include "debugfs_key.h"
16 16
17#define KEY_READ(name, buflen, format_string) \ 17#define KEY_READ(name, prop, buflen, format_string) \
18static ssize_t key_##name##_read(struct file *file, \ 18static ssize_t key_##name##_read(struct file *file, \
19 char __user *userbuf, \ 19 char __user *userbuf, \
20 size_t count, loff_t *ppos) \ 20 size_t count, loff_t *ppos) \
21{ \ 21{ \
22 char buf[buflen]; \ 22 char buf[buflen]; \
23 struct ieee80211_key *key = file->private_data; \ 23 struct ieee80211_key *key = file->private_data; \
24 int res = scnprintf(buf, buflen, format_string, key->name); \ 24 int res = scnprintf(buf, buflen, format_string, key->prop); \
25 return simple_read_from_buffer(userbuf, count, ppos, buf, res); \ 25 return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
26} 26}
27#define KEY_READ_D(name) KEY_READ(name, 20, "%d\n") 27#define KEY_READ_D(name) KEY_READ(name, name, 20, "%d\n")
28 28
29#define KEY_OPS(name) \ 29#define KEY_OPS(name) \
30static const struct file_operations key_ ##name## _ops = { \ 30static const struct file_operations key_ ##name## _ops = { \
@@ -36,10 +36,25 @@ static const struct file_operations key_ ##name## _ops = { \
36 KEY_READ_##format(name) \ 36 KEY_READ_##format(name) \
37 KEY_OPS(name) 37 KEY_OPS(name)
38 38
39KEY_FILE(keylen, D); 39#define KEY_CONF_READ(name, buflen, format_string) \
40KEY_FILE(force_sw_encrypt, D); 40 KEY_READ(conf_##name, conf.name, buflen, format_string)
41KEY_FILE(keyidx, D); 41#define KEY_CONF_READ_D(name) KEY_CONF_READ(name, 20, "%d\n")
42KEY_FILE(hw_key_idx, D); 42#define KEY_CONF_READ_X(name) KEY_CONF_READ(name, 20, "0x%x\n")
43
44#define KEY_CONF_OPS(name) \
45static const struct file_operations key_ ##name## _ops = { \
46 .read = key_conf_##name##_read, \
47 .open = mac80211_open_file_generic, \
48}
49
50#define KEY_CONF_FILE(name, format) \
51 KEY_CONF_READ_##format(name) \
52 KEY_CONF_OPS(name)
53
54KEY_CONF_FILE(keylen, D);
55KEY_CONF_FILE(keyidx, D);
56KEY_CONF_FILE(hw_key_idx, D);
57KEY_CONF_FILE(flags, X);
43KEY_FILE(tx_rx_count, D); 58KEY_FILE(tx_rx_count, D);
44 59
45static ssize_t key_algorithm_read(struct file *file, 60static ssize_t key_algorithm_read(struct file *file,
@@ -49,7 +64,7 @@ static ssize_t key_algorithm_read(struct file *file,
49 char *alg; 64 char *alg;
50 struct ieee80211_key *key = file->private_data; 65 struct ieee80211_key *key = file->private_data;
51 66
52 switch (key->alg) { 67 switch (key->conf.alg) {
53 case ALG_WEP: 68 case ALG_WEP:
54 alg = "WEP\n"; 69 alg = "WEP\n";
55 break; 70 break;
@@ -74,7 +89,7 @@ static ssize_t key_tx_spec_read(struct file *file, char __user *userbuf,
74 int len; 89 int len;
75 struct ieee80211_key *key = file->private_data; 90 struct ieee80211_key *key = file->private_data;
76 91
77 switch (key->alg) { 92 switch (key->conf.alg) {
78 case ALG_WEP: 93 case ALG_WEP:
79 len = scnprintf(buf, sizeof(buf), "\n"); 94 len = scnprintf(buf, sizeof(buf), "\n");
80 break; 95 break;
@@ -103,7 +118,7 @@ static ssize_t key_rx_spec_read(struct file *file, char __user *userbuf,
103 int i, len; 118 int i, len;
104 const u8 *rpn; 119 const u8 *rpn;
105 120
106 switch (key->alg) { 121 switch (key->conf.alg) {
107 case ALG_WEP: 122 case ALG_WEP:
108 len = scnprintf(buf, sizeof(buf), "\n"); 123 len = scnprintf(buf, sizeof(buf), "\n");
109 break; 124 break;
@@ -139,7 +154,7 @@ static ssize_t key_replays_read(struct file *file, char __user *userbuf,
139 char buf[20]; 154 char buf[20];
140 int len; 155 int len;
141 156
142 if (key->alg != ALG_CCMP) 157 if (key->conf.alg != ALG_CCMP)
143 return 0; 158 return 0;
144 len = scnprintf(buf, sizeof(buf), "%u\n", key->u.ccmp.replays); 159 len = scnprintf(buf, sizeof(buf), "%u\n", key->u.ccmp.replays);
145 return simple_read_from_buffer(userbuf, count, ppos, buf, len); 160 return simple_read_from_buffer(userbuf, count, ppos, buf, len);
@@ -150,12 +165,12 @@ static ssize_t key_key_read(struct file *file, char __user *userbuf,
150 size_t count, loff_t *ppos) 165 size_t count, loff_t *ppos)
151{ 166{
152 struct ieee80211_key *key = file->private_data; 167 struct ieee80211_key *key = file->private_data;
153 int i, res, bufsize = 2*key->keylen+2; 168 int i, res, bufsize = 2 * key->conf.keylen + 2;
154 char *buf = kmalloc(bufsize, GFP_KERNEL); 169 char *buf = kmalloc(bufsize, GFP_KERNEL);
155 char *p = buf; 170 char *p = buf;
156 171
157 for (i = 0; i < key->keylen; i++) 172 for (i = 0; i < key->conf.keylen; i++)
158 p += scnprintf(p, bufsize+buf-p, "%02x", key->key[i]); 173 p += scnprintf(p, bufsize + buf - p, "%02x", key->conf.key[i]);
159 p += scnprintf(p, bufsize+buf-p, "\n"); 174 p += scnprintf(p, bufsize+buf-p, "\n");
160 res = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf); 175 res = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
161 kfree(buf); 176 kfree(buf);
@@ -185,7 +200,7 @@ void ieee80211_debugfs_key_add(struct ieee80211_local *local,
185 return; 200 return;
186 201
187 DEBUGFS_ADD(keylen); 202 DEBUGFS_ADD(keylen);
188 DEBUGFS_ADD(force_sw_encrypt); 203 DEBUGFS_ADD(flags);
189 DEBUGFS_ADD(keyidx); 204 DEBUGFS_ADD(keyidx);
190 DEBUGFS_ADD(hw_key_idx); 205 DEBUGFS_ADD(hw_key_idx);
191 DEBUGFS_ADD(tx_rx_count); 206 DEBUGFS_ADD(tx_rx_count);
@@ -205,7 +220,7 @@ void ieee80211_debugfs_key_remove(struct ieee80211_key *key)
205 return; 220 return;
206 221
207 DEBUGFS_DEL(keylen); 222 DEBUGFS_DEL(keylen);
208 DEBUGFS_DEL(force_sw_encrypt); 223 DEBUGFS_DEL(flags);
209 DEBUGFS_DEL(keyidx); 224 DEBUGFS_DEL(keyidx);
210 DEBUGFS_DEL(hw_key_idx); 225 DEBUGFS_DEL(hw_key_idx);
211 DEBUGFS_DEL(tx_rx_count); 226 DEBUGFS_DEL(tx_rx_count);
@@ -227,7 +242,7 @@ void ieee80211_debugfs_key_add_default(struct ieee80211_sub_if_data *sdata)
227 if (!sdata->debugfsdir) 242 if (!sdata->debugfsdir)
228 return; 243 return;
229 244
230 sprintf(buf, "../keys/%d", sdata->default_key->keyidx); 245 sprintf(buf, "../keys/%d", sdata->default_key->conf.keyidx);
231 sdata->debugfs.default_key = 246 sdata->debugfs.default_key =
232 debugfs_create_symlink("default_key", sdata->debugfsdir, buf); 247 debugfs_create_symlink("default_key", sdata->debugfsdir, buf);
233} 248}