mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 16:44:39 +00:00
system: detect far gateway situation for #5493
The far gateway flag has some benefits for configuration runs and validation purposes on the GUI but in the end after lots of reworks we are able to reliably get a network from the interface to put the default route on so that we can detect if we are in need of a far gateway or not. This is required for automatic gateways on DHCP that hand out these situations while the gateway code should not be in charge of flipping on the fargw bit as it does pertain to runtime interface configuration. Leave the fargw configuration flag in place for now to let people test this, maybe backport it earlier and look at fargw more closely in the remaining use case(s).
This commit is contained in:
parent
a9a67b4255
commit
9cf2b221d8
@ -325,12 +325,7 @@ function filter_configure_sync($verbose = false, $load_aliases = true)
|
||||
}
|
||||
$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'])
|
||||
);
|
||||
system_default_route($default_gw['gateway'], $ipprotocol, $default_gw['if']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -449,7 +449,7 @@ function system_host_route($host, $gateway, $delete = true, $add = true)
|
||||
}
|
||||
}
|
||||
|
||||
function system_default_route($gateway, $family, $interface, $far = false)
|
||||
function system_default_route($gateway, $family, $interface)
|
||||
{
|
||||
$realif = get_real_interface($interface, $family == 'inet' ? 'all' : 'inet6');
|
||||
|
||||
@ -482,8 +482,11 @@ function system_default_route($gateway, $family, $interface, $far = false)
|
||||
log_error("ROUTING: creating /tmp/{$realif}_defaultgw using '{$gateway}'");
|
||||
@file_put_contents("/tmp/{$realif}_defaultgw", $gateway);
|
||||
|
||||
if (!$far) {
|
||||
list ($unused, $network) = interfaces_primary_address($interface);
|
||||
if (ip_in_subnet($gateway, $network)) {
|
||||
$realif = null;
|
||||
} else {
|
||||
log_error("ROUTING: treating gateway '{$gateway}' as far gateway");
|
||||
}
|
||||
} else {
|
||||
foreach (glob('/tmp/*_defaultgwv6') as $to_delete) {
|
||||
@ -529,7 +532,7 @@ function system_routing_configure($verbose = false, $interface = '')
|
||||
log_error("ROUTING: {$logproto} default gateway set to {$gateway['interface']}");
|
||||
if ((empty($interface) || $interface == $gateway['interface']) && !empty($gateway['gateway'])) {
|
||||
log_error("ROUTING: setting {$logproto} default route to {$gateway['gateway']}");
|
||||
system_default_route($gateway['gateway'], $ipproto, $gateway['interface'], isset($gateway['fargw']));
|
||||
system_default_route($gateway['gateway'], $ipproto, $gateway['interface']);
|
||||
} else {
|
||||
log_error("ROUTING: skipping {$logproto} default route");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user