diff options
author | Vinicius Coque <vinicius.coque@bluepex.com> | 2011-04-04 10:42:48 -0300 |
---|---|---|
committer | Vinicius Coque <vinicius.coque@bluepex.com> | 2011-04-04 10:42:48 -0300 |
commit | f599d893fff3d78f44068dc3ba238046d933ddb1 (patch) | |
tree | e4b2c4707df823ca6b9cabeb25fe908f9caa531b /etc/inc/gwlb.inc | |
parent | 7de4284cffe27ed6b1f4335dd39b31cd3f852321 (diff) | |
parent | 1309faddc84d101fb0ecba85782d97b04a2a1a9f (diff) | |
download | pfsense-f599d893fff3d78f44068dc3ba238046d933ddb1.zip pfsense-f599d893fff3d78f44068dc3ba238046d933ddb1.tar.gz |
Merge remote-tracking branch 'mainline/master' into inc
Conflicts:
etc/inc/shaper.inc
Diffstat (limited to 'etc/inc/gwlb.inc')
-rw-r--r-- | etc/inc/gwlb.inc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/etc/inc/gwlb.inc b/etc/inc/gwlb.inc index 8ca69cc..6c4cb9d 100644 --- a/etc/inc/gwlb.inc +++ b/etc/inc/gwlb.inc @@ -367,6 +367,30 @@ function return_gateway_groups_array() { $gateways_arr = return_gateways_array(); $gateway_groups_array = array(); + /* + * NOTE: The code below is meant to replace the default gateway when it goes down. + * This facilitates services running on pfSense itself and are not handled by a PBR to continue working. + */ + $upgw = ""; + $dfltgwdown = false; + foreach ($gateways_arr as $gwname => $gwsttng) { + if ($gwsttng['defaultgw'] == true && 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']}"); + } + break; + } + } + unset($upgw, $dfltgwdown, $gwname, $gwsttng); + if (is_array($config['gateways']['gateway_group'])) { foreach($config['gateways']['gateway_group'] as $group) { /* create array with group gateways members seperated by tier */ |