core/trivial: rename "nm-generated-assumed" flag to "volatile"

The concept of assumed-connection will change. Currently we mark
connections that are generated and assumed as "nm-generated-assumed".
That has several consequences, one of them being that such a settings
connection gets deleted when the device disconnects.

That is, such a settings connection lingers around as long as it's active,
but once it deactivates it gets automatically deleted. As such, it's
a more volatile concept of an in-memory connection.

The concept of such automatically cleaned up connections is useful beyond
generated-assumed. See the related bug rh#1401515.
This commit is contained in:
Thomas Haller 2017-02-16 20:10:19 +01:00
parent d43a54c907
commit 90e7c8bf5b
5 changed files with 18 additions and 18 deletions

View file

@ -1606,7 +1606,7 @@ nm_device_uses_generated_assumed_connection (NMDevice *self)
&& nm_active_connection_get_assumed (NM_ACTIVE_CONNECTION (priv->act_request))) { && nm_active_connection_get_assumed (NM_ACTIVE_CONNECTION (priv->act_request))) {
connection = nm_act_request_get_settings_connection (priv->act_request); connection = nm_act_request_get_settings_connection (priv->act_request);
if ( connection if ( connection
&& nm_settings_connection_get_nm_generated_assumed (connection)) && nm_settings_connection_get_volatile (connection))
return TRUE; return TRUE;
} }
return FALSE; return FALSE;

View file

