diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2020-07-02 13:47:22 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2020-07-02 13:50:47 +0200 |
commit | ff96b5dee9698730e0c698e3f7cbede2bae70ee6 (patch) | |
tree | a1006a75158c2eca03d8476e832cdef7c4c8f7fe | |
parent | e83cd5b4bcc452b253cf2f13f70d89e4ba7badc9 (diff) | |
download | NetworkManager-bg/ovs-mac-pt2.tar.gz |
device: don't reset the MAC without ifindexbg/ovs-mac-pt2
nm_device_cleanup() can be called when the device no longer has an
ifindex. In such case, don't try to reset the MAC address as that
would lead to an assertion failure.
-rw-r--r-- | src/devices/nm-device.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 90178b68fe..5cb12405f6 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -15602,17 +15602,19 @@ nm_device_cleanup (NMDevice *self, NMDeviceStateReason reason, CleanupType clean nm_device_update_metered (self); - /* during device cleanup, we want to reset the MAC address of the device - * to the initial state. - * - * We certainly want to do that when reaching the UNMANAGED state... */ - if (nm_device_get_state (self) <= NM_DEVICE_STATE_UNMANAGED) - nm_device_hw_addr_reset (self, "unmanage"); - else { - /* for other device states (UNAVAILABLE, DISCONNECTED), allow the - * device to overwrite the reset behavior, so that Wi-Fi can set - * a randomized MAC address used during scanning. */ - NM_DEVICE_GET_CLASS (self)->deactivate_reset_hw_addr (self); + if (ifindex > 0) { + /* during device cleanup, we want to reset the MAC address of the device + * to the initial state. + * + * We certainly want to do that when reaching the UNMANAGED state... */ + if (nm_device_get_state (self) <= NM_DEVICE_STATE_UNMANAGED) + nm_device_hw_addr_reset (self, "unmanage"); + else { + /* for other device states (UNAVAILABLE, DISCONNECTED), allow the + * device to overwrite the reset behavior, so that Wi-Fi can set + * a randomized MAC address used during scanning. */ + NM_DEVICE_GET_CLASS (self)->deactivate_reset_hw_addr (self); + } } priv->mtu_source = NM_DEVICE_MTU_SOURCE_NONE; |