summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2020-07-02 13:47:22 +0200
committerThomas Haller <thaller@redhat.com>2020-08-17 18:10:56 +0200
commit27f224a76552ed218d60acbf84090ffe9a3a70a2 (patch)
treeaa4b079a1920bb53ffd37e81f137a23e922de517
parent6a40b79ce0de2dd9061d3bd5676eea694d0c5dad (diff)
downloadNetworkManager-27f224a76552ed218d60acbf84090ffe9a3a70a2.tar.gz
device: don't reset the MAC without ifindex
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. (cherry picked from commit 77b6ce7d04f6c88e78fb7f1972549956e00e1f4b) (cherry picked from commit 791a888cad3d260675781c0ed30acf13cc1194f7) (cherry picked from commit e1f76e70447049487b2d8240ce12007624ab3c29) (cherry picked from commit 5f22c06c53d9ae9003cd17603d6d6ff3e16f195b) (cherry picked from commit 6beaa83d32d4c2784771b114725c34056f7083bf)
-rw-r--r--src/devices/nm-device.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 86abdc183b..7fea915858 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -14649,17 +14649,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;