@ -575,7 +575,7 @@ _dispatcher_call (NMDispatcherAction action,
NMD_CONNECTION_PROPS_FILENAME, NMD_CONNECTION_PROPS_FILENAME,
g_variant_new_string (filename)); g_variant_new_string (filename));
} }
if (nm_settings_connection_get_nm_generated_assumed (settings_connection)) { if (nm_settings_connection_get_volatile (settings_connection)) {
g_variant_builder_add (&connection_props, "{sv}", g_variant_builder_add (&connection_props, "{sv}",
NMD_CONNECTION_PROPS_EXTERNAL, NMD_CONNECTION_PROPS_EXTERNAL,
g_variant_new_boolean (TRUE)); g_variant_new_boolean (TRUE));

View file

@ -272,7 +272,7 @@ active_connection_remove (NMManager *self, NMActiveConnection *active)
if ( nm_active_connection_get_assumed (active) if ( nm_active_connection_get_assumed (active)
&& (connection = nm_active_connection_get_settings_connection (active)) && (connection = nm_active_connection_get_settings_connection (active))
&& nm_settings_connection_get_nm_generated_assumed (connection)) && nm_settings_connection_get_volatile (connection))
g_object_ref (connection); g_object_ref (connection);
else else
connection = NULL; connection = NULL;
@ -1697,7 +1697,7 @@ done:
static gboolean static gboolean
match_connection_filter (NMConnection *connection, gpointer user_data) match_connection_filter (NMConnection *connection, gpointer user_data)
{ {
if (nm_settings_connection_get_nm_generated_assumed (NM_SETTINGS_CONNECTION (connection))) if (nm_settings_connection_get_volatile (NM_SETTINGS_CONNECTION (connection)))
return FALSE; return FALSE;
return nm_device_check_connection_compatible (NM_DEVICE (user_data), connection); return nm_device_check_connection_compatible (NM_DEVICE (user_data), connection);
@ -1800,7 +1800,7 @@ get_existing_connection (NMManager *self, NMDevice *device, gboolean *out_genera
if (added) { if (added) {
nm_settings_connection_set_flags (NM_SETTINGS_CONNECTION (added), nm_settings_connection_set_flags (NM_SETTINGS_CONNECTION (added),
NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED | NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED |
NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED_ASSUMED, NM_SETTINGS_CONNECTION_FLAGS_VOLATILE,
TRUE); TRUE);
if (out_generated) if (out_generated)
*out_generated = TRUE; *out_generated = TRUE;

View file

@ -498,7 +498,7 @@ set_unsaved (NMSettingsConnection *self, gboolean now_unsaved)
else { else {
flags &= ~(NM_SETTINGS_CONNECTION_FLAGS_UNSAVED | flags &= ~(NM_SETTINGS_CONNECTION_FLAGS_UNSAVED |
NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED | NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED |
NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED_ASSUMED); NM_SETTINGS_CONNECTION_FLAGS_VOLATILE);
} }
nm_settings_connection_set_flags_all (self, flags); nm_settings_connection_set_flags_all (self, flags);
} }
@ -561,7 +561,7 @@ nm_settings_connection_replace_settings (NMSettingsConnection *self,
_LOGD ("replace settings from connection %p (%s)", new_connection, nm_connection_get_id (NM_CONNECTION (self))); _LOGD ("replace settings from connection %p (%s)", new_connection, nm_connection_get_id (NM_CONNECTION (self)));
nm_settings_connection_set_flags (self, nm_settings_connection_set_flags (self,
NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED | NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED_ASSUMED, NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED | NM_SETTINGS_CONNECTION_FLAGS_VOLATILE,
FALSE); FALSE);
/* Cache the just-updated system secrets in case something calls /* Cache the just-updated system secrets in case something calls
@ -2641,18 +2641,18 @@ nm_settings_connection_get_nm_generated (NMSettingsConnection *self)
} }
/** /**
* nm_settings_connection_get_nm_generated_assumed: * nm_settings_connection_get_volatile:
* @self: an #NMSettingsConnection * @self: an #NMSettingsConnection
* *
* Gets the "nm-generated-assumed" flag on @self. * Gets the "volatile" flag on @self.
* *
* The connection is a generated connection especially * The connection is marked as volatile and will be removed when
* generated for connection assumption. * it disconnects.
*/ */
gboolean gboolean
nm_settings_connection_get_nm_generated_assumed (NMSettingsConnection *self) nm_settings_connection_get_volatile (NMSettingsConnection *self)
{ {
return NM_FLAGS_HAS (nm_settings_connection_get_flags (self), NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED_ASSUMED); return NM_FLAGS_HAS (nm_settings_connection_get_flags (self), NM_SETTINGS_CONNECTION_FLAGS_VOLATILE);
} }
gboolean gboolean

View file

@ -58,9 +58,9 @@
* @NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED: A connection is "nm-generated" if * @NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED: A connection is "nm-generated" if
* it was generated by NetworkManger. If the connection gets modified or saved * it was generated by NetworkManger. If the connection gets modified or saved
* by the user, the flag gets cleared. A nm-generated is implicitly unsaved. * by the user, the flag gets cleared. A nm-generated is implicitly unsaved.
* @NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED_ASSUMED: A special kind of "nm-generated" * @NM_SETTINGS_CONNECTION_FLAGS_VOLATILE: The connection will be deleted
* connection that was specifically created for connection assumption. "nm-generated-assumed" * when it disconnects. That is for in-memory connections (unsaved), which are
* implies "nm-generated". * currently active but cleanup on disconnect.
* @NM_SETTINGS_CONNECTION_FLAGS_ALL: special mask, for all known flags * @NM_SETTINGS_CONNECTION_FLAGS_ALL: special mask, for all known flags
* *
* #NMSettingsConnection flags. * #NMSettingsConnection flags.
@ -70,7 +70,7 @@ typedef enum
NM_SETTINGS_CONNECTION_FLAGS_NONE = 0x00, NM_SETTINGS_CONNECTION_FLAGS_NONE = 0x00,
NM_SETTINGS_CONNECTION_FLAGS_UNSAVED = 0x01, NM_SETTINGS_CONNECTION_FLAGS_UNSAVED = 0x01,
NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED = 0x02, NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED = 0x02,
NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED_ASSUMED = 0x04, NM_SETTINGS_CONNECTION_FLAGS_VOLATILE = 0x04,
__NM_SETTINGS_CONNECTION_FLAGS_LAST, __NM_SETTINGS_CONNECTION_FLAGS_LAST,
NM_SETTINGS_CONNECTION_FLAGS_ALL = ((__NM_SETTINGS_CONNECTION_FLAGS_LAST - 1) << 1) - 1, NM_SETTINGS_CONNECTION_FLAGS_ALL = ((__NM_SETTINGS_CONNECTION_FLAGS_LAST - 1) << 1) - 1,
@ -228,7 +228,7 @@ void nm_settings_connection_set_autoconnect_blocke
gboolean nm_settings_connection_can_autoconnect (NMSettingsConnection *self); gboolean nm_settings_connection_can_autoconnect (NMSettingsConnection *self);
gboolean nm_settings_connection_get_nm_generated (NMSettingsConnection *self); gboolean nm_settings_connection_get_nm_generated (NMSettingsConnection *self);
gboolean nm_settings_connection_get_nm_generated_assumed (NMSettingsConnection *self); gboolean nm_settings_connection_get_volatile (NMSettingsConnection *self);
gboolean nm_settings_connection_get_ready (NMSettingsConnection *self); gboolean nm_settings_connection_get_ready (NMSettingsConnection *self);
void nm_settings_connection_set_ready (NMSettingsConnection *self, void nm_settings_connection_set_ready (NMSettingsConnection *self,