summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2023-03-29 11:24:25 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2023-03-29 11:24:25 +0200
commit37de834575bf1c8a69b96ff2647a394b855e693d (patch)
tree9edc9eadf6e0f3d3e8479fd8d7e682e7a27e170d
parent9d4bbf78f0b3a80eec9115663bd9db2c6460b369 (diff)
parentb3e550497275598c7a34484a9d0a00c712916066 (diff)
downloadNetworkManager-37de834575bf1c8a69b96ff2647a394b855e693d.tar.gz
merge: branch 'bg/rh2174353'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1589 https://bugzilla.redhat.com/show_bug.cgi?id=2174353
-rw-r--r--src/core/nm-manager.c49
-rw-r--r--src/core/nm-manager.h2
-rw-r--r--src/core/nm-policy.c34
3 files changed, 54 insertions, 31 deletions
diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c
index 52f6304785..d44e25c02c 100644
--- a/src/core/nm-manager.c
+++ b/src/core/nm-manager.c
@@ -5978,6 +5978,55 @@ fail:
error_desc ?: error->message);
}
+void
+nm_manager_deactivate_ac(NMManager *self, NMSettingsConnection *connection)
+{
+ NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self);
+ NMActiveConnection *ac;
+ const CList *tmp_list, *tmp_safe;
+ GError *error = NULL;
+ AsyncOpData *async_op_data;
+ AsyncOpData *async_op_data_safe;
+
+ 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);
+ }
+ }
+ }
+
+ c_list_for_each_entry_safe (async_op_data,
+ async_op_data_safe,
+ &priv->async_op_lst_head,
+ async_op_lst) {
+ if (!NM_IN_SET(async_op_data->async_op_type,
+ ASYNC_OP_TYPE_AC_AUTH_ACTIVATE_INTERNAL,
+ ASYNC_OP_TYPE_AC_AUTH_ACTIVATE_USER,
+ ASYNC_OP_TYPE_AC_AUTH_ADD_AND_ACTIVATE,
+ ASYNC_OP_TYPE_AC_AUTH_ADD_AND_ACTIVATE2))
+ continue;
+
+ ac = async_op_data->ac_auth.active;
+ if (nm_active_connection_get_settings_connection(ac) == connection) {
+ nm_active_connection_set_state(ac,
+ NM_ACTIVE_CONNECTION_STATE_DEACTIVATED,
+ NM_ACTIVE_CONNECTION_STATE_REASON_CONNECTION_REMOVED);
+ }
+ }
+}
+
/**
* 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..b2ccb16478 100644
--- a/src/core/nm-policy.c
+++ b/src/core/nm-policy.c
@@ -1326,7 +1326,8 @@ pending_ac_state_changed(NMActiveConnection *ac, guint state, guint reason, NMPo
* device, but block the current connection to avoid an activation
* loop.
*/
- if (reason != NM_ACTIVE_CONNECTION_STATE_REASON_DEVICE_DISCONNECTED) {
+ if (reason != NM_ACTIVE_CONNECTION_STATE_REASON_DEVICE_DISCONNECTED
+ && reason != NM_ACTIVE_CONNECTION_STATE_REASON_CONNECTION_REMOVED) {
con = nm_active_connection_get_settings_connection(ac);
nm_manager_devcon_autoconnect_blocked_reason_set(
priv->manager,
@@ -2625,40 +2626,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