Add bird2 as selectable babel implementation
Bird 2 has a few advantages over babeld. Especially the possiblity to dynamically reload the configuration without restarting the daemon and birds significant performance advantage make it an interesting alternative to babeld for our firmware. This adds the necessary implementation-specific fff-babel-bird2 package, which allows to integrate bird2 into the fff firmware. Signed-off-by: Fabian Bläse <fabian@blaese.de>
This commit is contained in:
parent
ccc4bf823c
commit
b7829d789a
|
@ -15,7 +15,7 @@ ROUTINGREV="2baff33918c089fd3744c7192f8ae7a29c47a8d7"
|
|||
GLUONREV="12e41d0ff07ec54bbd67a31ab50d12ca04f2238c"
|
||||
|
||||
OPENWRT_PKGS="gpioctl-sysfs libugpio fastd haserl micrond mtr bmon"
|
||||
ROUTING_PKGS="kmod-batman-adv batctl alfred babeld"
|
||||
ROUTING_PKGS="kmod-batman-adv batctl alfred babeld bird2"
|
||||
GLUON_PKGS="simple-tc uradvd"
|
||||
|
||||
FFF_VARIANTS="node layer3"
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=fff-babel-bird2
|
||||
PKG_RELEASE:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/fff-babel-bird2
|
||||
SECTION:=base
|
||||
CATEGORY:=Freifunk
|
||||
TITLE:=Freifunk-Franken 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
|
||||
This is the Freifunk Franken Firmware babel-bird2 package.
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
# nothing
|
||||
endef
|
||||
|
||||
define Package/fff-babel-bird2/install
|
||||
$(CP) ./files/* $(1)/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,fff-babel-bird2))
|
|
@ -0,0 +1 @@
|
|||
include "/etc/bird-babel/*.conf";
|
|
@ -0,0 +1,117 @@
|
|||
# router id is not required for babeld, but necessary for bird startup
|
||||
router id 192.0.2.0;
|
||||
|
||||
ipv4 table fff4;
|
||||
ipv6 sadr table fff6;
|
||||
|
||||
protocol device {
|
||||
scan time 15;
|
||||
}
|
||||
|
||||
# device routes for ipv4 peering address
|
||||
protocol direct {
|
||||
ipv4 {
|
||||
table fff4;
|
||||
import filter {
|
||||
if (net ~ 10.50.0.0/16 || net ~ 10.83.0.0/16) && net.len = 32 then {
|
||||
accept;
|
||||
}
|
||||
reject;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# device routes on loopback interface
|
||||
protocol direct {
|
||||
ipv4 {
|
||||
table fff4;
|
||||
import filter {
|
||||
if net ~ 10.50.0.0/16 || net ~ 10.83.0.0/16 then {
|
||||
accept;
|
||||
}
|
||||
reject;
|
||||
};
|
||||
};
|
||||
|
||||
ipv6 sadr {
|
||||
table fff6;
|
||||
import filter {
|
||||
if net ~ fdff::/64 from ::/0 then {
|
||||
reject;
|
||||
}
|
||||
|
||||
# only import GUA + ULA addresses
|
||||
if net !~ 2000::/3 from ::/0 || net !~ fc00::/7 from ::/0 then {
|
||||
reject;
|
||||
}
|
||||
|
||||
accept;
|
||||
};
|
||||
import keep filtered;
|
||||
};
|
||||
|
||||
interface "lo";
|
||||
}
|
||||
|
||||
# ipv6 kernel route interface
|
||||
protocol kernel {
|
||||
ipv6 sadr {
|
||||
table fff6;
|
||||
import filter {
|
||||
# only import routes from kernel with proto static
|
||||
if krt_source != 4 then {
|
||||
reject;
|
||||
}
|
||||
|
||||
if net ~ fdff::/64 from ::/0 then {
|
||||
reject;
|
||||
}
|
||||
|
||||
accept;
|
||||
};
|
||||
export all;
|
||||
preference 200;
|
||||
};
|
||||
kernel table 10;
|
||||
scan time 15;
|
||||
learn yes;
|
||||
}
|
||||
|
||||
# ipv4 kernel route interface
|
||||
protocol kernel {
|
||||
ipv4 {
|
||||
table fff4;
|
||||
import filter {
|
||||
# only import routes from kernel with proto static
|
||||
if krt_source = 4 then {
|
||||
accept;
|
||||
}
|
||||
reject;
|
||||
};
|
||||
export all;
|
||||
preference 200;
|
||||
};
|
||||
kernel table 10;
|
||||
scan time 15;
|
||||
learn yes;
|
||||
}
|
||||
|
||||
protocol babel {
|
||||
# required due to static configuration of global router id.
|
||||
# also improves reconnect speed after restart.
|
||||
randomize router id yes;
|
||||
|
||||
ipv4 {
|
||||
table fff4;
|
||||
import all;
|
||||
export all;
|
||||
};
|
||||
|
||||
ipv6 sadr {
|
||||
table fff6;
|
||||
import all;
|
||||
export all;
|
||||
};
|
||||
|
||||
include "/etc/bird-babel-include.conf";
|
||||
};
|
|
@ -0,0 +1,5 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
mv /etc/bird-fff.conf /etc/bird.conf
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,63 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
babel_add_interface() {
|
||||
[ "$#" -ne "4" ] && return 1
|
||||
|
||||
local name="$1"
|
||||
local interface="$2"
|
||||
local type="$3"
|
||||
local rxcost="$4"
|
||||
|
||||
mkdir -p /tmp/bird-babel
|
||||
echo "interface \"$interface\" { type $type; rxcost $rxcost; };" > /tmp/bird-babel/$name.conf
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
babel_delete_interface() {
|
||||
[ "$#" -ne "1" ] && return 1
|
||||
|
||||
local name="$1"
|
||||
|
||||
# Removing peers from /etc is not necessary, as all peers are generated into /tmp on every configuration run,
|
||||
# which completely overwrites existing peers in /etc in the apply step.
|
||||
rm -f /tmp/bird-babel/$name.conf
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
babel_add_redistribute_filter() {
|
||||
return 0
|
||||
}
|
||||
|
||||
babel_remove_custom_redistribute_filters() {
|
||||
return 0
|
||||
}
|
||||
|
||||
babel_apply() {
|
||||
# error output hidden because apply might be executed without a preceding configure step.
|
||||
if [ -d /tmp/bird-babel ]; then
|
||||
rm -rf /etc/bird-babel
|
||||
mv /tmp/bird-babel /etc/bird-babel
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
babel_reload() {
|
||||
# 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),
|
||||
# switch back to the permanent configuration (/etc).
|
||||
if [ -d /tmp/bird-babel ]; then
|
||||
echo 'include "/tmp/bird-babel/*.conf";' > /etc/bird-babel-include.conf
|
||||
else
|
||||
echo 'include "/etc/bird-babel/*.conf";' > /etc/bird-babel-include.conf
|
||||
fi
|
||||
|
||||
/etc/init.d/bird reload
|
||||
}
|
||||
|
||||
babel_revert() {
|
||||
rm -r /tmp/bird-babel
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
neighbours="$(birdc -r show babel neighbors |
|
||||
tail -n +5 |
|
||||
awk '{ printf "<neighbour><ip>%s</ip><outgoing_interface>%s</outgoing_interface><link_cost>%s</link_cost></neighbour>", $1, $2, $3 }'
|
||||
)"
|
||||
|
||||
echo -n "<babel_neighbours>$neighbours</babel_neighbours>"
|
||||
|
||||
exit 0
|
|
@ -76,6 +76,8 @@ fi
|
|||
|
||||
if [ -x /usr/sbin/babeld ]; then
|
||||
SYSTEM_DATA="$SYSTEM_DATA<babel_version>$(/usr/sbin/babeld -V 2>&1)</babel_version>"
|
||||
elif [ -x /usr/sbin/bird ]; then
|
||||
SYSTEM_DATA="$SYSTEM_DATA<babel_version>$(/usr/sbin/bird --version 2>&1 | sed "s/BIRD version /bird-/")</babel_version>"
|
||||
fi
|
||||
|
||||
# example for /etc/openwrt_release:
|
||||
|
|
Loading…
Reference in New Issue