Commit 9720bb3a authored by Johannes Berg's avatar Johannes Berg Committed by John W. Linville

nl80211: use netlink consistent dump feature for BSS dumps

Use the new consistent dump feature from (generic) netlink
to advertise when dumps are incomplete.

Readers may note that this does not initialize the
rdev->bss_generation counter to a non-zero value. This is
still OK since the value is modified only under spinlock
when the list is modified. Since the dump code holds the
spinlock, the value will either be > 0 already, or the
list will still be empty in which case a consistent dump
will actually be made (and be empty).
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent a5ffddb7
...@@ -3620,7 +3620,8 @@ static int nl80211_stop_sched_scan(struct sk_buff *skb, ...@@ -3620,7 +3620,8 @@ static int nl80211_stop_sched_scan(struct sk_buff *skb,
return __cfg80211_stop_sched_scan(rdev, false); return __cfg80211_stop_sched_scan(rdev, false);
} }
static int nl80211_send_bss(struct sk_buff *msg, u32 pid, u32 seq, int flags, static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb,
u32 seq, int flags,
struct cfg80211_registered_device *rdev, struct cfg80211_registered_device *rdev,
struct wireless_dev *wdev, struct wireless_dev *wdev,
struct cfg80211_internal_bss *intbss) struct cfg80211_internal_bss *intbss)
...@@ -3632,11 +3633,13 @@ static int nl80211_send_bss(struct sk_buff *msg, u32 pid, u32 seq, int flags, ...@@ -3632,11 +3633,13 @@ static int nl80211_send_bss(struct sk_buff *msg, u32 pid, u32 seq, int flags,
ASSERT_WDEV_LOCK(wdev); ASSERT_WDEV_LOCK(wdev);
hdr = nl80211hdr_put(msg, pid, seq, flags, hdr = nl80211hdr_put(msg, NETLINK_CB(cb->skb).pid, seq, flags,
NL80211_CMD_NEW_SCAN_RESULTS); NL80211_CMD_NEW_SCAN_RESULTS);
if (!hdr) if (!hdr)
return -1; return -1;
genl_dump_check_consistent(cb, hdr, &nl80211_fam);
NLA_PUT_U32(msg, NL80211_ATTR_GENERATION, rdev->bss_generation); NLA_PUT_U32(msg, NL80211_ATTR_GENERATION, rdev->bss_generation);
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, wdev->netdev->ifindex); NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, wdev->netdev->ifindex);
...@@ -3725,11 +3728,12 @@ static int nl80211_dump_scan(struct sk_buff *skb, ...@@ -3725,11 +3728,12 @@ static int nl80211_dump_scan(struct sk_buff *skb,
spin_lock_bh(&rdev->bss_lock); spin_lock_bh(&rdev->bss_lock);
cfg80211_bss_expire(rdev); cfg80211_bss_expire(rdev);
cb->seq = rdev->bss_generation;
list_for_each_entry(scan, &rdev->bss_list, list) { list_for_each_entry(scan, &rdev->bss_list, list) {
if (++idx <= start) if (++idx <= start)
continue; continue;
if (nl80211_send_bss(skb, if (nl80211_send_bss(skb, cb,
NETLINK_CB(cb->skb).pid,
cb->nlh->nlmsg_seq, NLM_F_MULTI, cb->nlh->nlmsg_seq, NLM_F_MULTI,
rdev, wdev, scan) < 0) { rdev, wdev, scan) < 0) {
idx--; idx--;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment