diff options
author | Vinicius Coque <vinicius.coque@bluepex.com> | 2011-04-15 13:38:13 -0300 |
---|---|---|
committer | Vinicius Coque <vinicius.coque@bluepex.com> | 2011-04-15 13:38:13 -0300 |
commit | a51493d1981175048bdccce51f6b4ad6720da679 (patch) | |
tree | 0c4afae78c022380e5f4cbb9397859761f46d708 /etc/inc/gwlb.inc | |
parent | f599d893fff3d78f44068dc3ba238046d933ddb1 (diff) | |
parent | 7b2fdeb3c5d4fecc23ce2f9a7e1fa1a4c3af63be (diff) | |
download | pfsense-a51493d1981175048bdccce51f6b4ad6720da679.zip pfsense-a51493d1981175048bdccce51f6b4ad6720da679.tar.gz |
Merge remote-tracking branch 'mainline/master' into inc
Conflicts:
etc/inc/gwlb.inc
Diffstat (limited to 'etc/inc/gwlb.inc')
-rw-r--r-- | etc/inc/gwlb.inc | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/etc/inc/gwlb.inc b/etc/inc/gwlb.inc index 6c4cb9d..d2aaa39 100644 --- a/etc/inc/gwlb.inc +++ b/etc/inc/gwlb.inc @@ -373,23 +373,33 @@ function return_gateway_groups_array() { */ $upgw = ""; $dfltgwdown = false; + $dfltgwfound = false; foreach ($gateways_arr as $gwname => $gwsttng) { - if ($gwsttng['defaultgw'] == true && stristr($gateways_status[$gwname]['status'], "down")) - $dfltgwdown = true; + if (isset($gwsttng['defaultgw'])) { + $dfltgwfound = true; + if (stristr($gateways_status[$gwname]['status'], "down")) + $dfltgwdown = true; + } /* Keep a record of the last up gateway */ if (empty($upgw) && !stristr($gateways_status[$gwname]['status'], "down")) $upgw = $gwname; - if ($dfltgwdown == true && !empty($upgw)) { - if ($gateways_arr[$upgw]['gateway'] == "dynamic") - $gateways_arr[$upgw]['gateway'] = get_interface_gateway($gateways_arr[$upgw]['friendlyiface']); - if (is_ipaddr($gateways_arr[$upgw]['gateway'])) { - log_error("Default gateway down setting {$upgw} as default!"); - mwexec("/sbin/route delete -inet default; /sbin/route add -inet default {$gateways_arr[$upgw]['gateway']}"); - } + if ($dfltgwdown == true && !empty($upgw)) break; + } + if ($dfltgwfound == false) { + $gwname = convert_friendly_interface_to_friendly_descr("wan"); + if (stristr($gateways_status[$gwname]['status'], "down")) + $dfltgwdown = true; + } + if ($dfltgwdown == true && !empty($upgw)) { + if ($gateways_arr[$upgw]['gateway'] == "dynamic") + $gateways_arr[$upgw]['gateway'] = get_interface_gateway($gateways_arr[$upgw]['friendlyiface']); + if (is_ipaddr($gateways_arr[$upgw]['gateway'])) { + log_error("Default gateway down setting {$upgw} as default!"); + mwexec("/sbin/route delete -inet default; /sbin/route add -inet default {$gateways_arr[$upgw]['gateway']}"); } } - unset($upgw, $dfltgwdown, $gwname, $gwsttng); + unset($upgw, $dfltgwfound, $dfltgwdown, $gwname, $gwsttng); if (is_array($config['gateways']['gateway_group'])) { foreach($config['gateways']['gateway_group'] as $group) { @@ -409,7 +419,7 @@ function return_gateway_groups_array() { $status = $gateways_status[$gwname]; $gwdown = false; if (stristr($status['status'], "down")) { - $msg = sprintf(gettext("MONITOR: %s has high latency, removing from routing group"), $gwname); + $msg = sprintf(gettext("MONITOR: %s is down, removing from routing group"), $gwname); $gwdown = true; } else if (stristr($status['status'], "loss") && strstr($group['trigger'], "loss")) { /* packet loss */ @@ -423,6 +433,7 @@ function return_gateway_groups_array() { if ($gwdown == true) { log_error($msg); notify_via_growl($msg); + notify_via_smtp($msg); } else /* Online add member */ $tiers[$tier][] = $gwname; @@ -435,6 +446,7 @@ function return_gateway_groups_array() { $msg = gettext("Gateways status could not be determined, considering all as up/active."); log_error($msg); notify_via_growl($msg); + notify_via_smtp($msg); } $tiers = $backupplan; } |