diff options
| author | Christian Breunig <christian@breunig.cc> | 2026-10-17 20:55:19 +0200 |
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2026-10-17 20:56:35 +0200 |
| commit | bd8be7c142269bbe3849ab70e8e26bc2077e3f9b (patch) | |
| tree | c2a09f8d68779db7469bfb14c0d2076fdf026b56 /python | |
| parent | db494f512ae62eab3d90b786da5f8d855b45ec7d (diff) | |
| download | vyos-1x-bd8be7c142269bbe3849ab70e8e26bc2077e3f9b.tar.gz vyos-1x-bd8be7c142269bbe3849ab70e8e26bc2077e3f9b.zip | |
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.
Diffstat (limited to 'python')
| -rw-r--r-- | python/vyos/wanloadbalance.py | 11 |
1 files changed, 7 insertions, 4 deletions
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)) |
