From f561e272e9b7fe94ba598b70c6d2f44d034446ed Mon Sep 17 00:00:00 2001 From: Oyvind Albrigtsen Date: Wed, 14 Aug 2024 12:05:54 +0200 Subject: [PATCH] findif.sh: ignore unreachable, blackhole, and prohibit routes --- heartbeat/findif.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heartbeat/findif.sh b/heartbeat/findif.sh index ca5d1a5c1..7b817f75c 100644 --- a/heartbeat/findif.sh +++ b/heartbeat/findif.sh @@ -218,9 +218,9 @@ findif() fi if [ -n "$nic" ] ; then # NIC supports more than two. - routematch=$(ip -o -f $family route list match $match $proto $scope | grep "dev $nic " | sed -e 's,^\([0-9.]\+\) ,\1/32 ,;s,^\([0-9a-f:]\+\) ,\1/128 ,' | sort -t/ -k2,2nr) + routematch=$(ip -o -f $family route list match $match $proto $scope | grep -v "^\(unreachable\|prohibit\|blackhole\)" | grep "dev $nic " | sed -e 's,^\([0-9.]\+\) ,\1/32 ,;s,^\([0-9a-f:]\+\) ,\1/128 ,' | sort -t/ -k2,2nr) else - routematch=$(ip -o -f $family route list match $match $proto $scope | sed -e 's,^\([0-9.]\+\) ,\1/32 ,;s,^\([0-9a-f:]\+\) ,\1/128 ,' | sort -t/ -k2,2nr) + routematch=$(ip -o -f $family route list match $match $proto $scope | grep -v "^\(unreachable\|prohibit\|blackhole\)" | sed -e 's,^\([0-9.]\+\) ,\1/32 ,;s,^\([0-9a-f:]\+\) ,\1/128 ,' | sort -t/ -k2,2nr) fi if [ "$family" = "inet6" ]; then routematch=$(echo "$routematch" | grep -v "^default")