From 93e9010b75700c8a0191f10d92e8f21d2ca988c6 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 26 Nov 2019 10:58:49 +0100 Subject: [PATCH] device: don't transition assumed devices to FAILED before ACTIVATED If the activation of an assumed device fails, we first set the device state to FAILED and then to ACTIVATED. In the FAILED state, the active connection transitions to DEACTIVATED and clears its device pointer; hence we end up with an inconsistent state which causes assertion failures in other parts of the code (for example, get_best_ip_config() assumes that the device of the best active connection is not NULL). Don't first transition to FAILED and then to ACTIVATED, just set the latter. https://bugzilla.redhat.com/show_bug.cgi?id=1737774 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/351 --- src/devices/nm-device.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index c4e7b80c69..c50aa42ac7 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -15476,6 +15476,13 @@ _set_state_full (NMDevice *self, old_state = priv->state; + if ( state == NM_DEVICE_STATE_FAILED + && nm_device_sys_iface_state_is_external_or_assume (self)) { + /* Avoid tearing down assumed connection, assume it's connected */ + state = NM_DEVICE_STATE_ACTIVATED; + reason = NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED; + } + /* Do nothing if state isn't changing, but as a special case allow * re-setting UNAVAILABLE if the device is missing firmware so that we * can retry device initialization. @@ -15727,14 +15734,6 @@ _set_state_full (NMDevice *self, */ _cancel_activation (self); - if (nm_device_sys_iface_state_is_external_or_assume (self)) { - /* Avoid tearing down assumed connection, assume it's connected */ - nm_device_queue_state (self, - NM_DEVICE_STATE_ACTIVATED, - NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED); - break; - } - sett_conn = nm_device_get_settings_connection (self); _LOGW (LOGD_DEVICE | LOGD_WIFI, "Activation: failed for connection '%s'",