From 575c64400d72527f80fa4b77c04301116fe92abc Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Fri, 5 May 2017 11:36:10 +0200 Subject: [PATCH] gateway failover, typo in fixup_default_gateway() leading to not switch no gw down --- src/etc/inc/gwlb.inc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/etc/inc/gwlb.inc b/src/etc/inc/gwlb.inc index 7e848e6e9..2bae8b4ad 100644 --- a/src/etc/inc/gwlb.inc +++ b/src/etc/inc/gwlb.inc @@ -739,7 +739,7 @@ function fixup_default_gateway($gateways_status, $gateways_arr) (isset($gwsttng['monitor_disable']) || !stristr($gateways_status[$gwname]['status'], "down"))) { $upgw = $gwname; } - if ($dfltgwdown && !empty($upgw)) { + if (!$dfltgwup && !empty($upgw)) { // switch gateway $dfltgwname = $upgw; break; @@ -755,7 +755,8 @@ function fixup_default_gateway($gateways_status, $gateways_arr) } else { $gwip = $gateways_arr[$dfltgwname]['gateway']; } - $defaultgw = trim(exec("/sbin/route -n get -{$ipprotocol} default | /usr/bin/awk '/gateway:/ {print $2}'"), " \n"); + $tmpcmd = "/sbin/route -n get -{$ipprotocol} default | /usr/bin/awk '/gateway:/ {print $2}'"; + $defaultgw = trim(exec($tmpcmd), " \n"); if (!$dfltgwup) { log_error("Default gateway down setting {$dfltgwname} as default!"); }