Skip to content

Commit 00062a9

Browse files
committed
Merge tag 'batadv-next-for-davem-20160816' of git://git.open-mesh.org/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 <[email protected]>
2 parents 268ef4b + 4c09a08 commit 00062a9

19 files changed

+2348
-48
lines changed

include/uapi/linux/batman_adv.h

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,42 @@
2222

2323
#define BATADV_NL_MCAST_GROUP_TPMETER "tpmeter"
2424

25+
/**
26+
* enum batadv_tt_client_flags - TT client specific flags
27+
* @BATADV_TT_CLIENT_DEL: the client has to be deleted from the table
28+
* @BATADV_TT_CLIENT_ROAM: the client roamed to/from another node and the new
29+
* update telling its new real location has not been received/sent yet
30+
* @BATADV_TT_CLIENT_WIFI: this client is connected through a wifi interface.
31+
* This information is used by the "AP Isolation" feature
32+
* @BATADV_TT_CLIENT_ISOLA: this client is considered "isolated". This
33+
* information is used by the Extended Isolation feature
34+
* @BATADV_TT_CLIENT_NOPURGE: this client should never be removed from the table
35+
* @BATADV_TT_CLIENT_NEW: this client has been added to the local table but has
36+
* not been announced yet
37+
* @BATADV_TT_CLIENT_PENDING: this client is marked for removal but it is kept
38+
* in the table for one more originator interval for consistency purposes
39+
* @BATADV_TT_CLIENT_TEMP: this global client has been detected to be part of
40+
* the network but no nnode has already announced it
41+
*
42+
* Bits from 0 to 7 are called _remote flags_ because they are sent on the wire.
43+
* Bits from 8 to 15 are called _local flags_ because they are used for local
44+
* computations only.
45+
*
46+
* Bits from 4 to 7 - a subset of remote flags - are ensured to be in sync with
47+
* the other nodes in the network. To achieve this goal these flags are included
48+
* in the TT CRC computation.
49+
*/
50+
enum batadv_tt_client_flags {
51+
BATADV_TT_CLIENT_DEL = (1 << 0),
52+
BATADV_TT_CLIENT_ROAM = (1 << 1),
53+
BATADV_TT_CLIENT_WIFI = (1 << 4),
54+
BATADV_TT_CLIENT_ISOLA = (1 << 5),
55+
BATADV_TT_CLIENT_NOPURGE = (1 << 8),
56+
BATADV_TT_CLIENT_NEW = (1 << 9),
57+
BATADV_TT_CLIENT_PENDING = (1 << 10),
58+
BATADV_TT_CLIENT_TEMP = (1 << 11),
59+
};
60+
2561
/**
2662
* enum batadv_nl_attrs - batman-adv netlink attributes
2763
*
@@ -40,6 +76,26 @@
4076
* @BATADV_ATTR_TPMETER_BYTES: amount of acked bytes during run
4177
* @BATADV_ATTR_TPMETER_COOKIE: session cookie to match tp_meter session
4278
* @BATADV_ATTR_PAD: attribute used for padding for 64-bit alignment
79+
* @BATADV_ATTR_ACTIVE: Flag indicating if the hard interface is active
80+
* @BATADV_ATTR_TT_ADDRESS: Client MAC address
81+
* @BATADV_ATTR_TT_TTVN: Translation table version
82+
* @BATADV_ATTR_TT_LAST_TTVN: Previous translation table version
83+
* @BATADV_ATTR_TT_CRC32: CRC32 over translation table
84+
* @BATADV_ATTR_TT_VID: VLAN ID
85+
* @BATADV_ATTR_TT_FLAGS: Translation table client flags
86+
* @BATADV_ATTR_FLAG_BEST: Flags indicating entry is the best
87+
* @BATADV_ATTR_LAST_SEEN_MSECS: Time in milliseconds since last seen
88+
* @BATADV_ATTR_NEIGH_ADDRESS: Neighbour MAC address
89+
* @BATADV_ATTR_TQ: TQ to neighbour
90+
* @BATADV_ATTR_THROUGHPUT: Estimated throughput to Neighbour
91+
* @BATADV_ATTR_BANDWIDTH_UP: Reported uplink bandwidth
92+
* @BATADV_ATTR_BANDWIDTH_DOWN: Reported downlink bandwidth
93+
* @BATADV_ATTR_ROUTER: Gateway router MAC address
94+
* @BATADV_ATTR_BLA_OWN: Flag indicating own originator
95+
* @BATADV_ATTR_BLA_ADDRESS: Bridge loop avoidance claim MAC address
96+
* @BATADV_ATTR_BLA_VID: BLA VLAN ID
97+
* @BATADV_ATTR_BLA_BACKBONE: BLA gateway originator MAC address
98+
* @BATADV_ATTR_BLA_CRC: BLA CRC
4399
* @__BATADV_ATTR_AFTER_LAST: internal use
44100
* @NUM_BATADV_ATTR: total number of batadv_nl_attrs available
45101
* @BATADV_ATTR_MAX: highest attribute number currently defined
@@ -60,6 +116,26 @@ enum batadv_nl_attrs {
60116
BATADV_ATTR_TPMETER_BYTES,
61117
BATADV_ATTR_TPMETER_COOKIE,
62118
BATADV_ATTR_PAD,
119+
BATADV_ATTR_ACTIVE,
120+
BATADV_ATTR_TT_ADDRESS,
121+
BATADV_ATTR_TT_TTVN,
122+
BATADV_ATTR_TT_LAST_TTVN,
123+
BATADV_ATTR_TT_CRC32,
124+
BATADV_ATTR_TT_VID,
125+
BATADV_ATTR_TT_FLAGS,
126+
BATADV_ATTR_FLAG_BEST,
127+
BATADV_ATTR_LAST_SEEN_MSECS,
128+
BATADV_ATTR_NEIGH_ADDRESS,
129+
BATADV_ATTR_TQ,
130+
BATADV_ATTR_THROUGHPUT,
131+
BATADV_ATTR_BANDWIDTH_UP,
132+
BATADV_ATTR_BANDWIDTH_DOWN,
133+
BATADV_ATTR_ROUTER,
134+
BATADV_ATTR_BLA_OWN,
135+
BATADV_ATTR_BLA_ADDRESS,
136+
BATADV_ATTR_BLA_VID,
137+
BATADV_ATTR_BLA_BACKBONE,
138+
BATADV_ATTR_BLA_CRC,
63139
/* add attributes above here, update the policy in netlink.c */
64140
__BATADV_ATTR_AFTER_LAST,
65141
NUM_BATADV_ATTR = __BATADV_ATTR_AFTER_LAST,
@@ -73,6 +149,15 @@ enum batadv_nl_attrs {
73149
* @BATADV_CMD_GET_MESH_INFO: Query basic information about batman-adv device
74150
* @BATADV_CMD_TP_METER: Start a tp meter session
75151
* @BATADV_CMD_TP_METER_CANCEL: Cancel a tp meter session
152+
* @BATADV_CMD_GET_ROUTING_ALGOS: Query the list of routing algorithms.
153+
* @BATADV_CMD_GET_HARDIFS: Query list of hard interfaces
154+
* @BATADV_CMD_GET_TRANSTABLE_LOCAL: Query list of local translations
155+
* @BATADV_CMD_GET_TRANSTABLE_GLOBAL Query list of global translations
156+
* @BATADV_CMD_GET_ORIGINATORS: Query list of originators
157+
* @BATADV_CMD_GET_NEIGHBORS: Query list of neighbours
158+
* @BATADV_CMD_GET_GATEWAYS: Query list of gateways
159+
* @BATADV_CMD_GET_BLA_CLAIM: Query list of bridge loop avoidance claims
160+
* @BATADV_CMD_GET_BLA_BACKBONE: Query list of bridge loop avoidance backbones
76161
* @__BATADV_CMD_AFTER_LAST: internal use
77162
* @BATADV_CMD_MAX: highest used command number
78163
*/
@@ -81,6 +166,15 @@ enum batadv_nl_commands {
81166
BATADV_CMD_GET_MESH_INFO,
82167
BATADV_CMD_TP_METER,
83168
BATADV_CMD_TP_METER_CANCEL,
169+
BATADV_CMD_GET_ROUTING_ALGOS,
170+
BATADV_CMD_GET_HARDIFS,
171+
BATADV_CMD_GET_TRANSTABLE_LOCAL,
172+
BATADV_CMD_GET_TRANSTABLE_GLOBAL,
173+
BATADV_CMD_GET_ORIGINATORS,
174+
BATADV_CMD_GET_NEIGHBORS,
175+
BATADV_CMD_GET_GATEWAYS,
176+
BATADV_CMD_GET_BLA_CLAIM,
177+
BATADV_CMD_GET_BLA_BACKBONE,
84178
/* add new commands above here */
85179
__BATADV_CMD_AFTER_LAST,
86180
BATADV_CMD_MAX = __BATADV_CMD_AFTER_LAST - 1

net/batman-adv/bat_algo.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,18 @@
2020
#include <linux/errno.h>
2121
#include <linux/list.h>
2222
#include <linux/moduleparam.h>
23+
#include <linux/netlink.h>
2324
#include <linux/printk.h>
2425
#include <linux/seq_file.h>
26+
#include <linux/skbuff.h>
2527
#include <linux/stddef.h>
2628
#include <linux/string.h>
29+
#include <net/genetlink.h>
30+
#include <net/netlink.h>
31+
#include <uapi/linux/batman_adv.h>
2732

2833
#include "bat_algo.h"
34+
#include "netlink.h"
2935

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

139145
module_param_cb(routing_algo, &batadv_param_ops_ra, &batadv_param_string_ra,
140146
0644);
147+
148+
/**
149+
* batadv_algo_dump_entry - fill in information about one supported routing
150+
* algorithm
151+
* @msg: netlink message to be sent back
152+
* @portid: Port to reply to
153+
* @seq: Sequence number of message
154+
* @bat_algo_ops: Algorithm to be dumped
155+
*
156+
* Return: Error number, or 0 on success
157+
*/
158+
static int batadv_algo_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
159+
struct batadv_algo_ops *bat_algo_ops)
160+
{
161+
void *hdr;
162+
163+
hdr = genlmsg_put(msg, portid, seq, &batadv_netlink_family,
164+
NLM_F_MULTI, BATADV_CMD_GET_ROUTING_ALGOS);
165+
if (!hdr)
166+
return -EMSGSIZE;
167+
168+
if (nla_put_string(msg, BATADV_ATTR_ALGO_NAME, bat_algo_ops->name))
169+
goto nla_put_failure;
170+
171+
genlmsg_end(msg, hdr);
172+
return 0;
173+
174+
nla_put_failure:
175+
genlmsg_cancel(msg, hdr);
176+
return -EMSGSIZE;
177+
}
178+
179+
/**
180+
* batadv_algo_dump - fill in information about supported routing
181+
* algorithms
182+
* @msg: netlink message to be sent back
183+
* @cb: Parameters to the netlink request
184+
*
185+
* Return: Length of reply message.
186+
*/
187+
int batadv_algo_dump(struct sk_buff *msg, struct netlink_callback *cb)
188+
{
189+
int portid = NETLINK_CB(cb->skb).portid;
190+
struct batadv_algo_ops *bat_algo_ops;
191+
int skip = cb->args[0];
192+
int i = 0;
193+
194+
hlist_for_each_entry(bat_algo_ops, &batadv_algo_list, list) {
195+
if (i++ < skip)
196+
continue;
197+
198+
if (batadv_algo_dump_entry(msg, portid, cb->nlh->nlmsg_seq,
199+
bat_algo_ops)) {
200+
i--;
201+
break;
202+
}
203+
}
204+
205+
cb->args[0] = i;
206+
207+
return msg->len;
208+
}

net/batman-adv/bat_algo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222

2323
#include <linux/types.h>
2424

25+
struct netlink_callback;
2526
struct seq_file;
27+
struct sk_buff;
2628

2729
extern char batadv_routing_algo[];
2830
extern struct list_head batadv_hardif_list;
@@ -31,5 +33,6 @@ void batadv_algo_init(void);
3133
int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops);
3234
int batadv_algo_select(struct batadv_priv *bat_priv, char *name);
3335
int batadv_algo_seq_print_text(struct seq_file *seq, void *offset);
36+
int batadv_algo_dump(struct sk_buff *msg, struct netlink_callback *cb);
3437

3538
#endif /* _NET_BATMAN_ADV_BAT_ALGO_H_ */

0 commit comments

Comments
 (0)