Skip to content

Commit f717b4a

Browse files
committed
findif.sh: fix corner cases
1 parent 227ae15 commit f717b4a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

heartbeat/findif.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ findif()
215215
fi
216216
if [ -n "$nic" ] ; then
217217
# NIC supports more than two.
218-
set -- $(ip -o -f $family route list match $match $scope | grep "dev $nic " | awk 'BEGIN{best=0} /\// { mask=$1; sub(".*/", "", mask); if( int(mask)>=best ) { best=int(mask); best_ln=$0; } } END{print best_ln}')
218+
set -- $(ip -o -f $family route list match $match $scope | grep "dev $nic " | sed -e 's,^\([0-9.]\+\) ,\1/32 ,;s,^\([0-9a-f:]\+\) ,\1/128 ,' | sort -t/ -k2,2nr)
219219
else
220-
set -- $(ip -o -f $family route list match $match $scope | awk 'BEGIN{best=0} /\// { mask=$1; sub(".*/", "", mask); if( int(mask)>=best ) { best=int(mask); best_ln=$0; } } END{print best_ln}')
220+
set -- $(ip -o -f $family route list match $match $scope | sed -e 's,^\([0-9.]\+\) ,\1/32 ,;s,^\([0-9a-f:]\+\) ,\1/128 ,' | sort -t/ -k2,2nr)
221221
fi
222222
if [ $# = 0 ] ; then
223223
case $OCF_RESKEY_ip in

0 commit comments

Comments
 (0)