fff-babel: Make implementation runtime switchable

Some users might want to prefer one babel implementation over another
for various reasons. Having to compile the firmware from scratch can be
quite tedious in that case.

Instead, make the babel implementation switchable at runtime.

Currently, the implementation has to be switched manually in
/lib/functions/fff/babel, which is not upgrade-safe. Also, the previous
implementation is currently not restored after test-mode, so switching
implementations should not be done with test-mode.

Signed-off-by: Fabian Bläse <fabian@blaese.de>
This commit is contained in:
Fabian Bläse 2022-01-05 13:45:58 +01:00
parent b7829d789a
commit bdcaa1c285
7 changed files with 35 additions and 4 deletions

View File

@ -12,7 +12,6 @@ define Package/fff-babel-bird2
URL:=https://www.freifunk-franken.de
DEPENDS:=+bird2 +bird2c
PROVIDES:=fff-babel-implementation
CONFLICTS:=fff-babeld
endef
define Package/fff-babel-bird2/description

View File

@ -0,0 +1,3 @@
/etc/init.d/bird disable
exit 0

View File

@ -44,7 +44,7 @@ babel_apply() {
return 0
}
babel_reload() {
babel_reload_implementation() {
# Change include file path, so bird uses the correct configuration, depending on the configuration state:
# - If test mode is active (and /tmp/bird-babel exists), switch to the temporary (/tmp) configuration to be tested.
# - If new settings are applied or the old settings are restored after an unsuccessful test (and /tmp/bird-babel does not exist),

View File

@ -1,4 +1,6 @@
. /lib/functions/fff/babeldaemon
implementation=babeld
. /lib/functions/fff/babeldaemon/$implementation
babel_add_iifrules() {
[ "$#" -ne "1" ] && return 1
@ -62,3 +64,26 @@ babel_add_peer6addr() {
return 0
}
babel_reload() {
# switch implementation
case $implementation in
bird2)
/etc/init.d/babeld stop 2>/dev/null
/etc/init.d/babeld disable
/etc/init.d/bird enable
/etc/init.d/bird start
;;
babeld)
/etc/init.d/bird stop 2>/dev/null
/etc/init.d/bird disable
/etc/init.d/babeld enable
/etc/init.d/babeld start
;;
esac
# call implementation-specific reload commands
babel_reload_implementation
return 0
}

View File

@ -0,0 +1,3 @@
/etc/init.d/babeld disable
exit 0

View File

@ -63,7 +63,7 @@ babel_apply() {
uci commit babeld
}
babel_reload() {
babel_reload_implementation() {
return 0
}

View File

@ -13,6 +13,7 @@ define Package/fff-layer3
DEPENDS:=+fff-alfred-monitoring-proxy \
+fff-babel \
+fff-babeld \
+fff-babel-bird2 \
+fff-boardname \
+fff-dhcp \
+fff-layer3-config \