Just set defaultgw after all gateways are processed, it fixes return_gateways_array()

This commit is contained in:
Renato Botelho 2013-02-27 12:47:03 -03:00
parent 5b0e0182c7
commit 08c3810ceb

View File

@ -455,24 +455,6 @@ function return_gateways_array($disabled = false, $localhost = false) {
$found_defaultv6 = 1;
}
}
/* FIXME: Should this be enabled.
* Some interface like wan might be default but have no info recorded
* the config. */
/* this is a fallback if all else fails and we want to get packets out @smos */
if (!isset($gateway['defaultgw'])) {
if (($gateway['friendlyiface'] == "wan") && ($found_defaultv4 == 0) && (!isset($gateway['ipprotocol']) || ($gateway['ipprotocol'] == "inet"))) {
if (file_exists("{$g['tmp_path']}/{$gateway['interface']}_defaultgw")) {
$gateway['defaultgw'] = true;
$found_defaultv4 = 1;
}
}
if (($gateway['friendlyiface'] == "wan") && ($found_defaultv6 == 0) && ($gateway['ipprotocol'] == "inet6")) {
if (file_exists("{$g['tmp_path']}/{$gateway['interface']}_defaultgwv6")) {
$gateway['defaultgw'] = true;
$found_defaultv6 = 1;
}
}
}
/* include the gateway index as the attribute */
$gateway['attribute'] = $i;
@ -644,6 +626,27 @@ function return_gateways_array($disabled = false, $localhost = false) {
unset($gateway);
}
/* FIXME: Should this be enabled.
* Some interface like wan might be default but have no info recorded
* the config. */
/* this is a fallback if all else fails and we want to get packets out @smos */
if ($found_defaultv4 == 0 || $found_defaultv6 == 0) {
foreach ($gateways_arr as &$gateway) {
if (($gateway['friendlyiface'] == "wan") && ($found_defaultv4 == 0) && (!isset($gateway['ipprotocol']) || ($gateway['ipprotocol'] == "inet"))) {
if (file_exists("{$g['tmp_path']}/{$gateway['interface']}_defaultgw")) {
$gateway['defaultgw'] = true;
$found_defaultv4 = 1;
}
}
if (($gateway['friendlyiface'] == "wan") && ($found_defaultv6 == 0) && ($gateway['ipprotocol'] == "inet6")) {
if (file_exists("{$g['tmp_path']}/{$gateway['interface']}_defaultgwv6")) {
$gateway['defaultgw'] = true;
$found_defaultv6 = 1;
}
}
}
}
if($localhost === true) {
/* attach localhost for Null routes */
$gwlo4 = array();