[v4,00/12] netns and netlink support

Message ID 1495261.OkJHpVOaGk@bentobox (mailing list archive)
State Not Applicable, archived
Headers

Commit Message

Sven Eckelmann May 9, 2016, 6:50 p.m. UTC
  On Monday 09 May 2016 20:29:21 Sven Eckelmann wrote:
> On Monday 09 May 2016 20:07:07 Andrew Lunn wrote:
> > This patchset completes netns support, by disabling debugfs entries
> > when not in the default name space, and correctly handling interface
> > stack loops when the parent is in a different name space.
> > 
> > It additionally adds netlink support for most of the information found
> > in debugfs, and is netns awaire.
> 
> Attached is a tarball with the v4 version rebased on the two initial patches
> from the tp_meter patchset. The patches include many TODOs in the kernel-doc
> which should be replaced with actual docs.
> 
> The batctl patch was not yet rebased.

Just tried it and it is not really a big thing to rebase batctl. I have again
taken the initial two patches of the tp_meter patchset.

I hope this helps to reduce the conflicts (even when not resolving it
completely) between the tp_meter and the netlink patchset.

Kind regards,
	Sven
  

Comments

Andrew Lunn May 9, 2016, 7:06 p.m. UTC | #1
> I hope this helps to reduce the conflicts (even when not resolving it
> completely) between the tp_meter and the netlink patchset.

Hi Sven

Do you want to take over my patches and merge them all into one set?

   Andrew
  
Sven Eckelmann May 10, 2016, 7 a.m. UTC | #2
On Monday 09 May 2016 21:06:08 Andrew Lunn wrote:
> > I hope this helps to reduce the conflicts (even when not resolving it
> > completely) between the tp_meter and the netlink patchset.
> 
> Hi Sven
> 
> Do you want to take over my patches and merge them all into one set?

No, this is the last thing I want to do :)

I only want to get the "big" conflicts solved and mark the parts which most
likely will needs to be changed before Marek will accept them.

I will have not much time in the next days to do any private work on it. So it
most likely not the best idea to give me the patchset with a lot of TODOs in
it ;)

I will try to poke Antonio and Marek some more so we get a common starting 
point (the two patches from batctl/batman-adv) which we then can use prepare 
our patchsets with a lot less conflicts.

Kind regards,
	Sven
  
Sven Eckelmann May 10, 2016, 9:25 a.m. UTC | #3
On Tuesday 10 May 2016 09:00:49 Sven Eckelmann wrote:
> On Monday 09 May 2016 21:06:08 Andrew Lunn wrote:
> > > I hope this helps to reduce the conflicts (even when not resolving it
> > > completely) between the tp_meter and the netlink patchset.
> > 
> > Hi Sven
> > 
> > Do you want to take over my patches and merge them all into one set?
> 
> No, this is the last thing I want to do :)
> 
> I only want to get the "big" conflicts solved and mark the parts which most
> likely will needs to be changed before Marek will accept them.
> 
> I will have not much time in the next days to do any private work on it. So it
> most likely not the best idea to give me the patchset with a lot of TODOs in
> it ;)
> 
> I will try to poke Antonio and Marek some more so we get a common starting 
> point (the two patches from batctl/batman-adv) which we then can use prepare 
> our patchsets with a lot less conflicts.

Some reports which I forgot to mention yesterday and which I've just remembered:


bracket_align master ./net/batman-adv/bat_iv_ogm.c
--------------------------------------------------

    Found wrong alignment at ./net/batman-adv/bat_iv_ogm.c:2371, was 37 but expected 61
    Found wrong alignment at ./net/batman-adv/bat_iv_ogm.c:2372, was 37 but expected 61


checkpatch master ./net/batman-adv/bat_v.c
------------------------------------------

    CHECK: Please don't use multiple blank lines
    #450: FILE: ./net/batman-adv/bat_v.c:450:
    +
    +
    
    total: 0 errors, 0 warnings, 1 checks, 732 lines checked

Kind regards,
	Sven
  

Patch

diff --git a/Makefile b/Makefile
index 60795f7..3fa21f4 100755
--- a/Makefile
+++ b/Makefile
@@ -24,7 +24,20 @@  export CONFIG_BATCTL_BISECT=n
 
 # batctl build
 BINARY_NAME = batctl
-OBJ = main.o bat-hosts.o functions.o sys.o debug.o ping.o traceroute.o tcpdump.o  hash.o debugfs.o ioctl.o list-batman.o translate.o netlink.o
+OBJ += bat-hosts.o
+OBJ += debugfs.o
+OBJ += debug.o
+OBJ += functions.o
+OBJ += hash.o
+OBJ += ioctl.o
+OBJ += list-batman.o
+OBJ += main.o
+OBJ += netlink.o
+OBJ += ping.o
+OBJ += sys.o
+OBJ += tcpdump.o
+OBJ += traceroute.o
+OBJ += translate.o
 OBJ_BISECT = bisect_iv.o
 MANPAGE = man/batctl.8
 
diff --git a/batman_adv.h b/batman_adv.h
index 6a97a2c..4c8e526 100644
--- a/batman_adv.h
+++ b/batman_adv.h
@@ -56,7 +56,44 @@  enum batadv_tt_client_flags {
 	BATADV_TT_CLIENT_TEMP	 = (1 << 11),
 };
 
-enum {
+/**
+ * enum batadv_nl_attrs - batman-adv netlink attributes
+ *
+ * @BATADV_ATTR_UNSPEC: unspecified attribute to catch errors
+ * @BATADV_ATTR_VERSION: batman-adv version string
+ * @BATADV_ATTR_ALGO_NAME: name of routing algorithm
+ * @BATADV_ATTR_MESH_IFINDEX: index of the batman-adv interface
+ * @BATADV_ATTR_MESH_IFNAME: name of the batman-adv interface
+ * @BATADV_ATTR_MESH_ADDRESS: mac address of the batman-adv interface
+ * @BATADV_ATTR_HARD_IFINDEX: index of the non-batman-adv interface
+ * @BATADV_ATTR_HARD_IFNAME: name of the non-batman-adv interface
+ * @BATADV_ATTR_HARD_ADDRESS: mac address of the non-batman-adv interface
+ * @BATADV_ATTR_ACTIVE: TODO
+ * @BATADV_ATTR_ORIG_ADDRESS: TODO
+ * @BATADV_ATTR_TT_ADDRESS: TODO
+ * @BATADV_ATTR_TT_TTVN: TODO
+ * @BATADV_ATTR_TT_LAST_TTVN: TODO
+ * @BATADV_ATTR_TT_CRC32: TODO
+ * @BATADV_ATTR_TT_VID: TODO
+ * @BATADV_ATTR_TT_FLAGS: TODO
+ * @BATADV_ATTR_FLAG_BEST: TODO
+ * @BATADV_ATTR_LAST_SEEN_MSECS: TODO
+ * @BATADV_ATTR_NEIGH_ADDRESS: TODO
+ * @BATADV_ATTR_TQ: TODO
+ * @BATADV_ATTR_THROUGHPUT: TODO
+ * @BATADV_ATTR_BANDWIDTH_UP: TODO
+ * @BATADV_ATTR_BANDWIDTH_DOWN: TODO
+ * @BATADV_ATTR_ROUTER: TODO
+ * @BATADV_ATTR_BLA_OWN: TODO
+ * @BATADV_ATTR_BLA_ADDRESS: TODO
+ * @BATADV_ATTR_BLA_VID: TODO
+ * @BATADV_ATTR_BLA_BACKBONE: TODO
+ * @BATADV_ATTR_BLA_CRC: TODO
+ * @__BATADV_ATTR_AFTER_LAST: internal use
+ * @NUM_BATADV_ATTR: total number of batadv_nl_attrs available
+ * @BATADV_ATTR_MAX: highest attribute number currently defined
+ */
+enum batadv_nl_attrs {
 	BATADV_ATTR_UNSPEC,
 	BATADV_ATTR_VERSION,
 	BATADV_ATTR_ALGO_NAME,
@@ -87,15 +124,32 @@  enum {
 	BATADV_ATTR_BLA_VID,
 	BATADV_ATTR_BLA_BACKBONE,
 	BATADV_ATTR_BLA_CRC,
-	__BATADV_ATTR_MAX,
+	/* add attributes above here, update the policy in netlink.c */
+	__BATADV_ATTR_AFTER_LAST,
+	NUM_BATADV_ATTR = __BATADV_ATTR_AFTER_LAST,
+	BATADV_ATTR_MAX = __BATADV_ATTR_AFTER_LAST - 1
 };
 
-#define BATADV_ATTR_MAX (__BATADV_ATTR_MAX - 1)
-
-enum {
+/**
+ * enum batadv_nl_commands - supported batman-adv netlink commands
+ *
+ * @BATADV_CMD_UNSPEC: unspecified command to catch errors
+ * @BATADV_CMD_GET_MESH_INFO: Query basic information about batman-adv device
+ * @BATADV_CMD_GET_ROUTING_ALGOS: TODO
+ * @BATADV_CMD_GET_HARDIFS: TODO
+ * @BATADV_CMD_GET_TRANSTABLE_LOCAL: TODO
+ * @BATADV_CMD_GET_TRANSTABLE_GLOBAL: TODO
+ * @BATADV_CMD_GET_ORIGINATORS: TODO
+ * @BATADV_CMD_GET_NEIGHBORS: TODO
+ * @BATADV_CMD_GET_GATEWAYS: TODO
+ * @BATADV_CMD_GET_BLA_CLAIM: TODO
+ * @__BATADV_CMD_AFTER_LAST: internal use
+ * @BATADV_CMD_MAX: highest used command number
+ */
+enum batadv_nl_commands {
 	BATADV_CMD_UNSPEC,
-	BATADV_CMD_GET_ROUTING_ALGOS,
 	BATADV_CMD_GET_MESH_INFO,
+	BATADV_CMD_GET_ROUTING_ALGOS,
 	BATADV_CMD_GET_HARDIFS,
 	BATADV_CMD_GET_TRANSTABLE_LOCAL,
 	BATADV_CMD_GET_TRANSTABLE_GLOBAL,
@@ -103,9 +157,9 @@  enum {
 	BATADV_CMD_GET_NEIGHBORS,
 	BATADV_CMD_GET_GATEWAYS,
 	BATADV_CMD_GET_BLA_CLAIM,
-	__BATADV_CMD_MAX,
+	/* add new commands above here */
+	__BATADV_CMD_AFTER_LAST,
+	BATADV_CMD_MAX = __BATADV_CMD_AFTER_LAST - 1
 };
 
-#define BATADV_CMD_MAX (__BATADV_CMD_MAX - 1)
-
 #endif /* _UAPI_LINUX_BATMAN_ADV_H_ */
diff --git a/netlink.c b/netlink.c
index e09166c..de2fd8a 100644
--- a/netlink.c
+++ b/netlink.c
@@ -1,3 +1,27 @@ 
+/*
+ * Copyright (C) 2009-2016  B.A.T.M.A.N. contributors:
+ *
+ * Andrew Lunn <andrew@lunn.ch>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA
+ *
+ */
+
+#include "netlink.h"
+#include "main.h"
+
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
@@ -23,7 +47,7 @@  struct print_opts {
 	float watch_interval;
 };
 
-static struct nla_policy policy[BATADV_ATTR_MAX+1] = {
+static struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = {
 	[BATADV_ATTR_VERSION]		= { .type = NLA_STRING },
 	[BATADV_ATTR_ALGO_NAME]		= { .type = NLA_STRING },
 	[BATADV_ATTR_MESH_IFINDEX]	= { .type = NLA_U32 },
@@ -145,7 +169,7 @@  static int info_callback(struct nl_msg *msg, void *arg)
 		return NL_OK;
 
 	if (nla_parse(attrs, BATADV_ATTR_MAX, genlmsg_attrdata(ghdr, 0),
-		      genlmsg_len(ghdr), policy)) {
+		      genlmsg_len(ghdr), batadv_netlink_policy)) {
 		fputs("Received invalid data from kernel.\n", stderr);
 		exit(1);
 	}
@@ -247,7 +271,7 @@  static int routing_algos_callback(struct nl_msg *msg, void *arg __unused)
 		return NL_OK;
 
 	if (nla_parse(attrs, BATADV_ATTR_MAX, genlmsg_attrdata(ghdr, 0),
-		      genlmsg_len(ghdr), policy)) {
+		      genlmsg_len(ghdr), batadv_netlink_policy)) {
 		fputs("Received invalid data from kernel.\n", stderr);
 		exit(1);
 	}
@@ -336,7 +360,7 @@  static int originators_callback(struct nl_msg *msg, void *arg)
 		return NL_OK;
 
 	if (nla_parse(attrs, BATADV_ATTR_MAX, genlmsg_attrdata(ghdr, 0),
-		      genlmsg_len(ghdr), policy)) {
+		      genlmsg_len(ghdr), batadv_netlink_policy)) {
 		fputs("Received invalid data from kernel.\n", stderr);
 		exit(1);
 	}
@@ -470,7 +494,7 @@  static int neighbors_callback(struct nl_msg *msg, void *arg)
 		return NL_OK;
 
 	if (nla_parse(attrs, BATADV_ATTR_MAX, genlmsg_attrdata(ghdr, 0),
-		      genlmsg_len(ghdr), policy)) {
+		      genlmsg_len(ghdr), batadv_netlink_policy)) {
 		fputs("Received invalid data from kernel.\n", stderr);
 		exit(1);
 	}
@@ -561,7 +585,7 @@  static int transglobal_callback(struct nl_msg *msg, void *arg)
 		return NL_OK;
 
 	if (nla_parse(attrs, BATADV_ATTR_MAX, genlmsg_attrdata(ghdr, 0),
-		      genlmsg_len(ghdr), policy)) {
+		      genlmsg_len(ghdr), batadv_netlink_policy)) {
 		fputs("Received invalid data from kernel.\n", stderr);
 		exit(1);
 	}
@@ -657,7 +681,7 @@  static int translocal_callback(struct nl_msg *msg, void *arg)
 		return NL_OK;
 
 	if (nla_parse(attrs, BATADV_ATTR_MAX, genlmsg_attrdata(ghdr, 0),
-		      genlmsg_len(ghdr), policy)) {
+		      genlmsg_len(ghdr), batadv_netlink_policy)) {
 		fputs("Received invalid data from kernel.\n", stderr);
 		exit(1);
 	}
@@ -757,7 +781,7 @@  static int gateways_callback(struct nl_msg *msg, void *arg)
 		return NL_OK;
 
 	if (nla_parse(attrs, BATADV_ATTR_MAX, genlmsg_attrdata(ghdr, 0),
-		      genlmsg_len(ghdr), policy)) {
+		      genlmsg_len(ghdr), batadv_netlink_policy)) {
 		fputs("Received invalid data from kernel.\n", stderr);
 		exit(1);
 	}
@@ -836,7 +860,7 @@  static int bla_claim_callback(struct nl_msg *msg, void *arg)
 		return NL_OK;
 
 	if (nla_parse(attrs, BATADV_ATTR_MAX, genlmsg_attrdata(ghdr, 0),
-		      genlmsg_len(ghdr), policy)) {
+		      genlmsg_len(ghdr), batadv_netlink_policy)) {
 		fputs("Received invalid data from kernel.\n", stderr);
 		exit(1);
 	}