dhcp: kill "static" mode, move flags to advanced #5185

While technically not correct to make flags "AdvDeprecatePrefix"
and "AdvRemoveRoute" we simply use it to overwrite the existing
defaults which depend on CARP-or-not situation in the address
being used.

There was an extensive discussion about what it should and should
not do but the only way to keep the current defaults AND provide
requested overrides is this one.

The valid values are either "off" or "on", but no validation
takes place as customary to this page's advanced options. Use
with care.
This commit is contained in:
Franco Fichtner 2022-01-17 16:11:47 +01:00
parent 21fe4db493
commit a94c63b2b7
2 changed files with 17 additions and 19 deletions

View File

@ -1,7 +1,7 @@
<?php
/*
* Copyright (C) 2014-2021 Franco Fichtner <franco@opnsense.org>
* Copyright (C) 2014-2022 Franco Fichtner <franco@opnsense.org>
* Copyright (C) 2010 Ermal Luçi
* Copyright (C) 2005-2006 Colin Smith <ethethlay@gmail.com>
* Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>
@ -352,7 +352,7 @@ function dhcpd_radvd_configure($verbose = false, $blacklist = array())
foreach ($stanzas as $stanza) {
$radvdconf .= "\tprefix {$stanza} {\n";
$radvdconf .= "\t\tDeprecatePrefix " . ($carp_mode || !empty($dhcpv6ifconf['rastatic']) ? "off" : "on") . ";\n";
$radvdconf .= "\t\tDeprecatePrefix " . (!empty($dhcpv6ifconf['AdvDeprecatePrefix']) ? $dhcpv6ifconf['AdvDeprecatePrefix'] : ($carp_mode ? 'off' : 'on')) . ";\n";
switch ($dhcpv6ifconf['ramode']) {
case 'managed':
$radvdconf .= "\t\tAdvOnLink on;\n";
@ -383,9 +383,7 @@ function dhcpd_radvd_configure($verbose = false, $blacklist = array())
if (!empty($dhcpv6ifconf['raroutes'])) {
foreach (explode(',', $dhcpv6ifconf['raroutes']) as $raroute) {
$radvdconf .= "\troute {$raroute} {\n";
if ($carp_mode || !empty($dhcpv6ifconf['rastatic'])) {
$radvdconf .= "\t\tRemoveRoute off;\n";
}
$radvdconf .= "\t\tRemoveRoute " . (!empty($dhcpv6ifconf['AdvRemoveRoute']) ? $dhcpv6ifconf['AdvRemoveRoute'] : ($carp_mode ? 'off' : 'on')) . ";\n";
if (!empty($dhcpv6ifconf['AdvRouteLifetime'])) {
$radvdconf .= "\t\tAdvRouteLifetime {$dhcpv6ifconf['AdvRouteLifetime']};\n";
}

View File

@ -1,7 +1,7 @@
<?php
/*
* Copyright (C) 2016-2021 Franco Fichtner <franco@opnsense.org>
* Copyright (C) 2016-2022 Franco Fichtner <franco@opnsense.org>
* Copyright (C) 2014-2016 Deciso B.V.
* Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>
* Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>
@ -37,7 +37,18 @@ function val_int_in_range($value, $min, $max) {
return (((string)(int)$value) == $value) && $value >= $min && $value <= $max;
}
$advanced_options = array('AdvDefaultLifetime', 'AdvValidLifetime', 'AdvPreferredLifetime', 'AdvRDNSSLifetime', 'AdvDNSSLLifetime', 'AdvRouteLifetime', 'AdvLinkMTU');
$advanced_options = [
'AdvDefaultLifetime',
'AdvValidLifetime',
'AdvPreferredLifetime',
'AdvRDNSSLifetime',
'AdvDNSSLLifetime',
'AdvRouteLifetime',
'AdvLinkMTU',
'AdvDeprecatePrefix',
'AdvRemoveRoute',
];
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (!empty($_GET['if']) && !empty($config['interfaces'][$_GET['if']])) {
$if = $_GET['if'];
@ -62,7 +73,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig['rasamednsasdhcp6'] = isset($config['dhcpdv6'][$if]['rasamednsasdhcp6']);
$pconfig['radisablerdnss'] = isset($config['dhcpdv6'][$if]['radisablerdnss']);
$pconfig['radefault'] = empty($config['dhcpdv6'][$if]['ranodefault']) ? true : null;
$pconfig['rastatic'] = !empty($config['dhcpdv6'][$if]['rastatic']);
// defaults
if (empty($pconfig['ramininterval'])) {
@ -179,7 +189,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
$config['dhcpdv6'][$if]['rasamednsasdhcp6'] = !empty($pconfig['rasamednsasdhcp6']);
$config['dhcpdv6'][$if]['radisablerdnss'] = !empty($pconfig['radisablerdnss']);
$config['dhcpdv6'][$if]['rastatic'] = !empty($pconfig['rastatic']);
if (count($pconfig['raroutes'])) {
$config['dhcpdv6'][$if]['raroutes'] = implode(',', $pconfig['raroutes']);
@ -336,16 +345,7 @@ include("head.inc");
<?php endforeach ?>
</select>
<div class="hidden" data-for="help_for_rainterface">
<?= gettext('Select the source address embedded in the RA messages. If a CARP address is used static mode is assumed.') ?>
</div>
</td>
</tr>
<tr>
<td><a id="help_for_rastatic" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?= gettext('Static Mode') ?></td>
<td>
<input id="rastatic" name="rastatic" type="checkbox" value="yes" <?= !empty($pconfig['rastatic']) ? 'checked="checked"' : '' ?>/>
<div class="hidden" data-for="help_for_rastatic">
<?= gettext('When a CARP address is not configured using the source address setting the adverisement behaviour can still be made static with this option.') ?>
<?= gettext('Select the source address embedded in the RA messages. If a CARP address is used DeprecatePrefix and RemoveRoute are both set to "off" by default.') ?>
</div>
</td>
</tr>