mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-03 23:20:15 +01:00
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.
(cherry picked from commit 29a576496e)
This commit is contained in:
parent
e8a7d1500a
commit
293710434d
5 changed files with 78 additions and 3 deletions
|
|
@ -2064,6 +2064,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 \
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -8862,6 +8862,63 @@ test_write_team_port (void)
|
|||
nmtst_assert_connection_equals (connection, TRUE, reread, FALSE);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue