From 35bd1db7fbed1f60815bfeea09b52ecd386a7524 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Tue, 27 Sep 2016 11:43:26 -0700 Subject: [PATCH] Handle Down or missing interfaces in 'delete_gateway()' Signed-off-by: Tom Eastep --- Shorewall/Perl/lib.runtime | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Shorewall/Perl/lib.runtime b/Shorewall/Perl/lib.runtime index abb32f716..6020a76f7 100644 --- a/Shorewall/Perl/lib.runtime +++ b/Shorewall/Perl/lib.runtime @@ -996,9 +996,16 @@ delete_gateway() # $! = Description of the Gateway $2 = table number $3 = device if [ -n "$route" ]; then if echo $route | grep -qF ' nexthop '; then - gateway="nexthop $gateway" - eval route=\`echo $route \| sed \'s/$gateway/ /\'\` - run_ip route replace table $2 $route + if interface_is_up $3; then + gateway="nexthop $gateway" + else + gateway="nexthop $gateway dead" + fi + + if eval echo $route \| fgrep -q \'$gateway\'; then + eval route=\`echo $route \| sed \'s/$gateway/ /\'\` + run_ip route replace table $2 $route + fi else dev=$(find_device $route) [ "$dev" = "$3" ] && run_ip route delete default table $2