Skip to content

Commit

Permalink
mgmtd: enable conn debug when user enables mgmtd debugs
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Hopps <chopps@labn.net>
  • Loading branch information
choppsv1 committed Dec 5, 2023
1 parent c37c19a commit 71ede2d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
13 changes: 11 additions & 2 deletions mgmtd/mgmt_be_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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 *
Expand All @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions mgmtd/mgmt_be_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions mgmtd/mgmt_fe_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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'",
Expand Down
4 changes: 4 additions & 0 deletions mgmtd/mgmt_fe_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */
10 changes: 8 additions & 2 deletions mgmtd/mgmt_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 71ede2d

Please sign in to comment.