From b4fe3b7cd97df2360b49b8bcf3b7f065384519a3 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Mon, 3 Nov 2014 21:22:09 +0100 Subject: [PATCH 1/5] libnm: Drop a wrong assert An active connection object could disappear from the bus before its removal from NMManager:active-connections is signalled -- don't assert it's gone from there already. Here /o/fd/NM/ActiveConnection/81 disappears shortly after it's added: libnm-Message: PC: (0x9ebd088) NMManager:active-connections => '['/org/freedesktop/NetworkManager/ActiveConnection/81', '/org/freedesktop/NetworkManager/ActiveConnection/80']' (ao / NMActiveConnection) libnm-Message: PC: (0x9ebd088) NMManager:activating-connection => ''/'' (o / NMActiveConnection) libnm-Message: PC: (0x9ed1458) NMDeviceTeam:state => '110' (u) libnm-Message: PC: (0x9ed1458) NMDeviceTeam:state-reason => '(110, 0)' ((uu)) libnm-Message: PC: (0x9ece9a0) NMActiveConnection:state => '3' (u) libnm-Message: PC: (0x9ebd088) NMManager:state => '20' (u) libnm-Message: PC: (0x9ebd088) NMManager:devices => '['/org/freedesktop/NetworkManager/Devices/0', '/org/freedesktop/NetworkManager/Devices/2', '/org/freedesktop/NetworkManager/Devices/3']' (ao / NMDevice) libnm-Message: PC: (0x9ebd088) NMManager:active-connections => '['/org/freedesktop/NetworkManager/ActiveConnection/81', '/org/freedesktop/NetworkManager/ActiveConnection/80']' (ao / NMActiveConnection) libnm-Message: PC: (0x9ece9a0) NMActiveConnection:state => '4' (u) libnm-Message: PC: (0x9ece9a0) NMActiveConnection:devices => '[]' (ao / NMDevice) libnm-Message: Could not create object for /org/freedesktop/NetworkManager/ActiveConnection/81: Method "GetAll" with signature "s" on interface "org.freedesktop.DBus.Properties" doesn't exist (process:18042): libnm-CRITICAL **: object_creation_failed: assertion 'find_active_connection_by_path (self, failed_path) == NULL' failed --- libnm/nm-manager.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libnm/nm-manager.c b/libnm/nm-manager.c index d60845edc..8d78d221b 100644 --- a/libnm/nm-manager.c +++ b/libnm/nm-manager.c @@ -1043,8 +1043,6 @@ object_creation_failed (NMObject *object, const char *failed_path) GError *error; GSList *iter; - g_return_if_fail (find_active_connection_by_path (self, failed_path) == NULL); - /* A newly activated connection failed due to some immediate error * and disappeared from active connection list. Make sure the * callback gets called. From 42b9e8283969a851751a9eff5c767ae99d717156 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Mon, 3 Nov 2014 23:25:23 +0100 Subject: [PATCH 2/5] libnm: Complete activation when ActiveConnection abruptly disappears A NMActiveConnection may disappear before a match with NMDevice is found. In such case recheck_pending_activations() would never call the activation callback and the client would hang indefinitely: libnm-Message: PC: (0x95bf088) NMManager:active-connections => '['/org/freedesktop/NetworkManager/ActiveConnection/225']' (ao / NMActiveConnection) libnm-Message: PC: (0x95bf088) NMManager:activating-connection => ''/'' (o / NMActiveConnection) libnm-Message: PC: (0x95d0a28) NMActiveConnection:state => '4' (u) libnm-Message: PC: (0x95d0a28) NMActiveConnection:devices => '[]' (ao / NMDevice) libnm-Message: PC: (0x95bf088) NMManager:active-connections => '[]' (ao / NMActiveConnection) *hang* Let's listen for active-connection-removed and tear down the activation with an error if the removed connection is one we're activating. --- libnm/nm-manager.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libnm/nm-manager.c b/libnm/nm-manager.c index 8d78d221b..fc558620c 100644 --- a/libnm/nm-manager.c +++ b/libnm/nm-manager.c @@ -743,6 +743,8 @@ typedef struct { char *new_connection_path; } ActivateInfo; +static void active_removed (NMObject *object, NMActiveConnection *active, gpointer user_data); + static void activate_info_complete (ActivateInfo *info, NMActiveConnection *active, @@ -750,6 +752,7 @@ activate_info_complete (ActivateInfo *info, { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (info->manager); + g_signal_handlers_disconnect_by_func (info->manager, G_CALLBACK (active_removed), info); if (active) g_simple_async_result_set_op_res_gpointer (info->simple, g_object_ref (active), g_object_unref); else @@ -836,6 +839,22 @@ activation_cancelled (GCancellable *cancellable, g_clear_error (&error); } +static void +active_removed (NMObject *object, NMActiveConnection *active, gpointer user_data) +{ + ActivateInfo *info = user_data; + GError *error = NULL; + + if (strcmp (info->active_path, nm_object_get_path (NM_OBJECT (active)))) + return; + + error = g_error_new_literal (NM_CLIENT_ERROR, + NM_CLIENT_ERROR_FAILED, + _("Active connection could not be attached to the device")); + activate_info_complete (info, NULL, error); + g_clear_error (&error); +} + static void activate_cb (GObject *object, GAsyncResult *result, @@ -852,6 +871,9 @@ activate_cb (GObject *object, G_CALLBACK (activation_cancelled), info); } + g_signal_connect (info->manager, "active-connection-removed", + G_CALLBACK (active_removed), info); + recheck_pending_activations (info->manager); } else { g_dbus_error_strip_remote_error (error); From 5aa93e55183ba3b67355f384ac54b4dd7e047d61 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Sun, 19 Oct 2014 15:08:44 +0200 Subject: [PATCH 3/5] connections: Don't give up if we've not seen an active connection yet It will appear later on. https://bugzilla.redhat.com/show_bug.cgi?id=1149200 --- clients/cli/connections.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 3f921a400..65d900b9b 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -1736,7 +1736,7 @@ device_state_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data) g_print (_("Connection successfully activated (master waiting for slaves) (D-Bus active path: %s)\n"), nm_object_get_path (NM_OBJECT (active))); quit (); - } else if (ac_state != NM_ACTIVE_CONNECTION_STATE_ACTIVATING) { + } else if (active && ac_state != NM_ACTIVE_CONNECTION_STATE_ACTIVATING) { g_string_printf (nmc->return_text, _("Error: Connection activation failed.")); nmc->return_value = NMC_RESULT_ERROR_CON_ACTIVATION; quit (); From 842648a99211441c4b7c41895ecbabf456f285c0 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Tue, 4 Nov 2014 09:38:01 +0100 Subject: [PATCH 4/5] team: Don't let teamd rip off the link when it terminates We might be reactivating a connection on the device and don't want it to go away. In other cases we still take care of the link deletion ourselves. --- src/devices/team/nm-device-team.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c index df2756201..3c949258c 100644 --- a/src/devices/team/nm-device-team.c +++ b/src/devices/team/nm-device-team.c @@ -453,6 +453,7 @@ teamd_start (NMDevice *device, NMSettingTeam *s_team) g_ptr_array_add (argv, (gpointer) "-n"); g_ptr_array_add (argv, (gpointer) "-U"); g_ptr_array_add (argv, (gpointer) "-D"); + g_ptr_array_add (argv, (gpointer) "-N"); g_ptr_array_add (argv, (gpointer) "-t"); g_ptr_array_add (argv, (gpointer) iface); From 892602c912cd3cb8e2b4ddecd5f99649c4acab2b Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Tue, 4 Nov 2014 09:41:42 +0100 Subject: [PATCH 5/5] device: Don't delete the link if a re-activation is scheduled --- src/devices/nm-device.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index d9fdd1bb8..efb7f25d2 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -5081,6 +5081,8 @@ delete_on_deactivate_check_and_schedule (NMDevice *self, int ifindex) return; if (!priv->is_nm_owned) return; + if (priv->queued_act_request) + return; if (!nm_device_is_software (self)) return; if (nm_device_get_state (self) == NM_DEVICE_STATE_UNMANAGED)