From 53747c55abd6fa2488012c449f89a0564be22cb0 Mon Sep 17 00:00:00 2001 From: Julien Fortin Date: Wed, 27 Jun 2018 21:46:38 +0300 Subject: [PATCH] nlmanager: nlpacket: update AttributeMACAddress decode comments this commit adds some explanation/comments in the decode function of the AttributeMACAddress class. Some comments are moved around and placed in the right location. Signed-off-by: Julien Fortin --- ifupdown2/nlmanager/nlpacket.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ifupdown2/nlmanager/nlpacket.py b/ifupdown2/nlmanager/nlpacket.py index 94463d0..f2cf600 100644 --- a/ifupdown2/nlmanager/nlpacket.py +++ b/ifupdown2/nlmanager/nlpacket.py @@ -533,14 +533,17 @@ class AttributeMACAddress(Attribute): def decode(self, parent_msg, data): self.decode_length_type(data) - + + # IFLA_ADDRESS and IFLA_BROADCAST attributes for all interfaces has been a + # 6-byte MAC address. But the GRE interface uses a 4-byte IP address and + # GREv6 uses a 16-byte IPv6 address for this attribute. try: - # MAC Address + # GRE interface uses a 4-byte IP address for this attribute if self.length == 8: self.value = IPv4Address(unpack('>L', self.data[4:])[0]) self.value_int = int(self.value) self.value_int_str = str(self.value_int) - # GRE interface uses a 4-byte IP address for this attribute + # MAC Address elif self.length == 10: (data1, data2) = unpack(self.PACK, self.data[4:]) self.value = mac_int_to_str(data1 << 16 | data2)