batman-adv: use batctl for configuration
authorSven Eckelmann <sven@narfation.org>
Sun, 6 Jan 2019 12:24:21 +0000 (13:24 +0100)
committerSven Eckelmann <sven@narfation.org>
Sun, 27 Jan 2019 14:31:37 +0000 (15:31 +0100)
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 <sven@narfation.org>
batctl/Makefile
batman-adv/Makefile
batman-adv/files/lib/batman-adv/config.sh
batman-adv/files/lib/netifd/proto/batadv.sh
batman-adv/files/lib/netifd/proto/batadv_vlan.sh

index 126a4f3aa0cc9bf50674d36e987a4e885b199dea..9eefe864801e86fb9d7dfedad10832b00d78f591 100644 (file)
@@ -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 <sw@simonwunderlich.de>
 endef
index dc73feefa6a26c0ae4cf1a3dbdea0e7e59764558..19cba8ae26abc2912bbe4a32f820bd0d7322974c 100644 (file)
@@ -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 <sw@simonwunderlich.de>
   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)
index 3a746a3c0e280b9a01ae67ea27bde65619b77ebc..3d6b8849c1723bcf31d10c74ddbbda5e92288e46 100644 (file)
@@ -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"
 }
index 1e0c9d0fe24d44c7f7cc9bddaf8065c60f680862..2233091452dbfad801bb1e93ae90cd03919fac87 100755 (executable)
@@ -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
index 85002c35e76f9a426358832204b16ae3ca519913..d6d00ad488cb4cec47d370559b3585c5f513ff80 100755 (executable)
@@ -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"
 }