diff options
author | Igor Ryzhov <iryzhov@nfware.com> | 2024-03-26 15:54:54 +0100 |
---|---|---|
committer | Mark Stapp <mjs@cisco.com> | 2024-08-27 15:53:02 +0200 |
commit | 5dac6961540422a1ca139fae8c5ea9e5a437c4ba (patch) | |
tree | 3ff27afc04b9605f832c747b82449b58d5aa5455 /pathd | |
parent | pathd: rework debugs (diff) | |
download | frr-5dac6961540422a1ca139fae8c5ea9e5a437c4ba.tar.xz frr-5dac6961540422a1ca139fae8c5ea9e5a437c4ba.zip |
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>
Diffstat (limited to 'pathd')
-rw-r--r-- | pathd/path_cli.c | 14 | ||||
-rw-r--r-- | pathd/path_pcep_cli.c | 18 | ||||
-rw-r--r-- | pathd/path_ted.c | 15 |
3 files changed, 9 insertions, 38 deletions
diff --git a/pathd/path_cli.c b/pathd/path_cli.c index b841d29bd..700d1db8c 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 66d1aa8b4..1e0d52e38 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 f8348f158..470a973ae 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); } /** |