mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 18:40:09 +01:00
ifcfg-rh: accept TEAM connections also without DEVICETYPE setting
Allow omitting DEVICETYPE=Team or DEVICETYPE=TeamPort and accept team connections based on the presence of TEAM_CONFIG/TEAM_MASTER alone. Also, check first for a team slave before checking for bond slave. That is what initscripts do and matters if somebody wrongly sets MASTER and TEAM_MASTER. libteam:20d45a1e02initscripts: https://git.fedorahosted.org/cgit/initscripts.git/commit/?id=3235be4a3da91bc91c698b318935240dbdf81aac https://bugzilla.redhat.com/show_bug.cgi?id=1367180 (cherry picked from commit114eb5b963)
This commit is contained in:
parent
6de181247f
commit
a82b7c8d5e
7 changed files with 51 additions and 30 deletions
|
|
@ -1621,26 +1621,29 @@ check_if_bond_slave (shvarFile *ifcfg,
|
|||
*/
|
||||
}
|
||||
|
||||
static void
|
||||
static gboolean
|
||||
check_if_team_slave (shvarFile *ifcfg,
|
||||
NMSettingConnection *s_con)
|
||||
{
|
||||
char *value;
|
||||
gs_free char *value = NULL;
|
||||
|
||||
value = svGetValue (ifcfg, "DEVICETYPE", FALSE);
|
||||
if (!value)
|
||||
return;
|
||||
if (strcasecmp (value, TYPE_TEAM_PORT)) {
|
||||
g_free (value);
|
||||
return;
|
||||
}
|
||||
g_free (value);
|
||||
value = svGetValue (ifcfg, "TEAM_MASTER", FALSE);
|
||||
if (!value)
|
||||
return;
|
||||
return FALSE;
|
||||
g_object_set (s_con, NM_SETTING_CONNECTION_MASTER, value, NULL);
|
||||
g_object_set (s_con, NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_TEAM_SETTING_NAME, NULL);
|
||||
g_free (value);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
check_if_slave (shvarFile *ifcfg,
|
||||
NMSettingConnection *s_con)
|
||||
{
|
||||
g_return_if_fail (NM_IS_SETTING_CONNECTION (s_con));
|
||||
|
||||
if (check_if_team_slave (ifcfg, s_con))
|
||||
return;
|
||||
check_if_bond_slave (ifcfg, s_con);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -3948,8 +3951,7 @@ wired_connection_from_ifcfg (const char *file,
|
|||
g_object_unref (connection);
|
||||
return NULL;
|
||||
}
|
||||
check_if_bond_slave (ifcfg, NM_SETTING_CONNECTION (con_setting));
|
||||
check_if_team_slave (ifcfg, NM_SETTING_CONNECTION (con_setting));
|
||||
check_if_slave (ifcfg, (NMSettingConnection *) con_setting);
|
||||
nm_connection_add_setting (connection, con_setting);
|
||||
|
||||
wired_setting = make_wired_setting (ifcfg, file, &s_8021x, error);
|
||||
|
|
@ -4099,8 +4101,7 @@ infiniband_connection_from_ifcfg (const char *file,
|
|||
g_object_unref (connection);
|
||||
return NULL;
|
||||
}
|
||||
check_if_bond_slave (ifcfg, NM_SETTING_CONNECTION (con_setting));
|
||||
check_if_team_slave (ifcfg, NM_SETTING_CONNECTION (con_setting));
|
||||
check_if_slave (ifcfg, (NMSettingConnection *) con_setting);
|
||||
nm_connection_add_setting (connection, con_setting);
|
||||
|
||||
infiniband_setting = make_infiniband_setting (ifcfg, file, error);
|
||||
|
|
@ -4599,8 +4600,6 @@ is_bond_device (const char *name, shvarFile *parsed)
|
|||
|
||||
if (svGetValueBoolean (parsed, "BONDING_MASTER", FALSE))
|
||||
return TRUE;
|
||||
|
||||
/* XXX: Check for "bond[\d]+"? */
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -4816,8 +4815,7 @@ vlan_connection_from_ifcfg (const char *file,
|
|||
g_object_unref (connection);
|
||||
return NULL;
|
||||
}
|
||||
check_if_bond_slave (ifcfg, NM_SETTING_CONNECTION (con_setting));
|
||||
check_if_team_slave (ifcfg, NM_SETTING_CONNECTION (con_setting));
|
||||
check_if_slave (ifcfg, (NMSettingConnection *) con_setting);
|
||||
nm_connection_add_setting (connection, con_setting);
|
||||
|
||||
vlan_setting = make_vlan_setting (ifcfg, file, error);
|
||||
|
|
@ -5008,6 +5006,16 @@ connection_from_file_full (const char *filename,
|
|||
type = g_strdup (TYPE_ETHERNET);
|
||||
g_free (devtype);
|
||||
}
|
||||
if (!type) {
|
||||
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
|
||||
* DEVICETYPE. */
|
||||
t = svGetValue (parsed, "TEAM_CONFIG", FALSE);
|
||||
if (t)
|
||||
type = g_strdup (TYPE_TEAM);
|
||||
}
|
||||
|
||||
if (!type)
|
||||
type = svGetValue (parsed, "TYPE", FALSE);
|
||||
|
|
|
|||
|
|
@ -132,8 +132,10 @@ EXTRA_DIST = \
|
|||
ifcfg-test-dcb-pgpct-not-100 \
|
||||
ifcfg-test-fcoe-fabric \
|
||||
ifcfg-test-fcoe-vn2vn \
|
||||
ifcfg-test-team-master \
|
||||
ifcfg-test-team-port \
|
||||
ifcfg-test-team-master-1 \
|
||||
ifcfg-test-team-master-2 \
|
||||
ifcfg-test-team-port-1 \
|
||||
ifcfg-test-team-port-2 \
|
||||
ifcfg-test-team-port-empty-config \
|
||||
ifcfg-test-vlan-trailing-spaces \
|
||||
ifcfg-test-dns-options \
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
DEVICE=team0
|
||||
ONBOOT=no
|
||||
BOOTPROTO=dhcp
|
||||
TEAM_CONFIG="{ \"device\": \"team0\", \"link_watch\": { \"name\": \"ethtool\" } }"
|
||||
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
TYPE=Ethernet
|
||||
TEAM_PORT_CONFIG="{ \"p4p1\": { \"prio\": -10, \"sticky\": true } }"
|
||||
DEVICE=p4p1
|
||||
TEAM_MASTER=team0
|
||||
|
|
@ -8430,15 +8430,15 @@ test_write_fcoe_mode (gconstpointer user_data)
|
|||
}
|
||||
|
||||
static void
|
||||
test_read_team_master (void)
|
||||
test_read_team_master (gconstpointer user_data)
|
||||
{
|
||||
const char *const PATH_NAME = user_data;
|
||||
NMConnection *connection;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingTeam *s_team;
|
||||
const char *expected_config = "{ \"device\": \"team0\", \"link_watch\": { \"name\": \"ethtool\" } }";
|
||||
|
||||
connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-team-master",
|
||||
NULL, TYPE_ETHERNET, NULL);
|
||||
connection = _connection_from_file (PATH_NAME, NULL, TYPE_ETHERNET, NULL);
|
||||
|
||||
g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, "team0");
|
||||
|
||||
|
|
@ -8546,15 +8546,15 @@ test_write_team_master (void)
|
|||
}
|
||||
|
||||
static void
|
||||
test_read_team_port (void)
|
||||
test_read_team_port (gconstpointer user_data)
|
||||
{
|
||||
const char *const PATH_NAME = user_data;
|
||||
NMConnection *connection;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingTeamPort *s_team_port;
|
||||
const char *expected_config = "{ \"p4p1\": { \"prio\": -10, \"sticky\": true } }";
|
||||
|
||||
connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-team-port",
|
||||
NULL, TYPE_ETHERNET, NULL);
|
||||
connection = _connection_from_file (PATH_NAME, NULL, TYPE_ETHERNET, NULL);
|
||||
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
g_assert (s_con);
|
||||
|
|
@ -9048,9 +9048,11 @@ int main (int argc, char **argv)
|
|||
g_test_add_func (TPATH "bridge/write-component", test_write_bridge_component);
|
||||
g_test_add_func (TPATH "bridge/read-missing-stp", test_read_bridge_missing_stp);
|
||||
|
||||
g_test_add_func (TPATH "team/read-master", test_read_team_master);
|
||||
g_test_add_data_func (TPATH "team/read-master-1", TEST_IFCFG_DIR"/network-scripts/ifcfg-test-team-master-1", test_read_team_master);
|
||||
g_test_add_data_func (TPATH "team/read-master-2", TEST_IFCFG_DIR"/network-scripts/ifcfg-test-team-master-2", test_read_team_master);
|
||||
g_test_add_func (TPATH "team/write-master", test_write_team_master);
|
||||
g_test_add_func (TPATH "team/read-port", test_read_team_port);
|
||||
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/read-port-empty-config", test_read_team_port_empty_config);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue