summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2020-05-27 12:01:21 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2020-05-28 14:34:44 +0200
commit3957d40f54167bcc49dd4147bfa8d6a159304677 (patch)
treec59dd17d56f04ed2e2d4c01f6e0201ff04ec62de
parenteff0e0d1233d834403accad29cb7ec05ea4f915b (diff)
downloadNetworkManager-3957d40f54167bcc49dd4147bfa8d6a159304677.tar.gz
initrd: don't generate new connections for rd.znet
The rd.znet specifies the s390 parameters of an existing connection. If no matching connection exists, we should not create a new one. https://bugzilla.redhat.com/show_bug.cgi?id=1840287
-rw-r--r--src/initrd/nmi-cmdline-reader.c18
-rw-r--r--src/initrd/tests/test-cmdline-reader.c16
2 files changed, 30 insertions, 4 deletions
diff --git a/src/initrd/nmi-cmdline-reader.c b/src/initrd/nmi-cmdline-reader.c
index 2f6afefcb7..d4cb04df2f 100644
--- a/src/initrd/nmi-cmdline-reader.c
+++ b/src/initrd/nmi-cmdline-reader.c
@@ -796,7 +796,9 @@ reader_parse_rd_znet (Reader *reader, char *argument, gboolean net_ifnames)
ifname = g_strdup_printf ("%s%d", prefix, index);
}
- connection = reader_get_connection (reader, ifname, NM_SETTING_WIRED_SETTING_NAME, TRUE);
+ connection = reader_get_connection (reader, ifname, NM_SETTING_WIRED_SETTING_NAME, FALSE);
+ if (!connection)
+ return;
s_wired = nm_connection_get_setting_wired (connection);
g_object_set (s_wired,
NM_SETTING_WIRED_S390_NETTYPE, nettype,
@@ -884,6 +886,7 @@ nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv, char **
gboolean net_ifnames = TRUE;
gs_unref_ptrarray GPtrArray *nameservers = NULL;
gs_unref_ptrarray GPtrArray *routes = NULL;
+ gs_unref_ptrarray GPtrArray *znets = NULL;
int i;
reader = reader_new ();
@@ -948,9 +951,11 @@ nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv, char **
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)
- reader_parse_rd_znet (reader, argument, net_ifnames);
- else if (g_ascii_strcasecmp (tag, "BOOTIF") == 0) {
+ else if (strcmp (tag, "rd.znet") == 0) {
+ if (!znets)
+ znets = g_ptr_array_new_with_free_func (g_free);
+ g_ptr_array_add (znets, g_strdup (argument));
+ } else if (g_ascii_strcasecmp (tag, "BOOTIF") == 0) {
nm_clear_g_free (&bootif_val);
bootif_val = g_strdup (argument);
}
@@ -1016,6 +1021,11 @@ nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv, char **
if (nameservers)
reader_add_nameservers (reader, nameservers);
+ if (znets) {
+ for (i = 0; i < znets->len; i++)
+ reader_parse_rd_znet (reader, znets->pdata[i], net_ifnames);
+ }
+
g_hash_table_foreach (reader->hash, _normalize_conn, NULL);
NM_SET_OUT (hostname, g_steal_pointer (&reader->hostname));
diff --git a/src/initrd/tests/test-cmdline-reader.c b/src/initrd/tests/test-cmdline-reader.c
index 4c972e7384..5379c3a3bf 100644
--- a/src/initrd/tests/test-cmdline-reader.c
+++ b/src/initrd/tests/test-cmdline-reader.c
@@ -917,6 +917,7 @@ test_rd_znet (void)
{
gs_unref_hashtable GHashTable *connections = NULL;
const char *const*const ARGV = NM_MAKE_STRV ("ip=10.11.12.13::10.11.12.1:24:foo.example.com:enc800:none",
+ "ip=slc600:dhcp",
"rd.znet=qeth,0.0.0800,0.0.0801,0.0.0802,layer2=0,portno=1",
"rd.znet=ctc,0.0.0600,0.0.0601,layer2=0,portno=0");
NMConnection *connection;
@@ -1004,6 +1005,7 @@ test_rd_znet_legacy (void)
const char *const*const ARGV = NM_MAKE_STRV ("ip=10.11.12.13::10.11.12.1:24:foo.example.com:eth0:none",
"rd.znet=qeth,0.0.0800,0.0.0801,0.0.0802,layer2=0,portno=1",
"rd.znet=ctc,0.0.0600,0.0.0601,layer2=0,portno=0",
+ "ip=ctc0:dhcp",
"net.ifnames=0");
NMConnection *connection;
NMSettingConnection *s_con;
@@ -1038,6 +1040,19 @@ test_rd_znet_legacy (void)
}
static void
+test_rd_znet_no_ip (void)
+{
+ gs_unref_hashtable GHashTable *connections = NULL;
+ const char *const*const ARGV = NM_MAKE_STRV ("rd.znet=qeth,0.0.0800,0.0.0801,0.0.0802,layer2=0,portno=1");
+ gs_free char *hostname = NULL;
+
+ connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV, &hostname);
+ g_assert (connections);
+ g_assert_cmpint (g_hash_table_size (connections), ==, 0);
+ g_assert_cmpstr (hostname, ==, NULL);
+}
+
+static void
test_bootif (void)
{
gs_unref_hashtable GHashTable *connections = NULL;
@@ -1228,6 +1243,7 @@ int main (int argc, char **argv)
g_test_add_func ("/initrd/cmdline/ignore_extra", test_ignore_extra);
g_test_add_func ("/initrd/cmdline/rd_znet", test_rd_znet);
g_test_add_func ("/initrd/cmdline/rd_znet/legacy", test_rd_znet_legacy);
+ g_test_add_func ("/initrd/cmdline/rd_znet/no_ip", test_rd_znet_no_ip);
g_test_add_func ("/initrd/cmdline/bootif", test_bootif);
g_test_add_func ("/initrd/cmdline/bootif/hwtype", test_bootif_hwtype);
g_test_add_func ("/initrd/cmdline/bootif/off", test_bootif_off);