From bd8be7c142269bbe3849ab70e8e26bc2077e3f9b Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Sat, 17 Oct 2026 20:55:19 +0200 Subject: wlb: T9472: fix the inverted ttl health test The ttl test considered the interface healthy whenever ping failed. A dead uplink, where nothing answers, therefore stayed ACTIVE, while a target answering the ping marked the interface FAILED. The test now passes if the hop where the TTL runs out reports it, or if the target is closer and answers itself. If nothing answers within resp-time, the test fails. --- python/vyos/wanloadbalance.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'python') diff --git a/python/vyos/wanloadbalance.py b/python/vyos/wanloadbalance.py index a8cd87350..faea469c2 100644 --- a/python/vyos/wanloadbalance.py +++ b/python/vyos/wanloadbalance.py @@ -17,6 +17,7 @@ import os from vyos.defaults import directories +from vyos.utils.process import rc_cmd from vyos.utils.process import run dhclient_lease = 'dhclient_{0}.lease' @@ -172,10 +173,12 @@ def health_ping_host(host, ifname, count=1, wait_time=0): rc = run(cmd_str) return rc == 0 -def health_ping_host_ttl(host, ifname, count=1, ttl_limit=0): - cmd_str = f'ping -c {count} -t {ttl_limit} -I {ifname} {host}' - rc = run(cmd_str) - return rc != 0 +def health_ping_host_ttl(host, ifname, count=1, ttl_limit=0, wait_time=0): + # The path is up to ttl_limit hops if the hop where the TTL runs out + # reports it, or if the target itself is closer and answers + cmd_str = f'ping -c {count} -W {wait_time} -t {ttl_limit} -I {ifname} {host}' + rc, out = rc_cmd(cmd_str) + return rc == 0 or 'Time to live exceeded' in out def parse_dhcp_nexthop(ifname): lease_file = os.path.join(directories['isc_dhclient_dir'], dhclient_lease.format(ifname)) -- cgit v1.2.3