Merge pull request #4141 from opensourcerouting/nb-minor-fixes

northbound minor fixes and improvements
This commit is contained in:
Mark Stapp 2019-04-18 13:48:15 -04:00 committed by GitHub
commit ad7d96c159
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 29 additions and 35 deletions

View File

@ -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"

View File

@ -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;
}

View File

@ -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);

View File

@ -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
}

View File

@ -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);

View File

@ -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;

View File

@ -20,7 +20,6 @@
#include <zebra.h>
#include "log.h"
#include "log_int.h"
#include "lib_errors.h"
#include "yang.h"
#include "yang_translator.h"

View File

@ -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"