First 4 pings lost when mwan3/failover is enabled

Hi,

is there an easy way to test in RUTM50/RUT951 the latest mwan3 (PKG_VERSION:=2.11.16) or a way around to fix the issue with the first 4 ping requests getting lost (for the backup interfaces) when failover/mwan3 is enabled?
According to mwan3: First four pings dropped/lost on mvebu/cortexa9 21.02.05 · Issue #12278 · openwrt/openwrt · GitHub, the issue is not in the 2.11.16?

Thanks

Hello,

Could you please specify if you are experiencing issues with pings being lost?

I have just tested failover functionality with the latest RutOS firmware, and no issues were observed.

Please ensure your devices are updated to the latest firmware versions:

Best regards,

Hi Marija,

Yes, I’m experiencing the issue with the first 4 pings being lost. I noticed this issue while back but I couldn’t figure out that it’s relating to the mwan3.

Setup

  • RUTM50 FW: 07.11.2 (newer versions don’t seem to change the mwan3)
  • mwan3-2.10.12
  • The failover priority is as follows: wlan, mobile, wan, and wan2 (br-lan.2)

Issue
ping 8.8.8.8 -I <interface>:

  • works when failover is disabled
  • works for the wireless (wifi/mob) interfaces
  • 4 pings fail for the wired interfaces (while issuing the pings through mwan3 use works for them)

The PR/fix adds the IP rules, which it seems to make the trick for my case (1501-1503)

root@RUTM50:~# ip rule show
0:	from all lookup local
1001:	from all iif wlan0-1 lookup 1
1002:	from all iif br-lan.2 lookup 2
1003:	from all iif wan lookup 3
1004:	from all iif qmimux0 lookup 4
1501:	from 192.168.1.198 lookup 1
1502:	from 192.168.2.2 lookup 2
1503:	from 192.168.2.3 lookup 3
2001:	from all fwmark 0x100/0x3f00 lookup 1
2002:	from all fwmark 0x200/0x3f00 lookup 2
2003:	from all fwmark 0x300/0x3f00 lookup 3
2004:	from all fwmark 0x400/0x3f00 lookup 4
2061:	from all fwmark 0x3d00/0x3f00 blackhole
2062:	from all fwmark 0x3e00/0x3f00 unreachable
3001:	from all fwmark 0x100/0x3f00 unreachable
3002:	from all fwmark 0x200/0x3f00 unreachable
3003:	from all fwmark 0x300/0x3f00 unreachable
3004:	from all fwmark 0x400/0x3f00 unreachable
32766:	from all lookup main
32767:	from all lookup default

I made this patch based on the proposal PR and deleting the 1500s id rules - seems to be working ok for IPv4

Index: mwan3-2.10.12/files/etc/init.d/mwan3
===================================================================
--- mwan3-2.10.12.orig/files/etc/init.d/mwan3
+++ mwan3-2.10.12/files/etc/init.d/mwan3
@@ -118,7 +118,7 @@
 			$IP route flush table $tid &> /dev/null
 		done
 
-		for rule in $($IP rule list | grep -E '^[1-3][0-9]{3}\:' | cut -d ':' -f 1); do
+		for rule in $($IP rule list | grep -E '^[1-3][0-9]{3}:' | cut -d ':' -f 1); do
 			$IP rule del pref $rule &> /dev/null
 		done
 		table="$($IPT -S)"
Index: mwan3-2.10.12/files/lib/mwan3/mwan3.sh
===================================================================
--- mwan3-2.10.12.orig/files/lib/mwan3/mwan3.sh
+++ mwan3-2.10.12/files/etc/lib/mwan3/mwan3.sh
@@ -492,15 +492,17 @@
 
 	if [ "$family" = "ipv4" ]; then
 		IP="$IP4"
+		network_get_ipaddr wan_addr "${1}"
 	elif [ "$family" = "ipv6" ] && [ $NO_IPV6 -eq 0 ]; then
 		IP="$IP6"
+		network_get_subnet6 wan_addr "${1}"
 	else
 		return
 	fi
-
 	mwan3_delete_iface_rules "$1"
 
 	$IP rule add pref $((id+1000)) iif "$2" lookup "$id"
+	$IP rule add pref $((id+1500)) from ${wan_addr} lookup "$id"
 	$IP rule add pref $((id+2000)) fwmark "$(mwan3_id2mask id MMX_MASK)/$MMX_MASK" lookup "$id"
 	$IP rule add pref $((id+3000)) fwmark "$(mwan3_id2mask id MMX_MASK)/$MMX_MASK" unreachable
 }
@@ -522,7 +524,7 @@
 		return
 	fi
 
-	for rule_id in $(ip rule list | awk '$1 % 1000 == '$id' && $1 > 1000 && $1 < 4000 {print substr($1,0,4)}'); do
+	for rule_id in $(ip rule list | awk '($1 % 1000 == '$id' || $1 % 1500 == '$id') && $1 > 1000 && $1 < 4000 {print substr($1,0,4)}'); do
 		$IP rule del pref $rule_id
 	done
 }

Regards,
yanis