diff options
author | Emanuele Di Pascale <emanuele@voltanet.io> | 2018-11-09 16:13:12 +0100 |
---|---|---|
committer | Emanuele Di Pascale <emanuele@voltanet.io> | 2018-12-18 15:15:26 +0100 |
commit | 625b70e3da7b1ec163607cc7354404904eacf36e (patch) | |
tree | 1f94af0d2bb967420a776f62b8fefb5d0bb2a05d /lib/northbound.c | |
parent | Merge pull request #3500 from pguibert6WIND/missing_default_vrf_name (diff) | |
download | frr-625b70e3da7b1ec163607cc7354404904eacf36e.tar.xz frr-625b70e3da7b1ec163607cc7354404904eacf36e.zip |
lib: add NB phase-specific error codes
As suggested by Renato, add error codes that are specific
to the various phases of a northbound callback. These can
be used by the daemons when logging an error. The reasoning
is that validation errors typically mean that there is an
inconsistency in the configuration, a prepare error means
that we are running out of resources, and abort/apply errors
are bugs that need to be reported to the devs.
Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
Diffstat (limited to 'lib/northbound.c')
-rw-r--r-- | lib/northbound.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/lib/northbound.c b/lib/northbound.c index 09aa60b1d..a7f9c8620 100644 --- a/lib/northbound.c +++ b/lib/northbound.c @@ -719,6 +719,7 @@ static int nb_configuration_callback(const enum nb_event event, const struct lyd_node *dnode = change->cb.dnode; union nb_resource *resource; int ret = NB_ERR; + enum lib_log_refs ref; if (debug_northbound) { const char *value = "(none)"; @@ -751,12 +752,36 @@ static int nb_configuration_callback(const enum nb_event event, break; } - if (ret != NB_OK) - flog_warn( - EC_LIB_NB_CB_CONFIG, - "%s: error processing configuration change: error [%s] event [%s] operation [%s] xpath [%s]", - __func__, nb_err_name(ret), nb_event_name(event), - nb_operation_name(operation), xpath); + if (ret != NB_OK) { + switch (event) { + case NB_EV_VALIDATE: + ref = EC_LIB_NB_CB_CONFIG_VALIDATE; + break; + case NB_EV_PREPARE: + ref = EC_LIB_NB_CB_CONFIG_PREPARE; + break; + case NB_EV_ABORT: + ref = EC_LIB_NB_CB_CONFIG_ABORT; + break; + case NB_EV_APPLY: + ref = EC_LIB_NB_CB_CONFIG_APPLY; + break; + } + if (event == NB_EV_VALIDATE || event == NB_EV_PREPARE) + flog_warn( + ref, + "%s: error processing configuration change: error [%s] event [%s] operation [%s] xpath [%s]", + __func__, nb_err_name(ret), + nb_event_name(event), + nb_operation_name(operation), xpath); + else + flog_err( + ref, + "%s: error processing configuration change: error [%s] event [%s] operation [%s] xpath [%s]", + __func__, nb_err_name(ret), + nb_event_name(event), + nb_operation_name(operation), xpath); + } return ret; } |