system: iterate over gateways without $config access

Positive side-effect is we don't have to sanity-check access
anymore.
This commit is contained in:
Franco Fichtner 2018-09-12 08:59:06 +02:00
parent baa43590d7
commit 21d3ff051f

View File

@ -464,8 +464,6 @@ function system_default_route($gateway, $family, $interface, $far = false)
function system_routing_configure($verbose = false, $interface = '')
{
global $config;
if ($verbose) {
echo 'Setting up routes...';
flush();
@ -486,31 +484,29 @@ function system_routing_configure($verbose = false, $interface = '')
log_error("ROUTING: entering configure using defaults");
}
if (isset($config['gateways']['gateway_item'])) {
foreach ($config['gateways']['gateway_item'] as $gateway) {
if (isset($gateway['defaultgw'])) {
if ($foundgw == false && $gateway['ipprotocol'] != 'inet6') {
if ($gateway['gateway'] == 'dynamic') {
$gateway['gateway'] = get_interface_gateway($gateway['interface']);
}
$interfacegw = $gateway['interface'];
$fargw = isset($gateway['fargw']);
$gatewayip = $gateway['gateway'];
$foundgw = true;
log_error("ROUTING: IPv4 default gateway set to {$interfacegw}");
} elseif ($foundgwv6 == false && $gateway['ipprotocol'] == 'inet6') {
if ($gateway['gateway'] == 'dynamic') {
$gateway['gateway'] = get_interface_gateway_v6($gateway['interface']);
}
$interfacegwv6 = $gateway['interface'];
$gatewayipv6 = $gateway['gateway'];
$foundgwv6 = true;
log_error("ROUTING: IPv6 default gateway set to {$interfacegwv6}");
foreach (config_read_array('gateways', 'gateway_item') as $gateway) {
if (isset($gateway['defaultgw'])) {
if ($foundgw == false && $gateway['ipprotocol'] != 'inet6') {
if ($gateway['gateway'] == 'dynamic') {
$gateway['gateway'] = get_interface_gateway($gateway['interface']);
}
$interfacegw = $gateway['interface'];
$fargw = isset($gateway['fargw']);
$gatewayip = $gateway['gateway'];
$foundgw = true;
log_error("ROUTING: IPv4 default gateway set to {$interfacegw}");
} elseif ($foundgwv6 == false && $gateway['ipprotocol'] == 'inet6') {
if ($gateway['gateway'] == 'dynamic') {
$gateway['gateway'] = get_interface_gateway_v6($gateway['interface']);
}
$interfacegwv6 = $gateway['interface'];
$gatewayipv6 = $gateway['gateway'];
$foundgwv6 = true;
log_error("ROUTING: IPv6 default gateway set to {$interfacegwv6}");
}
}
}