Skip to content

Commit

Permalink
T6648: dhcpv6-server: align stateless DHCPv6 options with stateful
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasec committed Aug 12, 2024
1 parent ba0f8db commit dfdfefb
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 24 deletions.
12 changes: 12 additions & 0 deletions interface-definitions/include/dhcp/option-v6.xml.i
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@
<multi/>
</properties>
</leafNode>
<leafNode name="info-refresh-time">
<properties>
<help>Time (in seconds) that stateless clients should wait between refreshing the information they were given</help>
<valueHelp>
<format>u32:1-4294967295</format>
<description>DHCPv6 information refresh time</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 1-4294967295"/>
</constraint>
</properties>
</leafNode>
<node name="vendor-option">
<properties>
<help>Vendor Specific Options</help>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- include start from include/version/dhcpv6-server-version.xml.i -->
<syntaxVersion component='dhcpv6-server' version='5'></syntaxVersion>
<syntaxVersion component='dhcpv6-server' version='6'></syntaxVersion>
<!-- include end -->
22 changes: 1 addition & 21 deletions interface-definitions/service_dhcpv6-server.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,7 @@
</constraint>
</properties>
</leafNode>
<node name="common-options">
<properties>
<help>Common options to distribute to all clients, including stateless clients</help>
</properties>
<children>
<leafNode name="info-refresh-time">
<properties>
<help>Time (in seconds) that stateless clients should wait between refreshing the information they were given</help>
<valueHelp>
<format>u32:1-4294967295</format>
<description>DHCPv6 information refresh time</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 1-4294967295"/>
</constraint>
</properties>
</leafNode>
#include <include/dhcp/domain-search.xml.i>
#include <include/name-server-ipv6.xml.i>
</children>
</node>
#include <include/dhcp/option-v6.xml.i>
<tagNode name="subnet">
<properties>
<help>IPv6 DHCP subnet for this shared network</help>
Expand Down
4 changes: 2 additions & 2 deletions python/vyos/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,8 +922,8 @@ def kea6_shared_network_json(shared_networks):
'subnet6': []
}

if 'common_options' in config:
network['option-data'] = kea6_parse_options(config['common_options'])
if 'option' in config:
network['option-data'] = kea6_parse_options(config['option'])

if 'interface' in config:
network['interface'] = config['interface']
Expand Down
32 changes: 32 additions & 0 deletions src/migration-scripts/dhcpv6-server/5-to-6
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2024 VyOS maintainers and contributors <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.

# T6648: Rename "common-options" to "option" at shared-network level

from ipaddress import ip_network
from vyos.configtree import ConfigTree

base = ['service', 'dhcpv6-server', 'shared-network-name']

def migrate(config: ConfigTree) -> None:
if not config.exists(base):
# Nothing to do
return

for network in config.list_nodes(base):
if not config.exists(base + [network, 'common-options']):
continue

config.rename(base + [network, 'common-options'], 'option')

0 comments on commit dfdfefb

Please sign in to comment.