summaryrefslogtreecommitdiff
path: root/mgmtd/mgmt_vty.c
diff options
context:
space:
mode:
authorChristian Hopps <chopps@labn.net>2023-04-26 17:50:46 -0400
committerChristian Hopps <chopps@labn.net>2023-05-01 13:47:12 -0400
commitcfa0facbf936fc6cc053fafea7d2b6fa8bccfc4c (patch)
tree727b06f65947ae9702c691dfeb4dfe8951225ca8 /mgmtd/mgmt_vty.c
parent13c426150fd4699466306d88a917df6493faf9bd (diff)
mgmtd: fully implement debug flags for mgmtd and clients
Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'mgmtd/mgmt_vty.c')
-rw-r--r--mgmtd/mgmt_vty.c55
1 files changed, 25 insertions, 30 deletions
diff --git a/mgmtd/mgmt_vty.c b/mgmtd/mgmt_vty.c
index fa34d90c75..7d133d522f 100644
--- a/mgmtd/mgmt_vty.c
+++ b/mgmtd/mgmt_vty.c
@@ -380,7 +380,7 @@ DEFPY(mgmt_rollback,
return CMD_SUCCESS;
}
-static int config_write_mgmt_debug(struct vty *vty);
+int config_write_mgmt_debug(struct vty *vty);
static struct cmd_node debug_node = {
.name = "debug",
.node = DEBUG_NODE,
@@ -388,27 +388,25 @@ static struct cmd_node debug_node = {
.config_write = config_write_mgmt_debug,
};
-static int config_write_mgmt_debug_helper(struct vty *vty, bool config)
+static int write_mgmt_debug_helper(struct vty *vty, bool config)
{
- int n = mgmt_debug_be + mgmt_debug_fe + mgmt_debug_ds + mgmt_debug_txn;
+ uint32_t mode = config ? DEBUG_MODE_CONF : DEBUG_MODE_ALL;
+ bool be = DEBUG_MODE_CHECK(&mgmt_debug_be, mode);
+ bool ds = DEBUG_MODE_CHECK(&mgmt_debug_ds, mode);
+ bool fe = DEBUG_MODE_CHECK(&mgmt_debug_fe, mode);
+ bool txn = DEBUG_MODE_CHECK(&mgmt_debug_txn, mode);
- if (!n)
+ if (!(be || ds || fe || txn))
return 0;
- if (config && mgmt_debug_be && mgmt_debug_fe && mgmt_debug_ds &&
- mgmt_debug_txn) {
- vty_out(vty, "debug mgmt all\n");
- return 0;
- }
-
vty_out(vty, "debug mgmt");
- if (mgmt_debug_be)
+ if (be)
vty_out(vty, " backend");
- if (mgmt_debug_ds)
+ if (ds)
vty_out(vty, " datastore");
- if (mgmt_debug_fe)
+ if (fe)
vty_out(vty, " frontend");
- if (mgmt_debug_txn)
+ if (txn)
vty_out(vty, " transaction");
vty_out(vty, "\n");
@@ -416,17 +414,17 @@ static int config_write_mgmt_debug_helper(struct vty *vty, bool config)
return 0;
}
-static int config_write_mgmt_debug(struct vty *vty)
+int config_write_mgmt_debug(struct vty *vty)
{
- return config_write_mgmt_debug_helper(vty, true);
+ return write_mgmt_debug_helper(vty, true);
}
-DEFUN_NOSH(show_debugging_mgmt, show_debugging_mgmt_cmd,
+DEFPY_NOSH(show_debugging_mgmt, show_debugging_mgmt_cmd,
"show debugging [mgmt]", SHOW_STR DEBUG_STR "MGMT Information\n")
{
vty_out(vty, "MGMT debugging status:\n");
- config_write_mgmt_debug_helper(vty, false);
+ write_mgmt_debug_helper(vty, false);
cmd_show_lib_debugs(vty);
@@ -434,27 +432,23 @@ DEFUN_NOSH(show_debugging_mgmt, show_debugging_mgmt_cmd,
}
DEFPY(debug_mgmt, debug_mgmt_cmd,
- "[no$no] debug mgmt <all$all|{backend$be|datastore$ds|frontend$fe|transaction$txn}>",
+ "[no$no] debug mgmt {backend$be|datastore$ds|frontend$fe|transaction$txn}",
NO_STR DEBUG_STR MGMTD_STR
- "All debug\n"
- "Back-end debug\n"
+ "Backend debug\n"
"Datastore debug\n"
- "Front-end debug\n"
+ "Frontend debug\n"
"Transaction debug\n")
{
- bool set = !no;
-
- if (all)
- be = fe = ds = txn = set ? all : NULL;
+ uint32_t mode = DEBUG_NODE2MODE(vty->node);
if (be)
- mgmt_debug_be = set;
+ DEBUG_MODE_SET(&mgmt_debug_be, mode, !no);
if (ds)
- mgmt_debug_ds = set;
+ DEBUG_MODE_SET(&mgmt_debug_ds, mode, !no);
if (fe)
- mgmt_debug_fe = set;
+ DEBUG_MODE_SET(&mgmt_debug_fe, mode, !no);
if (txn)
- mgmt_debug_txn = set;
+ DEBUG_MODE_SET(&mgmt_debug_txn, mode, !no);
return CMD_SUCCESS;
}
@@ -530,6 +524,7 @@ void mgmt_vty_init(void)
install_element(ENABLE_NODE, &show_debugging_mgmt_cmd);
+ mgmt_fe_client_lib_vty_init();
/*
* TODO: Register and handlers for auto-completion here.
*/