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
Changes from v3:
- move "batman-adv: split routing API data structure in subobjects" as patch 1
- check if algo_ops->gw.get_best_gw_node was implemented before calling it
- add patch to disable GW mode knobs if API have not been implemented (6/6)
Cheers,
Antonio Quartulli (6):
batman-adv: split routing API data structure in subobjects
batman-adv: make the GW selection class algorithm specific
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
batman-adv: disable sysfs knobs when GW-mode is not implemented
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 | 223 ++++-------------------------
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 | 64 ++++++++-
net/batman-adv/translation-table.c | 6 +-
net/batman-adv/types.h | 137 +++++++++++-------
15 files changed, 744 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.
Changes from v3:
- add missing "#include <linux/atomic.h>"
net/batman-adv/bat_v.c | 15 +++++++++++++++
net/batman-adv/bat_v.h | 5 +++++
net/batman-adv/hard-interface.c | 10 ++--------
3 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
index e4a91cd..7231440 100644
--- a/net/batman-adv/bat_v.c
+++ b/net/batman-adv/bat_v.c
@@ -18,6 +18,7 @@
#include "bat_v.h"
#include "main.h"
+#include <linux/atomic.h>
#include <linux/bug.h>
#include <linux/cache.h>
#include <linux/init.h>
@@ -334,6 +335,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: Simon Wunderlich <sw(a)simonwunderlich.de>
The BATADV_CMD_TP_METER_CANCEL netlink cmd can for example fail when no
valid soft_iface can be found. This error should not only detected but
also be reported back to the caller.
Fixes: 98d7a766b645 ("batman-adv: throughput meter implementation")
Signed-off-by: Simon Wunderlich <sw(a)simonwunderlich.de>
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
net/batman-adv/netlink.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c
index 56e63ce..c25bbb8 100644
--- a/net/batman-adv/netlink.c
+++ b/net/batman-adv/netlink.c
@@ -350,7 +350,7 @@ batadv_netlink_tp_meter_cancel(struct sk_buff *skb, struct genl_info *info)
struct batadv_priv *bat_priv;
int ifindex;
u8 *dst;
- int ret;
+ int ret = 0;
if (!info->attrs[BATADV_ATTR_MESH_IFINDEX])
return -EINVAL;
@@ -377,7 +377,7 @@ out:
if (soft_iface)
dev_put(soft_iface);
- return 0;
+ return ret;
}
static struct genl_ops batadv_netlink_ops[] = {
--
2.8.1
The kernels for Debian stretch require some special CFLAGS settings which
are only correctly defined when NOSTDINC_FLAGS is defined inside 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 include 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>
---
v3:
- append NOSTDINC_FLAGS with our own flags instead of overwriting it
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..2568fb2 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
The skb_linearize may reallocate the skb. This makes the calculated pointer
for ethhdr invalid. But it the pointer is used later to fill in the RR
field of the batadv_icmp_packet_rr packet.
Instead re-evaluate eth_hdr after the skb_linearize+skb_cow to fix the
pointer and avoid the invalid read.
Fixes: bb69cb678d37 ("batman-adv: generalize batman-adv icmp packet handling")
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
net/batman-adv/routing.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 0c0c30e..27e07dd 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -374,6 +374,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb,
if (skb_cow(skb, ETH_HLEN) < 0)
goto out;
+ ethhdr = eth_hdr(skb);
icmph = (struct batadv_icmp_header *)skb->data;
icmp_packet_rr = (struct batadv_icmp_packet_rr *)icmph;
if (icmp_packet_rr->rr_cur >= BATADV_RR_LEN)
--
2.8.1