提交 b60ad348 编写于 作者: J Johannes Berg

cfg80211: move cookie_counter out of wiphy

There's no reason for drivers to be able to access the
cfg80211 internal cookie counter; move it out of the
wiphy into the rdev structure.

While at it, also make it never assign 0 as a cookie
(we consider that invalid in some places), and warn if
we manage to do that for some reason (wrapping is not
likely to happen with a u64.)
Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
上级 71e5e886
...@@ -4012,7 +4012,6 @@ struct wiphy_iftype_ext_capab { ...@@ -4012,7 +4012,6 @@ struct wiphy_iftype_ext_capab {
* by the driver in the .connect() callback. The bit position maps to the * by the driver in the .connect() callback. The bit position maps to the
* attribute indices defined in &enum nl80211_bss_select_attr. * attribute indices defined in &enum nl80211_bss_select_attr.
* *
* @cookie_counter: unique generic cookie counter, used to identify objects.
* @nan_supported_bands: bands supported by the device in NAN mode, a * @nan_supported_bands: bands supported by the device in NAN mode, a
* bitmap of &enum nl80211_band values. For instance, for * bitmap of &enum nl80211_band values. For instance, for
* NL80211_BAND_2GHZ, bit 0 would be set * NL80211_BAND_2GHZ, bit 0 would be set
...@@ -4151,8 +4150,6 @@ struct wiphy { ...@@ -4151,8 +4150,6 @@ struct wiphy {
u32 bss_select_support; u32 bss_select_support;
u64 cookie_counter;
u8 nan_supported_bands; u8 nan_supported_bands;
u32 txq_limit; u32 txq_limit;
......
...@@ -66,6 +66,7 @@ struct cfg80211_registered_device { ...@@ -66,6 +66,7 @@ struct cfg80211_registered_device {
/* protected by RTNL only */ /* protected by RTNL only */
int num_running_ifaces; int num_running_ifaces;
int num_running_monitor_ifaces; int num_running_monitor_ifaces;
u64 cookie_counter;
/* BSSes/scanning */ /* BSSes/scanning */
spinlock_t bss_lock; spinlock_t bss_lock;
...@@ -133,6 +134,16 @@ cfg80211_rdev_free_wowlan(struct cfg80211_registered_device *rdev) ...@@ -133,6 +134,16 @@ cfg80211_rdev_free_wowlan(struct cfg80211_registered_device *rdev)
#endif #endif
} }
static inline u64 cfg80211_assign_cookie(struct cfg80211_registered_device *rdev)
{
u64 r = ++rdev->cookie_counter;
if (WARN_ON(r == 0))
r = ++rdev->cookie_counter;
return r;
}
extern struct workqueue_struct *cfg80211_wq; extern struct workqueue_struct *cfg80211_wq;
extern struct list_head cfg80211_rdev_list; extern struct list_head cfg80211_rdev_list;
extern int cfg80211_rdev_list_generation; extern int cfg80211_rdev_list_generation;
......
...@@ -7803,7 +7803,7 @@ static int nl80211_start_sched_scan(struct sk_buff *skb, ...@@ -7803,7 +7803,7 @@ static int nl80211_start_sched_scan(struct sk_buff *skb,
*/ */
if (want_multi && rdev->wiphy.max_sched_scan_reqs > 1) { if (want_multi && rdev->wiphy.max_sched_scan_reqs > 1) {
while (!sched_scan_req->reqid) while (!sched_scan_req->reqid)
sched_scan_req->reqid = rdev->wiphy.cookie_counter++; sched_scan_req->reqid = cfg80211_assign_cookie(rdev);
} }
err = rdev_sched_scan_start(rdev, dev, sched_scan_req); err = rdev_sched_scan_start(rdev, dev, sched_scan_req);
...@@ -11798,7 +11798,7 @@ static int nl80211_nan_add_func(struct sk_buff *skb, ...@@ -11798,7 +11798,7 @@ static int nl80211_nan_add_func(struct sk_buff *skb,
if (!func) if (!func)
return -ENOMEM; return -ENOMEM;
func->cookie = wdev->wiphy->cookie_counter++; func->cookie = cfg80211_assign_cookie(rdev);
if (!tb[NL80211_NAN_FUNC_TYPE] || if (!tb[NL80211_NAN_FUNC_TYPE] ||
nla_get_u8(tb[NL80211_NAN_FUNC_TYPE]) > NL80211_NAN_FUNC_MAX_TYPE) { nla_get_u8(tb[NL80211_NAN_FUNC_TYPE]) > NL80211_NAN_FUNC_MAX_TYPE) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册