From e32bc8e3b193171d3f3a53a703d0057195bed11d Mon Sep 17 00:00:00 2001 From: Adam Smith Date: Sat, 4 Jan 2025 22:16:29 -0500 Subject: [PATCH] T7106: force delete only dynamic IPv4 address from interface --- python/vyos/ifconfig/interface.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py index cad1685a93..de821ab602 100644 --- a/python/vyos/ifconfig/interface.py +++ b/python/vyos/ifconfig/interface.py @@ -1423,11 +1423,13 @@ def set_dhcp(self, enable): tmp = get_interface_address(self.ifname) if tmp and 'addr_info' in tmp: for address_dict in tmp['addr_info']: - # Only remove dynamic assigned addresses - if 'dynamic' not in address_dict: - continue - address = address_dict['local'] - self.del_addr(address) + if address_dict['family'] == 'inet': + # Only remove dynamic assigned addresses + if 'dynamic' not in address_dict: + continue + address = address_dict['local'] + prefixlen = address_dict['prefixlen'] + self.del_addr(f'{address}/{prefixlen}') # cleanup old config files for file in [dhclient_config_file, systemd_override_file, dhclient_lease_file]: