fff-babeld: Only select first list entry from router_ip

The router_ip option can be a list of multiple ip addresses. It is also
possible to specify a subnet using a CIDR mask.

Only a single ip is required for peering interfaces, so select only the
first list entry and remove the CIDR mask.

Fixes: #197

Signed-off-by: Fabian Bläse <fabian@blaese.de>
This commit is contained in:
Fabian Bläse 2022-01-04 12:02:41 +01:00
parent a6b90f1a83
commit 8ef6dba5a1
1 changed files with 9 additions and 1 deletions

View File

@ -38,7 +38,15 @@ babel_add_peeraddr() {
uci add_list "$option"="$peer_ip"
elif router_ip=$(uci -q get gateway.meta.router_ip); then
# use router_ip if no peer_ip is set
uci add_list "$option"="$router_ip"
ip=$router_ip
# use only first ip
ip=${ip%% *}
# remove CIDR mask
ip=${ip%%/*}
uci add_list "$option"="$ip"
elif ipaddr=$(uci -q get gateway.@client[0].ipaddr); then
# use client interface address (without subnet) if no router_ip is set
uci add_list "$option"=$(echo $ipaddr | cut -d / -f1)