diff options
| author | Christian Hopps <chopps@labn.net> | 2023-11-29 22:29:14 -0500 | 
|---|---|---|
| committer | Christian Hopps <chopps@labn.net> | 2023-12-05 13:39:40 -0500 | 
| commit | 71ede2db9ee298fbc96ad7310a9e7e1cad4a417c (patch) | |
| tree | a885c30ad765f40877a919abe995d5107fd0f01e /mgmtd | |
| parent | c37c19a9ec66eb6b0dd2fdbd6d09c09bd2a22108 (diff) | |
mgmtd: enable conn debug when user enables mgmtd debugs
Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'mgmtd')
| -rw-r--r-- | mgmtd/mgmt_be_adapter.c | 13 | ||||
| -rw-r--r-- | mgmtd/mgmt_be_adapter.h | 3 | ||||
| -rw-r--r-- | mgmtd/mgmt_fe_adapter.c | 11 | ||||
| -rw-r--r-- | mgmtd/mgmt_fe_adapter.h | 4 | ||||
| -rw-r--r-- | mgmtd/mgmt_vty.c | 10 | 
5 files changed, 37 insertions, 4 deletions
diff --git a/mgmtd/mgmt_be_adapter.c b/mgmtd/mgmt_be_adapter.c index 0043c9d8e0..ed93244b83 100644 --- a/mgmtd/mgmt_be_adapter.c +++ b/mgmtd/mgmt_be_adapter.c @@ -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. diff --git a/mgmtd/mgmt_be_adapter.h b/mgmtd/mgmt_be_adapter.h index a818d658a9..e06ee115f0 100644 --- a/mgmtd/mgmt_be_adapter.h +++ b/mgmtd/mgmt_be_adapter.h @@ -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); diff --git a/mgmtd/mgmt_fe_adapter.c b/mgmtd/mgmt_fe_adapter.c index 2b2471c901..d613b7467a 100644 --- a/mgmtd/mgmt_fe_adapter.c +++ b/mgmtd/mgmt_fe_adapter.c @@ -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'", diff --git a/mgmtd/mgmt_fe_adapter.h b/mgmtd/mgmt_fe_adapter.h index 1560916c85..1172262a45 100644 --- a/mgmtd/mgmt_fe_adapter.h +++ b/mgmtd/mgmt_fe_adapter.h @@ -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_ */ diff --git a/mgmtd/mgmt_vty.c b/mgmtd/mgmt_vty.c index 0f6df9f129..3116ccbaf7 100644 --- a/mgmtd/mgmt_vty.c +++ b/mgmtd/mgmt_vty.c @@ -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);  | 
