dcb: workarounds for lldpad/drivers and some bug fixes (rh #799241)
This commit is contained in:
89
src/nm-dcb.c
89
src/nm-dcb.c
@@ -154,23 +154,27 @@ _dcb_setup (const char *iface,
|
|||||||
|
|
||||||
/* Priority Groups */
|
/* Priority Groups */
|
||||||
flags = nm_setting_dcb_get_priority_group_flags (s_dcb);
|
flags = nm_setting_dcb_get_priority_group_flags (s_dcb);
|
||||||
SET_FLAGS (flags, "pg");
|
|
||||||
if (flags & NM_SETTING_DCB_FLAG_ENABLE) {
|
if (flags & NM_SETTING_DCB_FLAG_ENABLE) {
|
||||||
char buf[10];
|
GString *s;
|
||||||
|
gboolean success;
|
||||||
guint id;
|
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 */
|
/* Priority Groups */
|
||||||
|
g_string_append (s, " pgid:");
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
id = nm_setting_dcb_get_priority_group_id (s_dcb, i);
|
id = nm_setting_dcb_get_priority_group_id (s_dcb, i);
|
||||||
g_assert (id < 8 || id == 15);
|
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 */
|
/* Priority Group Bandwidth */
|
||||||
if (!do_helper (iface, DCBTOOL, run_func, user_data, error, "pg pgpct:%u,%u,%u,%u,%u,%u,%u,%u",
|
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, 0),
|
||||||
nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 1),
|
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, 2),
|
||||||
@@ -178,11 +182,10 @@ _dcb_setup (const char *iface,
|
|||||||
nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 4),
|
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, 5),
|
||||||
nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 6),
|
nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 6),
|
||||||
nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 7)))
|
nm_setting_dcb_get_priority_group_bandwidth (s_dcb, 7));
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
/* Priority Bandwidth */
|
/* Priority Bandwidth */
|
||||||
if (!do_helper (iface, DCBTOOL, run_func, user_data, error, "pg uppct:%u,%u,%u,%u,%u,%u,%u,%u",
|
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, 0),
|
||||||
nm_setting_dcb_get_priority_bandwidth (s_dcb, 1),
|
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, 2),
|
||||||
@@ -190,25 +193,30 @@ _dcb_setup (const char *iface,
|
|||||||
nm_setting_dcb_get_priority_bandwidth (s_dcb, 4),
|
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, 5),
|
||||||
nm_setting_dcb_get_priority_bandwidth (s_dcb, 6),
|
nm_setting_dcb_get_priority_bandwidth (s_dcb, 6),
|
||||||
nm_setting_dcb_get_priority_bandwidth (s_dcb, 7)))
|
nm_setting_dcb_get_priority_bandwidth (s_dcb, 7));
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
/* Strict Bandwidth */
|
/* Strict Bandwidth */
|
||||||
|
g_string_append (s, " strict:");
|
||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < 8; i++)
|
||||||
buf[i] = nm_setting_dcb_get_priority_strict_bandwidth (s_dcb, i) ? '1' : '0';
|
g_string_append_c (s, 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;
|
|
||||||
|
|
||||||
/* Priority Traffic Class */
|
/* Priority Traffic Class */
|
||||||
|
g_string_append (s, " up2tc:");
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
id = nm_setting_dcb_get_priority_traffic_class (s_dcb, i);
|
id = nm_setting_dcb_get_priority_traffic_class (s_dcb, i);
|
||||||
g_assert (id < 8);
|
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;
|
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;
|
return TRUE;
|
||||||
@@ -220,8 +228,26 @@ _dcb_cleanup (const char *iface,
|
|||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
/* FIXME: do we need to turn off features individually here? */
|
const char *cmds[] = {
|
||||||
return do_helper (iface, DCBTOOL, run_func, user_data, error, "dcb off");
|
"dcb off",
|
||||||
|
"app:fcoe e:0",
|
||||||
|
"app:iscsi e:0",
|
||||||
|
"app:fip e:0",
|
||||||
|
"pfc e:0",
|
||||||
|
"pg e:0",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
const char **iter = cmds;
|
||||||
|
gboolean success = TRUE;
|
||||||
|
|
||||||
|
/* Turn everything off and return first error we get (if any) */
|
||||||
|
while (iter && *iter) {
|
||||||
|
if (!do_helper (iface, DCBTOOL, run_func, user_data, success ? error : NULL, *iter))
|
||||||
|
success = FALSE;
|
||||||
|
iter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
@@ -307,12 +333,21 @@ run_helper (char **argv, guint which, gpointer user_data, GError **error)
|
|||||||
&outmsg, &errmsg, &exit_status, error);
|
&outmsg, &errmsg, &exit_status, error);
|
||||||
/* Log any stderr output */
|
/* Log any stderr output */
|
||||||
if (success && WIFEXITED (exit_status) && WEXITSTATUS (exit_status) && (errmsg || outmsg)) {
|
if (success && WIFEXITED (exit_status) && WEXITSTATUS (exit_status) && (errmsg || outmsg)) {
|
||||||
nm_log_dbg (LOGD_DCB, "'%s' failed: '%s'",
|
gboolean ignore_error = FALSE;
|
||||||
|
|
||||||
|
/* Ignore fcoeadm "success" errors like when FCoE is already set up */
|
||||||
|
if (errmsg && strstr (errmsg, "Connection already created"))
|
||||||
|
ignore_error = TRUE;
|
||||||
|
|
||||||
|
if (ignore_error == FALSE) {
|
||||||
|
nm_log_warn (LOGD_DCB, "'%s' failed: '%s'",
|
||||||
cmdline, (errmsg && strlen (errmsg)) ? errmsg : outmsg);
|
cmdline, (errmsg && strlen (errmsg)) ? errmsg : outmsg);
|
||||||
g_set_error (error, NM_DCB_ERROR, NM_DCB_ERROR_HELPER_FAILED,
|
g_set_error (error, NM_DCB_ERROR, NM_DCB_ERROR_HELPER_FAILED,
|
||||||
"Failed to run '%s'", cmdline);
|
"Failed to run '%s'", cmdline);
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
g_free (outmsg);
|
||||||
g_free (errmsg);
|
g_free (errmsg);
|
||||||
|
|
||||||
g_free (cmdline);
|
g_free (cmdline);
|
||||||
@@ -334,6 +369,14 @@ nm_dcb_setup (const char *iface, NMSettingDcb *s_dcb, GError **error)
|
|||||||
gboolean
|
gboolean
|
||||||
nm_dcb_cleanup (const char *iface, GError **error)
|
nm_dcb_cleanup (const char *iface, GError **error)
|
||||||
{
|
{
|
||||||
return _dcb_cleanup (iface, run_helper, GUINT_TO_POINTER (DCBTOOL), error);
|
gboolean success;
|
||||||
|
|
||||||
|
success = _dcb_cleanup (iface, run_helper, GUINT_TO_POINTER (DCBTOOL), error);
|
||||||
|
if (success) {
|
||||||
|
/* Only report FCoE errors if DCB cleanup was successful */
|
||||||
|
success = _fcoe_cleanup (iface, run_helper, GUINT_TO_POINTER (FCOEADM), success ? error : NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -221,12 +221,12 @@ test_dcb_priority_groups (void)
|
|||||||
"dcbtool sc eth0 app:iscsi e:0 a:0 w:0",
|
"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 app:fip e:0 a:0 w:0",
|
||||||
"dcbtool sc eth0 pfc 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 e:1 a:1 w:1" \
|
||||||
"dcbtool sc eth0 pg pgid:765f3210",
|
" pgid:765f3210" \
|
||||||
"dcbtool sc eth0 pg pgpct:10,40,5,10,5,20,7,3",
|
" pgpct:10,40,5,10,5,20,7,3" \
|
||||||
"dcbtool sc eth0 pg uppct:100,50,33,25,20,16,14,12",
|
" uppct:100,50,33,25,20,16,14,12" \
|
||||||
"dcbtool sc eth0 pg strict:01010101",
|
" strict:01010101" \
|
||||||
"dcbtool sc eth0 pg up2tc:01201201",
|
" up2tc:01201201",
|
||||||
NULL },
|
NULL },
|
||||||
};
|
};
|
||||||
NMSettingDcb *s_dcb;
|
NMSettingDcb *s_dcb;
|
||||||
@@ -268,7 +268,13 @@ static void
|
|||||||
test_dcb_cleanup (void)
|
test_dcb_cleanup (void)
|
||||||
{
|
{
|
||||||
static DcbExpected expected = { 0,
|
static DcbExpected expected = { 0,
|
||||||
{ "dcbtool sc eth0 dcb off", NULL },
|
{ "dcbtool sc eth0 dcb off",
|
||||||
|
"dcbtool sc eth0 app:fcoe e:0",
|
||||||
|
"dcbtool sc eth0 app:iscsi e:0",
|
||||||
|
"dcbtool sc eth0 app:fip e:0",
|
||||||
|
"dcbtool sc eth0 pfc e:0",
|
||||||
|
"dcbtool sc eth0 pg e:0",
|
||||||
|
NULL },
|
||||||
};
|
};
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
gboolean success;
|
gboolean success;
|
||||||
|
Reference in New Issue
Block a user