mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-13 17:40:04 +00:00
commit
4eb4afa3b6
27
lib/debug.c
27
lib/debug.c
@ -18,29 +18,46 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#include <zebra.h>
|
||||
#include "typesafe.h"
|
||||
#include "debug.h"
|
||||
#include "command.h"
|
||||
|
||||
static const struct debug_callbacks *callbacks;
|
||||
static struct debug_cb_list_head cb_head;
|
||||
|
||||
DECLARE_LIST(debug_cb_list, struct debug_callbacks, item)
|
||||
|
||||
/* All code in this section should be reentrant and MT-safe */
|
||||
|
||||
DEFUN_NOSH(debug_all, debug_all_cmd, "[no] debug all",
|
||||
NO_STR DEBUG_STR "Toggle all debugging output\n")
|
||||
{
|
||||
struct debug_callbacks *cb;
|
||||
|
||||
bool set = !strmatch(argv[0]->text, "no");
|
||||
uint32_t mode = DEBUG_NODE2MODE(vty->node);
|
||||
|
||||
if (callbacks->debug_set_all)
|
||||
callbacks->debug_set_all(mode, set);
|
||||
frr_each (debug_cb_list, &cb_head, cb)
|
||||
cb->debug_set_all(mode, set);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
void debug_init(const struct debug_callbacks *cb)
|
||||
void debug_init(struct debug_callbacks *cb)
|
||||
{
|
||||
static bool inited = false;
|
||||
|
||||
if (!inited) {
|
||||
inited = true;
|
||||
debug_cb_list_init(&cb_head);
|
||||
}
|
||||
|
||||
debug_cb_list_add_head(&cb_head, cb);
|
||||
}
|
||||
|
||||
void debug_init_cli(void)
|
||||
{
|
||||
callbacks = cb;
|
||||
install_element(ENABLE_NODE, &debug_all_cmd);
|
||||
install_element(CONFIG_NODE, &debug_all_cmd);
|
||||
}
|
||||
|
14
lib/debug.h
14
lib/debug.h
@ -84,6 +84,7 @@ struct debug {
|
||||
const char *desc;
|
||||
};
|
||||
|
||||
PREDECL_LIST(debug_cb_list)
|
||||
/*
|
||||
* Callback set for debugging code.
|
||||
*
|
||||
@ -92,6 +93,11 @@ struct debug {
|
||||
* mode set.
|
||||
*/
|
||||
struct debug_callbacks {
|
||||
/*
|
||||
* Linked list of Callbacks to call
|
||||
*/
|
||||
struct debug_cb_list_item item;
|
||||
|
||||
/*
|
||||
* flags
|
||||
* flags to set on debug flag fields
|
||||
@ -233,7 +239,13 @@ struct debug_callbacks {
|
||||
*
|
||||
* MT-Safe
|
||||
*/
|
||||
void debug_init(const struct debug_callbacks *cb);
|
||||
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
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user