diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2016-09-07 17:47:26 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2016-09-20 18:28:31 +0200 |
commit | 5ce31c2a7d7197b3233848505f6e7c2135bd1f84 (patch) | |
tree | 744fdf651d7d1f3d1119f5111f509565a1bef1e5 | |
parent | 97cc61a9167177252ee089ae9b85b2366c398c68 (diff) | |
download | NetworkManager-5ce31c2a7d7197b3233848505f6e7c2135bd1f84.tar.gz |
core: allow passing an applied connection to nm_act_request_new()
This is useful for the checkpoint/restore functionality to revert both
the applied and the settings connections.
-rw-r--r-- | src/nm-activation-request.c | 2 | ||||
-rw-r--r-- | src/nm-activation-request.h | 1 | ||||
-rw-r--r-- | src/nm-active-connection.c | 25 | ||||
-rw-r--r-- | src/nm-active-connection.h | 1 | ||||
-rw-r--r-- | src/nm-checkpoint.c | 1 | ||||
-rw-r--r-- | src/nm-manager.c | 14 | ||||
-rw-r--r-- | src/nm-manager.h | 1 | ||||
-rw-r--r-- | src/nm-policy.c | 3 |
8 files changed, 42 insertions, 6 deletions
diff --git a/src/nm-activation-request.c b/src/nm-activation-request.c index 22fa5b6910..1b4f93676a 100644 --- a/src/nm-activation-request.c +++ b/src/nm-activation-request.c @@ -473,6 +473,7 @@ master_failed (NMActiveConnection *self) */ NMActRequest * nm_act_request_new (NMSettingsConnection *settings_connection, + NMConnection *applied, const char *specific_object, NMAuthSubject *subject, NMDevice *device) @@ -482,6 +483,7 @@ nm_act_request_new (NMSettingsConnection *settings_connection, g_return_val_if_fail (NM_IS_AUTH_SUBJECT (subject), NULL); return (NMActRequest *) g_object_new (NM_TYPE_ACT_REQUEST, + NM_ACTIVE_CONNECTION_INT_APPLIED_CONNECTION, applied, NM_ACTIVE_CONNECTION_INT_SETTINGS_CONNECTION, settings_connection, NM_ACTIVE_CONNECTION_INT_DEVICE, device, NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, specific_object, diff --git a/src/nm-activation-request.h b/src/nm-activation-request.h index 1bd004994e..5a170d8976 100644 --- a/src/nm-activation-request.h +++ b/src/nm-activation-request.h @@ -46,6 +46,7 @@ typedef struct { GType nm_act_request_get_type (void); NMActRequest *nm_act_request_new (NMSettingsConnection *settings_connection, + NMConnection *applied_connection, const char *specific_object, NMAuthSubject *subject, NMDevice *device); diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c index 1844587c67..c3fa821443 100644 --- a/src/nm-active-connection.c +++ b/src/nm-active-connection.c @@ -90,6 +90,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMActiveConnection, PROP_MASTER, PROP_INT_SETTINGS_CONNECTION, + PROP_INT_APPLIED_CONNECTION, PROP_INT_DEVICE, PROP_INT_SUBJECT, PROP_INT_MASTER, @@ -951,6 +952,12 @@ constructed (GObject *object) G_OBJECT_CLASS (nm_active_connection_parent_class)->constructed (object); + if (!priv->applied_connection && priv->settings_connection) { + priv->applied_connection = + nm_simple_connection_new_clone ((NMConnection *) priv->settings_connection); + nm_connection_clear_secrets (priv->applied_connection); + } + _LOGD ("constructed (%s, version-id %llu)", G_OBJECT_TYPE_NAME (self), (long long unsigned) priv->version_id); g_return_if_fail (priv->subject); @@ -964,16 +971,20 @@ set_property (GObject *object, guint prop_id, NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self); const char *tmp; NMSettingsConnection *con; + NMConnection *acon; switch (prop_id) { case PROP_INT_SETTINGS_CONNECTION: /* construct-only */ con = g_value_get_object (value); - if (con) { + if (con) _set_settings_connection (self, con); - priv->applied_connection = nm_simple_connection_new_clone ((NMConnection *) priv->settings_connection); - nm_connection_clear_secrets (priv->applied_connection); - } + break; + case PROP_INT_APPLIED_CONNECTION: + /* construct-only */ + acon = g_value_get_object (value); + if (acon) + priv->applied_connection = g_object_ref (acon); break; case PROP_INT_DEVICE: /* construct-only */ @@ -1259,6 +1270,12 @@ nm_active_connection_class_init (NMActiveConnectionClass *ac_class) G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_INT_APPLIED_CONNECTION] = + g_param_spec_object (NM_ACTIVE_CONNECTION_INT_APPLIED_CONNECTION, "", "", + NM_TYPE_CONNECTION, + G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + obj_properties[PROP_INT_DEVICE] = g_param_spec_object (NM_ACTIVE_CONNECTION_INT_DEVICE, "", "", NM_TYPE_DEVICE, diff --git a/src/nm-active-connection.h b/src/nm-active-connection.h index a66f8e9ffc..42e45a2bf1 100644 --- a/src/nm-active-connection.h +++ b/src/nm-active-connection.h @@ -50,6 +50,7 @@ /* Internal non-exported properties */ #define NM_ACTIVE_CONNECTION_INT_SETTINGS_CONNECTION "int-settings-connection" +#define NM_ACTIVE_CONNECTION_INT_APPLIED_CONNECTION "int-applied-connection" #define NM_ACTIVE_CONNECTION_INT_DEVICE "int-device" #define NM_ACTIVE_CONNECTION_INT_SUBJECT "int-subject" #define NM_ACTIVE_CONNECTION_INT_MASTER "int-master" diff --git a/src/nm-checkpoint.c b/src/nm-checkpoint.c index 605e0700be..f2d573574a 100644 --- a/src/nm-checkpoint.c +++ b/src/nm-checkpoint.c @@ -178,6 +178,7 @@ nm_checkpoint_rollback (NMCheckpoint *self) if (!nm_manager_activate_connection (priv->manager, connection, NULL, + NULL, device, subject, &local_error)) { diff --git a/src/nm-manager.c b/src/nm-manager.c index cba9f3701e..9136303658 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -64,6 +64,7 @@ static gboolean add_device (NMManager *self, NMDevice *device, GError **error); static NMActiveConnection *_new_active_connection (NMManager *self, NMConnection *connection, + NMConnection *applied, const char *specific_object, NMDevice *device, NMAuthSubject *subject, @@ -1742,7 +1743,7 @@ assume_connection (NMManager *self, NMDevice *device, NMSettingsConnection *conn g_return_val_if_fail (nm_device_get_state (device) >= NM_DEVICE_STATE_DISCONNECTED, FALSE); subject = nm_auth_subject_new_internal (); - active = _new_active_connection (self, NM_CONNECTION (connection), NULL, device, subject, &error); + active = _new_active_connection (self, NM_CONNECTION (connection), NULL, NULL, device, subject, &error); g_object_unref (subject); if (!active) { @@ -2620,6 +2621,7 @@ ensure_master_active_connection (NMManager *self, master_ac = nm_manager_activate_connection (self, candidate, NULL, + NULL, master_device, subject, error); @@ -2666,6 +2668,7 @@ ensure_master_active_connection (NMManager *self, master_ac = nm_manager_activate_connection (self, master_connection, NULL, + NULL, candidate, subject, error); @@ -2790,6 +2793,7 @@ autoconnect_slaves (NMManager *self, nm_manager_activate_connection (self, slave_connection, NULL, + NULL, nm_manager_get_best_device_for_connection (self, NM_CONNECTION (slave_connection), FALSE), subject, &local_err); @@ -2949,7 +2953,7 @@ _internal_activate_device (NMManager *self, NMActiveConnection *active, GError * return FALSE; } - parent_ac = nm_manager_activate_connection (self, parent_con, NULL, parent, subject, error); + parent_ac = nm_manager_activate_connection (self, parent_con, NULL, NULL, parent, subject, error); if (!parent_ac) { g_prefix_error (error, "%s failed to activate parent: ", nm_device_get_iface (device)); return FALSE; @@ -3131,6 +3135,7 @@ _new_vpn_active_connection (NMManager *self, static NMActiveConnection * _new_active_connection (NMManager *self, NMConnection *connection, + NMConnection *applied, const char *specific_object, NMDevice *device, NMAuthSubject *subject, @@ -3170,6 +3175,7 @@ _new_active_connection (NMManager *self, } return (NMActiveConnection *) nm_act_request_new (settings_connection, + applied, specific_object, subject, device); @@ -3237,6 +3243,7 @@ _internal_activation_auth_done (NMActiveConnection *active, NMActiveConnection * nm_manager_activate_connection (NMManager *self, NMSettingsConnection *connection, + NMConnection *applied, const char *specific_object, NMDevice *device, NMAuthSubject *subject, @@ -3282,6 +3289,7 @@ nm_manager_activate_connection (NMManager *self, active = _new_active_connection (self, NM_CONNECTION (connection), + applied, specific_object, device, subject, @@ -3536,6 +3544,7 @@ impl_manager_activate_connection (NMManager *self, active = _new_active_connection (self, NM_CONNECTION (connection), + NULL, specific_object_path, device, subject, @@ -3743,6 +3752,7 @@ impl_manager_add_and_activate_connection (NMManager *self, active = _new_active_connection (self, connection, + NULL, specific_object_path, device, subject, diff --git a/src/nm-manager.h b/src/nm-manager.h index 0854d1990d..b453c0b77d 100644 --- a/src/nm-manager.h +++ b/src/nm-manager.h @@ -102,6 +102,7 @@ char * nm_manager_get_connection_iface (NMManager *self, NMActiveConnection *nm_manager_activate_connection (NMManager *manager, NMSettingsConnection *connection, + NMConnection *applied_connection, const char *specific_object, NMDevice *device, NMAuthSubject *subject, diff --git a/src/nm-policy.c b/src/nm-policy.c index 5fa46259cd..0e437d9d4c 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -724,6 +724,7 @@ auto_activate_device (gpointer user_data) subject = nm_auth_subject_new_internal (); if (!nm_manager_activate_connection (priv->manager, best_connection, + NULL, specific_object, data->device, subject, @@ -1117,6 +1118,7 @@ activate_secondary_connections (NMPolicy *self, nm_connection_get_id (connection), nm_connection_get_uuid (connection)); ac = nm_manager_activate_connection (priv->manager, settings_con, + NULL, nm_exported_object_get_path (NM_EXPORTED_OBJECT (req)), device, nm_active_connection_get_subject (NM_ACTIVE_CONNECTION (req)), @@ -1520,6 +1522,7 @@ vpn_connection_retry_after_failure (NMVpnConnection *vpn, NMPolicy *self) connection, NULL, NULL, + NULL, nm_active_connection_get_subject (ac), &error)) { _LOGW (LOGD_DEVICE, "VPN '%s' reconnect failed: %s", |