From a9f71b48cd4e0e48accd00fdbaa696e556ff5fca Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Mon, 27 May 2019 11:24:45 +0200 Subject: 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). --- src/initrd/nmi-cmdline-reader.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/initrd/nmi-cmdline-reader.c b/src/initrd/nmi-cmdline-reader.c index b9c75c1ba2..65a2530149 100644 --- a/src/initrd/nmi-cmdline-reader.c +++ b/src/initrd/nmi-cmdline-reader.c @@ -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); -- cgit v1.2.1