Until now, fault status changes just log the new status. This means that
the administrator has to find two consecutive status change messages to
see what actually changed.
This commit changes the log message format to prefix new faults with '+'
and faults that disappeared with '-'. Existing faults that are still
present are not prefixed.
This also simplifies the code a little by making ds_put_cfm_fault()
put spaces before fault names instead of after.
Signed-off-by: Ben Pfaff <blp@nicira.com>
- * Copyright (c) 2010, 2011 Nicira Networks.
+ * Copyright (c) 2010, 2011, 2012 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
-ds_put_cfm_fault(struct ds *ds, int fault)
+ds_put_cfm_fault(struct ds *ds, int old_fault, int new_fault)
- size_t length = ds->length;
int i;
for (i = 0; i < CFM_FAULT_N_REASONS; i++) {
int reason = 1 << i;
int i;
for (i = 0; i < CFM_FAULT_N_REASONS; i++) {
int reason = 1 << i;
- if (fault & reason) {
- ds_put_format(ds, "%s ", cfm_fault_reason_to_str(reason));
+ if ((old_fault | new_fault) & reason) {
+ ds_put_format(ds, " %s%s",
+ (!(old_fault & reason) ? "+"
+ : !(new_fault & reason) ? "-"
+ : ""),
+ cfm_fault_reason_to_str(reason));
-
- if (ds->length > length) {
- ds_truncate(ds, ds->length - 1);
- }
if (old_cfm_fault != cfm->fault) {
struct ds ds = DS_EMPTY_INITIALIZER;
if (old_cfm_fault != cfm->fault) {
struct ds ds = DS_EMPTY_INITIALIZER;
- ds_put_cfm_fault(&ds, cfm->fault);
- VLOG_INFO_RL(&rl, "%s: CFM fault status changed: %s", cfm->name,
+ ds_put_cfm_fault(&ds, old_cfm_fault, cfm->fault);
+ VLOG_INFO_RL(&rl, "%s: CFM fault status changed:%s", cfm->name,
ds_cstr_ro(&ds));
ds_destroy(&ds);
}
ds_cstr_ro(&ds));
ds_destroy(&ds);
}
cfm_print_details(struct ds *ds, const struct cfm *cfm)
{
struct remote_mp *rmp;
cfm_print_details(struct ds *ds, const struct cfm *cfm)
{
struct remote_mp *rmp;
ds_put_format(ds, "---- %s ----\n", cfm->name);
ds_put_format(ds, "MPID %"PRIu64":%s%s\n", cfm->mpid,
cfm->extended ? " extended" : "",
cfm->fault_override >= 0 ? " fault_override" : "");
ds_put_format(ds, "---- %s ----\n", cfm->name);
ds_put_format(ds, "MPID %"PRIu64":%s%s\n", cfm->mpid,
cfm->extended ? " extended" : "",
cfm->fault_override >= 0 ? " fault_override" : "");
-
- if (cfm_get_fault(cfm)) {
- ds_put_cstr(ds, "\tfault: ");
- ds_put_cfm_fault(ds, cfm_get_fault(cfm));
+ fault = cfm_get_fault(cfm);
+ if (fault) {
+ ds_put_cstr(ds, "\tfault:");
+ ds_put_cfm_fault(ds, fault, fault);