summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/command.h4
-rw-r--r--lib/debug.c21
-rw-r--r--lib/debug.h4
-rw-r--r--lib/mgmt_be_client.c17
-rw-r--r--lib/mgmt_fe_client.c17
-rw-r--r--lib/northbound.h1
-rw-r--r--lib/northbound_cli.c57
-rw-r--r--lib/northbound_sysrepo.c14
8 files changed, 44 insertions, 91 deletions
diff --git a/lib/command.h b/lib/command.h
index cb105c656c..61d09973fd 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -84,14 +84,12 @@ enum node_type {
CONFIG_NODE, /* Config node. Default mode of config file. */
PREFIX_NODE, /* ip prefix-list node. */
PREFIX_IPV6_NODE, /* ipv6 prefix-list node. */
+ LIB_DEBUG_NODE, /* frrlib debug node. */
DEBUG_NODE, /* Debug node. */
VRF_DEBUG_NODE, /* Vrf Debug node. */
- NORTHBOUND_DEBUG_NODE, /* Northbound Debug node. */
DEBUG_VNC_NODE, /* Debug VNC node. */
RMAP_DEBUG_NODE, /* Route-map debug node */
RESOLVER_DEBUG_NODE, /* Resolver debug node */
- MGMT_BE_DEBUG_NODE, /* mgmtd backend-client debug node */
- MGMT_FE_DEBUG_NODE, /* mgmtd frontend-client debug node */
AAA_NODE, /* AAA node. */
EXTLOG_NODE, /* RFC5424 & co. extended syslog */
KEYCHAIN_NODE, /* Key-chain node. */
diff --git a/lib/debug.c b/lib/debug.c
index 5f9109b3f1..9c283176a6 100644
--- a/lib/debug.c
+++ b/lib/debug.c
@@ -38,6 +38,25 @@ DEFUN_NOSH (debug_all,
/* ------------------------------------------------------------------------- */
+static int config_write_debug(struct vty *vty)
+{
+ struct debug *debug;
+
+ frr_each (debug_list, &debug_head, debug) {
+ if (DEBUG_MODE_CHECK(debug, DEBUG_MODE_CONF))
+ vty_out(vty, "%s\n", debug->conf);
+ }
+
+ return 0;
+}
+
+static struct cmd_node debug_node = {
+ .name = "debug",
+ .node = LIB_DEBUG_NODE,
+ .prompt = "",
+ .config_write = config_write_debug,
+};
+
void debug_install(struct debug *debug)
{
debug_list_add_tail(&debug_head, debug);
@@ -47,6 +66,8 @@ void debug_init(void)
{
debug_list_init(&debug_head);
+ install_node(&debug_node);
+
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 90385d87d9..60f42e3071 100644
--- a/lib/debug.h
+++ b/lib/debug.h
@@ -64,11 +64,15 @@ PREDECL_LIST(debug_list);
* manipulate the flags field in a multithreaded environment results in
* undefined behavior.
*
+ * conf
+ * The configuration string that will be written to the config file.
+ *
* desc
* Human-readable description of this debugging record.
*/
struct debug {
atomic_uint_fast32_t flags;
+ const char *conf;
const char *desc;
struct debug_list_item item;
diff --git a/lib/mgmt_be_client.c b/lib/mgmt_be_client.c
index ef87b023a1..ad57a887f9 100644
--- a/lib/mgmt_be_client.c
+++ b/lib/mgmt_be_client.c
@@ -116,6 +116,7 @@ struct mgmt_be_client {
frr_each_safe (mgmt_be_txns, &(client_ctx)->txn_head, (txn))
struct debug mgmt_dbg_be_client = {
+ .conf = "debug mgmt client backend",
.desc = "Management backend client operations"
};
@@ -1258,27 +1259,12 @@ DEFPY(debug_mgmt_client_be, debug_mgmt_client_be_cmd,
return CMD_SUCCESS;
}
-static int mgmt_debug_be_client_config_write(struct vty *vty)
-{
- if (DEBUG_MODE_CHECK(&mgmt_dbg_be_client, DEBUG_MODE_CONF))
- vty_out(vty, "debug mgmt client backend\n");
-
- return 1;
-}
-
void mgmt_debug_be_client_show_debug(struct vty *vty)
{
if (debug_check_be_client())
vty_out(vty, "debug mgmt client backend\n");
}
-static struct cmd_node mgmt_dbg_node = {
- .name = "debug mgmt client backend",
- .node = MGMT_BE_DEBUG_NODE,
- .prompt = "",
- .config_write = mgmt_debug_be_client_config_write,
-};
-
struct mgmt_be_client *mgmt_be_client_create(const char *client_name,
struct mgmt_be_client_cbs *cbs,
uintptr_t user_data,
@@ -1326,7 +1312,6 @@ void mgmt_be_client_lib_vty_init(void)
{
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 39eda6298e..cd74f38271 100644
--- a/lib/mgmt_fe_client.c
+++ b/lib/mgmt_fe_client.c
@@ -49,6 +49,7 @@ struct mgmt_fe_client {
frr_each_safe (mgmt_sessions, &(client)->sessions, (session))
struct debug mgmt_dbg_fe_client = {
+ .conf = "debug mgmt client frontend",
.desc = "Management frontend client operations"
};
@@ -805,27 +806,12 @@ DEFPY(debug_mgmt_client_fe, debug_mgmt_client_fe_cmd,
return CMD_SUCCESS;
}
-static int mgmt_debug_fe_client_config_write(struct vty *vty)
-{
- if (DEBUG_MODE_CHECK(&mgmt_dbg_fe_client, DEBUG_MODE_CONF))
- vty_out(vty, "debug mgmt client frontend\n");
-
- return CMD_SUCCESS;
-}
-
void mgmt_debug_fe_client_show_debug(struct vty *vty)
{
if (debug_check_fe_client())
vty_out(vty, "debug mgmt client frontend\n");
}
-static struct cmd_node mgmt_dbg_node = {
- .name = "debug mgmt client frontend",
- .node = MGMT_FE_DEBUG_NODE,
- .prompt = "",
- .config_write = mgmt_debug_fe_client_config_write,
-};
-
/*
* Initialize library and try connecting with MGMTD.
*/
@@ -868,7 +854,6 @@ void mgmt_fe_client_lib_vty_init(void)
{
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 b75500c5e0..da5f5be1ee 100644
--- a/lib/northbound.h
+++ b/lib/northbound.h
@@ -799,7 +799,6 @@ DECLARE_HOOK(nb_notification_send, (const char *xpath, struct list *arguments),
(xpath, 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));
/* Northbound debugging records */
extern struct debug nb_dbg_cbs_config;
diff --git a/lib/northbound_cli.c b/lib/northbound_cli.c
index 0e89c5315c..f70bae9ed2 100644
--- a/lib/northbound_cli.c
+++ b/lib/northbound_cli.c
@@ -22,13 +22,19 @@
#include "northbound_db.h"
#include "lib/northbound_cli_clippy.c"
-struct debug nb_dbg_cbs_config = {0, "Northbound callbacks: configuration"};
-struct debug nb_dbg_cbs_state = {0, "Northbound callbacks: state"};
-struct debug nb_dbg_cbs_rpc = {0, "Northbound callbacks: RPCs"};
-struct debug nb_dbg_cbs_notify = {0, "Northbound callbacks: notifications"};
-struct debug nb_dbg_notif = {0, "Northbound notifications"};
-struct debug nb_dbg_events = {0, "Northbound events"};
-struct debug nb_dbg_libyang = {0, "libyang debugging"};
+struct debug nb_dbg_cbs_config = { 0, "debug northbound callbacks configuration",
+ "Northbound callbacks: configuration" };
+struct debug nb_dbg_cbs_state = { 0, "debug northbound callbacks state",
+ "Northbound callbacks: state" };
+struct debug nb_dbg_cbs_rpc = { 0, "debug northbound callbacks rpc",
+ "Northbound callbacks: RPCs" };
+struct debug nb_dbg_cbs_notify = { 0, "debug northbound callbacks notify",
+ "Northbound callbacks: notifications" };
+struct debug nb_dbg_notif = { 0, "debug northbound notifications",
+ "Northbound notifications" };
+struct debug nb_dbg_events = { 0, "debug northbound events",
+ "Northbound events" };
+struct debug nb_dbg_libyang = { 0, "debug northbound libyang", "libyang" };
struct nb_config *vty_shared_candidate_config;
static struct event_loop *master;
@@ -1842,22 +1848,6 @@ DEFPY (rollback_config,
}
/* Debug CLI commands. */
-static struct debug *nb_debugs[] = {
- &nb_dbg_cbs_config, &nb_dbg_cbs_state, &nb_dbg_cbs_rpc,
- &nb_dbg_cbs_notify, &nb_dbg_notif, &nb_dbg_events,
- &nb_dbg_libyang,
-};
-
-static const char *const nb_debugs_conflines[] = {
- "debug northbound callbacks configuration",
- "debug northbound callbacks state",
- "debug northbound callbacks rpc",
- "debug northbound callbacks notify",
- "debug northbound notifications",
- "debug northbound events",
- "debug northbound libyang",
-};
-
DEFPY (debug_nb,
debug_nb_cmd,
"[no] debug northbound\
@@ -1910,26 +1900,6 @@ DEFPY (debug_nb,
return CMD_SUCCESS;
}
-DEFINE_HOOK(nb_client_debug_config_write, (struct vty *vty), (vty));
-
-static int nb_debug_config_write(struct vty *vty)
-{
- for (unsigned int i = 0; i < array_size(nb_debugs); i++)
- if (DEBUG_MODE_CHECK(nb_debugs[i], DEBUG_MODE_CONF))
- vty_out(vty, "%s\n", nb_debugs_conflines[i]);
-
- hook_call(nb_client_debug_config_write, vty);
-
- return 1;
-}
-
-static struct cmd_node nb_debug_node = {
- .name = "northbound debug",
- .node = NORTHBOUND_DEBUG_NODE,
- .prompt = "",
- .config_write = nb_debug_config_write,
-};
-
void nb_cli_install_default(int node)
{
_install_element(node, &show_config_candidate_section_cmd);
@@ -1998,7 +1968,6 @@ void nb_cli_init(struct event_loop *tm)
debug_install(&nb_dbg_events);
debug_install(&nb_dbg_libyang);
- install_node(&nb_debug_node);
install_element(ENABLE_NODE, &debug_nb_cmd);
install_element(CONFIG_NODE, &debug_nb_cmd);
diff --git a/lib/northbound_sysrepo.c b/lib/northbound_sysrepo.c
index edf327c9a6..1f4d036cc2 100644
--- a/lib/northbound_sysrepo.c
+++ b/lib/northbound_sysrepo.c
@@ -19,7 +19,9 @@
#include <sysrepo/values.h>
#include <sysrepo/xpath.h>
-static struct debug nb_dbg_client_sysrepo = {0, "Northbound client: Sysrepo"};
+static struct debug nb_dbg_client_sysrepo = { 0,
+ "debug northbound client sysrepo",
+ "Northbound client: Sysrepo" };
static struct event_loop *master;
static sr_session_ctx_t *session;
@@ -553,18 +555,8 @@ DEFUN (debug_nb_sr,
return CMD_SUCCESS;
}
-static int frr_sr_debug_config_write(struct vty *vty)
-{
- if (DEBUG_MODE_CHECK(&nb_dbg_client_sysrepo, DEBUG_MODE_CONF))
- vty_out(vty, "debug northbound client sysrepo\n");
-
- return 0;
-}
-
static void frr_sr_cli_init(void)
{
- hook_register(nb_client_debug_config_write, frr_sr_debug_config_write);
-
debug_install(&nb_dbg_client_sysrepo);
install_element(ENABLE_NODE, &debug_nb_sr_cmd);