[commits] [openwrt-feed-devel] master: batman-adv-devel: use batctl for configuration (5b98583)

postmaster at open-mesh.org postmaster at open-mesh.org
Sat Mar 9 13:02:42 CET 2019


Repository : ssh://git@open-mesh.org/openwrt-feed-devel

On branch  : master

>---------------------------------------------------------------

commit 5b98583e58be97d380d4ed32dd68a7c2dbbe73ce
Author: Sven Eckelmann <sven at narfation.org>
Date:   Sun Jan 6 13:24:21 2019 +0100

    batman-adv-devel: 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 <sven at narfation.org>


>---------------------------------------------------------------

5b98583e58be97d380d4ed32dd68a7c2dbbe73ce
 batctl-devel/Makefile                              |  2 +-
 batman-adv-devel/Makefile                          |  2 +-
 batman-adv-devel/files/lib/batman-adv/config.sh    | 48 +++++++++++++++-------
 batman-adv-devel/files/lib/netifd/proto/batadv.sh  |  9 ++--
 .../files/lib/netifd/proto/batadv_vlan.sh          |  6 +--
 5 files changed, 42 insertions(+), 25 deletions(-)

diff --git a/batctl-devel/Makefile b/batctl-devel/Makefile
index 340c316..c22b1bd 100644
--- a/batctl-devel/Makefile
+++ b/batctl-devel/Makefile
@@ -41,7 +41,7 @@ define Package/batctl-devel
   URL:=https://www.open-mesh.org/
   SECTION:=net
   CATEGORY:=Network
-  DEPENDS:=+kmod-batman-adv-devel +libnl-tiny +libc +librt
+  DEPENDS:=+libnl-tiny +libc +librt
   PROVIDES:=batctl-devel
   MAINTAINER:=Simon Wunderlich <sw at simonwunderlich.de>
   TITLE:=B.A.T.M.A.N. Advanced user space configuration tool (Default)
diff --git a/batman-adv-devel/Makefile b/batman-adv-devel/Makefile
index 7dd42b7..bede8cc 100644
--- a/batman-adv-devel/Makefile
+++ b/batman-adv-devel/Makefile
@@ -41,7 +41,7 @@ define KernelPackage/batman-adv-devel
   URL:=https://www.open-mesh.org/
   MAINTAINER:=Simon Wunderlich <sw at simonwunderlich.de>
   SUBMENU:=Network Support
-  DEPENDS:=+BATMAN_ADV_DEVEL_BLA:kmod-lib-crc16 +kmod-lib-crc32c +kmod-cfg80211
+  DEPENDS:=+BATMAN_ADV_DEVEL_BLA:kmod-lib-crc16 +kmod-lib-crc32c +kmod-cfg80211 +batctl-devel
   TITLE:=B.A.T.M.A.N. Adv devel
   FILES:=$(PKG_BUILD_DIR)/net/batman-adv/batman-adv.$(LINUX_KMOD_SUFFIX)
   AUTOLOAD:=$(call AutoProbe,batman-adv)
diff --git a/batman-adv-devel/files/lib/batman-adv/config.sh b/batman-adv-devel/files/lib/batman-adv/config.sh
index 3a746a3..952f93e 100644
--- a/batman-adv-devel/files/lib/batman-adv/config.sh
+++ b/batman-adv-devel/files/lib/batman-adv/config.sh
@@ -33,19 +33,37 @@ 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 "$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 "$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"
+
+	case "$gw_mode" in
+	server)
+		if [ -n "$gw_bandwidth" ]; then
+			batctl -m "$mesh" gw_mode "server" "$gw_bandwidth"
+		else
+			batctl -m "$mesh" gw_mode "server"
+		fi
+		;;
+	client)
+		if [ -n "$gw_sel_class" ]; then
+			batctl -m "$mesh" gw_mode "client" "$gw_sel_class"
+		else
+			batctl -m "$mesh" gw_mode "client"
+		fi
+		;;
+	*)
+		batctl -m "$mesh" gw_mode "off"
+		;;
+	esac
+
+	[ -n "$hop_penalty" ] && batctl -m "$mesh" hop_penalty "$hop_penalty"
+	[ -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-devel/files/lib/netifd/proto/batadv.sh b/batman-adv-devel/files/lib/netifd/proto/batadv.sh
index 1e0c9d0..2233091 100755
--- a/batman-adv-devel/files/lib/netifd/proto/batadv.sh
+++ b/batman-adv-devel/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-devel/files/lib/netifd/proto/batadv_vlan.sh b/batman-adv-devel/files/lib/netifd/proto/batadv_vlan.sh
index 85002c3..d6d00ad 100755
--- a/batman-adv-devel/files/lib/netifd/proto/batadv_vlan.sh
+++ b/batman-adv-devel/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"
 }



More information about the commits mailing list