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:
Dan Williams 2013-03-22 09:13:12 -05:00
parent c934038b59
commit 360a02fc13
4 changed files with 58 additions and 2 deletions

View file

@ -3792,6 +3792,7 @@ make_bridge_setting (shvarFile *ifcfg,
char *value;
guint32 u;
gboolean stp = FALSE;
gboolean stp_set = FALSE;
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")) {
g_object_set (s_bridge, NM_SETTING_BRIDGE_STP, TRUE, NULL);
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);
else
stp_set = TRUE;
} else
PLUGIN_WARN (IFCFG_PLUGIN_NAME, " warning: invalid STP value '%s'", 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);
if (value) {
if (stp) {

View file

@ -81,6 +81,7 @@ EXTRA_DIST = \
ifcfg-test-wired-ctc-static \
ifcfg-test-bridge-main \
ifcfg-test-bridge-component \
ifcfg-test-bridge-missing-stp \
ifcfg-test-vlan-interface \
ifcfg-test-vlan-only-vlanid \
ifcfg-test-vlan-only-device \

View file

@ -0,0 +1,5 @@
DEVICE=br0
ONBOOT=no
TYPE=Bridge
BOOTPROTO=dhcp

View file

@ -11853,6 +11853,46 @@ test_write_bridge_component (void)
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"
static void
@ -13107,10 +13147,12 @@ int main (int argc, char **argv)
test_write_bond_slave ();
test_write_bond_slave_ib ();
/* bridging */
test_read_bridge_main ();
test_write_bridge_main ();
test_read_bridge_component ();
test_write_bridge_component ();
test_read_bridge_missing_stp ();
/* Stuff we expect to fail for now */
test_write_wired_pppoe ();