diff options
| author | Christian Breunig <christian@breunig.cc> | 2026-11-07 21:22:01 +0100 |
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2026-11-07 21:22:01 +0100 |
| commit | a4110d7d50eddc433da2d0d08a092585f5fe6ee5 (patch) | |
| tree | 2dd739c7ede3c1ae8353927cd5212cd0c957ae49 | |
| parent | d6902e6423ec78b5b99d96b6427ebee771ea6c38 (diff) | |
| download | vyos-1x-a4110d7d50eddc433da2d0d08a092585f5fe6ee5.tar.gz vyos-1x-a4110d7d50eddc433da2d0d08a092585f5fe6ee5.zip | |
dhcpv6-client: T6301: do not block commits on an unanswered Release
When stopped, dhcp6c removes its leases at once but then retransmits the
Release for ~30 seconds if the server never replies. As the client is stopped
or restarted synchronously, every commit deleting "address dhcpv6", changing
"dhcpv6-options" or moving the interface to another VRF hung for that long.
Stopping the client now waits at most 5 seconds for it to exit before it is
killed, which is treated as a clean stop so the unit does not end up failed.
Add a smoketest dropping the Release on a veth pair with a local DHCPv6
server, verifying the commit returns quickly and the lease is removed.
| -rwxr-xr-x | smoketest/scripts/cli/test_interfaces_virtual-ethernet.py | 50 | ||||
| -rw-r--r-- | src/systemd/dhcp6c@.service | 4 |
2 files changed, 54 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/test_interfaces_virtual-ethernet.py b/smoketest/scripts/cli/test_interfaces_virtual-ethernet.py index 96ca36830..826127ce6 100755 --- a/smoketest/scripts/cli/test_interfaces_virtual-ethernet.py +++ b/smoketest/scripts/cli/test_interfaces_virtual-ethernet.py @@ -16,11 +16,15 @@ import unittest +from time import time + from base_interfaces_test import BasicInterfaceTest from base_vyostest_shim import VyOSUnitTestSHIM from vyos.configsession import ConfigSessionError from vyos.utils.network import interface_exists +from vyos.utils.network import is_intf_addr_assigned +from vyos.utils.process import rc_cmd class VEthInterfaceTest(BasicInterfaceTest.TestCase): @classmethod @@ -50,5 +54,51 @@ class VEthInterfaceTest(BasicInterfaceTest.TestCase): self.assertTrue(interface_exists(peer[0])) self.assertTrue(interface_exists(peer[1])) + def test_dhcpv6_client_unanswered_release(self): + # T6301: a DHCPv6 server not answering the Release of a stopping + # client must not block the commit for ~30 seconds + client, server = 'veth0', 'veth1' + lease = '2001:db8:6301::100' + server_path = ['service', 'dhcpv6-server', 'shared-network-name', 'T6301', + 'subnet', '2001:db8:6301::/64'] + nft_table = 'inet smoketest_t6301' + + for interface in self._interfaces: + for option in self._options.get(interface, []): + self.cli_set(self._base_path + [interface] + option.split()) + self.cli_set(self._base_path + [server, 'address', '2001:db8:6301::1/64']) + self.cli_set(self._base_path + [client, 'address', 'dhcpv6']) + self.cli_set(server_path + ['subnet-id', '6301']) + self.cli_set(server_path + ['interface', server]) + self.cli_set(server_path + ['range', '1', 'start', lease]) + self.cli_set(server_path + ['range', '1', 'stop', lease]) + self.cli_commit() + + try: + self.wait_for_result(lambda: is_intf_addr_assigned(client, lease), True, + timeout=30) + self.assertTrue(is_intf_addr_assigned(client, lease)) + + # Drop the client's Release so it never sees a Reply + for nft in [f'add table {nft_table}', + f"add chain {nft_table} out '{{ type filter hook output priority 0; }}'", + f'add rule {nft_table} out oifname {client} udp dport 547 drop']: + rc, out = rc_cmd(f'sudo nft {nft}') + self.assertEqual(rc, 0, out) + + self.cli_delete(self._base_path + [client, 'address', 'dhcpv6']) + start = time() + self.cli_commit() + self.assertLess(time() - start, 15) + + self.assertFalse(is_intf_addr_assigned(client, lease)) + # A bounded stop must still be a clean stop + _, state = rc_cmd(f'systemctl is-failed dhcp6c@{client}.service') + self.assertEqual(state, 'inactive') + finally: + rc_cmd(f'sudo nft delete table {nft_table}') + self.cli_delete(['service', 'dhcpv6-server']) + self.cli_commit() + if __name__ == '__main__': unittest.main(verbosity=2, failfast=VyOSUnitTestSHIM.TestCase.debug_on()) diff --git a/src/systemd/dhcp6c@.service b/src/systemd/dhcp6c@.service index f634bd944..b991ac345 100644 --- a/src/systemd/dhcp6c@.service +++ b/src/systemd/dhcp6c@.service @@ -10,6 +10,10 @@ WorkingDirectory=/run/dhcp6c EnvironmentFile=-/run/dhcp6c/dhcp6c.%i.options PIDFile=/run/dhcp6c/dhcp6c.%i.pid ExecStart=/usr/sbin/dhcp6c $DHCP6C_OPTS +# T6301: dhcp6c removes all leases at once on SIGTERM, but then waits ~30s for +# a Reply to its Release. Do not block commits on a server that never answers. +ExecStop=/bin/sh -c 'kill -TERM ${MAINPID}; timeout 5 tail -s 0.1 --pid=${MAINPID} -f /dev/null || kill -KILL ${MAINPID}' +SuccessExitStatus=KILL Restart=always RestartPreventExitStatus= RestartSec=10 |
