]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: rework debug init
authorIgor Ryzhov <iryzhov@nfware.com>
Tue, 26 Mar 2024 14:54:54 +0000 (16:54 +0200)
committerMark Stapp <mjs@cisco.com>
Tue, 27 Aug 2024 13:53:02 +0000 (09:53 -0400)
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>
22 files changed:
lib/debug.c
lib/debug.h
lib/libfrr.c
lib/mgmt_be_client.c
lib/mgmt_fe_client.c
lib/northbound.h
lib/northbound_cli.c
lib/northbound_sysrepo.c
mgmtd/mgmt.c
pathd/path_cli.c
pathd/path_pcep_cli.c
pathd/path_ted.c
pbrd/pbr_debug.c
pbrd/pbr_vty.c
staticd/static_debug.c
tests/bgpd/test_peer_attr.c
tests/helpers/c/main.c
tests/lib/cli/common_cli.c
tests/lib/cli/test_commands.c
tests/lib/northbound/test_oper_data.c
tests/lib/test_grpc.cpp
vrrpd/vrrp_debug.c

index 757a47ab99b37e3aa3f168ca050362bdf9c5acc0..5f9109b3f1cf66c968d52a51753ec78f5733d7ce 100644 (file)
@@ -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);
 }
index e9d8a31abd2b7d8d1fd708b17ed01a07609f1668..90385d87d94ff985902044ef3a398a6a49e61c3b 100644 (file)
@@ -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
 }
index 07cd4a5306f153d52c026e3ece2f1d1e2d000f97..2737e2df22b40d12212da8a812a4258714bfc67b 100644 (file)
@@ -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;
 }
 
index 49879f3f5334b5eb62e235154c0587d7ba60a25b..ef87b023a1eecb1137d0f4e9881214d2df342b6a 100644 (file)
@@ -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);
index 8cfb025f7225ea5afdf0a7d5530f995fe40d5893..39eda6298e5cbb1aa7a702b89d2bf57c41201a94 100644 (file)
@@ -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);
index 34d17a587caa9716e70e59a92cfbf6200c2d05b7..b75500c5e047a6b92d2682d55fabf1de9eedaf42 100644 (file)
@@ -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;
index 4f962cda5c1d73a9668983558a14b08e6bc8cc02..0e89c5315ccdac0d551496e86c3f6e016b64f27d 100644 (file)
@@ -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);
index 0ec7610a9a7c65c98888158586366cbe6d2db9db..edf327c9a6987730cd5b4159cf54fbf6778ef735 100644 (file)
@@ -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);
index fe0357e7e4ce9294a8d3fd157c762d23ca723368..5c647551fded05ae43759f0446481475ff1aac83 100644 (file)
@@ -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);
index b841d29bd0f4debe324471918cf4f91acd993470..700d1db8cbd2a69e23dfd5c7cffd68cc60b8ece3 100644 (file)
@@ -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);
index 66d1aa8b4e6aa51e710254838b5c1f5d75b9b967..1e0d52e38d7901936653e0c80520957f731c69d5 100644 (file)
@@ -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));
 
index f8348f15819945e7054f9355b40cb9d8437251a3..470a973ae29ed05856342789f2f2b67c26cccd62 100644 (file)
@@ -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);
 }
 
 /**
index b30b54b7f0a4fbd6252cda4bb506c357219b4aad..eca2802e98f9fac7e2a623b122b2dd49f907c95a 100644 (file)
@@ -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);
 }
index 64d88847c8a5663bc6a87109c09445cfdb7a8cc9..4378a3f414a48fdb0227556f03f6f7199a4aca79 100644 (file)
@@ -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;
 }
 
index a65752c9584f4d1d52fa7874cfe89d92d1b38f6c..045c0d5b05fbacacaac8882773919e525aca0745 100644 (file)
@@ -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);
 }
index 767c41cfee67fb5dce01e91e46fcc2e4c3541a95..d5faa33ca875e4d08e2ec2a9b4503dfe398aea21 100644 (file)
@@ -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);
index fdda7f1e2a283ab1d3fa3bc86f9b9eac18de941e..9cb395bb1f7384a630de60fb55e8a6e3da01d80d 100644 (file)
@@ -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. */
index f9f584f450f68d22a9e798d6a7bfa963ac3b6de2..640197143590b39b61328a94fd0cc857477d6099 100644 (file)
@@ -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++)
index ea84120fc1ea8004e34afe2aba8d8a621b2f10a8..0034c2af8960d98baed0da29f16986cb10f01be2 100644 (file)
@@ -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);
index 321f158668e20cd13c0d85c6a2e6f517d255b02f..74a0dfe6cc251588dcfe97e9faeca6a51dbc3833 100644 (file)
@@ -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);
index 202313603d0e9a5f022550346715bad712e40c93..2f0282704e15728f11b72461cc5aa02443ec6ec0 100644 (file)
@@ -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);
index a772b3b5c5374d011ec72f6068695e558c8e50ac..ebaeca27d39822e49a18fc547eafbfaf11d62612 100644 (file)
@@ -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);
 }