NetworkManager/src/nm-initrd-generator/nm-initrd-generator.h
Beniamino Galvani 0a18e97345 initrd: set required-timeout for default IPv4 configuration
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
2021-07-05 15:15:45 +02:00

46 lines
1.2 KiB
C

/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2014, 2018 Red Hat, Inc.
*/
#ifndef __NM_INITRD_GENERATOR_H__
#define __NM_INITRD_GENERATOR_H__
#include "nm-connection.h"
#include "nm-utils.h"
#define NMI_WAIT_DEVICE_TIMEOUT_MSEC 60000
#define NMI_IP_REQUIRED_TIMEOUT_MSEC 20000
static inline int
get_ip_address_family(const char *str, gboolean with_prefix)
{
int addr_family;
if (!str)
return AF_UNSPEC;
if (with_prefix) {
if (nm_utils_parse_inaddr_prefix_bin(AF_UNSPEC, str, &addr_family, NULL, NULL))
return addr_family;
} else {
if (nm_utils_parse_inaddr_bin(AF_UNSPEC, str, &addr_family, NULL))
return addr_family;
}
return AF_UNSPEC;
}
GHashTable *nmi_ibft_read(const char *sysfs_dir);
gboolean
nmi_ibft_update_connection_from_nic(NMConnection *connection, GHashTable *nic, GError **error);
NMConnection *nmi_dt_reader_parse(const char *sysfs_dir);
GHashTable *nmi_cmdline_reader_parse(const char * sysfs_dir,
const char *const *argv,
char ** hostname,
gint64 * carrier_timeout_sec);
#endif /* __NM_INITRD_GENERATOR_H__ */