summaryrefslogtreecommitdiff
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:36:36 +0200
commit10f6c3c2ee92ddc7f74b6dae0530e10e60bcf48d (patch)
treea84dffaea3054e547449c3fbb91e005b6752369e
parentfd0f4529eba75dee6b993ce449987e267a95cfb4 (diff)
downloadvyos-1x-10f6c3c2ee92ddc7f74b6dae0530e10e60bcf48d.tar.gz
vyos-1x-10f6c3c2ee92ddc7f74b6dae0530e10e60bcf48d.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. (cherry picked from commit de131151b2c52c6d91ce586066433e7c0afc2080)
-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