diff options
| author | Christian Breunig <christian@breunig.cc> | 2025-02-05 23:12:45 +0100 |
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2025-02-05 23:12:45 +0100 |
| commit | bc4adcf9a4b7dee5e0a56c39b707e40f6d64f482 (patch) | |
| tree | 298f63817eba6610c42efb6422de35282106dada /python/vyos/ifconfig/interface.py | |
| parent | 68002a3839d259d40d9a7bd88fe72c7361679388 (diff) | |
| download | veeos-1x-bc4adcf9a4b7dee5e0a56c39b707e40f6d64f482.tar.gz veeos-1x-bc4adcf9a4b7dee5e0a56c39b707e40f6d64f482.zip | |
vyos.ifconfig: T7135: only restart DHCPv6 client if needed
Previously the DHCPv6 client was restarted on any change to the interface,
including changes only to the interface description. Re-use pattern from IPv4
DHCP to only restart the DHCP client if necessary.
Diffstat (limited to 'python/vyos/ifconfig/interface.py')
| -rw-r--r-- | python/vyos/ifconfig/interface.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py index 91ee09d90..85f2d3484 100644 --- a/python/vyos/ifconfig/interface.py +++ b/python/vyos/ifconfig/interface.py @@ -1222,7 +1222,7 @@ class Interface(Control): if addr == 'dhcp': self.set_dhcp(True, vrf_changed=vrf_changed) elif addr == 'dhcpv6': - self.set_dhcpv6(True) + self.set_dhcpv6(True, vrf_changed=vrf_changed) elif not is_intf_addr_assigned(self.ifname, addr, netns=netns): netns_cmd = f'ip netns exec {netns}' if netns else '' tmp = f'{netns_cmd} ip addr add {addr} dev {self.ifname}' @@ -1430,7 +1430,7 @@ class Interface(Control): return None - def set_dhcpv6(self, enable): + def set_dhcpv6(self, enable: bool, vrf_changed: bool=False): """ Enable/Disable DHCPv6 client on a given interface. """ @@ -1459,7 +1459,10 @@ class Interface(Control): # We must ignore any return codes. This is required to enable # DHCPv6-PD for interfaces which are yet not up and running. - return self._popen(f'systemctl restart {systemd_service}') + if (vrf_changed or + ('dhcpv6_options_changed' in self.config) or + (not is_systemd_service_active(systemd_service))): + return self._popen(f'systemctl restart {systemd_service}') else: if is_systemd_service_active(systemd_service): self._cmd(f'systemctl stop {systemd_service}') @@ -1676,10 +1679,6 @@ class Interface(Control): else: self.del_addr(addr) - # start DHCPv6 client when only PD was configured - if dhcpv6pd: - self.set_dhcpv6(True) - # XXX: Bind interface to given VRF or unbind it if vrf is not set. Unbinding # will call 'ip link set dev eth0 nomaster' which will also drop the # interface out of any bridge or bond - thus this is checked before. @@ -1698,6 +1697,10 @@ class Interface(Control): else: vrf_changed = self.set_vrf(config.get('vrf', '')) + # start DHCPv6 client when only PD was configured + if dhcpv6pd: + self.set_dhcpv6(True, vrf_changed=vrf_changed) + # Add this section after vrf T4331 for addr in new_addr: self.add_addr(addr, vrf_changed=vrf_changed) |
