aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/key.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2010-12-09 13:49:02 -0500
committerJohn W. Linville <linville@tuxdriver.com>2010-12-13 15:23:29 -0500
commitf7e0104c1a4e77cc4f23d5969b0677bdc4f62c63 (patch)
tree6d1622ec2f6152b611867df1b7a0269471655b53 /net/mac80211/key.c
parentdbd2fd656f2060abfd3a16257f8b51ec60f6d2ed (diff)
mac80211: support separate default keys
Add support for split default keys (unicast and multicast) in mac80211. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/key.c')
-rw-r--r--net/mac80211/key.c45
1 files changed, 26 insertions, 19 deletions
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index 72df1ca7299b..84cf9196820f 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -178,7 +178,7 @@ void ieee80211_key_removed(struct ieee80211_key_conf *key_conf)
178EXPORT_SYMBOL_GPL(ieee80211_key_removed); 178EXPORT_SYMBOL_GPL(ieee80211_key_removed);
179 179
180static void __ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, 180static void __ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata,
181 int idx) 181 int idx, bool uni, bool multi)
182{ 182{
183 struct ieee80211_key *key = NULL; 183 struct ieee80211_key *key = NULL;
184 184
@@ -187,18 +187,19 @@ static void __ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata,
187 if (idx >= 0 && idx < NUM_DEFAULT_KEYS) 187 if (idx >= 0 && idx < NUM_DEFAULT_KEYS)
188 key = sdata->keys[idx]; 188 key = sdata->keys[idx];
189 189
190 rcu_assign_pointer(sdata->default_key, key); 190 if (uni)
191 rcu_assign_pointer(sdata->default_unicast_key, key);
192 if (multi)
193 rcu_assign_pointer(sdata->default_multicast_key, key);
191 194
192 if (key) { 195 ieee80211_debugfs_key_update_default(sdata);
193 ieee80211_debugfs_key_remove_default(key->sdata);
194 ieee80211_debugfs_key_add_default(key->sdata);
195 }
196} 196}
197 197
198void ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, int idx) 198void ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, int idx,
199 bool uni, bool multi)
199{ 200{
200 mutex_lock(&sdata->local->key_mtx); 201 mutex_lock(&sdata->local->key_mtx);
201 __ieee80211_set_default_key(sdata, idx); 202 __ieee80211_set_default_key(sdata, idx, uni, multi);
202 mutex_unlock(&sdata->local->key_mtx); 203 mutex_unlock(&sdata->local->key_mtx);
203} 204}
204 205
@@ -215,10 +216,7 @@ __ieee80211_set_default_mgmt_key(struct ieee80211_sub_if_data *sdata, int idx)
215 216
216 rcu_assign_pointer(sdata->default_mgmt_key, key); 217 rcu_assign_pointer(sdata->default_mgmt_key, key);
217 218
218 if (key) { 219 ieee80211_debugfs_key_update_default(sdata);
219 ieee80211_debugfs_key_remove_mgmt_default(key->sdata);
220 ieee80211_debugfs_key_add_mgmt_default(key->sdata);
221 }
222} 220}
223 221
224void ieee80211_set_default_mgmt_key(struct ieee80211_sub_if_data *sdata, 222void ieee80211_set_default_mgmt_key(struct ieee80211_sub_if_data *sdata,
@@ -236,7 +234,8 @@ static void __ieee80211_key_replace(struct ieee80211_sub_if_data *sdata,
236 struct ieee80211_key *old, 234 struct ieee80211_key *old,
237 struct ieee80211_key *new) 235 struct ieee80211_key *new)
238{ 236{
239 int idx, defkey, defmgmtkey; 237 int idx;
238 bool defunikey, defmultikey, defmgmtkey;
240 239
241 if (new) 240 if (new)
242 list_add(&new->list, &sdata->key_list); 241 list_add(&new->list, &sdata->key_list);
@@ -257,17 +256,24 @@ static void __ieee80211_key_replace(struct ieee80211_sub_if_data *sdata,
257 else 256 else
258 idx = new->conf.keyidx; 257 idx = new->conf.keyidx;
259 258
260 defkey = old && sdata->default_key == old; 259 defunikey = old && sdata->default_unicast_key == old;
260 defmultikey = old && sdata->default_multicast_key == old;
261 defmgmtkey = old && sdata->default_mgmt_key == old; 261 defmgmtkey = old && sdata->default_mgmt_key == old;
262 262
263 if (defkey && !new) 263 if (defunikey && !new)
264 __ieee80211_set_default_key(sdata, -1); 264 __ieee80211_set_default_key(sdata, -1, true, false);
265 if (defmultikey && !new)
266 __ieee80211_set_default_key(sdata, -1, false, true);
265 if (defmgmtkey && !new) 267 if (defmgmtkey && !new)
266 __ieee80211_set_default_mgmt_key(sdata, -1); 268 __ieee80211_set_default_mgmt_key(sdata, -1);
267 269
268 rcu_assign_pointer(sdata->keys[idx], new); 270 rcu_assign_pointer(sdata->keys[idx], new);
269 if (defkey && new) 271 if (defunikey && new)
270 __ieee80211_set_default_key(sdata, new->conf.keyidx); 272 __ieee80211_set_default_key(sdata, new->conf.keyidx,
273 true, false);
274 if (defmultikey && new)
275 __ieee80211_set_default_key(sdata, new->conf.keyidx,
276 false, true);
271 if (defmgmtkey && new) 277 if (defmgmtkey && new)
272 __ieee80211_set_default_mgmt_key(sdata, 278 __ieee80211_set_default_mgmt_key(sdata,
273 new->conf.keyidx); 279 new->conf.keyidx);
@@ -509,11 +515,12 @@ void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata)
509 515
510 mutex_lock(&sdata->local->key_mtx); 516 mutex_lock(&sdata->local->key_mtx);
511 517
512 ieee80211_debugfs_key_remove_default(sdata);
513 ieee80211_debugfs_key_remove_mgmt_default(sdata); 518 ieee80211_debugfs_key_remove_mgmt_default(sdata);
514 519
515 list_for_each_entry_safe(key, tmp, &sdata->key_list, list) 520 list_for_each_entry_safe(key, tmp, &sdata->key_list, list)
516 __ieee80211_key_free(key); 521 __ieee80211_key_free(key);
517 522
523 ieee80211_debugfs_key_update_default(sdata);
524
518 mutex_unlock(&sdata->local->key_mtx); 525 mutex_unlock(&sdata->local->key_mtx);
519} 526}