summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-03-18 13:39:52 -0500
committerDan Williams <dcbw@redhat.com>2014-03-25 22:46:59 -0500
commit5233e6b913e85ae05c265058cec0984b83a057d0 (patch)
tree409fe5016e8b775163d82392b9830d8a578cf021
parent706af1aec550c1df710d5f8fe075a045f418358a (diff)
downloadNetworkManager-5233e6b913e85ae05c265058cec0984b83a057d0.tar.gz
dcb: set all Priority Group options at the same time (rh #799241)
First, lldpad doesn't support disabling priority groups (e:0) without specifying a complete priority group config (which wouldn't be used anyway, since you're turning it off!). While this bug is being fixed upstream, we'll just ignore errors turning off PG, since if you're using DCB on an interface, you probably want to use it all the time. Second, lldpad really wants all PG options on the same configuration line, not split apart, because it validates the complete package of options before applying them, regardless of whether or not they are given in the same command. Since NM was just emitting all the options in separate dcbtool invocations anyway, just combine them all into a single invocation.
-rw-r--r--src/nm-dcb.c74
-rw-r--r--src/tests/test-dcb.c12
2 files changed, 47 insertions, 39 deletions
diff --git a/src/nm-dcb.c b/src/nm-dcb.c
index d42cf23ea1..89a6507c1a 100644
--- a/src/nm-dcb.c
+++ b/src/nm-dcb.c
@@ -154,61 +154,69 @@ _dcb_setup (const char *iface,
/* Priority Groups */
flags = nm_setting_dcb_get_priority_group_flags (s_dcb);
- SET_FLAGS (flags, "pg");
if (flags & NM_SETTING_DCB_FLAG_ENABLE) {
- char buf[10];
+ GString *s;
+ gboolean success;
guint id;
+ s = g_string_sized_new (150);
+
+ g_string_append_printf (s, "pg e:1 a:%c w:%c",
+ flags & NM_SETTING_DCB_FLAG_ADVERTISE ? '1' : '0',
+ flags & NM_SETTING_DCB_FLAG_WILLING ? '1' : '0');
+
/* Priority Groups */
+ g_string_append (s, " pgid:");
for (i = 0; i < 8; i++) {
id = nm_setting_dcb_get_priority_group_id (s_dcb, i);
g_assert (id < 8 || id == 15);
- buf[i] = (id < 8) ? ('0' + id) : 'f';
+ g_string_append_c (s, (id < 8) ? ('0' + id) : 'f');
}
- buf[i] = 0;
- if (!do_helper (iface, DCBTOOL, run_func, user_data, error, "pg pgid:%s", buf))
- return FALSE;
/* Priority Group Bandwidth */
- if (!do_helper (iface, DCBTOOL, run_func, user_data, error, "pg pgpct:%u,%u,%u,%u,%u,%u,%u,%u",
- nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 0),
- nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 1),
- nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 2),
- nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 3),
- nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 4),
- nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 5),
- nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 6),
- nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 7)))
- return FALSE;
+ g_string_append_printf (s, " pgpct:%u,%u,%u,%u,%u,%u,%u,%u",
+ nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 0),
+ nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 1),
+ nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 2),
+ nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 3),
+ nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 4),
+ nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 5),
+ nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 6),
+ nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 7));
/* Priority Bandwidth */
- if (!do_helper (iface, DCBTOOL, run_func, user_data, error, "pg uppct:%u,%u,%u,%u,%u,%u,%u,%u",
- nm_setting_dcb_get_priority_bandwidth (s_dcb, 0),
- nm_setting_dcb_get_priority_bandwidth (s_dcb, 1),
- nm_setting_dcb_get_priority_bandwidth (s_dcb, 2),
- nm_setting_dcb_get_priority_bandwidth (s_dcb, 3),
- nm_setting_dcb_get_priority_bandwidth (s_dcb, 4),
- nm_setting_dcb_get_priority_bandwidth (s_dcb, 5),
- nm_setting_dcb_get_priority_bandwidth (s_dcb, 6),
- nm_setting_dcb_get_priority_bandwidth (s_dcb, 7)))
- return FALSE;
+ g_string_append_printf (s, " uppct:%u,%u,%u,%u,%u,%u,%u,%u",
+ nm_setting_dcb_get_priority_bandwidth (s_dcb, 0),
+ nm_setting_dcb_get_priority_bandwidth (s_dcb, 1),
+ nm_setting_dcb_get_priority_bandwidth (s_dcb, 2),
+ nm_setting_dcb_get_priority_bandwidth (s_dcb, 3),
+ nm_setting_dcb_get_priority_bandwidth (s_dcb, 4),
+ nm_setting_dcb_get_priority_bandwidth (s_dcb, 5),
+ nm_setting_dcb_get_priority_bandwidth (s_dcb, 6),
+ nm_setting_dcb_get_priority_bandwidth (s_dcb, 7));
/* Strict Bandwidth */
+ g_string_append (s, " strict:");
for (i = 0; i < 8; i++)
- buf[i] = nm_setting_dcb_get_priority_strict_bandwidth (s_dcb, i) ? '1' : '0';
- buf[i] = 0;
- if (!do_helper (iface, DCBTOOL, run_func, user_data, error, "pg strict:%s", buf))
- return FALSE;
+ g_string_append_c (s, nm_setting_dcb_get_priority_strict_bandwidth (s_dcb, i) ? '1' : '0');
/* Priority Traffic Class */
+ g_string_append (s, " up2tc:");
for (i = 0; i < 8; i++) {
id = nm_setting_dcb_get_priority_traffic_class (s_dcb, i);
g_assert (id < 8);
- buf[i] = '0' + id;
+ g_string_append_c (s, '0' + id);
}
- buf[i] = 0;
- if (!do_helper (iface, DCBTOOL, run_func, user_data, error, "pg up2tc:%s", buf))
+
+ success = do_helper (iface, DCBTOOL, run_func, user_data, error, s->str);
+ g_string_free (s, TRUE);
+ if (!success)
return FALSE;
+ } else {
+ /* Ignore disable failure since lldpad <= 0.9.46 does not support disabling
+ * priority groups without specifying an entire PG config.
+ */
+ do_helper (iface, DCBTOOL, run_func, user_data, error, "pg e:0");
}
return TRUE;
diff --git a/src/tests/test-dcb.c b/src/tests/test-dcb.c
index 0a0924423e..c950ac6d0b 100644
--- a/src/tests/test-dcb.c
+++ b/src/tests/test-dcb.c
@@ -221,12 +221,12 @@ test_dcb_priority_groups (void)
"dcbtool sc eth0 app:iscsi e:0 a:0 w:0",
"dcbtool sc eth0 app:fip e:0 a:0 w:0",
"dcbtool sc eth0 pfc e:0 a:0 w:0",
- "dcbtool sc eth0 pg e:1 a:1 w:1",
- "dcbtool sc eth0 pg pgid:765f3210",
- "dcbtool sc eth0 pg pgpct:10,40,5,10,5,20,7,3",
- "dcbtool sc eth0 pg uppct:100,50,33,25,20,16,14,12",
- "dcbtool sc eth0 pg strict:01010101",
- "dcbtool sc eth0 pg up2tc:01201201",
+ "dcbtool sc eth0 pg e:1 a:1 w:1" \
+ " pgid:765f3210" \
+ " pgpct:10,40,5,10,5,20,7,3" \
+ " uppct:100,50,33,25,20,16,14,12" \
+ " strict:01010101" \
+ " up2tc:01201201",
NULL },
};
NMSettingDcb *s_dcb;