summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2018-04-04 13:36:59 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2018-04-04 13:36:59 +0200
commitcc1920d71470042c4e0837848da9183526b663d0 (patch)
treeb2dc215ac22262cd579d542cf7fab9a4a28936bd
parenteb8257dea5802a004af9cccacb30af98440e2172 (diff)
parent346064189ae15c4d524a6e25830168e7550d2dd8 (diff)
downloadNetworkManager-cc1920d71470042c4e0837848da9183526b663d0.tar.gz
core: merge branch 'bg/restart-assume-rh1551958'
https://bugzilla.redhat.com/show_bug.cgi?id=1551958
-rw-r--r--src/NetworkManagerUtils.c24
-rw-r--r--src/NetworkManagerUtils.h1
-rw-r--r--src/nm-manager.c66
-rw-r--r--src/tests/test-general.c2
4 files changed, 23 insertions, 70 deletions
diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c
index 12d46697ae..72f2cbd568 100644
--- a/src/NetworkManagerUtils.c
+++ b/src/NetworkManagerUtils.c
@@ -767,10 +767,6 @@ check_possible_match (NMConnection *orig,
* @connections: a (optionally pre-sorted) list of connections from which to
* find a matching connection to @original based on "inferrable" properties
* @original: the #NMConnection to find a match for from @connections
- * @indicated: whether the match is already hinted/indicated. That is the
- * case when we found the connection in the state file from a previous run.
- * In this case, we perform a relexed check, as we have a good hint
- * that the connection actually matches.
* @device_has_carrier: pass %TRUE if the device that generated @original has
* a carrier, %FALSE if not
* @match_filter_func: a function to check whether each connection from @connections
@@ -790,7 +786,6 @@ check_possible_match (NMConnection *orig,
NMConnection *
nm_utils_match_connection (NMConnection *const*connections,
NMConnection *original,
- gboolean indicated,
gboolean device_has_carrier,
gint64 default_v4_metric,
gint64 default_v6_metric,
@@ -811,24 +806,7 @@ nm_utils_match_connection (NMConnection *const*connections,
continue;
}
- if (indicated) {
- NMSettingConnection *s_orig, *s_cand;
-
- s_orig = nm_connection_get_setting_connection (original);
- s_cand = nm_connection_get_setting_connection (candidate);
-
- /* It is indicated that this connection matches. Assume we have
- * a match, but check for particular differences that let us
- * reject the candidate. */
- if (!nm_streq0 (nm_setting_connection_get_connection_type (s_orig),
- nm_setting_connection_get_connection_type (s_cand)))
- continue;
- if (!nm_streq0 (nm_setting_connection_get_slave_type (s_orig),
- nm_setting_connection_get_slave_type (s_cand)))
- continue;
-
- /* this is good enough for a match */
- } else if (!nm_connection_diff (original, candidate, NM_SETTING_COMPARE_FLAG_INFERRABLE, &diffs)) {
+ if (!nm_connection_diff (original, candidate, NM_SETTING_COMPARE_FLAG_INFERRABLE, &diffs)) {
if (!best_match) {
best_match = check_possible_match (original, candidate, diffs, device_has_carrier,
default_v4_metric, default_v6_metric);
diff --git a/src/NetworkManagerUtils.h b/src/NetworkManagerUtils.h
index 13bdb67e85..54ba10fe28 100644
--- a/src/NetworkManagerUtils.h
+++ b/src/NetworkManagerUtils.h
@@ -41,7 +41,6 @@ typedef gboolean (NMUtilsMatchFilterFunc) (NMConnection *connection, gpointer us
NMConnection *nm_utils_match_connection (NMConnection *const*connections,
NMConnection *original,
- gboolean indicated,
gboolean device_has_carrier,
gint64 default_v4_metric,
gint64 default_v6_metric,
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 5b77e6adc0..7629d0df34 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -2125,12 +2125,12 @@ get_existing_connection (NMManager *self,
gboolean *out_generated)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
- gs_unref_object NMConnection *connection = NULL;
+ NMConnection *connection = NULL;
NMSettingsConnection *added = NULL;
GError *error = NULL;
NMDevice *master = NULL;
int ifindex = nm_device_get_ifindex (device);
- NMSettingsConnection *matched;
+ NMSettingsConnection *matched = NULL;
NMSettingsConnection *connection_checked = NULL;
gboolean assume_state_guess_assume = FALSE;
const char *assume_state_connection_uuid = NULL;
@@ -2161,54 +2161,31 @@ get_existing_connection (NMManager *self,
}
}
- /* The core of the API is nm_device_generate_connection() function and
- * update_connection() virtual method and the convenient connection_type
- * class attribute. Subclasses supporting the new API must have
- * update_connection() implemented, otherwise nm_device_generate_connection()
- * returns NULL.
- */
- connection = nm_device_generate_connection (device, master, &maybe_later, &error);
- if (!connection) {
- if (!maybe_later)
- nm_device_assume_state_reset (device);
- _LOG2D (LOGD_DEVICE, device, "assume: cannot generate connection: %s",
- error->message);
- g_error_free (error);
- return NULL;
- }
-
nm_device_assume_state_get (device,
&assume_state_guess_assume,
&assume_state_connection_uuid);
- /* Now we need to compare the generated connection to each configured
- * connection. The comparison function is the heart of the connection
- * assumption implementation and it must compare the connections very
- * carefully to sort out various corner cases. Also, the comparison is
- * not entirely symmetric.
- *
- * When no configured connection matches the generated connection, we keep
- * the generated connection instead.
- */
if ( assume_state_connection_uuid
&& (connection_checked = nm_settings_get_connection_by_uuid (priv->settings, assume_state_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 (connection_checked),
- NULL,
- };
-
- matched = NM_SETTINGS_CONNECTION (nm_utils_match_connection (connections,
- connection,
- TRUE,
- nm_device_has_carrier (device),
- nm_device_get_route_metric (device, AF_INET),
- nm_device_get_route_metric (device, AF_INET6),
- NULL, NULL));
- } else
- matched = NULL;
+ && nm_device_check_connection_compatible (device, NM_CONNECTION (connection_checked)))
+ matched = connection_checked;
+
+ if (!matched) {
+ /* The core of the API is nm_device_generate_connection() function and
+ * update_connection() virtual method and the convenient connection_type
+ * class attribute. Subclasses supporting the new API must have
+ * update_connection() implemented, otherwise nm_device_generate_connection()
+ * returns NULL.
+ */
+ connection = nm_device_generate_connection (device, master, &maybe_later, &error);
+ if (!connection) {
+ if (!maybe_later)
+ nm_device_assume_state_reset (device);
+ _LOG2D (LOGD_DEVICE, device, "assume: cannot generate connection: %s", error->message);
+ g_error_free (error);
+ return NULL;
+ }
+ }
if (!matched && assume_state_guess_assume) {
gs_free NMSettingsConnection **connections = NULL;
@@ -2232,7 +2209,6 @@ get_existing_connection (NMManager *self,
matched = NM_SETTINGS_CONNECTION (nm_utils_match_connection ((NMConnection *const*) connections,
connection,
- FALSE,
nm_device_has_carrier (device),
nm_device_get_route_metric (device, AF_INET),
nm_device_get_route_metric (device, AF_INET6),
diff --git a/src/tests/test-general.c b/src/tests/test-general.c
index 632f2c33cc..5276d9b0e3 100644
--- a/src/tests/test-general.c
+++ b/src/tests/test-general.c
@@ -359,7 +359,7 @@ _match_connection (GSList *connections,
}
list[i] = NULL;
- return nm_utils_match_connection (list, original, FALSE, device_has_carrier, default_v4_metric, default_v6_metric, NULL, NULL);
+ return nm_utils_match_connection (list, original, device_has_carrier, default_v4_metric, default_v6_metric, NULL, NULL);
}
static void