From c54faa4801e5c5155a4a9fb0ed6078d13dc57df6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Tue, 15 Apr 2014 11:51:56 +0200 Subject: [PATCH] policy: check device state before changing it for secondaries (rh #1055099) We have to check the previous base device state in process_secondaries() when making a state change. The device might got disconnected in the meantime and thus the transition from DISCONNECTED to ACTIVATED or FAILED would have been incorrect. Logs showing the problem: NetworkManager[2655]: (eth0): disconnecting for new activation request. NetworkManager[2655]: (eth0): device state change: secondaries -> deactivating (reason 'none') [90 110 0] NetworkManager[2655]: (eth0): device state change: deactivating -> disconnected (reason 'none') [110 30 0] NetworkManager[2655]: (eth0): deactivating device (reason 'none') [0] NetworkManager[2655]: (eth0): canceled DHCP transaction, DHCP client pid 11409 NetworkManager[2655]: NetworkManager state is now DISCONNECTED NetworkManager[2655]: (devices/nm-device.c:6591):nm_device_state_changed: runtime check failed: (priv->in_state_changed == FALSE) NetworkManager[2655]: (eth0): device state change: disconnected -> failed (reason 'secondary-connection-failed') [30 120 54] NetworkManager[2655]: Activation (eth0) failed for connection '' NetworkManager[2655]: (eth0): add_pending_action (4): 'queued state change to disconnected' already added NetworkManager[2655]: file devices/nm-device.c: line 7682 (nm_device_add_pending_action): should not be reached NetworkManager[2655]: Activation (eth0) starting connection 'ethernet-12' NetworkManager[2655]: Activation (eth0) Stage 1 of 5 (Device Prepare) scheduled... NetworkManager[2655]: (eth0): device state change: failed -> disconnected (reason 'none') [120 30 0] NetworkManager[2655]: (eth0): deactivating device (reason 'none') [0] NetworkManager[2655]: (eth0): remove_pending_action (2): 'queued state change to disconnected' never added NetworkManager[2655]: file devices/nm-device.c: line 7733 (nm_device_remove_pending_action): should not be reached NetworkManager[2655]: VPN service 'openvpn' disappeared https://bugzilla.redhat.com/show_bug.cgi?id=1055099 https://bugzilla.redhat.com/show_bug.cgi?id=1055101 --- src/nm-policy.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/nm-policy.c b/src/nm-policy.c index f454d90fbf..380f4ced47 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -1087,7 +1087,8 @@ process_secondaries (NMPolicy *policy, /* No secondary UUID remained -> remove the secondary data item */ priv->pending_secondaries = g_slist_remove (priv->pending_secondaries, secondary_data); pending_secondary_data_free (secondary_data); - nm_device_state_changed (item_device, NM_DEVICE_STATE_ACTIVATED, NM_DEVICE_STATE_REASON_NONE); + if (nm_device_get_state (item_device) == NM_DEVICE_STATE_SECONDARIES) + nm_device_state_changed (item_device, NM_DEVICE_STATE_ACTIVATED, NM_DEVICE_STATE_REASON_NONE); break; } } else { @@ -1098,8 +1099,10 @@ process_secondaries (NMPolicy *policy, /* Secondary connection failed -> do not watch other connections */ priv->pending_secondaries = g_slist_remove (priv->pending_secondaries, secondary_data); pending_secondary_data_free (secondary_data); - nm_device_state_changed (item_device, NM_DEVICE_STATE_FAILED, - NM_DEVICE_STATE_REASON_SECONDARY_CONNECTION_FAILED); + if ( nm_device_get_state (item_device) == NM_DEVICE_STATE_SECONDARIES + || nm_device_get_state (item_device) == NM_DEVICE_STATE_ACTIVATED) + nm_device_state_changed (item_device, NM_DEVICE_STATE_FAILED, + NM_DEVICE_STATE_REASON_SECONDARY_CONNECTION_FAILED); break; } }