settings: add NMSettingsConnectionFlags flags

Up to now, it was not visible on D-Bus whether a connection
was generated by NetworkManager and/or volatile.

That is for example interesting for firewalld, which aims
to store persistant configuration in NetworkManager's profile.
However, that doesn't make sense for external connections
(which are nm-generated & volatile). In fact, it probably
makes no sense for volatile connections in general, because
modifying them, likely makes them non-volatile (depending on
how the profile is modified).

Also, the Update2() D-Bus operation allows to carefully
make connections volatile and unsaved. As we have public
API to set these flags, we should also expose them on D-Bus.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1460295
This commit is contained in:
Thomas Haller 2018-04-05 21:07:34 +02:00
parent acc8244ca2
commit aae483c0a9
2 changed files with 28 additions and 5 deletions

View file

@ -888,6 +888,19 @@ typedef enum { /*< skip >*/
/**
* NMSettingsConnectionFlags:
* @NM_SETTINGS_CONNECTION_FLAG_NONE: an alias for numeric zero, no flags set.
* @NM_SETTINGS_CONNECTION_FLAG_UNSAVED: the connection is not saved to disk.
* That either means, that the connection is in-memory only and currently
* is not backed by a file. Or, that the connection is backed by a file,
* but has modifications in-memory that were not persisted to disk.
* @NM_SETTINGS_CONNECTION_FLAG_NM_GENERATED: A connection is "nm-generated" if
* it was generated by NetworkManger. If the connection gets modified or saved
* by the user, the flag gets cleared. A nm-generated is also unsaved
* and has no backing file as it is in-memory only.
* @NM_SETTINGS_CONNECTION_FLAG_VOLATILE: The connection will be deleted
* when it disconnects. That is for in-memory connections (unsaved), which are
* currently active but deleted on disconnect. Volatile connections are
* always unsaved, but they are also no backing file on disk and are entirely
* in-memory only.
*
* Flags describing the current activation state.
*
@ -895,6 +908,9 @@ typedef enum { /*< skip >*/
**/
typedef enum { /*< flags >*/
NM_SETTINGS_CONNECTION_FLAG_NONE = 0,
NM_SETTINGS_CONNECTION_FLAG_UNSAVED = 0x01,
NM_SETTINGS_CONNECTION_FLAG_NM_GENERATED = 0x02,
NM_SETTINGS_CONNECTION_FLAG_VOLATILE = 0x04,
} NMSettingsConnectionFlags;
/**

View file

@ -52,13 +52,16 @@
/**
* NMSettingsConnectionIntFlags:
* @NM_SETTINGS_CONNECTION_INT_FLAGS_NONE: no flag set
* @NM_SETTINGS_CONNECTION_INT_FLAGS_UNSAVED: the connection is not saved to disk
* @NM_SETTINGS_CONNECTION_INT_FLAGS_UNSAVED: the connection is not saved to disk.
* See also #NM_SETTINGS_CONNECTION_FLAG_UNSAVED.
* @NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED: A connection is "nm-generated" if
* 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.
* See also #NM_SETTINGS_CONNECTION_FLAG_NM_GENERATED.
* @NM_SETTINGS_CONNECTION_INT_FLAGS_VOLATILE: The connection will be deleted
* when it disconnects. That is for in-memory connections (unsaved), which are
* currently active but cleanup on disconnect.
* See also #NM_SETTINGS_CONNECTION_FLAG_VOLATILE.
* @NM_SETTINGS_CONNECTION_INT_FLAGS_VISIBLE: The connection is visible
* @NM_SETTINGS_CONNECTION_INT_FLAGS_EXPORTED_MASK: the entire enum is
* internal, however, parts of it is public API as #NMSettingsConnectionFlags.
@ -70,15 +73,19 @@
typedef enum {
NM_SETTINGS_CONNECTION_INT_FLAGS_NONE = 0,
NM_SETTINGS_CONNECTION_INT_FLAGS_UNSAVED = (1LL << 0),
NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED = (1LL << 1),
NM_SETTINGS_CONNECTION_INT_FLAGS_VOLATILE = (1LL << 2),
NM_SETTINGS_CONNECTION_INT_FLAGS_UNSAVED = NM_SETTINGS_CONNECTION_FLAG_UNSAVED,
NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED = NM_SETTINGS_CONNECTION_FLAG_NM_GENERATED,
NM_SETTINGS_CONNECTION_INT_FLAGS_VOLATILE = NM_SETTINGS_CONNECTION_FLAG_VOLATILE,
NM_SETTINGS_CONNECTION_INT_FLAGS_VISIBLE = (1LL << 3),
__NM_SETTINGS_CONNECTION_INT_FLAGS_LAST,
NM_SETTINGS_CONNECTION_INT_FLAGS_EXPORTED_MASK = 0,
NM_SETTINGS_CONNECTION_INT_FLAGS_EXPORTED_MASK = 0
| NM_SETTINGS_CONNECTION_INT_FLAGS_UNSAVED
| NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED
| NM_SETTINGS_CONNECTION_INT_FLAGS_VOLATILE
| 0,
NM_SETTINGS_CONNECTION_INT_FLAGS_ALL = ((__NM_SETTINGS_CONNECTION_INT_FLAGS_LAST - 1) << 1) - 1,
} NMSettingsConnectionIntFlags;