fff-babeld: redistribute all peer_ip and peer_ip6 addresses

So far peer ips were only distributed via babel if they happened to fall
into the predefined network ranges. Currently, these only contain the
prefixes from the private and ULA ranges. Specifying any other address,
e.g. a globally routed one, will not result in the router being
reachable via that address.

Now peer ips are added to the `loopback` interface and babel is
instructed to redistribute addresses from `lo`, so any peer ip is
redistributed and therefore the router is now reachable via these
addresses.

Another option could have been to dynamically add a redistribute filter
for the peer ips before this section:

```
config filter
    option type 'redistribute'
    option local 'true'
    option action 'deny'
```

Sadly it almost impossible to do this in a reasonable manner with uci,
that doesn't involve iterating over all filter options or requiring this
specific section to be always named.

Adding the peer ips to `lo` is also the more conventional way to
configure an address "owned" by a router.

Signed-off-by: Johannes Kimmel <fff@bareminimum.eu>
This commit is contained in:
Johannes Kimmel 2021-01-26 18:28:50 +01:00
parent f6c1e4da52
commit 60051fb4a7
Signed by: jkimmel
GPG Key ID: 6B8F7858CE2AF6A5
2 changed files with 20 additions and 0 deletions

View File

@ -22,6 +22,11 @@ config filter
option local 'true'
option ip 'fd43:5602:29bd::/48'
config filter
option type 'redistribute'
option local 'true'
option interface 'lo'
config filter
option type 'redistribute'
option local 'true'

View File

@ -90,6 +90,21 @@ configure() {
for prefix in $(uci -q get gateway.@client[0].ip6addr); do
babel_add_redistribute_filter "$prefix"
done
# clean up old peer ips
uci -q del network.loopback.ipaddr
uci -q del network.loopback.ip6addr
# remove netmask entry that ships by default
uci -q del network.loopback.netmask
# re-add loopback addresses
uci -q add_list network.loopback.ipaddr="127.0.0.1/8"
uci -q add_list network.loopback.ip6addr="::1/128"
# add peer ips to lo to be redistributed
peerip=$(uci -q get gateway.@gateway[0].peer_ip) && uci -q add_list network.loopback.ipaddr="${peerip}/32"
peerip6=$(uci -q get gateway.@gateway[0].peer_ip6) && uci -q add_list network.loopback.ip6addr="${peerip6}/128"
}
apply() {