summaryrefslogtreecommitdiff
path: root/src/nm-initrd-generator/nmi-cmdline-reader.c
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2021-06-24 08:09:10 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2021-07-05 16:47:11 +0200
commit4e10b94a1db47be8e8a50531987d2c0970ad4dc2 (patch)
treef959788c99b4b786c2cd454a9f2ac30bb5a34098 /src/nm-initrd-generator/nmi-cmdline-reader.c
parentba64505d30a5a1d407eeab13d47b032364f76f01 (diff)
downloadNetworkManager-bg/required-timeout-1-32.tar.gz
initrd: set required-timeout for default IPv4 configurationbg/required-timeout-1-32
If the kernel command-line doesn't contain an explict ip=$method, currently the generator creates connections with both IPv4 and IPv6 set to 'auto', and both allowed to fail. Since NM is run in configure-and-quit mode in the initrd, NM can get an IPv4 address or an IPv6 one (or both) depending on which address family is quicker to complete. This unpredictable behavior is not present in the legacy module, which always does IPv4 only by default. Set a required-timeout of 20 seconds for IPv4, so that NM will preferably get an IPv4, or will fall back to IPv6. See also: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/729 (cherry picked from commit 0a18e97345894a6ea76fd336a5b4e2ed7a1b537b)
Diffstat (limited to 'src/nm-initrd-generator/nmi-cmdline-reader.c')
-rw-r--r--src/nm-initrd-generator/nmi-cmdline-reader.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/nm-initrd-generator/nmi-cmdline-reader.c b/src/nm-initrd-generator/nmi-cmdline-reader.c
index 0a7e0d64e2..35978ba3e4 100644
--- a/src/nm-initrd-generator/nmi-cmdline-reader.c
+++ b/src/nm-initrd-generator/nmi-cmdline-reader.c
@@ -119,6 +119,8 @@ reader_create_connection(Reader * reader,
reader->dhcp_timeout,
NM_SETTING_IP4_CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER,
reader->dhcp4_vci,
+ NM_SETTING_IP_CONFIG_REQUIRED_TIMEOUT,
+ NMI_IP_REQUIRED_TIMEOUT_MSEC,
NULL);
setting = nm_setting_ip6_config_new();
@@ -401,18 +403,19 @@ reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument)
gs_unref_hashtable GHashTable *ibft = NULL;
const char * tmp;
const char * tmp2;
- const char * kind = NULL;
- const char * client_ip = NULL;
- const char * peer = NULL;
- const char * gateway_ip = NULL;
- const char * netmask = NULL;
- const char * client_hostname = NULL;
- const char * iface_spec = NULL;
- const char * mtu = NULL;
- const char * macaddr = NULL;
- int client_ip_family = AF_UNSPEC;
- int client_ip_prefix = -1;
- const char * dns[2] = {
+ const char * kind = NULL;
+ const char * client_ip = NULL;
+ const char * peer = NULL;
+ const char * gateway_ip = NULL;
+ const char * netmask = NULL;
+ const char * client_hostname = NULL;
+ const char * iface_spec = NULL;
+ const char * mtu = NULL;
+ const char * macaddr = NULL;
+ int client_ip_family = AF_UNSPEC;
+ int client_ip_prefix = -1;
+ gboolean clear_ip4_required_timeout = TRUE;
+ const char * dns[2] = {
NULL,
NULL,
};
@@ -679,8 +682,13 @@ reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument)
g_clear_error(&error);
}
}
+ } else {
+ clear_ip4_required_timeout = FALSE;
}
+ if (clear_ip4_required_timeout)
+ g_object_set(s_ip4, NM_SETTING_IP_CONFIG_REQUIRED_TIMEOUT, -1, NULL);
+
if (peer && *peer)
_LOGW(LOGD_CORE, "Ignoring peer: %s (not implemented)\n", peer);