Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f5ea9120 authored by Johannes Berg's avatar Johannes Berg Committed by John W. Linville
Browse files

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: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent f401a6f7
Loading
Loading
Loading
Loading
+12 −5
Original line number Original line Diff line number Diff line
@@ -480,10 +480,6 @@ enum nl80211_commands {
 * @NL80211_ATTR_SCAN_FREQUENCIES: nested attribute with frequencies (in MHz)
 * @NL80211_ATTR_SCAN_FREQUENCIES: nested attribute with frequencies (in MHz)
 * @NL80211_ATTR_SCAN_SSIDS: nested attribute with SSIDs, leave out for passive
 * @NL80211_ATTR_SCAN_SSIDS: nested attribute with SSIDs, leave out for passive
 *	scanning and include a zero-length SSID (wildcard) for wildcard scan
 *	scanning and include a zero-length SSID (wildcard) for wildcard scan
 * @NL80211_ATTR_SCAN_GENERATION: the scan generation increases whenever the
 *	scan result list changes (BSS expired or added) so that applications
 *	can verify that they got a single, consistent snapshot (when all dump
 *	messages carried the same generation number)
 * @NL80211_ATTR_BSS: scan result BSS
 * @NL80211_ATTR_BSS: scan result BSS
 *
 *
 * @NL80211_ATTR_REG_INITIATOR: indicates who requested the regulatory domain
 * @NL80211_ATTR_REG_INITIATOR: indicates who requested the regulatory domain
@@ -580,6 +576,14 @@ enum nl80211_commands {
 *
 *
 * @NL80211_ATTR_PID: Process ID of a network namespace.
 * @NL80211_ATTR_PID: Process ID of a network namespace.
 *
 *
 * @NL80211_ATTR_GENERATION: Used to indicate consistent snapshots for
 *	dumps. This number increases whenever the object list being
 *	dumped changes, and as such userspace can verify that it has
 *	obtained a complete and consistent snapshot by verifying that
 *	all dump messages contain the same generation number. If it
 *	changed then the list changed and the dump should be repeated
 *	completely from scratch.
 *
 * @NL80211_ATTR_MAX: highest attribute number currently defined
 * @NL80211_ATTR_MAX: highest attribute number currently defined
 * @__NL80211_ATTR_AFTER_LAST: internal use
 * @__NL80211_ATTR_AFTER_LAST: internal use
 */
 */
@@ -651,7 +655,7 @@ enum nl80211_attrs {


	NL80211_ATTR_SCAN_FREQUENCIES,
	NL80211_ATTR_SCAN_FREQUENCIES,
	NL80211_ATTR_SCAN_SSIDS,
	NL80211_ATTR_SCAN_SSIDS,
	NL80211_ATTR_SCAN_GENERATION,
	NL80211_ATTR_GENERATION, /* replaces old SCAN_GENERATION */
	NL80211_ATTR_BSS,
	NL80211_ATTR_BSS,


	NL80211_ATTR_REG_INITIATOR,
	NL80211_ATTR_REG_INITIATOR,
@@ -716,6 +720,9 @@ enum nl80211_attrs {
	NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1
	NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1
};
};


/* source-level API compatibility */
#define NL80211_ATTR_SCAN_GENERATION NL80211_ATTR_GENERATION

/*
/*
 * Allow user space programs to use #ifdef on new attributes by defining them
 * Allow user space programs to use #ifdef on new attributes by defining them
 * here
 * here
+12 −0
Original line number Original line Diff line number Diff line
@@ -372,6 +372,10 @@ struct rate_info {
 * @txrate: current unicast bitrate to this station
 * @txrate: current unicast bitrate to this station
 * @rx_packets: packets received from this station
 * @rx_packets: packets received from this station
 * @tx_packets: packets transmitted to this station
 * @tx_packets: packets transmitted to this station
 * @generation: generation number for nl80211 dumps.
 *	This number should increase every time the list of stations
 *	changes, i.e. when a station is added or removed, so that
 *	userspace can tell whether it got a consistent snapshot.
 */
 */
struct station_info {
struct station_info {
	u32 filled;
	u32 filled;
@@ -385,6 +389,8 @@ struct station_info {
	struct rate_info txrate;
	struct rate_info txrate;
	u32 rx_packets;
	u32 rx_packets;
	u32 tx_packets;
	u32 tx_packets;

	int generation;
};
};


/**
/**
@@ -444,6 +450,10 @@ enum mpath_info_flags {
 * @flags: mesh path flags
 * @flags: mesh path flags
 * @discovery_timeout: total mesh path discovery timeout, in msecs
 * @discovery_timeout: total mesh path discovery timeout, in msecs
 * @discovery_retries: mesh path discovery retries
 * @discovery_retries: mesh path discovery retries
 * @generation: generation number for nl80211 dumps.
 *	This number should increase every time the list of mesh paths
 *	changes, i.e. when a station is added or removed, so that
 *	userspace can tell whether it got a consistent snapshot.
 */
 */
struct mpath_info {
struct mpath_info {
	u32 filled;
	u32 filled;
@@ -454,6 +464,8 @@ struct mpath_info {
	u32 discovery_timeout;
	u32 discovery_timeout;
	u8 discovery_retries;
	u8 discovery_retries;
	u8 flags;
	u8 flags;

	int generation;
};
};


/**
/**
+4 −0
Original line number Original line Diff line number Diff line
@@ -323,6 +323,8 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
{
{
	struct ieee80211_sub_if_data *sdata = sta->sdata;
	struct ieee80211_sub_if_data *sdata = sta->sdata;


	sinfo->generation = sdata->local->sta_generation;

	sinfo->filled = STATION_INFO_INACTIVE_TIME |
	sinfo->filled = STATION_INFO_INACTIVE_TIME |
			STATION_INFO_RX_BYTES |
			STATION_INFO_RX_BYTES |
			STATION_INFO_TX_BYTES |
			STATION_INFO_TX_BYTES |
@@ -909,6 +911,8 @@ static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
	else
	else
		memset(next_hop, 0, ETH_ALEN);
		memset(next_hop, 0, ETH_ALEN);


	pinfo->generation = mesh_paths_generation;

	pinfo->filled = MPATH_INFO_FRAME_QLEN |
	pinfo->filled = MPATH_INFO_FRAME_QLEN |
			MPATH_INFO_DSN |
			MPATH_INFO_DSN |
			MPATH_INFO_METRIC |
			MPATH_INFO_METRIC |
+1 −0
Original line number Original line Diff line number Diff line
@@ -678,6 +678,7 @@ struct ieee80211_local {
	struct list_head sta_list;
	struct list_head sta_list;
	struct sta_info *sta_hash[STA_HASH_SIZE];
	struct sta_info *sta_hash[STA_HASH_SIZE];
	struct timer_list sta_cleanup;
	struct timer_list sta_cleanup;
	int sta_generation;


	struct sk_buff_head pending[IEEE80211_MAX_QUEUES];
	struct sk_buff_head pending[IEEE80211_MAX_QUEUES];
	struct tasklet_struct tx_pending_tasklet;
	struct tasklet_struct tx_pending_tasklet;
+2 −0
Original line number Original line Diff line number Diff line
@@ -265,6 +265,8 @@ void mesh_path_discard_frame(struct sk_buff *skb,
void mesh_path_quiesce(struct ieee80211_sub_if_data *sdata);
void mesh_path_quiesce(struct ieee80211_sub_if_data *sdata);
void mesh_path_restart(struct ieee80211_sub_if_data *sdata);
void mesh_path_restart(struct ieee80211_sub_if_data *sdata);


extern int mesh_paths_generation;

#ifdef CONFIG_MAC80211_MESH
#ifdef CONFIG_MAC80211_MESH
extern int mesh_allocated;
extern int mesh_allocated;


Loading