interfaces: bring back special IPv6 vars

This commit is contained in:
Franco Fichtner 2020-05-06 16:54:58 +02:00
parent 732e4b3388
commit d87ce014d9
2 changed files with 52 additions and 11 deletions

View file

@ -2897,11 +2897,11 @@ function interface_6to4_configure($interface = 'wan', $wancfg)
function interface_dhcpv6_configure($interface = 'wan', $wancfg)
{
global $config;
$syscfg = config_read_array('system');
/* write DUID if override was set */
if (!empty($config['system']['ipv6duid'])) {
dhcp6c_duid_write($config['system']['ipv6duid']);
if (!empty($syscfg['ipv6duid'])) {
dhcp6c_duid_write($syscfg['ipv6duid']);
/* clear DUID if it is faulty */
} elseif (empty(dhcp6c_duid_read())) {
dhcp6c_duid_clear();
@ -2931,7 +2931,7 @@ function interface_dhcpv6_configure($interface = 'wan', $wancfg)
"/var/run/rtsold_{$realifv6}.pid",
'/var/etc/rtsold_script.sh',
'/usr/bin/true', /* XXX missing proper script to refresh resolv.conf */
empty($wancfg['adv_dhcp6_debug']) ? '-d' : '-D',
empty($syscfg['dhcp6_debug']) ? '-d' : '-D',
$realifv6
)
);
@ -2970,6 +2970,7 @@ function interface_dhcpv6_prepare($interface = 'wan', $wancfg)
$wanif = get_real_interface($interface, 'inet6');
$id = interface_dhcpv6_id($interface);
$syscfg = config_read_array('system');
$dhcp6cconf = DHCP6_Config_File_Basic($interface, $wancfg, $wanif, $id);
@ -2992,11 +2993,11 @@ function interface_dhcpv6_prepare($interface = 'wan', $wancfg)
@file_put_contents("/var/etc/dhcp6c_{$interface}.conf", $dhcp6cconf);
$dhcp6cscript = "#!/bin/sh\n";
$dhcp6cscript .= "if [ -n '" . (!empty($wancfg['adv_dhcp6_debug']) ? 'debug' : '') . "' ]; then\n";
$dhcp6cscript .= "if [ -n '" . (!empty($syscfg['dhcp6_debug']) ? 'debug' : '') . "' ]; then\n";
$dhcp6cscript .= "\t/usr/bin/logger -t dhcp6c \"dhcp6c \$REASON on {$wanif}\"\n";
$dhcp6cscript .= "fi\n";
$dhcp6cscript .= "case \$REASON in\n";
$dhcp6cscript .= "REQUEST|" . (!empty($wancfg['dhcp6norelease']) ? 'EXIT' : 'RELEASE') . ")\n";
$dhcp6cscript .= "REQUEST|" . (!empty($syscfg['dhcp6_norelease']) ? 'EXIT' : 'RELEASE') . ")\n";
$dhcp6cscript .= "\t/usr/bin/logger -t dhcp6c \"dhcp6c \$REASON on {$wanif} - running newipv6\"\n";
$dhcp6cscript .= "\t/usr/local/opnsense/service/configd_ctl.py interface newipv6 {$wanif}\n";
$dhcp6cscript .= "\t;;\n";
@ -3010,7 +3011,7 @@ function interface_dhcpv6_prepare($interface = 'wan', $wancfg)
$dhcp6ccommand = exec_safe(
"/usr/local/sbin/dhcp6c %s -c %s -p %s %s",
array(
'-' . (empty($wancfg['adv_dhcp6_debug']) ? 'd' : 'D' ) . (!empty($wancfg['dhcp6norelease']) ? 'n' : ''),
'-' . (empty($syscfg['dhcp6_debug']) ? 'd' : 'D' ) . (!empty($syscfg['dhcp6_norelease']) ? 'n' : ''),
"/var/etc/dhcp6c_{$interface}.conf",
"/var/run/dhcp6c_{$wanif}.pid",
"{$wanif}"

View file

@ -174,6 +174,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig['disablechecksumoffloading'] = isset($config['system']['disablechecksumoffloading']);
$pconfig['disablesegmentationoffloading'] = isset($config['system']['disablesegmentationoffloading']);
$pconfig['disablelargereceiveoffloading'] = isset($config['system']['disablelargereceiveoffloading']);
$pconfig['dhcp6_norelease'] = isset($config['system']['dhcp6_norelease']);
$pconfig['dhcp6_debug'] = isset($config['system']['dhcp6_debug']);
$pconfig['ipv6duid'] = $config['system']['ipv6duid'];
if (!isset($config['system']['disablevlanhwfilter'])) {
$pconfig['disablevlanhwfilter'] = '0';
@ -224,6 +226,18 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
unset($config['system']['disablevlanhwfilter']);
}
if (!empty($pconfig['dhcp6_norelease'])) {
$config['system']['dhcp6_norelease'] = $pconfig['dhcp6_norelease'];
} elseif (isset($config['system']['dhcp6_norelease'])) {
unset($config['system']['dhcp6_norelease']);
}
if (!empty($pconfig['dhcp6_debug'])) {
$config['system']['dhcp6_debug'] = $pconfig['dhcp6_debug'];
} elseif (isset($config['system']['dhcp6_debug'])) {
unset($config['system']['dhcp6_debug']);
}
if (!empty($pconfig['ipv6duid'])) {
$config['system']['ipv6duid'] = format_duid($pconfig['ipv6duid']);
} elseif (isset($config['system']['ipv6duid'])) {
@ -260,8 +274,8 @@ include("head.inc");
}
?>
<section class="col-xs-12">
<div class="content-box tab-content table-responsive">
<form method="post" name="iform" id="iform">
<form method="post" name="iform" id="iform">
<div class="content-box tab-content table-responsive __mb">
<table class="table table-striped opnsense_standard_table_form">
<tr>
<td style="width:22%"><strong><?= gettext('Network Interfaces') ?></strong></td>
@ -329,6 +343,32 @@ include("head.inc");
</div>
</td>
</tr>
</table>
</div>
<div class="content-box tab-content table-responsive __mb">
<table class="table table-striped opnsense_standard_table_form">
<tr>
<td style="width:22%"><strong><?= gettext('IPv6 DHCP') ?></strong></td>
<td style="width:78%"></td>
</tr>
<tr>
<td><a id="help_for_dhcp6_norelease" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?= gettext('Prevent release') ?></td>
<td>
<input name="dhcp6_norelease" type="checkbox" id="dhcp6_norelease" value="yes" <?= !empty($pconfig['dhcp6_norelease']) ? 'checked="checked"' : '' ?> />
<div class="hidden" data-for="help_for_dhcp6_norelease">
<?= gettext('Do not send a release message on client exit to prevent the release of an allocated address or prefix on the server.') ?>
</div>
</td>
</tr>
<tr>
<td><a id="help_for_dhcp6_debug" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?= gettext('Enable debug'); ?></td>
<td>
<input name="dhcp6_debug" type="checkbox" id="dhcp6_debug" value="yes" <?= !empty($pconfig['dhcp6_debug']) ? 'checked="checked"' : '' ?> />
<div class="hidden" data-for="help_for_dhcp6_debug">
<?= gettext('Enable debug mode for DHCPv6 client') ?>
</div>
</td>
</tr>
<tr>
<td><a id="help_for_persistent_duid" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("DHCP Unique Identifier"); ?></td>
<td>
@ -364,8 +404,8 @@ include("head.inc");
</td>
</tr>
</table>
</form>
</div>
</div>
</form>
</section>
</div>
</div>