Commit 294c3801 authored by Franco Fichtner's avatar Franco Fichtner

system: set up a helper route through interface for far gateways

This finally concludes work on #880, left on -devel for a while
longer to double-check with the requesters.
parent b4329c84
......@@ -672,7 +672,7 @@ function system_staticroutes_configure($interface = '', $update_dns = false)
}
$gatewayip = $gateway['gateway'];
$needs_iface = isset($gateway['fargw']);
$fargw = isset($gateway['fargw']);
$interfacegw = $gateway['interface'];
$blackhole = "";
......@@ -726,12 +726,15 @@ function system_staticroutes_configure($interface = '', $update_dns = false)
$ip .= "/128";
}
$inet = (is_subnetv6($ip) ? "-inet6" : "-inet");
$iface = $needs_iface ? ' -interface ' . escapeshellarg($interfacegw) . ' ' : '';
$cmd = " {$inet} {$blackhole} " . escapeshellarg($ip) . " ";
if (is_subnet($ip)) {
if (is_ipaddr($gatewayip)) {
mwexec("/sbin/route delete".$cmd . escapeshellarg($gatewayip) . $iface);
mwexec("/sbin/route add".$cmd . escapeshellarg($gatewayip) . $iface);
mwexec("/sbin/route delete".$cmd . escapeshellarg($gatewayip));
if ($fargw) {
mwexecf('/sbin/route delete %s %s -interface %s', array($inet, $ip, $interfacegw));
mwexecf('/sbin/route add %s %s -interface %s', array($inet, $ip, $interfacegw));
}
mwexec("/sbin/route add".$cmd . escapeshellarg($gatewayip));
} elseif (!empty($interfacegw)) {
mwexec("/sbin/route delete".$cmd . "-interface " . escapeshellarg($interfacegw));
mwexec("/sbin/route add".$cmd . "-interface " . escapeshellarg($interfacegw));
......
......@@ -645,8 +645,7 @@ $( document ).ready(function() {
<td>
<input name="fargw" type="checkbox" value="yes" <?=!empty($pconfig['fargw']) ? 'checked="checked"' : '';?> />
<div class="hidden" for="help_for_fargw">
<?=gettext("This will allow the gateway to exist outside of the interface subnet. " .
"A corresponding route must bet set up for this gateway in order for it to operate correctly."); ?>
<?=gettext("This will allow the gateway to exist outside of the interface subnet."); ?>
</div>
</td>
</tr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment