batman-adv: use batctl for configuration of gw_mode
authorSven Eckelmann <sven@narfation.org>
Fri, 22 Feb 2019 20:47:40 +0000 (21:47 +0100)
committerSven Eckelmann <sven@narfation.org>
Fri, 22 Feb 2019 21:46:21 +0000 (22:46 +0100)
The batctl tool should be used for modifying settings in the batman-adv
driver to keep the scripts consistent and allow to use the correct way of
communicating with the kernel (sysfs vs. netlink).

The gw_mode, gw_bandwidth and gw_sel_class options are all handled by
the same gw_mode command in batctl and thus have to be combined depending
on the "gw_mode" value.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
batman-adv/Makefile
batman-adv/files/lib/batman-adv/config.sh

index 9ad8210050ac92559f5b0c3edacad45a9e3d0fb6..b47e3b6609f42f5095d5b693d4d84c673d40b28f 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 PKG_NAME:=batman-adv
 
 PKG_VERSION:=2019.0
-PKG_RELEASE:=0
+PKG_RELEASE:=1
 PKG_HASH:=3e97d8a771cdbd7b2df42c52b88e071eaa58b5d28eb4e17a4b13b6698debbdc0
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
index 3d6b8849c1723bcf31d10c74ddbbda5e92288e46..a74c9d8f3ad4fed33579cc16adf7f2104af98f1e 100644 (file)
@@ -40,9 +40,26 @@ bat_config()
        [ -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
+       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" ] && echo $hop_penalty > /sys/class/net/$mesh/mesh/hop_penalty
 
        [ -n "$isolation_mark" ] && batctl -m "$mesh" isolation_mark "$isolation_mark"