mwan3: use network_get_preferred_ipaddr6
authorJonas Lochmann <git@inkompetenz.org>
Mon, 1 Jan 2024 00:00:00 +0000 (01:00 +0100)
committerRosen Penev <rosenp@gmail.com>
Mon, 5 Feb 2024 00:39:13 +0000 (16:39 -0800)
This updates mwan3 to use network_get_preferred_ipaddr6 instead of
network_get_ipaddr6 if possible to determine a source ip for the
connectivity checks. This avoids issues where the first ip address
that is returned from network_get_ipaddr6 does not work anymore while
the preferred one returned from network_get_preferred_ipaddr6 works.

Signed-off-by: Jonas Lochmann <git@inkompetenz.org>
net/mwan3/Makefile
net/mwan3/files/lib/mwan3/common.sh

index 9bfc24dbdedff98672cfb952fb6dc5ce1c27ef01..76cc12f58f64f06e7ae756f93802a8d4d08ae959 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=mwan3
 PKG_VERSION:=2.11.12
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 PKG_MAINTAINER:=Florian Eckert <fe@dev.tdt.de>, \
                Aaron Goodman <aaronjg@alumni.stanford.edu>
 PKG_LICENSE:=GPL-2.0
index ecd45026e8db6c863889d4f3105726b0c4c3ff2f..3778cc46cd361529e0fe016f283dcddb1f5bc484 100644 (file)
@@ -61,18 +61,20 @@ mwan3_get_src_ip()
        unset "$1"
        config_get family "$interface" family ipv4
        if [ "$family" = "ipv4" ]; then
-               addr_cmd='network_get_ipaddr'
+               addr_cmd_1='network_get_ipaddr'
+               addr_cmd_2='false'
                default_ip="0.0.0.0"
                sed_str='s/ *inet \([^ \/]*\).*/\1/;T; pq'
                IP="$IP4"
        elif [ "$family" = "ipv6" ]; then
-               addr_cmd='network_get_ipaddr6'
+               addr_cmd_1='network_get_preferred_ipaddr6'
+               addr_cmd_2='network_get_ipaddr6'
                default_ip="::"
                sed_str='s/ *inet6 \([^ \/]*\).* scope.*/\1/;T; pq'
                IP="$IP6"
        fi
 
-       $addr_cmd _src_ip "$true_iface"
+       $addr_cmd_1 _src_ip "$true_iface" 2>&1 || $addr_cmd_2 _src_ip "$true_iface"
        if [ -z "$_src_ip" ]; then
                network_get_device device $true_iface
                _src_ip=$($IP address ls dev $device 2>/dev/null | sed -ne "$sed_str")