From 5dac6961540422a1ca139fae8c5ea9e5a437c4ba Mon Sep 17 00:00:00 2001 From: Igor Ryzhov Date: Tue, 26 Mar 2024 16:54:54 +0200 Subject: [PATCH] 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 --- lib/debug.c | 38 ++++++++++++----------- lib/debug.h | 42 +++++--------------------- lib/libfrr.c | 3 +- lib/mgmt_be_client.c | 7 ++--- lib/mgmt_fe_client.c | 7 ++--- lib/northbound.h | 1 - lib/northbound_cli.c | 43 ++++++++++----------------- lib/northbound_sysrepo.c | 14 ++------- mgmtd/mgmt.c | 4 +++ pathd/path_cli.c | 14 ++------- pathd/path_pcep_cli.c | 18 ++++------- pathd/path_ted.c | 15 ++-------- pbrd/pbr_debug.c | 18 +++-------- pbrd/pbr_vty.c | 17 ++++++----- staticd/static_debug.c | 29 ++---------------- tests/bgpd/test_peer_attr.c | 2 ++ tests/helpers/c/main.c | 2 ++ tests/lib/cli/common_cli.c | 2 ++ tests/lib/cli/test_commands.c | 2 ++ tests/lib/northbound/test_oper_data.c | 2 ++ tests/lib/test_grpc.cpp | 2 ++ vrrpd/vrrp_debug.c | 30 +++++-------------- 22 files changed, 98 insertions(+), 214 deletions(-) diff --git a/lib/debug.c b/lib/debug.c index 757a47ab99..5f9109b3f1 100644 --- a/lib/debug.c +++ b/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); } diff --git a/lib/debug.h b/lib/debug.h index e9d8a31abd..90385d87d9 100644 --- a/lib/debug.h +++ b/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 } diff --git a/lib/libfrr.c b/lib/libfrr.c index 07cd4a5306..2737e2df22 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -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; } diff --git a/lib/mgmt_be_client.c b/lib/mgmt_be_client.c index 49879f3f53..ef87b023a1 100644 --- a/lib/mgmt_be_client.c +++ b/lib/mgmt_be_client.c @@ -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); diff --git a/lib/mgmt_fe_client.c b/lib/mgmt_fe_client.c index 8cfb025f72..39eda6298e 100644 --- a/lib/mgmt_fe_client.c +++ b/lib/mgmt_fe_client.c @@ -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); diff --git a/lib/northbound.h b/lib/northbound.h index 34d17a587c..b75500c5e0 100644 --- a/lib/northbound.h +++ b/lib/northbound.h @@ -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; diff --git a/lib/northbound_cli.c b/lib/northbound_cli.c index 4f962cda5c..0e89c5315c 100644 --- a/lib/northbound_cli.c +++ b/lib/northbound_cli.c @@ -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); diff --git a/lib/northbound_sysrepo.c b/lib/northbound_sysrepo.c index 0ec7610a9a..edf327c9a6 100644 --- a/lib/northbound_sysrepo.c +++ b/lib/northbound_sysrepo.c @@ -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); diff --git a/mgmtd/mgmt.c b/mgmtd/mgmt.c index fe0357e7e4..5c647551fd 100644 --- a/mgmtd/mgmt.c +++ b/mgmtd/mgmt.c @@ -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); diff --git a/pathd/path_cli.c b/pathd/path_cli.c index b841d29bd0..700d1db8cb 100644 --- a/pathd/path_cli.c +++ b/pathd/path_cli.c @@ -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); diff --git a/pathd/path_pcep_cli.c b/pathd/path_pcep_cli.c index 66d1aa8b4e..1e0d52e38d 100644 --- a/pathd/path_pcep_cli.c +++ b/pathd/path_pcep_cli.c @@ -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)); diff --git a/pathd/path_ted.c b/pathd/path_ted.c index f8348f1581..470a973ae2 100644 --- a/pathd/path_ted.c +++ b/pathd/path_ted.c @@ -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); } /** diff --git a/pbrd/pbr_debug.c b/pbrd/pbr_debug.c index b30b54b7f0..eca2802e98 100644 --- a/pbrd/pbr_debug.c +++ b/pbrd/pbr_debug.c @@ -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); } diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c index 64d88847c8..4378a3f414 100644 --- a/pbrd/pbr_vty.c +++ b/pbrd/pbr_vty.c @@ -1973,20 +1973,21 @@ DEFPY(debug_pbr, "Events\n") { uint32_t mode = DEBUG_NODE2MODE(vty->node); + bool all = false; - if (map) + /* no specific debug --> act on all of them */ + if (strmatch(argv[argc - 1]->text, "pbr")) + all = true; + + if (map || all) DEBUG_MODE_SET(&pbr_dbg_map, mode, !no); - if (zebra) + if (zebra || all) DEBUG_MODE_SET(&pbr_dbg_zebra, mode, !no); - if (nht) + if (nht || all) DEBUG_MODE_SET(&pbr_dbg_nht, mode, !no); - if (events) + if (events || all) DEBUG_MODE_SET(&pbr_dbg_event, mode, !no); - /* no specific debug --> act on all of them */ - if (strmatch(argv[argc - 1]->text, "pbr")) - pbr_debug_set_all(mode, !no); - return CMD_SUCCESS; } diff --git a/staticd/static_debug.c b/staticd/static_debug.c index a65752c958..045c0d5b05 100644 --- a/staticd/static_debug.c +++ b/staticd/static_debug.c @@ -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); } diff --git a/tests/bgpd/test_peer_attr.c b/tests/bgpd/test_peer_attr.c index 767c41cfee..d5faa33ca8 100644 --- a/tests/bgpd/test_peer_attr.c +++ b/tests/bgpd/test_peer_attr.c @@ -5,6 +5,7 @@ */ #include +#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); diff --git a/tests/helpers/c/main.c b/tests/helpers/c/main.c index fdda7f1e2a..9cb395bb1f 100644 --- a/tests/helpers/c/main.c +++ b/tests/helpers/c/main.c @@ -6,6 +6,7 @@ #include #include +#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. */ diff --git a/tests/lib/cli/common_cli.c b/tests/lib/cli/common_cli.c index f9f584f450..6401971435 100644 --- a/tests/lib/cli/common_cli.c +++ b/tests/lib/cli/common_cli.c @@ -9,6 +9,7 @@ #include #include +#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++) diff --git a/tests/lib/cli/test_commands.c b/tests/lib/cli/test_commands.c index ea84120fc1..0034c2af89 100644 --- a/tests/lib/cli/test_commands.c +++ b/tests/lib/cli/test_commands.c @@ -21,6 +21,7 @@ #include #include +#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); diff --git a/tests/lib/northbound/test_oper_data.c b/tests/lib/northbound/test_oper_data.c index 321f158668..74a0dfe6cc 100644 --- a/tests/lib/northbound/test_oper_data.c +++ b/tests/lib/northbound/test_oper_data.c @@ -7,6 +7,7 @@ #include #include +#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); diff --git a/tests/lib/test_grpc.cpp b/tests/lib/test_grpc.cpp index 202313603d..2f0282704e 100644 --- a/tests/lib/test_grpc.cpp +++ b/tests/lib/test_grpc.cpp @@ -9,6 +9,7 @@ #include #include +#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); diff --git a/vrrpd/vrrp_debug.c b/vrrpd/vrrp_debug.c index a772b3b5c5..ebaeca27d3 100644 --- a/vrrpd/vrrp_debug.c +++ b/vrrpd/vrrp_debug.c @@ -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); } -- 2.39.5