mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-05 15:00:25 +01:00
initrd: support the rd.net.dhcp.retry argument
Since we always set autoconnect-retries=1, use the value of
rd.net.dhcp.retry as a multiplier for the DHCP timeout.
(cherry picked from commit 099ce63888)
This commit is contained in:
parent
772b213321
commit
329902339e
2 changed files with 14 additions and 4 deletions
|
|
@ -53,7 +53,6 @@ reader_new(void)
|
|||
g_hash_table_new_full(nm_direct_hash, NULL, g_object_unref, NULL),
|
||||
.vlan_parents = g_ptr_array_new_with_free_func(g_free),
|
||||
.array = g_ptr_array_new(),
|
||||
.dhcp_timeout = 90,
|
||||
};
|
||||
|
||||
return reader;
|
||||
|
|
@ -1068,6 +1067,8 @@ nmi_cmdline_reader_parse(const char * sysfs_dir,
|
|||
gs_unref_ptrarray GPtrArray *routes = NULL;
|
||||
gs_unref_ptrarray GPtrArray *znets = NULL;
|
||||
int i;
|
||||
guint64 dhcp_timeout = 90;
|
||||
guint64 dhcp_num_tries = 1;
|
||||
|
||||
reader = reader_new();
|
||||
|
||||
|
|
@ -1086,11 +1087,14 @@ nmi_cmdline_reader_parse(const char * sysfs_dir,
|
|||
reader->ignore_auto_dns = !_nm_utils_ascii_str_to_bool(argument, TRUE);
|
||||
else if (nm_streq(tag, "rd.net.timeout.dhcp")) {
|
||||
if (nm_streq0(argument, "infinity")) {
|
||||
reader->dhcp_timeout = G_MAXINT32;
|
||||
dhcp_timeout = G_MAXINT32;
|
||||
} else {
|
||||
reader->dhcp_timeout =
|
||||
_nm_utils_ascii_str_to_int64(argument, 10, 1, G_MAXINT32, reader->dhcp_timeout);
|
||||
dhcp_timeout =
|
||||
_nm_utils_ascii_str_to_int64(argument, 10, 1, G_MAXINT32, dhcp_timeout);
|
||||
}
|
||||
} else if (nm_streq(tag, "rd.net.dhcp.retry")) {
|
||||
dhcp_num_tries =
|
||||
_nm_utils_ascii_str_to_int64(argument, 10, 1, G_MAXINT32, dhcp_num_tries);
|
||||
} else if (nm_streq(tag, "rd.net.dhcp.vendor-class")) {
|
||||
if (nm_utils_validate_dhcp4_vendor_class_id(argument, NULL))
|
||||
nm_utils_strdup_reset(&reader->dhcp4_vci, argument);
|
||||
|
|
@ -1100,6 +1104,8 @@ nmi_cmdline_reader_parse(const char * sysfs_dir,
|
|||
}
|
||||
}
|
||||
|
||||
reader->dhcp_timeout = NM_CLAMP(dhcp_timeout * dhcp_num_tries, 1, G_MAXINT32);
|
||||
|
||||
for (i = 0; argv[i]; i++) {
|
||||
gs_free char *argument_clone = NULL;
|
||||
char * argument;
|
||||
|
|
|
|||
|
|
@ -240,7 +240,11 @@ test_dhcp_timeout(void)
|
|||
{NM_MAKE_STRV("ip=dhcp", "rd.net.timeout.dhcp=0"), 90},
|
||||
{NM_MAKE_STRV("ip=dhcp", "rd.net.timeout.dhcp=foobar"), 90},
|
||||
{NM_MAKE_STRV("ip=dhcp", "rd.net.timeout.dhcp=42"), 42},
|
||||
{NM_MAKE_STRV("ip=dhcp", "rd.net.dhcp.retry=2"), 180},
|
||||
{NM_MAKE_STRV("ip=dhcp", "rd.net.dhcp.retry=3", "rd.net.timeout.dhcp=40"), 120},
|
||||
{NM_MAKE_STRV("ip=dhcp", "rd.net.timeout.dhcp=infinity"), G_MAXINT32},
|
||||
{NM_MAKE_STRV("ip=dhcp", "rd.net.timeout.dhcp=infinity", "rd.net.dhcp.retry=100"),
|
||||
G_MAXINT32},
|
||||
};
|
||||
guint i;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue