aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/ieee80211_ioctl.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/ieee80211_ioctl.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/ieee80211_ioctl.c')
-rw-r--r--net/mac80211/ieee80211_ioctl.c79
1 files changed, 30 insertions, 49 deletions
diff --git a/net/mac80211/ieee80211_ioctl.c b/net/mac80211/ieee80211_ioctl.c
index 9964f057bcef..380670c7a0ca 100644
--- a/net/mac80211/ieee80211_ioctl.c
+++ b/net/mac80211/ieee80211_ioctl.c
@@ -31,29 +31,20 @@ static void ieee80211_set_hw_encryption(struct net_device *dev,
31 struct sta_info *sta, u8 addr[ETH_ALEN], 31 struct sta_info *sta, u8 addr[ETH_ALEN],
32 struct ieee80211_key *key) 32 struct ieee80211_key *key)
33{ 33{
34 struct ieee80211_key_conf *keyconf = NULL;
35 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 34 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
36 35
37 /* default to sw encryption; this will be cleared by low-level 36 /* default to sw encryption; this will be cleared by low-level
38 * driver if the hw supports requested encryption */ 37 * driver if the hw supports requested encryption */
39 if (key) 38 if (key)
40 key->force_sw_encrypt = 1; 39 key->conf.flags |= IEEE80211_KEY_FORCE_SW_ENCRYPT;
41 40
42 if (key && local->ops->set_key && 41 if (key && local->ops->set_key) {
43 (keyconf = ieee80211_key_data2conf(local, key))) {
44 if (local->ops->set_key(local_to_hw(local), SET_KEY, addr, 42 if (local->ops->set_key(local_to_hw(local), SET_KEY, addr,
45 keyconf, sta ? sta->aid : 0)) { 43 &key->conf, local->default_wep_only)) {
46 key->force_sw_encrypt = 1; 44 key->conf.flags |= IEEE80211_KEY_FORCE_SW_ENCRYPT;
47 key->hw_key_idx = HW_KEY_IDX_INVALID; 45 key->conf.hw_key_idx = HW_KEY_IDX_INVALID;
48 } else {
49 key->force_sw_encrypt =
50 !!(keyconf->flags & IEEE80211_KEY_FORCE_SW_ENCRYPT);
51 key->hw_key_idx =
52 keyconf->hw_key_idx;
53
54 } 46 }
55 } 47 }
56 kfree(keyconf);
57} 48}
58 49
59 50
@@ -66,7 +57,6 @@ static int ieee80211_set_encryption(struct net_device *dev, u8 *sta_addr,
66 struct sta_info *sta; 57 struct sta_info *sta;
67 struct ieee80211_key *key, *old_key; 58 struct ieee80211_key *key, *old_key;
68 int try_hwaccel = 1; 59 int try_hwaccel = 1;
69 struct ieee80211_key_conf *keyconf;
70 struct ieee80211_sub_if_data *sdata; 60 struct ieee80211_sub_if_data *sdata;
71 61
72 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 62 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
@@ -154,18 +144,16 @@ static int ieee80211_set_encryption(struct net_device *dev, u8 *sta_addr,
154 } 144 }
155 145
156 if (alg == ALG_NONE) { 146 if (alg == ALG_NONE) {
157 keyconf = NULL;
158 if (try_hwaccel && key && 147 if (try_hwaccel && key &&
159 key->hw_key_idx != HW_KEY_IDX_INVALID && 148 key->conf.hw_key_idx != HW_KEY_IDX_INVALID &&
160 local->ops->set_key && 149 local->ops->set_key &&
161 (keyconf = ieee80211_key_data2conf(local, key)) != NULL &&
162 local->ops->set_key(local_to_hw(local), DISABLE_KEY, 150 local->ops->set_key(local_to_hw(local), DISABLE_KEY,
163 sta_addr, keyconf, sta ? sta->aid : 0)) { 151 sta_addr, &key->conf,
152 local->default_wep_only)) {
164 printk(KERN_DEBUG "%s: set_encrypt - low-level disable" 153 printk(KERN_DEBUG "%s: set_encrypt - low-level disable"
165 " failed\n", dev->name); 154 " failed\n", dev->name);
166 ret = -EINVAL; 155 ret = -EINVAL;
167 } 156 }
168 kfree(keyconf);
169 157
170 if (set_tx_key || sdata->default_key == key) { 158 if (set_tx_key || sdata->default_key == key) {
171 ieee80211_debugfs_key_remove_default(sdata); 159 ieee80211_debugfs_key_remove_default(sdata);
@@ -189,22 +177,20 @@ static int ieee80211_set_encryption(struct net_device *dev, u8 *sta_addr,
189 177
190 /* default to sw encryption; low-level driver sets these if the 178 /* default to sw encryption; low-level driver sets these if the
191 * requested encryption is supported */ 179 * requested encryption is supported */
192 key->hw_key_idx = HW_KEY_IDX_INVALID; 180 key->conf.hw_key_idx = HW_KEY_IDX_INVALID;
193 key->force_sw_encrypt = 1; 181 key->conf.flags |= IEEE80211_KEY_FORCE_SW_ENCRYPT;
194 182
195 key->alg = alg; 183 key->conf.alg = alg;
196 key->keyidx = idx; 184 key->conf.keyidx = idx;
197 key->keylen = key_len; 185 key->conf.keylen = key_len;
198 memcpy(key->key, _key, key_len); 186 memcpy(key->conf.key, _key, key_len);
199 if (set_tx_key)
200 key->default_tx_key = 1;
201 187
202 if (alg == ALG_CCMP) { 188 if (alg == ALG_CCMP) {
203 /* Initialize AES key state here as an optimization 189 /* Initialize AES key state here as an optimization
204 * so that it does not need to be initialized for every 190 * so that it does not need to be initialized for every
205 * packet. */ 191 * packet. */
206 key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt( 192 key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt(
207 key->key); 193 key->conf.key);
208 if (!key->u.ccmp.tfm) { 194 if (!key->u.ccmp.tfm) {
209 ret = -ENOMEM; 195 ret = -ENOMEM;
210 goto err_free; 196 goto err_free;
@@ -941,43 +927,38 @@ static int ieee80211_ioctl_giwretry(struct net_device *dev,
941static void ieee80211_key_enable_hwaccel(struct ieee80211_local *local, 927static void ieee80211_key_enable_hwaccel(struct ieee80211_local *local,
942 struct ieee80211_key *key) 928 struct ieee80211_key *key)
943{ 929{
944 struct ieee80211_key_conf *keyconf;
945 u8 addr[ETH_ALEN]; 930 u8 addr[ETH_ALEN];
946 931
947 if (!key || key->alg != ALG_WEP || !key->force_sw_encrypt || 932 if (!key || key->conf.alg != ALG_WEP ||
933 !(key->conf.flags & IEEE80211_KEY_FORCE_SW_ENCRYPT) ||
948 (local->hw.flags & IEEE80211_HW_DEVICE_HIDES_WEP)) 934 (local->hw.flags & IEEE80211_HW_DEVICE_HIDES_WEP))
949 return; 935 return;
950 936
951 memset(addr, 0xff, ETH_ALEN); 937 memset(addr, 0xff, ETH_ALEN);
952 keyconf = ieee80211_key_data2conf(local, key); 938
953 if (keyconf && local->ops->set_key && 939 if (local->ops->set_key)
954 local->ops->set_key(local_to_hw(local), 940 local->ops->set_key(local_to_hw(local),
955 SET_KEY, addr, keyconf, 0) == 0) { 941 SET_KEY, addr, &key->conf,
956 key->force_sw_encrypt = 942 local->default_wep_only);
957 !!(keyconf->flags & IEEE80211_KEY_FORCE_SW_ENCRYPT);
958 key->hw_key_idx = keyconf->hw_key_idx;
959 }
960 kfree(keyconf);
961} 943}
962 944
963 945
964static void ieee80211_key_disable_hwaccel(struct ieee80211_local *local, 946static void ieee80211_key_disable_hwaccel(struct ieee80211_local *local,
965 struct ieee80211_key *key) 947 struct ieee80211_key *key)
966{ 948{
967 struct ieee80211_key_conf *keyconf;
968 u8 addr[ETH_ALEN]; 949 u8 addr[ETH_ALEN];
969 950
970 if (!key || key->alg != ALG_WEP || key->force_sw_encrypt || 951 if (!key || key->conf.alg != ALG_WEP ||
952 (key->conf.flags & IEEE80211_KEY_FORCE_SW_ENCRYPT) ||
971 (local->hw.flags & IEEE80211_HW_DEVICE_HIDES_WEP)) 953 (local->hw.flags & IEEE80211_HW_DEVICE_HIDES_WEP))
972 return; 954 return;
973 955
974 memset(addr, 0xff, ETH_ALEN); 956 memset(addr, 0xff, ETH_ALEN);
975 keyconf = ieee80211_key_data2conf(local, key); 957 if (local->ops->set_key)
976 if (keyconf && local->ops->set_key)
977 local->ops->set_key(local_to_hw(local), DISABLE_KEY, 958 local->ops->set_key(local_to_hw(local), DISABLE_KEY,
978 addr, keyconf, 0); 959 addr, &key->conf,
979 kfree(keyconf); 960 local->default_wep_only);
980 key->force_sw_encrypt = 1; 961 key->conf.flags |= IEEE80211_KEY_FORCE_SW_ENCRYPT;
981} 962}
982 963
983 964
@@ -1341,9 +1322,9 @@ static int ieee80211_ioctl_giwencode(struct net_device *dev,
1341 return 0; 1322 return 0;
1342 } 1323 }
1343 1324
1344 memcpy(key, sdata->keys[idx]->key, 1325 memcpy(key, sdata->keys[idx]->conf.key,
1345 min((int)erq->length, sdata->keys[idx]->keylen)); 1326 min((int)erq->length, sdata->keys[idx]->conf.keylen));
1346 erq->length = sdata->keys[idx]->keylen; 1327 erq->length = sdata->keys[idx]->conf.keylen;
1347 erq->flags |= IW_ENCODE_ENABLED; 1328 erq->flags |= IW_ENCODE_ENABLED;
1348 1329
1349 return 0; 1330 return 0;