diff options
-rw-r--r-- | python/vyos/ifconfig/interface.py | 6 | ||||
-rw-r--r-- | python/vyos/validate.py | 4 | ||||
-rw-r--r-- | src/tests/test_validate.py | 7 |
3 files changed, 12 insertions, 5 deletions
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py index 6837e2d6a..d695f05e3 100644 --- a/python/vyos/ifconfig/interface.py +++ b/python/vyos/ifconfig/interface.py @@ -40,6 +40,7 @@ from vyos.util import read_file from vyos.template import is_ipv4 from vyos.template import is_ipv6 from vyos.validate import is_intf_addr_assigned +from vyos.validate import is_ipv6_link_local from vyos.validate import assert_boolean from vyos.validate import assert_list from vyos.validate import assert_mac @@ -1042,7 +1043,10 @@ class Interface(Control): # list of addresses which are no longer in the dict so they can be removed cur_addr = self.get_addr() for addr in list_diff(cur_addr, new_addr): - self.del_addr(addr) + # do not clean out link-local IPv6 addresses - it makes no sense + # as they will be readded so this prevents any flapping links + if not is_ipv6_link_local(addr): + self.del_addr(addr) for addr in new_addr: self.add_addr(addr) diff --git a/python/vyos/validate.py b/python/vyos/validate.py index 84a7bc2de..98bd40f74 100644 --- a/python/vyos/validate.py +++ b/python/vyos/validate.py @@ -27,11 +27,11 @@ from vyos.util import cmd def is_ipv6_link_local(addr): """ Check if addrsss is an IPv6 link-local address. Returns True/False """ - from ipaddress import IPv6Address + from ipaddress import ip_interface from vyos.template import is_ipv6 addr = addr.split('%')[0] if is_ipv6(addr): - if IPv6Address(addr).is_link_local: + if ip_interface(addr).is_link_local: return True return False diff --git a/src/tests/test_validate.py b/src/tests/test_validate.py index 226e856a3..4348e2ef8 100644 --- a/src/tests/test_validate.py +++ b/src/tests/test_validate.py @@ -22,13 +22,16 @@ class TestVyOSValidate(TestCase): pass def test_is_ipv6_link_local(self): - self.assertFalse(vyos.validate.is_ipv6_link_local('169.254.0.1')) self.assertTrue(vyos.validate.is_ipv6_link_local('fe80::')) self.assertTrue(vyos.validate.is_ipv6_link_local('fe80::affe:1')) + self.assertTrue(vyos.validate.is_ipv6_link_local('fe80::250:56ff:febf:efaa/64')) + + self.assertFalse(vyos.validate.is_ipv6_link_local('169.254.0.1')) self.assertFalse(vyos.validate.is_ipv6_link_local('2001:db8::')) + self.assertFalse(vyos.validate.is_ipv6_link_local('2001:db8::1/64')) self.assertFalse(vyos.validate.is_ipv6_link_local('VyOS')) - def test_is_ipv6_link_local(self): + def test_is_loopback(self): self.assertTrue(vyos.validate.is_loopback_addr('127.0.0.1')) self.assertTrue(vyos.validate.is_loopback_addr('127.0.1.1')) self.assertTrue(vyos.validate.is_loopback_addr('127.1.1.1')) |