summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-04-20 13:31:30 +0200
committerThomas Haller <thaller@redhat.com>2017-04-20 13:42:05 +0200
commit31fa24176d3afb5879950a6ebfb976b60e7bdf39 (patch)
tree3a473a879a00b27e4d7a47729a33a28f99d36e65
parent83fa3a041ba8762bb857e412427508193ea1cc4a (diff)
downloadNetworkManager-th/device-assume-guess-rh1443878.tar.gz
fixup! device: assume matching connections during first startth/device-assume-guess-rh1443878
-rw-r--r--src/nm-manager.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 7b2607b3ac..2490025574 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -1679,12 +1679,6 @@ done:
g_clear_error (&error);
}
-static gboolean
-match_connection_filter (NMConnection *connection, gpointer user_data)
-{
- return nm_device_check_connection_compatible (NM_DEVICE (user_data), connection);
-}
-
/**
* get_existing_connection:
* @manager: #NMManager instance
@@ -1713,6 +1707,7 @@ get_existing_connection (NMManager *self,
NMDevice *master = NULL;
int ifindex = nm_device_get_ifindex (device);
NMSettingsConnection *matched;
+ NMSettingsConnection *connection_checked = NULL;
if (out_generated)
*out_generated = FALSE;
@@ -1757,11 +1752,12 @@ get_existing_connection (NMManager *self,
* the generated connection instead.
*/
if ( assume_connection_uuid
- && (matched = nm_settings_get_connection_by_uuid (priv->settings, assume_connection_uuid))
- && !active_connection_find_first (self, matched, NULL,
- NM_ACTIVE_CONNECTION_STATE_DEACTIVATING)) {
+ && (connection_checked = nm_settings_get_connection_by_uuid (priv->settings, assume_connection_uuid))
+ && !active_connection_find_first (self, connection_checked, NULL,
+ NM_ACTIVE_CONNECTION_STATE_DEACTIVATING)
+ && nm_device_check_connection_compatible (device, NM_CONNECTION (connection_checked))) {
NMConnection *const connections[] = {
- NM_CONNECTION (matched),
+ NM_CONNECTION (connection_checked),
NULL,
};
@@ -1770,19 +1766,27 @@ get_existing_connection (NMManager *self,
nm_device_has_carrier (device),
nm_device_get_ip4_route_metric (device),
nm_device_get_ip6_route_metric (device),
- match_connection_filter,
- device));
+ NULL, NULL));
} else
matched = NULL;
if (!matched && guess_assume) {
gs_free NMSettingsConnection **connections = NULL;
- guint len;
+ guint len, i, j;
/* the state file doesn't indicate a connection UUID to assume. Search the
* persistent connections for a matching candidate. */
connections = nm_manager_get_activatable_connections (self, &len, FALSE);
if (len > 0) {
+ for (i = 0, j = 0; i < len; i++) {
+ NMConnection *con = NM_CONNECTION (connections[i]);
+
+ if ( con != NM_CONNECTION (connection_checked)
+ && nm_device_check_connection_compatible (device, con))
+ connections[j++] = connections[i];
+ }
+ connections[j] = NULL;
+ len = j;
g_qsort_with_data (connections, len, sizeof (connections[0]),
nm_settings_connection_cmp_timestamp_p_with_data, NULL);
@@ -1791,8 +1795,7 @@ get_existing_connection (NMManager *self,
nm_device_has_carrier (device),
nm_device_get_ip4_route_metric (device),
nm_device_get_ip6_route_metric (device),
- match_connection_filter,
- device));
+ NULL, NULL));
}
}