From bdcaa1c285ba4215f166c7bbe5f53936fe23fbcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Bl=C3=A4se?= Date: Wed, 5 Jan 2022 13:45:58 +0100 Subject: [PATCH] fff-babel: Make implementation runtime switchable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/packages/fff/fff-babel-bird2/Makefile | 1 - .../files/etc/uci-defaults/30-disable-bird2 | 3 +++ .../fff/{babeldaemon => babeldaemon/bird2} | 2 +- .../fff-babel/files/lib/functions/fff/babel | 27 ++++++++++++++++++- .../files/etc/uci-defaults/30-disable-babeld | 3 +++ .../fff/{babeldaemon => babeldaemon/babeld} | 2 +- src/packages/fff/fff-layer3/Makefile | 1 + 7 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 src/packages/fff/fff-babel-bird2/files/etc/uci-defaults/30-disable-bird2 rename src/packages/fff/fff-babel-bird2/files/lib/functions/fff/{babeldaemon => babeldaemon/bird2} (98%) create mode 100644 src/packages/fff/fff-babeld/files/etc/uci-defaults/30-disable-babeld rename src/packages/fff/fff-babeld/files/lib/functions/fff/{babeldaemon => babeldaemon/babeld} (97%) diff --git a/src/packages/fff/fff-babel-bird2/Makefile b/src/packages/fff/fff-babel-bird2/Makefile index 9c26462b..67efc7a4 100644 --- a/src/packages/fff/fff-babel-bird2/Makefile +++ b/src/packages/fff/fff-babel-bird2/Makefile @@ -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 diff --git a/src/packages/fff/fff-babel-bird2/files/etc/uci-defaults/30-disable-bird2 b/src/packages/fff/fff-babel-bird2/files/etc/uci-defaults/30-disable-bird2 new file mode 100644 index 00000000..aa46f2a5 --- /dev/null +++ b/src/packages/fff/fff-babel-bird2/files/etc/uci-defaults/30-disable-bird2 @@ -0,0 +1,3 @@ +/etc/init.d/bird disable + +exit 0 diff --git a/src/packages/fff/fff-babel-bird2/files/lib/functions/fff/babeldaemon b/src/packages/fff/fff-babel-bird2/files/lib/functions/fff/babeldaemon/bird2 similarity index 98% rename from src/packages/fff/fff-babel-bird2/files/lib/functions/fff/babeldaemon rename to src/packages/fff/fff-babel-bird2/files/lib/functions/fff/babeldaemon/bird2 index a1740bfa..f2b6e6fc 100644 --- a/src/packages/fff/fff-babel-bird2/files/lib/functions/fff/babeldaemon +++ b/src/packages/fff/fff-babel-bird2/files/lib/functions/fff/babeldaemon/bird2 @@ -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), diff --git a/src/packages/fff/fff-babel/files/lib/functions/fff/babel b/src/packages/fff/fff-babel/files/lib/functions/fff/babel index 2e3d3f2e..8233cb20 100644 --- a/src/packages/fff/fff-babel/files/lib/functions/fff/babel +++ b/src/packages/fff/fff-babel/files/lib/functions/fff/babel @@ -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 +} diff --git a/src/packages/fff/fff-babeld/files/etc/uci-defaults/30-disable-babeld b/src/packages/fff/fff-babeld/files/etc/uci-defaults/30-disable-babeld new file mode 100644 index 00000000..e14dd4b9 --- /dev/null +++ b/src/packages/fff/fff-babeld/files/etc/uci-defaults/30-disable-babeld @@ -0,0 +1,3 @@ +/etc/init.d/babeld disable + +exit 0 diff --git a/src/packages/fff/fff-babeld/files/lib/functions/fff/babeldaemon b/src/packages/fff/fff-babeld/files/lib/functions/fff/babeldaemon/babeld similarity index 97% rename from src/packages/fff/fff-babeld/files/lib/functions/fff/babeldaemon rename to src/packages/fff/fff-babeld/files/lib/functions/fff/babeldaemon/babeld index fe584339..ec033794 100644 --- a/src/packages/fff/fff-babeld/files/lib/functions/fff/babeldaemon +++ b/src/packages/fff/fff-babeld/files/lib/functions/fff/babeldaemon/babeld @@ -63,7 +63,7 @@ babel_apply() { uci commit babeld } -babel_reload() { +babel_reload_implementation() { return 0 } diff --git a/src/packages/fff/fff-layer3/Makefile b/src/packages/fff/fff-layer3/Makefile index 7e9f08ba..782fbd16 100644 --- a/src/packages/fff/fff-layer3/Makefile +++ b/src/packages/fff/fff-layer3/Makefile @@ -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 \