mgmtd: rm unused/unneeded code add couple comments

Signed-off-by: Christian Hopps <chopps@labn.net>
This commit is contained in:
Christian Hopps 2023-06-04 18:09:25 -04:00
parent ee235c606f
commit c6b8e95703
6 changed files with 38 additions and 123 deletions

View File

@ -792,18 +792,19 @@ static void nb_update_candidate_changes(struct nb_config *candidate,
LYD_TREE_DFS_BEGIN (root, dnode) { LYD_TREE_DFS_BEGIN (root, dnode) {
op = nb_lyd_diff_get_op(dnode); op = nb_lyd_diff_get_op(dnode);
switch (op) { switch (op) {
case 'c': case 'c': /* create */
nb_config_diff_created(dnode, seq, cfg_chgs); nb_config_diff_created(dnode, seq, cfg_chgs);
LYD_TREE_DFS_continue = 1; LYD_TREE_DFS_continue = 1;
break; break;
case 'd': case 'd': /* delete */
nb_config_diff_deleted(dnode, seq, cfg_chgs); nb_config_diff_deleted(dnode, seq, cfg_chgs);
LYD_TREE_DFS_continue = 1; LYD_TREE_DFS_continue = 1;
break; break;
case 'r': case 'r': /* replace */
nb_config_diff_add_change(cfg_chgs, NB_OP_MODIFY, seq, nb_config_diff_add_change(cfg_chgs, NB_OP_MODIFY, seq,
dnode); dnode);
break; break;
case 'n': /* none */
default: default:
break; break;
} }

View File

@ -2420,6 +2420,7 @@ void vty_close(struct vty *vty)
vty->status = VTY_CLOSE; vty->status = VTY_CLOSE;
if (mgmt_fe_client && vty->mgmt_session_id) { if (mgmt_fe_client && vty->mgmt_session_id) {
MGMTD_FE_CLIENT_DBG("closing vty session");
mgmt_fe_destroy_client_session(mgmt_fe_client, mgmt_fe_destroy_client_session(mgmt_fe_client,
vty->mgmt_client_id); vty->mgmt_client_id);
vty->mgmt_session_id = 0; vty->mgmt_session_id = 0;

View File

@ -564,8 +564,8 @@ mgmt_be_adapter_handle_msg(struct mgmt_be_client_adapter *adapter,
return 0; return 0;
} }
static int mgmt_be_send_txn_req(struct mgmt_be_client_adapter *adapter, int mgmt_be_send_txn_req(struct mgmt_be_client_adapter *adapter,
uint64_t txn_id, bool create) uint64_t txn_id, bool create)
{ {
Mgmtd__BeMessage be_msg; Mgmtd__BeMessage be_msg;
Mgmtd__BeTxnReq txn_req; Mgmtd__BeTxnReq txn_req;
@ -584,11 +584,10 @@ static int mgmt_be_send_txn_req(struct mgmt_be_client_adapter *adapter,
return mgmt_be_adapter_send_msg(adapter, &be_msg); return mgmt_be_adapter_send_msg(adapter, &be_msg);
} }
static int int mgmt_be_send_cfgdata_req(struct mgmt_be_client_adapter *adapter,
mgmt_be_send_cfgdata_create_req(struct mgmt_be_client_adapter *adapter, uint64_t txn_id, uint64_t batch_id,
uint64_t txn_id, uint64_t batch_id, Mgmtd__YangCfgDataReq **cfgdata_reqs,
Mgmtd__YangCfgDataReq **cfgdata_reqs, size_t num_reqs, bool end_of_data)
size_t num_reqs, bool end_of_data)
{ {
Mgmtd__BeMessage be_msg; Mgmtd__BeMessage be_msg;
Mgmtd__BeCfgDataCreateReq cfgdata_req; Mgmtd__BeCfgDataCreateReq cfgdata_req;
@ -612,8 +611,8 @@ mgmt_be_send_cfgdata_create_req(struct mgmt_be_client_adapter *adapter,
return mgmt_be_adapter_send_msg(adapter, &be_msg); return mgmt_be_adapter_send_msg(adapter, &be_msg);
} }
static int mgmt_be_send_cfgapply_req(struct mgmt_be_client_adapter *adapter, int mgmt_be_send_cfgapply_req(struct mgmt_be_client_adapter *adapter,
uint64_t txn_id) uint64_t txn_id)
{ {
Mgmtd__BeMessage be_msg; Mgmtd__BeMessage be_msg;
Mgmtd__BeCfgDataApplyReq apply_req; Mgmtd__BeCfgDataApplyReq apply_req;
@ -834,35 +833,6 @@ int mgmt_be_get_adapter_config(struct mgmt_be_client_adapter *adapter,
return 0; return 0;
} }
int mgmt_be_create_txn(struct mgmt_be_client_adapter *adapter,
uint64_t txn_id)
{
return mgmt_be_send_txn_req(adapter, txn_id, true);
}
int mgmt_be_destroy_txn(struct mgmt_be_client_adapter *adapter,
uint64_t txn_id)
{
return mgmt_be_send_txn_req(adapter, txn_id, false);
}
int mgmt_be_send_cfg_data_create_req(struct mgmt_be_client_adapter *adapter,
uint64_t txn_id, uint64_t batch_id,
struct mgmt_be_cfgreq *cfg_req,
bool end_of_data)
{
return mgmt_be_send_cfgdata_create_req(
adapter, txn_id, batch_id, cfg_req->cfgdata_reqs,
cfg_req->num_reqs, end_of_data);
}
extern int
mgmt_be_send_cfg_apply_req(struct mgmt_be_client_adapter *adapter,
uint64_t txn_id)
{
return mgmt_be_send_cfgapply_req(adapter, txn_id);
}
void mgmt_be_get_subscr_info_for_xpath( void mgmt_be_get_subscr_info_for_xpath(
const char *xpath, struct mgmt_be_client_subscr_info *subscr_info) const char *xpath, struct mgmt_be_client_subscr_info *subscr_info)
{ {

View File

@ -115,13 +115,9 @@ mgmt_be_get_adapter_config(struct mgmt_be_client_adapter *adapter,
struct mgmt_ds_ctx *ds_ctx, struct mgmt_ds_ctx *ds_ctx,
struct nb_config_cbs **cfg_chgs); struct nb_config_cbs **cfg_chgs);
/* Create a transaction. */ /* Create/destroy a transaction. */
extern int mgmt_be_create_txn(struct mgmt_be_client_adapter *adapter, extern int mgmt_be_send_txn_req(struct mgmt_be_client_adapter *adapter,
uint64_t txn_id); uint64_t txn_id, bool create);
/* Destroy a transaction. */
extern int mgmt_be_destroy_txn(struct mgmt_be_client_adapter *adapter,
uint64_t txn_id);
/* /*
* Send config data create request to backend client. * Send config data create request to backend client.
@ -135,8 +131,11 @@ extern int mgmt_be_destroy_txn(struct mgmt_be_client_adapter *adapter,
* batch_id * batch_id
* Request batch ID. * Request batch ID.
* *
* cfg_req * cfgdata_reqs
* Config data request. * An array of pointer to Mgmtd__YangCfgDataReq.
*
* num_reqs
* Length of the cfgdata_reqs array.
* *
* end_of_data * end_of_data
* TRUE if the data from last batch, FALSE otherwise. * TRUE if the data from last batch, FALSE otherwise.
@ -144,37 +143,15 @@ extern int mgmt_be_destroy_txn(struct mgmt_be_client_adapter *adapter,
* Returns: * Returns:
* 0 on success, -1 on failure. * 0 on success, -1 on failure.
*/ */
extern int mgmt_be_send_cfg_data_create_req( extern int mgmt_be_send_cfgdata_req(struct mgmt_be_client_adapter *adapter,
struct mgmt_be_client_adapter *adapter, uint64_t txn_id, uint64_t txn_id, uint64_t batch_id,
uint64_t batch_id, struct mgmt_be_cfgreq *cfg_req, bool end_of_data); Mgmtd__YangCfgDataReq **cfgdata_reqs,
size_t num_reqs, bool end_of_data);
/*
* Send config validate request to backend client.
*
* adaptr
* Backend adapter information.
*
* txn_id
* Unique transaction identifier.
*
* batch_ids
* List of request batch IDs.
*
* num_batch_ids
* Number of batch ids.
*
* Returns:
* 0 on success, -1 on failure.
*/
extern int
mgmt_be_send_cfg_validate_req(struct mgmt_be_client_adapter *adapter,
uint64_t txn_id, uint64_t batch_ids[],
size_t num_batch_ids);
/* /*
* Send config apply request to backend client. * Send config apply request to backend client.
* *
* adaptr * adapter
* Backend adapter information. * Backend adapter information.
* *
* txn_id * txn_id
@ -183,9 +160,8 @@ mgmt_be_send_cfg_validate_req(struct mgmt_be_client_adapter *adapter,
* Returns: * Returns:
* 0 on success, -1 on failure. * 0 on success, -1 on failure.
*/ */
extern int extern int mgmt_be_send_cfgapply_req(struct mgmt_be_client_adapter *adapter,
mgmt_be_send_cfg_apply_req(struct mgmt_be_client_adapter *adapter, uint64_t txn_id);
uint64_t txn_id);
/* /*
* Dump backend adapter status to vty. * Dump backend adapter status to vty.

View File

@ -635,7 +635,6 @@ static void mgmt_txn_process_set_cfg(struct event *thread)
txn->session_id); txn->session_id);
FOREACH_TXN_REQ_IN_LIST (&txn->set_cfg_reqs, txn_req) { FOREACH_TXN_REQ_IN_LIST (&txn->set_cfg_reqs, txn_req) {
error = false;
assert(txn_req->req_event == MGMTD_TXN_PROC_SETCFG); assert(txn_req->req_event == MGMTD_TXN_PROC_SETCFG);
ds_ctx = txn_req->req.set_cfg->ds_ctx; ds_ctx = txn_req->req.set_cfg->ds_ctx;
if (!ds_ctx) { if (!ds_ctx) {
@ -644,7 +643,6 @@ static void mgmt_txn_process_set_cfg(struct event *thread)
txn_req->req.set_cfg->ds_id, txn_req->req_id, txn_req->req.set_cfg->ds_id, txn_req->req_id,
MGMTD_INTERNAL_ERROR, "No such datastore!", MGMTD_INTERNAL_ERROR, "No such datastore!",
txn_req->req.set_cfg->implicit_commit); txn_req->req.set_cfg->implicit_commit);
error = true;
goto mgmt_txn_process_set_cfg_done; goto mgmt_txn_process_set_cfg_done;
} }
@ -656,7 +654,6 @@ static void mgmt_txn_process_set_cfg(struct event *thread)
MGMTD_INTERNAL_ERROR, MGMTD_INTERNAL_ERROR,
"Unable to retrieve DS Config Tree!", "Unable to retrieve DS Config Tree!",
txn_req->req.set_cfg->implicit_commit); txn_req->req.set_cfg->implicit_commit);
error = true;
goto mgmt_txn_process_set_cfg_done; goto mgmt_txn_process_set_cfg_done;
} }
@ -713,7 +710,6 @@ static void mgmt_txn_process_set_cfg(struct event *thread)
"Failed to send SET_CONFIG_REPLY txn-id %" PRIu64 "Failed to send SET_CONFIG_REPLY txn-id %" PRIu64
" session-id: %" PRIu64, " session-id: %" PRIu64,
txn->txn_id, txn->session_id); txn->txn_id, txn->session_id);
error = true;
} }
mgmt_txn_process_set_cfg_done: mgmt_txn_process_set_cfg_done:
@ -1338,8 +1334,7 @@ static int mgmt_txn_send_be_txn_create(struct mgmt_txn_ctx *txn)
FOREACH_MGMTD_BE_CLIENT_ID (id) { FOREACH_MGMTD_BE_CLIENT_ID (id) {
if (cmtcfg_req->subscr_info.xpath_subscr[id]) { if (cmtcfg_req->subscr_info.xpath_subscr[id]) {
adapter = mgmt_be_get_adapter_by_id(id); adapter = mgmt_be_get_adapter_by_id(id);
if (mgmt_be_create_txn(adapter, txn->txn_id) if (mgmt_be_send_txn_req(adapter, txn->txn_id, true)) {
!= 0) {
(void)mgmt_txn_send_commit_cfg_reply( (void)mgmt_txn_send_commit_cfg_reply(
txn, MGMTD_INTERNAL_ERROR, txn, MGMTD_INTERNAL_ERROR,
"Could not send TXN_CREATE to backend adapter"); "Could not send TXN_CREATE to backend adapter");
@ -1372,9 +1367,8 @@ static int mgmt_txn_send_be_txn_create(struct mgmt_txn_ctx *txn)
return 0; return 0;
} }
static int static int mgmt_txn_send_be_cfg_data(struct mgmt_txn_ctx *txn,
mgmt_txn_send_be_cfg_data(struct mgmt_txn_ctx *txn, struct mgmt_be_client_adapter *adapter)
struct mgmt_be_client_adapter *adapter)
{ {
struct mgmt_commit_cfg_req *cmtcfg_req; struct mgmt_commit_cfg_req *cmtcfg_req;
struct mgmt_txn_be_cfg_batch *cfg_btch; struct mgmt_txn_be_cfg_batch *cfg_btch;
@ -1396,10 +1390,10 @@ mgmt_txn_send_be_cfg_data(struct mgmt_txn_ctx *txn,
cfg_req.cfgdata_reqs = cfg_btch->cfg_datap; cfg_req.cfgdata_reqs = cfg_btch->cfg_datap;
cfg_req.num_reqs = cfg_btch->num_cfg_data; cfg_req.num_reqs = cfg_btch->num_cfg_data;
indx++; indx++;
if (mgmt_be_send_cfg_data_create_req( if (mgmt_be_send_cfgdata_req(
adapter, txn->txn_id, cfg_btch->batch_id, &cfg_req, adapter, txn->txn_id, cfg_btch->batch_id,
indx == num_batches ? true : false) cfg_req.cfgdata_reqs, cfg_req.num_reqs,
!= 0) { indx == num_batches ? true : false)) {
(void)mgmt_txn_send_commit_cfg_reply( (void)mgmt_txn_send_commit_cfg_reply(
txn, MGMTD_INTERNAL_ERROR, txn, MGMTD_INTERNAL_ERROR,
"Internal Error! Could not send config data to backend!"); "Internal Error! Could not send config data to backend!");
@ -1419,7 +1413,7 @@ mgmt_txn_send_be_cfg_data(struct mgmt_txn_ctx *txn,
} }
/* /*
* This could ne the last Backend Client to send CFGDATA_CREATE_REQ to. * This could be the last Backend Client to send CFGDATA_CREATE_REQ to.
* Try moving the commit to next phase. * Try moving the commit to next phase.
*/ */
mgmt_try_move_commit_to_next_phase(txn, cmtcfg_req); mgmt_try_move_commit_to_next_phase(txn, cmtcfg_req);
@ -1439,7 +1433,7 @@ mgmt_txn_send_be_txn_delete(struct mgmt_txn_ctx *txn,
cmtcfg_req = &txn->commit_cfg_req->req.commit_cfg; cmtcfg_req = &txn->commit_cfg_req->req.commit_cfg;
if (cmtcfg_req->subscr_info.xpath_subscr[adapter->id]) { if (cmtcfg_req->subscr_info.xpath_subscr[adapter->id]) {
adapter = mgmt_be_get_adapter_by_id(adapter->id); adapter = mgmt_be_get_adapter_by_id(adapter->id);
(void)mgmt_be_destroy_txn(adapter, txn->txn_id); (void)mgmt_be_send_txn_req(adapter, txn->txn_id, false);
FOREACH_TXN_CFG_BATCH_IN_LIST ( FOREACH_TXN_CFG_BATCH_IN_LIST (
&txn->commit_cfg_req->req.commit_cfg &txn->commit_cfg_req->req.commit_cfg
@ -1512,8 +1506,7 @@ static int mgmt_txn_send_be_cfg_apply(struct mgmt_txn_ctx *txn)
return -1; return -1;
btch_list = &cmtcfg_req->curr_batches[id]; btch_list = &cmtcfg_req->curr_batches[id];
if (mgmt_be_send_cfg_apply_req(adapter, txn->txn_id) if (mgmt_be_send_cfgapply_req(adapter, txn->txn_id)) {
!= 0) {
(void)mgmt_txn_send_commit_cfg_reply( (void)mgmt_txn_send_commit_cfg_reply(
txn, MGMTD_INTERNAL_ERROR, txn, MGMTD_INTERNAL_ERROR,
"Could not send CFG_APPLY_REQ to backend adapter"); "Could not send CFG_APPLY_REQ to backend adapter");
@ -2261,11 +2254,6 @@ uint64_t mgmt_create_txn(uint64_t session_id, enum mgmt_txn_type type)
return txn ? txn->txn_id : MGMTD_TXN_ID_NONE; return txn ? txn->txn_id : MGMTD_TXN_ID_NONE;
} }
bool mgmt_txn_id_is_valid(uint64_t txn_id)
{
return mgmt_txn_id2ctx(txn_id) ? true : false;
}
void mgmt_destroy_txn(uint64_t *txn_id) void mgmt_destroy_txn(uint64_t *txn_id)
{ {
struct mgmt_txn_ctx *txn; struct mgmt_txn_ctx *txn;
@ -2278,17 +2266,6 @@ void mgmt_destroy_txn(uint64_t *txn_id)
*txn_id = MGMTD_TXN_ID_NONE; *txn_id = MGMTD_TXN_ID_NONE;
} }
enum mgmt_txn_type mgmt_get_txn_type(uint64_t txn_id)
{
struct mgmt_txn_ctx *txn;
txn = mgmt_txn_id2ctx(txn_id);
if (!txn)
return MGMTD_TXN_TYPE_NONE;
return txn->type;
}
int mgmt_txn_send_set_config_req(uint64_t txn_id, uint64_t req_id, int mgmt_txn_send_set_config_req(uint64_t txn_id, uint64_t req_id,
Mgmtd__DatastoreId ds_id, Mgmtd__DatastoreId ds_id,
struct mgmt_ds_ctx *ds_ctx, struct mgmt_ds_ctx *ds_ctx,

View File

@ -100,16 +100,6 @@ extern uint64_t mgmt_create_txn(uint64_t session_id, enum mgmt_txn_type type);
*/ */
extern void mgmt_destroy_txn(uint64_t *txn_id); extern void mgmt_destroy_txn(uint64_t *txn_id);
/*
* Check if transaction is valid given an ID.
*/
extern bool mgmt_txn_id_is_valid(uint64_t txn_id);
/*
* Returns the type of transaction given an ID.
*/
extern enum mgmt_txn_type mgmt_get_txn_type(uint64_t txn_id);
/* /*
* Send set-config request to be processed later in transaction. * Send set-config request to be processed later in transaction.
* *