Skip to content

Commit 6f0a0dc

Browse files
committed
mwan3: prefer default route source address
Prefer the source address from the interface default route before falling back to the interface address from netifd. This fixes diagnostics and tracking in setups where the route-selected source address differs from the interface address. Fixes: #29055 Signed-off-by: Dharmik Parmar <dharmikparmar2004@yahoo.com>
1 parent f5160c8 commit 6f0a0dc

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

net/mwan3/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
99

1010
PKG_NAME:=mwan3
1111
PKG_VERSION:=2.12.1
12-
PKG_RELEASE:=1
12+
PKG_RELEASE:=2
1313

1414
PKG_MAINTAINER:=Florian Eckert <fe@dev.tdt.de>
1515
PKG_LICENSE:=GPL-2.0

net/mwan3/files/lib/mwan3/common.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ mwan3_get_src_ip()
7272
IP="$IP6"
7373
fi
7474

75-
$addr_cmd _src_ip "$true_iface"
75+
network_get_device device $true_iface
76+
if [ -n "$device" ]; then
77+
_src_ip=$($IP route show default dev "$device" 2>/dev/null |
78+
sed -ne 's/.* src \([^ ]*\).*/\1/;T;p;q')
79+
fi
80+
[ -z "$_src_ip" ] && $addr_cmd _src_ip "$true_iface"
7681
if [ -z "$_src_ip" ]; then
7782
if [ "$family" = "ipv6" ]; then
7883
# on IPv6-PD interfaces (like PPPoE interfaces) we don't
@@ -98,7 +103,6 @@ mwan3_get_src_ip()
98103
fi
99104
fi
100105
if [ -z "$_src_ip" ]; then
101-
network_get_device device $true_iface
102106
_src_ip=$($IP address ls dev $device 2>/dev/null | sed -ne "$sed_str")
103107
fi
104108
if [ -n "$_src_ip" ]; then

0 commit comments

Comments
 (0)