Skip to content

Commit

Permalink
system: add system_host_route(), later we also want system_default_ro…
Browse files Browse the repository at this point in the history
…ute()
  • Loading branch information
fichtner committed May 31, 2017
1 parent 2a2bca9 commit 611d972
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
10 changes: 1 addition & 9 deletions src/etc/inc/interfaces.inc
Original file line number Diff line number Diff line change
Expand Up @@ -985,15 +985,7 @@ function interface_gif_configure(&$gif, $gifkey = "")
file_put_contents("/tmp/{$gifif}_routerv6", $gif['tunnel-remote-addr']);
}

if (is_ipaddrv4($realifgw)) {
mwexec("/sbin/route delete -host " . escapeshellarg($gif['remote-addr']));
mwexec("/sbin/route add -host " . escapeshellarg($gif['remote-addr']) . " {$realifgw}");
}
if (is_ipaddrv6($realifgw)) {
mwexec("/sbin/route delete -host -inet6 " . escapeshellarg($gif['remote-addr']));
mwexec("/sbin/route add -host -inet6 " . escapeshellarg($gif['remote-addr']) . " {$realifgw}");
}

system_host_route($gif['remote-addr'], $realifgw);
interfaces_bring_up($gifif);

return $gifif;
Expand Down
14 changes: 14 additions & 0 deletions src/etc/inc/system.inc
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,20 @@ function system_hostname_configure($verbose = false)
}
}

function system_host_route($host, $gateway)
{
if (is_ipaddrv4($realifgw)) {
$family = 'inet';
} elseif (is_ipaddrv6($realifgw)) {
$family = 'inet6';
} else {
return;
}

mwexecf('/sbin/route delete -host -%s %s', array($family, $host), true);
mwexecf('/sbin/route add -host -%s %s %s', array($family, $host, $gateway));
}

function system_routing_configure($interface = '', $verbose = false)
{
global $config;
Expand Down

0 comments on commit 611d972

Please sign in to comment.