o11s: (nl80211/cfg80211) support for mesh interfaces and mesh paths
PATCH v2 1/13 o11s: (nl80211/cfg80211) support for mesh interfaces and mesh paths
Added support for mesh id and mesh path operation.
--- include/linux/nl80211.h | 119 +++++++++++-- include/net/cfg80211.h | 139 +++++++++++++-- net/wireless/nl80211.c | 438 ++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 639 insertions(+), 57 deletions(-)
include/linux/nl80211.h +101 -18
@@ -78,6 +78,18 @@* or, if no MAC address given, all stations, on the interface identified * by %NL80211_ATTR_IFINDEX. * +* @NL80211_CMD_GET_MPATH: Get mesh path attributes for mesh path to +* destination %NL80211_ATTR_MAC on the interface identified by +* %NL80211_ATTR_IFINDEX. +* @NL80211_CMD_SET_MPATH: Set mesh path attributes for mesh path to +* destination %NL80211_ATTR_MAC on the interface identified by +* %NL80211_ATTR_IFINDEX. +* @NL80211_CMD_NEW_PATH: Add a mesh path with given attributes to the +* the interface identified by %NL80211_ATTR_IFINDEX. +* @NL80211_CMD_DEL_PATH: Remove a mesh path identified by %NL80211_ATTR_MAC +* or, if no MAC address given, all mesh paths, on the interface identified +* by %NL80211_ATTR_IFINDEX. +* * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use */
@@ -112,6 +124,11 @@ enum nl80211_commands {/* add commands here */ +NL80211_CMD_GET_MPATH , +NL80211_CMD_SET_MPATH , +NL80211_CMD_NEW_MPATH , +NL80211_CMD_DEL_MPATH , +/* used to define NL80211_CMD_MAX below */ __NL80211_CMD_AFTER_LAST,NL80211_CMD_MAX = __NL80211_CMD_AFTER_LAST -1
@@ -157,13 +174,21 @@ enum nl80211_commands {* restriction (at most %NL80211_MAX_SUPP_RATES). * @NL80211_ATTR_STA_VLAN: interface index of VLAN interface to move station * to, or the AP interface the station was originally added to to. -* @NL80211_ATTR_STA_STATS: statistics for a station, part of station info +* @NL80211_ATTR_STA_INFO: information about a station, part of station info * given for %NL80211_CMD_GET_STATION, nested attribute containing -* info as possible, see &enum nl80211_sta_stats. +* info as possible, see &enum nl80211_sta_info. * * @NL80211_ATTR_WIPHY_BANDS: Information about an operating bands, * consisting of a nested array. * +* @NL80211_ATTR_MESH_ID: mesh id (1-32 bytes). +* @NL80211_ATTR_PLINK_ACTION: action to perform on the mesh peer link. +* @NL80211_ATTR_MPATH_NEXT_HOP: MAC address of the next hop for a mesh path. +* @NL80211_ATTR_MPATH_INFO: information about a mesh_path, part of mesh path +* info given for %NL80211_CMD_GET_MPATH, nested attribute described at +* &enum nl80211_mpath_info. +* +* * @NL80211_ATTR_MNTR_FLAGS: flags, nested element with NLA_FLAG attributes of * &enum nl80211_mntr_flags. *
@@ -199,7 +224,7 @@ enum nl80211_attrs {NL80211_ATTR_STA_LISTEN_INTERVAL ,NL80211_ATTR_STA_SUPPORTED_RATES ,NL80211_ATTR_STA_VLAN , -NL80211_ATTR_STA_STATS , +NL80211_ATTR_STA_INFO , NL80211_ATTR_WIPHY_BANDS,
@@ -207,6 +232,11 @@ enum nl80211_attrs {/* add attributes here, update the policy in nl80211.c */ +NL80211_ATTR_MESH_ID , +NL80211_ATTR_STA_PLINK_ACTION , +NL80211_ATTR_MPATH_NEXT_HOP , +NL80211_ATTR_MPATH_INFO , + __NL80211_ATTR_AFTER_LAST, NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1 };
@@ -223,6 +253,7 @@ enum nl80211_attrs {* @NL80211_IFTYPE_AP_VLAN: VLAN interface for access points * @NL80211_IFTYPE_WDS: wireless distribution interface * @NL80211_IFTYPE_MONITOR: monitor interface receiving all frames +* @NL80211_IFTYPE_MESH_POINT: mesh point * @NL80211_IFTYPE_MAX: highest interface type number currently defined * @__NL80211_IFTYPE_AFTER_LAST: internal use *
@@ -238,6 +269,7 @@ enum nl80211_iftype {NL80211_IFTYPE_AP_VLAN ,NL80211_IFTYPE_WDS ,NL80211_IFTYPE_MONITOR , +NL80211_IFTYPE_MESH_POINT ,/* keep last */ __NL80211_IFTYPE_AFTER_LAST,
@@ -267,27 +299,78 @@ enum nl80211_sta_flags { };/** -* enum nl80211_sta_stats - station statistics +* enum nl80211_sta_info - station information * -* These attribute types are used with %NL80211_ATTR_STA_STATS +* These attribute types are used with %NL80211_ATTR_STA_INFO * when getting information about a station. * -* @__NL80211_STA_STAT_INVALID: attribute number 0 is reserved -* @NL80211_STA_STAT_INACTIVE_TIME: time since last activity (u32, msecs) -* @NL80211_STA_STAT_RX_BYTES: total received bytes (u32, from this station) -* @NL80211_STA_STAT_TX_BYTES: total transmitted bytes (u32, to this station) -* @__NL80211_STA_STAT_AFTER_LAST: internal -* @NL80211_STA_STAT_MAX: highest possible station stats attribute +* @__NL80211_STA_INFO_INVALID: attribute number 0 is reserved +* @NL80211_STA_INFO_INACTIVE_TIME: time since last activity (u32, msecs) +* @NL80211_STA_INFO_RX_BYTES: total received bytes (u32, from this station) +* @NL80211_STA_INFO_TX_BYTES: total transmitted bytes (u32, to this station) +* @__NL80211_STA_INFO_AFTER_LAST: internal +* @NL80211_STA_INFO_MAX: highest possible station info attribute +*/ +enum nl80211_sta_info { + __NL80211_STA_INFO_INVALID, +NL80211_STA_INFO_INACTIVE_TIME , +NL80211_STA_INFO_RX_BYTES , +NL80211_STA_INFO_TX_BYTES , +NL80211_STA_INFO_LLID , +NL80211_STA_INFO_PLID , +NL80211_STA_INFO_PLINK_STATE , + +/* keep last */ + __NL80211_STA_INFO_AFTER_LAST, +NL80211_STA_INFO_MAX = __NL80211_STA_INFO_AFTER_LAST -1 +}; + +/** +* enum nl80211_mpath_flags - nl80211 mesh path flags +* +* @NL80211_MPATH_FLAG_ACTIVE: the mesh path is active +* @NL80211_MPATH_FLAG_RESOLVING: the mesh path discovery process is running +* @NL80211_MPATH_FLAG_DSN_VALID: the mesh path contains a valid DSN +* @NL80211_MPATH_FLAG_FIXED: the mesh path has been manually set +* @NL80211_MPATH_FLAG_RESOLVED: the mesh path discovery process succeeded +*/ +enum nl80211_mpath_flags { +NL80211_MPATH_FLAG_ACTIVE =1 <<0 , +NL80211_MPATH_FLAG_RESOLVING =1 <<1 , +NL80211_MPATH_FLAG_DSN_VALID =1 <<2 , +NL80211_MPATH_FLAG_FIXED =1 <<3 , +NL80211_MPATH_FLAG_RESOLVED =1 <<4 , +}; + +/** +* enum nl80211_mpath_info - mesh path information +* +* These attribute types are used with %NL80211_ATTR_MPATH_INFO when getting +* information about a mesh path. +* +* @__NL80211_MPATH_INFO_INVALID: attribute number 0 is reserved +* @NL80211_ATTR_MPATH_FRAME_QLEN: number of queued frames for this destination +* @NL80211_ATTR_MPATH_DSN: destination sequence number +* @NL80211_ATTR_MPATH_METRIC: metric (cost) of this mesh path +* @NL80211_ATTR_MPATH_EXPTIME: expiration time for the path, in msec from now +* @NL80211_ATTR_MPATH_FLAGS: mesh path flags, enumerated in +* &enum nl80211_mpath_flags; +* @NL80211_ATTR_MPATH_DISCOVERY_TIMEOUT: total path discovery timeout, in msec +* @NL80211_ATTR_MPATH_DISCOVERY_RETRIES: mesh path discovery retries */ -enum nl80211_sta_stats { - __NL80211_STA_STAT_INVALID, -NL80211_STA_STAT_INACTIVE_TIME , -NL80211_STA_STAT_RX_BYTES , -NL80211_STA_STAT_TX_BYTES , +enum nl80211_mpath_info { + __NL80211_MPATH_INFO_INVALID, +NL80211_MPATH_INFO_FRAME_QLEN , +NL80211_MPATH_INFO_DSN , +NL80211_MPATH_INFO_METRIC , +NL80211_MPATH_INFO_EXPTIME , +NL80211_MPATH_INFO_FLAGS , +NL80211_MPATH_INFO_DISCOVERY_TIMEOUT , +NL80211_MPATH_INFO_DISCOVERY_RETRIES ,/* keep last */ - __NL80211_STA_STAT_AFTER_LAST, -NL80211_STA_STAT_MAX = __NL80211_STA_STAT_AFTER_LAST -1 + __NL80211_MPATH_INFO_AFTER_LAST, +NL80211_MPATH_INFO_MAX = __NL80211_MPATH_INFO_AFTER_LAST -1 };/**
include/net/cfg80211.h +122 -17
199 lines not on this page · raw message
net/wireless/nl80211.c +416 -22
559 lines not on this page · raw message
Signature · 1 line
1.5.2.5
Johannes Berg
maintainerQuoted 1 line · Luis Carlos Cobo
Added support for mesh id and mesh path operation.
Looks great, a few minor comments.
Quoted 11 lines
include/net/cfg80211.h +9
-0+/** +* struct vif_params - describes virtual interface parameters +* @mesh_id: mesh ID to use +* @mesh_id_len: length of the mesh ID +*/ +struct vif_params { +u8 *mesh_id; +int mesh_id_len; +};int (*add_virtual_intf)(struct wiphy *wiphy, char *name,
include/net/cfg80211.h struct wiphy; · line 325
Quoted 3 lines
include/net/cfg80211.h +2
-1- enum nl80211_iftype type, u32 *flags); + enum nl80211_iftype type, u32 *flags, + struct vif_params *params);
I think we should move flags into the params struct, but we can do that in a follow-up patch.
include/net/cfg80211.h struct cfg80211_ops { · line 359
Quoted 2 lines
include/net/cfg80211.h +2
-0+int (*dump_station)(struct wiphy *wiphy,struct net_device *dev, +int idx,u8 *mac,struct station_info *sinfo);
How do you use this? I can see that the "idx" is used to iterate, but this cannot possibly provide race-free access because the implementation in mac80211's cfg.c needs to give up the lock. I think we need to change this to
int (*dump_stations)(wiphy, dev,
void (*callback)(wiphy, dev, data, mac, sinfo), void *data);
The same seems to apply to nl80211_dump_mpath() and the corresponding callback.
An alternative would be to provide start_station_dump() and stop_station_dump() callbacks for the locking, or, something I wouldn't really like to see, document the interface to lock when idx == 0 and unlock when the return value is -ENOENT or something...
The rest looks fine.
johannes
Johannes Berg
maintainerQuoted 13 lines
include/net/cfg80211.h struct cfg80211_ops { · line 359
Quoted 3 lines
include/net/cfg80211.h +2
-0+int (*dump_station)(struct wiphy *wiphy,struct net_device *dev, +int idx,u8 *mac,struct station_info *sinfo);How do you use this? I can see that the "idx" is used to iterate, but this cannot possibly provide race-free access because the implementation in mac80211's
cfg.cneeds to give up the lock. I think we need to change this toint (*dump_stations)(wiphy, dev,
void (*callback)(wiphy, dev, data, mac, sinfo), void *data);
Quoted 7 lines
The same seems to apply to
nl80211_dump_mpath()and the corresponding callback.An alternative would be to provide
start_station_dump()andstop_station_dump()callbacks for the locking, or, something I wouldn't really like to see, document the interface to lock when idx == 0 and unlock when the return value is-ENOENTor something...
Ok, I changed my mind, it has to be with conditional locking even for the RTNL because .dumpit callbacks can be invoked multiple times for a single dump operation and need to keep all locks (even the rtnl) across the calls.
Can you do that in both nl80211 and mac80211 for both STAs and paths? Look at net/netlink/genetlink.c ctrl_dumpfamily() for an example.
johannes
Quoted 2 lines · Johannes Berg
Can you do that in both nl80211 and mac80211 for both STAs and paths? Look at
net/netlink/genetlink.cctrl_dumpfamily()for an example.
Ok, no problem.
Signature · 2 lines
Luis Carlos Cobo Rus GnuPG ID: 44019B60 cozybit Inc.
Quoted 2 lines · Johannes Berg
Can you do that in both nl80211 and mac80211 for both STAs and paths? Look at
net/netlink/genetlink.cctrl_dumpfamily()for an example.
I'm not sure I completely get what changes are necessary.
What I understand is that I should acquire (if idx == 0) and release (just before returning -ENOENT) the rtnl_lock() from within (mac80211 or equivalent) dump_station function instead of from nl80211_dump_station. Is this the whole idea?
Signature · 2 lines
Luis Carlos Cobo Rus GnuPG ID: 44019B60 cozybit Inc.
Johannes Berg
maintainerQuoted 10 lines · Luis Carlos Cobo
Quoted 2 lines · Johannes Berg
Can you do that in both nl80211 and mac80211 for both STAs and paths? Look at
net/netlink/genetlink.cctrl_dumpfamily()for an example.I'm not sure I completely get what changes are necessary.
What I understand is that I should acquire (if idx == 0) and release (just before returning
-ENOENT) thertnl_lock()from within (mac80211 or equivalent)dump_stationfunction instead of fromnl80211_dump_station. Is this the whole idea?
I think it's a bit more complicated because nl80211's dump_station() can also be invoked multiple times.
To guarantee the cfg80211 rtnl_lock() promise, dump_station() should acquire the rtnl and all locks it needs when it first enters the function (oh. that's actually a bug in the other functions too, they should acquire the mutex conditionally, will fix).
mac80211 also needs to acquire the sta_lock because otherwise stations can be added or removed while dumping.
I suppose the struct netlink_callback needs to be passed through to mac80211's dump function with the limitation that the first two entries are already used by nl80211...
johannes
Johannes Berg
maintainerQuoted 10 lines · Luis Carlos Cobo
Quoted 2 lines · Johannes Berg
Can you do that in both nl80211 and mac80211 for both STAs and paths? Look at
net/netlink/genetlink.cctrl_dumpfamily()for an example.I'm not sure I completely get what changes are necessary.
What I understand is that I should acquire (if idx == 0) and release (just before returning
-ENOENT) thertnl_lock()from within (mac80211 or equivalent)dump_stationfunction instead of fromnl80211_dump_station. Is this the whole idea?
Actually. This is a bit weird, I think I'm misunderstanding how it is supposed to work. I'll dig a bit and let you know.
johannes
Johannes Berg
maintainerQuoted 5 lines · Luis Carlos Cobo
Quoted 2 lines · Johannes Berg
Can you do that in both nl80211 and mac80211 for both STAs and paths? Look at
net/netlink/genetlink.cctrl_dumpfamily()for an example.I'm not sure I completely get what changes are necessary.
Actually, none are. I was totally wrong about all the stuff. Sorry.
Quoted 4 lines
What I understand is that I should acquire (if idx == 0) and release (just before returning
-ENOENT) thertnl_lock()from within (mac80211 or equivalent)dump_stationfunction instead of fromnl80211_dump_station. Is this the whole idea?
That was completely wrong, I was trying to guarantee a consistent dump but that is impossible.
johannes