From 86ceade93afaafb5c29291bd2c62e729016bd453 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 22 Dec 2015 10:04:24 +0100 Subject: [PATCH] device/vlan: fix failed assertion in parent_hwaddr_changed() Parent MAC can be NULL if the interface has gone, fix the following failed assertion: [devices/nm-device-vlan.c:107] parent_hwaddr_changed(): (vlan1): parent hardware address changed nm_device_set_hw_addr: assertion 'addr != NULL' failed While at it, improve logging by printing the new MAC address. Fixes: e6d7fee5a617632acae02e12b1ec6156842df788 (cherry picked from commit e1d06d7a0bc4773ade5659942672cf818eb9df4c) --- src/devices/nm-device-vlan.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index b330397f2d..7cce6593dd 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -96,7 +96,7 @@ parent_hwaddr_changed (NMDevice *parent, NMDeviceVlan *self = NM_DEVICE_VLAN (user_data); NMConnection *connection; NMSettingWired *s_wired; - const char *cloned_mac = NULL; + const char *cloned_mac = NULL, *new_mac; /* Never touch assumed devices */ if (nm_device_uses_assumed_connection (self)) @@ -112,9 +112,13 @@ parent_hwaddr_changed (NMDevice *parent, cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); if (!cloned_mac) { - _LOGD (LOGD_VLAN, "parent hardware address changed"); - nm_device_set_hw_addr (self, nm_device_get_hw_address (parent), - "set", LOGD_VLAN); + new_mac = nm_device_get_hw_address (parent); + _LOGD (LOGD_VLAN, "parent hardware address changed to %s%s%s", + NM_PRINT_FMT_QUOTE_STRING (new_mac)); + if (new_mac) { + nm_device_set_hw_addr (self, nm_device_get_hw_address (parent), + "set", LOGD_VLAN); + } } }