]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/mac80211/debugfs_key.c
Merge branch 'core/rcu' into core/rcu-for-linus
[linux-2.6-omap-h63xx.git] / net / mac80211 / debugfs_key.c
index c881524c87251ca39a02717663538f381248a836..19efc3a6a9327cfd343ab5e62de2a993ec6821bf 100644 (file)
@@ -10,7 +10,7 @@
 
 #include <linux/kobject.h>
 #include "ieee80211_i.h"
-#include "ieee80211_key.h"
+#include "key.h"
 #include "debugfs.h"
 #include "debugfs_key.h"
 
@@ -184,23 +184,36 @@ KEY_OPS(key);
        key->debugfs.name = debugfs_create_file(#name, 0400,\
                                key->debugfs.dir, key, &key_##name##_ops);
 
-void ieee80211_debugfs_key_add(struct ieee80211_local *local,
-                              struct ieee80211_key *key)
-{
+void ieee80211_debugfs_key_add(struct ieee80211_key *key)
+  {
        static int keycount;
-       char buf[20];
+       char buf[50];
+       DECLARE_MAC_BUF(mac);
+       struct sta_info *sta;
 
-       if (!local->debugfs.keys)
+       if (!key->local->debugfs.keys)
                return;
 
        sprintf(buf, "%d", keycount);
+       key->debugfs.cnt = keycount;
        keycount++;
        key->debugfs.dir = debugfs_create_dir(buf,
-                                       local->debugfs.keys);
+                                       key->local->debugfs.keys);
 
        if (!key->debugfs.dir)
                return;
 
+       rcu_read_lock();
+       sta = rcu_dereference(key->sta);
+       if (sta)
+               sprintf(buf, "../../stations/%s", print_mac(mac, sta->addr));
+       rcu_read_unlock();
+
+       /* using sta as a boolean is fine outside RCU lock */
+       if (sta)
+               key->debugfs.stalink =
+                       debugfs_create_symlink("station", key->debugfs.dir, buf);
+
        DEBUGFS_ADD(keylen);
        DEBUGFS_ADD(flags);
        DEBUGFS_ADD(keyidx);
@@ -242,14 +255,23 @@ void ieee80211_debugfs_key_remove(struct ieee80211_key *key)
 void ieee80211_debugfs_key_add_default(struct ieee80211_sub_if_data *sdata)
 {
        char buf[50];
+       struct ieee80211_key *key;
 
        if (!sdata->debugfsdir)
                return;
 
-       sprintf(buf, "../keys/%d", sdata->default_key->conf.keyidx);
-       sdata->debugfs.default_key =
-               debugfs_create_symlink("default_key", sdata->debugfsdir, buf);
+       /* this is running under the key lock */
+
+       key = sdata->default_key;
+       if (key) {
+               sprintf(buf, "../keys/%d", key->debugfs.cnt);
+               sdata->debugfs.default_key =
+                       debugfs_create_symlink("default_key",
+                                              sdata->debugfsdir, buf);
+       } else
+               ieee80211_debugfs_key_remove_default(sdata);
 }
+
 void ieee80211_debugfs_key_remove_default(struct ieee80211_sub_if_data *sdata)
 {
        if (!sdata)
@@ -258,19 +280,6 @@ void ieee80211_debugfs_key_remove_default(struct ieee80211_sub_if_data *sdata)
        debugfs_remove(sdata->debugfs.default_key);
        sdata->debugfs.default_key = NULL;
 }
-void ieee80211_debugfs_key_sta_link(struct ieee80211_key *key,
-                                   struct sta_info *sta)
-{
-       char buf[50];
-       DECLARE_MAC_BUF(mac);
-
-       if (!key->debugfs.dir)
-               return;
-
-       sprintf(buf, "../../stations/%s", print_mac(mac, sta->addr));
-       key->debugfs.stalink =
-               debugfs_create_symlink("station", key->debugfs.dir, buf);
-}
 
 void ieee80211_debugfs_key_sta_del(struct ieee80211_key *key,
                                   struct sta_info *sta)