diff --git a/src/etc/inc/filter.inc b/src/etc/inc/filter.inc index 9a5319b4a..d0e053093 100644 --- a/src/etc/inc/filter.inc +++ b/src/etc/inc/filter.inc @@ -298,8 +298,18 @@ function filter_configure_sync($verbose = false, $flush_states = false, $load_al } if (isset($config['system']['gw_switch_default'])) { - /* XXX gw_switch_group4 and gw_switch_group6 to pass down: */ - fixup_default_gateway(); + // When gateway switching is enabled, we might consider a different default gateway. + // although this isn't really the right spot for the feature (it's a monitoring/routing decision), + // we keep it here for now (historical reasons). + $down_gateways = return_down_gateways(); + foreach (array("inet", "inet6") as $ipprotocol) { + $default_gw = $fw->getGateways()->getDefaultGW($down_gateways, $ipprotocol); + if ($default_gw !== null) { + system_default_route( + $default_gw['gateway'], $ipprotocol, $default_gw['if'], isset($default_gw['fargw']) + ); + } + } } $aliases = filter_generate_aliases(); diff --git a/src/etc/inc/gwlb.inc b/src/etc/inc/gwlb.inc index d30340d93..d6d626a61 100644 --- a/src/etc/inc/gwlb.inc +++ b/src/etc/inc/gwlb.inc @@ -624,66 +624,6 @@ function return_down_gateways() return $result ; } -function fixup_default_gateway() -{ - $gateways_status = return_gateways_status(); - $gateways_arr = return_gateways_array(); - - foreach (array("inet", "inet6") as $ipprotocol) { - $dfltgwname = null; - $dfltgwip = null; - $count = 0; - - foreach ($gateways_arr as $gwname => $gwsttng) { - if (isset($gwsttng['disabled'])) { - /* does not apply */ - continue; - } - if ($gwsttng['ipprotocol'] !== $ipprotocol) { - /* wrong address family */ - continue; - } - if (strpos($gateways_status[$gwname]['status'], 'down') !== false) { - /* cannot use down gateway */ - continue; - } - - $gwip = ''; - - if ($gateways_arr[$gwname]['gateway'] == "dynamic") { - if ($ipprotocol == 'inet') { - $gwip = get_interface_gateway($gateways_arr[$gwname]['friendlyiface']); - } else { - $gwip = get_interface_gateway_v6($gateways_arr[$gwname]['friendlyiface']); - } - } else { - $gwip = $gateways_arr[$gwname]['gateway']; - } - - if (!is_ipaddr($gwip)) { - log_error("Cannot switch gateway $gwname with undefined address"); - continue; - } - - /* can use this gateway */ - $dfltgwname = $gwname; - $dfltgwip = $gwip; - $count += 1; - - if (isset($gwsttng['defaultgw'])) { - /* if we found the default to be working use it right away */ - break; - } - } - - if (empty($dfltgwname)) { - log_error("Cannot switch while $count $ipprotocol gateways are up"); - continue; - } - - system_default_route($dfltgwip, $ipprotocol, $gateways_arr[$dfltgwname]['friendlyiface'], isset($gateways_arr[$dfltgwname]['fargw'])); - } -} /* * Return an array with all gateway groups with name as key diff --git a/src/www/system_general.php b/src/www/system_general.php index 08138836b..5e1bfad4f 100644 --- a/src/www/system_general.php +++ b/src/www/system_general.php @@ -52,8 +52,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $pconfig['timezone'] = empty($config['system']['timezone']) ? 'Etc/UTC' : $config['system']['timezone']; $pconfig['gw_switch_default'] = isset($config['system']['gw_switch_default']); - $pconfig['gw_switch_group4'] = isset($config['system']['gw_switch_group4']) ? $config['system']['gw_switch_group4'] : null; - $pconfig['gw_switch_group6'] = isset($config['system']['gw_switch_group6']) ? $config['system']['gw_switch_group6'] : null; for ($dnscounter = 1; $dnscounter < 9; $dnscounter++) { $dnsname = "dns{$dnscounter}"; @@ -160,18 +158,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { unset($config['system']['gw_switch_default']); } - if (!empty($pconfig['gw_switch_group4'])) { - $config['system']['gw_switch_group4'] = $pconfig['gw_switch_group4']; - } elseif (isset($config['system']['gw_switch_group4'])) { - unset($config['system']['gw_switch_group4']); - } - - if (!empty($pconfig['gw_switch_group6'])) { - $config['system']['gw_switch_group6'] = $pconfig['gw_switch_group6']; - } elseif (isset($config['system']['gw_switch_group6'])) { - unset($config['system']['gw_switch_group6']); - } - $olddnsservers = $config['system']['dnsserver']; $config['system']['dnsserver'] = array(); @@ -453,28 +439,6 @@ include("head.inc"); -