summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Hopps <chopps@labn.net>2023-11-11 19:21:17 +0100
committerChristian Hopps <chopps@labn.net>2023-11-11 19:25:03 +0100
commit59beac5013f48889d8b73bb57df085d8d3e7a09f (patch)
tree799ce3a01f6417db5d7538e615a5e72fd3761185
parent19bcca4f2e9a3ee3c8cc16608dcf303241bbf014 (diff)
lib: mgmtd: fix debug cli commands and memleaks
- Cannot have 2 cmd_node's with same .node number. Install the mgmtd client library debug nodes (client frontend and client backend) using new unique node numbers. Fixes memleaks. - Fix "debug mgmt client backend" to generate correct config (and not for frontend). Signed-off-by: Christian Hopps <chopps@labn.net>
-rw-r--r--lib/command.h2
-rw-r--r--lib/mgmt_be_client.c6
-rw-r--r--lib/mgmt_fe_client.c4
-rw-r--r--mgmtd/mgmt_vty.c2
-rw-r--r--vtysh/vtysh_config.c6
5 files changed, 14 insertions, 6 deletions
diff --git a/lib/command.h b/lib/command.h
index 718d34b007..0da838feb1 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -88,6 +88,8 @@ enum node_type {
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/mgmt_be_client.c b/lib/mgmt_be_client.c
index 762ace1361..d1651dde1d 100644
--- a/lib/mgmt_be_client.c
+++ b/lib/mgmt_be_client.c
@@ -880,7 +880,7 @@ static void mgmt_debug_client_be_set_all(uint32_t flags, bool set)
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 frontend\n");
+ vty_out(vty, "debug mgmt client backend\n");
return 1;
}
@@ -895,8 +895,8 @@ static struct debug_callbacks mgmt_dbg_be_client_cbs = {
.debug_set_all = mgmt_debug_client_be_set_all};
static struct cmd_node mgmt_dbg_node = {
- .name = "mgmt backend client",
- .node = DEBUG_NODE,
+ .name = "debug mgmt client backend",
+ .node = MGMT_BE_DEBUG_NODE,
.prompt = "",
.config_write = mgmt_debug_be_client_config_write,
};
diff --git a/lib/mgmt_fe_client.c b/lib/mgmt_fe_client.c
index 7e42e1c09e..aab553049d 100644
--- a/lib/mgmt_fe_client.c
+++ b/lib/mgmt_fe_client.c
@@ -580,8 +580,8 @@ static struct debug_callbacks mgmt_dbg_fe_client_cbs = {
.debug_set_all = mgmt_debug_client_fe_set_all};
static struct cmd_node mgmt_dbg_node = {
- .name = "mgmt client frontend",
- .node = DEBUG_NODE,
+ .name = "debug mgmt client frontend",
+ .node = MGMT_FE_DEBUG_NODE,
.prompt = "",
.config_write = mgmt_debug_fe_client_config_write,
};
diff --git a/mgmtd/mgmt_vty.c b/mgmtd/mgmt_vty.c
index e7d6966710..9591d46132 100644
--- a/mgmtd/mgmt_vty.c
+++ b/mgmtd/mgmt_vty.c
@@ -379,7 +379,7 @@ DEFPY(mgmt_rollback,
int config_write_mgmt_debug(struct vty *vty);
static struct cmd_node debug_node = {
- .name = "debug",
+ .name = "mgmt debug",
.node = DEBUG_NODE,
.prompt = "",
.config_write = config_write_mgmt_debug,
diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c
index ae64d51283..c02f27c876 100644
--- a/vtysh/vtysh_config.c
+++ b/vtysh/vtysh_config.c
@@ -455,6 +455,12 @@ void vtysh_config_parse_line(void *arg, const char *line)
else if (strncmp(line, "debug resolver",
strlen("debug resolver")) == 0)
config = config_get(RESOLVER_DEBUG_NODE, line);
+ else if (strncmp(line, "debug mgmt client frontend",
+ strlen("debug mgmt client frontend")) == 0)
+ config = config_get(MGMT_FE_DEBUG_NODE, line);
+ else if (strncmp(line, "debug mgmt client backend",
+ strlen("debug mgmt client backend")) == 0)
+ config = config_get(MGMT_BE_DEBUG_NODE, line);
else if (strncmp(line, "debug", strlen("debug")) == 0)
config = config_get(DEBUG_NODE, line);
else if (strncmp(line, "password", strlen("password")) == 0