summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2025-04-19 15:18:44 +0200
committerChristian Breunig <christian@breunig.cc>2025-04-22 16:06:19 +0200
commite9fb2078d5ea82e1d9186ee8ef1dd982591954d0 (patch)
tree5ddd0429ba8e5802946829368af29a01cbc2b691 /python
parent39e2a908e5d141911820c20bb1a5a5b1b96fa457 (diff)
downloadvyos-1x-e9fb2078d5ea82e1d9186ee8ef1dd982591954d0.tar.gz
vyos-1x-e9fb2078d5ea82e1d9186ee8ef1dd982591954d0.zip
interface: T7375: SLAAC assigned address is not cleared when removing SLAAC
Diffstat (limited to 'python')
-rw-r--r--python/vyos/ifconfig/interface.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py
index 979b62578..85f994e08 100644
--- a/python/vyos/ifconfig/interface.py
+++ b/python/vyos/ifconfig/interface.py
@@ -909,7 +909,10 @@ class Interface(Control):
tmp = self.get_interface('ipv6_autoconf')
if tmp == autoconf:
return None
- return self.set_interface('ipv6_autoconf', autoconf)
+ rc = self.set_interface('ipv6_autoconf', autoconf)
+ if autoconf == '0':
+ self.flush_ipv6_slaac_addrs()
+ return rc
def add_ipv6_eui64_address(self, prefix):
"""
@@ -1310,6 +1313,34 @@ class Interface(Control):
# flush all addresses
self._cmd(cmd)
+ def flush_ipv6_slaac_addrs(self):
+ """
+ Flush all IPv6 addresses installed in response to router advertisement
+ messages from this interface.
+
+ Will raise an exception on error.
+ """
+ netns = get_interface_namespace(self.ifname)
+ netns_cmd = f'ip netns exec {netns}' if netns else ''
+ tmp = get_interface_address(self.ifname)
+ if 'addr_info' not in tmp:
+ return
+
+ # Parse interface IP addresses. Example data:
+ # {'family': 'inet6', 'local': '2001:db8:1111:0:250:56ff:feb3:38c5',
+ # 'prefixlen': 64, 'scope': 'global', 'dynamic': True,
+ # 'mngtmpaddr': True, 'protocol': 'kernel_ra',
+ # 'valid_life_time': 2591987, 'preferred_life_time': 14387}
+ for addr_info in tmp['addr_info']:
+ if 'protocol' not in addr_info:
+ continue
+ if (addr_info['protocol'] == 'kernel_ra' and
+ addr_info['scope'] == 'global'):
+ # Flush IPv6 addresses installed by router advertisement
+ ra_addr = f"{addr_info['local']}/{addr_info['prefixlen']}"
+ cmd = f'{netns_cmd} ip -6 addr del dev {self.ifname} {ra_addr}'
+ self._cmd(cmd)
+
def add_to_bridge(self, bridge_dict):
"""
Adds the interface to the bridge with the passed port config.