NetworkManager/src/devices
Thomas Haller 36ca7dd2c0 core: refactor loading machine-id and cache it
Previously, whenever we needed /etc/machine-id we would re-load it
from file. The are 3 downsides of that:

 - the smallest downside is the runtime overhead of repeatedly
   reading the file and parse it.

 - as we read it multiple times, it may change anytime. Most
   code in NetworkManager does not expect or handle a change of
   the machine-id.
   Generally, the admin should make sure that the machine-id is properly
   initialized before NetworkManager starts, and not change it. As such,
   a change of the machine-id should never happen in practice.
   But if it would change, we would get odd behaviors. Note for example
   how generate_duid_from_machine_id() already cached the generated DUID
   and only read it once.
   It's better to pick the machine-id once, and rely to use the same
   one for the remainder of the program.
   If the admin wants to change the machine-id, NetworkManager must be
   restarted as well (in case the admin cares).
   Also, as we now only load it once, it makes sense to log an error
   (once) when we fail to read the machine-id.

 - previously, loading the machine-id could fail each time. And we
   have to somehow handle that error. It seems, the best thing what we
   anyway can do, is to log an error once and continue with a fake
   machine-id. Here we add a fake machine-id based on the secret-key
   or the boot-id. Now obtaining a machine-id can no longer fail
   and error handling is no longer necessary.

Also, ensure that a machine-id of all zeros is not valid.

Technically, a machine-id is not an RFC 4122 UUID. But it's
the same size, so we also use NMUuid data structure for it.

While at it, also refactor caching of the boot-id and the secret
key. In particular, fix the thread-safety of the double-checked
locking implementations.

