Skip to content

Commit

Permalink
Merge tag 'batadv-next-for-davem-20160816' of git://git.open-mesh.org…
Browse files Browse the repository at this point in the history
…/linux-merge

Simon Wunderlich says:

====================
pull request for net-next: batman-adv 2016-08-16

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)
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Aug 17, 2016
2 parents 268ef4b + 4c09a08 commit 00062a9
Show file tree
Hide file tree
Showing 19 changed files with 2,348 additions and 48 deletions.
94 changes: 94 additions & 0 deletions include/uapi/linux/batman_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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
*
Expand All @@ -40,6 +76,26 @@
* @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_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_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_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
Expand All @@ -60,6 +116,26 @@ enum batadv_nl_attrs {
BATADV_ATTR_TPMETER_BYTES,
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,
BATADV_ATTR_NEIGH_ADDRESS,
BATADV_ATTR_TQ,
BATADV_ATTR_THROUGHPUT,
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,
Expand All @@ -73,6 +149,15 @@ 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_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_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
*/
Expand All @@ -81,6 +166,15 @@ enum batadv_nl_commands {
BATADV_CMD_GET_MESH_INFO,
BATADV_CMD_TP_METER,
BATADV_CMD_TP_METER_CANCEL,
BATADV_CMD_GET_ROUTING_ALGOS,
BATADV_CMD_GET_HARDIFS,
BATADV_CMD_GET_TRANSTABLE_LOCAL,
BATADV_CMD_GET_TRANSTABLE_GLOBAL,
BATADV_CMD_GET_ORIGINATORS,
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
Expand Down
68 changes: 68 additions & 0 deletions net/batman-adv/bat_algo.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@
#include <linux/errno.h>
#include <linux/list.h>
#include <linux/moduleparam.h>
#include <linux/netlink.h>
#include <linux/printk.h>
#include <linux/seq_file.h>
#include <linux/skbuff.h>
#include <linux/stddef.h>
#include <linux/string.h>
#include <net/genetlink.h>
#include <net/netlink.h>
#include <uapi/linux/batman_adv.h>

#include "bat_algo.h"
#include "netlink.h"

char batadv_routing_algo[20] = "BATMAN_IV";
static struct hlist_head batadv_algo_list;
Expand Down Expand Up @@ -138,3 +144,65 @@ static struct kparam_string batadv_param_string_ra = {

module_param_cb(routing_algo, &batadv_param_ops_ra, &batadv_param_string_ra,
0644);

/**
* batadv_algo_dump_entry - fill in information about one supported routing
* algorithm
* @msg: netlink message to be sent back
* @portid: Port to reply to
* @seq: Sequence number of message
* @bat_algo_ops: Algorithm to be dumped
*
* Return: Error number, or 0 on success
*/
static int batadv_algo_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
struct batadv_algo_ops *bat_algo_ops)
{
void *hdr;

hdr = genlmsg_put(msg, portid, seq, &batadv_netlink_family,
NLM_F_MULTI, BATADV_CMD_GET_ROUTING_ALGOS);
if (!hdr)
return -EMSGSIZE;

if (nla_put_string(msg, BATADV_ATTR_ALGO_NAME, bat_algo_ops->name))
goto nla_put_failure;

genlmsg_end(msg, hdr);
return 0;

nla_put_failure:
genlmsg_cancel(msg, hdr);
return -EMSGSIZE;
}

/**
* batadv_algo_dump - fill in information about supported routing
* algorithms
* @msg: netlink message to be sent back
* @cb: Parameters to the netlink request
*
* Return: Length of reply message.
*/
int batadv_algo_dump(struct sk_buff *msg, struct netlink_callback *cb)
{
int portid = NETLINK_CB(cb->skb).portid;
struct batadv_algo_ops *bat_algo_ops;
int skip = cb->args[0];
int i = 0;

hlist_for_each_entry(bat_algo_ops, &batadv_algo_list, list) {
if (i++ < skip)
continue;

if (batadv_algo_dump_entry(msg, portid, cb->nlh->nlmsg_seq,
bat_algo_ops)) {
i--;
break;
}
}

cb->args[0] = i;

return msg->len;
}
3 changes: 3 additions & 0 deletions net/batman-adv/bat_algo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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_ */
Loading

0 comments on commit 00062a9

Please sign in to comment.