summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2020-01-11 14:11:58 +0100
committerThomas Haller <thaller@redhat.com>2020-01-14 16:43:26 +0100
commit59ead7095202fa4df5e33d3d78469a4c80471cd3 (patch)
tree71161f927e4c8860cb9fd5fc06f3fb5419721a54
parentde818bf610ba0fed2b275a19fe3e6f9cbfa1862b (diff)
downloadNetworkManager-59ead7095202fa4df5e33d3d78469a4c80471cd3.tar.gz
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.
-rw-r--r--src/initrd/nmi-ibft-reader.c1
-rw-r--r--src/initrd/tests/test-cmdline-reader.c24
-rw-r--r--src/initrd/tests/test-ibft-reader.c3
3 files changed, 28 insertions, 0 deletions
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
@@ -768,6 +768,27 @@ test_team (void)
}
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)
{
gs_unref_hashtable GHashTable *connections = NULL;
@@ -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);