mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
normalizing ip address(s) to IPNetwork format for string comparaison
Ticket: CM-12798 Reviewed By: Roopa, Nikhil G Testing Done: We are seeing some issue when using IP addresses with inner values padded with zeros. Such as: 2a01:75e0:0000:09b0::1/64 The kernel will process the ip properly but when we query the kernel again (with iproute2 or netlink) it returns 2a01:75e0:0:09b0::1/64 Since we are doing string comparaison we are seeing failures. We are now converting all ip address to a standard format using IPNetwork or IPAddress obj Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
This commit is contained in:
@@ -10,6 +10,7 @@ try:
|
||||
from ipaddr import IPNetwork, IPv4Network, IPv6Network, IPv4Address, IPv6Address
|
||||
from sets import Set
|
||||
from ifupdown.iface import *
|
||||
from ifupdown.utils import utils
|
||||
from ifupdownaddons.modulebase import moduleBase
|
||||
from ifupdownaddons.iproute2 import iproute2
|
||||
from ifupdownaddons.dhclient import dhclient
|
||||
@@ -221,6 +222,7 @@ class address(moduleBase):
|
||||
ifaceobjlist = [ifaceobj]
|
||||
|
||||
(addr_supported, newaddrs, newaddr_attrs) = self._inet_address_convert_to_cidr(ifaceobjlist)
|
||||
newaddrs = utils.get_normalized_ip_addr(ifaceobj.name, newaddrs)
|
||||
if not addr_supported:
|
||||
return
|
||||
if (not squash_addr_config and (ifaceobj.flags & iface.HAS_SIBLINGS)):
|
||||
@@ -234,11 +236,11 @@ class address(moduleBase):
|
||||
if not ifupdownflags.flags.PERFMODE and purge_addresses == 'yes':
|
||||
# if perfmode is not set and purge addresses is not set to 'no'
|
||||
# lets purge addresses not in the config
|
||||
runningaddrs = self.ipcmd.addr_get(ifaceobj.name, details=False)
|
||||
runningaddrs = utils.get_normalized_ip_addr(ifaceobj.name, self.ipcmd.addr_get(ifaceobj.name, details=False))
|
||||
|
||||
# if anycast address is configured on 'lo' and is in running config
|
||||
# add it to newaddrs so that ifreload doesn't wipe it out
|
||||
anycast_addr = self._get_anycast_addr(ifaceobjlist)
|
||||
anycast_addr = utils.get_normalized_ip_addr(ifaceobj.name, self._get_anycast_addr(ifaceobjlist))
|
||||
|
||||
if runningaddrs and anycast_addr and anycast_addr in runningaddrs:
|
||||
newaddrs.append(anycast_addr)
|
||||
@@ -466,11 +468,12 @@ class address(moduleBase):
|
||||
# compare addresses
|
||||
if addr_method == 'dhcp':
|
||||
return
|
||||
addrs = self._get_iface_addresses(ifaceobj)
|
||||
addrs = utils.get_normalized_ip_addr(ifaceobj.name,
|
||||
self._get_iface_addresses(ifaceobj))
|
||||
runningaddrsdict = self.ipcmd.addr_get(ifaceobj.name)
|
||||
# if anycast address is configured on 'lo' and is in running config
|
||||
# add it to addrs so that query_check doesn't fail
|
||||
anycast_addr = ifaceobj.get_attr_value_first('clagd-vxlan-anycast-ip')
|
||||
anycast_addr = utils.get_normalized_ip_addr(ifaceobj.name, ifaceobj.get_attr_value_first('clagd-vxlan-anycast-ip'))
|
||||
if anycast_addr:
|
||||
anycast_addr = anycast_addr+'/32'
|
||||
if runningaddrsdict and anycast_addr and runningaddrsdict.get(anycast_addr):
|
||||
|
Reference in New Issue
Block a user