From 498463cd59d227e39f9af86e55df0c970436c08c Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Sun, 6 Jan 2019 13:24:21 +0100 Subject: [PATCH] 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" } -- 2.30.2