1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

nlpacket: AttributeIPAddress: fix decode handler for Routes

During the python2 to 3 migration there was some refactoring
Seems like some code specific to Route-decoding was removed
This patch is fixing the issue by re-adding this code and
tweaking it a little bit (to make it nice and clean :))

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
This commit is contained in:
Julien Fortin
2020-02-14 02:36:36 +01:00
parent 79bd5819b9
commit 49cb2925f1

View File

@@ -1362,19 +1362,19 @@ class AttributeIPAddress(Attribute):
if isinstance(parent_msg, Route):
if self.atype == Route.RTA_SRC:
self.value = ipnetwork.IPNetwork(self.value, parent_msg.src_len)
prefixlen = parent_msg.src_len
elif self.atype == Route.RTA_DST:
self.value = ipnetwork.IPNetwork(self.value, parent_msg.dst_len)
prefixlen = parent_msg.dst_len
if self.family in (AF_INET, AF_BRIDGE):
self.value = ipnetwork.IPNetwork(unpack(self.PACK, self.data[4:])[0], prefixlen, scope)
elif self.family == AF_INET6:
(data1, data2) = unpack(self.PACK, self.data[4:])
self.value = ipnetwork.IPNetwork(data1 << 64 | data2, prefixlen, scope)
else:
if self.family in (AF_INET, AF_BRIDGE):
self.value = ipnetwork.IPNetwork(unpack(self.PACK, self.data[4:])[0], prefixlen, scope)
elif self.family == AF_INET6:
(data1, data2) = unpack(self.PACK, self.data[4:])
self.value = ipnetwork.IPNetwork(data1 << 64 | data2, prefixlen, scope)
else:
self.log.debug("AttributeIPAddress: decode: unsupported address family ({})".format(self.family))
self.log.debug("AttributeIPAddress: decode: unsupported address family ({})".format(self.family))
except struct.error:
self.value = None