cfg80211 fixes, cleanups, improvements
Subsystems (2)
Johannes Berg
maintainercover cfg80211 fixes, cleanups, improvements
This has a whole bunch of cfg80211 fixes, most notably work to actually do locking in cfg80211 properly! Sorry, my head was too small to grasp all of that in cfg80211 at once, so I deferred locking for the connect() API to this series.
johannes
Johannes Berg
maintainerPATCH 1/9 cfg80211: fix netdev down problem
We shouldn't be looking at the ssid_len for non-IBSS, and for IBSS we should also return an error on trying to leave an IBSS while not in or joining an IBSS.
This fixes an issue where we wouldn't disconnect() on an interface being taken down since there's no SSID configured this way.
--- net/wireless/core.c | 3 --- net/wireless/ibss.c | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-)
net/wireless/core.c +0 -3
@@ -567,9 +567,6 @@ static int cfg80211_netdev_notifier_call#endif break ;case NETDEV_GOING_DOWN : -if (!wdev->ssid_len) -break ; -switch (wdev->iftype) {case NL80211_IFTYPE_ADHOC :cfg80211_leave_ibss (rdev, dev, true);
net/wireless/ibss.c +4 -0
@@ -92,8 +92,12 @@ void cfg80211_clear_ibss(struct net_deviint cfg80211_leave_ibss (struct cfg80211_registered_device *rdev,struct net_device *dev,bool nowext) { +struct wireless_dev *wdev = dev->ieee80211_ptr;int err; +if (!wdev->ssid_len) +return -ENOLINK ; + err = rdev->ops->leave_ibss (&rdev->wiphy, dev);if (err)
Johannes Berg
maintainerPATCH 2/9 cfg80211: dont use union for wext
In reply to Johannes BergOtherwise it becomes very hard to reset the structs correctly since wext can be configured while the interface is down.
--- include/net/cfg80211.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
include/net/cfg80211.h +2 -4
@@ -1270,10 +1270,8 @@ struct wireless_dev { #ifdef CONFIG_WIRELESS_EXT /* wext data */ struct { - union { - struct cfg80211_ibss_params ibss; - struct cfg80211_connect_params connect; - }; + struct cfg80211_ibss_params ibss; + struct cfg80211_connect_params connect; u8 *ie; size_t ie_len; u8 bssid[ETH_ALEN];
Johannes Berg
maintainerPATCH 3/9 cfg80211: mlme API must be able to sleep
In reply to Johannes BergAfter the mac80211 mlme cleanup, we can require that the MLME functions in cfg80211 can sleep. This will simplify future work in cfg80211 a lot.
--- include/net/cfg80211.h | 30 +++++++++++++--------------- net/mac80211/mlme.c | 26 ++++++++---------------- net/wireless/mlme.c | 51 +++++++++++++++++++++++++++++++------------------ 3 files changed, 56 insertions(+), 51 deletions(-)
include/net/cfg80211.h +14 -16
@@ -1721,70 +1721,68 @@ void cfg80211_unlink_bss(struct wiphy *w* @dev: network device * @buf: authentication frame (header + body) * @len: length of the frame data -* @gfp: allocation flags * * This function is called whenever an authentication has been processed in * station mode. The driver is required to call either this function or * cfg80211_send_auth_timeout() to indicate the result of cfg80211_ops::auth() -* call. +* call. This function may sleep. */ -void cfg80211_send_rx_auth (struct net_device *dev,const u8 *buf,size_t len,gfp_t gfp); +void cfg80211_send_rx_auth (struct net_device *dev,const u8 *buf,size_t len);/** * cfg80211_send_auth_timeout - notification of timed out authentication * @dev: network device * @addr: The MAC address of the device with which the authentication timed out -* @gfp: allocation flags +* +* This function may sleep. */ -void cfg80211_send_auth_timeout (struct net_device *dev,const u8 *addr,gfp_t gfp); +void cfg80211_send_auth_timeout (struct net_device *dev,const u8 *addr);/** * cfg80211_send_rx_assoc - notification of processed association * @dev: network device * @buf: (re)association response frame (header + body) * @len: length of the frame data -* @gfp: allocation flags * * This function is called whenever a (re)association response has been * processed in station mode. The driver is required to call either this * function or cfg80211_send_assoc_timeout() to indicate the result of -* cfg80211_ops::assoc() call. +* cfg80211_ops::assoc() call. This function may sleep. */ -void cfg80211_send_rx_assoc (struct net_device *dev,const u8 *buf,size_t len,gfp_t gfp); +void cfg80211_send_rx_assoc (struct net_device *dev,const u8 *buf,size_t len);/** * cfg80211_send_assoc_timeout - notification of timed out association * @dev: network device * @addr: The MAC address of the device with which the association timed out -* @gfp: allocation flags +* +* This function may sleep. */ -void cfg80211_send_assoc_timeout (struct net_device *dev,const u8 *addr,gfp_t gfp); +void cfg80211_send_assoc_timeout (struct net_device *dev,const u8 *addr);/** * cfg80211_send_deauth - notification of processed deauthentication * @dev: network device * @buf: deauthentication frame (header + body) * @len: length of the frame data -* @gfp: allocation flags * * This function is called whenever deauthentication has been processed in * station mode. This includes both received deauthentication frames and -* locally generated ones. +* locally generated ones. This function may sleep. */ -void cfg80211_send_deauth (struct net_device *dev,const u8 *buf,size_t len,gfp_t gfp); +void cfg80211_send_deauth (struct net_device *dev,const u8 *buf,size_t len);/** * cfg80211_send_disassoc - notification of processed disassociation * @dev: network device * @buf: disassociation response frame (header + body) * @len: length of the frame data -* @gfp: allocation flags * * This function is called whenever disassociation has been processed in * station mode. This includes both received disassociation frames and locally -* generated ones. +* generated ones. This function may sleep. */ -void cfg80211_send_disassoc (struct net_device *dev,const u8 *buf,size_t len,gfp_t gfp); +void cfg80211_send_disassoc (struct net_device *dev,const u8 *buf,size_t len);/** * cfg80211_michael_mic_failure - notification of Michael MIC failure (TKIP)
net/wireless/mlme.c +33 -18
146 lines not on this page · raw message
net/mac80211/mlme.c +9 -17
@@ -412,11 +412,9 @@ static void ieee80211_send_deauth_disass mgmt->u.deauth.reason_code =cpu_to_le16 (reason);if (stype ==IEEE80211_STYPE_DEAUTH ) -cfg80211_send_deauth (sdata->dev, (u8 *) mgmt, skb->len, -GFP_KERNEL ); +cfg80211_send_deauth (sdata->dev, (u8 *) mgmt, skb->len);else -cfg80211_send_disassoc (sdata->dev, (u8 *) mgmt, skb->len, -GFP_KERNEL ); +cfg80211_send_disassoc (sdata->dev, (u8 *) mgmt, skb->len);ieee80211_tx_skb (sdata, skb, ifmgd->flags &IEEE80211_STA_MFP_ENABLED ); }
@@ -1839,12 +1837,10 @@ static void ieee80211_sta_rx_queued_mgmt/* no action */ break ;case RX_MGMT_CFG80211_DEAUTH : -cfg80211_send_deauth (sdata->dev, (u8 *) mgmt, - skb->len,GFP_KERNEL ); +cfg80211_send_deauth (sdata->dev, (u8 *)mgmt, skb->len);break ;case RX_MGMT_CFG80211_DISASSOC : -cfg80211_send_disassoc (sdata->dev, (u8 *) mgmt, - skb->len,GFP_KERNEL ); +cfg80211_send_disassoc (sdata->dev, (u8 *)mgmt, skb->len);break ;default :WARN (1 ,"unexpected: %d" , rma);
@@ -1893,12 +1889,10 @@ static void ieee80211_sta_rx_queued_mgmt/* no action */ break ;case RX_MGMT_CFG80211_AUTH : -cfg80211_send_rx_auth (sdata->dev, (u8 *) mgmt, skb->len, -GFP_KERNEL ); +cfg80211_send_rx_auth (sdata->dev, (u8 *) mgmt, skb->len);break ;case RX_MGMT_CFG80211_ASSOC : -cfg80211_send_rx_assoc (sdata->dev, (u8 *) mgmt, skb->len, -GFP_KERNEL ); +cfg80211_send_rx_assoc (sdata->dev, (u8 *) mgmt, skb->len);break ;default :WARN (1 ,"unexpected: %d" , rma);
@@ -2026,13 +2020,11 @@ static void ieee80211_sta_work(struct woswitch (wk->tries) {case RX_MGMT_CFG80211_AUTH_TO :cfg80211_send_auth_timeout (sdata->dev, - wk->bss->cbss.bssid, -GFP_KERNEL ); + wk->bss->cbss.bssid);break ;case RX_MGMT_CFG80211_ASSOC_TO : -cfg80211_send_auth_timeout (sdata->dev, - wk->bss->cbss.bssid, -GFP_KERNEL ); +cfg80211_send_assoc_timeout (sdata->dev, + wk->bss->cbss.bssid);break ;default :WARN (1 ,"unexpected: %d" , wk->tries);
Johannes Berg
maintainerPATCH 4/9 cfg80211: warn again on spurious deauth
In reply to Johannes BergThe original code in mac80211 could send a deauth frame under certain circumstances even if nothing had ever requested an authentication. This has been fixed with the rework there, so cfg80211 can now warn again about spurious events to catch possible future drivers or mac80211 regressions.
--- net/wireless/mlme.c | 6 ------ 1 file changed, 6 deletions(-)
net/wireless/mlme.c +0 -6
@@ -122,15 +122,9 @@ void cfg80211_send_deauth(struct net_devbreak ; } } -/* -* mac80211 currently triggers this warning, -* so disable for now (it's harmless, just -* means that we got a spurious event) WARN_ON (!done); -*/ -if (wdev->sme_state ==CFG80211_SME_CONNECTED ) {u16 reason_code;bool from_ap;
Johannes Berg
maintainerPATCH 5/9 cfg80211: properly name driver locking
In reply to Johannes BergCurrently we call that cfg80211_put_dev(), but that is misleading. With the new convention of using 'rdev' for registered_device variables, also call that function cfg80211_unlock_rdev().
--- net/wireless/core.c | 6 --- net/wireless/core.h | 8 +++-- net/wireless/nl80211.c | 74 ++++++++++++++++++++++++------------------------- net/wireless/scan.c | 6 +-- 4 files changed, 45 insertions(+), 49 deletions(-)
net/wireless/core.c +0 -6
@@ -171,12 +171,6 @@ cfg80211_get_dev_from_ifindex(int ifindereturn drv; } -void cfg80211_put_dev (struct cfg80211_registered_device *drv) -{ -BUG_ON (IS_ERR (drv)); -mutex_unlock (&drv->mtx); -} -/* requires cfg80211_mutex to be held */ int cfg80211_dev_rename (struct cfg80211_registered_device *rdev,char *newname)
net/wireless/core.h +6 -2
@@ -146,7 +146,7 @@ __cfg80211_drv_from_info(struct genl_inf* If successful, it returns non-NULL and also locks * the driver's mutex! * -* This means that you need to call cfg80211_put_dev() +* This means that you need to call cfg80211_unlock_rdev() * before being allowed to acquire &cfg80211_mutex! * * This is necessary because we need to lock the global
@@ -170,7 +170,11 @@ struct wiphy *wiphy_idx_to_wiphy(int wipextern struct cfg80211_registered_device *cfg80211_get_dev_from_ifindex (int ifindex); -extern void cfg80211_put_dev (struct cfg80211_registered_device *drv); +static inline void cfg80211_unlock_rdev (struct cfg80211_registered_device *drv) +{ +BUG_ON (IS_ERR (drv) || !drv); +mutex_unlock (&drv->mtx); +}/* free object */ extern void cfg80211_dev_free (struct cfg80211_registered_device *drv);
net/wireless/nl80211.c +37 -37
296 lines not on this page · raw message
net/wireless/scan.c +2 -4
@@ -28,8 +28,6 @@ void cfg80211_scan_done(struct cfg80211_if (!dev) goto out; -WARN_ON (request !=wiphy_to_dev (request->wiphy)->scan_req); -/* * This must be before sending the other events! * Otherwise, wpa_supplicant gets completely confused with
@@ -636,7 +634,7 @@ int cfg80211_wext_siwscan(struct net_dev }else nl80211_send_scan_start (rdev, dev); out: -cfg80211_put_dev (rdev); +cfg80211_unlock_rdev (rdev);return err; }EXPORT_SYMBOL_GPL (cfg80211_wext_siwscan);
@@ -945,7 +943,7 @@ int cfg80211_wext_giwscan(struct net_dev } out: -cfg80211_put_dev (rdev); +cfg80211_unlock_rdev (rdev);return res; }EXPORT_SYMBOL_GPL (cfg80211_wext_giwscan);
Johannes Berg
maintainerPATCH 6/9 cfg80211: fix MFP bug, sparse warnings
In reply to Johannes Bergsparse warns about a number of things, and one of them (use_mfp shadowed variable) actually is a bug, fix all of them.
--- net/wireless/nl80211.c | 6 +++--- net/wireless/wext-compat.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
net/wireless/nl80211.c +3 -3
@@ -3239,11 +3239,11 @@ static int nl80211_associate(struct sk_b }if (info->attrs[NL80211_ATTR_USE_MFP ]) { -enum nl80211_mfp use_mfp = +enum nl80211_mfp mfp =nla_get_u32 (info->attrs[NL80211_ATTR_USE_MFP ]); -if (use_mfp ==NL80211_MFP_REQUIRED ) +if (mfp ==NL80211_MFP_REQUIRED ) use_mfp = true; -else if (use_mfp !=NL80211_MFP_NO ) { +else if (mfp !=NL80211_MFP_NO ) { err = -EINVAL ; goto out; }
net/wireless/wext-compat.c +3 -3
@@ -855,7 +855,7 @@ static int cfg80211_set_wpa_version(strureturn 0 ; } -int cfg80211_set_cipher_group (struct wireless_dev *wdev,u32 cipher) +static int cfg80211_set_cipher_group (struct wireless_dev *wdev,u32 cipher) { wdev->wext.connect.crypto.cipher_group =0 ;
@@ -880,7 +880,7 @@ int cfg80211_set_cipher_group(struct wirreturn 0 ; } -int cfg80211_set_cipher_pairwise (struct wireless_dev *wdev,u32 cipher) +static int cfg80211_set_cipher_pairwise (struct wireless_dev *wdev,u32 cipher) {int nr_ciphers =0 ;u32 *ciphers_pairwise = wdev->wext.connect.crypto.ciphers_pairwise;
@@ -918,7 +918,7 @@ int cfg80211_set_cipher_pairwise(struct } -int cfg80211_set_key_mgt (struct wireless_dev *wdev,u32 key_mgt) +static int cfg80211_set_key_mgt (struct wireless_dev *wdev,u32 key_mgt) {int nr_akm_suites =0 ;
Johannes Berg
maintainerPATCH 7/9 cfg80211: fix locking
In reply to Johannes BergOver time, a lot of locking issues have crept into the smarts of cfg80211, so e.g. scan completion can race against a new scan, IBSS join can race against leaving an IBSS, etc.
Introduce a new per-interface lock that protects most of the per-interface data that we need to keep track of, and sprinkle assertions about that lock everywhere. Some things now need to be offloaded to work structs so that we don't require being able to sleep in functions the drivers call. The exception to that are the MLME callbacks (rx_auth etc.) that currently only mac80211 calls because it was easier to do that there instead of in cfg80211, and future drivers implementing those calls will, if they ever exist, probably need to use a similar scheme like mac80211 anyway...
In order to be able to handle _deauth and _disassoc properly, introduce a cookie passed to it that will determine locking requirements.
--- include/net/cfg80211.h | 24 +++- net/mac80211/cfg.c | 12 +- net/mac80211/ieee80211_i.h | 6 - net/mac80211/mlme.c | 25 ++-- net/wireless/core.c | 92 +++++++++++++++- net/wireless/core.h | 100 +++++++++++++++++ net/wireless/ibss.c | 133 ++++++++++++++++++----- net/wireless/mlme.c | 214 ++++++++++++++++++++++++++++++-------- net/wireless/nl80211.c | 8 - net/wireless/nl80211.h | 2 net/wireless/scan.c | 30 ++++- net/wireless/sme.c | 252 +++++++++++++++++++++++++++++++++++---------- net/wireless/wext-sme.c | 125 +++++++++++++++------- 13 files changed, 823 insertions(+), 200 deletions(-)
net/wireless/core.c +86 -6
@@ -257,6 +257,71 @@ static void cfg80211_rfkill_sync_work(stcfg80211_rfkill_set_block (drv,rfkill_blocked (drv->rfkill)); } +static void cfg80211_process_events (struct wireless_dev *wdev) +{ +struct cfg80211_event *ev; +unsigned long flags; + +spin_lock_irqsave (&wdev->event_lock, flags); +while (!list_empty (&wdev->event_list)) { + ev =list_first_entry (&wdev->event_list, + struct cfg80211_event, list); +list_del (&ev->list); +spin_unlock_irqrestore (&wdev->event_lock, flags); + +wdev_lock (wdev); +switch (ev->type) { +case EVENT_CONNECT_RESULT : +__cfg80211_connect_result ( + wdev->netdev, ev->cr.bssid, + ev->cr.req_ie, ev->cr.req_ie_len, + ev->cr.resp_ie, ev->cr.resp_ie_len, + ev->cr.status, + ev->cr.status ==WLAN_STATUS_SUCCESS ); +break ; +case EVENT_ROAMED : +__cfg80211_roamed (wdev, ev->rm.bssid, + ev->rm.req_ie, ev->rm.req_ie_len, + ev->rm.resp_ie, ev->rm.resp_ie_len); +break ; +case EVENT_DISCONNECTED : +__cfg80211_disconnected (wdev->netdev, + ev->dc.ie, ev->dc.ie_len, + ev->dc.reason, true); +break ; +case EVENT_IBSS_JOINED : +__cfg80211_ibss_joined (wdev->netdev, ev->ij.bssid); +break ; + } +wdev_unlock (wdev); + +kfree (ev); + +spin_lock_irqsave (&wdev->event_lock, flags); + } +spin_unlock_irqrestore (&wdev->event_lock, flags); +} + +static void cfg80211_event_work (struct work_struct *work) +{ +struct cfg80211_registered_device *rdev; +struct wireless_dev *wdev; + + rdev = container_of(work, struct cfg80211_registered_device, + event_work); + +rtnl_lock (); +cfg80211_lock_rdev (rdev); +mutex_lock (&rdev->devlist_mtx); + +list_for_each_entry (wdev, &rdev->netdev_list, list) +cfg80211_process_events (wdev); + +mutex_unlock (&rdev->devlist_mtx); +cfg80211_unlock_rdev (rdev); +rtnl_unlock (); +} +/* exported functions */ struct wiphy *wiphy_new (const struct cfg80211_ops *ops,int sizeof_priv)
@@ -299,6 +364,7 @@ struct wiphy *wiphy_new(const struct cfgINIT_LIST_HEAD (&drv->netdev_list);spin_lock_init (&drv->bss_lock);INIT_LIST_HEAD (&drv->bss_list); +INIT_WORK (&drv->scan_done_wk, __cfg80211_scan_done);device_initialize (&drv->wiphy.dev); drv->wiphy.dev.class = &ieee80211_class;
@@ -316,6 +382,7 @@ struct wiphy *wiphy_new(const struct cfgINIT_WORK (&drv->rfkill_sync, cfg80211_rfkill_sync_work);INIT_WORK (&drv->conn_work, cfg80211_conn_work); +INIT_WORK (&drv->event_work, cfg80211_event_work);/* * Initialize wiphy parameters to IEEE 802.11 MIB default values.
@@ -477,6 +544,9 @@ void wiphy_unregister(struct wiphy *wiphmutex_unlock (&drv->mtx);cancel_work_sync (&drv->conn_work); +cancel_work_sync (&drv->scan_done_wk); +kfree (drv->scan_req); +flush_work (&drv->event_work);cfg80211_debugfs_drv_del (drv);
@@ -535,6 +605,9 @@ static int cfg80211_netdev_notifier_callswitch (state) {case NETDEV_REGISTER : +mutex_init (&wdev->mtx); +INIT_LIST_HEAD (&wdev->event_list); +spin_lock_init (&wdev->event_lock);mutex_lock (&rdev->devlist_mtx);list_add (&wdev->list, &rdev->netdev_list); if (sysfs_create_link(&dev->dev.kobj, &rdev->wiphy.dev.kobj,
@@ -566,15 +639,17 @@ static int cfg80211_netdev_notifier_callcfg80211_leave_ibss (rdev, dev, true);break ;case NL80211_IFTYPE_STATION : +wdev_lock (wdev);#ifdef CONFIG_WIRELESS_EXT kfree (wdev->wext.ie); wdev->wext.ie =NULL ; wdev->wext.ie_len =0 ; wdev->wext.connect.auth_type =NL80211_AUTHTYPE_AUTOMATIC ;#endif -cfg80211_disconnect (rdev, dev, -WLAN_REASON_DEAUTH_LEAVING , true); +__cfg80211_disconnect (rdev, dev, +WLAN_REASON_DEAUTH_LEAVING , true);cfg80211_mlme_down (rdev, dev); +wdev_unlock (wdev);break ;default :break ;
@@ -582,20 +657,24 @@ static int cfg80211_netdev_notifier_callbreak ;case NETDEV_UP :#ifdef CONFIG_WIRELESS_EXT +cfg80211_lock_rdev (rdev); +wdev_lock (wdev);switch (wdev->iftype) {case NL80211_IFTYPE_ADHOC :if (wdev->wext.ibss.ssid_len) -cfg80211_join_ibss (rdev, dev, - &wdev->wext.ibss); +__cfg80211_join_ibss (rdev, dev, + &wdev->wext.ibss);break ;case NL80211_IFTYPE_STATION :if (wdev->wext.connect.ssid_len) -cfg80211_connect (rdev, dev, - &wdev->wext.connect); +__cfg80211_connect (rdev, dev, + &wdev->wext.connect);break ;default :break ; } +wdev_unlock (wdev); +cfg80211_unlock_rdev (rdev);#endif break ;case NETDEV_UNREGISTER :
@@ -605,6 +684,7 @@ static int cfg80211_netdev_notifier_calllist_del_init (&wdev->list); }mutex_unlock (&rdev->devlist_mtx); +mutex_destroy (&wdev->mtx);break ;case NETDEV_PRE_UP :if (rfkill_blocked (rdev->rfkill))
net/wireless/core.h +99 -1
172 lines not on this page · raw message
net/wireless/mlme.c +168 -46
386 lines not on this page · raw message
net/wireless/sme.c +196 -56
443 lines not on this page · raw message
include/net/cfg80211.h +19 -5
@@ -555,6 +555,7 @@ struct cfg80211_scan_request {/* internal */ struct wiphy *wiphy;int ifidx; +bool aborted; };/**
@@ -998,9 +999,11 @@ struct cfg80211_ops {int (*assoc)(struct wiphy *wiphy,struct net_device *dev,struct cfg80211_assoc_request *req);int (*deauth)(struct wiphy *wiphy,struct net_device *dev, -struct cfg80211_deauth_request *req); +struct cfg80211_deauth_request *req, +void *cookie);int (*disassoc)(struct wiphy *wiphy,struct net_device *dev, -struct cfg80211_disassoc_request *req); +struct cfg80211_disassoc_request *req, +void *cookie);int (*connect)(struct wiphy *wiphy,struct net_device *dev,struct cfg80211_connect_params *sme);
@@ -1249,10 +1252,12 @@ struct wireless_dev {struct wiphy *wiphy;enum nl80211_iftype iftype; -/* private to the generic wireless code */ +/* the remainder of this struct should be private to cfg80211 */ struct list_head list;struct net_device *netdev; +struct mutex mtx; +/* currently used for IBSS and SME - might be rearranged later */ u8 ssid[IEEE80211_MAX_SSID_LEN ];u8 ssid_len;
@@ -1263,6 +1268,9 @@ struct wireless_dev { } sme_state;struct cfg80211_conn *conn; +struct list_head event_list; +spinlock_t event_lock; +struct cfg80211_internal_bss *authtry_bsses[MAX_AUTH_BSSES ];struct cfg80211_internal_bss *auth_bsses[MAX_AUTH_BSSES ];struct cfg80211_internal_bss *current_bss;/* associated / joined */
@@ -1765,24 +1773,30 @@ void cfg80211_send_assoc_timeout(struct* @dev: network device * @buf: deauthentication frame (header + body) * @len: length of the frame data +* @cookie: cookie from ->deauth if called within that callback, +* %NULL otherwise * * This function is called whenever deauthentication has been processed in * station mode. This includes both received deauthentication frames and * locally generated ones. This function may sleep. */ -void cfg80211_send_deauth (struct net_device *dev,const u8 *buf,size_t len); +void cfg80211_send_deauth (struct net_device *dev,const u8 *buf,size_t len, +void *cookie);/** * cfg80211_send_disassoc - notification of processed disassociation * @dev: network device * @buf: disassociation response frame (header + body) * @len: length of the frame data +* @cookie: cookie from ->disassoc if called within that callback, +* %NULL otherwise * * This function is called whenever disassociation has been processed in * station mode. This includes both received disassociation frames and locally * generated ones. This function may sleep. */ -void cfg80211_send_disassoc (struct net_device *dev,const u8 *buf,size_t len); +void cfg80211_send_disassoc (struct net_device *dev,const u8 *buf,size_t len, +void *cookie);/** * cfg80211_michael_mic_failure - notification of Michael MIC failure (TKIP)
net/wireless/scan.c +27 -3
@@ -17,13 +17,21 @@#define IEEE80211_SCAN_RESULT_EXPIRE (10 * HZ) -void cfg80211_scan_done (struct cfg80211_scan_request *request,bool aborted) +void __cfg80211_scan_done (struct work_struct *wk) { +struct cfg80211_registered_device *rdev; +struct cfg80211_scan_request *request;struct net_device *dev;#ifdef CONFIG_WIRELESS_EXT union iwreq_data wrqu;#endif + rdev = container_of(wk, struct cfg80211_registered_device, + scan_done_wk); + +mutex_lock (&rdev->mtx); + request = rdev->scan_req; + dev =dev_get_by_index (&init_net, request->ifidx);if (!dev) goto out;
@@ -35,7 +43,7 @@ void cfg80211_scan_done(struct cfg80211_*/ cfg80211_sme_scan_done (dev); -if (aborted) +if (request->aborted)nl80211_send_scan_aborted (wiphy_to_dev (request->wiphy), dev);else nl80211_send_scan_done (wiphy_to_dev (request->wiphy), dev);
@@ -43,7 +51,7 @@ void cfg80211_scan_done(struct cfg80211_wiphy_to_dev (request->wiphy)->scan_req =NULL ;#ifdef CONFIG_WIRELESS_EXT -if (!aborted) { +if (!request->aborted) {memset (&wrqu,0 ,sizeof (wrqu));wireless_send_event (dev,SIOCGIWSCAN , &wrqu,NULL );
@@ -53,8 +61,24 @@ void cfg80211_scan_done(struct cfg80211_dev_put (dev); out: +cfg80211_unlock_rdev (rdev);kfree (request); } + +void cfg80211_scan_done (struct cfg80211_scan_request *request,bool aborted) +{ +struct net_device *dev =dev_get_by_index (&init_net, request->ifidx); +if (WARN_ON (!dev)) { +kfree (request); +return ; + } + +WARN_ON (request !=wiphy_to_dev (request->wiphy)->scan_req); + + request->aborted = aborted; +schedule_work (&wiphy_to_dev (request->wiphy)->scan_done_wk); +dev_put (dev); +}EXPORT_SYMBOL (cfg80211_scan_done);static void bss_release (struct kref *ref)
net/wireless/nl80211.c +5 -3
@@ -4029,6 +4029,8 @@ static int nl80211_add_scan_req(struct sstruct nlattr *nest;int i; +ASSERT_RDEV_LOCK (rdev); +if (WARN_ON (!req))return 0 ;
@@ -4391,12 +4393,12 @@ void nl80211_send_roamed(struct cfg80211void nl80211_send_disconnected (struct cfg80211_registered_device *rdev,struct net_device *netdev,u16 reason, -u8 *ie,size_t ie_len,bool from_ap,gfp_t gfp) +const u8 *ie,size_t ie_len,bool from_ap) {struct sk_buff *msg;void *hdr; - msg =nlmsg_new (NLMSG_GOODSIZE , gfp); + msg =nlmsg_new (NLMSG_GOODSIZE ,GFP_KERNEL );if (!msg)return ;
@@ -4420,7 +4422,7 @@ void nl80211_send_disconnected(struct cfreturn ; } -genlmsg_multicast (msg,0 , nl80211_mlme_mcgrp.id, gfp); +genlmsg_multicast (msg,0 , nl80211_mlme_mcgrp.id,GFP_KERNEL );return ; nla_put_failure:
net/wireless/ibss.c +106 -27
236 lines not on this page · raw message
net/wireless/wext-sme.c +88 -37
273 lines not on this page · raw message
net/mac80211/cfg.c +8 -4
@@ -1182,15 +1182,19 @@ static int ieee80211_assoc(struct wiphy }static int ieee80211_deauth (struct wiphy *wiphy,struct net_device *dev, -struct cfg80211_deauth_request *req) +struct cfg80211_deauth_request *req, +void *cookie) { -return ieee80211_mgd_deauth (IEEE80211_DEV_TO_SUB_IF (dev), req); +return ieee80211_mgd_deauth (IEEE80211_DEV_TO_SUB_IF (dev), + req, cookie); }static int ieee80211_disassoc (struct wiphy *wiphy,struct net_device *dev, -struct cfg80211_disassoc_request *req) +struct cfg80211_disassoc_request *req, +void *cookie) { -return ieee80211_mgd_disassoc (IEEE80211_DEV_TO_SUB_IF (dev), req); +return ieee80211_mgd_disassoc (IEEE80211_DEV_TO_SUB_IF (dev), + req, cookie); } static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
net/mac80211/ieee80211_i.h +4 -2
@@ -916,9 +916,11 @@ int ieee80211_mgd_auth(struct ieee80211_int ieee80211_mgd_assoc (struct ieee80211_sub_if_data *sdata,struct cfg80211_assoc_request *req);int ieee80211_mgd_deauth (struct ieee80211_sub_if_data *sdata, -struct cfg80211_deauth_request *req); +struct cfg80211_deauth_request *req, +void *cookie);int ieee80211_mgd_disassoc (struct ieee80211_sub_if_data *sdata, -struct cfg80211_disassoc_request *req); +struct cfg80211_disassoc_request *req, +void *cookie);ieee80211_rx_result ieee80211_sta_rx_mgmt (struct ieee80211_sub_if_data *sdata,struct sk_buff *skb); void ieee80211_send_pspoll(struct ieee80211_local *local,
net/mac80211/mlme.c +16 -9
@@ -386,7 +386,8 @@ static void ieee80211_send_assoc(structstatic void ieee80211_send_deauth_disassoc (struct ieee80211_sub_if_data *sdata, -const u8 *bssid,u16 stype,u16 reason) +const u8 *bssid,u16 stype,u16 reason, +void *cookie) {struct ieee80211_local *local = sdata->local;struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
@@ -412,9 +413,9 @@ static void ieee80211_send_deauth_disass mgmt->u.deauth.reason_code =cpu_to_le16 (reason);if (stype ==IEEE80211_STYPE_DEAUTH ) -cfg80211_send_deauth (sdata->dev, (u8 *) mgmt, skb->len); +cfg80211_send_deauth (sdata->dev, (u8 *)mgmt, skb->len, cookie);else -cfg80211_send_disassoc (sdata->dev, (u8 *) mgmt, skb->len); +cfg80211_send_disassoc (sdata->dev, (u8 *)mgmt, skb->len, cookie);ieee80211_tx_skb (sdata, skb, ifmgd->flags &IEEE80211_STA_MFP_ENABLED ); }
@@ -1837,10 +1838,12 @@ static void ieee80211_sta_rx_queued_mgmt/* no action */ break ;case RX_MGMT_CFG80211_DEAUTH : -cfg80211_send_deauth (sdata->dev, (u8 *)mgmt, skb->len); +cfg80211_send_deauth (sdata->dev, (u8 *)mgmt, skb->len, +NULL );break ;case RX_MGMT_CFG80211_DISASSOC : -cfg80211_send_disassoc (sdata->dev, (u8 *)mgmt, skb->len); +cfg80211_send_disassoc (sdata->dev, (u8 *)mgmt, skb->len, +NULL );break ;default :WARN (1 ,"unexpected: %d" , rma);
@@ -2273,7 +2276,8 @@ int ieee80211_mgd_assoc(struct ieee80211 }int ieee80211_mgd_deauth (struct ieee80211_sub_if_data *sdata, -struct cfg80211_deauth_request *req) +struct cfg80211_deauth_request *req, +void *cookie) {struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;struct ieee80211_mgd_work *wk;
@@ -2305,13 +2309,15 @@ int ieee80211_mgd_deauth(struct ieee8021mutex_unlock (&ifmgd->mtx);ieee80211_send_deauth_disassoc (sdata, bssid, -IEEE80211_STYPE_DEAUTH , req->reason_code); +IEEE80211_STYPE_DEAUTH , req->reason_code, + cookie);return 0 ; }int ieee80211_mgd_disassoc (struct ieee80211_sub_if_data *sdata, -struct cfg80211_disassoc_request *req) +struct cfg80211_disassoc_request *req, +void *cookie) {struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
@@ -2331,6 +2337,7 @@ int ieee80211_mgd_disassoc(struct ieee80mutex_unlock (&ifmgd->mtx);ieee80211_send_deauth_disassoc (sdata, req->bss->bssid, -IEEE80211_STYPE_DISASSOC , req->reason_code); +IEEE80211_STYPE_DISASSOC , req->reason_code, + cookie);return 0 ; }
net/wireless/nl80211.h +1 -1
@@ -42,7 +42,7 @@ void nl80211_send_roamed(struct cfg80211 const u8 *resp_ie, size_t resp_ie_len, gfp_t gfp);void nl80211_send_disconnected (struct cfg80211_registered_device *rdev,struct net_device *netdev,u16 reason, -u8 *ie,size_t ie_len,bool from_ap,gfp_t gfp); +const u8 *ie,size_t ie_len,bool from_ap); void nl80211_michael_mic_failure(struct cfg80211_registered_device *rdev,
Johannes Berg
maintainerPATCH 8/9 cfg80211: clean up naming once and for all
In reply to Johannes BergWe've named the registered devices 'drv' sometimes, thinking of "driver", which is not what it is, it's the internal representation of a wiphy, i.e. a device. Let's clean up the naming once and and use 'rdev' aka 'registered device' everywhere.
--- net/wireless/core.c | 224 ++++++++++++++++---------------- net/wireless/core.h | 26 +-- net/wireless/debugfs.c | 14 +- net/wireless/debugfs.h | 8 - net/wireless/nl80211.c | 340 ++++++++++++++++++++++++------------------------- net/wireless/reg.c | 48 +++--- net/wireless/sme.c | 48 +++--- 7 files changed, 354 insertions(+), 354 deletions(-)
net/wireless/core.c +112 -112
@@ -30,10 +30,10 @@ MODULE_DESCRIPTION("wireless configurati/* RCU might be appropriate here since we usually * only read the list, and that can happen quite * often because we need to do it for each command */ -LIST_HEAD (cfg80211_drv_list); +LIST_HEAD (cfg80211_rdev_list);/* -* This is used to protect the cfg80211_drv_list, cfg80211_regdomain, +* This is used to protect the cfg80211_rdev_list, cfg80211_regdomain, * country_ie_regdomain, the reg_beacon_list and the the last regulatory * request receipt (last_request). */
@@ -43,18 +43,18 @@ DEFINE_MUTEX(cfg80211_mutex);static struct dentry *ieee80211_debugfs_dir;/* requires cfg80211_mutex to be held! */ -struct cfg80211_registered_device *cfg80211_drv_by_wiphy_idx (int wiphy_idx) +struct cfg80211_registered_device *cfg80211_rdev_by_wiphy_idx (int wiphy_idx) { -struct cfg80211_registered_device *result =NULL , *drv; +struct cfg80211_registered_device *result =NULL , *rdev;if (!wiphy_idx_valid (wiphy_idx))return NULL ;assert_cfg80211_lock (); -list_for_each_entry (drv, &cfg80211_drv_list, list) { -if (drv->wiphy_idx == wiphy_idx) { - result = drv; +list_for_each_entry (rdev, &cfg80211_rdev_list, list) { +if (rdev->wiphy_idx == wiphy_idx) { + result = rdev;break ; } }
@@ -64,32 +64,32 @@ struct cfg80211_registered_device *cfg80int get_wiphy_idx (struct wiphy *wiphy) { -struct cfg80211_registered_device *drv; +struct cfg80211_registered_device *rdev;if (!wiphy)return WIPHY_IDX_STALE ; - drv =wiphy_to_dev (wiphy); -return drv->wiphy_idx; + rdev =wiphy_to_dev (wiphy); +return rdev->wiphy_idx; } -/* requires cfg80211_drv_mutex to be held! */ +/* requires cfg80211_rdev_mutex to be held! */ struct wiphy *wiphy_idx_to_wiphy (int wiphy_idx) { -struct cfg80211_registered_device *drv; +struct cfg80211_registered_device *rdev;if (!wiphy_idx_valid (wiphy_idx))return NULL ;assert_cfg80211_lock (); - drv =cfg80211_drv_by_wiphy_idx (wiphy_idx); -if (!drv) + rdev =cfg80211_rdev_by_wiphy_idx (wiphy_idx); +if (!rdev)return NULL ; -return &drv->wiphy; +return &rdev->wiphy; }/* requires cfg80211_mutex to be held! */ struct cfg80211_registered_device * -__cfg80211_drv_from_info (struct genl_info *info) +__cfg80211_rdev_from_info (struct genl_info *info) {int ifindex;struct cfg80211_registered_device *bywiphyidx =NULL , *byifidx =NULL ;
@@ -99,7 +99,7 @@ __cfg80211_drv_from_info(struct genl_infassert_cfg80211_lock ();if (info->attrs[NL80211_ATTR_WIPHY ]) { - bywiphyidx =cfg80211_drv_by_wiphy_idx ( + bywiphyidx =cfg80211_rdev_by_wiphy_idx (nla_get_u32 (info->attrs[NL80211_ATTR_WIPHY ])); err = -ENODEV ; }
@@ -134,26 +134,26 @@ __cfg80211_drv_from_info(struct genl_infstruct cfg80211_registered_device *cfg80211_get_dev_from_info (struct genl_info *info) { -struct cfg80211_registered_device *drv; +struct cfg80211_registered_device *rdev;mutex_lock (&cfg80211_mutex); - drv =__cfg80211_drv_from_info (info); + rdev =__cfg80211_rdev_from_info (info);/* if it is not an error we grab the lock on * it to assure it won't be going away while * we operate on it */ -if (!IS_ERR (drv)) -mutex_lock (&drv->mtx); +if (!IS_ERR (rdev)) +mutex_lock (&rdev->mtx);mutex_unlock (&cfg80211_mutex); -return drv; +return rdev; }struct cfg80211_registered_device *cfg80211_get_dev_from_ifindex (int ifindex) { -struct cfg80211_registered_device *drv =ERR_PTR (-ENODEV ); +struct cfg80211_registered_device *rdev =ERR_PTR (-ENODEV );struct net_device *dev;mutex_lock (&cfg80211_mutex);
@@ -161,21 +161,21 @@ cfg80211_get_dev_from_ifindex(int ifindeif (!dev) goto out;if (dev->ieee80211_ptr) { - drv =wiphy_to_dev (dev->ieee80211_ptr->wiphy); -mutex_lock (&drv->mtx); + rdev =wiphy_to_dev (dev->ieee80211_ptr->wiphy); +mutex_lock (&rdev->mtx); }else - drv =ERR_PTR (-ENODEV ); + rdev =ERR_PTR (-ENODEV );dev_put (dev); out:mutex_unlock (&cfg80211_mutex); -return drv; +return rdev; }/* requires cfg80211_mutex to be held */ int cfg80211_dev_rename (struct cfg80211_registered_device *rdev,char *newname) { -struct cfg80211_registered_device *drv; +struct cfg80211_registered_device *rdev2;int wiphy_idx, taken =-1 , result, digits;assert_cfg80211_lock ();
@@ -201,8 +201,8 @@ int cfg80211_dev_rename(struct cfg80211_return 0 ;/* Ensure another device does not already have this name. */ -list_for_each_entry (drv, &cfg80211_drv_list, list) -if (strcmp (newname,dev_name (&drv->wiphy.dev)) ==0 ) +list_for_each_entry (rdev2, &cfg80211_rdev_list, list) +if (strcmp (newname,dev_name (&rdev2->wiphy.dev)) ==0 )return -EINVAL ; result =device_rename (&rdev->wiphy.dev, newname);
@@ -224,26 +224,26 @@ int cfg80211_dev_rename(struct cfg80211_static void cfg80211_rfkill_poll (struct rfkill *rfkill,void *data) { -struct cfg80211_registered_device *drv = data; +struct cfg80211_registered_device *rdev = data; - drv->ops->rfkill_poll (&drv->wiphy); + rdev->ops->rfkill_poll (&rdev->wiphy); }static int cfg80211_rfkill_set_block (void *data,bool blocked) { -struct cfg80211_registered_device *drv = data; +struct cfg80211_registered_device *rdev = data;struct wireless_dev *wdev;if (!blocked)return 0 ;rtnl_lock (); -mutex_lock (&drv->devlist_mtx); +mutex_lock (&rdev->devlist_mtx); -list_for_each_entry (wdev, &drv->netdev_list, list) +list_for_each_entry (wdev, &rdev->netdev_list, list)dev_close (wdev->netdev); -mutex_unlock (&drv->devlist_mtx); +mutex_unlock (&rdev->devlist_mtx);rtnl_unlock ();return 0 ;
@@ -251,10 +251,10 @@ static int cfg80211_rfkill_set_block(voistatic void cfg80211_rfkill_sync_work (struct work_struct *work) { -struct cfg80211_registered_device *drv; +struct cfg80211_registered_device *rdev; - drv = container_of(work, struct cfg80211_registered_device, rfkill_sync); -cfg80211_rfkill_set_block (drv,rfkill_blocked (drv->rfkill)); + rdev = container_of(work, struct cfg80211_registered_device, rfkill_sync); +cfg80211_rfkill_set_block (rdev,rfkill_blocked (rdev->rfkill)); }static void cfg80211_process_events (struct wireless_dev *wdev)
@@ -328,79 +328,79 @@ struct wiphy *wiphy_new(const struct cfg {static int wiphy_counter; -struct cfg80211_registered_device *drv; +struct cfg80211_registered_device *rdev;int alloc_size;WARN_ON (!ops->add_key && ops->del_key);WARN_ON (ops->add_key && !ops->del_key); - alloc_size =sizeof (*drv) + sizeof_priv; + alloc_size =sizeof (*rdev) + sizeof_priv; - drv =kzalloc (alloc_size,GFP_KERNEL ); -if (!drv) + rdev =kzalloc (alloc_size,GFP_KERNEL ); +if (!rdev)return NULL ; - drv->ops = ops; + rdev->ops = ops;mutex_lock (&cfg80211_mutex); - drv->wiphy_idx = wiphy_counter++; + rdev->wiphy_idx = wiphy_counter++; -if (unlikely (!wiphy_idx_valid (drv->wiphy_idx))) { +if (unlikely (!wiphy_idx_valid (rdev->wiphy_idx))) { wiphy_counter--;mutex_unlock (&cfg80211_mutex);/* ugh, wrapped! */ -kfree (drv); +kfree (rdev);return NULL ; }mutex_unlock (&cfg80211_mutex);/* give it a proper name */ -dev_set_name (&drv->wiphy.dev,PHY_NAME "%d" , drv->wiphy_idx); +dev_set_name (&rdev->wiphy.dev,PHY_NAME "%d" , rdev->wiphy_idx); -mutex_init (&drv->mtx); -mutex_init (&drv->devlist_mtx); -INIT_LIST_HEAD (&drv->netdev_list); -spin_lock_init (&drv->bss_lock); -INIT_LIST_HEAD (&drv->bss_list); -INIT_WORK (&drv->scan_done_wk, __cfg80211_scan_done); - -device_initialize (&drv->wiphy.dev); - drv->wiphy.dev.class = &ieee80211_class; - drv->wiphy.dev.platform_data = drv; - - drv->rfkill_ops.set_block = cfg80211_rfkill_set_block; - drv->rfkill =rfkill_alloc (dev_name (&drv->wiphy.dev), - &drv->wiphy.dev,RFKILL_TYPE_WLAN , - &drv->rfkill_ops, drv); +mutex_init (&rdev->mtx); +mutex_init (&rdev->devlist_mtx); +INIT_LIST_HEAD (&rdev->netdev_list); +spin_lock_init (&rdev->bss_lock); +INIT_LIST_HEAD (&rdev->bss_list); +INIT_WORK (&rdev->scan_done_wk, __cfg80211_scan_done); + +device_initialize (&rdev->wiphy.dev); + rdev->wiphy.dev.class = &ieee80211_class; + rdev->wiphy.dev.platform_data = rdev; + + rdev->rfkill_ops.set_block = cfg80211_rfkill_set_block; + rdev->rfkill =rfkill_alloc (dev_name (&rdev->wiphy.dev), + &rdev->wiphy.dev,RFKILL_TYPE_WLAN , + &rdev->rfkill_ops, rdev); -if (!drv->rfkill) { -kfree (drv); +if (!rdev->rfkill) { +kfree (rdev);return NULL ; } -INIT_WORK (&drv->rfkill_sync, cfg80211_rfkill_sync_work); -INIT_WORK (&drv->conn_work, cfg80211_conn_work); -INIT_WORK (&drv->event_work, cfg80211_event_work); +INIT_WORK (&rdev->rfkill_sync, cfg80211_rfkill_sync_work); +INIT_WORK (&rdev->conn_work, cfg80211_conn_work); +INIT_WORK (&rdev->event_work, cfg80211_event_work);/* * Initialize wiphy parameters to IEEE 802.11 MIB default values. * Fragmentation and RTS threshold are disabled by default with the * special -1 value. */ - drv->wiphy.retry_short =7 ; - drv->wiphy.retry_long =4 ; - drv->wiphy.frag_threshold = (u32) -1 ; - drv->wiphy.rts_threshold = (u32) -1 ; + rdev->wiphy.retry_short =7 ; + rdev->wiphy.retry_long =4 ; + rdev->wiphy.frag_threshold = (u32) -1 ; + rdev->wiphy.rts_threshold = (u32) -1 ; -return &drv->wiphy; +return &rdev->wiphy; }EXPORT_SYMBOL (wiphy_new);int wiphy_register (struct wiphy *wiphy) { -struct cfg80211_registered_device *drv =wiphy_to_dev (wiphy); +struct cfg80211_registered_device *rdev =wiphy_to_dev (wiphy);int res;enum ieee80211_band band;struct ieee80211_supported_band *sband;
@@ -454,11 +454,11 @@ int wiphy_register(struct wiphy *wiphy)/* check and set up bitrates */ ieee80211_set_bitrate_flags (wiphy); - res =device_add (&drv->wiphy.dev); + res =device_add (&rdev->wiphy.dev);if (res)return res; - res =rfkill_register (drv->rfkill); + res =rfkill_register (rdev->rfkill);if (res) goto out_rm_dev;
@@ -467,16 +467,16 @@ int wiphy_register(struct wiphy *wiphy)/* set up regulatory info */ wiphy_update_regulatory (wiphy,NL80211_REGDOM_SET_BY_CORE ); -list_add (&drv->list, &cfg80211_drv_list); +list_add (&rdev->list, &cfg80211_rdev_list);mutex_unlock (&cfg80211_mutex);/* add to debugfs */ - drv->wiphy.debugfsdir = -debugfs_create_dir (wiphy_name (&drv->wiphy), + rdev->wiphy.debugfsdir = +debugfs_create_dir (wiphy_name (&rdev->wiphy), ieee80211_debugfs_dir); -if (IS_ERR (drv->wiphy.debugfsdir)) - drv->wiphy.debugfsdir =NULL ; +if (IS_ERR (rdev->wiphy.debugfsdir)) + rdev->wiphy.debugfsdir =NULL ;if (wiphy->custom_regulatory) {struct regulatory_request request;
@@ -489,48 +489,48 @@ int wiphy_register(struct wiphy *wiphy)nl80211_send_reg_change_event (&request); } -cfg80211_debugfs_drv_add (drv); +cfg80211_debugfs_rdev_add (rdev);return 0 ; out_rm_dev: -device_del (&drv->wiphy.dev); +device_del (&rdev->wiphy.dev);return res; }EXPORT_SYMBOL (wiphy_register);void wiphy_rfkill_start_polling (struct wiphy *wiphy) { -struct cfg80211_registered_device *drv =wiphy_to_dev (wiphy); +struct cfg80211_registered_device *rdev =wiphy_to_dev (wiphy); -if (!drv->ops->rfkill_poll) +if (!rdev->ops->rfkill_poll)return ; - drv->rfkill_ops.poll = cfg80211_rfkill_poll; -rfkill_resume_polling (drv->rfkill); + rdev->rfkill_ops.poll = cfg80211_rfkill_poll; +rfkill_resume_polling (rdev->rfkill); }EXPORT_SYMBOL (wiphy_rfkill_start_polling);void wiphy_rfkill_stop_polling (struct wiphy *wiphy) { -struct cfg80211_registered_device *drv =wiphy_to_dev (wiphy); +struct cfg80211_registered_device *rdev =wiphy_to_dev (wiphy); -rfkill_pause_polling (drv->rfkill); +rfkill_pause_polling (rdev->rfkill); }EXPORT_SYMBOL (wiphy_rfkill_stop_polling);void wiphy_unregister (struct wiphy *wiphy) { -struct cfg80211_registered_device *drv =wiphy_to_dev (wiphy); +struct cfg80211_registered_device *rdev =wiphy_to_dev (wiphy); -rfkill_unregister (drv->rfkill); +rfkill_unregister (rdev->rfkill);/* protect the device list */ mutex_lock (&cfg80211_mutex); -BUG_ON (!list_empty (&drv->netdev_list)); +BUG_ON (!list_empty (&rdev->netdev_list));/* -* Try to grab drv->mtx. If a command is still in progress, +* Try to grab rdev->mtx. If a command is still in progress, * hopefully the driver will refuse it since it's tearing * down the device already. We wait for this command to complete * before unlinking the item from the list.
@@ -539,38 +539,38 @@ void wiphy_unregister(struct wiphy *wiph* get to lock contention here if userspace issues a command * that identified the hardware by wiphy index. */ -mutex_lock (&drv->mtx); +mutex_lock (&rdev->mtx);/* unlock again before freeing */ -mutex_unlock (&drv->mtx); +mutex_unlock (&rdev->mtx); -cancel_work_sync (&drv->conn_work); -cancel_work_sync (&drv->scan_done_wk); -kfree (drv->scan_req); -flush_work (&drv->event_work); +cancel_work_sync (&rdev->conn_work); +cancel_work_sync (&rdev->scan_done_wk); +kfree (rdev->scan_req); +flush_work (&rdev->event_work); -cfg80211_debugfs_drv_del (drv); +cfg80211_debugfs_rdev_del (rdev);/* If this device got a regulatory hint tell core its * free to listen now to a new shiny device regulatory hint */ reg_device_remove (wiphy); -list_del (&drv->list); -device_del (&drv->wiphy.dev); -debugfs_remove (drv->wiphy.debugfsdir); +list_del (&rdev->list); +device_del (&rdev->wiphy.dev); +debugfs_remove (rdev->wiphy.debugfsdir);mutex_unlock (&cfg80211_mutex); }EXPORT_SYMBOL (wiphy_unregister); -void cfg80211_dev_free (struct cfg80211_registered_device *drv) +void cfg80211_dev_free (struct cfg80211_registered_device *rdev) {struct cfg80211_internal_bss *scan, *tmp; -rfkill_destroy (drv->rfkill); -mutex_destroy (&drv->mtx); -mutex_destroy (&drv->devlist_mtx); -list_for_each_entry_safe (scan, tmp, &drv->bss_list, list) +rfkill_destroy (rdev->rfkill); +mutex_destroy (&rdev->mtx); +mutex_destroy (&rdev->devlist_mtx); +list_for_each_entry_safe (scan, tmp, &rdev->bss_list, list)cfg80211_put_bss (&scan->pub); -kfree (drv); +kfree (rdev); }void wiphy_free (struct wiphy *wiphy)
@@ -581,10 +581,10 @@ EXPORT_SYMBOL(wiphy_free);void wiphy_rfkill_set_hw_state (struct wiphy *wiphy,bool blocked) { -struct cfg80211_registered_device *drv =wiphy_to_dev (wiphy); +struct cfg80211_registered_device *rdev =wiphy_to_dev (wiphy); -if (rfkill_set_hw_state (drv->rfkill, blocked)) -schedule_work (&drv->rfkill_sync); +if (rfkill_set_hw_state (rdev->rfkill, blocked)) +schedule_work (&rdev->rfkill_sync); }EXPORT_SYMBOL (wiphy_rfkill_set_hw_state);
net/wireless/core.h +13 -13
@@ -97,13 +97,13 @@ bool wiphy_idx_valid(int wiphy_idx) }extern struct mutex cfg80211_mutex; -extern struct list_head cfg80211_drv_list; +extern struct list_head cfg80211_rdev_list;#define assert_cfg80211_lock () WARN_ON(!mutex_is_locked(&cfg80211_mutex))/* * You can use this to mark a wiphy_idx as not having an associated wiphy. -* It guarantees cfg80211_drv_by_wiphy_idx(wiphy_idx) will return NULL +* It guarantees cfg80211_rdev_by_wiphy_idx(wiphy_idx) will return NULL */ #define WIPHY_IDX_STALE -1
@@ -136,11 +136,11 @@ static inline void cfg80211_unhold_bss(s } -struct cfg80211_registered_device *cfg80211_drv_by_wiphy_idx (int wiphy_idx); +struct cfg80211_registered_device *cfg80211_rdev_by_wiphy_idx (int wiphy_idx);int get_wiphy_idx (struct wiphy *wiphy);struct cfg80211_registered_device * -__cfg80211_drv_from_info (struct genl_info *info); +__cfg80211_rdev_from_info (struct genl_info *info);/* * This function returns a pointer to the driver
@@ -153,7 +153,7 @@ __cfg80211_drv_from_info(struct genl_inf* * This is necessary because we need to lock the global * mutex to get an item off the list safely, and then -* we lock the drv mutex so it doesn't go away under us. +* we lock the rdev mutex so it doesn't go away under us. * * We don't want to keep cfg80211_mutex locked * for all the time in order to allow requests on
@@ -165,22 +165,22 @@ __cfg80211_drv_from_info(struct genl_infextern struct cfg80211_registered_device *cfg80211_get_dev_from_info (struct genl_info *info); -/* requires cfg80211_drv_mutex to be held! */ +/* requires cfg80211_rdev_mutex to be held! */ struct wiphy *wiphy_idx_to_wiphy (int wiphy_idx);/* identical to cfg80211_get_dev_from_info but only operate on ifindex */ extern struct cfg80211_registered_device *cfg80211_get_dev_from_ifindex (int ifindex); -static inline void cfg80211_lock_rdev (struct cfg80211_registered_device *drv) +static inline void cfg80211_lock_rdev (struct cfg80211_registered_device *rdev) { -mutex_lock (&drv->mtx); +mutex_lock (&rdev->mtx); } -static inline void cfg80211_unlock_rdev (struct cfg80211_registered_device *drv) +static inline void cfg80211_unlock_rdev (struct cfg80211_registered_device *rdev) { -BUG_ON (IS_ERR (drv) || !drv); -mutex_unlock (&drv->mtx); +BUG_ON (IS_ERR (rdev) || !rdev); +mutex_unlock (&rdev->mtx); }static inline void wdev_lock (struct wireless_dev *wdev)
@@ -240,9 +240,9 @@ struct cfg80211_event {/* free object */ -extern void cfg80211_dev_free (struct cfg80211_registered_device *drv); +extern void cfg80211_dev_free (struct cfg80211_registered_device *rdev); -extern int cfg80211_dev_rename (struct cfg80211_registered_device *drv, +extern int cfg80211_dev_rename (struct cfg80211_registered_device *rdev,char *newname);void ieee80211_set_bitrate_flags (struct wiphy *wiphy);
net/wireless/debugfs.c +7 -7
@@ -104,15 +104,15 @@ static const struct file_operations ht40 };#define DEBUGFS_ADD (name) \ - drv->debugfs.name = debugfs_create_file(#name, S_IRUGO, phyd, \ - &drv->wiphy, &name## _ops); + rdev->debugfs.name = debugfs_create_file(#name, S_IRUGO, phyd, \ + &rdev->wiphy, &name## _ops);#define DEBUGFS_DEL (name) \ - debugfs_remove(drv->debugfs.name); \ - drv->debugfs.name = NULL; + debugfs_remove(rdev->debugfs.name); \ + rdev->debugfs.name = NULL; -void cfg80211_debugfs_drv_add (struct cfg80211_registered_device *drv) +void cfg80211_debugfs_rdev_add (struct cfg80211_registered_device *rdev) { -struct dentry *phyd = drv->wiphy.debugfsdir; +struct dentry *phyd = rdev->wiphy.debugfsdir;DEBUGFS_ADD (rts_threshold);DEBUGFS_ADD (fragmentation_threshold);
@@ -121,7 +121,7 @@ void cfg80211_debugfs_drv_add(struct cfgDEBUGFS_ADD (ht40allow_map); } -void cfg80211_debugfs_drv_del (struct cfg80211_registered_device *drv) +void cfg80211_debugfs_rdev_del (struct cfg80211_registered_device *rdev) {DEBUGFS_DEL (rts_threshold);DEBUGFS_DEL (fragmentation_threshold);
net/wireless/debugfs.h +4 -4
@@ -2,13 +2,13 @@#define __CFG80211_DEBUGFS_H#ifdef CONFIG_CFG80211_DEBUGFS -void cfg80211_debugfs_drv_add (struct cfg80211_registered_device *drv); -void cfg80211_debugfs_drv_del (struct cfg80211_registered_device *drv); +void cfg80211_debugfs_rdev_add (struct cfg80211_registered_device *rdev); +void cfg80211_debugfs_rdev_del (struct cfg80211_registered_device *rdev);#else static inline -void cfg80211_debugfs_drv_add (struct cfg80211_registered_device *drv) {} +void cfg80211_debugfs_rdev_add (struct cfg80211_registered_device *rdev) {}static inline -void cfg80211_debugfs_drv_del (struct cfg80211_registered_device *drv) {} +void cfg80211_debugfs_rdev_del (struct cfg80211_registered_device *rdev) {}#endif #endif /* __CFG80211_DEBUGFS_H */
net/wireless/nl80211.c +170 -170
1,105 lines not on this page · raw message
net/wireless/reg.c +24 -24
113 lines not on this page · raw message
net/wireless/sme.c +24 -24
141 lines not on this page · raw message
Johannes Berg
maintainerPATCH 9/9 cfg80211: disallow configuring unsupported interfaces
In reply to Johannes BergIn order to force drivers to advertise their interface types, don't just disallow creating new interfaces with unadvertised types but also disallow setting them UP. Additionally, add some validation on the operations the drivers support.
--- net/wireless/core.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
net/wireless/core.c +9 -2
@@ -331,8 +331,13 @@ struct wiphy *wiphy_new(const struct cfgstruct cfg80211_registered_device *rdev;int alloc_size; -WARN_ON (!ops->add_key && ops->del_key); -WARN_ON (ops->add_key && !ops->del_key); +WARN_ON (ops->add_key && (!ops->del_key || !ops->set_default_key)); +WARN_ON (ops->auth && (!ops->assoc || !ops->deauth || !ops->disassoc)); +WARN_ON (ops->connect && !ops->disconnect); +WARN_ON (ops->join_ibss && !ops->leave_ibss); +WARN_ON (ops->add_virtual_intf && !ops->del_virtual_intf); +WARN_ON (ops->add_station && !ops->del_station); +WARN_ON (ops->add_mpath && !ops->del_mpath); alloc_size =sizeof (*rdev) + sizeof_priv;
@@ -687,6 +692,8 @@ static int cfg80211_netdev_notifier_callmutex_destroy (&wdev->mtx);break ;case NETDEV_PRE_UP : +if (!(wdev->wiphy->interface_modes &BIT (wdev->iftype))) +return notifier_from_errno (-EOPNOTSUPP );if (rfkill_blocked (rdev->rfkill))return notifier_from_errno (-ERFKILL );break ;