From 98575bd5138afdb61a3837a2a73436eb05490f4a Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 12 Sep 2022 11:33:46 +0200 Subject: [PATCH] initrd: generate initrd generator profiles with autoconnect-priority -100 ... and profiles from firmware with autoconnect-priority -200. In general, after switch root we remember the still activated profile in /run, and NetworkManager would take over the device with the same profile as before. In that case, autoconnect and autoconnect-priority doesn't matter. Autoconnect only matters when having a device in disconnected state and not being blocked from autoconnect. For example, if you unplug and replug the cable. In that case, it does make sense to me that user-provided profiles from real-root are preferred. To me the reasons for this change is not very strong (but neither are the reasons against it). Read the discussion on rhbz #2089707. https://bugzilla.redhat.com/show_bug.cgi?id=2089707 Co-authored-by: Lubomir Rintel https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1376 --- src/nm-initrd-generator/nm-initrd-generator.h | 3 +++ src/nm-initrd-generator/nmi-cmdline-reader.c | 6 ++++++ src/nm-initrd-generator/nmi-dt-reader.c | 2 ++ src/nm-initrd-generator/nmi-ibft-reader.c | 2 ++ 4 files changed, 13 insertions(+) diff --git a/src/nm-initrd-generator/nm-initrd-generator.h b/src/nm-initrd-generator/nm-initrd-generator.h index a7bbbe65fa..87db9fc665 100644 --- a/src/nm-initrd-generator/nm-initrd-generator.h +++ b/src/nm-initrd-generator/nm-initrd-generator.h @@ -12,6 +12,9 @@ #define NMI_WAIT_DEVICE_TIMEOUT_MSEC 60000 #define NMI_IP_REQUIRED_TIMEOUT_MSEC 20000 +#define NMI_AUTOCONNECT_PRIORITY_CMDLINE -100 +#define NMI_AUTOCONNECT_PRIORITY_FIRMWARE -200 + static inline int get_ip_address_family(const char *str, gboolean with_prefix) { diff --git a/src/nm-initrd-generator/nmi-cmdline-reader.c b/src/nm-initrd-generator/nmi-cmdline-reader.c index 985da2d30f..431537cf52 100644 --- a/src/nm-initrd-generator/nmi-cmdline-reader.c +++ b/src/nm-initrd-generator/nmi-cmdline-reader.c @@ -99,6 +99,7 @@ reader_create_connection(Reader *reader, const char *ifname, const char *mac, const char *type_name, + int autoconnect_priority, NMConnectionMultiConnect multi_connect) { NMConnection *connection; @@ -155,6 +156,8 @@ reader_create_connection(Reader *reader, multi_connect, NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES, 1, + NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY, + autoconnect_priority, NULL); if (nm_streq0(type_name, NM_SETTING_INFINIBAND_SETTING_NAME)) { @@ -189,6 +192,7 @@ reader_get_default_connection(Reader *reader) NULL, NULL, NM_SETTING_WIRED_SETTING_NAME, + NMI_AUTOCONNECT_PRIORITY_CMDLINE, NM_CONNECTION_MULTI_CONNECT_MULTIPLE); nm_connection_add_setting(con, nm_setting_wired_new()); reader->default_connection = con; @@ -264,6 +268,7 @@ reader_get_connection(Reader *reader, ifname, mac, type_name, + NMI_AUTOCONNECT_PRIORITY_CMDLINE, NM_CONNECTION_MULTI_CONNECT_SINGLE); } setting = (NMSetting *) nm_connection_get_setting_connection(connection); @@ -1526,6 +1531,7 @@ nmi_cmdline_reader_parse(const char *etc_connections_dir, NULL, bootif, NM_SETTING_WIRED_SETTING_NAME, + NMI_AUTOCONNECT_PRIORITY_FIRMWARE, NM_CONNECTION_MULTI_CONNECT_SINGLE); } else { g_object_set(s_wired, NM_SETTING_WIRED_MAC_ADDRESS, bootif, NULL); diff --git a/src/nm-initrd-generator/nmi-dt-reader.c b/src/nm-initrd-generator/nmi-dt-reader.c index 77ded4ac94..f1279d5807 100644 --- a/src/nm-initrd-generator/nmi-dt-reader.c +++ b/src/nm-initrd-generator/nmi-dt-reader.c @@ -248,6 +248,8 @@ nmi_dt_reader_parse(const char *sysfs_dir) NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_CONNECTION_ID, "OpenFirmware Connection", + NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY, + NMI_AUTOCONNECT_PRIORITY_FIRMWARE, NULL)); s_ip4 = nm_setting_ip4_config_new(); diff --git a/src/nm-initrd-generator/nmi-ibft-reader.c b/src/nm-initrd-generator/nmi-ibft-reader.c index f7145c9946..a5330fd2cb 100644 --- a/src/nm-initrd-generator/nmi-ibft-reader.c +++ b/src/nm-initrd-generator/nmi-ibft-reader.c @@ -330,6 +330,8 @@ connection_setting_add(GHashTable *nic, id, NM_SETTING_CONNECTION_INTERFACE_NAME, NULL, + NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY, + NMI_AUTOCONNECT_PRIORITY_FIRMWARE, NULL); g_free(uuid);