diff options
author | Christian Poessinger <christian@poessinger.com> | 2018-10-25 22:33:33 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2018-10-25 22:35:50 +0200 |
commit | de131151b2c52c6d91ce586066433e7c0afc2080 (patch) | |
tree | 28f447fe7be1b71980049dbec2c2782449ca8d7f /python/vyos/validate.py | |
parent | 4029814a1ee22d02748ab92e01c357c66a9f9137 (diff) | |
download | vyos-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/vyos/validate.py')
-rw-r--r-- | python/vyos/validate.py | 4 |
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 |