summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-02-06 11:35:21 +0100
committerThomas Haller <thaller@redhat.com>2018-02-06 11:39:50 +0100
commit66ea468c1f9503063a30e121ca6becd2df889738 (patch)
treecc8c3a58ea1c5bb178919ab2b594bc62b451ce16
parent5f8f54d2b038132aec67e1db4792af34d1a573ad (diff)
downloadNetworkManager-th/device-activation-fix-rh1537160.tar.gz
device: gracefully handle unmanaged device during _device_activate()th/device-activation-fix-rh1537160
-rw-r--r--src/devices/nm-device.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 67df676b70..94906224ac 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -10160,7 +10160,7 @@ _device_activate (NMDevice *self, NMActRequest *req)
g_return_if_fail (NM_IS_DEVICE (self));
g_return_if_fail (NM_IS_ACT_REQUEST (req));
- g_return_if_fail (nm_device_get_managed (self, FALSE));
+ nm_assert (nm_device_is_real (self));
/* Ensure the activation request is still valid; the master may have
* already failed in which case activation of this device should not proceed.
@@ -10168,6 +10168,17 @@ _device_activate (NMDevice *self, NMActRequest *req)
if (nm_active_connection_get_state (NM_ACTIVE_CONNECTION (req)) >= NM_ACTIVE_CONNECTION_STATE_DEACTIVATING)
return;
+ if (!nm_device_get_managed (self, FALSE)) {
+ /* It's unclear why the device would be unmanaged at this point.
+ * Just to be sure, handle it and error out. */
+ _LOGE (LOGD_DEVICE, "Activation: failed activating connection '%s' because device is still unmanaged",
+ nm_active_connection_get_settings_connection_id ((NMActiveConnection *) req));
+ nm_active_connection_set_state_fail ((NMActiveConnection *) req,
+ NM_ACTIVE_CONNECTION_STATE_REASON_UNKNOWN,
+ NULL);
+ return;
+ }
+
connection = nm_act_request_get_applied_connection (req);
nm_assert (connection);