NetworkManager/libnm-core
Thomas Haller d35d3c468a settings: rework tracking settings connections and settings plugins
Completely rework how settings plugin handle connections and how
NMSettings tracks the list of connections.

Previously, settings plugins would return objects of (a subtype of) type
NMSettingsConnection. The NMSettingsConnection was tightly coupled with
the settings plugin. That has a lot of downsides.

Change that. When changing this basic relation how settings connections
are tracked, everything falls appart. That's why this is a huge change.
Also, since I have to largely rewrite the settings plugins, I also
added support for multiple keyfile directories, handle in-memory
connections only by keyfile plugin and (partly) use copy-on-write NMConnection
instances. I don't want to spend effort rewriting large parts while
preserving the old way, that anyway should change. E.g. while rewriting ifcfg-rh,
I don't want to let it handle in-memory connections because that's not right
long-term.

--

If the settings plugins themself create subtypes of NMSettingsConnection
instances, then a lot of knowledge about tracking connections moves
to the plugins.
Just try to follow the code what happend during nm_settings_add_connection().
Note how the logic is spread out:
 - nm_settings_add_connection() calls plugin's add_connection()
 - add_connection() creates a NMSettingsConnection subtype
 - the plugin has to know that it's called during add-connection and
   not emit NM_SETTINGS_PLUGIN_CONNECTION_ADDED signal
 - NMSettings calls claim_connection() which hocks up the new
   NMSettingsConnection instance and configures the instance
   (like calling nm_settings_connection_added()).
This summary does not sound like a lot, but try to follow that code. The logic
is all over the place.

Instead, settings plugins should have a very simple API for adding, modifying,
deleting, loading and reloading connections. All the plugin does is to return a
NMSettingsStorage handle. The storage instance is a handle to identify a profile
in storage (e.g. a particular file). The settings plugin is free to subtype
NMSettingsStorage, but it's not necessary.
There are no more events raised, and the settings plugin implements the small
API in a straightforward manner.
NMSettings now drives all of this. Even NMSettingsConnection has now
very little concern about how it's tracked and delegates only to NMSettings.

This should make settings plugins simpler. Currently settings plugins
are so cumbersome to implement, that we avoid having them. It should not be
like that and it should be easy, beneficial and lightweight to create a new
settings plugin.

Note also how the settings plugins no longer care about duplicate UUIDs.
Duplicated UUIDs are a fact of life and NMSettings must handle them. No
need to overly concern settings plugins with that.

--

NMSettingsConnection is exposed directly on D-Bus (being a subtype of
NMDBusObject) but it was also a GObject type provided by the settings
plugin. Hence, it was not possible to migrate a profile from one plugin to
another.
However that would be useful when one profile does not support a
connection type (like ifcfg-rh not supporting VPN). Currently such
migration is not implemented except for migrating them to/from keyfile's
run directory. The problem is that migrating profiles in general is
complicated but in some cases it is important to do.

For example checkpoint rollback should recreate the profile in the right
settings plugin, not just add it to persistent storage. This is not yet
properly implemented.

--

