mgmtd: enable conn debug when user enables mgmtd debugs

Signed-off-by: Christian Hopps <chopps@labn.net>
This commit is contained in:
Christian Hopps 2023-11-29 22:29:14 -05:00
parent c37c19a9ec
commit 71ede2db9e
5 changed files with 37 additions and 4 deletions

View file

@ -668,6 +668,8 @@ struct msg_conn *mgmt_be_create_adapter(int conn_fd, union sockunion *from)
MGMTD_BE_MAX_NUM_MSG_WRITE, MGMTD_BE_MSG_MAX_LEN, adapter,
"BE-adapter");
adapter->conn->debug = DEBUG_MODE_CHECK(&mgmt_debug_be, DEBUG_MODE_ALL);
MGMTD_BE_ADAPTER_DBG("Added new MGMTD Backend adapter '%s'",
adapter->name);
@ -677,8 +679,7 @@ struct msg_conn *mgmt_be_create_adapter(int conn_fd, union sockunion *from)
struct mgmt_be_client_adapter *
mgmt_be_get_adapter_by_id(enum mgmt_be_client_id id)
{
return (id < MGMTD_BE_CLIENT_ID_MAX ? mgmt_be_adapters_by_id[id]
: NULL);
return (id < MGMTD_BE_CLIENT_ID_MAX ? mgmt_be_adapters_by_id[id] : NULL);
}
struct mgmt_be_client_adapter *
@ -687,6 +688,14 @@ mgmt_be_get_adapter_by_name(const char *name)
return mgmt_be_find_adapter_by_name(name);
}
void mgmt_be_adapter_toggle_client_debug(bool set)
{
struct mgmt_be_client_adapter *adapter;
FOREACH_ADAPTER_IN_LIST (adapter)
adapter->conn->debug = set;
}
/*
* Get a full set of changes for all the config that an adapter is subscribed to
* receive.

View file

@ -149,6 +149,9 @@ mgmt_be_get_adapter_by_name(const char *name);
extern struct mgmt_be_client_adapter *
mgmt_be_get_adapter_by_id(enum mgmt_be_client_id id);
/* Toggle debug on or off for connected clients. */
extern void mgmt_be_adapter_toggle_client_debug(bool set);
/* Fetch backend adapter config. */
extern int mgmt_be_get_adapter_config(struct mgmt_be_client_adapter *adapter,
struct nb_config_cbs **cfg_chgs);

View file

@ -246,6 +246,14 @@ mgmt_session_id2ctx(uint64_t session_id)
return session;
}
void mgmt_fe_adapter_toggle_client_debug(bool set)
{
struct mgmt_fe_client_adapter *adapter;
FOREACH_ADAPTER_IN_LIST (adapter)
adapter->conn->debug = set;
}
static struct mgmt_fe_session_ctx *
mgmt_fe_create_session(struct mgmt_fe_client_adapter *adapter,
uint64_t client_id)
@ -1132,6 +1140,9 @@ struct msg_conn *mgmt_fe_create_adapter(int conn_fd, union sockunion *from)
MGMTD_FE_MAX_NUM_MSG_WRITE, MGMTD_FE_MSG_MAX_LEN,
adapter, "FE-adapter");
adapter->conn->debug = DEBUG_MODE_CHECK(&mgmt_debug_fe,
DEBUG_MODE_ALL);
adapter->setcfg_stats.min_tm = ULONG_MAX;
adapter->cmt_stats.min_tm = ULONG_MAX;
MGMTD_FE_ADAPTER_DBG("Added new MGMTD Frontend adapter '%s'",

View file

@ -149,4 +149,8 @@ mgmt_fe_get_session_commit_stats(uint64_t session_id);
extern void mgmt_fe_adapter_status_write(struct vty *vty, bool detail);
extern void mgmt_fe_adapter_perf_measurement(struct vty *vty, bool config);
extern void mgmt_fe_adapter_reset_perf_stats(struct vty *vty);
/* Toggle debug on or off for connected clients. */
extern void mgmt_fe_adapter_toggle_client_debug(bool set);
#endif /* _FRR_MGMTD_FE_ADAPTER_H_ */

View file

@ -438,12 +438,18 @@ DEFPY(debug_mgmt, debug_mgmt_cmd,
{
uint32_t mode = DEBUG_NODE2MODE(vty->node);
if (be)
if (be) {
DEBUG_MODE_SET(&mgmt_debug_be, mode, !no);
mgmt_be_adapter_toggle_client_debug(
DEBUG_MODE_CHECK(&mgmt_debug_be, DEBUG_MODE_ALL));
}
if (ds)
DEBUG_MODE_SET(&mgmt_debug_ds, mode, !no);
if (fe)
if (fe) {
DEBUG_MODE_SET(&mgmt_debug_fe, mode, !no);
mgmt_fe_adapter_toggle_client_debug(
DEBUG_MODE_CHECK(&mgmt_debug_fe, DEBUG_MODE_ALL));
}
if (txn)
DEBUG_MODE_SET(&mgmt_debug_txn, mode, !no);