move per-netdev and key stuff to debugfs
Johannes Berg
maintainerPATCH 1/1 move per-netdev and key stuff to debugfs
This patch moves the remaining sysfs stuff from mac80211 into debugfs.
---
It is *slightly* incomplete because it doesn't follow interface renames yet, the infrastructure is there, the patch to do it will be a few lines only.
--- net/mac80211/Makefile | 4 net/mac80211/debugfs.c | 2 net/mac80211/debugfs_key.c | 244 ++++++++++++++++++++++ net/mac80211/debugfs_key.h | 30 ++ net/mac80211/debugfs_netdev.c | 439 +++++++++++++++++++++++++++++++++++++++++ net/mac80211/debugfs_netdev.h | 30 ++ net/mac80211/ieee80211.c | 49 +--- net/mac80211/ieee80211_i.h | 65 +++++- net/mac80211/ieee80211_iface.c | 25 -- net/mac80211/ieee80211_ioctl.c | 31 +- net/mac80211/ieee80211_key.h | 21 + net/mac80211/ieee80211_sysfs.c | 344 -------------------------------- net/mac80211/ieee80211_sysfs.h | 10 net/mac80211/key_sysfs.c | 217 -------------------- net/mac80211/key_sysfs.h | 12 - net/mac80211/sta_info.c | 4 16 files changed, 872 insertions(+), 655 deletions(-)
net/mac80211/Makefile +1 -3
@@ -1,7 +1,7 @@ obj-$(CONFIG_MAC80211) += mac80211.o rc80211_simple.o mac80211-objs-$(CONFIG_MAC80211_LEDS) += ieee80211_led.o -mac80211-objs-$(CONFIG_DEBUG_FS) += debugfs.o debugfs_sta.o +mac80211-objs-$(CONFIG_DEBUG_FS) += debugfs.o debugfs_sta.o debugfs_netdev.o debugfs_key.o mac80211-objs := \ ieee80211.o \
@@ -13,13 +13,11 @@ mac80211-objs := \ ieee80211_sta.o \ ieee80211_iface.o \ ieee80211_rate.o \ - ieee80211_sysfs.o \ michael.o \ tkip.o \ aes_ccm.o \ wme.o \ ieee80211_cfg.o \ - key_sysfs.o \ $(mac80211-objs-y) ifeq ($(CONFIG_NET_SCHED),)
net/mac80211/debugfs_netdev.c new file +439 -0
439 lines not on this page · raw message
net/mac80211/debugfs_netdev.h new file +30 -0
@@ -0,0 +1,30 @@ +/* routines exported for sysfs handling */ + +#ifndef __IEEE80211_SYSFS_H +#define __IEEE80211_SYSFS_H + +#ifdef CONFIG_DEBUG_FS +void ieee80211_debugfs_add_netdev (struct ieee80211_sub_if_data *sdata); +void ieee80211_debugfs_remove_netdev (struct ieee80211_sub_if_data *sdata); +void ieee80211_debugfs_change_if_type (struct ieee80211_sub_if_data *sdata, +int oldtype); +void ieee80211_debugfs_netdev_init (void ); +void ieee80211_debugfs_netdev_exit (void ); +#else +static inline void ieee80211_debugfs_add_netdev ( +struct ieee80211_sub_if_data *sdata) +{} +static inline void ieee80211_debugfs_remove_netdev ( +struct ieee80211_sub_if_data *sdata) +{} +static inline void ieee80211_debugfs_change_if_type + struct ieee80211_sub_if_data *sdata, int oldtype) +{} +static inline void ieee80211_debugfs_netdev_init (void ) +{} + +static inline void ieee80211_debugfs_netdev_exit (void ) +{} +#endif + +#endif /* __IEEE80211_SYSFS_H */
net/mac80211/ieee80211.c +21 -28
107 lines not on this page · raw message
net/mac80211/ieee80211_i.h +62 -3
93 lines not on this page · raw message
net/mac80211/ieee80211_iface.c +9 -16
@@ -14,7 +14,7 @@#include <net/mac80211.h> #include "ieee80211_i.h" #include "sta_info.h" -#include "ieee80211_sysfs.h" +#include "debugfs_netdev.h" void ieee80211_if_sdata_init (struct ieee80211_sub_if_data *sdata) {
@@ -81,14 +81,8 @@ int ieee80211_if_add(struct net_device * ret =register_netdevice (ndev);if (ret) goto fail; - ret =ieee80211_sysfs_add_netdevice (ndev); -if (ret) { -/* ndev will be freed by ndev->destructor */ -unregister_netdevice (ndev); - *new_dev =NULL ; -return ret; - } +ieee80211_debugfs_add_netdev (sdata);list_add (&sdata->list, &local->sub_if_list);ieee80211_update_default_wep_only (local);
@@ -130,16 +124,14 @@ int ieee80211_if_add_mgmt(struct ieee802 ret =register_netdevice (ndev);if (ret) goto fail; - ret =ieee80211_sysfs_add_netdevice (ndev); -if (ret) - goto fail_sysfs; + +ieee80211_debugfs_add_netdev (nsdata); +if (local->open_count >0 )dev_open (ndev); local->apdev = ndev;return 0 ; -fail_sysfs: -unregister_netdevice (ndev); fail:free_netdev (ndev);return ret;
@@ -151,7 +143,7 @@ void ieee80211_if_del_mgmt(struct ieee80ASSERT_RTNL (); apdev = local->apdev; -ieee80211_sysfs_remove_netdevice (apdev); +ieee80211_debugfs_remove_netdev (IEEE80211_DEV_TO_SUB_IF (apdev)); local->apdev =NULL ;unregister_netdevice (apdev); }
@@ -160,6 +152,7 @@ void ieee80211_if_set_type(struct net_de {struct ieee80211_sub_if_data *sdata =IEEE80211_DEV_TO_SUB_IF (dev);struct ieee80211_local *local =wdev_priv (dev->ieee80211_ptr); +int oldtype = sdata->type; sdata->type = type;switch (type) {
@@ -205,7 +198,7 @@ void ieee80211_if_set_type(struct net_deprintk (KERN_WARNING "%s: %s: Unknown interface type 0x%x" , dev->name, __FUNCTION__, type); } -ieee80211_sysfs_change_if_type (dev); +ieee80211_debugfs_change_if_type (sdata, oldtype);ieee80211_update_default_wep_only (local); }
@@ -309,7 +302,7 @@ void __ieee80211_if_del(struct ieee80211struct net_device *dev = sdata->dev;list_del (&sdata->list); -ieee80211_sysfs_remove_netdevice (dev); +ieee80211_debugfs_remove_netdev (sdata);unregister_netdevice (dev);/* Except master interface, the net_device will be freed by * net_device->destructor (i. e. ieee80211_if_free). */
net/mac80211/ieee80211_key.h +19 -2
@@ -11,7 +11,7 @@#define IEEE80211_KEY_H #include <linux/types.h> -#include <linux/kobject.h> +#include <linux/kref.h> #include <linux/crypto.h> #include <net/mac80211.h>
@@ -42,7 +42,7 @@#define NUM_RX_DATA_QUEUES 17struct ieee80211_key { -struct kobject kobj; +struct kref kref;int hw_key_idx;/* filled and used by low-level driver */ ieee80211_key_alg alg;
@@ -83,6 +83,23 @@ struct ieee80211_key {* (used only for broadcast keys). */ s8 keyidx;/* WEP key index */ +#ifdef CONFIG_DEBUG_FS +struct { +struct dentry *stalink; +struct dentry *dir; +struct dentry *keylen; +struct dentry *force_sw_encrypt; +struct dentry *keyidx; +struct dentry *hw_key_idx; +struct dentry *tx_rx_count; +struct dentry *algorithm; +struct dentry *tx_spec; +struct dentry *rx_spec; +struct dentry *replays; +struct dentry *key; + } debugfs; +#endif +u8 key[0 ]; };
net/mac80211/ieee80211_sysfs.c deleted +0 -344
344 lines not on this page · raw message
net/mac80211/ieee80211_sysfs.h deleted +0 -10
@@ -1,10 +0,0 @@ -/* routines exported for sysfs handling */ - -#ifndef __IEEE80211_SYSFS_H -#define __IEEE80211_SYSFS_H - -int ieee80211_sysfs_add_netdevice (struct net_device *dev); -void ieee80211_sysfs_remove_netdevice (struct net_device *dev); -int ieee80211_sysfs_change_if_type (struct net_device *dev); - -#endif /* __IEEE80211_SYSFS_H */
net/mac80211/debugfs_key.c new file +244 -0
244 lines not on this page · raw message
net/mac80211/debugfs_key.h new file +30 -0
@@ -0,0 +1,30 @@ +#ifndef __MAC80211_DEBUGFS_KEY_H +#define __MAC80211_DEBUGFS_KEY_H + +#ifdef CONFIG_DEBUG_FS +void ieee80211_debugfs_key_add (struct ieee80211_local *local, +struct ieee80211_key *key); +void ieee80211_debugfs_key_remove (struct ieee80211_key *key); +void ieee80211_debugfs_key_add_default (struct ieee80211_sub_if_data *sdata); +void ieee80211_debugfs_key_remove_default (struct ieee80211_sub_if_data *sdata); +void ieee80211_debugfs_key_sta_link (struct ieee80211_key *key, +struct sta_info *sta); +#else +static inline void ieee80211_debugfs_key_add (struct ieee80211_local *local, +struct ieee80211_key *key) +{} +static inline void ieee80211_debugfs_key_remove (struct ieee80211_key *key) +{} +static inline void ieee80211_debugfs_key_add_default ( +struct ieee80211_sub_if_data *sdata) +{} +static inline void ieee80211_debugfs_key_remove_default ( +struct ieee80211_sub_if_data *sdata) +{} +static inline void ieee80211_debugfs_key_sta_link ( +struct ieee80211_key *key,struct sta_info *sta) +{ +} +#endif + +#endif /* __MAC80211_DEBUGFS_KEY_H */
net/mac80211/ieee80211_ioctl.c +13 -18
@@ -25,7 +25,7 @@#include "ieee80211_rate.h" #include "wpa.h" #include "aes_ccm.h" -#include "key_sysfs.h" +#include "debugfs_key.h" static int ieee80211_regdom =0x10 ;/* FCC */ module_param (ieee80211_regdom, int,0444 );
@@ -634,10 +634,10 @@ static int ieee80211_set_encryption(strukfree (keyconf);if (set_tx_key || sdata->default_key == key) { -ieee80211_key_sysfs_remove_default (sdata); +ieee80211_debugfs_key_remove_default (sdata); sdata->default_key =NULL ; } -ieee80211_key_sysfs_remove (key); +ieee80211_debugfs_key_remove (key);if (sta) sta->key =NULL ;else
@@ -678,18 +678,18 @@ static int ieee80211_set_encryption(stru }if (set_tx_key || sdata->default_key == old_key) { -ieee80211_key_sysfs_remove_default (sdata); +ieee80211_debugfs_key_remove_default (sdata); sdata->default_key =NULL ; } -ieee80211_key_sysfs_remove (old_key); +ieee80211_debugfs_key_remove (old_key);if (sta) sta->key = key;else sdata->keys[idx] = key;ieee80211_key_free (old_key); - ret =ieee80211_key_sysfs_add (key); -if (ret) - goto err_null; +ieee80211_debugfs_key_add (local, key); +if (sta) +ieee80211_debugfs_key_sta_link (key, sta);if (try_hwaccel && (alg ==ALG_WEP || alg ==ALG_TKIP || alg ==ALG_CCMP )) {
@@ -702,9 +702,9 @@ static int ieee80211_set_encryption(struif (set_tx_key || (!sta && !sdata->default_key && key)) { sdata->default_key = key; -if (key &&ieee80211_key_sysfs_add_default (sdata)) -printk (KERN_WARNING "%s: cannot create symlink to " -"default key\n" , dev->name); +if (key) +ieee80211_debugfs_key_add_default (sdata); +if (local->ops->set_key_idx && local->ops->set_key_idx (local_to_hw (local), idx)) printk(KERN_DEBUG "%s: failed to set TX key idx for "
@@ -716,11 +716,6 @@ static int ieee80211_set_encryption(strureturn 0 ; -err_null: -if (sta) - sta->key =NULL ; -else - sdata->keys[idx] =NULL ; err_free:ieee80211_key_free (key); err_out:
@@ -2949,10 +2944,10 @@ static int ieee80211_ioctl_siwencode(strelse if (erq->length ==0 ) {/* No key data - just set the default TX key index */ if (sdata->default_key != sdata->keys[idx]) { -ieee80211_key_sysfs_remove_default (sdata); +ieee80211_debugfs_key_remove_default (sdata); sdata->default_key = sdata->keys[idx];if (sdata->default_key) -ieee80211_key_sysfs_add_default (sdata); +ieee80211_debugfs_key_add_default (sdata); }return 0 ; }
net/mac80211/key_sysfs.c deleted +0 -217
217 lines not on this page · raw message
net/mac80211/key_sysfs.h deleted +0 -12
@@ -1,12 +0,0 @@ -#ifndef __MAC80211_KEY_SYSFS_H -#define __MAC80211_KEY_SYSFS_H - -int ieee80211_key_kset_sysfs_register (struct ieee80211_sub_if_data *sdata); -void ieee80211_key_kset_sysfs_unregister (struct ieee80211_sub_if_data *sdata); -void ieee80211_key_sysfs_set_kset (struct ieee80211_key *key,struct kset *kset); -int ieee80211_key_sysfs_add (struct ieee80211_key *key); -void ieee80211_key_sysfs_remove (struct ieee80211_key *key); -int ieee80211_key_sysfs_add_default (struct ieee80211_sub_if_data *sdata); -void ieee80211_key_sysfs_remove_default (struct ieee80211_sub_if_data *sdata); - -#endif /* __MAC80211_KEY_SYSFS_H */
net/mac80211/sta_info.c +2 -2
@@ -18,7 +18,7 @@#include "ieee80211_i.h" #include "ieee80211_rate.h" #include "sta_info.h" -#include "key_sysfs.h" +#include "debugfs_key.h" #include "debugfs_sta.h" /* Caller must hold local->sta_lock */
@@ -197,7 +197,7 @@ static void finish_sta_info_free(struct#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ if (sta->key) { -ieee80211_key_sysfs_remove (sta->key); +ieee80211_debugfs_key_remove (sta->key);ieee80211_key_free (sta->key); sta->key =NULL ; }
net/mac80211/debugfs.c +2 -0
@@ -301,6 +301,7 @@ void debugfs_hw_add(struct ieee80211_locreturn ; local->debugfs.stations =debugfs_create_dir ("stations" , phyd); + local->debugfs.keys =debugfs_create_dir ("keys" , phyd);DEBUGFS_ADD (channel);DEBUGFS_ADD (frequency);
@@ -426,4 +427,5 @@ void debugfs_hw_del(struct ieee80211_locdebugfs_remove (local->debugfs.statistics);debugfs_remove (local->debugfs.stations); +debugfs_remove (local->debugfs.keys); }
Johannes Berg
maintainerFound a small bug and did some cleanups, I'll post a link to the series to not spam you with these huge patches again.
johannes
!DSPAM:45e891fa22798165083049!
Johannes Berg
maintainerQuoted 2 lines · Johannes Berg
Found a small bug and did some cleanups, I'll post a link to the series to not spam you with these huge patches again.
Here we go:
http://johannes.sipsolutions.net/patches/mac80211-debugfs/
It relies on
[PATCH] add privid field to wiphy
and applies after bluetape's patches.
I've tested association, a key, the default_key symlink works, and some more. I couldn't really test per-sta keys since I don't run an AP but I'm pretty sure they should be fine.
johannes