initrd/cmdline: add support for rd.neednet option

This is used to indicate the network dracut module should fall back to
configure network automatically (as with ip=dhcp was specified) if
there's no other network configuration present on the command line.

The option is documented in dracut.cmdline(7).

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/167
This commit is contained in:
Lubomir Rintel 2019-05-27 11:24:45 +02:00
parent 7502fb0f5e
commit 04621c6c0f

View file

@ -678,6 +678,7 @@ nmi_cmdline_reader_parse (const char *sysfs_dir, char **argv)
const char *tag;
char *argument;
gboolean ignore_bootif = FALSE;
gboolean neednet = FALSE;
char *bootif = NULL;
int i;
@ -706,6 +707,8 @@ nmi_cmdline_reader_parse (const char *sysfs_dir, char **argv)
parse_rd_peerdns (connections, argument);
else if (strcmp (tag, "rd.bootif") == 0)
ignore_bootif = !_nm_utils_ascii_str_to_bool (argument, TRUE);
else if (strcmp (tag, "rd.neednet") == 0)
neednet = _nm_utils_ascii_str_to_bool (argument, TRUE);
else if (strcasecmp (tag, "BOOTIF") == 0)
bootif = argument;
}
@ -723,6 +726,10 @@ nmi_cmdline_reader_parse (const char *sysfs_dir, char **argv)
NM_SETTING_WIRED_MAC_ADDRESS, bootif,
NULL);
}
if (neednet && g_hash_table_size (connections) == 0) {
/* Make sure there's some connection. */
get_conn (connections, NULL, NM_SETTING_WIRED_SETTING_NAME);
}
g_hash_table_foreach (connections, _normalize_conn, NULL);