From 59ead7095202fa4df5e33d3d78469a4c80471cd3 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Sat, 11 Jan 2020 14:11:58 +0100 Subject: [PATCH] initrd/ibft-reader: don't set con.interface-name in iBFT connections If an argument in form ip=eth0:ibft is specified, we'd first create a wired connection with con.interface-name and then proceed completing it from the iBFT block. At that point we also add the MAC address, so the interface-name is no longer necessary.. Worse even, for VLAN connections, it results in an attempt to create a VLAN with the same name as the parent wired device. Ooops. Let's just drop it. MAC address is guarranteed to be there and does the right thing for both plain wired devices as well as VLANs. --- src/initrd/nmi-ibft-reader.c | 1 + src/initrd/tests/test-cmdline-reader.c | 24 ++++++++++++++++++++++++ src/initrd/tests/test-ibft-reader.c | 3 +++ 3 files changed, 28 insertions(+) diff --git a/src/initrd/nmi-ibft-reader.c b/src/initrd/nmi-ibft-reader.c index ffce98fc40..47b90ebfdb 100644 --- a/src/initrd/nmi-ibft-reader.c +++ b/src/initrd/nmi-ibft-reader.c @@ -296,6 +296,7 @@ connection_setting_add (GHashTable *nic, NM_SETTING_CONNECTION_TYPE, type, NM_SETTING_CONNECTION_UUID, uuid, NM_SETTING_CONNECTION_ID, id, + NM_SETTING_CONNECTION_INTERFACE_NAME, NULL, NULL); g_free (uuid); diff --git a/src/initrd/tests/test-cmdline-reader.c b/src/initrd/tests/test-cmdline-reader.c index 1d4bb9a6e8..5ea5e105c0 100644 --- a/src/initrd/tests/test-cmdline-reader.c +++ b/src/initrd/tests/test-cmdline-reader.c @@ -767,6 +767,27 @@ test_team (void) g_assert_cmpint (nm_setting_connection_get_multi_connect (s_con), ==, NM_CONNECTION_MULTI_CONNECT_SINGLE); } +static void +test_ibft_ip_dev (void) +{ + const char *const*ARGV = NM_MAKE_STRV ("ip=eth0:ibft"); + gs_unref_hashtable GHashTable *connections = NULL; + NMSettingConnection *s_con; + NMConnection *connection; + + connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV); + g_assert (connections); + g_assert_cmpint (g_hash_table_size (connections), ==, 1); + + connection = g_hash_table_lookup (connections, "eth0"); + g_assert (connection); + + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con); + g_assert_cmpstr (nm_setting_connection_get_connection_type (s_con), ==, NM_SETTING_VLAN_SETTING_NAME); + g_assert_cmpstr (nm_setting_connection_get_interface_name (s_con), ==, NULL); +} + static void test_ibft (void) { @@ -782,11 +803,13 @@ test_ibft (void) g_assert (connection); nmtst_assert_connection_verifies_without_normalization (connection); g_assert_cmpstr (nm_connection_get_id (connection), ==, "iBFT VLAN Connection 0"); + g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, NULL); connection = g_hash_table_lookup (connections, "ibft2"); g_assert (connection); nmtst_assert_connection_verifies_without_normalization (connection); g_assert_cmpstr (nm_connection_get_id (connection), ==, "iBFT Connection 2"); + g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, NULL); } static void @@ -1045,6 +1068,7 @@ int main (int argc, char **argv) g_test_add_func ("/initrd/cmdline/team", test_team); g_test_add_func ("/initrd/cmdline/bridge", test_bridge); g_test_add_func ("/initrd/cmdline/bridge/default", test_bridge_default); + g_test_add_func ("/initrd/cmdline/ibft/ip_dev", test_ibft_ip_dev); g_test_add_func ("/initrd/cmdline/ibft", test_ibft); g_test_add_func ("/initrd/cmdline/ignore_extra", test_ignore_extra); g_test_add_func ("/initrd/cmdline/rd_znet", test_rd_znet); diff --git a/src/initrd/tests/test-ibft-reader.c b/src/initrd/tests/test-ibft-reader.c index 932c1a48d3..f7709543f1 100644 --- a/src/initrd/tests/test-ibft-reader.c +++ b/src/initrd/tests/test-ibft-reader.c @@ -65,6 +65,7 @@ test_read_ibft_dhcp (void) g_assert (s_con); g_assert_cmpstr (nm_setting_connection_get_connection_type (s_con), ==, NM_SETTING_WIRED_SETTING_NAME); g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, "iBFT Connection 1"); + g_assert_cmpstr (nm_setting_connection_get_interface_name (s_con), ==, NULL); g_assert_cmpint (nm_setting_connection_get_timestamp (s_con), ==, 0); g_assert (nm_setting_connection_get_autoconnect (s_con)); @@ -109,6 +110,7 @@ test_read_ibft_static (void) g_assert (s_con); g_assert_cmpstr (nm_setting_connection_get_connection_type (s_con), ==, NM_SETTING_WIRED_SETTING_NAME); g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, "iBFT Connection 0"); + g_assert_cmpstr (nm_setting_connection_get_interface_name (s_con), ==, NULL); g_assert_cmpint (nm_setting_connection_get_timestamp (s_con), ==, 0); g_assert (nm_setting_connection_get_autoconnect (s_con)); @@ -178,6 +180,7 @@ test_read_ibft_vlan (void) s_con = nm_connection_get_setting_connection (connection); g_assert (s_con); g_assert_cmpstr (nm_setting_connection_get_connection_type (s_con), ==, NM_SETTING_VLAN_SETTING_NAME); + g_assert_cmpstr (nm_setting_connection_get_interface_name (s_con), ==, NULL); /* ===== WIRED SETTING ===== */ s_wired = nm_connection_get_setting_wired (connection);