(cherry picked from commit 8308311264)
2018-11-14 14:18:02 +01:00
..
adsl core: give better error reason why device is incompatible with profile 2018-07-24 09:39:09 +02:00
bluetooth meson: set RPATH for libnm_device_plugin_bluetooth.so 2018-10-24 09:59:44 +02:00
ovs build: always define NM_MORE_LOGGING define and don't check with #ifdef 2018-08-27 17:49:29 +02:00
team core: give better error reason why device is incompatible with profile 2018-07-24 09:39:09 +02:00
tests all: remove consecutive empty lines 2018-04-30 16:24:52 +02:00
wifi devices/olpc: don't assert we're waiting for companion on device_added_cb() 2018-10-12 12:57:12 +02:00
wwan meson: set RPATH for libnm_device_plugin_wwan.so 2018-10-24 09:59:46 +02:00
meson.build build: add initial support for meson build system 2017-12-13 15:48:50 +01:00
nm-acd-manager.c n-acd: slightly improve logging 2018-05-29 11:18:30 +02:00
nm-acd-manager.h core: rename 'arping' to 'acd' 2018-04-18 15:22:34 +02:00
nm-device-6lowpan.c libnm: drop API nm_connection_get_setting_{6lowpan,sriov,wpan}() 2018-09-14 16:30:51 +02:00
nm-device-6lowpan.h devices: add NMDevice6Lowpan 2018-06-26 16:21:55 +02:00
nm-device-bond.c core: give better error reason why device is incompatible with profile 2018-07-24 09:39:09 +02:00
nm-device-bond.h core: refactor private data in "src" 2016-10-04 09:50:56 +02:00
nm-device-bridge.c core: give better error reason why device is incompatible with profile 2018-07-24 09:39:09 +02:00
nm-device-bridge.h bridge: move the Bluetooth NAP logic to bridge device 2017-06-01 11:57:42 +02:00
nm-device-dummy.c core: give better error reason why device is incompatible with profile 2018-07-24 09:39:09 +02:00
nm-device-dummy.h core: add support for dummy devices 2017-02-22 21:05:04 +01:00
nm-device-ethernet-utils.c device: fix a wrong comparison 2018-10-07 14:15:17 +02:00
nm-device-ethernet-utils.h settings: use delegation instead of inheritance for NMSettingsConnection and NMConnection 2018-08-28 22:27:55 +02:00
nm-device-ethernet.c core: refactor loading machine-id and cache it 2018-11-14 14:18:02 +01:00
nm-device-ethernet.h all: replace non-leading tabs with spaces 2018-02-07 13:32:04 +01:00
nm-device-factory.c core: introduce NMDeviceWireGuard 2018-08-06 08:34:27 +02:00
nm-device-factory.h core: device-factory: implement match_connection() 2017-08-05 08:03:16 +02:00
nm-device-generic.c core: give better error reason why device is incompatible with profile 2018-07-24 09:39:09 +02:00
nm-device-generic.h core: refactor private data in "src" 2016-10-04 09:50:56 +02:00
nm-device-infiniband.c core: give better error reason why device is incompatible with profile 2018-07-24 09:39:09 +02:00
nm-device-infiniband.h core: refactor private data in "src" 2016-10-04 09:50:56 +02:00
nm-device-ip-tunnel.c device: refactor setting parent in device's update_connection() 2018-08-28 22:27:54 +02:00
nm-device-ip-tunnel.h core/dbus: rework D-Bus implementation to use lower layer GDBusConnection API 2018-03-12 18:37:08 +01:00
nm-device-logging.h Revert "device: log device type too" 2017-10-31 18:48:41 +01:00
nm-device-macsec.c core: give better error reason why device is incompatible with profile 2018-07-24 09:39:09 +02:00
nm-device-macsec.h core/dbus: rework D-Bus implementation to use lower layer GDBusConnection API 2018-03-12 18:37:08 +01:00
nm-device-macvlan.c device: refactor setting parent in device's update_connection() 2018-08-28 22:27:54 +02:00
nm-device-macvlan.h core/dbus: rework D-Bus implementation to use lower layer GDBusConnection API 2018-03-12 18:37:08 +01:00
nm-device-ppp.c core: give better error reason why device is incompatible with profile 2018-07-24 09:39:09 +02:00
nm-device-ppp.h device: add NMDevicePPP 2017-08-05 08:03:15 +02:00
nm-device-private.h device: replace NM_DEVICE_CLASS_DECLARE_TYPES() macro by explicit initialization 2018-07-24 09:39:09 +02:00
nm-device-tun.c core: give better error reason why device is incompatible with profile 2018-07-24 09:39:09 +02:00
nm-device-tun.h core: refactor private data in "src" 2016-10-04 09:50:56 +02:00
nm-device-veth.c device: replace NM_DEVICE_CLASS_DECLARE_TYPES() macro by explicit initialization 2018-07-24 09:39:09 +02:00
nm-device-veth.h all: cleanup includes in header files 2016-08-17 19:51:17 +02:00
nm-device-vlan.c device: refactor setting parent in device's update_connection() 2018-08-28 22:27:54 +02:00
nm-device-vlan.h core/dbus: rework D-Bus implementation to use lower layer GDBusConnection API 2018-03-12 18:37:08 +01:00
nm-device-vxlan.c device: refactor setting parent in device's update_connection() 2018-08-28 22:27:54 +02:00
nm-device-vxlan.h core/dbus: rework D-Bus implementation to use lower layer GDBusConnection API 2018-03-12 18:37:08 +01:00
nm-device-wireguard.c core: introduce NMDeviceWireGuard 2018-08-06 08:34:27 +02:00
nm-device-wireguard.h core: introduce NMDeviceWireGuard 2018-08-06 08:34:27 +02:00
nm-device-wpan.c libnm: drop API nm_connection_get_setting_{6lowpan,sriov,wpan}() 2018-09-14 16:30:51 +02:00
nm-device-wpan.h devices: add NMDeviceWpan 2018-06-26 16:21:54 +02:00
nm-device.c core: refactor loading machine-id and cache it 2018-11-14 14:18:02 +01:00
nm-device.h device: add and use overrule-unmanaged flag for nm_device_check_connection_available() 2018-10-17 15:54:33 +02:00
nm-lldp-listener.c all: use nm_utils_hash_keys_to_array() 2018-03-27 09:58:00 +02:00
nm-lldp-listener.h core: refactor private data for NMExportedObject and others 2016-10-03 12:04:14 +02:00