wg-installer: use babeld add_interface function
authorNick Hainke <vincent@systemli.org>
Tue, 1 Feb 2022 20:56:23 +0000 (21:56 +0100)
committerNick Hainke <vincent@systemli.org>
Tue, 1 Feb 2022 21:32:30 +0000 (22:32 +0100)
With commit 385200443554 ("babeld: add add_interface function") babeld
has a new ubus function allowing to dynamically add an interface.

Before the add_interface function, we were required to reload babeld.
The reload influenced the babeld routing. However, the remove part is
still missing and will be added at a later stage.

Signed-off-by: Nick Hainke <vincent@systemli.org>
net/wg-installer/Makefile
net/wg-installer/wg-server/hotplug.d/99-mesh-babeld

index b41f5f25e0f38e8319b038a81c63549d7d6121fd..c238faa881440cb92902511c2ce3bdda87bb5b7d 100644 (file)
@@ -57,7 +57,7 @@ endef
 
 define Package/wg-installer-server-hotplug-babeld
        $(call Package/wg-installer-server)
-       DEPENDS:=wg-installer-server +coreutils-realpath
+       DEPENDS:=wg-installer-server
 endef
 
 define Package/wg-installer-server-hotplug-babeld/install
index 49c2f1f18521806e631a690f2ae43d1a5b5615d7..d3ef3e39c49b2508136f02134f7272db18e06a15 100644 (file)
@@ -12,25 +12,5 @@ if [ "${slicedint}" != "wg_" ]; then
 fi
 
 if [ "${ACTION}" = "add" ]; then
-       uci add babeld interface
-       uci set babeld.@interface[-1].ifname="${INTERFACE}"
-       uci get wgserver.@babeld_hotplug[0].rxcost
-       if [ $? -eq 0 ]; then
-               babeld_rxcost="$(uci get wgserver.@babeld_hotplug[0].rxcost)"
-               uci set babeld.@interface[-1].rxcost="$babeld_rxcost"
-       fi
-       uci -c "$(dirname "$(realpath /etc/config/babeld)")" commit babeld
-       /etc/init.d/babeld reload
-fi
-
-if [ "${ACTION}" = "remove" ]; then
-       i=0
-       while uci get babeld.@interface[$i] &> /dev/null ; do
-               if [ "$(uci get babeld.@interface[$i].ifname)" = "${INTERFACE}" ]; then
-                       uci delete babeld.@interface[$i]
-               fi
-               i=$((i+1));
-       done
-       uci -c "$(dirname "$(realpath /etc/config/babeld)")" commit babeld
-       /etc/init.d/babeld reload
+       ubus call babeld add_interface '{"ifname":'\""$INTERFACE"\"'}'
 fi