Previously, both keyfile and ifcfg-rh plugin implemented in-memory (unsaved)
profiles, while ifupdown plugin cannot handle them. That meant duplication of code
and a ifupdown profile could not be modified or made unsaved.
This is now unified and only keyfile plugin handles in-memory profiles (bgo #744711).
Also, NMSettings is aware of such profiles and treats them specially.
In particular, NMSettings drives the migration between persistent and non-persistent
storage.

Note that a settings plugins may create truly generated, in-memory profiles.
The settings plugin is free to generate and persist the profiles in any way it
wishes. But the concept of "unsaved" profiles is now something explicitly handled
by keyfile plugin. Also, these "unsaved" keyfile profiles are persisted to file system
too, to the /run directory. This is great for two reasons: first of all, all
profiles from keyfile storage in fact have a backing file -- even the
unsaved ones. It also means you can create "unsaved" profiles in /run
and load them with `nmcli connection load`, meaning there is a file
based API for creating unsaved profiles.
The other advantage is that these profiles now survive restarting
NetworkManager. It's paramount that restarting the daemon is as
non-disruptive as possible. Persisting unsaved files to /run improves
here significantly.

--

In the past, NMSettingsConnection also implemented NMConnection interface.
That was already changed a while ago and instead users call now
nm_settings_connection_get_connection() to delegate to a
NMSimpleConnection. What however still happened was that the NMConnection
instance gets never swapped but instead the instance was modified with
nm_connection_replace_settings_from_connection(), clear-secrets, etc.
Change that and treat the NMConnection instance immutable. Instead of modifying
it, reference/clone a new instance. This changes that previously when somebody
wanted to keep a reference to an NMConnection, then the profile would be cloned.
Now, it is supposed to be safe to reference the instance directly and everybody
must ensure not to modify the instance. nmtst_connection_assert_unchanging()
should help with that.
The point is that the settings plugins may keep references to the
NMConnection instance, and so does the NMSettingsConnection. We want
to avoid cloning the instances as long as they are the same.
Likewise, the device's applied connection can now also be referenced
instead of cloning it. This is not yet done, and possibly there are
further improvements possible.

--

Also implement multiple keyfile directores /usr/lib, /etc, /run (rh #1674545,
bgo #772414).

It was always the case that multiple files could provide the same UUID
(both in case of keyfile and ifcfg-rh). For keyfile plugin, if a profile in
read-only storage in /usr/lib gets modified, then it gets actually stored in
/etc (or /run, if the profile is unsaved).

--

While at it, make /etc/network/interfaces profiles for ifupdown plugin reloadable.

--

https://bugzilla.gnome.org/show_bug.cgi?id=772414
https://bugzilla.gnome.org/show_bug.cgi?id=744711
https://bugzilla.redhat.com/show_bug.cgi?id=1674545
2019-07-16 19:09:08 +02:00
..
tests libnm/crypto: accept TPM2-wrapped PEM keys 2019-07-10 17:31:48 +02:00
meson.build libnm-core: add ovs-dpdk setting 2019-06-14 12:10:20 +02:00
nm-connection-private.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-connection.c libnm: accept %NULL argument in nmtst_connection_assert_unchanging() 2019-07-16 12:35:36 +02:00
nm-connection.h libnm: add NM_CONNECTION_SERIALIZE_WITH_SECRETS_AGENT_OWNED serialization flag 2019-06-17 12:12:02 +02:00
nm-core-enum-types.c.template libnm-core: add ovs-dpdk setting 2019-06-14 12:10:20 +02:00
nm-core-enum-types.h.template build: use template files for enum types' sources generation 2017-12-18 11:25:06 +01:00
nm-core-internal.h libnm,core: add support for "suppress_prefixlength" rule attribute 2019-07-16 10:03:17 +02:00
nm-core-types-internal.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-core-types.h libnm-core: add ovs-dpdk setting 2019-06-14 12:10:20 +02:00
nm-crypto-gnutls.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-crypto-impl.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-crypto-nss.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-crypto.c libnm/crypto: accept TPM2-wrapped PEM keys 2019-07-10 17:31:48 +02:00
nm-crypto.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-dbus-interface.h settings: rework tracking settings connections and settings plugins 2019-07-16 19:09:08 +02:00
nm-dbus-utils.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-errors.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-errors.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-json.c libnm-core: don't use RTLD_DEEPBIND when building with asan 2018-02-15 15:34:03 +01:00
nm-json.h shared: move most of "shared/nm-utils" to "shared/nm-glib-aux" 2019-04-18 18:59:09 +02:00
nm-keyfile-internal.h settings: rework tracking settings connections and settings plugins 2019-07-16 19:09:08 +02:00
nm-keyfile-utils.c libnm: add nm_key_file_get_boolean() helper 2019-07-16 12:35:36 +02:00
nm-keyfile-utils.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-keyfile.c settings: rework tracking settings connections and settings plugins 2019-07-16 19:09:08 +02:00
nm-property-compare.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-property-compare.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-6lowpan.c libnm-core: reorder code in settings 2019-01-15 09:55:24 +01:00
nm-setting-6lowpan.h libnm-core: add NMSetting{6Lowpan,Wpan}Class to a public header 2018-06-29 22:34:23 +02:00
nm-setting-8021x.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-8021x.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-adsl.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-adsl.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-bluetooth.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-bluetooth.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-bond.c libnm-core: change unsupported modes for arp_ip_targets bond option 2019-06-11 18:30:18 +02:00
nm-setting-bond.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-bridge-port.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-bridge-port.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-bridge.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-bridge.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-cdma.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-cdma.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-connection.c libnm,cli,ifcfg-rh: add connection:wait-device-timeout property 2019-07-10 12:43:06 +02:00
nm-setting-connection.h libnm,cli,ifcfg-rh: add connection:wait-device-timeout property 2019-07-10 12:43:06 +02:00
nm-setting-dcb.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-dcb.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-dummy.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-dummy.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-ethtool.c libnm: belatedly expose nm_ethtool_optname_is_feature() in libnm 2019-06-11 14:58:14 +02:00
nm-setting-ethtool.h libnm: belatedly expose nm_ethtool_optname_is_feature() in libnm 2019-06-11 14:58:14 +02:00
nm-setting-generic.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-generic.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-gsm.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-gsm.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-infiniband.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-infiniband.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-ip-config.c libnm,core: add support for "suppress_prefixlength" rule attribute 2019-07-16 10:03:17 +02:00
nm-setting-ip-config.h libnm,core: add support for "suppress_prefixlength" rule attribute 2019-07-16 10:03:17 +02:00
nm-setting-ip-tunnel.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-ip-tunnel.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-ip4-config.c libnm: add nm_connection_to_dbus_full() with options argument 2019-06-28 16:48:17 +02:00
nm-setting-ip4-config.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-ip6-config.c libnm: add nm_connection_to_dbus_full() with options argument 2019-06-28 16:48:17 +02:00
nm-setting-ip6-config.h ipv6: add 'disabled' method 2019-06-11 16:22:04 +02:00
nm-setting-macsec.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-macsec.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-macvlan.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-macvlan.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-match.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-match.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-olpc-mesh.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-olpc-mesh.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-ovs-bridge.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-ovs-bridge.h libnm-core: add ovs-bridge setting 2017-10-30 17:40:08 +01:00
nm-setting-ovs-dpdk.c libnm-core: add ovs-dpdk setting 2019-06-14 12:10:20 +02:00
nm-setting-ovs-dpdk.h libnm-core: add ovs-dpdk setting 2019-06-14 12:10:20 +02:00
nm-setting-ovs-interface.c core/ovs-interface: add support for dpdk type 2019-06-14 12:10:20 +02:00
nm-setting-ovs-interface.h libnm-core: add ovs-interface setting 2017-10-30 17:40:08 +01:00
nm-setting-ovs-patch.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-ovs-patch.h libnm-core: add ovs-patch setting 2017-10-30 17:40:08 +01:00
nm-setting-ovs-port.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-ovs-port.h libnm-core: add ovs-port setting 2017-10-30 17:40:08 +01:00
nm-setting-ppp.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-ppp.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-pppoe.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-pppoe.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-private.h libnm: add nm_connection_to_dbus_full() with options argument 2019-06-28 16:48:17 +02:00
nm-setting-proxy.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-proxy.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-serial.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-serial.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-sriov.c libnm: add nm_connection_to_dbus_full() with options argument 2019-06-28 16:48:17 +02:00
nm-setting-sriov.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-tc-config.c libnm: add nm_connection_to_dbus_full() with options argument 2019-06-28 16:48:17 +02:00
nm-setting-tc-config.h libnm: don't return deep-copied strv array from nm_tc_qdisc_get_attribute_names() 2019-04-20 08:09:52 +02:00
nm-setting-team-port.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-team-port.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-team.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-team.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-tun.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-tun.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-user.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-user.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-vlan.c libnm: add nm_connection_to_dbus_full() with options argument 2019-06-28 16:48:17 +02:00
nm-setting-vlan.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-vpn.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-setting-vpn.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-vxlan.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-vxlan.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-wifi-p2p.c shared: build helper "libnm-libnm-core-{intern|aux}.la" library for libnm-core 2019-04-18 18:59:09 +02:00
nm-setting-wifi-p2p.h core/setting-wifi-p2p: Add WFD IEs property to P2P settings 2019-02-21 10:10:20 +01:00
nm-setting-wimax.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-wimax.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-wired.c core/wired: include the invalide MAC address in error messages 2019-07-02 16:06:03 +02:00
nm-setting-wired.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-wireguard.c libnm: add nm_connection_to_dbus_full() with options argument 2019-06-28 16:48:17 +02:00
nm-setting-wireguard.h libnm: change nm_wireguard_peer_set_endpoint() API to allow validation 2019-03-07 17:54:25 +01:00
nm-setting-wireless-security.c all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-wireless-security.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-wireless.c libnm: implement serialization options (inject timestamp/seen-bssids) for nm_connection_to_dbus_full() 2019-06-28 16:48:17 +02:00
nm-setting-wireless.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-setting-wpan.c libnm-core: reorder code in settings 2019-01-15 09:55:24 +01:00
nm-setting-wpan.h core/setting-wpan: add page and channel properties 2018-10-07 15:46:02 +02:00
nm-setting.c libnm: add nm_connection_to_dbus_full() with options argument 2019-06-28 16:48:17 +02:00
nm-setting.h all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
nm-simple-connection.c libnm: workaround assertion failure for nmtst_connection_assert_unchanging() when disposing connection 2019-06-26 09:53:54 +02:00
nm-simple-connection.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-team-utils.c libnm: add nm_connection_to_dbus_full() with options argument 2019-06-28 16:48:17 +02:00
nm-team-utils.h libnm: add nm_connection_to_dbus_full() with options argument 2019-06-28 16:48:17 +02:00
nm-utils-private.h libnm: add nm_connection_to_dbus_full() with options argument 2019-06-28 16:48:17 +02:00
nm-utils.c libnm: add nm_connection_to_dbus_full() with options argument 2019-06-28 16:48:17 +02:00
nm-utils.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-version.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-vpn-dbus-interface.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-vpn-editor-plugin.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-vpn-editor-plugin.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-vpn-plugin-info.c all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
nm-vpn-plugin-info.h all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00