Skip to content

Commit

Permalink
interfaces: skip rtsold in case required by ISP for #637
Browse files Browse the repository at this point in the history
  • Loading branch information
fichtner committed Jul 16, 2016
1 parent b1161df commit e2998ac
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 23 deletions.
53 changes: 30 additions & 23 deletions src/etc/inc/interfaces.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3419,7 +3419,7 @@ function interface_dhcpv6_configure($interface = 'wan', $wancfg)
$dhcp6cscript = "#!/bin/sh\n";
$dhcp6cscript .= "# This shell script launches /usr/local/etc/rc.newwanipv6 with a interface argument.\n";
$dhcp6cscript .= "/usr/local/etc/rc.newwanipv6 {$wanif} \n";
/* Add wide-dhcp6c shell script here. Because we can not pass a argument to it. */

if (!@file_put_contents("/var/etc/dhcp6c_{$interface}_script.sh", $dhcp6cscript)) {
printf("Error: cannot open dhcp6c_{$interface}_script.sh in interface_dhcpv6_configure() for writing.\n");
unset($dhcp6cscript);
Expand All @@ -3428,6 +3428,16 @@ function interface_dhcpv6_configure($interface = 'wan', $wancfg)
unset($dhcp6cscript);
chmod("/var/etc/dhcp6c_{$interface}_script.sh", 0755);

$dhcp6ccommand = exec_safe(
"/usr/local/sbin/dhcp6c %s -c %s -p %s %s",
array(
empty($wancfg['adv_dhcp6_debug']) ? '-d' : '-D',
"/var/etc/dhcp6c_{$interface}.conf",
"/var/run/dhcp6c_{$wanif}.pid",
"{$wanif}"
)
);

$rtsoldscript = "#!/bin/sh\n";
$rtsoldscript .= "# This shell script launches dhcp6c and configured gateways for this interface.\n";
$rtsoldscript .= "echo $2 > /tmp/{$wanif}_routerv6\n";
Expand All @@ -3436,10 +3446,9 @@ function interface_dhcpv6_configure($interface = 'wan', $wancfg)
$rtsoldscript .= "\t/bin/pkill -F /var/run/dhcp6c_{$wanif}.pid\n";
$rtsoldscript .= "\t/bin/sleep 1\n";
$rtsoldscript .= "fi\n";
$rtsoldscript .= "/usr/local/sbin/dhcp6c " . (empty($wancfg['adv_dhcp6_debug']) ? '-d' : '-D') ;
$rtsoldscript .= " -c /var/etc/dhcp6c_{$interface}.conf -p /var/run/dhcp6c_{$wanif}.pid {$wanif}\n";
$rtsoldscript .= "/usr/bin/logger -t rtsold \"Starting dhcp6 client for interface {$interface}({$wanif})\"\n";
/* Add wide-dhcp6c shell script here. Because we can not pass a argument to it. */
$rtsoldscript .= "$dhcp6ccommand\n";

if (!@file_put_contents("/var/etc/rtsold_{$wanif}_script.sh", $rtsoldscript)) {
printf("Error: cannot open rtsold_{$wanif}_script.sh in interface_dhcpv6_configure() for writing.\n");
unset($rtsoldscript);
Expand All @@ -3456,26 +3465,24 @@ function interface_dhcpv6_configure($interface = 'wan', $wancfg)
/* Enable RFC6204w support for IPv6 Customer Edge (CE) router */
set_single_sysctl("net.inet6.ip6.rfc6204w3", "1");

/* fire up rtsold for IPv6 RAs first, this backgrounds immediately. It will call dhcp6c */
if (isvalidpid("/var/run/rtsold_{$wanif}.pid")) {
killbypid("/var/run/rtsold_{$wanif}.pid");
sleep(2);
}

mwexecf(
'/usr/sbin/rtsold -p %s -O %s -R %s %s %s',
array(
"/var/run/rtsold_{$wanif}.pid",
"/var/etc/rtsold_{$wanif}_script.sh",
'/usr/bin/true', /* XXX missing proper script to refresh resolv.conf */
empty($wancfg['adv_dhcp6_debug']) ? '-d' : '-D',
$wanif
)
);
killbypid("/var/run/rtsold_{$wanif}.pid", 'TERM', true);

/* NOTE: will be called from rtsold invoked script
* link_interface_to_track6($interface, "update");
*/
if (isset($wancfg['dhcp6sendsolicit'])) {
/* command is already exec_safe() */
mwexec($dhcp6ccommand);
} else {
/* fire up rtsold for IPv6 RAs first, this backgrounds immediately. It will call dhcp6c */
mwexecf(
'/usr/sbin/rtsold -p %s -O %s -R %s %s %s',
array(
"/var/run/rtsold_{$wanif}.pid",
"/var/etc/rtsold_{$wanif}_script.sh",
'/usr/bin/true', /* XXX missing proper script to refresh resolv.conf */
empty($wancfg['adv_dhcp6_debug']) ? '-d' : '-D',
$wanif
)
);
}

return 0;
}
Expand Down
13 changes: 13 additions & 0 deletions src/www/interfaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ function get_wireless_channel_info($interface) {
$pconfig['blockpriv'] = isset($a_interfaces[$if]['blockpriv']);
$pconfig['blockbogons'] = isset($a_interfaces[$if]['blockbogons']);
$pconfig['dhcp6-ia-pd-send-hint'] = isset($a_interfaces[$if]['dhcp6-ia-pd-send-hint']);
$pconfig['dhcp6sendsolicit'] = isset($a_interfaces[$if]['dhcp6sendsolicit']);
$pconfig['dhcp6prefixonly'] = isset($a_interfaces[$if]['dhcp6prefixonly']);
$pconfig['dhcp6usev4iface'] = isset($a_interfaces[$if]['dhcp6usev4iface']);
$pconfig['adv_dhcp6_debug'] = isset($a_interfaces[$if]['adv_dhcp6_debug']);
Expand Down Expand Up @@ -1060,6 +1061,9 @@ interface_sync_wireless_clones($a_interfaces[$if], false);
if (!empty($pconfig['dhcp6prefixonly'])) {
$new_config['dhcp6prefixonly'] = true;
}
if (!empty($pconfig['dhcp6sendsolicit'])) {
$new_config['dhcp6sendsolicit'] = true;
}
if (!empty($pconfig['dhcp6usev4iface'])) {
$new_config['dhcp6usev4iface'] = true;
}
Expand Down Expand Up @@ -2460,6 +2464,15 @@ function toggle_allcfg() {
</div>
</td>
</tr>
<tr class="dhcpv6_basic">
<td><a id="help_for_dhcp6sendsolicit" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('Directly send SOLICIT'); ?></td>
<td>
<input name="dhcp6sendsolicit" type="checkbox" id="dhcp6sendsolicit" value="yes" <?= !empty($pconfig['dhcp6sendsolicit']) ? 'checked="checked"' : '' ?>/>
<div class="hidden" for="help_for_dhcp6sendsolicit">
<?= gettext('In case the ISP requires a SOLICIT message for authentication, select this option to prevent indefinite waiting for a router advertisement.') ?>
</div>
</td>
</tr>
<tr class="dhcpv6_basic">
<td><a id="help_for_dhcp6-ia-pd-len" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("DHCPv6 Prefix Delegation size"); ?></td>
<td>
Expand Down

0 comments on commit e2998ac

Please sign in to comment.