diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2009-08-07 10:17:38 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-08-14 09:13:43 -0400 |
commit | f5ea9120be2e5d5c846243416cfdce01d02f5836 (patch) | |
tree | cade27e47a90dde79a523598b96a2ebb50770d2f /net/wireless/nl80211.c | |
parent | f401a6f7ede753e56b84025e7d2db0d5ef560ce6 (diff) |
nl80211: add generation number to all dumps
In order for userspace to be able to figure out whether
it obtained a consistent snapshot of data or not when
using netlink dumps, we need to have a generation number
in each dump message that indicates whether the list has
changed or not -- its value is arbitrary.
This patch adds such a number to all dumps, this needs
some mac80211 involvement to keep track of a generation
number to start with when adding/removing mesh paths or
stations.
The wiphy and netdev lists can be fully handled within
cfg80211, of course, but generation numbers need to be
stored there as well.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/wireless/nl80211.c')
-rw-r--r-- | net/wireless/nl80211.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 2ff7376f35a3..b3d5c1df08dd 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -408,6 +408,9 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, | |||
408 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, dev->wiphy_idx); | 408 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, dev->wiphy_idx); |
409 | NLA_PUT_STRING(msg, NL80211_ATTR_WIPHY_NAME, wiphy_name(&dev->wiphy)); | 409 | NLA_PUT_STRING(msg, NL80211_ATTR_WIPHY_NAME, wiphy_name(&dev->wiphy)); |
410 | 410 | ||
411 | NLA_PUT_U32(msg, NL80211_ATTR_GENERATION, | ||
412 | cfg80211_rdev_list_generation); | ||
413 | |||
411 | NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_RETRY_SHORT, | 414 | NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_RETRY_SHORT, |
412 | dev->wiphy.retry_short); | 415 | dev->wiphy.retry_short); |
413 | NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_RETRY_LONG, | 416 | NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_RETRY_LONG, |
@@ -825,6 +828,11 @@ static int nl80211_send_iface(struct sk_buff *msg, u32 pid, u32 seq, int flags, | |||
825 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); | 828 | NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); |
826 | NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, dev->name); | 829 | NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, dev->name); |
827 | NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, dev->ieee80211_ptr->iftype); | 830 | NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, dev->ieee80211_ptr->iftype); |
831 | |||
832 | NLA_PUT_U32(msg, NL80211_ATTR_GENERATION, | ||
833 | rdev->devlist_generation ^ | ||
834 | (cfg80211_rdev_list_generation << 2)); | ||
835 | |||
828 | return genlmsg_end(msg, hdr); | 836 | return genlmsg_end(msg, hdr); |
829 | 837 | ||
830 | nla_put_failure: | 838 | nla_put_failure: |
@@ -838,12 +846,12 @@ static int nl80211_dump_interface(struct sk_buff *skb, struct netlink_callback * | |||
838 | int if_idx = 0; | 846 | int if_idx = 0; |
839 | int wp_start = cb->args[0]; | 847 | int wp_start = cb->args[0]; |
840 | int if_start = cb->args[1]; | 848 | int if_start = cb->args[1]; |
841 | struct cfg80211_registered_device *dev; | 849 | struct cfg80211_registered_device *rdev; |
842 | struct wireless_dev *wdev; | 850 | struct wireless_dev *wdev; |
843 | 851 | ||
844 | mutex_lock(&cfg80211_mutex); | 852 | mutex_lock(&cfg80211_mutex); |
845 | list_for_each_entry(dev, &cfg80211_rdev_list, list) { | 853 | list_for_each_entry(rdev, &cfg80211_rdev_list, list) { |
846 | if (!net_eq(wiphy_net(&dev->wiphy), sock_net(skb->sk))) | 854 | if (!net_eq(wiphy_net(&rdev->wiphy), sock_net(skb->sk))) |
847 | continue; | 855 | continue; |
848 | if (wp_idx < wp_start) { | 856 | if (wp_idx < wp_start) { |
849 | wp_idx++; | 857 | wp_idx++; |
@@ -851,21 +859,21 @@ static int nl80211_dump_interface(struct sk_buff *skb, struct netlink_callback * | |||
851 | } | 859 | } |
852 | if_idx = 0; | 860 | if_idx = 0; |
853 | 861 | ||
854 | mutex_lock(&dev->devlist_mtx); | 862 | mutex_lock(&rdev->devlist_mtx); |
855 | list_for_each_entry(wdev, &dev->netdev_list, list) { | 863 | list_for_each_entry(wdev, &rdev->netdev_list, list) { |
856 | if (if_idx < if_start) { | 864 | if (if_idx < if_start) { |
857 | if_idx++; | 865 | if_idx++; |
858 | continue; | 866 | continue; |
859 | } | 867 | } |
860 | if (nl80211_send_iface(skb, NETLINK_CB(cb->skb).pid, | 868 | if (nl80211_send_iface(skb, NETLINK_CB(cb->skb).pid, |
861 | cb->nlh->nlmsg_seq, NLM_F_MULTI, | 869 | cb->nlh->nlmsg_seq, NLM_F_MULTI, |
862 | dev, wdev->netdev) < 0) { | 870 | rdev, wdev->netdev) < 0) { |
863 | mutex_unlock(&dev->devlist_mtx); | 871 | mutex_unlock(&rdev->devlist_mtx); |
864 | goto out; | 872 | goto out; |
865 | } | 873 | } |
866 | if_idx++; | 874 | if_idx++; |
867 | } | 875 | } |
868 | mutex_unlock(&dev->devlist_mtx); | 876 | mutex_unlock(&rdev->devlist_mtx); |
869 | 877 | ||
870 | wp_idx++; | 878 | wp_idx++; |
871 | } | 879 | } |
@@ -1616,6 +1624,8 @@ static int nl80211_send_station(struct sk_buff *msg, u32 pid, u32 seq, | |||
1616 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); | 1624 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); |
1617 | NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr); | 1625 | NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr); |
1618 | 1626 | ||
1627 | NLA_PUT_U32(msg, NL80211_ATTR_GENERATION, sinfo->generation); | ||
1628 | |||
1619 | sinfoattr = nla_nest_start(msg, NL80211_ATTR_STA_INFO); | 1629 | sinfoattr = nla_nest_start(msg, NL80211_ATTR_STA_INFO); |
1620 | if (!sinfoattr) | 1630 | if (!sinfoattr) |
1621 | goto nla_put_failure; | 1631 | goto nla_put_failure; |
@@ -2101,6 +2111,8 @@ static int nl80211_send_mpath(struct sk_buff *msg, u32 pid, u32 seq, | |||
2101 | NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, dst); | 2111 | NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, dst); |
2102 | NLA_PUT(msg, NL80211_ATTR_MPATH_NEXT_HOP, ETH_ALEN, next_hop); | 2112 | NLA_PUT(msg, NL80211_ATTR_MPATH_NEXT_HOP, ETH_ALEN, next_hop); |
2103 | 2113 | ||
2114 | NLA_PUT_U32(msg, NL80211_ATTR_GENERATION, pinfo->generation); | ||
2115 | |||
2104 | pinfoattr = nla_nest_start(msg, NL80211_ATTR_MPATH_INFO); | 2116 | pinfoattr = nla_nest_start(msg, NL80211_ATTR_MPATH_INFO); |
2105 | if (!pinfoattr) | 2117 | if (!pinfoattr) |
2106 | goto nla_put_failure; | 2118 | goto nla_put_failure; |
@@ -3090,8 +3102,7 @@ static int nl80211_send_bss(struct sk_buff *msg, u32 pid, u32 seq, int flags, | |||
3090 | if (!hdr) | 3102 | if (!hdr) |
3091 | return -1; | 3103 | return -1; |
3092 | 3104 | ||
3093 | NLA_PUT_U32(msg, NL80211_ATTR_SCAN_GENERATION, | 3105 | NLA_PUT_U32(msg, NL80211_ATTR_GENERATION, rdev->bss_generation); |
3094 | rdev->bss_generation); | ||
3095 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, wdev->netdev->ifindex); | 3106 | NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, wdev->netdev->ifindex); |
3096 | 3107 | ||
3097 | bss = nla_nest_start(msg, NL80211_ATTR_BSS); | 3108 | bss = nla_nest_start(msg, NL80211_ATTR_BSS); |