Blob Blame History Raw
From 2b62887a170766241826ae8747c46d9b74c399ca Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Mon, 19 Oct 2015 14:14:17 +0200
Subject: [PATCH 1/4] manager: fix activation without specified device

For an explicit user-request, we relax some checks when searching for a suitable
device; such as requiring-carrier.

Without this patch, a connection-up while the device has no carrier yet,
would fail right away with "No suitable device found for this connection."

https://bugzilla.redhat.com/show_bug.cgi?id=1079353
Fixes: 0bfe635119facb8514e8f5824f599f4c4c3514e2
(cherry picked from commit cff3e93527b589138efa4beb829e5ed875e40973)
(cherry picked from commit 31b594561c08be233ef1e91734d9efe979d65954)
---
 src/nm-manager.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/nm-manager.c b/src/nm-manager.c
index d91a0d7..a6c23b1 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -2088,20 +2088,24 @@ nm_manager_get_connection_device (NMManager *self,
 
 static NMDevice *
 nm_manager_get_best_device_for_connection (NMManager *self,
-                                           NMConnection *connection)
+                                           NMConnection *connection,
+                                           gboolean for_user_request)
 {
 	const GSList *devices, *iter;
 	NMDevice *act_device = nm_manager_get_connection_device (self, connection);
+	NMDeviceCheckConAvailableFlags flags;
 
 	if (act_device)
 		return act_device;
 
+	flags = for_user_request ? NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST : NM_DEVICE_CHECK_CON_AVAILABLE_NONE;
+
 	/* Pick the first device that's compatible with the connection. */
 	devices = nm_manager_get_devices (self);
 	for (iter = devices; iter; iter = g_slist_next (iter)) {
 		NMDevice *device = NM_DEVICE (iter->data);
 
-		if (nm_device_check_connection_available (device, connection, NM_DEVICE_CHECK_CON_AVAILABLE_NONE, NULL))
+		if (nm_device_check_connection_available (device, connection, flags, NULL))
 			return device;
 	}
 
@@ -2581,7 +2585,7 @@ autoconnect_slaves (NMManager *manager,
 			nm_manager_activate_connection (manager,
 			                                slave_connection,
 			                                NULL,
-			                                nm_manager_get_best_device_for_connection (manager, slave_connection),
+			                                nm_manager_get_best_device_for_connection (manager, slave_connection, FALSE),
 			                                subject,
 			                                &local_err);
 			if (local_err) {
@@ -3092,7 +3096,7 @@ validate_activation_request (NMManager *self,
 			goto error;
 		}
 	} else
-		device = nm_manager_get_best_device_for_connection (self, connection);
+		device = nm_manager_get_best_device_for_connection (self, connection, TRUE);
 
 	if (!device) {
 		gboolean is_software = nm_connection_is_virtual (connection);
-- 
2.4.3


From 0ffd074d4ef555984542ce05f93c839487acfaca Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Mon, 19 Oct 2015 14:26:52 +0200
Subject: [PATCH 2/4] device: refactor using nm_clear_g_source() for
 priv->carrier_wait_id

(cherry picked from commit c89fd1ea76421ab63bbc227e4c12924f197e6585)
(cherry picked from commit 971a7611bdab8da2c1f6f3ef199f99999202b93a)
---
 src/devices/nm-device.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 5e413ba..8b2fa33 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -1325,9 +1325,7 @@ nm_device_set_carrier (NMDevice *self, gboolean carrier)
 		link_disconnect_action_cancel (self);
 		klass->carrier_changed (self, TRUE);
 
-		if (priv->carrier_wait_id) {
-			g_source_remove (priv->carrier_wait_id);
-			priv->carrier_wait_id = 0;
+		if (nm_clear_g_source (&priv->carrier_wait_id)) {
 			nm_device_remove_pending_action (self, "carrier wait", TRUE);
 			_carrier_wait_check_queued_act_request (self);
 		}
@@ -7113,9 +7111,7 @@ nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
 	 * a timeout is reached.
 	 */
 	if (nm_device_has_capability (self, NM_DEVICE_CAP_CARRIER_DETECT)) {
-		if (priv->carrier_wait_id)
-			g_source_remove (priv->carrier_wait_id);
-		else
+		if (!nm_clear_g_source (&priv->carrier_wait_id))
 			nm_device_add_pending_action (self, "carrier wait", TRUE);
 		priv->carrier_wait_id = g_timeout_add_seconds (5, carrier_wait_timeout, self);
 	}
@@ -9245,10 +9241,7 @@ dispose (GObject *object)
 
 	g_hash_table_remove_all (priv->available_connections);
 
-	if (priv->carrier_wait_id) {
-		g_source_remove (priv->carrier_wait_id);
-		priv->carrier_wait_id = 0;
-	}
+	nm_clear_g_source (&priv->carrier_wait_id);
 
 	_clear_queued_act_request (priv);
 
-- 
2.4.3


From 3b25f451e30a89c5a136f1644fc761934c97b556 Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Mon, 19 Oct 2015 14:44:38 +0200
Subject: [PATCH 3/4] device: don't wait for carrier when activating static
 connection

When the connection to be activated doesn't require carrier,
don't queue it to wait for it.

https://bugzilla.redhat.com/show_bug.cgi?id=1079353
Fixes: 0bfe635119facb8514e8f5824f599f4c4c3514e2
(cherry picked from commit 118de885eab0a161db291f1c2fb14690b891b00e)
(cherry picked from commit be3aee8b32b448e61b87d1e050f6c1a9d6a61afc)
---
 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 8b2fa33..c2a2b8a 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -6379,6 +6379,8 @@ _carrier_wait_check_act_request_must_queue (NMDevice *self, NMActRequest *req)
 		return FALSE;
 
 	connection = nm_act_request_get_connection (req);
+	if (!connection_requires_carrier (connection))
+		return FALSE;
 
 	if (!nm_device_check_connection_available (self, connection, NM_DEVICE_CHECK_CON_AVAILABLE_ALL, NULL)) {
 		/* We passed all @flags we have, and no @specific_object.
-- 
2.4.3


From 6287e99516aa822cdd546f57093197ebe962bf1c Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Mon, 19 Oct 2015 15:16:20 +0200
Subject: [PATCH 4/4] device: properly cancel queued activation request

We would leak the NMActivationRequest when carrier didn't
come within timeout. We must properly set the state of the
activation request.

https://bugzilla.redhat.com/show_bug.cgi?id=1079353
Fixes: 0bfe635119facb8514e8f5824f599f4c4c3514e2
(cherry picked from commit 839330cd39df8bb1c54cb35ce81f7c381b9090d1)
(cherry picked from commit d65897222acbda41442b4968d004a60c7cec57a4)
---
 src/devices/nm-device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index c2a2b8a..d4627ec 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -6355,7 +6355,7 @@ _carrier_wait_check_queued_act_request (NMDevice *self)
 	priv->queued_act_request_is_waiting_for_carrier = FALSE;
 	if (!priv->carrier) {
 		_LOGD (LOGD_DEVICE, "Cancel queued activation request as we have no carrier after timeout");
-		g_clear_object (&priv->queued_act_request);
+		_clear_queued_act_request (priv);
 	} else {
 		_LOGD (LOGD_DEVICE, "Activate queued activation request as we now have carrier");
 		queued_req = priv->queued_act_request;
-- 
2.4.3