mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
python-netifaces: update to reflect upstream changes
python-netifaces now provides IPv6 netmask in format mask/prefix. It breaks freeipa as it is unexpected format for python-netaddr. We must split netmask and provide only prefix for netaddr. https://pagure.io/freeipa/issue/7021 Reviewed-By: Martin Babinsky <mbabinsk@redhat.com> Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
This commit is contained in:
parent
172a2e7456
commit
52b43c7168
@ -197,6 +197,7 @@ class CheckedIPAddress(UnsafeIPAddress):
|
||||
:return: InterfaceDetails named tuple or None if no interface has
|
||||
this address
|
||||
"""
|
||||
root_logger.debug("Searching for an interface of IP address: %s", self)
|
||||
if self.version == 4:
|
||||
family = netifaces.AF_INET
|
||||
elif self.version == 6:
|
||||
@ -213,10 +214,20 @@ class CheckedIPAddress(UnsafeIPAddress):
|
||||
# errors in IPNetwork
|
||||
ifaddr = ifdata['addr'].split(u'%', 1)[0]
|
||||
|
||||
ifnet = netaddr.IPNetwork('{addr}/{netmask}'.format(
|
||||
# newer versions of netifaces provide IPv6 netmask in format
|
||||
# 'ffff:ffff:ffff:ffff::/64'. We have to split and use prefix
|
||||
# or the netmask with older versions
|
||||
ifmask = ifdata['netmask'].split(u'/')[-1]
|
||||
|
||||
ifaddrmask = '{addr}/{netmask}'.format(
|
||||
addr=ifaddr,
|
||||
netmask=ifdata['netmask']
|
||||
))
|
||||
netmask=ifmask
|
||||
)
|
||||
root_logger.debug(
|
||||
"Testing local IP address: %s (interface: %s)",
|
||||
ifaddrmask, interface)
|
||||
|
||||
ifnet = netaddr.IPNetwork(ifaddrmask)
|
||||
|
||||
if ifnet.ip == self:
|
||||
return InterfaceDetails(interface, ifnet)
|
||||
|
Loading…
Reference in New Issue
Block a user