From fc3cc2fe5c33b36014178d3652785d00cae1c9eb Mon Sep 17 00:00:00 2001 From: Jonas Lochmann Date: Mon, 1 Jan 2024 01:00:00 +0100 Subject: [PATCH] mwan3: use network_get_preferred_ipaddr6 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 --- net/mwan3/Makefile | 2 +- net/mwan3/files/lib/mwan3/common.sh | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/net/mwan3/Makefile b/net/mwan3/Makefile index 9bfc24dbde..76cc12f58f 100644 --- a/net/mwan3/Makefile +++ b/net/mwan3/Makefile @@ -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 , \ Aaron Goodman PKG_LICENSE:=GPL-2.0 diff --git a/net/mwan3/files/lib/mwan3/common.sh b/net/mwan3/files/lib/mwan3/common.sh index ecd45026e8..3778cc46cd 100644 --- a/net/mwan3/files/lib/mwan3/common.sh +++ b/net/mwan3/files/lib/mwan3/common.sh @@ -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") -- 2.30.2