process s390 specific device info from rd.znet parameter in nm-initrd-generator

syntax: rd.znet=<nettype>,<subchannels>,<options>

The s390 specific options used to create the network interface in the kernel
are currently not processed by nm-initrd-generator causing incomplete ifcfg file.

fixes https://bugzilla.redhat.com/show_bug.cgi?id=1753975
This commit is contained in:
Dan Horák 2019-09-20 16:25:17 +02:00 committed by Thomas Haller
parent 7df769600b
commit 11d4412ee1
2 changed files with 34 additions and 1 deletions

View file

@ -86,7 +86,7 @@ main (int argc, char *argv[])
int errsv;
option_context = g_option_context_new ("-- [ip=...] [rd.route=...] [bridge=...] [bond=...] [team=...] [vlan=...] "
"[bootdev=...] [nameserver=...] [rd.peerdns=...] [rd.bootif=...] [BOOTIF=...] ... ");
"[bootdev=...] [nameserver=...] [rd.peerdns=...] [rd.bootif=...] [BOOTIF=...] [rd.znet=...] ... ");
g_option_context_set_summary (option_context, "Generate early NetworkManager configuration.");
g_option_context_set_description (option_context,

View file

@ -683,6 +683,37 @@ parse_rd_peerdns (GHashTable *connections, char *argument)
NULL);
}
static void
parse_rd_znet (GHashTable *connections, char *argument)
{
const char *nettype = NULL;
const char *tmp = NULL;
const char *subchannels[4] = { 0, 0, 0, 0 };
NMConnection *connection;
NMSettingWired *s_wired = NULL;
nettype = get_word (&argument, ',');
subchannels[0] = get_word (&argument, ',');
subchannels[1] = get_word (&argument, ',');
if (g_strcmp0 (nettype, "ctc") != 0) {
subchannels[2] = get_word (&argument, ',');
}
connection = get_conn (connections, NULL, NULL);
s_wired = nm_connection_get_setting_wired (connection);
g_object_set (s_wired,
NM_SETTING_WIRED_S390_NETTYPE, nettype,
NM_SETTING_WIRED_S390_SUBCHANNELS, &subchannels,
NULL);
while ((tmp = get_word (&argument, ',')) != NULL) {
gs_strfreev char ** optval = NULL;
optval = g_strsplit (tmp, "=", 2);
nm_setting_wired_add_s390_option (s_wired, optval[0], optval[1]);
}
}
static void
_normalize_conn (gpointer key, gpointer value, gpointer user_data)
{
@ -729,6 +760,8 @@ nmi_cmdline_reader_parse (const char *sysfs_dir, char **argv)
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 (strcmp (tag, "rd.znet") == 0)
parse_rd_znet (connections, argument);
else if (strcasecmp (tag, "BOOTIF") == 0)
bootif = argument;
}