mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-06 04:28:29 +02:00
ifcfg-rh: ensure missing STP property is interpreted as "off" (rh #922702)
The initscripts interpreted it this way, so we do too.
This commit is contained in:
parent
c934038b59
commit
360a02fc13
4 changed files with 58 additions and 2 deletions
|
|
@ -3792,6 +3792,7 @@ make_bridge_setting (shvarFile *ifcfg,
|
||||||
char *value;
|
char *value;
|
||||||
guint32 u;
|
guint32 u;
|
||||||
gboolean stp = FALSE;
|
gboolean stp = FALSE;
|
||||||
|
gboolean stp_set = FALSE;
|
||||||
|
|
||||||
s_bridge = NM_SETTING_BRIDGE (nm_setting_bridge_new ());
|
s_bridge = NM_SETTING_BRIDGE (nm_setting_bridge_new ());
|
||||||
|
|
||||||
|
|
@ -3809,13 +3810,20 @@ make_bridge_setting (shvarFile *ifcfg,
|
||||||
if (!strcasecmp (value, "on") || !strcasecmp (value, "yes")) {
|
if (!strcasecmp (value, "on") || !strcasecmp (value, "yes")) {
|
||||||
g_object_set (s_bridge, NM_SETTING_BRIDGE_STP, TRUE, NULL);
|
g_object_set (s_bridge, NM_SETTING_BRIDGE_STP, TRUE, NULL);
|
||||||
stp = TRUE;
|
stp = TRUE;
|
||||||
} else if (!strcasecmp (value, "off") || !strcasecmp (value, "no"))
|
stp_set = TRUE;
|
||||||
|
} else if (!strcasecmp (value, "off") || !strcasecmp (value, "no")) {
|
||||||
g_object_set (s_bridge, NM_SETTING_BRIDGE_STP, FALSE, NULL);
|
g_object_set (s_bridge, NM_SETTING_BRIDGE_STP, FALSE, NULL);
|
||||||
else
|
stp_set = TRUE;
|
||||||
|
} else
|
||||||
PLUGIN_WARN (IFCFG_PLUGIN_NAME, " warning: invalid STP value '%s'", value);
|
PLUGIN_WARN (IFCFG_PLUGIN_NAME, " warning: invalid STP value '%s'", value);
|
||||||
g_free (value);
|
g_free (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!stp_set) {
|
||||||
|
/* Missing or invalid STP property means "no" */
|
||||||
|
g_object_set (s_bridge, NM_SETTING_BRIDGE_STP, FALSE, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
value = svGetValue (ifcfg, "DELAY", FALSE);
|
value = svGetValue (ifcfg, "DELAY", FALSE);
|
||||||
if (value) {
|
if (value) {
|
||||||
if (stp) {
|
if (stp) {
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,7 @@ EXTRA_DIST = \
|
||||||
ifcfg-test-wired-ctc-static \
|
ifcfg-test-wired-ctc-static \
|
||||||
ifcfg-test-bridge-main \
|
ifcfg-test-bridge-main \
|
||||||
ifcfg-test-bridge-component \
|
ifcfg-test-bridge-component \
|
||||||
|
ifcfg-test-bridge-missing-stp \
|
||||||
ifcfg-test-vlan-interface \
|
ifcfg-test-vlan-interface \
|
||||||
ifcfg-test-vlan-only-vlanid \
|
ifcfg-test-vlan-only-vlanid \
|
||||||
ifcfg-test-vlan-only-device \
|
ifcfg-test-vlan-only-device \
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
DEVICE=br0
|
||||||
|
ONBOOT=no
|
||||||
|
TYPE=Bridge
|
||||||
|
BOOTPROTO=dhcp
|
||||||
|
|
||||||
|
|
@ -11853,6 +11853,46 @@ test_write_bridge_component (void)
|
||||||
g_object_unref (reread);
|
g_object_unref (reread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_read_bridge_missing_stp (void)
|
||||||
|
{
|
||||||
|
NMConnection *connection;
|
||||||
|
NMSettingBridge *s_bridge;
|
||||||
|
char *unmanaged = NULL;
|
||||||
|
char *keyfile = NULL;
|
||||||
|
char *routefile = NULL;
|
||||||
|
char *route6file = NULL;
|
||||||
|
gboolean ignore_error = FALSE;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-bridge-missing-stp",
|
||||||
|
NULL,
|
||||||
|
TYPE_BRIDGE,
|
||||||
|
NULL,
|
||||||
|
&unmanaged,
|
||||||
|
&keyfile,
|
||||||
|
&routefile,
|
||||||
|
&route6file,
|
||||||
|
&error,
|
||||||
|
&ignore_error);
|
||||||
|
g_assert (connection);
|
||||||
|
g_assert (nm_connection_verify (connection, &error));
|
||||||
|
g_assert_no_error (error);
|
||||||
|
|
||||||
|
/* ===== Bridging SETTING ===== */
|
||||||
|
|
||||||
|
s_bridge = nm_connection_get_setting_bridge (connection);
|
||||||
|
g_assert (s_bridge);
|
||||||
|
g_assert_cmpstr (nm_setting_bridge_get_interface_name (s_bridge), ==, "br0");
|
||||||
|
g_assert_cmpuint (nm_setting_bridge_get_stp (s_bridge), ==, FALSE);
|
||||||
|
|
||||||
|
g_free (unmanaged);
|
||||||
|
g_free (keyfile);
|
||||||
|
g_free (routefile);
|
||||||
|
g_free (route6file);
|
||||||
|
g_object_unref (connection);
|
||||||
|
}
|
||||||
|
|
||||||
#define TEST_IFCFG_VLAN_INTERFACE TEST_IFCFG_DIR"/network-scripts/ifcfg-test-vlan-interface"
|
#define TEST_IFCFG_VLAN_INTERFACE TEST_IFCFG_DIR"/network-scripts/ifcfg-test-vlan-interface"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -13107,10 +13147,12 @@ int main (int argc, char **argv)
|
||||||
test_write_bond_slave ();
|
test_write_bond_slave ();
|
||||||
test_write_bond_slave_ib ();
|
test_write_bond_slave_ib ();
|
||||||
|
|
||||||
|
/* bridging */
|
||||||
test_read_bridge_main ();
|
test_read_bridge_main ();
|
||||||
test_write_bridge_main ();
|
test_write_bridge_main ();
|
||||||
test_read_bridge_component ();
|
test_read_bridge_component ();
|
||||||
test_write_bridge_component ();
|
test_write_bridge_component ();
|
||||||
|
test_read_bridge_missing_stp ();
|
||||||
|
|
||||||
/* Stuff we expect to fail for now */
|
/* Stuff we expect to fail for now */
|
||||||
test_write_wired_pppoe ();
|
test_write_wired_pppoe ();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue