diff --git a/isisd/isis_misc.c b/isisd/isis_misc.c index c24917454..2ce68262e 100644 --- a/isisd/isis_misc.c +++ b/isisd/isis_misc.c @@ -28,7 +28,6 @@ #include "hash.h" #include "if.h" #include "command.h" -#include "log_int.h" #include "isisd/dict.h" #include "isisd/isis_constants.h" diff --git a/lib/libfrr.c b/lib/libfrr.c index 1afe30d61..0d4c8d6c0 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -38,6 +38,7 @@ #include "lib_errors.h" #include "db.h" #include "northbound_cli.h" +#include "northbound_db.h" DEFINE_HOOK(frr_late_init, (struct thread_master * tm), (tm)) DEFINE_KOOH(frr_early_fini, (), ()) @@ -654,6 +655,10 @@ struct thread_master *frr_init(void) yang_init(); nb_init(master, di->yang_modules, di->n_yang_modules); + if (nb_db_init() != NB_OK) + flog_warn(EC_LIB_NB_DATABASE, + "%s: failed to initialize northbound database", + __func__); return master; } diff --git a/lib/log.h b/lib/log.h index 189857a90..9368bf9e8 100644 --- a/lib/log.h +++ b/lib/log.h @@ -94,6 +94,7 @@ extern void zlog_warn(const char *format, ...) PRINTF_ATTRIBUTE(1, 2); extern void zlog_info(const char *format, ...) PRINTF_ATTRIBUTE(1, 2); extern void zlog_notice(const char *format, ...) PRINTF_ATTRIBUTE(1, 2); extern void zlog_debug(const char *format, ...) PRINTF_ATTRIBUTE(1, 2); +extern void zlog(int priority, const char *format, ...) PRINTF_ATTRIBUTE(2, 3); /* For logs which have error codes associated with them */ #define flog_err(ferr_id, format, ...) \ @@ -102,7 +103,8 @@ extern void zlog_debug(const char *format, ...) PRINTF_ATTRIBUTE(1, 2); flog_err(ferr_id, format, ##__VA_ARGS__) #define flog_warn(ferr_id, format, ...) \ zlog_warn("[EC %" PRIu32 "] " format, ferr_id, ##__VA_ARGS__) - +#define flog(priority, ferr_id, format, ...) \ + zlog(priority, "[EC %" PRIu32 "] " format, ferr_id, ##__VA_ARGS__) extern void zlog_thread_info(int log_level); diff --git a/lib/log_int.h b/lib/log_int.h index 58ae031e1..287e626ea 100644 --- a/lib/log_int.h +++ b/lib/log_int.h @@ -51,7 +51,6 @@ extern const char *zlog_priority[]; /* Generic function for zlog. */ extern void vzlog(int priority, const char *format, va_list args); -extern void zlog(int priority, const char *format, ...) PRINTF_ATTRIBUTE(2, 3); #ifdef __cplusplus } diff --git a/lib/northbound.c b/lib/northbound.c index 9deb9c6cc..d332aa465 100644 --- a/lib/northbound.c +++ b/lib/northbound.c @@ -454,13 +454,6 @@ int nb_candidate_edit(struct nb_config *candidate, struct lyd_node *dnode; char xpath_edit[XPATH_MAXLEN]; - if (!nb_operation_is_valid(operation, nb_node->snode)) { - flog_warn(EC_LIB_NB_CANDIDATE_EDIT_ERROR, - "%s: %s operation not valid for %s", __func__, - nb_operation_name(operation), xpath); - return NB_ERR; - } - /* Use special notation for leaf-lists (RFC 6020, section 9.13.5). */ if (nb_node->snode->nodetype == LYS_LEAFLIST) snprintf(xpath_edit, sizeof(xpath_edit), "%s[.='%s']", xpath, @@ -753,40 +746,44 @@ static int nb_callback_configuration(const enum nb_event event, ret = (*nb_node->cbs.move)(event, dnode); break; default: - break; + flog_err(EC_LIB_DEVELOPMENT, + "%s: unknown operation (%u) [xpath %s]", __func__, + operation, xpath); + exit(1); } if (ret != NB_OK) { - enum lib_log_refs ref = 0; + int priority; + enum lib_log_refs ref; switch (event) { case NB_EV_VALIDATE: + priority = LOG_WARNING; ref = EC_LIB_NB_CB_CONFIG_VALIDATE; break; case NB_EV_PREPARE: + priority = LOG_WARNING; ref = EC_LIB_NB_CB_CONFIG_PREPARE; break; case NB_EV_ABORT: + priority = LOG_WARNING; ref = EC_LIB_NB_CB_CONFIG_ABORT; break; case NB_EV_APPLY: + priority = LOG_ERR; ref = EC_LIB_NB_CB_CONFIG_APPLY; break; + default: + flog_err(EC_LIB_DEVELOPMENT, + "%s: unknown event (%u) [xpath %s]", + __func__, event, xpath); + exit(1); } - 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); + + flog(priority, 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; @@ -1677,12 +1674,6 @@ void nb_init(struct thread_master *tm, exit(1); } - /* Initialize the northbound database (used for the rollback log). */ - if (nb_db_init() != NB_OK) - flog_warn(EC_LIB_NB_DATABASE, - "%s: failed to initialize northbound database", - __func__); - /* Create an empty running configuration. */ running_config = nb_config_new(NULL); diff --git a/lib/northbound_sysrepo.c b/lib/northbound_sysrepo.c index 4359c39ca..33b6c2478 100644 --- a/lib/northbound_sysrepo.c +++ b/lib/northbound_sysrepo.c @@ -374,7 +374,7 @@ static int frr_sr_state_data_iter_cb(const struct lys_node *snode, /* Callback for state retrieval. */ static int frr_sr_state_cb(const char *xpath, sr_val_t **values, size_t *values_cnt, uint64_t request_id, - void *private_ctx) + const char *original_xpath, void *private_ctx) { struct list *elements; struct yang_data *data; diff --git a/lib/yang.c b/lib/yang.c index 7982d14fd..c5123d6ab 100644 --- a/lib/yang.c +++ b/lib/yang.c @@ -20,7 +20,6 @@ #include #include "log.h" -#include "log_int.h" #include "lib_errors.h" #include "yang.h" #include "yang_translator.h" diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index e47499b06..013a1d9a7 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -24,7 +24,6 @@ #include "if.h" #include "linklist.h" #include "log.h" -#include "log_int.h" #include "memory.h" #include "mpls.h" #include "nexthop.h"