From 129986825219d6d276098da8fe419e206bb9a056 Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Sun, 6 Jan 2019 13:23:42 +0100 Subject: [PATCH 1/5] batctl: Provide different variants The batctl binary is currently optional for batman-adv installations. But new configuration settings will only be exposed via generic netlink. The batctl tool will therefore be required to modify them. To also fit batctl in some of the smaller devices, a new variant batctl-tiny is build which only provides the settings subcommands. The batctl-default variant is equal to the old batctl package and batctl-full also provides the commands which were disabled until now. Signed-off-by: Sven Eckelmann --- batctl/Makefile | 164 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 156 insertions(+), 8 deletions(-) diff --git a/batctl/Makefile b/batctl/Makefile index d38874e..126a4f3 100644 --- a/batctl/Makefile +++ b/batctl/Makefile @@ -10,24 +10,48 @@ include $(TOPDIR)/rules.mk PKG_NAME:=batctl PKG_VERSION:=2018.4 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_HASH:=e43827a5e868b4e134e77ca04da989fde1981463166bf1b6f2053acc3edd6257 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION) PKG_LICENSE:=GPL-2.0 +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION) + include $(INCLUDE_DIR)/package.mk -define Package/batctl +define Package/batctl/Default URL:=https://www.open-mesh.org/ SECTION:=net CATEGORY:=Network DEPENDS:=+kmod-batman-adv +libnl-tiny +libc +librt - TITLE:=B.A.T.M.A.N. Advanced user space configuration tool batctl + PROVIDES:=batctl MAINTAINER:=Simon Wunderlich endef +define Package/batctl-tiny +$(call Package/batctl/Default) + TITLE:=B.A.T.M.A.N. Advanced user space configuration tool (Minimal) + VARIANT:=tiny + PROVIDES:=batctl + ALTERNATIVES:=100:/usr/sbin/batctl:/usr/libexec/batctl-tiny +endef + +define Package/batctl-default +$(call Package/batctl/Default) + TITLE:=B.A.T.M.A.N. Advanced user space configuration tool (Default) + VARIANT:=default + ALTERNATIVES:=200:/usr/sbin/batctl:/usr/libexec/batctl-full +endef + +define Package/batctl-full +$(call Package/batctl/Default) + TITLE:=B.A.T.M.A.N. Advanced user space configuration tool (Minimal) + VARIANT:=full + ALTERNATIVES:=300:/usr/sbin/batctl:/usr/libexec/batctl-full +endef + define Package/batctl/description batctl is a more intuitive managment utility for B.A.T.M.A.N.-Advanced. It is an easier method for configuring batman-adv and provides some @@ -63,14 +87,138 @@ MAKE_BATCTL_ARGS += \ batctl install \ REVISION="openwrt-$(PKG_VERSION)-$(PKG_RELEASE)" +config-n := \ + aggregation \ + ap_isolation \ + backbonetable \ + bisect_iv \ + bonding \ + bridge_loop_avoidance \ + claimtable \ + dat_cache \ + distributed_arp_table \ + event \ + fragmentation \ + gateways \ + gw_mode \ + interface \ + isolation_mark \ + log \ + loglevel \ + mcast_flags \ + multicast_mode \ + nc_nodes \ + neighbors \ + network_coding \ + orig_interval \ + originators \ + ping \ + routing_algo \ + statistics \ + tcpdump \ + throughputmeter \ + traceroute \ + transglobal \ + translate \ + translocal \ + +config-settings := \ + aggregation \ + ap_isolation \ + bonding \ + bridge_loop_avoidance \ + distributed_arp_table \ + fragmentation \ + gw_mode \ + interface \ + isolation_mark \ + loglevel \ + multicast_mode \ + network_coding \ + orig_interval \ + routing_algo \ + +config-tables := \ + backbonetable \ + claimtable \ + dat_cache \ + gateways \ + loglevel \ + nc_nodes \ + neighbors \ + originators \ + statistics \ + transglobal \ + translocal \ + +config-tools := \ + event \ + log \ + ping \ + tcpdump \ + throughputmeter \ + traceroute \ + translate \ + +config-extratools := \ + bisect_iv \ + +ifeq ($(BUILD_VARIANT),tiny) + +config-y := \ + $(config-settings) \ + +endif + +ifeq ($(BUILD_VARIANT),default) + +config-y := \ + $(config-settings) \ + $(config-tables) \ + $(config-tools) \ + +endif + +ifeq ($(BUILD_VARIANT),full) + +config-y := \ + $(config-settings) \ + $(config-tables) \ + $(config-tools) \ + $(config-extratools) \ + +endif + +define ConfigVars +$(subst $(space),,$(foreach opt,$(config-$(1)),CONFIG_$(opt)=$(1) +)) +endef + +define batctl_config +$(call ConfigVars,n)$(call ConfigVars,y) +endef +$(eval $(call shexport,batctl_config)) define Build/Compile - $(MAKE_BATCTL_ENV) $(MAKE) -C "$(PKG_BUILD_DIR)" $(MAKE_BATCTL_ARGS) + $(MAKE_BATCTL_ENV) $(MAKE) -C "$(PKG_BUILD_DIR)" $(MAKE_BATCTL_ARGS) \ + $$$$$(call shvar,batctl_config) endef -define Package/batctl/install - $(INSTALL_DIR) $(1)/usr/sbin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/batctl $(1)/usr/sbin/ +define Package/batctl-tiny/install + $(INSTALL_DIR) $(1)/usr/libexec + $(INSTALL_BIN) $(PKG_BUILD_DIR)/batctl $(1)/usr/libexec/batctl-tiny endef -$(eval $(call BuildPackage,batctl)) +define Package/batctl-default/install + $(INSTALL_DIR) $(1)/usr/libexec + $(INSTALL_BIN) $(PKG_BUILD_DIR)/batctl $(1)/usr/libexec/batctl-default +endef + +define Package/batctl-full/install + $(INSTALL_DIR) $(1)/usr/libexec + $(INSTALL_BIN) $(PKG_BUILD_DIR)/batctl $(1)/usr/libexec/batctl-full +endef + +$(eval $(call BuildPackage,batctl-default)) +$(eval $(call BuildPackage,batctl-tiny)) +$(eval $(call BuildPackage,batctl-full)) From 498463cd59d227e39f9af86e55df0c970436c08c Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Sun, 6 Jan 2019 13:24:21 +0100 Subject: [PATCH 2/5] batman-adv: use batctl for configuration The batctl binary is currently optional for batman-adv installations. But new configuration settings will only be exposed via generic netlink. The batctl tool will therefore be required to modify them. batctl must therefore no longer depend on batman-adv but batman-adv must depend on batctl. Some already implemented settings are already moved to batctl. Signed-off-by: Sven Eckelmann --- batctl/Makefile | 4 ++-- batman-adv/Makefile | 4 ++-- batman-adv/files/lib/batman-adv/config.sh | 24 ++++++++++--------- batman-adv/files/lib/netifd/proto/batadv.sh | 9 ++++--- .../files/lib/netifd/proto/batadv_vlan.sh | 6 +---- 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/batctl/Makefile b/batctl/Makefile index 126a4f3..9eefe86 100644 --- a/batctl/Makefile +++ b/batctl/Makefile @@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=batctl PKG_VERSION:=2018.4 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_HASH:=e43827a5e868b4e134e77ca04da989fde1981463166bf1b6f2053acc3edd6257 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz @@ -25,7 +25,7 @@ define Package/batctl/Default URL:=https://www.open-mesh.org/ SECTION:=net CATEGORY:=Network - DEPENDS:=+kmod-batman-adv +libnl-tiny +libc +librt + DEPENDS:=+libnl-tiny +libc +librt PROVIDES:=batctl MAINTAINER:=Simon Wunderlich endef diff --git a/batman-adv/Makefile b/batman-adv/Makefile index dc73fee..19cba8a 100644 --- a/batman-adv/Makefile +++ b/batman-adv/Makefile @@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=batman-adv PKG_VERSION:=2018.4 -PKG_RELEASE:=0 +PKG_RELEASE:=1 PKG_HASH:=3500b4bc7d41ce1adef0b0684972a439d48b454ba78282e94df13ba90605484d PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz @@ -27,7 +27,7 @@ define KernelPackage/batman-adv URL:=https://www.open-mesh.org/ MAINTAINER:=Simon Wunderlich SUBMENU:=Network Support - DEPENDS:=+BATMAN_ADV_BLA:kmod-lib-crc16 +kmod-lib-crc32c +kmod-cfg80211 + DEPENDS:=+BATMAN_ADV_BLA:kmod-lib-crc16 +kmod-lib-crc32c +kmod-cfg80211 +batctl TITLE:=B.A.T.M.A.N. Adv FILES:=$(PKG_BUILD_DIR)/net/batman-adv/batman-adv.$(LINUX_KMOD_SUFFIX) AUTOLOAD:=$(call AutoProbe,batman-adv) diff --git a/batman-adv/files/lib/batman-adv/config.sh b/batman-adv/files/lib/batman-adv/config.sh index 3a746a3..3d6b884 100644 --- a/batman-adv/files/lib/batman-adv/config.sh +++ b/batman-adv/files/lib/batman-adv/config.sh @@ -33,19 +33,21 @@ bat_config() [ ! -f "/sys/class/net/$mesh/mesh/orig_interval" ] && echo "batman-adv mesh $mesh does not exist - check your interface configuration" && return 1 - [ -n "$aggregated_ogms" ] && echo $aggregated_ogms > /sys/class/net/$mesh/mesh/aggregated_ogms - [ -n "$ap_isolation" ] && echo $ap_isolation > /sys/class/net/$mesh/mesh/ap_isolation - [ -n "$bonding" ] && echo $bonding > /sys/class/net/$mesh/mesh/bonding - [ -n "$bridge_loop_avoidance" ] && echo $bridge_loop_avoidance > /sys/class/net/$mesh/mesh/bridge_loop_avoidance 2>&- - [ -n "$distributed_arp_table" ] && echo $distributed_arp_table > /sys/class/net/$mesh/mesh/distributed_arp_table 2>&- - [ -n "$fragmentation" ] && echo $fragmentation > /sys/class/net/$mesh/mesh/fragmentation + [ -n "$aggregated_ogms" ] && batctl -m "$mesh" aggregation "$aggregated_ogms" + [ -n "$ap_isolation" ] && batctl -m "$mesh" ap_isolation "$ap_isolation" + [ -n "$bonding" ] && batctl -m "$mesh" bonding "$bonding" + [ -n "$bridge_loop_avoidance" ] && batctl -m "$mesh" bridge_loop_avoidance "$bridge_loop_avoidance" 2>&- + [ -n "$distributed_arp_table" ] && batctl -m "$mesh" distributed_arp_table "$distributed_arp_table" 2>&- + [ -n "$fragmentation" ] && batctl -m "$mesh" fragmentation "$fragmentation" + [ -n "$gw_bandwidth" ] && echo $gw_bandwidth > /sys/class/net/$mesh/mesh/gw_bandwidth [ -n "$gw_mode" ] && echo $gw_mode > /sys/class/net/$mesh/mesh/gw_mode [ -n "$gw_sel_class" ] && echo $gw_sel_class > /sys/class/net/$mesh/mesh/gw_sel_class [ -n "$hop_penalty" ] && echo $hop_penalty > /sys/class/net/$mesh/mesh/hop_penalty - [ -n "$isolation_mark" ] && echo $isolation_mark > /sys/class/net/$mesh/mesh/isolation_mark - [ -n "$multicast_mode" ] && echo $multicast_mode > /sys/class/net/$mesh/mesh/multicast_mode 2>&- - [ -n "$network_coding" ] && echo $network_coding > /sys/class/net/$mesh/mesh/network_coding 2>&- - [ -n "$log_level" ] && echo $log_level > /sys/class/net/$mesh/mesh/log_level 2>&- - [ -n "$orig_interval" ] && echo $orig_interval > /sys/class/net/$mesh/mesh/orig_interval + + [ -n "$isolation_mark" ] && batctl -m "$mesh" isolation_mark "$isolation_mark" + [ -n "$multicast_mode" ] && batctl -m "$mesh" multicast_mode "$multicast_mode" 2>&- + [ -n "$network_coding" ] && batctl -m "$mesh" network_coding "$network_coding" 2>&- + [ -n "$log_level" ] && batctl -m "$mesh" loglevel "$log_level" 2>&- + [ -n "$orig_interval" ] && batctl -m "$mesh" orig_interval "$orig_interval" } diff --git a/batman-adv/files/lib/netifd/proto/batadv.sh b/batman-adv/files/lib/netifd/proto/batadv.sh index 1e0c9d0..2233091 100755 --- a/batman-adv/files/lib/netifd/proto/batadv.sh +++ b/batman-adv/files/lib/netifd/proto/batadv.sh @@ -17,9 +17,9 @@ proto_batadv_setup() { json_get_vars mesh routing_algo [ -n "$routing_algo" ] || routing_algo="BATMAN_IV" - echo "$routing_algo" > "/sys/module/batman_adv/parameters/routing_algo" + batctl routing_algo "$routing_algo" - echo "$mesh" > "/sys/class/net/$iface/batman_adv/mesh_iface" + batctl -m "$mesh" interface add "$iface" proto_init_update "$iface" 1 proto_send_update "$config" } @@ -28,7 +28,10 @@ proto_batadv_teardown() { local config="$1" local iface="$2" - echo "none" > "/sys/class/net/$iface/batman_adv/mesh_iface" || true + local mesh + json_get_vars mesh + + batctl -m "$mesh" interface del "$iface" || true } add_protocol batadv diff --git a/batman-adv/files/lib/netifd/proto/batadv_vlan.sh b/batman-adv/files/lib/netifd/proto/batadv_vlan.sh index 85002c3..d6d00ad 100755 --- a/batman-adv/files/lib/netifd/proto/batadv_vlan.sh +++ b/batman-adv/files/lib/netifd/proto/batadv_vlan.sh @@ -12,16 +12,12 @@ proto_batadv_vlan_setup() { local config="$1" local iface="$2" - # VLAN specific variables - local device="${iface%.*}" - local vid="${iface#*.}" - # batadv_vlan options local ap_isolation json_get_vars ap_isolation - echo "$ap_isolation" > "/sys/class/net/${device}/mesh/vlan${vid}/ap_isolation" + batctl -m "$iface" ap_isolation "$ap_isolation" proto_init_update "$iface" 1 proto_send_update "$config" } From 0ba9fa2ba743116230f62f35d11ee9267ea22aad Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Sun, 27 Jan 2019 16:28:23 +0100 Subject: [PATCH 3/5] alfred: upgrade package to latest release 2019.0 * (no changes) Signed-off-by: Sven Eckelmann --- alfred/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/alfred/Makefile b/alfred/Makefile index 926f535..75edc26 100644 --- a/alfred/Makefile +++ b/alfred/Makefile @@ -8,9 +8,9 @@ include $(TOPDIR)/rules.mk PKG_NAME:=alfred -PKG_VERSION:=2018.4 +PKG_VERSION:=2019.0 PKG_RELEASE:=0 -PKG_HASH:=8d6595201d5d21b4e3824d408dc9ed705789af1d8831692efa8ffe69a3e1cc58 +PKG_HASH:=c06a674763fe27e85a979d7ca65d2af39df4943ff2a4128cad90dd09d237b46a PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION) From 5d3a71f342e50fb8d0109363c89385b25cf769ce Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Sun, 27 Jan 2019 16:28:23 +0100 Subject: [PATCH 4/5] batctl: upgrade package to latest release 2019.0 * coding style cleanups and refactoring * add gateway selection manpage section for B.A.T.M.A.N. V * bugs squashed: - re-integrate support for translation table unicast/multicast filter - avoid incorrect warning about disabled mesh interface when debugfs support is not enabled in batman-adv Signed-off-by: Sven Eckelmann --- batctl/Makefile | 6 +- ...ng-of-optional-debug-table-command-p.patch | 57 ------------------- 2 files changed, 3 insertions(+), 60 deletions(-) delete mode 100644 batctl/patches/0001-batctl-Fix-parsing-of-optional-debug-table-command-p.patch diff --git a/batctl/Makefile b/batctl/Makefile index 9eefe86..0284c79 100644 --- a/batctl/Makefile +++ b/batctl/Makefile @@ -9,9 +9,9 @@ include $(TOPDIR)/rules.mk PKG_NAME:=batctl -PKG_VERSION:=2018.4 -PKG_RELEASE:=3 -PKG_HASH:=e43827a5e868b4e134e77ca04da989fde1981463166bf1b6f2053acc3edd6257 +PKG_VERSION:=2019.0 +PKG_RELEASE:=0 +PKG_HASH:=997721096ff396644e8d697ea7651e9d38243faf317bcea2661d4139ff58b531 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION) diff --git a/batctl/patches/0001-batctl-Fix-parsing-of-optional-debug-table-command-p.patch b/batctl/patches/0001-batctl-Fix-parsing-of-optional-debug-table-command-p.patch deleted file mode 100644 index 559d2ed..0000000 --- a/batctl/patches/0001-batctl-Fix-parsing-of-optional-debug-table-command-p.patch +++ /dev/null @@ -1,57 +0,0 @@ -From: Sven Eckelmann -Date: Thu, 6 Dec 2018 07:31:59 +0100 -Subject: [PATCH] batctl: Fix parsing of optional debug table command parameters - -The commands which should have no support for -t/-u/-m/-i were allowed to -accept these parameters but commands which should have accepted them were -denying them. - -Fixes: cd2b4047ead9 ("batctl: Convert debug table to command infrastructure") -Reported-by: Andreas Ziegler -Signed-off-by: Sven Eckelmann - -Forwarded: https://patchwork.open-mesh.org/patch/17667/ ---- - debug.c | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/debug.c b/debug.c -index 2979dff99af0b1c98f56931e8650e298dd9eac9b..316312f7162dbe0dc38ced2df1444887482e7bad 100644 ---- a/debug.c -+++ b/debug.c -@@ -89,7 +89,7 @@ int handle_debug_table(struct state *state, int argc, char **argv) - } - break; - case 't': -- if (debug_table->option_watch_interval) { -+ if (!debug_table->option_watch_interval) { - fprintf(stderr, "Error - unrecognised option '-%c'\n", optchar); - debug_table_usage(state); - return EXIT_FAILURE; -@@ -105,7 +105,7 @@ int handle_debug_table(struct state *state, int argc, char **argv) - read_opt |= SKIP_HEADER; - break; - case 'u': -- if (debug_table->option_unicast_only) { -+ if (!debug_table->option_unicast_only) { - fprintf(stderr, "Error - unrecognised option '-%c'\n", optchar); - debug_table_usage(state); - return EXIT_FAILURE; -@@ -114,7 +114,7 @@ int handle_debug_table(struct state *state, int argc, char **argv) - read_opt |= UNICAST_ONLY; - break; - case 'm': -- if (debug_table->option_multicast_only) { -+ if (!debug_table->option_multicast_only) { - fprintf(stderr, "Error - unrecognised option '-%c'\n", optchar); - debug_table_usage(state); - return EXIT_FAILURE; -@@ -123,7 +123,7 @@ int handle_debug_table(struct state *state, int argc, char **argv) - read_opt |= MULTICAST_ONLY; - break; - case 'i': -- if (debug_table->option_orig_iface) { -+ if (!debug_table->option_orig_iface) { - fprintf(stderr, "Error - unrecognised option '-%c'\n", optchar); - debug_table_usage(state); - return EXIT_FAILURE; From e6fc697d418be2053fe4b99518f2c704fde6165e Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Sun, 27 Jan 2019 16:28:23 +0100 Subject: [PATCH 5/5] batman-adv: upgrade package to latest release 2019.0 * support latest kernels (3.16 - 5.0) * coding style cleanups and refactoring * allow to enable debug tracing without full batman-adv debugfs support * enable inconsistency reporting for most netlink dump commands * bugs squashed: - avoid unnecessary kernel warning (panic) during detection of interface loops - work around incorrect ethernet header offset in transmit code path Signed-off-by: Sven Eckelmann --- batman-adv/Config.in | 2 +- batman-adv/Makefile | 6 +++--- batman-adv/src/compat-hacks.h | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/batman-adv/Config.in b/batman-adv/Config.in index a6c8ad3..127a020 100644 --- a/batman-adv/Config.in +++ b/batman-adv/Config.in @@ -90,7 +90,7 @@ config BATMAN_ADV_DEBUGFS config BATMAN_ADV_DEBUG bool "B.A.T.M.A.N. debugging" - depends on BATMAN_ADV_DEBUGFS + depends on PACKAGE_kmod-batman-adv help This is an option for use by developers; most people should say N here. This enables compilation of support for diff --git a/batman-adv/Makefile b/batman-adv/Makefile index 19cba8a..9ad8210 100644 --- a/batman-adv/Makefile +++ b/batman-adv/Makefile @@ -9,9 +9,9 @@ include $(TOPDIR)/rules.mk PKG_NAME:=batman-adv -PKG_VERSION:=2018.4 -PKG_RELEASE:=1 -PKG_HASH:=3500b4bc7d41ce1adef0b0684972a439d48b454ba78282e94df13ba90605484d +PKG_VERSION:=2019.0 +PKG_RELEASE:=0 +PKG_HASH:=3e97d8a771cdbd7b2df42c52b88e071eaa58b5d28eb4e17a4b13b6698debbdc0 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION) diff --git a/batman-adv/src/compat-hacks.h b/batman-adv/src/compat-hacks.h index 4511184..718a15c 100644 --- a/batman-adv/src/compat-hacks.h +++ b/batman-adv/src/compat-hacks.h @@ -348,6 +348,27 @@ typedef unsigned __poll_t; #endif /* < KERNEL_VERSION(4, 16, 0) */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0) + +static inline int batadv_access_ok(int type, const void __user *p, + unsigned long size) +{ + return access_ok(type, p, size); +} + +#ifdef access_ok +#undef access_ok +#endif + +#define access_ok_get(_1, _2, _3 , access_ok_name, ...) access_ok_name +#define access_ok(...) \ + access_ok_get(__VA_ARGS__, access_ok3, access_ok2)(__VA_ARGS__) + +#define access_ok2(addr, size) batadv_access_ok(VERIFY_WRITE, (addr), (size)) +#define access_ok3(type, addr, size) batadv_access_ok((type), (addr), (size)) + +#endif /* < KERNEL_VERSION(5, 0, 0) */ + /* */ #include