summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-11-02 18:48:02 +0100
committerThomas Haller <thaller@redhat.com>2017-11-08 11:45:33 +0100
commitbfe66fb8f410a003f4d2ae05cba9baff798ddbad (patch)
tree90c815fb35264400f319a03e103e8bf54905b432
parent45da11f37068059df5d36115d80bebd15fc92188 (diff)
downloadNetworkManager-bfe66fb8f410a003f4d2ae05cba9baff798ddbad.tar.gz
policy: optimize nm_device_can_auto_connect() to not check nm_device_autoconnect_allowed()
-rw-r--r--src/devices/nm-device.c10
-rw-r--r--src/nm-policy.c3
2 files changed, 11 insertions, 2 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 1dd24fe8f0..6496aadea0 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -4372,8 +4372,14 @@ nm_device_can_auto_connect (NMDevice *self,
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
g_return_val_if_fail (!specific_object || !*specific_object, FALSE);
- if (!nm_device_autoconnect_allowed (self))
- return FALSE;
+ /* the caller must ensure that nm_device_autoconnect_allowed() returns
+ * TRUE as well. This is done, because nm_device_can_auto_connect()
+ * has only one caller, and it iterates over a list of available
+ * connections.
+ *
+ * Hence, we don't need to re-check nm_device_autoconnect_allowed()
+ * over and over again. The caller is supposed to do that. */
+ nm_assert (nm_device_autoconnect_allowed (self));
s_con = nm_connection_get_setting_connection (connection);
if (!nm_setting_connection_get_autoconnect (s_con))
diff --git a/src/nm-policy.c b/src/nm-policy.c
index f5c72a1dcd..95bf5a03e7 100644
--- a/src/nm-policy.c
+++ b/src/nm-policy.c
@@ -1226,6 +1226,9 @@ auto_activate_device (NMPolicy *self,
if (nm_device_get_act_request (device))
return;
+ if (!nm_device_autoconnect_allowed (device))
+ return;
+
connections = nm_manager_get_activatable_connections (priv->manager, &len, TRUE);
if (!connections[0])
return;