mirror of
https://github.com/opnsense/plugins.git
synced 2026-02-03 20:40:37 -05:00
net/isc-dhcp: support idassoc6 mode correctly
Slightly simplify the previous code conditions since the new GUI code does auto-track6 separately now and both modes have 'track6-interface' set. PR: https://forum.opnsense.org/index.php?topic=50474.msg257718#msg257718
This commit is contained in:
parent
2b44156267
commit
276b8ecdc5
4 changed files with 26 additions and 19 deletions
|
|
@ -1,6 +1,6 @@
|
|||
PLUGIN_NAME= isc-dhcp
|
||||
PLUGIN_VERSION= 1.0
|
||||
PLUGIN_REVISION= 1
|
||||
PLUGIN_REVISION= 2
|
||||
PLUGIN_COMMENT= ISC DHCPv4/v6 server
|
||||
PLUGIN_DEPENDS= isc-dhcp44-server
|
||||
PLUGIN_MAINTAINER= franco@opnsense.org
|
||||
|
|
|
|||
|
|
@ -13,5 +13,5 @@ Plugin Changelog
|
|||
|
||||
* First release resembling the core state of 25.7.11
|
||||
* Minor changes due to "radvd" extraction out of DHCPv6 configuration
|
||||
* Minor changes regarding "track6" mode handling
|
||||
* Minor changes regarding "track6" and "idassoc6" mode handling
|
||||
* Added DHCPv6 static mappings export
|
||||
|
|
|
|||
|
|
@ -886,7 +886,7 @@ function dhcpd_dhcp6_configure($verbose = false, $ignorelist = [])
|
|||
if (isset($ignorelist[$ifname])) {
|
||||
continue;
|
||||
}
|
||||
if (($config['interfaces'][$ifname]['ipaddrv6'] ?? 'none') == 'track6') {
|
||||
if (isset($config['interfaces'][$ifname]['track6-interface'])) {
|
||||
list ($ifcfgipv6) = interfaces_primary_address6($ifname, $ifconfig_details);
|
||||
if (!is_ipaddrv6($ifcfgipv6)) {
|
||||
continue;
|
||||
|
|
@ -895,7 +895,10 @@ function dhcpd_dhcp6_configure($verbose = false, $ignorelist = [])
|
|||
$ifcfgipv6 = Net_IPv6::getNetmask($ifcfgipv6, 64);
|
||||
$ifcfgipv6arr = explode(':', $ifcfgipv6);
|
||||
|
||||
if (!isset($config['interfaces'][$ifname]['dhcpd6track6allowoverride'])) {
|
||||
if (
|
||||
($config['interfaces'][$ifname]['ipaddrv6'] ?? 'none') == 'track6' &&
|
||||
!isset($config['interfaces'][$ifname]['dhcpd6track6allowoverride'])
|
||||
) {
|
||||
/* mock a real server */
|
||||
if (!empty($dhcpdv6cfg[$ifname]['enable']) && $dhcpdv6cfg[$ifname]['enable'] == '-1') {
|
||||
/* tracking, but dhcpv6 disabled */
|
||||
|
|
@ -1132,7 +1135,7 @@ host s_{$dhcpv6if}_{$i} {
|
|||
|
||||
EOD;
|
||||
if (!empty($sm['ipaddrv6'])) {
|
||||
if (isset($config['interfaces'][$dhcpv6if]['dhcpd6track6allowoverride'])) {
|
||||
if (isset($config['interfaces'][$dhcpv6if]['track6-interface'])) {
|
||||
$sm['ipaddrv6'] = merge_ipv6_address($ifcfgipv6, $sm['ipaddrv6']);
|
||||
}
|
||||
$dhcpdv6conf .= " fixed-address6 {$sm['ipaddrv6']};\n";
|
||||
|
|
@ -1209,7 +1212,7 @@ function dhcpd_staticmap($proto = null, $valid_addresses = true, $ifconfig_detai
|
|||
}
|
||||
|
||||
$ifconf = config_read_array('interfaces', $dhcpif);
|
||||
list ($ipaddrv6) = $inet == 6 && isset($ifconf['dhcpd6track6allowoverride']) ?
|
||||
list ($ipaddrv6) = $inet == 6 && isset($ifconf['track6-interface']) ?
|
||||
interfaces_primary_address6($dhcpif, $ifconfig_details) : [null];
|
||||
|
||||
foreach ($dhcpifconf['staticmap'] as $host) {
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
|||
if (!empty($_GET['if']) && !empty($config['interfaces'][$_GET['if']]) &&
|
||||
isset($config['interfaces'][$_GET['if']]['enable']) &&
|
||||
(is_ipaddr($config['interfaces'][$_GET['if']]['ipaddrv6']) ||
|
||||
$config['interfaces'][$_GET['if']]['ipaddrv6'] == 'track6')) {
|
||||
in_array($config['interfaces'][$_GET['if']]['ipaddrv6'], ['idassoc6', 'track6']))) {
|
||||
$if = $_GET['if'];
|
||||
}
|
||||
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
|
|
@ -154,29 +154,33 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* XXX: In case of tracking, show different form and only handle on/off options.
|
||||
* this code injection is intended to keep changes as minimal as possible and avoid regressions on existing isc-dhcp6 installs,
|
||||
* while showing current state for tracking interfaces.
|
||||
**/
|
||||
if ($if === null) {
|
||||
/* if no interface is provided this invoke is invalid */
|
||||
header(url_safe('Location: /index.php'));
|
||||
exit;
|
||||
} elseif (($config['interfaces'][$if]['ipaddrv6'] ?? 'none') == 'track6' && !isset($config['interfaces'][$if]['dhcpd6track6allowoverride'])) {
|
||||
/*
|
||||
* In case of automatic tracking, show different form and only handle on/off options.
|
||||
* This code injection is intended to keep changes as minimal as possible and avoid
|
||||
* regressions on existing isc-dhcp installs, while showing current state for tracking
|
||||
* interfaces.
|
||||
*/
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
show_track6_form($if);
|
||||
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
process_track6_form($if);
|
||||
} else {
|
||||
header(url_safe('Location: /index.php'));
|
||||
}
|
||||
exit;
|
||||
}
|
||||
/* default form processing */
|
||||
|
||||
/* default form processing (for manual track6 and idassoc6 but handled via 'track6-interface') */
|
||||
|
||||
$ifcfgip = $config['interfaces'][$if]['ipaddrv6'];
|
||||
$ifcfgsn = $config['interfaces'][$if]['subnetv6'];
|
||||
|
||||
if (isset($config['interfaces'][$if]['dhcpd6track6allowoverride'])) {
|
||||
if (isset($config['interfaces'][$if]['track6-interface'])) {
|
||||
list ($ifcfgip,, $ifcfgsn) = interfaces_primary_address6($if);
|
||||
$pdlen = calculate_ipv6_delegation_length($config['interfaces'][$if]['track6-interface']) - 1;
|
||||
}
|
||||
|
|
@ -316,7 +320,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
|||
$range_from = $pconfig['range_from'];
|
||||
$range_to = $pconfig['range_to'];
|
||||
|
||||
if (isset($config['interfaces'][$if]['dhcpd6track6allowoverride'])) {
|
||||
if (isset($config['interfaces'][$if]['track6-interface'])) {
|
||||
$range_from = merge_ipv6_address($ifcfgip, $pconfig['range_from']);
|
||||
$range_to = merge_ipv6_address($ifcfgip, $pconfig['range_to']);
|
||||
}
|
||||
|
|
@ -606,11 +610,11 @@ include("head.inc");
|
|||
</tbody>
|
||||
</table>
|
||||
<div class="hidden" data-for="help_for_range">
|
||||
<?php if (!isset($config['interfaces'][$if]['dhcpd6track6allowoverride'])): ?>
|
||||
<?= gettext('The range should be entered using the full IPv6 address.') ?>
|
||||
<?php else: ?>
|
||||
<?php if (isset($config['interfaces'][$if]['track6-interface'])): ?>
|
||||
<?= gettext('The range should be entered using the suffix part of the IPv6 address, i.e. ::1:2:3:4. ' .
|
||||
'The subnet prefix will be added automatically.') ?>
|
||||
<?php else: ?>
|
||||
<?= gettext('The range should be entered using the full IPv6 address.') ?>
|
||||
<?php endif ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -651,7 +655,7 @@ include("head.inc");
|
|||
<?= gettext("You can define a Prefix range here for DHCP Prefix Delegation. This allows for assigning networks to subrouters. " .
|
||||
"The start and end of the range must end on boundaries of the prefix delegation size."); ?>
|
||||
<?= gettext("Ensure that any prefix delegation range does not overlap the LAN prefix range."); ?>
|
||||
<?php if (isset($config['interfaces'][$if]['dhcpd6track6allowoverride'])): ?>
|
||||
<?php if (isset($config['interfaces'][$if]['track6-interface'])): ?>
|
||||
<br/><br/>
|
||||
<?= gettext('When using a tracked interface then please only enter the range itself, i.e. ::xxxx:0:0:0:0. ' .
|
||||
'For example, for a /56 delegation from ::100:0:0:0:0 to ::f00:0:0:0:0. ' .
|
||||
|
|
|
|||
Loading…
Reference in a new issue