mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-08 21:10:25 +01:00
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
This commit is contained in:
parent
eff0e0d123
commit
3957d40f54
2 changed files with 30 additions and 4 deletions
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -1037,6 +1039,19 @@ test_rd_znet_legacy (void)
|
|||
nmtst_assert_connection_verifies_without_normalization (connection);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue