[B.A.T.M.A.N.] [PATCH next] batman-adv: remove redundant #include <linux/kconfig.h>
by Sven Eckelmann
From: Masahiro Yamada <yamada.masahiro(a)socionext.com>
Kernel source files need not include <linux/kconfig.h> explicitly
because the top Makefile forces to include it with:
-include $(srctree)/include/linux/kconfig.h
Link: http://lkml.kernel.org/r/1473656164-11929-1-git-send-email-yamada.masahir...
Signed-off-by: Masahiro Yamada <yamada.masahiro(a)socionext.com>
Signed-off-by: Andrew Morton <akpm(a)linux-foundation.org>
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
net/batman-adv/debugfs.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/net/batman-adv/debugfs.h b/net/batman-adv/debugfs.h
index c68ff3d..e49121e 100644
--- a/net/batman-adv/debugfs.h
+++ b/net/batman-adv/debugfs.h
@@ -20,8 +20,6 @@
#include "main.h"
-#include <linux/kconfig.h>
-
struct net_device;
#define BATADV_DEBUGFS_SUBDIR "batman_adv"
--
2.9.3
5 years, 8 months
[B.A.T.M.A.N.] [PATCH v2] batman-adv: fix batadv_forw_packet kerneldoc for list attribute
by Linus Lüssing
The forw_packet list node is wrongly attributed to the icmp socket code.
Reviewed-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Linus Lüssing <linus.luessing(a)c0d3.blue>
---
Changes in v2:
* "Reviewed-by:" added
* detached from patchset
net/batman-adv/types.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index b3dd1a3..97336ec 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -1363,7 +1363,7 @@ struct batadv_skb_cb {
/**
* struct batadv_forw_packet - structure for bcast packets to be sent/forwarded
- * @list: list node for batadv_socket_client::queue_list
+ * @list: list node for batadv_priv::forw_{bat,bcast}_list
* @send_time: execution time for delayed_work (packet sending)
* @own: bool for locally generated packets (local OGMs are re-scheduled after
* sending)
--
2.1.4
5 years, 8 months
[B.A.T.M.A.N.] [PATCH] batman-adv: Remove unused function batadv_hash_delete
by Sven Eckelmann
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
net/batman-adv/hash.h | 30 ------------------------------
1 file changed, 30 deletions(-)
diff --git a/net/batman-adv/hash.h b/net/batman-adv/hash.h
index cbbf870..557a704 100644
--- a/net/batman-adv/hash.h
+++ b/net/batman-adv/hash.h
@@ -61,36 +61,6 @@ void batadv_hash_set_lock_class(struct batadv_hashtable *hash,
/* free only the hashtable and the hash itself. */
void batadv_hash_destroy(struct batadv_hashtable *hash);
-/* remove the hash structure. if hashdata_free_cb != NULL, this function will be
- * called to remove the elements inside of the hash. if you don't remove the
- * elements, memory might be leaked.
- */
-static inline void batadv_hash_delete(struct batadv_hashtable *hash,
- batadv_hashdata_free_cb free_cb,
- void *arg)
-{
- struct hlist_head *head;
- struct hlist_node *node, *node_tmp;
- spinlock_t *list_lock; /* spinlock to protect write access */
- u32 i;
-
- for (i = 0; i < hash->size; i++) {
- head = &hash->table[i];
- list_lock = &hash->list_locks[i];
-
- spin_lock_bh(list_lock);
- hlist_for_each_safe(node, node_tmp, head) {
- hlist_del_rcu(node);
-
- if (free_cb)
- free_cb(node, arg);
- }
- spin_unlock_bh(list_lock);
- }
-
- batadv_hash_destroy(hash);
-}
-
/**
* batadv_hash_add - adds data to the hashtable
* @hash: storage hash table
5 years, 8 months
[B.A.T.M.A.N.] [PATCH 1/5] batman-adv: Add BATADV_DBG_TP_METER to BATADV_DBG_ALL
by Sven Eckelmann
The BATADV_DBG_ALL has to contain the bit of BATADV_DBG_TP_METER to really
support all available debug messages.
Fixes: 98d7a766b645 ("batman-adv: throughput meter implementation")
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
net/batman-adv/log.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/batman-adv/log.h b/net/batman-adv/log.h
index e0e1a88..d2905a8 100644
--- a/net/batman-adv/log.h
+++ b/net/batman-adv/log.h
@@ -63,7 +63,7 @@ enum batadv_dbg_level {
BATADV_DBG_NC = BIT(5),
BATADV_DBG_MCAST = BIT(6),
BATADV_DBG_TP_METER = BIT(7),
- BATADV_DBG_ALL = 127,
+ BATADV_DBG_ALL = 255,
};
#ifdef CONFIG_BATMAN_ADV_DEBUG
--
2.8.1
5 years, 8 months
[B.A.T.M.A.N.] [PATCH] alfred: vis: Fix netlink function fallback
by Sven Eckelmann
The netlink functions return -EOPNOTSUPP when the kernel doesn't support
the netlink command. The caller can then fall back to debugfs. So check for
-EOPNOTSUPP and not EOPNOTSUPP.
Fixes: bca55a86fecd ("alfred: vis: Add support for netlink")
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
vis/vis.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/vis/vis.c b/vis/vis.c
index b865508..677f8aa 100644
--- a/vis/vis.c
+++ b/vis/vis.c
@@ -361,7 +361,7 @@ static int parse_transtable_local(struct globals *globals)
int ret;
ret = parse_transtable_local_netlink(globals);
- if (ret != EOPNOTSUPP)
+ if (ret != -EOPNOTSUPP)
return ret;
return parse_transtable_local_debugfs(globals);
@@ -602,7 +602,7 @@ static int parse_orig_list(struct globals *globals)
int ret;
ret = parse_orig_list_netlink(globals);
- if (ret != EOPNOTSUPP)
+ if (ret != -EOPNOTSUPP)
return ret;
return parse_orig_list_debugfs(globals);
--
2.9.3
5 years, 8 months
[B.A.T.M.A.N.] [PATCH] alfred: vis: Fix direct neighbors detection with netlink query
by Sven Eckelmann
Only entries in the originator table with the destination address equal to
the originator address should be handled by alfred as actual neighbors.
Fixes: bca55a86fecd ("alfred: vis: Add support for netlink")
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
vis/vis.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/vis/vis.c b/vis/vis.c
index 94e583e..f4d13c7 100644
--- a/vis/vis.c
+++ b/vis/vis.c
@@ -453,6 +453,7 @@ err:
static const int parse_orig_list_mandatory[] = {
BATADV_ATTR_ORIG_ADDRESS,
+ BATADV_ATTR_NEIGH_ADDRESS,
BATADV_ATTR_TQ,
BATADV_ATTR_HARD_IFINDEX,
};
@@ -466,6 +467,7 @@ static int parse_orig_list_netlink_cb(struct nl_msg *msg, void *arg)
struct genlmsghdr *ghdr;
struct vis_list_entry *v_entry;
uint8_t *orig;
+ uint8_t *neigh;
uint8_t tq;
uint32_t hardif;
@@ -493,12 +495,16 @@ static int parse_orig_list_netlink_cb(struct nl_msg *msg, void *arg)
return NL_OK;
orig = nla_data(attrs[BATADV_ATTR_ORIG_ADDRESS]);
+ neigh = nla_data(attrs[BATADV_ATTR_NEIGH_ADDRESS]);
tq = nla_get_u8(attrs[BATADV_ATTR_TQ]);
hardif = nla_get_u32(attrs[BATADV_ATTR_HARD_IFINDEX]);
if (tq < 1)
return NL_OK;
+ if (memcmp(orig, neigh, ETH_ALEN) != 0)
+ return NL_OK;
+
v_entry = malloc(sizeof(*v_entry));
if (!v_entry)
return NL_OK;
--
2.9.3
5 years, 8 months
[B.A.T.M.A.N.] [PATCH] alfred: Enable _GNU_SOURCE by default
by Sven Eckelmann
alfred uses any netlink library which is (more or less) compatible with
libnl-3. This is for example libnl-tiny on OpenWrt.
Programs and libraries which are build against libnl-tiny must be build
with _GNU_SOURCE enabled to have some types in its headers defined. Thus
_GNU_SOURCE is enabled in the OpenWrt alfred package since 2016.3. But
sometimes using _GNU_SOURCE and sometimes not using it can have severe side
effects which are non-trivial to debug when the developer is not also using
the same _GNU_SOURCE preprocessor define. Thus enable _GNU_SOURCE by
default to have similar behavior (defines, type definitions, structure
members, ...) from headers like on OpenWrt.
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
Makefile | 1 +
gpsd/Makefile | 1 +
vis/Makefile | 1 +
3 files changed, 3 insertions(+)
diff --git a/Makefile b/Makefile
index 6daa904..552e690 100755
--- a/Makefile
+++ b/Makefile
@@ -36,6 +36,7 @@ MANPAGE = man/alfred.8
# alfred flags and options
CFLAGS += -pedantic -Wall -W -std=gnu99 -fno-strict-aliasing -MD -MP
+CPPFLAGS += -D_GNU_SOURCE
LDLIBS += -lrt
# Turn on alfred capability dropping by default - set this to n if you don't want/need it
diff --git a/gpsd/Makefile b/gpsd/Makefile
index bae5660..b6172d9 100755
--- a/gpsd/Makefile
+++ b/gpsd/Makefile
@@ -25,6 +25,7 @@ MANPAGE = man/alfred-gpsd.8
# alfred flags and options
CFLAGS += -pedantic -Wall -W -std=gnu99 -fno-strict-aliasing -MD -MP
+CPPFLAGS += -D_GNU_SOURCE
# disable verbose output
ifneq ($(findstring $(MAKEFLAGS),s),s)
diff --git a/vis/Makefile b/vis/Makefile
index fd99f49..22483a5 100755
--- a/vis/Makefile
+++ b/vis/Makefile
@@ -27,6 +27,7 @@ MANPAGE = man/batadv-vis.8
# batadv-vis flags and options
CFLAGS += -pedantic -Wall -W -std=gnu99 -fno-strict-aliasing -MD -MP
+CPPFLAGS += -D_GNU_SOURCE
LDLIBS += -lrt
# disable verbose output
--
2.9.3
5 years, 8 months
[B.A.T.M.A.N.] [PATCH next v2 1/3] batman-adv: Introduce compat-patches support
by Sven Eckelmann
compat-includes/compat.h can usually be used to solve compatibility
problems with older kernels. This works well for functions, defines/enums
and sometimes even structures that were introduced.
But this can fail when structs changed. Some of these can be solved in
crude ways but sometimes it is unavoidable to have a version specific code.
Unfortunately, this kind of code is not acceptable in the kernel and thus
the compat infrastructure of the external module has to do add it
automatically before the source is compiled.
This process works by creating a build directory which is prefilled with
the source from net/batman-adv/. The patches from compat-patches/ will be
applied on top of this copy and then the code is compiled.
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
v2:
- Rebased on top of current next
.gitignore | 10 ++++------
Makefile | 31 +++++++++++++++++++++++++++----
compat-patches/README | 23 +++++++++++++++++++++++
compat-sources/Makefile | 6 +++---
4 files changed, 57 insertions(+), 13 deletions(-)
create mode 100644 compat-patches/README
diff --git a/.gitignore b/.gitignore
index 4c03561..15a99aa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,10 +1,8 @@
+/build/
/compat-autoconf.h
/compat-autoconf.h.tmp
/compat-sources/**/.*
/compat-sources/**/*.o
-/net/batman-adv/.*
-/net/batman-adv/batman-adv.ko
-/net/batman-adv/batman-adv.mod.c
-/net/batman-adv/modules.order
-/net/batman-adv/Module.symvers
-/net/batman-adv/*.o
+/modules.order
+/Module.symvers
+/.tmp_versions
diff --git a/Makefile b/Makefile
index d42bb56..b105290 100644
--- a/Makefile
+++ b/Makefile
@@ -33,6 +33,7 @@ export CONFIG_BATMAN_ADV_MCAST=y
export CONFIG_BATMAN_ADV_BATMAN_V=n
PWD:=$(shell pwd)
+BUILD_DIR=$(PWD)/build
KERNELPATH ?= /lib/modules/$(shell uname -r)/build
# sanity check: does KERNELPATH exist?
ifeq ($(shell cd $(KERNELPATH) && pwd),)
@@ -41,6 +42,14 @@ endif
export KERNELPATH
RM ?= rm -f
+MKDIR := mkdir -p
+PATCH_FLAGS = --batch --fuzz=0 --forward --strip=1 --unified --version-control=never -g0 --remove-empty-files --no-backup-if-mismatch --reject-file=-
+PATCH := patch $(PATCH_FLAGS) -i
+CP := cp -fpR
+
+SOURCE = $(wildcard net/batman-adv/*.[ch]) net/batman-adv/Makefile
+SOURCE_BUILD = $(wildcard $(BUILD_DIR)/net/batman-adv/*.[ch]) $(BUILD_DIR)/net/batman-adv/Makefile
+SOURCE_STAMP = $(BUILD_DIR)/net/batman-adv/.compat-prepared
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]"); \
@@ -57,7 +66,7 @@ endif
include $(PWD)/compat-sources/Makefile
-obj-y += net/batman-adv/
+obj-y += build/net/batman-adv/
export batman-adv-y
@@ -76,18 +85,32 @@ BUILD_FLAGS := \
CONFIG_BATMAN_ADV_BATMAN_V=$(CONFIG_BATMAN_ADV_BATMAN_V) \
INSTALL_MOD_DIR=updates/
-all: config
+all: config $(SOURCE_STAMP)
$(MAKE) -C $(KERNELPATH) $(BUILD_FLAGS) modules
clean:
$(RM) compat-autoconf.h*
- $(MAKE) -C $(KERNELPATH) $(BUILD_FLAGS) clean
+ $(RM) -r $(BUILD_DIR)
-install: config
+install: config $(SOURCE_STAMP)
$(MAKE) -C $(KERNELPATH) $(BUILD_FLAGS) modules_install
depmod -a
config:
$(PWD)/gen-compat-autoconf.sh $(PWD)/compat-autoconf.h
+$(SOURCE_STAMP): $(SOURCE) compat-patches/*
+ $(MKDIR) $(BUILD_DIR)/net/batman-adv/
+ @$(RM) $(SOURCE_BUILD)
+ @$(CP) $(SOURCE) $(BUILD_DIR)/net/batman-adv/
+ @set -e; \
+ patches="$$(ls -1 compat-patches/|grep '.patch$$'|sort)"; \
+ for i in $${patches}; do \
+ echo ' COMPAT_PATCH '$${i};\
+ cd $(BUILD_DIR); \
+ $(PATCH) ../compat-patches/$${i}; \
+ cd - > /dev/null; \
+ done
+ touch $(SOURCE_STAMP)
+
.PHONY: all clean install config
diff --git a/compat-patches/README b/compat-patches/README
new file mode 100644
index 0000000..3bbddb3
--- /dev/null
+++ b/compat-patches/README
@@ -0,0 +1,23 @@
+WARNING
+=======
+
+Please avoid using the compat-patches/ to implement support for old kernels.
+This should be the last resort.
+
+ * it is nearly always possible to use compat-includes/ to do the same with a
+ lot less problems
+
+ * maintaining these patches is *censored*
+
+GENERATING A PATCH
+==================
+
+If it not possible to avoid a patch then please make the patch as small as
+possible. Even refactor the code which has to be patched to reduce the
+size/number of the changes.
+
+Please use git-format-patches to generate them and order same inside via the
+XXXX- prefix of the patch name.
+
+ git format-patch --abbrev=7 -U3 --diff-algorithm=histogram --no-signature \
+ --format=format:'From: %an <%ae>%nDate: %aD%nSubject: [PATCH] %B' -1
diff --git a/compat-sources/Makefile b/compat-sources/Makefile
index a45c202..c8bae49 100644
--- a/compat-sources/Makefile
+++ b/compat-sources/Makefile
@@ -1,3 +1,3 @@
-batman-adv-$(CONFIG_BATMAN_ADV_MCAST) += ../../compat-sources/net/core/skbuff.o
-batman-adv-$(CONFIG_BATMAN_ADV_MCAST) += ../../compat-sources/net/ipv4/igmp.o
-batman-adv-$(CONFIG_BATMAN_ADV_MCAST) += ../../compat-sources/net/ipv6/mcast_snoop.o
+batman-adv-$(CONFIG_BATMAN_ADV_MCAST) += ../../../compat-sources/net/core/skbuff.o
+batman-adv-$(CONFIG_BATMAN_ADV_MCAST) += ../../../compat-sources/net/ipv4/igmp.o
+batman-adv-$(CONFIG_BATMAN_ADV_MCAST) += ../../../compat-sources/net/ipv6/mcast_snoop.o
--
2.9.3
5 years, 8 months
[B.A.T.M.A.N.] [PATCH 1/3] batman-adv: refactor wifi interface detection
by Marek Lindner
The ELP protocol requires cfg80211 to auto-detect the WiFi througput
to a given neighbor. Use batadv_is_cfg80211_netdev() to determine
whether or not an interface is eligible.
Signed-off-by: Marek Lindner <mareklindner(a)neomailbox.ch>
---
net/batman-adv/bat_v_elp.c | 29 ++++++++++++++---------------
net/batman-adv/hard-interface.c | 26 +++++++++++++++++++++-----
net/batman-adv/hard-interface.h | 1 +
3 files changed, 36 insertions(+), 20 deletions(-)
diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c
index 7d17001..51fc08d 100644
--- a/net/batman-adv/bat_v_elp.c
+++ b/net/batman-adv/bat_v_elp.c
@@ -90,22 +90,21 @@ static u32 batadv_v_elp_get_throughput(struct batadv_hardif_neigh_node *neigh)
* cfg80211 API
*/
if (batadv_is_wifi_netdev(hard_iface->net_dev)) {
- if (hard_iface->net_dev->ieee80211_ptr) {
- ret = cfg80211_get_station(hard_iface->net_dev,
- neigh->addr, &sinfo);
- if (ret == -ENOENT) {
- /* Node is not associated anymore! It would be
- * possible to delete this neighbor. For now set
- * the throughput metric to 0.
- */
- return 0;
- }
- if (!ret)
- return sinfo.expected_throughput / 100;
+ if (!batadv_is_cfg80211_netdev(hard_iface->net_dev))
+ /* unsupported WiFi driver version */
+ goto default_throughput;
+
+ ret = cfg80211_get_station(hard_iface->net_dev,
+ neigh->addr, &sinfo);
+ if (ret == -ENOENT) {
+ /* Node is not associated anymore! It would be
+ * possible to delete this neighbor. For now set
+ * the throughput metric to 0.
+ */
+ return 0;
}
-
- /* unsupported WiFi driver version */
- goto default_throughput;
+ if (!ret)
+ return sinfo.expected_throughput / 100;
}
/* if not a wifi interface, check if this device provides data via
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 714af8e..478977b 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -166,6 +166,26 @@ static bool batadv_is_valid_iface(const struct net_device *net_dev)
}
/**
+ * batadv_is_cfg80211_netdev - check if the given net_device struct is a
+ * cfg80211 wifi interface
+ * @net_device: the device to check
+ *
+ * Return: true if the net device is a cfg80211 wireless device, false
+ * otherwise.
+ */
+bool batadv_is_cfg80211_netdev(struct net_device *net_device)
+{
+ if (!net_device)
+ return false;
+
+ /* cfg80211 drivers have to set ieee80211_ptr */
+ if (net_device->ieee80211_ptr)
+ return true;
+
+ return false;
+}
+
+/**
* batadv_is_wifi_netdev - check if the given net_device struct is a wifi
* interface
* @net_device: the device to check
@@ -185,11 +205,7 @@ bool batadv_is_wifi_netdev(struct net_device *net_device)
return true;
#endif
- /* cfg80211 drivers have to set ieee80211_ptr */
- if (net_device->ieee80211_ptr)
- return true;
-
- return false;
+ return batadv_is_cfg80211_netdev(net_device);
}
static struct batadv_hard_iface *
diff --git a/net/batman-adv/hard-interface.h b/net/batman-adv/hard-interface.h
index a76724d..e0893de 100644
--- a/net/batman-adv/hard-interface.h
+++ b/net/batman-adv/hard-interface.h
@@ -51,6 +51,7 @@ enum batadv_hard_if_cleanup {
extern struct notifier_block batadv_hard_if_notifier;
+bool batadv_is_cfg80211_netdev(struct net_device *net_device);
bool batadv_is_wifi_netdev(struct net_device *net_device);
bool batadv_is_wifi_iface(int ifindex);
struct batadv_hard_iface*
--
2.8.0.rc3
5 years, 8 months