pull request for net-next: batman-adv 2016-08-16
Subsystems (3)
cover pull request for net-next: batman-adv 2016-08-16
Hi David,
this is our second feature pull request for batman-adv in this round, with our joint work on netlink and netns support. There will be at least one more pull request coming later.
Please pull or let me know of any problem!
Thank you,
Simon
The following changes since commit b5dcbad25219b82408e15e6d775a406be2116af1:
batman-adv: Fix consistency of update route messages (2016-08-09 07:54:34 +0200)
are available in the git repository at:
git://git.open-mesh.org/linux-merge.git tags/batadv-next-for-davem-20160816
for you to fetch changes up to 4c09a08b47ffac9aa3bc91870aa54c9ae39d9674:
batman-adv: Indicate netlink socket can be used with netns. (2016-08-09 07:54:43 +0200)
----------------------------------------------------------------
This feature patchset is all about adding netlink support, which should supersede our debugfs configuration interface in the long run. It is especially necessary when batman-adv should be used in different namespaces, since debugfs can not differentiate between those.
More specifically, the following changes are included:
- Two fixes for namespace handling by Andrew Lunn, checking also the namespaces for parent interfaces, and supress debugfs entries for non-default netns
- Implement various netlink commands for the new interface, by Matthias Schiffer, Andrew Lunn, Sven Eckelmann and Simon Wunderlich (13 patches):
* routing algorithm list
* hardif list
* translation tables (local and global)
* TTVN for the translation tables
* originator and neighbor tables for B.A.T.M.A.N. IV and B.A.T.M.A.N. V
* gateway dump functionality for B.A.T.M.A.N. IV
and B.A.T.M.A.N. V
* Bridge Loop Avoidance claims, and corresponding BLA group
* Bridge Loop Avoidance backbone tables
- Finally, mark batman-adv as netns compatible, by Andrew Lunn (1 patch)
----------------------------------------------------------------
Andrew Lunn (5):
batman-adv: Handle parent interfaces in a different netns
batman-adv: Suppress debugfs entries for netns's
batman-adv: add B.A.T.M.A.N. IV bat_gw_dump implementations
batman-adv: add B.A.T.M.A.N. Dump BLA claims via netlink
batman-adv: Indicate netlink socket can be used with netns.
Matthias Schiffer (6):
batman-adv: netlink: add routing_algo query
batman-adv: netlink: hardif query
batman-adv: netlink: add translation table query
batman-adv: netlink: add originator and neighbor table queries
batman-adv: add B.A.T.M.A.N. IV bat_{orig, neigh}_dump implementations
batman-adv: add B.A.T.M.A.N. V bat_{orig, neigh}_dump implementations
Simon Wunderlich (1):
batman-adv: add backbone table netlink support
Sven Eckelmann (4):
batman-adv: Provide TTVN in the mesh_info netlink msg
batman-adv: netlink: add gateway table queries
batman-adv: add B.A.T.M.A.N. V bat_gw_dump implementations
batman-adv: Provide bla group in the mesh_info netlink msg
include/uapi/linux/batman_adv.h | 94 +++++++ net/batman-adv/bat_algo.c | 68 +++++ net/batman-adv/bat_algo.h | 3 + net/batman-adv/bat_iv_ogm.c | 471 +++++++++++++++++++++++++++++++++ net/batman-adv/bat_v.c | 465 ++++++++++++++++++++++++++++++++ net/batman-adv/bridge_loop_avoidance.c | 333 +++++++++++++++++++++++ net/batman-adv/bridge_loop_avoidance.h | 17 +- net/batman-adv/debugfs.c | 18 ++ net/batman-adv/gateway_client.c | 59 +++++ net/batman-adv/gateway_client.h | 2 + net/batman-adv/hard-interface.c | 50 +++- net/batman-adv/netlink.c | 217 ++++++++++++++- net/batman-adv/netlink.h | 6 + net/batman-adv/originator.c | 160 +++++++++++ net/batman-adv/originator.h | 4 + net/batman-adv/packet.h | 36 --- net/batman-adv/translation-table.c | 377 ++++++++++++++++++++++++++ net/batman-adv/translation-table.h | 4 + net/batman-adv/types.h | 12 + 19 files changed, 2348 insertions(+), 48 deletions(-)
A message that is not in the archive (sent off-list or not yet received): 1471336364-16334-1-git-send-email-sw-2YrNx6rUIHYiY0qSoAWiAoQuADTiUCJX@public.gmane.org
PATCH 1/16 batman-adv: Handle parent interfaces in a different netns
From: Andrew Lunn <[email protected]>
batman-adv tries to prevent the user from placing a batX soft interface into another batman mesh as a hard interface. It does this by walking up the devices list of parents and ensures they are all none batX interfaces. iflink can point to an interface in a different namespace, so also retrieve the parents name space when finding the parent and use it when doing the comparison.
--- net/batman-adv/hard-interface.c | 50 +++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 7 deletions(-)
net/batman-adv/hard-interface.c +43 -7
@@ -35,6 +35,8 @@#include <linux/rtnetlink.h> #include <linux/slab.h> #include <linux/spinlock.h> +#include <net/net_namespace.h> +#include <net/rtnetlink.h> #include "bat_v.h" #include "bridge_loop_avoidance.h"
@@ -84,25 +86,55 @@ out: }/** +* batadv_getlink_net - return link net namespace (of use fallback) +* @netdev: net_device to check +* @fallback_net: return in case get_link_net is not available for @netdev +* +* Return: result of rtnl_link_ops->get_link_net or @fallback_net +*/ +static const struct net *batadv_getlink_net (const struct net_device *netdev, +const struct net *fallback_net) +{ +if (!netdev->rtnl_link_ops) +return fallback_net; + +if (!netdev->rtnl_link_ops->get_link_net) +return fallback_net; + +return netdev->rtnl_link_ops->get_link_net (netdev); +} + +/** * batadv_mutual_parents - check if two devices are each others parent -* @dev1: 1st net_device -* @dev2: 2nd net_device +* @dev1: 1st net dev +* @net1: 1st devices netns +* @dev2: 2nd net dev +* @net2: 2nd devices netns * * veth devices come in pairs and each is the parent of the other! * * Return: true if the devices are each others parent, otherwise false */ static bool batadv_mutual_parents (const struct net_device *dev1, -const struct net_device *dev2) +const struct net *net1, +const struct net_device *dev2, +const struct net *net2) {int dev1_parent_iflink =dev_get_iflink (dev1);int dev2_parent_iflink =dev_get_iflink (dev2); +const struct net *dev1_parent_net; +const struct net *dev2_parent_net; + + dev1_parent_net =batadv_getlink_net (dev1, net1); + dev2_parent_net =batadv_getlink_net (dev2, net2);if (!dev1_parent_iflink || !dev2_parent_iflink)return false;return (dev1_parent_iflink == dev2->ifindex) && - (dev2_parent_iflink == dev1->ifindex); + (dev2_parent_iflink == dev1->ifindex) && +net_eq (dev1_parent_net, net2) && +net_eq (dev2_parent_net, net1); }/**
@@ -120,8 +152,9 @@ static bool batadv_mutual_parents(const struct net_device *dev1,*/ static bool batadv_is_on_batman_iface (const struct net_device *net_dev) { -struct net_device *parent_dev;struct net *net =dev_net (net_dev); +struct net_device *parent_dev; +const struct net *parent_net;bool ret;/* check if this is a batman-adv mesh interface */
@@ -133,13 +166,16 @@ static bool batadv_is_on_batman_iface(const struct net_device *net_dev) dev_get_iflink(net_dev) == net_dev->ifindex)return false; + parent_net =batadv_getlink_net (net_dev, net); +/* recurse over the parent device */ - parent_dev =__dev_get_by_index (net,dev_get_iflink (net_dev)); + parent_dev =__dev_get_by_index ((struct net *)parent_net, +dev_get_iflink (net_dev));/* if we got a NULL parent_dev there is something broken.. */ if (WARN (!parent_dev,"Cannot find parent device" ))return false; -if (batadv_mutual_parents (net_dev, parent_dev)) +if (batadv_mutual_parents (net_dev, net, parent_dev, parent_net))return false; ret =batadv_is_on_batman_iface (parent_dev);
Signature · 1 line
2.8.1
PATCH 2/16 batman-adv: Suppress debugfs entries for netns's
In reply to a message not in the archiveFrom: Andrew Lunn <[email protected]>
Debugfs is not netns aware. It thus has problems when the same interface name exists in multiple network name spaces.
Work around this by not creating entries for interfaces in name spaces other than the default name space. This means meshes in network namespaces cannot be managed via debugfs, but there will soon be a netlink interface which is netns aware.
--- net/batman-adv/debugfs.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
net/batman-adv/debugfs.c +18 -0
@@ -31,6 +31,7 @@#include <linux/stddef.h> #include <linux/stringify.h> #include <linux/sysfs.h> +#include <net/net_namespace.h> #include "bat_algo.h" #include "bridge_loop_avoidance.h"
@@ -305,12 +306,16 @@ void batadv_debugfs_destroy(void)*/ int batadv_debugfs_add_hardif (struct batadv_hard_iface *hard_iface) { +struct net *net =dev_net (hard_iface->net_dev);struct batadv_debuginfo **bat_debug;struct dentry *file;if (!batadv_debugfs) goto out; +if (net != &init_net) +return 0 ; + hard_iface->debug_dir =debugfs_create_dir (hard_iface->net_dev->name, batadv_debugfs);if (!hard_iface->debug_dir)
@@ -341,6 +346,11 @@ out:*/ void batadv_debugfs_del_hardif (struct batadv_hard_iface *hard_iface) { +struct net *net =dev_net (hard_iface->net_dev); + +if (net != &init_net) +return ; +if (batadv_debugfs) {debugfs_remove_recursive (hard_iface->debug_dir); hard_iface->debug_dir =NULL ;
@@ -351,11 +361,15 @@ int batadv_debugfs_add_meshif(struct net_device *dev) {struct batadv_priv *bat_priv =netdev_priv (dev);struct batadv_debuginfo **bat_debug; +struct net *net =dev_net (dev);struct dentry *file;if (!batadv_debugfs) goto out; +if (net != &init_net) +return 0 ; + bat_priv->debug_dir =debugfs_create_dir (dev->name, batadv_debugfs);if (!bat_priv->debug_dir) goto out;
@@ -392,6 +406,10 @@ out:void batadv_debugfs_del_meshif (struct net_device *dev) {struct batadv_priv *bat_priv =netdev_priv (dev); +struct net *net =dev_net (dev); + +if (net != &init_net) +return ;batadv_debug_log_cleanup (bat_priv);
Signature · 1 line
2.8.1
PATCH 4/16 batman-adv: netlink: hardif query
In reply to a message not in the archiveFrom: Matthias Schiffer <[email protected]>
BATADV_CMD_GET_HARDIFS will return the list of hardifs (including index, name and MAC address) of all hardifs for a given softif.
[[email protected]: Reduce the number of changes to BATADV_CMD_GET_HARDIFS, add policy for attributes]
--- include/uapi/linux/batman_adv.h | 4 ++ net/batman-adv/netlink.c | 128 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 130 insertions(+), 2 deletions(-)
include/uapi/linux/batman_adv.h +4 -0
@@ -40,6 +40,7 @@* @BATADV_ATTR_TPMETER_BYTES: amount of acked bytes during run * @BATADV_ATTR_TPMETER_COOKIE: session cookie to match tp_meter session * @BATADV_ATTR_PAD: attribute used for padding for 64-bit alignment +* @BATADV_ATTR_ACTIVE: Flag indicating if the hard interface is active * @__BATADV_ATTR_AFTER_LAST: internal use * @NUM_BATADV_ATTR: total number of batadv_nl_attrs available * @BATADV_ATTR_MAX: highest attribute number currently defined
@@ -60,6 +61,7 @@ enum batadv_nl_attrs {BATADV_ATTR_TPMETER_BYTES ,BATADV_ATTR_TPMETER_COOKIE ,BATADV_ATTR_PAD , +BATADV_ATTR_ACTIVE ,/* add attributes above here, update the policy in netlink.c */ __BATADV_ATTR_AFTER_LAST, NUM_BATADV_ATTR = __BATADV_ATTR_AFTER_LAST,
@@ -74,6 +76,7 @@ enum batadv_nl_attrs {* @BATADV_CMD_TP_METER: Start a tp meter session * @BATADV_CMD_TP_METER_CANCEL: Cancel a tp meter session * @BATADV_CMD_GET_ROUTING_ALGOS: Query the list of routing algorithms. +* @BATADV_CMD_GET_HARDIFS: Query list of hard interfaces * @__BATADV_CMD_AFTER_LAST: internal use * @BATADV_CMD_MAX: highest used command number */
@@ -83,6 +86,7 @@ enum batadv_nl_commands {BATADV_CMD_TP_METER ,BATADV_CMD_TP_METER_CANCEL ,BATADV_CMD_GET_ROUTING_ALGOS , +BATADV_CMD_GET_HARDIFS ,/* add new commands above here */ __BATADV_CMD_AFTER_LAST,BATADV_CMD_MAX = __BATADV_CMD_AFTER_LAST -1
net/batman-adv/netlink.c +126 -2
165 lines not on this page · raw message
Signature · 1 line
2.8.1
PATCH 5/16 batman-adv: netlink: add translation table query
In reply to a message not in the archiveFrom: Matthias Schiffer <[email protected]>
This adds the commands BATADV_CMD_GET_TRANSTABLE_LOCAL and BATADV_CMD_GET_TRANSTABLE_GLOBAL, which correspond to the transtable_local and transtable_global debugfs files.
The batadv_tt_client_flags enum is moved to the UAPI to expose it as part of the netlink API.
--- include/uapi/linux/batman_adv.h | 56 ++++++ net/batman-adv/netlink.c | 23 ++- net/batman-adv/netlink.h | 3 + net/batman-adv/packet.h | 36 ---- net/batman-adv/translation-table.c | 377 +++++++++++++++++++++++++++++++++++++ net/batman-adv/translation-table.h | 4 + 6 files changed, 462 insertions(+), 37 deletions(-)
include/uapi/linux/batman_adv.h +56 -0
@@ -23,6 +23,42 @@#define BATADV_NL_MCAST_GROUP_TPMETER "tpmeter"/** +* enum batadv_tt_client_flags - TT client specific flags +* @BATADV_TT_CLIENT_DEL: the client has to be deleted from the table +* @BATADV_TT_CLIENT_ROAM: the client roamed to/from another node and the new +* update telling its new real location has not been received/sent yet +* @BATADV_TT_CLIENT_WIFI: this client is connected through a wifi interface. +* This information is used by the "AP Isolation" feature +* @BATADV_TT_CLIENT_ISOLA: this client is considered "isolated". This +* information is used by the Extended Isolation feature +* @BATADV_TT_CLIENT_NOPURGE: this client should never be removed from the table +* @BATADV_TT_CLIENT_NEW: this client has been added to the local table but has +* not been announced yet +* @BATADV_TT_CLIENT_PENDING: this client is marked for removal but it is kept +* in the table for one more originator interval for consistency purposes +* @BATADV_TT_CLIENT_TEMP: this global client has been detected to be part of +* the network but no nnode has already announced it +* +* Bits from 0 to 7 are called _remote flags_ because they are sent on the wire. +* Bits from 8 to 15 are called _local flags_ because they are used for local +* computations only. +* +* Bits from 4 to 7 - a subset of remote flags - are ensured to be in sync with +* the other nodes in the network. To achieve this goal these flags are included +* in the TT CRC computation. +*/ +enum batadv_tt_client_flags { +BATADV_TT_CLIENT_DEL = (1 <<0 ), +BATADV_TT_CLIENT_ROAM = (1 <<1 ), +BATADV_TT_CLIENT_WIFI = (1 <<4 ), +BATADV_TT_CLIENT_ISOLA = (1 <<5 ), +BATADV_TT_CLIENT_NOPURGE = (1 <<8 ), +BATADV_TT_CLIENT_NEW = (1 <<9 ), +BATADV_TT_CLIENT_PENDING = (1 <<10 ), +BATADV_TT_CLIENT_TEMP = (1 <<11 ), +}; + +/** * enum batadv_nl_attrs - batman-adv netlink attributes * * @BATADV_ATTR_UNSPEC: unspecified attribute to catch errors
@@ -41,6 +77,14 @@* @BATADV_ATTR_TPMETER_COOKIE: session cookie to match tp_meter session * @BATADV_ATTR_PAD: attribute used for padding for 64-bit alignment * @BATADV_ATTR_ACTIVE: Flag indicating if the hard interface is active +* @BATADV_ATTR_TT_ADDRESS: Client MAC address +* @BATADV_ATTR_TT_TTVN: Translation table version +* @BATADV_ATTR_TT_LAST_TTVN: Previous translation table version +* @BATADV_ATTR_TT_CRC32: CRC32 over translation table +* @BATADV_ATTR_TT_VID: VLAN ID +* @BATADV_ATTR_TT_FLAGS: Translation table client flags +* @BATADV_ATTR_FLAG_BEST: Flags indicating entry is the best +* @BATADV_ATTR_LAST_SEEN_MSECS: Time in milliseconds since last seen * @__BATADV_ATTR_AFTER_LAST: internal use * @NUM_BATADV_ATTR: total number of batadv_nl_attrs available * @BATADV_ATTR_MAX: highest attribute number currently defined
@@ -62,6 +106,14 @@ enum batadv_nl_attrs {BATADV_ATTR_TPMETER_COOKIE ,BATADV_ATTR_PAD ,BATADV_ATTR_ACTIVE , +BATADV_ATTR_TT_ADDRESS , +BATADV_ATTR_TT_TTVN , +BATADV_ATTR_TT_LAST_TTVN , +BATADV_ATTR_TT_CRC32 , +BATADV_ATTR_TT_VID , +BATADV_ATTR_TT_FLAGS , +BATADV_ATTR_FLAG_BEST , +BATADV_ATTR_LAST_SEEN_MSECS ,/* add attributes above here, update the policy in netlink.c */ __BATADV_ATTR_AFTER_LAST, NUM_BATADV_ATTR = __BATADV_ATTR_AFTER_LAST,
@@ -77,6 +129,8 @@ enum batadv_nl_attrs {* @BATADV_CMD_TP_METER_CANCEL: Cancel a tp meter session * @BATADV_CMD_GET_ROUTING_ALGOS: Query the list of routing algorithms. * @BATADV_CMD_GET_HARDIFS: Query list of hard interfaces +* @BATADV_CMD_GET_TRANSTABLE_LOCAL: Query list of local translations +* @BATADV_CMD_GET_TRANSTABLE_GLOBAL Query list of global translations * @__BATADV_CMD_AFTER_LAST: internal use * @BATADV_CMD_MAX: highest used command number */
@@ -87,6 +141,8 @@ enum batadv_nl_commands {BATADV_CMD_TP_METER_CANCEL ,BATADV_CMD_GET_ROUTING_ALGOS ,BATADV_CMD_GET_HARDIFS , +BATADV_CMD_GET_TRANSTABLE_LOCAL , +BATADV_CMD_GET_TRANSTABLE_GLOBAL ,/* add new commands above here */ __BATADV_CMD_AFTER_LAST,BATADV_CMD_MAX = __BATADV_CMD_AFTER_LAST -1
net/batman-adv/netlink.c +22 -1
@@ -40,6 +40,7 @@#include "hard-interface.h" #include "soft-interface.h" #include "tp_meter.h" +#include "translation-table.h" struct genl_family batadv_netlink_family = { .id =GENL_ID_GENERATE ,
@@ -73,6 +74,14 @@ static struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = { [BATADV_ATTR_TPMETER_BYTES] = { .type = NLA_U64 }, [BATADV_ATTR_TPMETER_COOKIE] = { .type = NLA_U32 }, [BATADV_ATTR_ACTIVE] = { .type = NLA_FLAG }, + [BATADV_ATTR_TT_ADDRESS] = { .len = ETH_ALEN }, + [BATADV_ATTR_TT_TTVN] = { .type = NLA_U8 }, + [BATADV_ATTR_TT_LAST_TTVN] = { .type = NLA_U8 }, + [BATADV_ATTR_TT_CRC32] = { .type = NLA_U32 }, + [BATADV_ATTR_TT_VID] = { .type = NLA_U16 }, + [BATADV_ATTR_TT_FLAGS] = { .type = NLA_U32 }, + [BATADV_ATTR_FLAG_BEST] = { .type = NLA_FLAG }, + [BATADV_ATTR_LAST_SEEN_MSECS] = { .type = NLA_U32 }, };/**
@@ -82,7 +91,7 @@ static struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = {* * Return: interface index, or 0. */ -static int +int batadv_netlink_get_ifindex (const struct nlmsghdr *nlh,int attrtype) {struct nlattr *attr =nlmsg_find_attr (nlh,GENL_HDRLEN , attrtype);
@@ -530,6 +539,18 @@ static struct genl_ops batadv_netlink_ops[] = { .policy = batadv_netlink_policy, .dumpit = batadv_netlink_dump_hardifs, }, + { + .cmd = BATADV_CMD_GET_TRANSTABLE_LOCAL, + .flags = GENL_ADMIN_PERM, + .policy = batadv_netlink_policy, + .dumpit = batadv_tt_local_dump, + }, + { + .cmd = BATADV_CMD_GET_TRANSTABLE_GLOBAL, + .flags = GENL_ADMIN_PERM, + .policy = batadv_netlink_policy, + .dumpit = batadv_tt_global_dump, + }, };/**
net/batman-adv/netlink.h +3 -0
@@ -23,8 +23,11 @@#include <linux/types.h> #include <net/genetlink.h> +struct nlmsghdr ; +void batadv_netlink_register (void );void batadv_netlink_unregister (void ); +int batadv_netlink_get_ifindex (const struct nlmsghdr *nlh,int attrtype); int batadv_netlink_tpmeter_notify(struct batadv_priv *bat_priv, const u8 *dst, u8 result, u32 test_time, u64 total_bytes,
net/batman-adv/packet.h +0 -36
@@ -129,42 +129,6 @@ enum batadv_tt_data_flags { };/** -* enum batadv_tt_client_flags - TT client specific flags -* @BATADV_TT_CLIENT_DEL: the client has to be deleted from the table -* @BATADV_TT_CLIENT_ROAM: the client roamed to/from another node and the new -* update telling its new real location has not been received/sent yet -* @BATADV_TT_CLIENT_WIFI: this client is connected through a wifi interface. -* This information is used by the "AP Isolation" feature -* @BATADV_TT_CLIENT_ISOLA: this client is considered "isolated". This -* information is used by the Extended Isolation feature -* @BATADV_TT_CLIENT_NOPURGE: this client should never be removed from the table -* @BATADV_TT_CLIENT_NEW: this client has been added to the local table but has -* not been announced yet -* @BATADV_TT_CLIENT_PENDING: this client is marked for removal but it is kept -* in the table for one more originator interval for consistency purposes -* @BATADV_TT_CLIENT_TEMP: this global client has been detected to be part of -* the network but no nnode has already announced it -* -* Bits from 0 to 7 are called _remote flags_ because they are sent on the wire. -* Bits from 8 to 15 are called _local flags_ because they are used for local -* computations only. -* -* Bits from 4 to 7 - a subset of remote flags - are ensured to be in sync with -* the other nodes in the network. To achieve this goal these flags are included -* in the TT CRC computation. -*/ -enum batadv_tt_client_flags { -BATADV_TT_CLIENT_DEL =BIT (0 ), -BATADV_TT_CLIENT_ROAM =BIT (1 ), -BATADV_TT_CLIENT_WIFI =BIT (4 ), -BATADV_TT_CLIENT_ISOLA =BIT (5 ), -BATADV_TT_CLIENT_NOPURGE =BIT (8 ), -BATADV_TT_CLIENT_NEW =BIT (9 ), -BATADV_TT_CLIENT_PENDING =BIT (10 ), -BATADV_TT_CLIENT_TEMP =BIT (11 ), -}; - -/** * enum batadv_vlan_flags - flags for the four MSB of any vlan ID field * @BATADV_VLAN_HAS_TAG: whether the field contains a valid vlan tag or not */
net/batman-adv/translation-table.c +377 -0
409 lines not on this page · raw message
net/batman-adv/translation-table.h +4 -0
@@ -22,8 +22,10 @@#include <linux/types.h> +struct netlink_callback ;struct net_device ;struct seq_file ; +struct sk_buff ;int batadv_tt_init (struct batadv_priv *bat_priv); bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,
@@ -33,6 +35,8 @@ u16 batadv_tt_local_remove(struct batadv_priv *bat_priv, const char *message, bool roaming);int batadv_tt_local_seq_print_text (struct seq_file *seq,void *offset);int batadv_tt_global_seq_print_text (struct seq_file *seq,void *offset); +int batadv_tt_local_dump (struct sk_buff *msg,struct netlink_callback *cb); +int batadv_tt_global_dump (struct sk_buff *msg,struct netlink_callback *cb);void batadv_tt_global_del_orig (struct batadv_priv *bat_priv,struct batadv_orig_node *orig_node,s32 match_vid,const char *message);
Signature · 1 line
2.8.1
PATCH 6/16 batman-adv: Provide TTVN in the mesh_info netlink msg
In reply to a message not in the archiveFrom: Sven Eckelmann <[email protected]>
The TTVN is the main information for the debugging of translation table problems. It is therefore necessary when comparing the global translation tables.
--- net/batman-adv/netlink.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/batman-adv/netlink.c +4 -1
@@ -18,6 +18,7 @@#include "netlink.h" #include "main.h" +#include <linux/atomic.h> #include <linux/errno.h> #include <linux/fs.h> #include <linux/genetlink.h>
@@ -121,7 +122,9 @@ batadv_netlink_mesh_info_put(struct sk_buff *msg, struct net_device *soft_iface)nla_put_u32 (msg,BATADV_ATTR_MESH_IFINDEX , soft_iface->ifindex) ||nla_put_string (msg,BATADV_ATTR_MESH_IFNAME , soft_iface->name) ||nla_put (msg,BATADV_ATTR_MESH_ADDRESS ,ETH_ALEN , - soft_iface->dev_addr)) + soft_iface->dev_addr) || +nla_put_u8 (msg,BATADV_ATTR_TT_TTVN , + (u8)atomic_read(&bat_priv->tt.vn))) goto out; primary_if =batadv_primary_if_get_selected (bat_priv);
Signature · 1 line
2.8.1
Simon Wunderlich
maintainerPATCH 3/16 batman-adv: netlink: add routing_algo query
In reply to Simon WunderlichFrom: Matthias Schiffer <[email protected]>
BATADV_CMD_GET_ROUTING_ALGOS is used to get the list of supported routing algorithms.
[[email protected]: Reduce the number of changes to BATADV_CMD_GET_ROUTING_ALGOS, fix includes]
--- include/uapi/linux/batman_adv.h | 2 ++ net/batman-adv/bat_algo.c | 68 +++++++++++++++++++++++++++++++++++++++++ net/batman-adv/bat_algo.h | 3 ++ net/batman-adv/netlink.c | 9 +++++- net/batman-adv/netlink.h | 3 ++ 5 files changed, 84 insertions(+), 1 deletion(-)
include/uapi/linux/batman_adv.h +2 -0
@@ -73,6 +73,7 @@ enum batadv_nl_attrs {* @BATADV_CMD_GET_MESH_INFO: Query basic information about batman-adv device * @BATADV_CMD_TP_METER: Start a tp meter session * @BATADV_CMD_TP_METER_CANCEL: Cancel a tp meter session +* @BATADV_CMD_GET_ROUTING_ALGOS: Query the list of routing algorithms. * @__BATADV_CMD_AFTER_LAST: internal use * @BATADV_CMD_MAX: highest used command number */
@@ -81,6 +82,7 @@ enum batadv_nl_commands {BATADV_CMD_GET_MESH_INFO ,BATADV_CMD_TP_METER ,BATADV_CMD_TP_METER_CANCEL , +BATADV_CMD_GET_ROUTING_ALGOS ,/* add new commands above here */ __BATADV_CMD_AFTER_LAST,BATADV_CMD_MAX = __BATADV_CMD_AFTER_LAST -1
net/batman-adv/bat_algo.c +68 -0
83 lines not on this page · raw message
net/batman-adv/bat_algo.h +3 -0
@@ -22,7 +22,9 @@#include <linux/types.h> +struct netlink_callback ;struct seq_file ; +struct sk_buff ;extern char batadv_routing_algo[];extern struct list_head batadv_hardif_list;
@@ -31,5 +33,6 @@ void batadv_algo_init(void);int batadv_algo_register (struct batadv_algo_ops *bat_algo_ops);int batadv_algo_select (struct batadv_priv *bat_priv,char *name);int batadv_algo_seq_print_text (struct seq_file *seq,void *offset); +int batadv_algo_dump (struct sk_buff *msg,struct netlink_callback *cb);#endif /* _NET_BATMAN_ADV_BAT_ALGO_H_ */
net/batman-adv/netlink.c +8 -1
@@ -32,13 +32,14 @@#include <net/netlink.h> #include <uapi/linux/batman_adv.h> +#include "bat_algo.h" #include "hard-interface.h" #include "soft-interface.h" #include "tp_meter.h" struct sk_buff ; -static struct genl_family batadv_netlink_family = { +struct genl_family batadv_netlink_family = { .id =GENL_ID_GENERATE , .hdrsize =0 , .name =BATADV_NL_NAME ,
@@ -399,6 +400,12 @@ static struct genl_ops batadv_netlink_ops[] = { .policy = batadv_netlink_policy, .doit = batadv_netlink_tp_meter_cancel, }, + { + .cmd = BATADV_CMD_GET_ROUTING_ALGOS, + .flags = GENL_ADMIN_PERM, + .policy = batadv_netlink_policy, + .dumpit = batadv_algo_dump, + }, };/**
net/batman-adv/netlink.h +3 -0
@@ -21,6 +21,7 @@#include "main.h" #include <linux/types.h> +#include <net/genetlink.h> void batadv_netlink_register (void );void batadv_netlink_unregister (void );
@@ -29,4 +30,6 @@ int batadv_netlink_tpmeter_notify(struct batadv_priv *bat_priv, const u8 *dst, u8 result, u32 test_time, u64 total_bytes, u32 cookie); +extern struct genl_family batadv_netlink_family; +#endif /* _NET_BATMAN_ADV_NETLINK_H_ */
Signature · 1 line
2.8.1
Simon Wunderlich
maintainerPATCH 7/16 batman-adv: netlink: add originator and neighbor table queries
In reply to Simon WunderlichFrom: Matthias Schiffer <[email protected]>
Add BATADV_CMD_GET_ORIGINATORS and BATADV_CMD_GET_NEIGHBORS commands, using handlers bat_orig_dump and bat_neigh_dump in batadv_algo_ops. Will always return -EOPNOTSUPP for now, as no implementations exist yet.
--- include/uapi/linux/batman_adv.h | 4 + net/batman-adv/netlink.c | 13 ++++ net/batman-adv/originator.c | 160 ++++++++++++++++++++++++++++++++++++++++ net/batman-adv/originator.h | 4 + net/batman-adv/types.h | 9 +++ 5 files changed, 190 insertions(+)
include/uapi/linux/batman_adv.h +4 -0
@@ -131,6 +131,8 @@ enum batadv_nl_attrs {* @BATADV_CMD_GET_HARDIFS: Query list of hard interfaces * @BATADV_CMD_GET_TRANSTABLE_LOCAL: Query list of local translations * @BATADV_CMD_GET_TRANSTABLE_GLOBAL Query list of global translations +* @BATADV_CMD_GET_ORIGINATORS: Query list of originators +* @BATADV_CMD_GET_NEIGHBORS: Query list of neighbours * @__BATADV_CMD_AFTER_LAST: internal use * @BATADV_CMD_MAX: highest used command number */
@@ -143,6 +145,8 @@ enum batadv_nl_commands {BATADV_CMD_GET_HARDIFS ,BATADV_CMD_GET_TRANSTABLE_LOCAL ,BATADV_CMD_GET_TRANSTABLE_GLOBAL , +BATADV_CMD_GET_ORIGINATORS , +BATADV_CMD_GET_NEIGHBORS ,/* add new commands above here */ __BATADV_CMD_AFTER_LAST,BATADV_CMD_MAX = __BATADV_CMD_AFTER_LAST -1
net/batman-adv/netlink.c +13 -0
@@ -39,6 +39,7 @@#include "bat_algo.h" #include "hard-interface.h" +#include "originator.h" #include "soft-interface.h" #include "tp_meter.h" #include "translation-table.h"
@@ -554,6 +555,18 @@ static struct genl_ops batadv_netlink_ops[] = { .policy = batadv_netlink_policy, .dumpit = batadv_tt_global_dump, }, + { + .cmd = BATADV_CMD_GET_ORIGINATORS, + .flags = GENL_ADMIN_PERM, + .policy = batadv_netlink_policy, + .dumpit = batadv_orig_dump, + }, + { + .cmd = BATADV_CMD_GET_NEIGHBORS, + .flags = GENL_ADMIN_PERM, + .policy = batadv_netlink_policy, + .dumpit = batadv_hardif_neigh_dump, + }, };/**
net/batman-adv/originator.c +160 -0
191 lines not on this page · raw message
net/batman-adv/originator.h +4 -0
@@ -31,7 +31,9 @@#include "hash.h" +struct netlink_callback ;struct seq_file ; +struct sk_buff ;bool batadv_compare_orig (const struct hlist_node *node,const void *data2);int batadv_originator_init (struct batadv_priv *bat_priv);
@@ -61,6 +63,7 @@ batadv_neigh_ifinfo_get(struct batadv_neigh_node *neigh, struct batadv_hard_iface *if_outgoing);void batadv_neigh_ifinfo_put (struct batadv_neigh_ifinfo *neigh_ifinfo); +int batadv_hardif_neigh_dump (struct sk_buff *msg,struct netlink_callback *cb);int batadv_hardif_neigh_seq_print_text (struct seq_file *seq,void *offset); struct batadv_orig_ifinfo *
@@ -72,6 +75,7 @@ batadv_orig_ifinfo_new(struct batadv_orig_node *orig_node,void batadv_orig_ifinfo_put (struct batadv_orig_ifinfo *orig_ifinfo);int batadv_orig_seq_print_text (struct seq_file *seq,void *offset); +int batadv_orig_dump (struct sk_buff *msg,struct netlink_callback *cb);int batadv_orig_hardif_seq_print_text (struct seq_file *seq,void *offset);int batadv_orig_hash_add_if (struct batadv_hard_iface *hard_iface,int max_if_num);
net/batman-adv/types.h +9 -0
@@ -28,6 +28,7 @@#include <linux/if_ether.h> #include <linux/kref.h> #include <linux/netdevice.h> +#include <linux/netlink.h> #include <linux/sched.h> /* for linux/wait.h */ #include <linux/spinlock.h> #include <linux/types.h>
@@ -1418,6 +1419,7 @@ struct batadv_algo_iface_ops {* @is_similar_or_better: check if neigh1 is equally similar or better than * neigh2 for their respective outgoing interface from the metric prospective * @print: print the single hop neighbor list (optional) +* @dump: dump neighbors to a netlink socket (optional) */ struct batadv_algo_neigh_ops {void (*hardif_init)(struct batadv_hardif_neigh_node *neigh);
@@ -1430,6 +1432,9 @@ struct batadv_algo_neigh_ops {struct batadv_neigh_node *neigh2, struct batadv_hard_iface *if_outgoing2);void (*print)(struct batadv_priv *priv,struct seq_file *seq); +void (*dump)(struct sk_buff *msg,struct netlink_callback *cb, +struct batadv_priv *priv, +struct batadv_hard_iface *hard_iface); };/**
@@ -1441,6 +1446,7 @@ struct batadv_algo_neigh_ops {* @del_if: ask the routing algorithm to apply the needed changes to the * orig_node due to an hard-interface being removed from the mesh (optional) * @print: print the originator table (optional) +* @dump: dump originators to a netlink socket (optional) */ struct batadv_algo_orig_ops {void (*free)(struct batadv_orig_node *orig_node);
@@ -1449,6 +1455,9 @@ struct batadv_algo_orig_ops { int del_if_num);void (*print)(struct batadv_priv *priv,struct seq_file *seq,struct batadv_hard_iface *hard_iface); +void (*dump)(struct sk_buff *msg,struct netlink_callback *cb, +struct batadv_priv *priv, +struct batadv_hard_iface *hard_iface); };/**
Signature · 1 line
2.8.1
Simon Wunderlich
maintainerPATCH 8/16 batman-adv: add B.A.T.M.A.N. IV bat_{orig, neigh}_dump implementations
In reply to Simon WunderlichFrom: Matthias Schiffer <[email protected]>
[[email protected]: Fix function parameter alignments, add policy for attributes, fix includes, fix algo_ops integration]
--- include/uapi/linux/batman_adv.h | 4 + net/batman-adv/bat_iv_ogm.c | 366 ++++++++++++++++++++++++++++++++++++++++ net/batman-adv/netlink.c | 2 + 3 files changed, 372 insertions(+)
include/uapi/linux/batman_adv.h +4 -0
@@ -85,6 +85,8 @@ enum batadv_tt_client_flags {* @BATADV_ATTR_TT_FLAGS: Translation table client flags * @BATADV_ATTR_FLAG_BEST: Flags indicating entry is the best * @BATADV_ATTR_LAST_SEEN_MSECS: Time in milliseconds since last seen +* @BATADV_ATTR_NEIGH_ADDRESS: Neighbour MAC address +* @BATADV_ATTR_TQ: TQ to neighbour * @__BATADV_ATTR_AFTER_LAST: internal use * @NUM_BATADV_ATTR: total number of batadv_nl_attrs available * @BATADV_ATTR_MAX: highest attribute number currently defined
@@ -114,6 +116,8 @@ enum batadv_nl_attrs {BATADV_ATTR_TT_FLAGS ,BATADV_ATTR_FLAG_BEST ,BATADV_ATTR_LAST_SEEN_MSECS , +BATADV_ATTR_NEIGH_ADDRESS , +BATADV_ATTR_TQ ,/* add attributes above here, update the policy in netlink.c */ __BATADV_ATTR_AFTER_LAST, NUM_BATADV_ATTR = __BATADV_ATTR_AFTER_LAST,
net/batman-adv/bat_iv_ogm.c +366 -0
405 lines not on this page · raw message
net/batman-adv/netlink.c +2 -0
@@ -84,6 +84,8 @@ static struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = { [BATADV_ATTR_TT_FLAGS] = { .type = NLA_U32 }, [BATADV_ATTR_FLAG_BEST] = { .type = NLA_FLAG }, [BATADV_ATTR_LAST_SEEN_MSECS] = { .type = NLA_U32 }, + [BATADV_ATTR_NEIGH_ADDRESS] = { .len = ETH_ALEN }, + [BATADV_ATTR_TQ] = { .type = NLA_U8 }, };/**
Signature · 1 line
2.8.1
Simon Wunderlich
maintainerPATCH 9/16 batman-adv: add B.A.T.M.A.N. V bat_{orig, neigh}_dump implementations
In reply to Simon WunderlichFrom: Matthias Schiffer <[email protected]>
Dump the algo V originators and neighbours.
--- include/uapi/linux/batman_adv.h | 2 + net/batman-adv/bat_v.c | 340 ++++++++++++++++++++++++++++++++++++++++ net/batman-adv/netlink.c | 1 + 3 files changed, 343 insertions(+)
include/uapi/linux/batman_adv.h +2 -0
@@ -87,6 +87,7 @@ enum batadv_tt_client_flags {* @BATADV_ATTR_LAST_SEEN_MSECS: Time in milliseconds since last seen * @BATADV_ATTR_NEIGH_ADDRESS: Neighbour MAC address * @BATADV_ATTR_TQ: TQ to neighbour +* @BATADV_ATTR_THROUGHPUT: Estimated throughput to Neighbour * @__BATADV_ATTR_AFTER_LAST: internal use * @NUM_BATADV_ATTR: total number of batadv_nl_attrs available * @BATADV_ATTR_MAX: highest attribute number currently defined
@@ -118,6 +119,7 @@ enum batadv_nl_attrs {BATADV_ATTR_LAST_SEEN_MSECS ,BATADV_ATTR_NEIGH_ADDRESS ,BATADV_ATTR_TQ , +BATADV_ATTR_THROUGHPUT ,/* add attributes above here, update the policy in netlink.c */ __BATADV_ATTR_AFTER_LAST, NUM_BATADV_ATTR = __BATADV_ATTR_AFTER_LAST,
net/batman-adv/bat_v.c +340 -0
387 lines not on this page · raw message
net/batman-adv/netlink.c +1 -0
@@ -86,6 +86,7 @@ static struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = { [BATADV_ATTR_LAST_SEEN_MSECS] = { .type = NLA_U32 }, [BATADV_ATTR_NEIGH_ADDRESS] = { .len = ETH_ALEN }, [BATADV_ATTR_TQ] = { .type = NLA_U8 }, + [BATADV_ATTR_THROUGHPUT] = { .type = NLA_U32 }, };/**
Signature · 1 line
2.8.1
Simon Wunderlich
maintainerPATCH 10/16 batman-adv: netlink: add gateway table queries
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
Add BATADV_CMD_GET_GATEWAYS commands, using handlers bat_gw_dump in batadv_algo_ops. Will always return -EOPNOTSUPP for now, as no implementations exist yet.
--- include/uapi/linux/batman_adv.h | 8 ++++++ net/batman-adv/gateway_client.c | 59 +++++++++++++++++++++++++++++++++++++++++ net/batman-adv/gateway_client.h | 2 ++ net/batman-adv/netlink.c | 10 +++++++ net/batman-adv/types.h | 3 +++ 5 files changed, 82 insertions(+)
include/uapi/linux/batman_adv.h +8 -0
@@ -88,6 +88,9 @@ enum batadv_tt_client_flags {* @BATADV_ATTR_NEIGH_ADDRESS: Neighbour MAC address * @BATADV_ATTR_TQ: TQ to neighbour * @BATADV_ATTR_THROUGHPUT: Estimated throughput to Neighbour +* @BATADV_ATTR_BANDWIDTH_UP: Reported uplink bandwidth +* @BATADV_ATTR_BANDWIDTH_DOWN: Reported downlink bandwidth +* @BATADV_ATTR_ROUTER: Gateway router MAC address * @__BATADV_ATTR_AFTER_LAST: internal use * @NUM_BATADV_ATTR: total number of batadv_nl_attrs available * @BATADV_ATTR_MAX: highest attribute number currently defined
@@ -120,6 +123,9 @@ enum batadv_nl_attrs {BATADV_ATTR_NEIGH_ADDRESS ,BATADV_ATTR_TQ ,BATADV_ATTR_THROUGHPUT , +BATADV_ATTR_BANDWIDTH_UP , +BATADV_ATTR_BANDWIDTH_DOWN , +BATADV_ATTR_ROUTER ,/* add attributes above here, update the policy in netlink.c */ __BATADV_ATTR_AFTER_LAST, NUM_BATADV_ATTR = __BATADV_ATTR_AFTER_LAST,
@@ -139,6 +145,7 @@ enum batadv_nl_attrs {* @BATADV_CMD_GET_TRANSTABLE_GLOBAL Query list of global translations * @BATADV_CMD_GET_ORIGINATORS: Query list of originators * @BATADV_CMD_GET_NEIGHBORS: Query list of neighbours +* @BATADV_CMD_GET_GATEWAYS: Query list of gateways * @__BATADV_CMD_AFTER_LAST: internal use * @BATADV_CMD_MAX: highest used command number */
@@ -153,6 +160,7 @@ enum batadv_nl_commands {BATADV_CMD_GET_TRANSTABLE_GLOBAL ,BATADV_CMD_GET_ORIGINATORS ,BATADV_CMD_GET_NEIGHBORS , +BATADV_CMD_GET_GATEWAYS ,/* add new commands above here */ __BATADV_CMD_AFTER_LAST,BATADV_CMD_MAX = __BATADV_CMD_AFTER_LAST -1
net/batman-adv/gateway_client.c +59 -0
90 lines not on this page · raw message
net/batman-adv/gateway_client.h +2 -0
@@ -23,6 +23,7 @@#include <linux/types.h> struct batadv_tvlv_gateway_data ; +struct netlink_callback ;struct seq_file ;struct sk_buff ;
@@ -43,6 +44,7 @@ void batadv_gw_node_put(struct batadv_gw_node *gw_node);struct batadv_gw_node *batadv_gw_get_selected_gw_node (struct batadv_priv *bat_priv);int batadv_gw_client_seq_print_text (struct seq_file *seq,void *offset); +int batadv_gw_dump (struct sk_buff *msg,struct netlink_callback *cb);bool batadv_gw_out_of_range (struct batadv_priv *bat_priv,struct sk_buff *skb); enum batadv_dhcp_recipient batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len,
net/batman-adv/netlink.c +10 -0
@@ -38,6 +38,7 @@#include <uapi/linux/batman_adv.h> #include "bat_algo.h" +#include "gateway_client.h" #include "hard-interface.h" #include "originator.h" #include "soft-interface.h"
@@ -87,6 +88,9 @@ static struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = { [BATADV_ATTR_NEIGH_ADDRESS] = { .len = ETH_ALEN }, [BATADV_ATTR_TQ] = { .type = NLA_U8 }, [BATADV_ATTR_THROUGHPUT] = { .type = NLA_U32 }, + [BATADV_ATTR_BANDWIDTH_UP] = { .type = NLA_U32 }, + [BATADV_ATTR_BANDWIDTH_DOWN] = { .type = NLA_U32 }, + [BATADV_ATTR_ROUTER] = { .len = ETH_ALEN }, };/**
@@ -570,6 +574,12 @@ static struct genl_ops batadv_netlink_ops[] = { .policy = batadv_netlink_policy, .dumpit = batadv_hardif_neigh_dump, }, + { + .cmd = BATADV_CMD_GET_GATEWAYS, + .flags = GENL_ADMIN_PERM, + .policy = batadv_netlink_policy, + .dumpit = batadv_gw_dump, + }, };/**
net/batman-adv/types.h +3 -0
@@ -1469,6 +1469,7 @@ struct batadv_algo_orig_ops {* @is_eligible: check if a newly discovered GW is a potential candidate for * the election as best GW (optional) * @print: print the gateway table (optional) +* @dump: dump gateways to a netlink socket (optional) */ struct batadv_algo_gw_ops { ssize_t (*store_sel_class)(struct batadv_priv *bat_priv, char *buff,
@@ -1480,6 +1481,8 @@ struct batadv_algo_gw_ops {struct batadv_orig_node *curr_gw_orig, struct batadv_orig_node *orig_node);void (*print)(struct batadv_priv *bat_priv,struct seq_file *seq); +void (*dump)(struct sk_buff *msg,struct netlink_callback *cb, +struct batadv_priv *priv); };/**
Signature · 1 line
2.8.1
Simon Wunderlich
maintainerPATCH 11/16 batman-adv: add B.A.T.M.A.N. IV bat_gw_dump implementations
In reply to Simon WunderlichFrom: Andrew Lunn <[email protected]>
Dump the list of gateways via the netlink socket.
--- net/batman-adv/bat_iv_ogm.c | 105 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+)
net/batman-adv/bat_iv_ogm.c +105 -0
@@ -2681,6 +2681,110 @@ static void batadv_iv_gw_print(struct batadv_priv *bat_priv,seq_puts (seq,"No gateways in range ...\n" ); } +/** +* batadv_iv_gw_dump_entry - Dump a gateway into a message +* @msg: Netlink message to dump into +* @portid: Port making netlink request +* @seq: Sequence number of netlink message +* @bat_priv: The bat priv with all the soft interface information +* @gw_node: Gateway to be dumped +* +* Return: Error code, or 0 on success +*/ +static int batadv_iv_gw_dump_entry (struct sk_buff *msg,u32 portid,u32 seq, +struct batadv_priv *bat_priv, +struct batadv_gw_node *gw_node) +{ +struct batadv_neigh_ifinfo *router_ifinfo =NULL ; +struct batadv_neigh_node *router; +struct batadv_gw_node *curr_gw; +int ret = -EINVAL ; +void *hdr; + + router =batadv_orig_router_get (gw_node->orig_node,BATADV_IF_DEFAULT ); +if (!router) + goto out; + + router_ifinfo =batadv_neigh_ifinfo_get (router,BATADV_IF_DEFAULT ); +if (!router_ifinfo) + goto out; + + curr_gw =batadv_gw_get_selected_gw_node (bat_priv); + + hdr =genlmsg_put (msg, portid, seq, &batadv_netlink_family, +NLM_F_MULTI ,BATADV_CMD_GET_GATEWAYS ); +if (!hdr) { + ret = -ENOBUFS ; + goto out; + } + + ret = -EMSGSIZE ; + +if (curr_gw == gw_node) +if (nla_put_flag (msg,BATADV_ATTR_FLAG_BEST )) { +genlmsg_cancel (msg, hdr); + goto out; + } + +if (nla_put (msg,BATADV_ATTR_ORIG_ADDRESS ,ETH_ALEN , + gw_node->orig_node->orig) || +nla_put_u8 (msg,BATADV_ATTR_TQ , router_ifinfo->bat_iv.tq_avg) || +nla_put (msg,BATADV_ATTR_ROUTER ,ETH_ALEN , + router->addr) || +nla_put_string (msg,BATADV_ATTR_HARD_IFNAME , + router->if_incoming->net_dev->name) || +nla_put_u32 (msg,BATADV_ATTR_BANDWIDTH_DOWN , + gw_node->bandwidth_down) || +nla_put_u32 (msg,BATADV_ATTR_BANDWIDTH_UP , + gw_node->bandwidth_up)) { +genlmsg_cancel (msg, hdr); + goto out; + } + +genlmsg_end (msg, hdr); + ret =0 ; + +out: +if (router_ifinfo) +batadv_neigh_ifinfo_put (router_ifinfo); +if (router) +batadv_neigh_node_put (router); +return ret; +} + +/** +* batadv_iv_gw_dump - Dump gateways into a message +* @msg: Netlink message to dump into +* @cb: Control block containing additional options +* @bat_priv: The bat priv with all the soft interface information +*/ +static void batadv_iv_gw_dump (struct sk_buff *msg,struct netlink_callback *cb, +struct batadv_priv *bat_priv) +{ +int portid =NETLINK_CB (cb->skb).portid; +struct batadv_gw_node *gw_node; +int idx_skip = cb->args[0 ]; +int idx =0 ; + +rcu_read_lock (); +hlist_for_each_entry_rcu (gw_node, &bat_priv->gw.list, list) { +if (idx++ < idx_skip) +continue ; + +if (batadv_iv_gw_dump_entry (msg, portid, cb->nlh->nlmsg_seq, + bat_priv, gw_node)) { + idx_skip = idx -1 ; + goto unlock; + } + } + + idx_skip = idx; +unlock: +rcu_read_unlock (); + + cb->args[0 ] = idx_skip; +} +static struct batadv_algo_ops batadv_batman_iv__read_mostly = { .name ="BATMAN_IV" , .iface = {
@@ -2707,6 +2811,7 @@ static struct batadv_algo_ops batadv_batman_iv __read_mostly = { .get_best_gw_node = batadv_iv_gw_get_best_gw_node, .is_eligible = batadv_iv_gw_is_eligible, .print = batadv_iv_gw_print, + .dump = batadv_iv_gw_dump, }, };
Signature · 1 line
2.8.1
Simon Wunderlich
maintainerPATCH 12/16 batman-adv: add B.A.T.M.A.N. V bat_gw_dump implementations
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
--- net/batman-adv/bat_v.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+)
net/batman-adv/bat_v.c +125 -0
@@ -897,6 +897,130 @@ static void batadv_v_gw_print(struct batadv_priv *bat_priv,seq_puts (seq,"No gateways in range ...\n" ); } +/** +* batadv_v_gw_dump_entry - Dump a gateway into a message +* @msg: Netlink message to dump into +* @portid: Port making netlink request +* @seq: Sequence number of netlink message +* @bat_priv: The bat priv with all the soft interface information +* @gw_node: Gateway to be dumped +* +* Return: Error code, or 0 on success +*/ +static int batadv_v_gw_dump_entry (struct sk_buff *msg,u32 portid,u32 seq, +struct batadv_priv *bat_priv, +struct batadv_gw_node *gw_node) +{ +struct batadv_neigh_ifinfo *router_ifinfo =NULL ; +struct batadv_neigh_node *router; +struct batadv_gw_node *curr_gw; +int ret = -EINVAL ; +void *hdr; + + router =batadv_orig_router_get (gw_node->orig_node,BATADV_IF_DEFAULT ); +if (!router) + goto out; + + router_ifinfo =batadv_neigh_ifinfo_get (router,BATADV_IF_DEFAULT ); +if (!router_ifinfo) + goto out; + + curr_gw =batadv_gw_get_selected_gw_node (bat_priv); + + hdr =genlmsg_put (msg, portid, seq, &batadv_netlink_family, +NLM_F_MULTI ,BATADV_CMD_GET_GATEWAYS ); +if (!hdr) { + ret = -ENOBUFS ; + goto out; + } + + ret = -EMSGSIZE ; + +if (curr_gw == gw_node) { +if (nla_put_flag (msg,BATADV_ATTR_FLAG_BEST )) { +genlmsg_cancel (msg, hdr); + goto out; + } + } + +if (nla_put (msg,BATADV_ATTR_ORIG_ADDRESS ,ETH_ALEN , + gw_node->orig_node->orig)) { +genlmsg_cancel (msg, hdr); + goto out; + } + +if (nla_put_u32 (msg,BATADV_ATTR_THROUGHPUT , + router_ifinfo->bat_v.throughput)) { +genlmsg_cancel (msg, hdr); + goto out; + } + +if (nla_put (msg,BATADV_ATTR_ROUTER ,ETH_ALEN , router->addr)) { +genlmsg_cancel (msg, hdr); + goto out; + } + +if (nla_put_string (msg,BATADV_ATTR_HARD_IFNAME , + router->if_incoming->net_dev->name)) { +genlmsg_cancel (msg, hdr); + goto out; + } + +if (nla_put_u32 (msg,BATADV_ATTR_BANDWIDTH_DOWN , + gw_node->bandwidth_down)) { +genlmsg_cancel (msg, hdr); + goto out; + } + +if (nla_put_u32 (msg,BATADV_ATTR_BANDWIDTH_UP , gw_node->bandwidth_up)) { +genlmsg_cancel (msg, hdr); + goto out; + } + +genlmsg_end (msg, hdr); + ret =0 ; + +out: +if (router_ifinfo) +batadv_neigh_ifinfo_put (router_ifinfo); +if (router) +batadv_neigh_node_put (router); +return ret; +} + +/** +* batadv_v_gw_dump - Dump gateways into a message +* @msg: Netlink message to dump into +* @cb: Control block containing additional options +* @bat_priv: The bat priv with all the soft interface information +*/ +static void batadv_v_gw_dump (struct sk_buff *msg,struct netlink_callback *cb, +struct batadv_priv *bat_priv) +{ +int portid =NETLINK_CB (cb->skb).portid; +struct batadv_gw_node *gw_node; +int idx_skip = cb->args[0 ]; +int idx =0 ; + +rcu_read_lock (); +hlist_for_each_entry_rcu (gw_node, &bat_priv->gw.list, list) { +if (idx++ < idx_skip) +continue ; + +if (batadv_v_gw_dump_entry (msg, portid, cb->nlh->nlmsg_seq, + bat_priv, gw_node)) { + idx_skip = idx -1 ; + goto unlock; + } + } + + idx_skip = idx; +unlock: +rcu_read_unlock (); + + cb->args[0 ] = idx_skip; +} +static struct batadv_algo_ops batadv_batman_v__read_mostly = { .name ="BATMAN_V" , .iface = {
@@ -923,6 +1047,7 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = { .get_best_gw_node = batadv_v_gw_get_best_gw_node, .is_eligible = batadv_v_gw_is_eligible, .print = batadv_v_gw_print, + .dump = batadv_v_gw_dump, }, };
Signature · 1 line
2.8.1
Simon Wunderlich
maintainerPATCH 13/16 batman-adv: add B.A.T.M.A.N. Dump BLA claims via netlink
In reply to Simon WunderlichFrom: Andrew Lunn <[email protected]>
Dump the list of bridge loop avoidance claims via the netlink socket.
[[email protected]: add policy for attributes, fix includes, fix soft_iface reference leak]
--- include/uapi/linux/batman_adv.h | 12 +++ net/batman-adv/bridge_loop_avoidance.c | 169 +++++++++++++++++++++++++++++++++ net/batman-adv/bridge_loop_avoidance.h | 10 +- net/batman-adv/netlink.c | 12 +++ 4 files changed, 202 insertions(+), 1 deletion(-)
include/uapi/linux/batman_adv.h +12 -0
@@ -91,6 +91,11 @@ enum batadv_tt_client_flags {* @BATADV_ATTR_BANDWIDTH_UP: Reported uplink bandwidth * @BATADV_ATTR_BANDWIDTH_DOWN: Reported downlink bandwidth * @BATADV_ATTR_ROUTER: Gateway router MAC address +* @BATADV_ATTR_BLA_OWN: Flag indicating own originator +* @BATADV_ATTR_BLA_ADDRESS: Bridge loop avoidance claim MAC address +* @BATADV_ATTR_BLA_VID: BLA VLAN ID +* @BATADV_ATTR_BLA_BACKBONE: BLA gateway originator MAC address +* @BATADV_ATTR_BLA_CRC: BLA CRC * @__BATADV_ATTR_AFTER_LAST: internal use * @NUM_BATADV_ATTR: total number of batadv_nl_attrs available * @BATADV_ATTR_MAX: highest attribute number currently defined
@@ -126,6 +131,11 @@ enum batadv_nl_attrs {BATADV_ATTR_BANDWIDTH_UP ,BATADV_ATTR_BANDWIDTH_DOWN ,BATADV_ATTR_ROUTER , +BATADV_ATTR_BLA_OWN , +BATADV_ATTR_BLA_ADDRESS , +BATADV_ATTR_BLA_VID , +BATADV_ATTR_BLA_BACKBONE , +BATADV_ATTR_BLA_CRC ,/* add attributes above here, update the policy in netlink.c */ __BATADV_ATTR_AFTER_LAST, NUM_BATADV_ATTR = __BATADV_ATTR_AFTER_LAST,
@@ -146,6 +156,7 @@ enum batadv_nl_attrs {* @BATADV_CMD_GET_ORIGINATORS: Query list of originators * @BATADV_CMD_GET_NEIGHBORS: Query list of neighbours * @BATADV_CMD_GET_GATEWAYS: Query list of gateways +* @BATADV_CMD_GET_BLA_CLAIM: Query list of bridge loop avoidance claims * @__BATADV_CMD_AFTER_LAST: internal use * @BATADV_CMD_MAX: highest used command number */
@@ -161,6 +172,7 @@ enum batadv_nl_commands {BATADV_CMD_GET_ORIGINATORS ,BATADV_CMD_GET_NEIGHBORS ,BATADV_CMD_GET_GATEWAYS , +BATADV_CMD_GET_BLA_CLAIM ,/* add new commands above here */ __BATADV_CMD_AFTER_LAST,BATADV_CMD_MAX = __BATADV_CMD_AFTER_LAST -1
net/batman-adv/bridge_loop_avoidance.c +169 -0
193 lines not on this page · raw message
net/batman-adv/bridge_loop_avoidance.h +9 -1
@@ -23,6 +23,7 @@#include <linux/types.h> struct net_device ; +struct netlink_callback ;struct seq_file ;struct sk_buff ;
@@ -35,6 +36,7 @@ bool batadv_bla_is_backbone_gw(struct sk_buff *skb,struct batadv_orig_node *orig_node, int hdr_size);int batadv_bla_claim_table_seq_print_text (struct seq_file *seq,void *offset); +int batadv_bla_claim_dump (struct sk_buff *msg,struct netlink_callback *cb);int batadv_bla_backbone_table_seq_print_text (struct seq_file *seq,void *offset); bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, u8 *orig,
@@ -47,7 +49,7 @@ void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,void batadv_bla_status_update (struct net_device *net_dev);int batadv_bla_init (struct batadv_priv *bat_priv);void batadv_bla_free (struct batadv_priv *bat_priv); - +int batadv_bla_claim_dump (struct sk_buff *msg,struct netlink_callback *cb);#define BATADV_BLA_CRC_INIT 0#else /* ifdef CONFIG_BATMAN_ADV_BLA */
@@ -112,6 +114,12 @@ static inline void batadv_bla_free(struct batadv_priv *bat_priv) { } +static inline int batadv_bla_claim_dump (struct sk_buff *msg, +struct netlink_callback *cb) +{ +return -EOPNOTSUPP ; +} +#endif /* ifdef CONFIG_BATMAN_ADV_BLA */ #endif /* ifndef _NET_BATMAN_ADV_BLA_H_ */
net/batman-adv/netlink.c +12 -0
@@ -38,6 +38,7 @@#include <uapi/linux/batman_adv.h> #include "bat_algo.h" +#include "bridge_loop_avoidance.h" #include "gateway_client.h" #include "hard-interface.h" #include "originator.h"
@@ -91,6 +92,11 @@ static struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = { [BATADV_ATTR_BANDWIDTH_UP] = { .type = NLA_U32 }, [BATADV_ATTR_BANDWIDTH_DOWN] = { .type = NLA_U32 }, [BATADV_ATTR_ROUTER] = { .len = ETH_ALEN }, + [BATADV_ATTR_BLA_OWN] = { .type = NLA_FLAG }, + [BATADV_ATTR_BLA_ADDRESS] = { .len = ETH_ALEN }, + [BATADV_ATTR_BLA_VID] = { .type = NLA_U16 }, + [BATADV_ATTR_BLA_BACKBONE] = { .len = ETH_ALEN }, + [BATADV_ATTR_BLA_CRC] = { .type = NLA_U16 }, };/**
@@ -580,6 +586,12 @@ static struct genl_ops batadv_netlink_ops[] = { .policy = batadv_netlink_policy, .dumpit = batadv_gw_dump, }, + { + .cmd = BATADV_CMD_GET_BLA_CLAIM, + .flags = GENL_ADMIN_PERM, + .policy = batadv_netlink_policy, + .dumpit = batadv_bla_claim_dump, + }, };/**
Signature · 1 line
2.8.1
Simon Wunderlich
maintainerPATCH 14/16 batman-adv: Provide bla group in the mesh_info netlink msg
In reply to Simon WunderlichFrom: Sven Eckelmann <[email protected]>
The bridge loop avoidange is the main information for the debugging of of bridge loop detection problems. It is therefore necessary when comparing the bla claim tables.
--- net/batman-adv/netlink.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/batman-adv/netlink.c +8 -0
@@ -19,6 +19,7 @@#include "main.h" #include <linux/atomic.h> +#include <linux/byteorder/generic.h> #include <linux/errno.h> #include <linux/fs.h> #include <linux/genetlink.h>
@@ -42,6 +43,7 @@#include "gateway_client.h" #include "hard-interface.h" #include "originator.h" +#include "packet.h" #include "soft-interface.h" #include "tp_meter.h" #include "translation-table.h"
@@ -141,6 +143,12 @@ batadv_netlink_mesh_info_put(struct sk_buff *msg, struct net_device *soft_iface) (u8)atomic_read(&bat_priv->tt.vn))) goto out; +#ifdef CONFIG_BATMAN_ADV_BLA +if (nla_put_u16 (msg,BATADV_ATTR_BLA_CRC , +ntohs (bat_priv->bla.claim_dest.group))) + goto out; +#endif + primary_if =batadv_primary_if_get_selected (bat_priv);if (primary_if && primary_if->if_status ==BATADV_IF_ACTIVE ) { hard_iface = primary_if->net_dev;
Signature · 1 line
2.8.1
Simon Wunderlich
maintainerPATCH 15/16 batman-adv: add backbone table netlink support
In reply to Simon WunderlichDump the list of bridge loop avoidance backbones via the netlink socket.
--- include/uapi/linux/batman_adv.h | 2 + net/batman-adv/bridge_loop_avoidance.c | 164 +++++++++++++++++++++++++++++++++ net/batman-adv/bridge_loop_avoidance.h | 7 ++ net/batman-adv/netlink.c | 7 ++ 4 files changed, 180 insertions(+)
include/uapi/linux/batman_adv.h +2 -0
@@ -157,6 +157,7 @@ enum batadv_nl_attrs {* @BATADV_CMD_GET_NEIGHBORS: Query list of neighbours * @BATADV_CMD_GET_GATEWAYS: Query list of gateways * @BATADV_CMD_GET_BLA_CLAIM: Query list of bridge loop avoidance claims +* @BATADV_CMD_GET_BLA_BACKBONE: Query list of bridge loop avoidance backbones * @__BATADV_CMD_AFTER_LAST: internal use * @BATADV_CMD_MAX: highest used command number */
@@ -173,6 +174,7 @@ enum batadv_nl_commands {BATADV_CMD_GET_NEIGHBORS ,BATADV_CMD_GET_GATEWAYS ,BATADV_CMD_GET_BLA_CLAIM , +BATADV_CMD_GET_BLA_BACKBONE ,/* add new commands above here */ __BATADV_CMD_AFTER_LAST,BATADV_CMD_MAX = __BATADV_CMD_AFTER_LAST -1
net/batman-adv/bridge_loop_avoidance.c +164 -0
167 lines not on this page · raw message
net/batman-adv/bridge_loop_avoidance.h +7 -0
@@ -39,6 +39,7 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset);int batadv_bla_claim_dump (struct sk_buff *msg,struct netlink_callback *cb);int batadv_bla_backbone_table_seq_print_text (struct seq_file *seq,void *offset); +int batadv_bla_backbone_dump (struct sk_buff *msg,struct netlink_callback *cb);bool batadv_bla_is_backbone_gw_orig (struct batadv_priv *bat_priv,u8 *orig,unsigned short vid); bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
@@ -120,6 +121,12 @@ static inline int batadv_bla_claim_dump(struct sk_buff *msg,return -EOPNOTSUPP ; } +static inline int batadv_bla_backbone_dump (struct sk_buff *msg, +struct netlink_callback *cb) +{ +return -EOPNOTSUPP ; +} +#endif /* ifdef CONFIG_BATMAN_ADV_BLA */ #endif /* ifndef _NET_BATMAN_ADV_BLA_H_ */
net/batman-adv/netlink.c +7 -0
@@ -600,6 +600,13 @@ static struct genl_ops batadv_netlink_ops[] = { .policy = batadv_netlink_policy, .dumpit = batadv_bla_claim_dump, }, + { + .cmd = BATADV_CMD_GET_BLA_BACKBONE, + .flags = GENL_ADMIN_PERM, + .policy = batadv_netlink_policy, + .dumpit = batadv_bla_backbone_dump, + }, + };/**
Signature · 1 line
2.8.1
Simon Wunderlich
maintainerPATCH 16/16 batman-adv: Indicate netlink socket can be used with netns.
In reply to Simon WunderlichFrom: Andrew Lunn <[email protected]>
Set the netnsof flag on the family structure, indicating it can be used with different network name spaces.
--- net/batman-adv/netlink.c | 1 + 1 file changed, 1 insertion(+)
net/batman-adv/netlink.c +1 -0
@@ -54,6 +54,7 @@ struct genl_family batadv_netlink_family = { .name = BATADV_NL_NAME, .version = 1, .maxattr = BATADV_ATTR_MAX, + .netnsok = true, };/* multicast groups */
Signature · 1 line
2.8.1
David Miller
maintainerFrom: Simon Wunderlich <[email protected]>
Date: Tue, 16 Aug 2016 10:32:28 +0200
Quoted 5 lines
this is our second feature pull request for batman-adv in this round, with our joint work on netlink and netns support. There will be at least one more pull request coming later.
Please pull or let me know of any problem!
Pulled, thanks Simon.