summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2017-11-06 15:32:01 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2017-11-06 16:40:57 +0100
commit29a576496e23278abab310ce83cad98239908e9f (patch)
tree623458f7b306799cba3d0bbbe281a6e9f057cce0
parent84878ac4e493276fefe45b3288ca48bdaa9cdaf3 (diff)
downloadNetworkManager-29a576496e23278abab310ce83cad98239908e9f.tar.gz
ifcfg-rh: persist the connection type for TeamPort connections
Currently the ifcfg-rh plugin doesn't explicitly store the connection type for team slaves and is only able to read back ethernet and vlan connections. Leave this unchanged for ethernet and vlan slaves, but store the TYPE variable for other connection types (Wi-Fi and Infiniband) so that we can properly determine their type when the connection is read.
-rw-r--r--Makefile.am1
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c8
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c5
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Team_Infiniband_Port.cexpected9
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c58
5 files changed, 78 insertions, 3 deletions
diff --git a/Makefile.am b/Makefile.am
index 23429b5741..95e7125c3d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2087,6 +2087,7 @@ EXTRA_DIST += \
src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Permissions.cexpected \
src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Proxy_Basic.cexpected \
src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Team_Port.cexpected \
+ src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Team_Infiniband_Port.cexpected \
src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_VLAN_reorder_hdr.cexpected \
src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_WiFi_Band_A.cexpected \
src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_WiFi_Hidden.cexpected \
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
index 4754bea5d3..66add713b0 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
@@ -5261,8 +5261,12 @@ connection_from_file_full (const char *filename,
else if (!strcasecmp (devtype, TYPE_TEAM_PORT)) {
gs_free char *device = NULL;
+ type = svGetValueStr_cp (parsed, "TYPE");
device = svGetValueStr_cp (parsed, "DEVICE");
- if (device && is_vlan_device (device, parsed))
+
+ if (type) {
+ /* nothing to do */
+ } else if (device && is_vlan_device (device, parsed))
type = g_strdup (TYPE_VLAN);
else
type = g_strdup (TYPE_ETHERNET);
@@ -5273,7 +5277,7 @@ connection_from_file_full (const char *filename,
gs_free char *t = NULL;
/* Team and TeamPort types are also accepted by the mere
- * presense of TEAM_CONFIG/TEAM_MASTER. They don't require
+ * presence of TEAM_CONFIG/TEAM_MASTER. They don't require
* DEVICETYPE. */
t = svGetValueStr_cp (parsed, "TEAM_CONFIG");
if (t)
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
index d16f46be1a..5c8de7d12a 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
@@ -1821,7 +1821,10 @@ write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg)
} else if (nm_setting_connection_is_slave_type (s_con, NM_SETTING_TEAM_SETTING_NAME)) {
svSetValueStr (ifcfg, "TEAM_MASTER_UUID", master);
svSetValueStr (ifcfg, "TEAM_MASTER", master_iface);
- svUnsetValue (ifcfg, "TYPE");
+ if (NM_IN_STRSET (type,
+ NM_SETTING_WIRED_SETTING_NAME,
+ NM_SETTING_VLAN_SETTING_NAME))
+ svUnsetValue (ifcfg, "TYPE");
}
}
diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Team_Infiniband_Port.cexpected b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Team_Infiniband_Port.cexpected
new file mode 100644
index 0000000000..460278e1eb
--- /dev/null
+++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Team_Infiniband_Port.cexpected
@@ -0,0 +1,9 @@
+CONNECTED_MODE=no
+TYPE=InfiniBand
+TEAM_PORT_CONFIG="{ \"inf1\": { \"prio\": -10, \"sticky\": true } }"
+NAME="Test Write Team Infiniband Port"
+UUID=${UUID}
+DEVICE=inf1
+ONBOOT=yes
+TEAM_MASTER=team0
+DEVICETYPE=TeamPort
diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
index 52dbd9320c..5044a2d7d8 100644
--- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
+++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
@@ -8863,6 +8863,63 @@ test_write_team_port (void)
}
static void
+test_write_team_infiniband_port (void)
+{
+ nmtst_auto_unlinkfile char *testfile = NULL;
+ gs_unref_object NMConnection *connection = NULL;
+ gs_unref_object NMConnection *reread = NULL;
+ NMSettingConnection *s_con;
+ NMSettingTeamPort *s_team_port;
+ NMSettingInfiniband *s_inf;
+ const char *expected_config = "{ \"inf1\": { \"prio\": -10, \"sticky\": true } }";
+ shvarFile *f;
+
+ connection = nm_simple_connection_new ();
+
+ /* Connection setting */
+ s_con = (NMSettingConnection *) nm_setting_connection_new ();
+ nm_connection_add_setting (connection, NM_SETTING (s_con));
+
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_ID, "Test Write Team Infiniband Port",
+ NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (),
+ NM_SETTING_CONNECTION_TYPE, NM_SETTING_INFINIBAND_SETTING_NAME,
+ NM_SETTING_CONNECTION_MASTER, "team0",
+ NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_TEAM_SETTING_NAME,
+ NM_SETTING_CONNECTION_INTERFACE_NAME, "inf1",
+ NULL);
+
+ /* Team setting */
+ s_team_port = (NMSettingTeamPort *) nm_setting_team_port_new ();
+ nm_connection_add_setting (connection, NM_SETTING (s_team_port));
+ g_object_set (s_team_port, NM_SETTING_TEAM_PORT_CONFIG, expected_config, NULL);
+
+ /* Infiniband setting */
+ s_inf = (NMSettingInfiniband *) nm_setting_infiniband_new ();
+ nm_connection_add_setting (connection, NM_SETTING (s_inf));
+ g_object_set (s_inf, NM_SETTING_INFINIBAND_TRANSPORT_MODE, "datagram", NULL);
+
+ nmtst_assert_connection_verifies (connection);
+
+ _writer_new_connec_exp (connection,
+ TEST_SCRATCH_DIR "/network-scripts/",
+ TEST_IFCFG_DIR "/network-scripts/ifcfg-Test_Write_Team_Infiniband_Port.cexpected",
+ &testfile);
+
+ f = _svOpenFile (testfile);
+ _svGetValue_check (f, "TYPE", "InfiniBand");
+ _svGetValue_check (f, "DEVICETYPE", "TeamPort");
+ _svGetValue_check (f, "TEAM_PORT_CONFIG", expected_config);
+ _svGetValue_check (f, "TEAM_MASTER", "team0");
+ svCloseFile (f);
+
+ reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET,
+ NULL);
+
+ nmtst_assert_connection_equals (connection, TRUE, reread, FALSE);
+}
+
+static void
test_read_team_port_empty_config (void)
{
NMConnection *connection;
@@ -9821,6 +9878,7 @@ int main (int argc, char **argv)
g_test_add_data_func (TPATH "team/read-port-1", TEST_IFCFG_DIR"/network-scripts/ifcfg-test-team-port-1", test_read_team_port);
g_test_add_data_func (TPATH "team/read-port-2", TEST_IFCFG_DIR"/network-scripts/ifcfg-test-team-port-2", test_read_team_port);
g_test_add_func (TPATH "team/write-port", test_write_team_port);
+ g_test_add_func (TPATH "team/write-infiniband-port", test_write_team_infiniband_port);
g_test_add_func (TPATH "team/read-port-empty-config", test_read_team_port_empty_config);
g_test_add_func (TPATH "team/reread-slave", test_team_reread_slave);