mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 09:20:08 +01:00
device: generate stable UUID for default-wired-connection
Generate a stable connection UUID for the default-wired-connection.
Otherwise, on every reboot, the UUID changes although the generated
connection is the same.
But also hash into the UUID the machine-id, the device name and the
hardware address. So, the UUID is only the same if the connection is
identical in every aspect.
Also, the UUID is used as Network_ID for the stable-privacy address
generation mode. It is bad to re-create different UUIDs on every boot
as it causes different addresses.
(cherry picked from commit 89cf9429a7)
This commit is contained in:
parent
fd82e00f2f
commit
7ede2a7a63
2 changed files with 21 additions and 7 deletions
|
|
@ -1433,7 +1433,9 @@ new_default_connection (NMDevice *self)
|
|||
const GSList *connections;
|
||||
NMSetting *setting;
|
||||
const char *hw_address;
|
||||
char *defname, *uuid;
|
||||
gs_free char *defname = NULL;
|
||||
gs_free char *uuid = NULL;
|
||||
gs_free char *machine_id = NULL;
|
||||
|
||||
if (nm_config_get_no_auto_default_for_device (nm_config_get (), self))
|
||||
return NULL;
|
||||
|
|
@ -1448,7 +1450,19 @@ new_default_connection (NMDevice *self)
|
|||
|
||||
connections = nm_connection_provider_get_connections (nm_connection_provider_get ());
|
||||
defname = nm_device_ethernet_utils_get_default_wired_name (connections);
|
||||
uuid = nm_utils_uuid_generate ();
|
||||
if (!defname)
|
||||
return NULL;
|
||||
|
||||
machine_id = nm_utils_machine_id_read ();
|
||||
|
||||
/* Create a stable UUID. The UUID is also the Network_ID for stable-privacy addr-gen-mode,
|
||||
* thus when it changes we will also generate different IPv6 addresses. */
|
||||
uuid = _nm_utils_uuid_generate_from_strings ("default-wired",
|
||||
machine_id ?: "",
|
||||
defname,
|
||||
hw_address,
|
||||
NULL);
|
||||
|
||||
g_object_set (setting,
|
||||
NM_SETTING_CONNECTION_ID, defname,
|
||||
NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME,
|
||||
|
|
@ -1457,8 +1471,6 @@ new_default_connection (NMDevice *self)
|
|||
NM_SETTING_CONNECTION_UUID, uuid,
|
||||
NM_SETTING_CONNECTION_TIMESTAMP, (guint64) time (NULL),
|
||||
NULL);
|
||||
g_free (uuid);
|
||||
g_free (defname);
|
||||
|
||||
/* Lock the connection to the device */
|
||||
setting = nm_setting_wired_new ();
|
||||
|
|
|
|||
|
|
@ -1996,9 +1996,11 @@ device_realized (NMDevice *device, GParamSpec *pspec, NMSettings *self)
|
|||
g_object_unref (connection);
|
||||
|
||||
if (!added) {
|
||||
_LOGW ("(%s) couldn't create default wired connection: %s",
|
||||
nm_device_get_iface (device),
|
||||
error->message);
|
||||
if (!g_error_matches (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_UUID_EXISTS)) {
|
||||
_LOGW ("(%s) couldn't create default wired connection: %s",
|
||||
nm_device_get_iface (device),
|
||||
error->message);
|
||||
}
|
||||
g_clear_error (&error);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue