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
This commit is contained in:
Beniamino Galvani 2019-11-26 10:58:49 +01:00
parent 8c0e5b323a
commit 93e9010b75

View file

@ -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'",