Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@1vivy dhcpv6-pd: T5387: add support for no-release flag #2108

Merged
merged 3 commits into from Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions data/templates/dhcp-client/dhcp6c_daemon-options.j2
@@ -0,0 +1,2 @@
{% set no_release = '-n' if dhcpv6_options.no_release is vyos_defined else '' %}
DHCP6C_OPTS="-D -k /run/dhcp6c/dhcp6c.{{ ifname }}.sock -c /run/dhcp6c/dhcp6c.{{ ifname }}.conf -p /run/dhcp6c/dhcp6c.{{ ifname }}.pid {{ no_release }} {{ ifname }}"
Expand Up @@ -95,6 +95,12 @@
<valueless/>
</properties>
</leafNode>
<leafNode name="no-release">
<properties>
<help>Do not send a release message on client exit</help>
<valueless/>
</properties>
</leafNode>
</children>
</node>
<!-- include end -->
2 changes: 2 additions & 0 deletions python/vyos/ifconfig/interface.py
Expand Up @@ -1288,9 +1288,11 @@ def set_dhcpv6(self, enable):

ifname = self.ifname
config_file = f'/run/dhcp6c/dhcp6c.{ifname}.conf'
options_file = f'/run/dhcp6c/dhcp6c.{ifname}.options'
systemd_service = f'dhcp6c@{ifname}.service'

if enable and 'disable' not in self._config:
render(options_file, 'dhcp-client/dhcp6c_daemon-options.j2', self._config)
render(config_file, 'dhcp-client/ipv6.j2', self._config)

# We must ignore any return codes. This is required to enable
Expand Down
4 changes: 4 additions & 0 deletions smoketest/scripts/cli/base_interfaces_test.py
Expand Up @@ -791,13 +791,17 @@ def test_dhcpv6_client_options(self):

# Enable DHCPv6 client
self.cli_set(path + ['address', 'dhcpv6'])
self.cli_set(path + ['dhcpv6-options', 'no-release'])
self.cli_set(path + ['dhcpv6-options', 'rapid-commit'])
self.cli_set(path + ['dhcpv6-options', 'parameters-only'])
self.cli_set(path + ['dhcpv6-options', 'duid', duid])
duid_base += 1

self.cli_commit()

dhcp6c_options = read_file(f'/run/dhcp6c/dhcp6c.{interface}.options')
self.assertIn(f'-n', dhcp6c_options)

duid_base = 10
for interface in self._interfaces:
duid = '00:01:00:01:27:71:db:f0:00:50:00:00:00:{}'.format(duid_base)
Expand Down
4 changes: 3 additions & 1 deletion src/systemd/dhcp6c@.service
Expand Up @@ -2,14 +2,16 @@
Description=WIDE DHCPv6 client on %i
Documentation=man:dhcp6c(8) man:dhcp6c.conf(5)
ConditionPathExists=/run/dhcp6c/dhcp6c.%i.conf
ConditionPathExists=/run/dhcp6c/dhcp6c.%i.options
After=vyos-router.service
StartLimitIntervalSec=0

[Service]
WorkingDirectory=/run/dhcp6c
EnvironmentFile=-/run/dhcp6c/dhcp6c.%i.options
Type=forking
PIDFile=/run/dhcp6c/dhcp6c.%i.pid
ExecStart=/usr/sbin/dhcp6c -D -k /run/dhcp6c/dhcp6c.%i.sock -c /run/dhcp6c/dhcp6c.%i.conf -p /run/dhcp6c/dhcp6c.%i.pid %i
ExecStart=/usr/sbin/dhcp6c $DHCP6C_OPTS
Restart=on-failure
RestartSec=20

Expand Down