From 2504a72ec0d07a4624fa3e6cd559b34a131f9b42 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 27 May 2022 10:53:48 +0200 Subject: [PATCH] initrd: set a default carrier timeout of 10 seconds in initrd In initrd, a too short carrier timeout means that the machine will possibly fail to boot. On the other hand, increasing the value doesn't have side effects, except for a bit longer delay on some machines. Increase the value to 10 seconds. Note that the default value is not propagated to the real root. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1239 --- src/nm-initrd-generator/nm-initrd-generator.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/nm-initrd-generator/nm-initrd-generator.c b/src/nm-initrd-generator/nm-initrd-generator.c index ef7047941d..09f8baf21a 100644 --- a/src/nm-initrd-generator/nm-initrd-generator.c +++ b/src/nm-initrd-generator/nm-initrd-generator.c @@ -198,7 +198,7 @@ main(int argc, char *argv[]) confs = g_array_new(FALSE, FALSE, sizeof(NMUtilsNamedValue)); g_array_set_clear_func(confs, (GDestroyNotify) nm_utils_named_value_clear_with_g_free); - if (carrier_timeout_sec != 0) { + { nm_auto_unref_keyfile GKeyFile *keyfile = NULL; NMUtilsNamedValue v; @@ -212,9 +212,19 @@ main(int argc, char *argv[]) g_key_file_set_int64(keyfile, NM_CONFIG_KEYFILE_GROUPPREFIX_DEVICE "-15-carrier-timeout", NM_CONFIG_KEYFILE_KEY_DEVICE_CARRIER_WAIT_TIMEOUT, - carrier_timeout_sec * 1000); - if (!dump_to_stdout) - add_keyfile_comment(keyfile, "from \"rd.net.timeout.carrier\""); + (carrier_timeout_sec != 0 ? carrier_timeout_sec : 10) * 1000); + if (carrier_timeout_sec == 0) { + g_key_file_set_value(keyfile, + NM_CONFIG_KEYFILE_GROUP_CONFIG, + NM_CONFIG_KEYFILE_KEY_CONFIG_ENABLE, + "env:initrd"); + } + + if (!dump_to_stdout) { + add_keyfile_comment(keyfile, + carrier_timeout_sec == 0 ? "default initrd carrier timeout" + : "from \"rd.net.timeout.carrier\""); + } v = (NMUtilsNamedValue){ .name = g_strdup_printf("%s/15-carrier-timeout.conf", run_config_dir),