summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2011-04-06 14:58:27 +0000
committerErmal <eri@pfsense.org>2011-04-06 14:58:27 +0000
commit19d9146637b36dd8cb3d42e300c44d4a8ccfe6d2 (patch)
treec2096ebd9d0b1ea682bd2a37c88da7acd102bc7f
parentd10da0f9958850c0417efdcfbee8a9ea746923a9 (diff)
downloadpfsense-19d9146637b36dd8cb3d42e300c44d4a8ccfe6d2.zip
pfsense-19d9146637b36dd8cb3d42e300c44d4a8ccfe6d2.tar.gz
Another sweep at keeping the default route always present when the default setup route is marked as down. This now adds checks for configuration where a defaultgw is not specified by the user but deduced automatically.
-rw-r--r--etc/inc/gwlb.inc30
1 files changed, 20 insertions, 10 deletions
diff --git a/etc/inc/gwlb.inc b/etc/inc/gwlb.inc
index 75dc775..50bd5c3 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) {
OpenPOWER on IntegriCloud