From f392da2c78a2a4c1b0ceebfb16eab28e69e01f7c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 22 Aug 2016 17:37:20 +0200 Subject: [PATCH] device: fix queued activation failure due to link disconnected When activating a connection, it may fail with nmcli reporting: $ nmcli connection up id "Wired Connection 1" Error: Connection activation failed: Active connection removed before it was initialized This should be easily reproducible by having a connection "Wired Connection 1" with cloned-mac-address set to random. When the connection is already active on a device, re-activating with $ nmcli connection up id "Wired Connection 1" fails. We first create a queued-activation and tear down the existing connection: device (enp0s25): state change: deactivating -> disconnected (reason 'new-activation') Shortly after we see: device[0x557d02cdb0c0] (enp0s25): set-hw-addr: setting MAC address to 'AA:BB:CC:DD:EE:FF' (reset, deactivate)... device[0x557d02cdb0c0] (enp0s25): taking down device later, we get: device (enp0s25): link disconnected device[0x557d02cdb0c0] (enp0s25): queued state change to unavailable due to carrier-changed (id 17290) in the meantime, the queued activation request starts: device (enp0s25): Activation: starting connection 'my-wired' (ca058ec5-8a47-4e1e-b38e-962b71c4699e) but the device already transitions to unavailable device[0x557d02cdb0c0] (enp0s25): running queued state change to unavailable (id 17290) device (enp0s25): state change: disconnected -> unavailable (reason 'carrier-changed') [30 20 40] which kills the new activation request: active-connection[0x557d02c10e40]: set state deactivated (was unknown) Just delay a carrier-lost handling if we have any queued activation requests. (cherry picked from commit d4e9b30320184f0f9e09da375bb6ec549d6ab337) --- src/devices/nm-device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 9d677e0a9..4807a9ba1 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -1726,7 +1726,8 @@ nm_device_set_carrier (NMDevice *self, gboolean carrier) nm_device_remove_pending_action (self, "carrier wait", TRUE); _carrier_wait_check_queued_act_request (self); } - } else if (state <= NM_DEVICE_STATE_DISCONNECTED) { + } else if ( state <= NM_DEVICE_STATE_DISCONNECTED + && !priv->queued_act_request) { _LOGI (LOGD_DEVICE, "link disconnected"); klass->carrier_changed (self, FALSE); } else {