aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2016-05-09 12:41:08 -0400
committerSimon Wunderlich <sw@simonwunderlich.de>2016-07-04 06:37:17 -0400
commit09748a22f4ab7b0ab5a83c432f6e18f65f18e09b (patch)
tree292aa3df79676ddf2cf06b9d8fb9ae6ea8e376de
parenta2d0816608df1ca69fcdbb9135a2b6df0c65d954 (diff)
batman-adv: add generic netlink family for batman-adv
debugfs is currently severely broken virtually everywhere in the kernel where files are dynamically added and removed (see http://lkml.iu.edu/hypermail/linux/kernel/1506.1/02196.html for some details). In addition to that, debugfs is not namespace-aware. Instead of adding new debugfs entries, the whole infrastructure should be moved to netlink. This will fix the long standing problem of large buffers for debug tables and hard to parse text files. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net> Signed-off-by: Andrew Lunn <andrew@lunn.ch> [sven.eckelmann@open-mesh.com: Strip down patch to only add genl family, add missing kerneldoc] Signed-off-by: Sven Eckelmann <sven.eckelmann@open-mesh.com> Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch> Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
-rw-r--r--MAINTAINERS1
-rw-r--r--include/uapi/linux/batman_adv.h53
-rw-r--r--net/batman-adv/Makefile1
-rw-r--r--net/batman-adv/main.c3
-rw-r--r--net/batman-adv/netlink.c57
-rw-r--r--net/batman-adv/netlink.h26
6 files changed, 141 insertions, 0 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 0e26025718c2..e25091f4e583 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2291,6 +2291,7 @@ S: Maintained
2291F: Documentation/ABI/testing/sysfs-class-net-batman-adv 2291F: Documentation/ABI/testing/sysfs-class-net-batman-adv
2292F: Documentation/ABI/testing/sysfs-class-net-mesh 2292F: Documentation/ABI/testing/sysfs-class-net-mesh
2293F: Documentation/networking/batman-adv.txt 2293F: Documentation/networking/batman-adv.txt
2294F: include/uapi/linux/batman_adv.h
2294F: net/batman-adv/ 2295F: net/batman-adv/
2295 2296
2296BAYCOM/HDLCDRV DRIVERS FOR AX.25 2297BAYCOM/HDLCDRV DRIVERS FOR AX.25
diff --git a/include/uapi/linux/batman_adv.h b/include/uapi/linux/batman_adv.h
new file mode 100644
index 000000000000..79f797281b87
--- /dev/null
+++ b/include/uapi/linux/batman_adv.h
@@ -0,0 +1,53 @@
1/* Copyright (C) 2016 B.A.T.M.A.N. contributors:
2 *
3 * Matthias Schiffer
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#ifndef _UAPI_LINUX_BATMAN_ADV_H_
19#define _UAPI_LINUX_BATMAN_ADV_H_
20
21#define BATADV_NL_NAME "batadv"
22
23/**
24 * enum batadv_nl_attrs - batman-adv netlink attributes
25 *
26 * @BATADV_ATTR_UNSPEC: unspecified attribute to catch errors
27 * @__BATADV_ATTR_AFTER_LAST: internal use
28 * @NUM_BATADV_ATTR: total number of batadv_nl_attrs available
29 * @BATADV_ATTR_MAX: highest attribute number currently defined
30 */
31enum batadv_nl_attrs {
32 BATADV_ATTR_UNSPEC,
33 /* add attributes above here, update the policy in netlink.c */
34 __BATADV_ATTR_AFTER_LAST,
35 NUM_BATADV_ATTR = __BATADV_ATTR_AFTER_LAST,
36 BATADV_ATTR_MAX = __BATADV_ATTR_AFTER_LAST - 1
37};
38
39/**
40 * enum batadv_nl_commands - supported batman-adv netlink commands
41 *
42 * @BATADV_CMD_UNSPEC: unspecified command to catch errors
43 * @__BATADV_CMD_AFTER_LAST: internal use
44 * @BATADV_CMD_MAX: highest used command number
45 */
46enum batadv_nl_commands {
47 BATADV_CMD_UNSPEC,
48 /* add new commands above here */
49 __BATADV_CMD_AFTER_LAST,
50 BATADV_CMD_MAX = __BATADV_CMD_AFTER_LAST - 1
51};
52
53#endif /* _UAPI_LINUX_BATMAN_ADV_H_ */
diff --git a/net/batman-adv/Makefile b/net/batman-adv/Makefile
index a55f4ec97068..7da59014e134 100644
--- a/net/batman-adv/Makefile
+++ b/net/batman-adv/Makefile
@@ -35,6 +35,7 @@ batman-adv-y += icmp_socket.o
35batman-adv-$(CONFIG_BATMAN_ADV_DEBUG) += log.o 35batman-adv-$(CONFIG_BATMAN_ADV_DEBUG) += log.o
36batman-adv-y += main.o 36batman-adv-y += main.o
37batman-adv-$(CONFIG_BATMAN_ADV_MCAST) += multicast.o 37batman-adv-$(CONFIG_BATMAN_ADV_MCAST) += multicast.o
38batman-adv-y += netlink.o
38batman-adv-$(CONFIG_BATMAN_ADV_NC) += network-coding.o 39batman-adv-$(CONFIG_BATMAN_ADV_NC) += network-coding.o
39batman-adv-y += originator.o 40batman-adv-y += originator.o
40batman-adv-y += routing.o 41batman-adv-y += routing.o
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index eab9d1b8a6eb..275604b7c64e 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -57,6 +57,7 @@
57#include "icmp_socket.h" 57#include "icmp_socket.h"
58#include "log.h" 58#include "log.h"
59#include "multicast.h" 59#include "multicast.h"
60#include "netlink.h"
60#include "network-coding.h" 61#include "network-coding.h"
61#include "originator.h" 62#include "originator.h"
62#include "packet.h" 63#include "packet.h"
@@ -99,6 +100,7 @@ static int __init batadv_init(void)
99 100
100 register_netdevice_notifier(&batadv_hard_if_notifier); 101 register_netdevice_notifier(&batadv_hard_if_notifier);
101 rtnl_link_register(&batadv_link_ops); 102 rtnl_link_register(&batadv_link_ops);
103 batadv_netlink_register();
102 104
103 pr_info("B.A.T.M.A.N. advanced %s (compatibility version %i) loaded\n", 105 pr_info("B.A.T.M.A.N. advanced %s (compatibility version %i) loaded\n",
104 BATADV_SOURCE_VERSION, BATADV_COMPAT_VERSION); 106 BATADV_SOURCE_VERSION, BATADV_COMPAT_VERSION);
@@ -109,6 +111,7 @@ static int __init batadv_init(void)
109static void __exit batadv_exit(void) 111static void __exit batadv_exit(void)
110{ 112{
111 batadv_debugfs_destroy(); 113 batadv_debugfs_destroy();
114 batadv_netlink_unregister();
112 rtnl_link_unregister(&batadv_link_ops); 115 rtnl_link_unregister(&batadv_link_ops);
113 unregister_netdevice_notifier(&batadv_hard_if_notifier); 116 unregister_netdevice_notifier(&batadv_hard_if_notifier);
114 batadv_hardif_remove_interfaces(); 117 batadv_hardif_remove_interfaces();
diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c
new file mode 100644
index 000000000000..9e4c865a9cc0
--- /dev/null
+++ b/net/batman-adv/netlink.c
@@ -0,0 +1,57 @@
1/* Copyright (C) 2016 B.A.T.M.A.N. contributors:
2 *
3 * Matthias Schiffer
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public
7 * License as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "netlink.h"
19#include "main.h"
20
21#include <linux/genetlink.h>
22#include <linux/init.h>
23#include <linux/printk.h>
24#include <net/genetlink.h>
25#include <uapi/linux/batman_adv.h>
26
27static struct genl_family batadv_netlink_family = {
28 .id = GENL_ID_GENERATE,
29 .hdrsize = 0,
30 .name = BATADV_NL_NAME,
31 .version = 1,
32 .maxattr = BATADV_ATTR_MAX,
33};
34
35static struct genl_ops batadv_netlink_ops[] = {
36};
37
38/**
39 * batadv_netlink_register - register batadv genl netlink family
40 */
41void __init batadv_netlink_register(void)
42{
43 int ret;
44
45 ret = genl_register_family_with_ops(&batadv_netlink_family,
46 batadv_netlink_ops);
47 if (ret)
48 pr_warn("unable to register netlink family");
49}
50
51/**
52 * batadv_netlink_unregister - unregister batadv genl netlink family
53 */
54void batadv_netlink_unregister(void)
55{
56 genl_unregister_family(&batadv_netlink_family);
57}
diff --git a/net/batman-adv/netlink.h b/net/batman-adv/netlink.h
new file mode 100644
index 000000000000..39044ccff662
--- /dev/null
+++ b/net/batman-adv/netlink.h
@@ -0,0 +1,26 @@
1/* Copyright (C) 2016 B.A.T.M.A.N. contributors:
2 *
3 * Matthias Schiffer
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public
7 * License as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef _NET_BATMAN_ADV_NETLINK_H_
19#define _NET_BATMAN_ADV_NETLINK_H_
20
21#include "main.h"
22
23void batadv_netlink_register(void);
24void batadv_netlink_unregister(void);
25
26#endif /* _NET_BATMAN_ADV_NETLINK_H_ */