summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2023-03-28 23:10:25 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2023-03-29 10:28:26 +0200
commite6b3a6a2b6c18a62d025fe55a5fd57759c9e1a69 (patch)
tree715a0efd2f5cfa0481ca37b32c7180cad5c4ad66
parent9d4bbf78f0b3a80eec9115663bd9db2c6460b369 (diff)
core: move deactivation of active connections to the manager
It's needed for the next commit.
-rw-r--r--src/core/nm-manager.c27
-rw-r--r--src/core/nm-manager.h2
-rw-r--r--src/core/nm-policy.c31
3 files changed, 30 insertions, 30 deletions
diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c
index 52f6304785..8285723739 100644
--- a/src/core/nm-manager.c
+++ b/src/core/nm-manager.c
@@ -5978,6 +5978,33 @@ fail:
error_desc ?: error->message);
}
+void
+nm_manager_deactivate_ac(NMManager *self, NMSettingsConnection *connection)
+{
+ NMActiveConnection *ac;
+ const CList *tmp_list, *tmp_safe;
+ GError *error = NULL;
+
+ nm_assert(NM_IS_SETTINGS_CONNECTION(connection));
+
+ nm_manager_for_each_active_connection_safe (self, ac, tmp_list, tmp_safe) {
+ if (nm_active_connection_get_settings_connection(ac) == connection
+ && (nm_active_connection_get_state(ac) <= NM_ACTIVE_CONNECTION_STATE_ACTIVATED)) {
+ if (!nm_manager_deactivate_connection(self,
+ ac,
+ NM_DEVICE_STATE_REASON_CONNECTION_REMOVED,
+ &error)) {
+ _LOGW(LOGD_DEVICE,
+ "connection '%s' disappeared, but error deactivating it: (%d) %s",
+ nm_settings_connection_get_id(connection),
+ error ? error->code : -1,
+ error ? error->message : "(unknown)");
+ g_clear_error(&error);
+ }
+ }
+ }
+}
+
/**
* nm_manager_activate_connection():
* @self: the #NMManager
diff --git a/src/core/nm-manager.h b/src/core/nm-manager.h
index ad8d0ba81a..fe78eb2687 100644
--- a/src/core/nm-manager.h
+++ b/src/core/nm-manager.h
@@ -121,6 +121,8 @@ NMSettingsConnection **nm_manager_get_activatable_connections(NMManager *manager
gboolean sort,
guint *out_len);
+void nm_manager_deactivate_ac(NMManager *self, NMSettingsConnection *connection);
+
void nm_manager_write_device_state_all(NMManager *manager);
gboolean nm_manager_write_device_state(NMManager *manager, NMDevice *device, int *out_ifindex);
diff --git a/src/core/nm-policy.c b/src/core/nm-policy.c
index 8d5054c824..ef7d2e434a 100644
--- a/src/core/nm-policy.c
+++ b/src/core/nm-policy.c
@@ -2625,40 +2625,11 @@ connection_updated(NMSettings *settings,
}
static void
-_deactivate_if_active(NMPolicy *self, NMSettingsConnection *connection)
-{
- NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self);
- NMActiveConnection *ac;
- const CList *tmp_list, *tmp_safe;
- GError *error = NULL;
-
- nm_assert(NM_IS_SETTINGS_CONNECTION(connection));
-
- nm_manager_for_each_active_connection_safe (priv->manager, ac, tmp_list, tmp_safe) {
- if (nm_active_connection_get_settings_connection(ac) == connection
- && (nm_active_connection_get_state(ac) <= NM_ACTIVE_CONNECTION_STATE_ACTIVATED)) {
- if (!nm_manager_deactivate_connection(priv->manager,
- ac,
- NM_DEVICE_STATE_REASON_CONNECTION_REMOVED,
- &error)) {
- _LOGW(LOGD_DEVICE,
- "connection '%s' disappeared, but error deactivating it: (%d) %s",
- nm_settings_connection_get_id(connection),
- error ? error->code : -1,
- error ? error->message : "(unknown)");
- g_clear_error(&error);
- }
- }
- }
-}
-
-static void
connection_removed(NMSettings *settings, NMSettingsConnection *connection, gpointer user_data)
{
NMPolicyPrivate *priv = user_data;
- NMPolicy *self = _PRIV_TO_SELF(priv);
- _deactivate_if_active(self, connection);
+ nm_manager_deactivate_ac(priv->manager, connection);
}
static void