From ae0994f6eb301491aafb8fef8f1d8c6a9033fae9 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 24 May 2019 20:15:31 -0400 Subject: [PATCH] lib: Separate out the debug_init api Separate out the debug_init api to have 2 functions: 1) Function to register a callback 2) Function to initiate the cli. Signed-off-by: Donald Sharp --- lib/debug.c | 3 +++ lib/debug.h | 6 ++++++ lib/libfrr.c | 4 ++++ lib/northbound_cli.c | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/debug.c b/lib/debug.c index a39623b039..3248ceb13b 100644 --- a/lib/debug.c +++ b/lib/debug.c @@ -54,7 +54,10 @@ void debug_init(struct debug_callbacks *cb) } debug_cb_list_add_head(&cb_head, cb); +} +void debug_init_cli(void) +{ install_element(ENABLE_NODE, &debug_all_cmd); install_element(CONFIG_NODE, &debug_all_cmd); } diff --git a/lib/debug.h b/lib/debug.h index 0ee5963ec6..f25cd42691 100644 --- a/lib/debug.h +++ b/lib/debug.h @@ -241,6 +241,12 @@ struct debug_callbacks { */ void debug_init(struct debug_callbacks *cb); +/* + * Turn on the cli to turn on/off debugs. + * Should only be called by libfrr + */ +void debug_init_cli(void); + #ifdef __cplusplus } #endif diff --git a/lib/libfrr.c b/lib/libfrr.c index 5970e70a6b..8fa1509b7d 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -39,6 +39,7 @@ #include "db.h" #include "northbound_cli.h" #include "northbound_db.h" +#include "debug.h" DEFINE_HOOK(frr_late_init, (struct thread_master * tm), (tm)) DEFINE_KOOH(frr_early_fini, (), ()) @@ -654,6 +655,9 @@ struct thread_master *frr_init(void) lib_error_init(); yang_init(); + + debug_init_cli(); + nb_init(master, di->yang_modules, di->n_yang_modules); if (nb_db_init() != NB_OK) flog_warn(EC_LIB_NB_DATABASE, diff --git a/lib/northbound_cli.c b/lib/northbound_cli.c index ae1b0578a0..7b7b526af0 100644 --- a/lib/northbound_cli.c +++ b/lib/northbound_cli.c @@ -1722,8 +1722,8 @@ void nb_cli_init(struct thread_master *tm) /* Initialize the shared candidate configuration. */ vty_shared_candidate_config = nb_config_new(NULL); - /* Install debug commands */ debug_init(&nb_dbg_cbs); + install_node(&nb_debug_node, nb_debug_config_write); install_element(ENABLE_NODE, &debug_nb_cmd); install_element(CONFIG_NODE, &debug_nb_cmd); -- 2.39.5