mac80211: kill rtnl usage
Johannes Berg
maintainerRFC 1/1 mac80211: kill rtnl usage
This patch introduces a new mutex to lock the ieee80211_local struct and kills off all usage of the RTNL.
When you apply it you may occasionally find a big WARN_ON in your kernel log, that's intended and probably needs to be fixed.
The simplification of ieee80211_if_add comes with a slight userspace API change, userspace can no longer specify an empty name to get a default. Which is IMNSHO a good thing.
--- net/mac80211/debugfs.c | 21 +++---------- net/mac80211/ieee80211.c | 43 ++++++++++++--------------- net/mac80211/ieee80211_cfg.c | 46 +++++++++++------------------ net/mac80211/ieee80211_i.h | 11 +++++- net/mac80211/ieee80211_iface.c | 65 +++++++++++++---------------------------- net/mac80211/ieee80211_ioctl.c | 8 ++--- net/mac80211/ieee80211_sta.c | 8 +++++ 7 files changed, 86 insertions(+), 116 deletions(-)
net/mac80211/debugfs.c +6 -15
@@ -118,16 +118,6 @@ DEBUGFS_READONLY_FILE(rate_ctrl_alg, 100/* statistics stuff */ -static inline int rtnl_lock_local (struct ieee80211_local *local) -{ -rtnl_lock (); -if (unlikely (local->reg_state !=IEEE80211_DEV_REGISTERED )) { -rtnl_unlock (); -return -ENODEV ; - } -return 0 ; -} - #define DEBUGFS_STATS_FILE(name, buflen, fmt, value...) \ DEBUGFS_READONLY_FILE(stats_ ##name, buflen, fmt, ##value)
@@ -144,12 +134,13 @@ static ssize_t format_devstat_counter(stif (!local->ops->get_stats)return -EOPNOTSUPP ; - res =rtnl_lock_local (local); -if (res) -return res; +mutex_lock (&local->mtx); +if (likely (local->reg_state ==IEEE80211_DEV_REGISTERED )) { + res = local->ops->get_stats (local_to_hw (local), &stats); + }else + res = -ENODEV ; +mutex_unlock (&local->mtx); - res = local->ops->get_stats (local_to_hw (local), &stats); -rtnl_unlock ();if (!res) res =printvalue (&stats, buf,sizeof (buf));return simple_read_from_buffer (userbuf, count, ppos, buf, res);
net/mac80211/ieee80211.c +20 -23
131 lines not on this page · raw message
net/mac80211/ieee80211_cfg.c +18 -28
64 lines not on this page · raw message
net/mac80211/ieee80211_i.h +9 -2
@@ -20,6 +20,7 @@#include <linux/workqueue.h> #include <linux/types.h> #include <linux/spinlock.h> +#include <linux/mutex.h> #include <net/wireless.h> #include "ieee80211_key.h" #include "sta_info.h"
@@ -407,6 +408,9 @@ struct ieee80211_local {const struct ieee80211_ops *ops; +/* protects this structure */ +struct mutex mtx; +/* List of registered struct ieee80211_hw_mode */ struct list_head modes_list;
@@ -660,6 +664,10 @@ struct ieee80211_local {#endif }; +#define ASSERT_LOCAL_MTX (local) do { \ + WARN_ON(!mutex_is_locked(&local->mtx)); \ + } while (0) +static inline struct ieee80211_local *hw_to_local (struct ieee80211_hw *hw) {
@@ -734,7 +742,6 @@ void ieee80211_tx_set_iswep(struct ieee8int ieee80211_if_update_wds (struct net_device *dev,u8 *remote_addr);void ieee80211_if_setup (struct net_device *dev);void ieee80211_if_mgmt_setup (struct net_device *dev); -void ieee80211_if_shutdown (struct net_device *dev);int ieee80211_init_rate_ctrl_alg (struct ieee80211_local *local,const char *name);struct net_device_stats *ieee80211_dev_stats (struct net_device *dev);
@@ -806,7 +813,7 @@ int ieee80211_sta_disassociate(struct ne/* ieee80211_iface.c */ int ieee80211_if_add (struct net_device *dev,const char *name, -int format,struct net_device **new_dev); +struct net_device **new_dev);void ieee80211_if_set_type (struct net_device *dev,int type);void ieee80211_if_reinit (struct net_device *dev); void __ieee80211_if_del(struct ieee80211_local *local,
net/mac80211/ieee80211_iface.c +21 -44
168 lines not on this page · raw message
net/mac80211/ieee80211_sta.c +8 -0
@@ -2677,6 +2677,14 @@ static int ieee80211_sta_start_scan(strustruct ieee80211_local *local =wdev_priv (dev->ieee80211_ptr);struct ieee80211_sub_if_data *sdata; + +mutex_lock (&local->mtx); +if (unlikely (local->reg_state ==IEEE80211_DEV_UNREGISTERED )) { +mutex_unlock (&local->mtx); +return -ENODEV ; + } +mutex_unlock (&local->mtx); +if (ssid_len >IEEE80211_MAX_SSID_LEN )return -EINVAL ;
net/mac80211/ieee80211_ioctl.c +4 -4
@@ -1010,7 +1010,7 @@ static int ieee80211_ioctl_add_if(structif (left <sizeof (struct hostapd_if_wds ))return -EPROTO ; - res =ieee80211_if_add (dev, param->u.if_info.name,0 , &new_dev); + res =ieee80211_if_add (dev, param->u.if_info.name, &new_dev);if (res)return res;ieee80211_if_set_type (new_dev,IEEE80211_IF_TYPE_WDS );
@@ -1023,7 +1023,7 @@ static int ieee80211_ioctl_add_if(structif (left <sizeof (struct hostapd_if_vlan ))return -EPROTO ; - res =ieee80211_if_add (dev, param->u.if_info.name,0 , &new_dev); + res =ieee80211_if_add (dev, param->u.if_info.name, &new_dev);if (res)return res;ieee80211_if_set_type (new_dev,IEEE80211_IF_TYPE_VLAN );
@@ -1040,7 +1040,7 @@ static int ieee80211_ioctl_add_if(structif (left <sizeof (struct hostapd_if_bss ))return -EPROTO ; - res =ieee80211_if_add (dev, param->u.if_info.name,0 , &new_dev); + res =ieee80211_if_add (dev, param->u.if_info.name, &new_dev);if (res)return res;ieee80211_if_set_type (new_dev,IEEE80211_IF_TYPE_AP );
@@ -1050,7 +1050,7 @@ static int ieee80211_ioctl_add_if(structif (left <sizeof (struct hostapd_if_sta ))return -EPROTO ; - res =ieee80211_if_add (dev, param->u.if_info.name,0 , &new_dev); + res =ieee80211_if_add (dev, param->u.if_info.name, &new_dev);if (res)return res;ieee80211_if_set_type (new_dev,IEEE80211_IF_TYPE_STA );