summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-05-29 09:55:39 +0200
committerChristian Breunig <christian@breunig.cc>2023-05-29 09:56:19 +0200
commitea01c2df78ddb9a6dcaf65c3d9bb2a267c8df883 (patch)
treeb46e5954d8501983270f165cd32aad8c6782e4b5
parentfdd5b644ec566b75e58a45478c94364858ac053e (diff)
downloadvyos-1x-ea01c2df78ddb9a6dcaf65c3d9bb2a267c8df883.tar.gz
vyos-1x-ea01c2df78ddb9a6dcaf65c3d9bb2a267c8df883.zip
ifconfig: T2104: use link_local_prefix literal for fe80::/64
-rw-r--r--python/vyos/ifconfig/interface.py8
-rw-r--r--python/vyos/validate.py4
2 files changed, 7 insertions, 5 deletions
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py
index f62b9f7d2..7754488c4 100644
--- a/python/vyos/ifconfig/interface.py
+++ b/python/vyos/ifconfig/interface.py
@@ -57,6 +57,8 @@ from vyos.ifconfig import Section
from netaddr import EUI
from netaddr import mac_unix_expanded
+link_local_prefix = 'fe80::/64'
+
class Interface(Control):
# This is the class which will be used to create
# self.operational, it allows subclasses, such as
@@ -1444,7 +1446,7 @@ class Interface(Control):
# we will delete all interface specific IP addresses if they are not
# explicitly configured on the CLI
if is_ipv6_link_local(addr):
- eui64 = mac2eui64(self.get_mac(), 'fe80::/64')
+ eui64 = mac2eui64(self.get_mac(), link_local_prefix)
if addr != f'{eui64}/64':
self.del_addr(addr)
else:
@@ -1571,9 +1573,9 @@ class Interface(Control):
# Manage IPv6 link-local addresses
if dict_search('ipv6.address.no_default_link_local', config) != None:
- self.del_ipv6_eui64_address('fe80::/64')
+ self.del_ipv6_eui64_address(link_local_prefix)
else:
- self.add_ipv6_eui64_address('fe80::/64')
+ self.add_ipv6_eui64_address(link_local_prefix)
# Add IPv6 EUI-based addresses
tmp = dict_search('ipv6.address.eui64', config)
diff --git a/python/vyos/validate.py b/python/vyos/validate.py
index a83193363..d18785aaf 100644
--- a/python/vyos/validate.py
+++ b/python/vyos/validate.py
@@ -62,7 +62,7 @@ def is_intf_addr_assigned(intf, address) -> bool:
# 10: [{'addr': 'fe80::a00:27ff:fed9:5b04%eth0', 'netmask': 'ffff:ffff:ffff:ffff::'}]
# }
try:
- ifaces = ifaddresses(intf)
+ addresses = ifaddresses(intf)
except ValueError as e:
print(e)
return False
@@ -74,7 +74,7 @@ def is_intf_addr_assigned(intf, address) -> bool:
netmask = None
if '/' in address:
address, netmask = address.split('/')
- for ip in ifaces.get(addr_type,[]):
+ for ip in addresses.get(addr_type, []):
# ip can have the interface name in the 'addr' field, we need to remove it
# {'addr': 'fe80::a00:27ff:fec5:f821%eth2', 'netmask': 'ffff:ffff:ffff:ffff::'}
ip_addr = ip['addr'].split('%')[0]