forked from Mirror/frr
lib: rework debug init
The debug library allows to register a `debug_set_all` callback which should enable all debugs in a daemon. This callback is implemented exactly the same in each daemon. Instead of duplicating the code, rework the lib to allow registration of each debug type, and implement the common code only once in the lib. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
parent
1797b7eefc
commit
5dac696154
38
lib/debug.c
38
lib/debug.c
|
@ -9,42 +9,44 @@
|
|||
#include "debug.h"
|
||||
#include "command.h"
|
||||
|
||||
static struct debug_cb_list_head cb_head;
|
||||
static struct debug_list_head debug_head;
|
||||
|
||||
DECLARE_LIST(debug_cb_list, struct debug_callbacks, item);
|
||||
DECLARE_LIST(debug_list, struct debug, 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")
|
||||
DEFUN_NOSH (debug_all,
|
||||
debug_all_cmd,
|
||||
"[no] debug all",
|
||||
NO_STR DEBUG_STR
|
||||
"Toggle all debugging output\n")
|
||||
{
|
||||
struct debug_callbacks *cb;
|
||||
|
||||
struct debug *debug;
|
||||
bool set = !strmatch(argv[0]->text, "no");
|
||||
uint32_t mode = DEBUG_NODE2MODE(vty->node);
|
||||
|
||||
frr_each (debug_cb_list, &cb_head, cb)
|
||||
cb->debug_set_all(mode, set);
|
||||
frr_each (debug_list, &debug_head, debug) {
|
||||
DEBUG_MODE_SET(debug, mode, set);
|
||||
|
||||
/* If all modes have been turned off, don't preserve options. */
|
||||
if (!DEBUG_MODE_CHECK(debug, DEBUG_MODE_ALL))
|
||||
DEBUG_CLEAR(debug);
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
void debug_init(struct debug_callbacks *cb)
|
||||
void debug_install(struct debug *debug)
|
||||
{
|
||||
static bool inited = false;
|
||||
|
||||
if (!inited) {
|
||||
inited = true;
|
||||
debug_cb_list_init(&cb_head);
|
||||
}
|
||||
|
||||
debug_cb_list_add_head(&cb_head, cb);
|
||||
debug_list_add_tail(&debug_head, debug);
|
||||
}
|
||||
|
||||
void debug_init_cli(void)
|
||||
void debug_init(void)
|
||||
{
|
||||
debug_list_init(&debug_head);
|
||||
|
||||
install_element(ENABLE_NODE, &debug_all_cmd);
|
||||
install_element(CONFIG_NODE, &debug_all_cmd);
|
||||
}
|
||||
|
|
42
lib/debug.h
42
lib/debug.h
|
@ -34,6 +34,7 @@ extern "C" {
|
|||
#define DEBUG_OPT_NONE 0x00000000
|
||||
|
||||
|
||||
PREDECL_LIST(debug_list);
|
||||
/*
|
||||
* Debugging record.
|
||||
*
|
||||
|
@ -69,31 +70,8 @@ extern "C" {
|
|||
struct debug {
|
||||
atomic_uint_fast32_t flags;
|
||||
const char *desc;
|
||||
};
|
||||
|
||||
PREDECL_LIST(debug_cb_list);
|
||||
/*
|
||||
* Callback set for debugging code.
|
||||
*
|
||||
* debug_set_all
|
||||
* Function pointer to call when the user requests that all debugs have a
|
||||
* 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
|
||||
*
|
||||
* set
|
||||
* true: set flags
|
||||
* false: unset flags
|
||||
*/
|
||||
void (*debug_set_all)(uint32_t flags, bool set);
|
||||
struct debug_list_item item;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -218,21 +196,15 @@ struct debug_callbacks {
|
|||
#define DEBUGD(name, fmt, ...) DEBUG(debug, name, fmt, ##__VA_ARGS__)
|
||||
|
||||
/*
|
||||
* Optional initializer for debugging. Highly recommended.
|
||||
*
|
||||
* This function installs common debugging commands and allows the caller to
|
||||
* specify callbacks to take when these commands are issued, allowing the
|
||||
* caller to respond to events such as a request to turn off all debugs.
|
||||
*
|
||||
* MT-Safe
|
||||
* Register a debug item.
|
||||
*/
|
||||
void debug_init(struct debug_callbacks *cb);
|
||||
void debug_install(struct debug *debug);
|
||||
|
||||
/*
|
||||
* Turn on the cli to turn on/off debugs.
|
||||
* Should only be called by libfrr
|
||||
* Initialize debugging.
|
||||
* Should only be called by libfrr.
|
||||
*/
|
||||
void debug_init_cli(void);
|
||||
void debug_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -809,6 +809,7 @@ struct event_loop *frr_init(void)
|
|||
|
||||
vty_init(master, di->log_always);
|
||||
lib_cmd_init();
|
||||
debug_init();
|
||||
|
||||
frr_pthread_init();
|
||||
#ifdef HAVE_SCRIPTING
|
||||
|
@ -825,8 +826,6 @@ struct event_loop *frr_init(void)
|
|||
"%s: failed to initialize northbound database",
|
||||
__func__);
|
||||
|
||||
debug_init_cli();
|
||||
|
||||
return master;
|
||||
}
|
||||
|
||||
|
|
|
@ -1272,10 +1272,6 @@ void mgmt_debug_be_client_show_debug(struct vty *vty)
|
|||
vty_out(vty, "debug mgmt client backend\n");
|
||||
}
|
||||
|
||||
static struct debug_callbacks mgmt_dbg_be_client_cbs = {
|
||||
.debug_set_all = mgmt_debug_client_be_set
|
||||
};
|
||||
|
||||
static struct cmd_node mgmt_dbg_node = {
|
||||
.name = "debug mgmt client backend",
|
||||
.node = MGMT_BE_DEBUG_NODE,
|
||||
|
@ -1328,7 +1324,8 @@ struct mgmt_be_client *mgmt_be_client_create(const char *client_name,
|
|||
|
||||
void mgmt_be_client_lib_vty_init(void)
|
||||
{
|
||||
debug_init(&mgmt_dbg_be_client_cbs);
|
||||
debug_install(&mgmt_dbg_be_client);
|
||||
|
||||
install_node(&mgmt_dbg_node);
|
||||
install_element(ENABLE_NODE, &debug_mgmt_client_be_cmd);
|
||||
install_element(CONFIG_NODE, &debug_mgmt_client_be_cmd);
|
||||
|
|
|
@ -819,10 +819,6 @@ void mgmt_debug_fe_client_show_debug(struct vty *vty)
|
|||
vty_out(vty, "debug mgmt client frontend\n");
|
||||
}
|
||||
|
||||
static struct debug_callbacks mgmt_dbg_fe_client_cbs = {
|
||||
.debug_set_all = mgmt_debug_client_fe_set
|
||||
};
|
||||
|
||||
static struct cmd_node mgmt_dbg_node = {
|
||||
.name = "debug mgmt client frontend",
|
||||
.node = MGMT_FE_DEBUG_NODE,
|
||||
|
@ -870,7 +866,8 @@ struct mgmt_fe_client *mgmt_fe_client_create(const char *client_name,
|
|||
|
||||
void mgmt_fe_client_lib_vty_init(void)
|
||||
{
|
||||
debug_init(&mgmt_dbg_fe_client_cbs);
|
||||
debug_install(&mgmt_dbg_fe_client);
|
||||
|
||||
install_node(&mgmt_dbg_node);
|
||||
install_element(ENABLE_NODE, &debug_mgmt_client_fe_cmd);
|
||||
install_element(CONFIG_NODE, &debug_mgmt_client_fe_cmd);
|
||||
|
|
|
@ -800,7 +800,6 @@ DECLARE_HOOK(nb_notification_send, (const char *xpath, struct list *arguments),
|
|||
DECLARE_HOOK(nb_notification_tree_send,
|
||||
(const char *xpath, const struct lyd_node *tree), (xpath, tree));
|
||||
DECLARE_HOOK(nb_client_debug_config_write, (struct vty *vty), (vty));
|
||||
DECLARE_HOOK(nb_client_debug_set_all, (uint32_t flags, bool set), (flags, set));
|
||||
|
||||
/* Northbound debugging records */
|
||||
extern struct debug nb_dbg_cbs_config;
|
||||
|
|
|
@ -1858,21 +1858,6 @@ static const char *const nb_debugs_conflines[] = {
|
|||
"debug northbound libyang",
|
||||
};
|
||||
|
||||
DEFINE_HOOK(nb_client_debug_set_all, (uint32_t flags, bool set), (flags, set));
|
||||
|
||||
static void nb_debug_set_all(uint32_t flags, bool set)
|
||||
{
|
||||
for (unsigned int i = 0; i < array_size(nb_debugs); i++) {
|
||||
DEBUG_FLAGS_SET(nb_debugs[i], flags, set);
|
||||
|
||||
/* If all modes have been turned off, don't preserve options. */
|
||||
if (!DEBUG_MODE_CHECK(nb_debugs[i], DEBUG_MODE_ALL))
|
||||
DEBUG_CLEAR(nb_debugs[i]);
|
||||
}
|
||||
|
||||
hook_call(nb_client_debug_set_all, flags, set);
|
||||
}
|
||||
|
||||
DEFPY (debug_nb,
|
||||
debug_nb_cmd,
|
||||
"[no] debug northbound\
|
||||
|
@ -1895,8 +1880,13 @@ DEFPY (debug_nb,
|
|||
"libyang debugging\n")
|
||||
{
|
||||
uint32_t mode = DEBUG_NODE2MODE(vty->node);
|
||||
bool all = false;
|
||||
|
||||
if (cbs) {
|
||||
/* no specific debug --> act on all of them */
|
||||
if (strmatch(argv[argc - 1]->text, "northbound"))
|
||||
all = true;
|
||||
|
||||
if (cbs || all) {
|
||||
bool none = (!cbs_cfg && !cbs_state && !cbs_rpc && !cbs_notify);
|
||||
|
||||
if (none || cbs_cfg)
|
||||
|
@ -1908,21 +1898,15 @@ DEFPY (debug_nb,
|
|||
if (none || cbs_notify)
|
||||
DEBUG_MODE_SET(&nb_dbg_cbs_notify, mode, !no);
|
||||
}
|
||||
if (notifications)
|
||||
if (notifications || all)
|
||||
DEBUG_MODE_SET(&nb_dbg_notif, mode, !no);
|
||||
if (events)
|
||||
if (events || all)
|
||||
DEBUG_MODE_SET(&nb_dbg_events, mode, !no);
|
||||
if (libyang) {
|
||||
if (libyang || all) {
|
||||
DEBUG_MODE_SET(&nb_dbg_libyang, mode, !no);
|
||||
yang_debugging_set(!no);
|
||||
}
|
||||
|
||||
/* no specific debug --> act on all of them */
|
||||
if (strmatch(argv[argc - 1]->text, "northbound")) {
|
||||
nb_debug_set_all(mode, !no);
|
||||
yang_debugging_set(!no);
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1939,7 +1923,6 @@ static int nb_debug_config_write(struct vty *vty)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static struct debug_callbacks nb_dbg_cbs = {.debug_set_all = nb_debug_set_all};
|
||||
static struct cmd_node nb_debug_node = {
|
||||
.name = "northbound debug",
|
||||
.node = NORTHBOUND_DEBUG_NODE,
|
||||
|
@ -2007,7 +1990,13 @@ void nb_cli_init(struct event_loop *tm)
|
|||
/* Initialize the shared candidate configuration. */
|
||||
vty_shared_candidate_config = nb_config_new(NULL);
|
||||
|
||||
debug_init(&nb_dbg_cbs);
|
||||
debug_install(&nb_dbg_cbs_config);
|
||||
debug_install(&nb_dbg_cbs_state);
|
||||
debug_install(&nb_dbg_cbs_rpc);
|
||||
debug_install(&nb_dbg_cbs_notify);
|
||||
debug_install(&nb_dbg_notif);
|
||||
debug_install(&nb_dbg_events);
|
||||
debug_install(&nb_dbg_libyang);
|
||||
|
||||
install_node(&nb_debug_node);
|
||||
install_element(ENABLE_NODE, &debug_nb_cmd);
|
||||
|
|
|
@ -561,21 +561,11 @@ static int frr_sr_debug_config_write(struct vty *vty)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int frr_sr_debug_set_all(uint32_t flags, bool set)
|
||||
{
|
||||
DEBUG_FLAGS_SET(&nb_dbg_client_sysrepo, flags, set);
|
||||
|
||||
/* If all modes have been turned off, don't preserve options. */
|
||||
if (!DEBUG_MODE_CHECK(&nb_dbg_client_sysrepo, DEBUG_MODE_ALL))
|
||||
DEBUG_CLEAR(&nb_dbg_client_sysrepo);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void frr_sr_cli_init(void)
|
||||
{
|
||||
hook_register(nb_client_debug_config_write, frr_sr_debug_config_write);
|
||||
hook_register(nb_client_debug_set_all, frr_sr_debug_set_all);
|
||||
|
||||
debug_install(&nb_dbg_client_sysrepo);
|
||||
|
||||
install_element(ENABLE_NODE, &debug_nb_sr_cmd);
|
||||
install_element(CONFIG_NODE, &debug_nb_sr_cmd);
|
||||
|
|
|
@ -39,6 +39,10 @@ void mgmt_master_init(struct event_loop *master, const int buffer_size)
|
|||
|
||||
void mgmt_init(void)
|
||||
{
|
||||
debug_install(&mgmt_debug_be);
|
||||
debug_install(&mgmt_debug_ds);
|
||||
debug_install(&mgmt_debug_fe);
|
||||
debug_install(&mgmt_debug_txn);
|
||||
|
||||
/* Initialize datastores */
|
||||
mgmt_ds_init(mm);
|
||||
|
|
|
@ -1314,22 +1314,12 @@ static int path_policy_cli_debug_config_write(struct vty *vty)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int path_policy_cli_debug_set_all(uint32_t flags, bool set)
|
||||
{
|
||||
DEBUG_FLAGS_SET(&path_policy_debug, flags, set);
|
||||
|
||||
/* If all modes have been turned off, don't preserve options. */
|
||||
if (!DEBUG_MODE_CHECK(&path_policy_debug, DEBUG_MODE_ALL))
|
||||
DEBUG_CLEAR(&path_policy_debug);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void path_cli_init(void)
|
||||
{
|
||||
hook_register(nb_client_debug_config_write,
|
||||
path_policy_cli_debug_config_write);
|
||||
hook_register(nb_client_debug_set_all, path_policy_cli_debug_set_all);
|
||||
|
||||
debug_install(&path_policy_debug);
|
||||
|
||||
install_node(&segment_routing_node);
|
||||
install_node(&sr_traffic_eng_node);
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
|
||||
/* CLI Function declarations */
|
||||
static int pcep_cli_debug_config_write(struct vty *vty);
|
||||
static int pcep_cli_debug_set_all(uint32_t flags, bool set);
|
||||
static int pcep_cli_pcep_config_write(struct vty *vty);
|
||||
static int pcep_cli_pcc_config_write(struct vty *vty);
|
||||
static int pcep_cli_pce_config_write(struct vty *vty);
|
||||
|
@ -1710,17 +1709,6 @@ int pcep_cli_debug_config_write(struct vty *vty)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int pcep_cli_debug_set_all(uint32_t flags, bool set)
|
||||
{
|
||||
DEBUG_FLAGS_SET(&pcep_g->dbg, flags, set);
|
||||
|
||||
/* If all modes have been turned off, don't preserve options. */
|
||||
if (!DEBUG_MODE_CHECK(&pcep_g->dbg, DEBUG_MODE_ALL))
|
||||
DEBUG_CLEAR(&pcep_g->dbg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pcep_cli_pcep_config_write(struct vty *vty)
|
||||
{
|
||||
vty_out(vty, " pcep\n");
|
||||
|
@ -2345,7 +2333,11 @@ void pcep_cli_init(void)
|
|||
hook_register(pathd_srte_config_write, pcep_cli_pcep_config_write);
|
||||
hook_register(nb_client_debug_config_write,
|
||||
pcep_cli_debug_config_write);
|
||||
hook_register(nb_client_debug_set_all, pcep_cli_debug_set_all);
|
||||
|
||||
debug_install(&pcep_g->dbg_basic);
|
||||
debug_install(&pcep_g->dbg_path);
|
||||
debug_install(&pcep_g->dbg_msg);
|
||||
debug_install(&pcep_g->dbg_lib);
|
||||
|
||||
memset(&pce_connections_g, 0, sizeof(pce_connections_g));
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ static enum zclient_send_status path_ted_link_state_sync(void);
|
|||
static void path_ted_timer_handler_sync(struct event *thread);
|
||||
static void path_ted_timer_handler_refresh(struct event *thread);
|
||||
static int path_ted_cli_debug_config_write(struct vty *vty);
|
||||
static int path_ted_cli_debug_set_all(uint32_t flags, bool set);
|
||||
|
||||
extern struct zclient *zclient;
|
||||
|
||||
|
@ -483,17 +482,6 @@ void path_ted_show_debugging(struct vty *vty)
|
|||
vty_out(vty, " Path TED debugging is on\n");
|
||||
}
|
||||
|
||||
int path_ted_cli_debug_set_all(uint32_t flags, bool set)
|
||||
{
|
||||
DEBUG_FLAGS_SET(&ted_state_g.dbg, flags, set);
|
||||
|
||||
/* If all modes have been turned off, don't preserve options. */
|
||||
if (!DEBUG_MODE_CHECK(&ted_state_g.dbg, DEBUG_MODE_ALL))
|
||||
DEBUG_CLEAR(&ted_state_g.dbg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Help fn to show ted related configuration
|
||||
*
|
||||
|
@ -542,7 +530,8 @@ static void path_ted_register_vty(void)
|
|||
|
||||
hook_register(nb_client_debug_config_write,
|
||||
path_ted_cli_debug_config_write);
|
||||
hook_register(nb_client_debug_set_all, path_ted_cli_debug_set_all);
|
||||
|
||||
debug_install(&ted_state_g.dbg);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,17 +28,6 @@ const char *pbr_debugs_conflines[] = {
|
|||
"debug pbr events",
|
||||
};
|
||||
|
||||
void pbr_debug_set_all(uint32_t flags, bool set)
|
||||
{
|
||||
for (unsigned int i = 0; i < array_size(pbr_debugs); i++) {
|
||||
DEBUG_FLAGS_SET(pbr_debugs[i], flags, set);
|
||||
|
||||
/* if all modes have been turned off, don't preserve options */
|
||||
if (!DEBUG_MODE_CHECK(pbr_debugs[i], DEBUG_MODE_ALL))
|
||||
DEBUG_CLEAR(pbr_debugs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int pbr_debug_config_write_helper(struct vty *vty, bool config)
|
||||
{
|
||||
uint32_t mode = DEBUG_MODE_ALL;
|
||||
|
@ -57,9 +46,10 @@ int pbr_debug_config_write(struct vty *vty)
|
|||
return pbr_debug_config_write_helper(vty, true);
|
||||
}
|
||||
|
||||
struct debug_callbacks pbr_dbg_cbs = {.debug_set_all = pbr_debug_set_all};
|
||||
|
||||
void pbr_debug_init(void)
|
||||
{
|
||||
debug_init(&pbr_dbg_cbs);
|
||||
debug_install(&pbr_dbg_map);
|
||||
debug_install(&pbr_dbg_zebra);
|
||||
debug_install(&pbr_dbg_nht);
|
||||
debug_install(&pbr_dbg_event);
|
||||
}
|
||||
|
|
|
@ -1973,19 +1973,20 @@ DEFPY(debug_pbr,
|
|||
"Events\n")
|
||||
{
|
||||
uint32_t mode = DEBUG_NODE2MODE(vty->node);
|
||||
|
||||
if (map)
|
||||
DEBUG_MODE_SET(&pbr_dbg_map, mode, !no);
|
||||
if (zebra)
|
||||
DEBUG_MODE_SET(&pbr_dbg_zebra, mode, !no);
|
||||
if (nht)
|
||||
DEBUG_MODE_SET(&pbr_dbg_nht, mode, !no);
|
||||
if (events)
|
||||
DEBUG_MODE_SET(&pbr_dbg_event, mode, !no);
|
||||
bool all = false;
|
||||
|
||||
/* no specific debug --> act on all of them */
|
||||
if (strmatch(argv[argc - 1]->text, "pbr"))
|
||||
pbr_debug_set_all(mode, !no);
|
||||
all = true;
|
||||
|
||||
if (map || all)
|
||||
DEBUG_MODE_SET(&pbr_dbg_map, mode, !no);
|
||||
if (zebra || all)
|
||||
DEBUG_MODE_SET(&pbr_dbg_zebra, mode, !no);
|
||||
if (nht || all)
|
||||
DEBUG_MODE_SET(&pbr_dbg_nht, mode, !no);
|
||||
if (events || all)
|
||||
DEBUG_MODE_SET(&pbr_dbg_event, mode, !no);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -36,27 +36,6 @@ const char *static_debugs_conflines[] = {
|
|||
};
|
||||
/* clang-format on */
|
||||
|
||||
|
||||
/*
|
||||
* Set or unset all staticd debugs
|
||||
*
|
||||
* flags
|
||||
* The flags to set
|
||||
*
|
||||
* set
|
||||
* Whether to set or unset the specified flags
|
||||
*/
|
||||
static void static_debug_set_all(uint32_t flags, bool set)
|
||||
{
|
||||
for (unsigned int i = 0; i < array_size(static_debug_arr); i++) {
|
||||
DEBUG_FLAGS_SET(static_debug_arr[i], flags, set);
|
||||
|
||||
/* if all modes have been turned off, don't preserve options */
|
||||
if (!DEBUG_MODE_CHECK(static_debug_arr[i], DEBUG_MODE_ALL))
|
||||
DEBUG_CLEAR(static_debug_arr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static int static_debug_config_write_helper(struct vty *vty, bool config)
|
||||
{
|
||||
uint32_t mode = DEBUG_MODE_ALL;
|
||||
|
@ -113,11 +92,9 @@ void static_debug_set(int vtynode, bool onoff, bool events, bool route,
|
|||
* Debug lib initialization
|
||||
*/
|
||||
|
||||
struct debug_callbacks static_dbg_cbs = {
|
||||
.debug_set_all = static_debug_set_all
|
||||
};
|
||||
|
||||
void static_debug_init(void)
|
||||
{
|
||||
debug_init(&static_dbg_cbs);
|
||||
debug_install(&static_dbg_events);
|
||||
debug_install(&static_dbg_route);
|
||||
debug_install(&static_dbg_bfd);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
#include <zebra.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "memory.h"
|
||||
#include "plist.h"
|
||||
#include "printfrr.h"
|
||||
|
@ -1348,6 +1349,7 @@ static void test_peer_attr(struct test *test, struct test_peer_attr *pa)
|
|||
static void bgp_startup(void)
|
||||
{
|
||||
cmd_init(1);
|
||||
debug_init();
|
||||
zlog_aux_init("NONE: ", LOG_DEBUG);
|
||||
zprivs_preinit(&bgpd_privs);
|
||||
zprivs_init(&bgpd_privs);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <sys/stat.h>
|
||||
|
||||
#include <lib/version.h>
|
||||
#include "debug.h"
|
||||
#include "getopt.h"
|
||||
#include "frrevent.h"
|
||||
#include "vty.h"
|
||||
|
@ -141,6 +142,7 @@ int main(int argc, char **argv)
|
|||
cmd_init(1);
|
||||
vty_init(master, false);
|
||||
lib_cmd_init();
|
||||
debug_init();
|
||||
nb_init(master, NULL, 0, false);
|
||||
|
||||
/* OSPF vty inits. */
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <zebra.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "frrevent.h"
|
||||
#include "vty.h"
|
||||
#include "command.h"
|
||||
|
@ -71,6 +72,7 @@ int main(int argc, char **argv)
|
|||
|
||||
vty_init(master, false);
|
||||
lib_cmd_init();
|
||||
debug_init();
|
||||
|
||||
for (yangcount = 0; test_yang_modules && test_yang_modules[yangcount];
|
||||
yangcount++)
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "command.h"
|
||||
#include "memory.h"
|
||||
#include "vector.h"
|
||||
|
@ -195,6 +196,7 @@ static void test_init(void)
|
|||
struct cmd_element *cmd;
|
||||
|
||||
cmd_init(1);
|
||||
debug_init();
|
||||
nb_init(master, NULL, 0, false);
|
||||
|
||||
install_node(&bgp_node);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <zebra.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "frrevent.h"
|
||||
#include "vty.h"
|
||||
#include "command.h"
|
||||
|
@ -459,6 +460,7 @@ int main(int argc, char **argv)
|
|||
cmd_hostname_set("test");
|
||||
vty_init(master, false);
|
||||
lib_cmd_init();
|
||||
debug_init();
|
||||
nb_init(master, modules, array_size(modules), false);
|
||||
|
||||
install_element(ENABLE_NODE, &test_rpc_cmd);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <unistd.h>
|
||||
#include <zebra.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "filter.h"
|
||||
#include "frr_pthread.h"
|
||||
#include "libfrr.h"
|
||||
|
@ -79,6 +80,7 @@ static void static_startup(void)
|
|||
// static struct option_chain *oc;
|
||||
|
||||
cmd_init(1);
|
||||
debug_init();
|
||||
|
||||
zlog_aux_init("NONE: ", LOG_DEBUG);
|
||||
zprivs_preinit(&static_privs);
|
||||
|
|
|
@ -42,26 +42,6 @@ const char *vrrp_debugs_conflines[] = {
|
|||
};
|
||||
/* clang-format on */
|
||||
|
||||
/*
|
||||
* Set or unset flags on all debugs for vrrpd.
|
||||
*
|
||||
* flags
|
||||
* The flags to set
|
||||
*
|
||||
* set
|
||||
* Whether to set or unset the specified flags
|
||||
*/
|
||||
static void vrrp_debug_set_all(uint32_t flags, bool set)
|
||||
{
|
||||
for (unsigned int i = 0; i < array_size(vrrp_debugs); i++) {
|
||||
DEBUG_FLAGS_SET(vrrp_debugs[i], flags, set);
|
||||
|
||||
/* if all modes have been turned off, don't preserve options */
|
||||
if (!DEBUG_MODE_CHECK(vrrp_debugs[i], DEBUG_MODE_ALL))
|
||||
DEBUG_CLEAR(vrrp_debugs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static int vrrp_debug_config_write_helper(struct vty *vty, bool config)
|
||||
{
|
||||
uint32_t mode = DEBUG_MODE_ALL;
|
||||
|
@ -110,9 +90,13 @@ void vrrp_debug_set(struct interface *ifp, uint8_t vrid, int vtynode,
|
|||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
struct debug_callbacks vrrp_dbg_cbs = {.debug_set_all = vrrp_debug_set_all};
|
||||
|
||||
void vrrp_debug_init(void)
|
||||
{
|
||||
debug_init(&vrrp_dbg_cbs);
|
||||
debug_install(&vrrp_dbg_arp);
|
||||
debug_install(&vrrp_dbg_auto);
|
||||
debug_install(&vrrp_dbg_ndisc);
|
||||
debug_install(&vrrp_dbg_pkt);
|
||||
debug_install(&vrrp_dbg_proto);
|
||||
debug_install(&vrrp_dbg_sock);
|
||||
debug_install(&vrrp_dbg_zebra);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue