From 10f6c3c2ee92ddc7f74b6dae0530e10e60bcf48d Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Thu, 25 Oct 2018 22:33:33 +0200 Subject: 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) --- python/vyos/validate.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'python') 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 -- cgit v1.2.3