summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2018-10-25 22:33:33 +0200
committerChristian Poessinger <christian@poessinger.com>2018-10-25 22:35:50 +0200
commitde131151b2c52c6d91ce586066433e7c0afc2080 (patch)
tree28f447fe7be1b71980049dbec2c2782449ca8d7f /python
parent4029814a1ee22d02748ab92e01c357c66a9f9137 (diff)
downloadvyos-1x-de131151b2c52c6d91ce586066433e7c0afc2080.tar.gz
vyos-1x-de131151b2c52c6d91ce586066433e7c0afc2080.zip
T937: proper handle IPv6 link-local addresses in vyos.validate module
The problem is that some IPv6 addresses reported by the system (mainly link-local addresses) contain an interface suffix like %eth0, this was not properly handeled in the validator script. Remove any given interface attribute on passed IPv6 addresses. If no interface suffix is added - there is no problem.
Diffstat (limited to 'python')
-rw-r--r--python/vyos/validate.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/python/vyos/validate.py b/python/vyos/validate.py
index 1b77f196a..8def0a510 100644
--- a/python/vyos/validate.py
+++ b/python/vyos/validate.py
@@ -94,7 +94,9 @@ def is_subnet_connected(subnet, primary=False):
# Check every assigned IP address if it is connected to the subnet
# in question
for ip in netifaces.ifaddresses(interface)[addr_type]:
- if ipaddress.ip_address(ip['addr']) in ipaddress.ip_network(subnet):
+ # remove interface extension (e.g. %eth0) that gets thrown on the end of _some_ addrs
+ addr = ip['addr'].split('%')[0]
+ if ipaddress.ip_address(addr) in ipaddress.ip_network(subnet):
return True
return False