Commit 8a31e66d authored by Thomas Haller's avatar Thomas Haller

core: add activation-type property to active-connection

It is still unused, but will be useful to mark a connection
whether it is a full activation or assumed.
parent ae4535ba
......@@ -543,6 +543,7 @@ nm_act_request_init (NMActRequest *req)
* @specific_object: the object path of the specific object (ie, WiFi access point,
* etc) that will be used to activate @connection and @device
* @subject: the #NMAuthSubject representing the requestor of the activation
* @activation_type: the #NMActivationType.
* @device: the device/interface to configure according to @connection
*
* Creates a new device-based activation request. If an applied connection is
......@@ -555,6 +556,7 @@ nm_act_request_new (NMSettingsConnection *settings_connection,
NMConnection *applied_connection,
const char *specific_object,
NMAuthSubject *subject,
NMActivationType activation_type,
NMDevice *device)
{
g_return_val_if_fail (!settings_connection || NM_IS_SETTINGS_CONNECTION (settings_connection), NULL);
......@@ -567,6 +569,7 @@ nm_act_request_new (NMSettingsConnection *settings_connection,
NM_ACTIVE_CONNECTION_INT_DEVICE, device,
NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, specific_object,
NM_ACTIVE_CONNECTION_INT_SUBJECT, subject,
NM_ACTIVE_CONNECTION_INT_ACTIVATION_TYPE, (int) activation_type,
NULL);
}
......
......@@ -40,6 +40,7 @@ NMActRequest *nm_act_request_new (NMSettingsConnection *settings_connec
NMConnection *applied_connection,
const char *specific_object,
NMAuthSubject *subject,
NMActivationType activation_type,
NMDevice *device);
NMSettingsConnection *nm_act_request_get_settings_connection (NMActRequest *req);
......
......@@ -52,6 +52,8 @@ typedef struct _NMActiveConnectionPrivate {
bool assumed:1;
bool master_ready:1;
NMActivationType activation_type:3;
NMAuthSubject *subject;
NMActiveConnection *master;
......@@ -87,6 +89,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMActiveConnection,
PROP_INT_SUBJECT,
PROP_INT_MASTER,
PROP_INT_MASTER_READY,
PROP_INT_ACTIVATION_TYPE,
);
enum {
......@@ -711,6 +714,14 @@ nm_active_connection_set_master (NMActiveConnection *self, NMActiveConnection *m
check_master_ready (self);
}
NMActivationType
nm_active_connection_get_activation_type (NMActiveConnection *self)
{
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (self), NM_ACTIVATION_TYPE_MANAGED);
return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->activation_type;
}
void
nm_active_connection_set_assumed (NMActiveConnection *self, gboolean assumed)
{
......@@ -1057,6 +1068,7 @@ set_property (GObject *object, guint prop_id,
const char *tmp;
NMSettingsConnection *con;
NMConnection *acon;
int i;
switch (prop_id) {
case PROP_INT_SETTINGS_CONNECTION:
......@@ -1081,6 +1093,13 @@ set_property (GObject *object, guint prop_id,
case PROP_INT_MASTER:
nm_active_connection_set_master (self, g_value_get_object (value));
break;
case PROP_INT_ACTIVATION_TYPE:
/* construct-only */
i = g_value_get_int (value);
if (!NM_IN_SET (i, NM_ACTIVATION_TYPE_MANAGED, NM_ACTIVATION_TYPE_ASSUME))
g_return_if_reached ();
priv->activation_type = (NMActivationType) i;
break;
case PROP_SPECIFIC_OBJECT:
tmp = g_value_get_string (value);
/* NM uses "/" to mean NULL */
......@@ -1116,6 +1135,7 @@ nm_active_connection_init (NMActiveConnection *self)
_LOGT ("creating");
priv->activation_type = NM_ACTIVATION_TYPE_MANAGED;
priv->version_id = _version_id_new ();
}
......@@ -1135,7 +1155,10 @@ constructed (GObject *object)
if (priv->applied_connection)
nm_connection_clear_secrets (priv->applied_connection);
_LOGD ("constructed (%s, version-id %llu)", G_OBJECT_TYPE_NAME (self), (unsigned long long) priv->version_id);
_LOGD ("constructed (%s, version-id %llu, type %s)",
G_OBJECT_TYPE_NAME (self),
(unsigned long long) priv->version_id,
nm_activation_type_to_string (priv->activation_type));
g_return_if_fail (priv->subject);
}
......@@ -1320,6 +1343,15 @@ nm_active_connection_class_init (NMActiveConnectionClass *ac_class)
FALSE, G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS);
obj_properties[PROP_INT_ACTIVATION_TYPE] =
g_param_spec_int (NM_ACTIVE_CONNECTION_INT_ACTIVATION_TYPE, "", "",
NM_ACTIVATION_TYPE_MANAGED,
NM_ACTIVATION_TYPE_ASSUME,
NM_ACTIVATION_TYPE_MANAGED,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
signals[DEVICE_CHANGED] =
......
......@@ -55,6 +55,7 @@
#define NM_ACTIVE_CONNECTION_INT_SUBJECT "int-subject"
#define NM_ACTIVE_CONNECTION_INT_MASTER "int-master"
#define NM_ACTIVE_CONNECTION_INT_MASTER_READY "int-master-ready"
#define NM_ACTIVE_CONNECTION_INT_ACTIVATION_TYPE "int-activation-type"
/* Internal signals*/
#define NM_ACTIVE_CONNECTION_DEVICE_CHANGED "device-changed"
......@@ -163,6 +164,8 @@ void nm_active_connection_set_assumed (NMActiveConnection *self,
gboolean nm_active_connection_get_assumed (NMActiveConnection *self);
NMActivationType nm_active_connection_get_activation_type (NMActiveConnection *self);
void nm_active_connection_clear_secrets (NMActiveConnection *self);
#endif /* __NETWORKMANAGER_ACTIVE_CONNECTION_H__ */
......@@ -281,6 +281,7 @@ activate:
NULL,
device,
subject,
NM_ACTIVATION_TYPE_MANAGED,
&local_error)) {
_LOGW ("rollback: reactivation of connection %s/%s failed: %s",
nm_connection_get_id ((NMConnection *) connection),
......
......@@ -4339,3 +4339,11 @@ nm_utils_format_con_diff_for_audit (GHashTable *diff)
return g_string_free (str, FALSE);
}
/*****************************************************************************/
NM_UTILS_LOOKUP_STR_DEFINE (nm_activation_type_to_string, NMActivationType,
NM_UTILS_LOOKUP_DEFAULT_WARN ("(unknown)"),
NM_UTILS_LOOKUP_STR_ITEM (NM_ACTIVATION_TYPE_MANAGED, "managed"),
NM_UTILS_LOOKUP_STR_ITEM (NM_ACTIVATION_TYPE_ASSUME, "assume"),
)
......@@ -472,4 +472,10 @@ char **nm_utils_read_plugin_paths (const char *dirname, const char *prefix);
char *nm_utils_format_con_diff_for_audit (GHashTable *diff);
/*****************************************************************************/
const char *nm_activation_type_to_string (NMActivationType activation_type);
/*****************************************************************************/
#endif /* __NM_CORE_UTILS_H__ */
......@@ -67,6 +67,7 @@ static NMActiveConnection *_new_active_connection (NMManager *self,
const char *specific_object,
NMDevice *device,
NMAuthSubject *subject,
NMActivationType activation_type,
GError **error);
static void policy_activating_device_changed (GObject *object, GParamSpec *pspec, gpointer user_data);
......@@ -1835,7 +1836,8 @@ 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, NULL, device, subject, &error);
active = _new_active_connection (self, NM_CONNECTION (connection), NULL, NULL,
device, subject, NM_ACTIVATION_TYPE_MANAGED, &error);
g_object_unref (subject);
if (!active) {
......@@ -2762,6 +2764,7 @@ ensure_master_active_connection (NMManager *self,
NULL,
master_device,
subject,
NM_ACTIVATION_TYPE_MANAGED,
error);
return master_ac;
}
......@@ -2807,6 +2810,7 @@ ensure_master_active_connection (NMManager *self,
NULL,
candidate,
subject,
NM_ACTIVATION_TYPE_MANAGED,
error);
return master_ac;
}
......@@ -2953,6 +2957,7 @@ autoconnect_slaves (NMManager *self,
NULL,
nm_manager_get_best_device_for_connection (self, NM_CONNECTION (slave_connection), FALSE),
subject,
NM_ACTIVATION_TYPE_MANAGED,
&local_err);
if (local_err) {
_LOGW (LOGD_CORE, "Slave connection activation failed: %s", local_err->message);
......@@ -3110,7 +3115,8 @@ _internal_activate_device (NMManager *self, NMActiveConnection *active, GError *
return FALSE;
}
parent_ac = nm_manager_activate_connection (self, parent_con, NULL, NULL, parent, subject, error);
parent_ac = nm_manager_activate_connection (self, parent_con, NULL, NULL, parent,
subject, NM_ACTIVATION_TYPE_MANAGED, error);
if (!parent_ac) {
g_prefix_error (error, "%s failed to activate parent: ", nm_device_get_iface (device));
return FALSE;
......@@ -3305,6 +3311,7 @@ _new_active_connection (NMManager *self,
const char *specific_object,
NMDevice *device,
NMAuthSubject *subject,
NMActivationType activation_type,
GError **error)
{
NMSettingsConnection *settings_connection = NULL;
......@@ -3333,6 +3340,8 @@ _new_active_connection (NMManager *self,
settings_connection = (NMSettingsConnection *) connection;
if (is_vpn) {
if (activation_type != NM_ACTIVATION_TYPE_MANAGED)
g_return_val_if_reached (NULL);
return _new_vpn_active_connection (self,
settings_connection,
specific_object,
......@@ -3344,6 +3353,7 @@ _new_active_connection (NMManager *self,
applied,
specific_object,
subject,
activation_type,
device);
}
......@@ -3396,6 +3406,8 @@ _internal_activation_auth_done (NMActiveConnection *active,
* @specific_object: the specific object path, if any, for the activation
* @device: the #NMDevice to activate @connection on
* @subject: the subject which requested activation
* @activation_type: whether to assume the connection. That is, take over gracefully,
* non-destructible.
* @error: return location for an error
*
* Begins a new internally-initiated activation of @connection on @device.
......@@ -3415,6 +3427,7 @@ nm_manager_activate_connection (NMManager *self,
const char *specific_object,
NMDevice *device,
NMAuthSubject *subject,
NMActivationType activation_type,
GError **error)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
......@@ -3461,6 +3474,7 @@ nm_manager_activate_connection (NMManager *self,
specific_object,
device,
subject,
activation_type,
error);
if (active) {
priv->authorizing_connections = g_slist_prepend (priv->authorizing_connections, active);
......@@ -3704,6 +3718,7 @@ impl_manager_activate_connection (NMManager *self,
specific_object_path,
device,
subject,
NM_ACTIVATION_TYPE_MANAGED,
&error);
if (!active)
goto error;
......@@ -3923,6 +3938,7 @@ impl_manager_add_and_activate_connection (NMManager *self,
specific_object_path,
device,
subject,
NM_ACTIVATION_TYPE_MANAGED,
&error);
if (!active)
goto error;
......
......@@ -115,6 +115,7 @@ NMActiveConnection *nm_manager_activate_connection (NMManager *manager,
const char *specific_object,
NMDevice *device,
NMAuthSubject *subject,
NMActivationType activation_type,
GError **error);
gboolean nm_manager_deactivate_connection (NMManager *manager,
......
......@@ -1023,6 +1023,7 @@ auto_activate_device (NMPolicy *self,
specific_object,
device,
subject,
NM_ACTIVATION_TYPE_MANAGED,
&error)) {
_LOGI (LOGD_DEVICE, "connection '%s' auto-activation failed: (%d) %s",
nm_settings_connection_get_id (best_connection),
......@@ -1433,6 +1434,7 @@ activate_secondary_connections (NMPolicy *self,
nm_exported_object_get_path (NM_EXPORTED_OBJECT (req)),
device,
nm_active_connection_get_subject (NM_ACTIVE_CONNECTION (req)),
NM_ACTIVATION_TYPE_MANAGED,
&error);
if (ac)
secondary_ac_list = g_slist_append (secondary_ac_list, g_object_ref (ac));
......@@ -1846,6 +1848,7 @@ vpn_connection_retry_after_failure (NMVpnConnection *vpn, NMPolicy *self)
NULL,
NULL,
nm_active_connection_get_subject (ac),
NM_ACTIVATION_TYPE_MANAGED,
&error)) {
_LOGW (LOGD_DEVICE, "VPN '%s' reconnect failed: %s",
nm_settings_connection_get_id (connection),
......
......@@ -55,6 +55,17 @@ typedef struct _NMSleepMonitor NMSleepMonitor;
typedef struct _NMLldpListener NMLldpListener;
typedef struct _NMConfigDeviceStateData NMConfigDeviceStateData;
/*****************************************************************************/
typedef enum {
/* Do a full activation. */
NM_ACTIVATION_TYPE_MANAGED = 0,
/* gracefully/seamlessly take over the device. This leaves additional
* IP addresses and does not restore missing manual addresses. */
NM_ACTIVATION_TYPE_ASSUME = 1,
} NMActivationType;
typedef enum {
/* In priority order; higher number == higher priority */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment