Skip to content

Commit

Permalink
T7016: Simplify logic for force deleting dynamic IPv4 address from in…
Browse files Browse the repository at this point in the history
…terface
  • Loading branch information
indrajitr committed Jan 6, 2025
1 parent f9f4137 commit 68afb84
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions python/vyos/ifconfig/interface.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2024 VyOS maintainers and contributors <[email protected]>
# Copyright 2019-2025 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
Expand Down Expand Up @@ -1423,13 +1423,11 @@ 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']:
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}')
# Only remove dynamic assigned addresses
if address_dict['family'] == 'inet' and 'dynamic' in address_dict:
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]:
Expand Down

0 comments on commit 68afb84

Please sign in to comment.