This patchset adds netns/netlink support to batctl. It complements the batman-adv
netns/netlink support v8 as sent on May 23rd (today). Note that there are no
previous batctl versions, I'm just using the same version number as the batman-adv
patches.
Andrews patch has been changed by Sven and me:
* rebase on current master
* fix printing of VID
* add missing newline for claim table entries
* fix claim table entry format
* adjust names of mandatory attributes struct to avoid conflicts with
backbone table
* add local TTVN to global translation table header
* add local group id to claim table
I've also added a patch to add support for BLA backbone tables.
Cheers,
Simon
Andrew Lunn (1):
batctl: Use netlink to replace some of debugfs
Simon Wunderlich (1):
batctl: add netlink dump function for backbone tables
batman_adv.h | 94 +++++
debug.c | 23 +-
debug.h | 4 +-
functions.c | 11 +
functions.h | 2 +
netlink.c | 1140 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
netlink.h | 20 +-
packet.h | 36 --
8 files changed, 1289 insertions(+), 41 deletions(-)
--
2.8.1
This cover letter only tries to recap the changes applied from the previous
version. Please check the patch for major details.
Changes from v1:
- rebased on top of latest master (some patches from the previous patchset were
merged already)
- accidental change to the GW table header moved to right patch
- remove bat_ prefix from API names
- API subobjects redefined as proper struct instead of anonymous ones to fix
kernel-doc complaints
- bonus kernel-doc added
- missing include files added
Changes from v2:
- minimum default value of gw_sel_class restored to 1
Cheers,
Antonio Quartulli (5):
batman-adv: make the GW selection class algorithm specific
batman-adv: split routing API data structure in subobjects
batman-adv: statically print gateway table header
batman-adv: make GW election code protocol specific
batman-adv: B.A.T.M.A.N. V - implement GW selection logic
net/batman-adv/bat_algo.c | 14 +-
net/batman-adv/bat_iv_ogm.c | 252 +++++++++++++++++++++++++++++++--
net/batman-adv/bat_v.c | 280 +++++++++++++++++++++++++++++++++++--
net/batman-adv/bat_v_elp.c | 2 +-
net/batman-adv/bat_v_ogm.c | 2 +-
net/batman-adv/gateway_client.c | 220 ++++-------------------------
net/batman-adv/gateway_client.h | 7 +
net/batman-adv/gateway_common.c | 5 +-
net/batman-adv/hard-interface.c | 16 +--
net/batman-adv/netlink.c | 2 +-
net/batman-adv/originator.c | 49 +++----
net/batman-adv/routing.c | 8 +-
net/batman-adv/sysfs.c | 37 ++++-
net/batman-adv/translation-table.c | 6 +-
net/batman-adv/types.h | 137 +++++++++++-------
15 files changed, 714 insertions(+), 323 deletions(-)
--
2.8.3
This cover letter only tries to recap the changes applied from the previous
version. Please check the patch for major details.
Changes from v1:
- rebased on top of latest master (some patches from the previous patchset were
merged already)
- accidental change to the GW table header moved to right patch
- remove bat_ prefix from API names
- API subobjects redefined as proper struct instead of anonymous ones to fix
kernel-doc complaints
- bonus kernel-doc added
- missing include files added
Cheers,
Antonio Quartulli (5):
batman-adv: make the GW selection class algorithm specific
batman-adv: split routing API data structure in subobjects
batman-adv: statically print gateway table header
batman-adv: make GW election code protocol specific
batman-adv: B.A.T.M.A.N. V - implement GW selection logic
net/batman-adv/bat_algo.c | 14 +-
net/batman-adv/bat_iv_ogm.c | 252 +++++++++++++++++++++++++++++++--
net/batman-adv/bat_v.c | 280 +++++++++++++++++++++++++++++++++++--
net/batman-adv/bat_v_elp.c | 2 +-
net/batman-adv/bat_v_ogm.c | 2 +-
net/batman-adv/gateway_client.c | 220 ++++-------------------------
net/batman-adv/gateway_client.h | 7 +
net/batman-adv/gateway_common.c | 5 +-
net/batman-adv/hard-interface.c | 16 +--
net/batman-adv/netlink.c | 2 +-
net/batman-adv/originator.c | 49 +++----
net/batman-adv/routing.c | 8 +-
net/batman-adv/sysfs.c | 37 ++++-
net/batman-adv/translation-table.c | 6 +-
net/batman-adv/types.h | 137 +++++++++++-------
15 files changed, 714 insertions(+), 323 deletions(-)
--
2.8.3
Some fields in the hard-interface data structure are specific to the
B.A.T.M.A.N. V protocol and have to be initialized only when such
protocol is compiled in.
Instead of having a #ifdef block in the middle of the hard-interface.c
code it is better to have an algorithm private function that hides the
precompiler logic in its own header file (like other functions).
Fixes: ffd2f27908e5 ("batman-adv: Only init ELP tweaking options when BATMAN_V is enabled")
Signed-off-by: Antonio Quartulli <a(a)unstable.cc>
---
Changes from v1:
- move bat_algo.h include line to the right location
Changes from v2:
- rebased on top of newest master to fix compile error.
net/batman-adv/bat_v.c | 14 ++++++++++++++
net/batman-adv/bat_v.h | 5 +++++
net/batman-adv/hard-interface.c | 10 ++--------
3 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
index e4a91cd..81157a3 100644
--- a/net/batman-adv/bat_v.c
+++ b/net/batman-adv/bat_v.c
@@ -334,6 +334,20 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = {
};
/**
+ * batadv_v_hardif_init - initialize the algorithm specific fields in the
+ * hard-interface object
+ * @hard_iface: the hard-interface to initialize
+ */
+void batadv_v_hardif_init(struct batadv_hard_iface *hard_iface)
+{
+ /* enable link throughput auto-detection by setting the throughput
+ * override to zero
+ */
+ atomic_set(&hard_iface->bat_v.throughput_override, 0);
+ atomic_set(&hard_iface->bat_v.elp_interval, 500);
+}
+
+/**
* batadv_v_mesh_init - initialize the B.A.T.M.A.N. V private resources for a
* mesh
* @bat_priv: the object representing the mesh interface to initialise
diff --git a/net/batman-adv/bat_v.h b/net/batman-adv/bat_v.h
index 52dd6cf..83b7763 100644
--- a/net/batman-adv/bat_v.h
+++ b/net/batman-adv/bat_v.h
@@ -23,6 +23,7 @@
#ifdef CONFIG_BATMAN_ADV_BATMAN_V
int batadv_v_init(void);
+void batadv_v_hardif_init(struct batadv_hard_iface *hardif);
int batadv_v_mesh_init(struct batadv_priv *bat_priv);
void batadv_v_mesh_free(struct batadv_priv *bat_priv);
@@ -33,6 +34,10 @@ static inline int batadv_v_init(void)
return 0;
}
+static inline void batadv_v_hardif_init(struct batadv_hard_iface *hardif)
+{
+}
+
static inline int batadv_v_mesh_init(struct batadv_priv *bat_priv)
{
return 0;
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 6689656..70841c1 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -37,6 +37,7 @@
#include <linux/spinlock.h>
#include <linux/workqueue.h>
+#include "bat_v.h"
#include "bridge_loop_avoidance.h"
#include "debugfs.h"
#include "distributed-arp-table.h"
@@ -684,14 +685,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
if (batadv_is_wifi_netdev(net_dev))
hard_iface->num_bcasts = BATADV_NUM_BCASTS_WIRELESS;
-#ifdef CONFIG_BATMAN_ADV_BATMAN_V
- /* enable link throughput auto-detection by setting the throughput
- * override to zero
- */
- atomic_set(&hard_iface->bat_v.throughput_override, 0);
-
- atomic_set(&hard_iface->bat_v.elp_interval, 500);
-#endif
+ batadv_v_hardif_init(hard_iface);
/* extra reference for return */
kref_init(&hard_iface->refcount);
--
2.8.3
From: Sven Eckelmann <sven(a)narfation.org>
The router is put down twice when it was non-NULL and either orig_ifinfo is
NULL afterwards or batman-adv receives a packet with the same sequence
number. This will end up in a use-after-free when the batadv_neigh_node is
removed because the reference counter ended up too early at 0.
Fixes: 9323158ef9f4 ("batman-adv: OGMv2 - implement originators logic")
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Antonio Quartulli <a(a)unstable.cc>
---
This patch is skipping netdev and is being sent directly to stable in
accordance with David S. Miller[1].
The reason is that this patch applies only on linux-4.6 and not on
linux-4.7/net because it was "accidentally" fixed by a refactoring
commit (more details in [2]).
It addresses a reference imbalance which systematically leads to a
use-after-free and then a kernel crash.
Cheers,
[1] https://www.mail-archive.com/b.a.t.m.a.n@lists.open-mesh.org/msg15258.html
[2] https://www.mail-archive.com/b.a.t.m.a.n@lists.open-mesh.org/msg15252.html
net/batman-adv/bat_v_ogm.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c
index d9bcbe6e7d65..91df28a100f9 100644
--- a/net/batman-adv/bat_v_ogm.c
+++ b/net/batman-adv/bat_v_ogm.c
@@ -529,8 +529,10 @@ static void batadv_v_ogm_route_update(struct batadv_priv *bat_priv,
goto out;
}
- if (router)
+ if (router) {
batadv_neigh_node_put(router);
+ router = NULL;
+ }
/* Update routes, and check if the OGM is from the best next hop */
batadv_v_ogm_orig_update(bat_priv, orig_node, neigh_node, ogm2,
--
2.8.3
The kernels for Debian stretch require some special CFLAGS settings
which are only correctly defined when NOSTDINC_FLAGS is set during the
execution of the Makefile via kbuild. But batman-adv sets it currently
outside to insert compatibility include headers and compat-sources.
This can be avoided by making the top Makefile kbuild compatible and
redefining the NOSTDINC_FLAGS when kbuild includes this Makefile. The
actual build of the batman-adv module is then done by adding the
subdirectory to obj-y.
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
v2:
- Fixed noise from other patches in context (should now apply cleanly on next)
Makefile | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index 5d2c058..fe574de 100644
--- a/Makefile
+++ b/Makefile
@@ -43,7 +43,7 @@ RM ?= rm -f
REVISION= $(shell if [ -d "$(PWD)/.git" ]; then \
echo $$(git --git-dir="$(PWD)/.git" describe --always --dirty --match "v*" |sed 's/^v//' 2> /dev/null || echo "[unknown]"); \
fi)
-export NOSTDINC_FLAGS := \
+NOSTDINC_FLAGS := \
-I$(PWD)/compat-include/ \
-include $(PWD)/compat.h \
$(CFLAGS)
@@ -52,8 +52,12 @@ ifneq ($(REVISION),)
NOSTDINC_FLAGS += -DBATADV_SOURCE_VERSION=\"$(REVISION)\"
endif
+obj-y += net/batman-adv/
+
BUILD_FLAGS := \
- M=$(PWD)/net/batman-adv \
+ M=$(PWD) \
+ PWD=$(PWD) \
+ REVISION=$(REVISION) \
CONFIG_BATMAN_ADV=m \
CONFIG_BATMAN_ADV_DEBUG=$(CONFIG_BATMAN_ADV_DEBUG) \
CONFIG_BATMAN_ADV_BLA=$(CONFIG_BATMAN_ADV_BLA) \
@@ -61,7 +65,7 @@ BUILD_FLAGS := \
CONFIG_BATMAN_ADV_NC=$(CONFIG_BATMAN_ADV_NC) \
CONFIG_BATMAN_ADV_MCAST=$(CONFIG_BATMAN_ADV_MCAST) \
CONFIG_BATMAN_ADV_BATMAN_V=$(CONFIG_BATMAN_ADV_BATMAN_V) \
- INSTALL_MOD_DIR=updates/net/batman-adv/
+ INSTALL_MOD_DIR=updates/
all: config
$(MAKE) -C $(KERNELPATH) $(BUILD_FLAGS) modules
--
2.8.1
If a VLAN tagged frame is received and the corresponding VLAN is not
configured on the soft interface, it will splat a WARN on every packet
received. This is a quite annoying behaviour for some scenarios, e.g. if
bat0 is bridged with eth0, and there are arbitrary VLAN tagged frames
from Ethernet coming in without having any VLAN configuration on bat0.
The code should probably create vlan objects on the fly and
transparently transport these VLAN-tagged Ethernet frames, but until
this is done, at least the WARN splat should be replaced by a rate
limited output.
Signed-off-by: Simon Wunderlich <sw(a)simonwunderlich.de>
---
Changes to PATCH-maint:
* added newline to output
---
net/batman-adv/translation-table.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 9b4551a..48adb91 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -650,8 +650,10 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,
/* increase the refcounter of the related vlan */
vlan = batadv_softif_vlan_get(bat_priv, vid);
- if (WARN(!vlan, "adding TT local entry %pM to non-existent VLAN %d",
- addr, BATADV_PRINT_VID(vid))) {
+ if (!vlan) {
+ net_ratelimited_function(batadv_info, soft_iface,
+ "adding TT local entry %pM to non-existent VLAN %d\n",
+ addr, BATADV_PRINT_VID(vid));
kfree(tt_local);
tt_local = NULL;
goto out;
--
2.8.1
This patchset introduces optimizations for batman-adv in setups having several
gateways into a common (switched) Ethernet backbone network especially if dat
is additionally enabled.
Using the current implementation with bla and dat enabled, several problems
can be observed in a real setup:
1. Multiplication of ARP replies from dat enabled gateways and dat enabled
mesh nodes leading to an "ARP reply storm" in the common backbone network.
2. In rare corner cases bla does not fully prevent looping of unicast frames
in the direction Backbone --> mesh --> backbone and looping of multicast
frames in the direction mesh --> backbone --> mesh.
The latter can lead to temporary confusion in the switched backbone resulting
in packet loss and communication timeouts.
The observed problems are solved by introduction of additional rules for the
dat handling, bla packet forwarding and bla claiming/unclaiming of clients.
v4:
- removed unnecessary include in soft-interface.c
- solved issue with double-use and refcounting of pointers in routing.c
v3:
- rebased patchset
- moved snooping of ip addresses for dat speed up into separate function
- removed "patch of a patch"
- removed automatic claiming during check of a claim
- fixed issues of the patchset not being compiled due to chosen batman
options
Kind regards,
Andreas
Andreas Pape (6):
batman-adv: prevent multiple ARP replies sent by gateways if dat
enbled
batman-adv: speed up dat by snooping received ip traffic
batman-adv: prevent duplication of ARP replies when DAT is used
batman-adv: drop unicast packets from other backbone gw
batman-adv: changed debug messages for easier bla debugging
batman-adv: handle race condition for claims between gateways
net/batman-adv/bridge_loop_avoidance.c | 87 ++++++++++++++++++++++++++---
net/batman-adv/bridge_loop_avoidance.h | 11 ++++
net/batman-adv/distributed-arp-table.c | 97 ++++++++++++++++++++++++++++++++
net/batman-adv/distributed-arp-table.h | 9 +++-
net/batman-adv/routing.c | 25 +++++++-
net/batman-adv/soft-interface.c | 3 +
6 files changed, 220 insertions(+), 12 deletions(-)
..................................................................
PHOENIX CONTACT ELECTRONICS GmbH
Sitz der Gesellschaft / registered office of the company: 31812 Bad Pyrmont
USt-Id-Nr.: DE811742156
Amtsgericht Hannover HRB 100528 / district court Hannover HRB 100528
Geschäftsführer / Executive Board: Roland Bent, Dr. Martin Heubeck
___________________________________________________________________
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren, jegliche anderweitige Verwendung sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.
----------------------------------------------------------------------------------------------------
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure, distribution or other use of the material or parts thereof is strictly forbidden.
___________________________________________________________________
Hi,
Antonio had some extra suggestions about the tpmeter. All are now included in
the patchset. I have also noticed some problems with the patches
(net.git/net-next.git) scheduled for 4.7 which required some adjustments to
the netlink code.
batman-adv:
* moved batadv_tp_meter_init to batadv_init (main.c)
* fixed missing space in kerneldoc between "<" and "0"
* port to nla_put_u64_64bit
* add compat code for nla_put_u64_64bit
* introduce attribute BATADV_ATTR_PAD which is used for alignment
* rename batadv_real_genl_register_family back to genl_register_family in
compat-include
batctl:
* introduce new attribute BATADV_ATTR_PAD used for u64 alignment
Kind regards,
Sven