There are cases when IFLA_ADDRESS is not included in the netlink
message, for example when vxlan device is created with gpe flag:
ip link add vxlan0 type vxlan external gpe
When the IFLA_ADDRESS is not present in the message the None value
is passed to hwaddress() parser function that raises an exception.
A check is added to hwaddr property whether the IFLA_ADDRESS attribute
is present. If it's not the parser function is bypassed and None is
returned.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
lnst/Devices/Device.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lnst/Devices/Device.py b/lnst/Devices/Device.py
index fd5ef86b..adebd117 100644
--- a/lnst/Devices/Device.py
+++ b/lnst/Devices/Device.py
@@ -416,7 +416,10 @@ class Device(object, metaclass=DeviceMeta):
Returns a HWAddress object representing the hardware address of the
device as reported by the kernel.
"""
- return hwaddress(self._nl_msg.get_attr("IFLA_ADDRESS"))
+ if self._nl_msg.get_attr("IFLA_ADDRESS"):
+ return hwaddress(self._nl_msg.get_attr("IFLA_ADDRESS"))
+ else:
+ return None
@hwaddr.setter
def hwaddr(self, addr):
--
2.26.3