mgmtd: step 6: remove old unfinished get-data code

Signed-off-by: Christian Hopps <chopps@labn.net>
This commit is contained in:
Christian Hopps 2023-10-09 20:52:54 -04:00
parent 8df542b219
commit 9cd8693363
6 changed files with 9 additions and 179 deletions

View File

@ -114,25 +114,11 @@ message BeCfgDataApplyReply {
optional string error_if_any = 3;
}
message BeOperDataGetReq {
required uint64 txn_id = 1;
required uint64 batch_id = 2;
repeated YangGetDataReq data = 3;
}
message YangDataReply {
repeated YangData data = 1;
required int64 next_indx = 2;
}
message BeOperDataGetReply {
required uint64 txn_id = 1;
required uint64 batch_id = 2;
required bool success = 3;
optional string error = 4;
optional YangDataReply data = 5;
}
//
// Any message on the MGMTD Backend Interface.
//
@ -146,8 +132,6 @@ message BeMessage {
BeCfgDataCreateReply cfg_data_reply = 7;
BeCfgDataApplyReq cfg_apply_req = 8;
BeCfgDataApplyReply cfg_apply_reply = 9;
BeOperDataGetReq get_req = 10;
BeOperDataGetReply get_reply = 11;
}
}

View File

@ -30,7 +30,6 @@ DEFINE_MTYPE_STATIC(LIB, MGMTD_BE_TXN, "backend transaction data");
enum mgmt_be_txn_event {
MGMTD_BE_TXN_PROC_SETCFG = 1,
MGMTD_BE_TXN_PROC_GETCFG,
MGMTD_BE_TXN_PROC_GETDATA
};
struct mgmt_be_set_cfg_req {
@ -38,16 +37,10 @@ struct mgmt_be_set_cfg_req {
uint16_t num_cfg_changes;
};
struct mgmt_be_get_data_req {
char *xpaths[MGMTD_MAX_NUM_DATA_REQ_IN_BATCH];
uint16_t num_xpaths;
};
struct mgmt_be_txn_req {
enum mgmt_be_txn_event event;
union {
struct mgmt_be_set_cfg_req set_cfg;
struct mgmt_be_get_data_req get_data;
} req;
};
@ -755,19 +748,11 @@ static int mgmt_be_client_handle_msg(struct mgmt_be_client *client_ctx,
mgmt_be_process_cfg_apply(
client_ctx, (uint64_t)be_msg->cfg_apply_req->txn_id);
break;
case MGMTD__BE_MESSAGE__MESSAGE_GET_REQ:
MGMTD_BE_CLIENT_ERR("Got unhandled message type %u",
be_msg->message_case);
/*
* TODO: Add handling code in future.
*/
break;
/*
* NOTE: The following messages are always sent from Backend
* clients to MGMTd only and/or need not be handled here.
*/
case MGMTD__BE_MESSAGE__MESSAGE_SUBSCR_REQ:
case MGMTD__BE_MESSAGE__MESSAGE_GET_REPLY:
case MGMTD__BE_MESSAGE__MESSAGE_TXN_REPLY:
case MGMTD__BE_MESSAGE__MESSAGE_CFG_DATA_REPLY:
case MGMTD__BE_MESSAGE__MESSAGE_CFG_APPLY_REPLY:

View File

@ -417,17 +417,11 @@ mgmt_be_adapter_handle_msg(struct mgmt_be_client_adapter *adapter,
be_msg->cfg_apply_reply->success,
be_msg->cfg_apply_reply->error_if_any, adapter);
break;
case MGMTD__BE_MESSAGE__MESSAGE_GET_REPLY:
/*
* TODO: Add handling code in future.
*/
break;
/*
* NOTE: The following messages are always sent from MGMTD to
* Backend clients only and/or need not be handled on MGMTd.
*/
case MGMTD__BE_MESSAGE__MESSAGE_SUBSCR_REPLY:
case MGMTD__BE_MESSAGE__MESSAGE_GET_REQ:
case MGMTD__BE_MESSAGE__MESSAGE_TXN_REQ:
case MGMTD__BE_MESSAGE__MESSAGE_CFG_DATA_REQ:
case MGMTD__BE_MESSAGE__MESSAGE_CFG_APPLY_REQ:

View File

@ -789,14 +789,8 @@ static int mgmt_fe_session_handle_get_req_msg(struct mgmt_fe_session_ctx *sessio
struct nb_config *cfg_root = NULL;
Mgmtd__DatastoreId ds_id = get_req->ds_id;
uint64_t req_id = get_req->req_id;
bool is_cfg = get_req->config;
bool ds_ok = true;
if (is_cfg && ds_id != MGMTD_DS_CANDIDATE && ds_id != MGMTD_DS_RUNNING)
ds_ok = false;
else if (!is_cfg && ds_id != MGMTD_DS_OPERATIONAL)
ds_ok = false;
if (!ds_ok) {
if (ds_id != MGMTD_DS_CANDIDATE && ds_id != MGMTD_DS_RUNNING) {
fe_adapter_send_get_reply(session, ds_id, req_id, false, NULL,
"get-req on unsupported datastore");
return 0;
@ -832,8 +826,7 @@ static int mgmt_fe_session_handle_get_req_msg(struct mgmt_fe_session_ctx *sessio
/*
* Get a copy of the datastore config root, avoids locking.
*/
if (is_cfg)
cfg_root = nb_config_dup(mgmt_ds_get_nb_config(ds_ctx));
cfg_root = nb_config_dup(mgmt_ds_get_nb_config(ds_ctx));
/*
* Create a GET request under the transaction.
@ -1029,9 +1022,8 @@ mgmt_fe_adapter_handle_msg(struct mgmt_fe_client_adapter *adapter,
break;
case MGMTD__FE_MESSAGE__MESSAGE_GET_REQ:
session = mgmt_session_id2ctx(fe_msg->get_req->session_id);
MGMTD_FE_ADAPTER_DBG("Got GET_REQ (iscfg %d) for DS:%s (xpaths: %d) on session-id %" PRIu64
MGMTD_FE_ADAPTER_DBG("Got GET_REQ for DS:%s (xpaths: %d) on session-id %" PRIu64
" from '%s'",
(int)fe_msg->get_req->config,
mgmt_ds_id2name(fe_msg->get_req->ds_id),
(int)fe_msg->get_req->n_data,
fe_msg->get_req->session_id, adapter->name);

View File

@ -29,7 +29,6 @@ enum mgmt_txn_event {
MGMTD_TXN_PROC_SETCFG = 1,
MGMTD_TXN_PROC_COMMITCFG,
MGMTD_TXN_PROC_GETCFG,
MGMTD_TXN_PROC_GETDATA,
MGMTD_TXN_PROC_GETTREE,
MGMTD_TXN_COMMITCFG_TIMEOUT,
MGMTD_TXN_GETTREE_TIMEOUT,
@ -242,14 +241,6 @@ struct mgmt_txn_ctx {
* involved.
*/
struct mgmt_txn_reqs_head get_cfg_reqs;
/*
* List of pending get-data requests for a given
* transaction/session Two lists, one for requests
* not processed at all, and one for requests that
* has been sent to backend for processing.
*/
struct mgmt_txn_reqs_head get_data_reqs;
struct mgmt_txn_reqs_head pending_get_datas;
/*
* List of pending get-tree requests.
*/
@ -412,16 +403,6 @@ static struct mgmt_txn_req *mgmt_txn_req_alloc(struct mgmt_txn_ctx *txn,
" txn-id: %" PRIu64 " session-id: %" PRIu64,
txn_req->req_id, txn->txn_id, txn->session_id);
break;
case MGMTD_TXN_PROC_GETDATA:
txn_req->req.get_data =
XCALLOC(MTYPE_MGMTD_TXN_GETDATA_REQ,
sizeof(struct mgmt_get_data_req));
assert(txn_req->req.get_data);
mgmt_txn_reqs_add_tail(&txn->get_data_reqs, txn_req);
MGMTD_TXN_DBG("Added a new GETDATA req-id: %" PRIu64
" txn-id: %" PRIu64 " session-id: %" PRIu64,
txn_req->req_id, txn->txn_id, txn->session_id);
break;
case MGMTD_TXN_PROC_GETTREE:
txn_req->req.get_tree = XCALLOC(MTYPE_MGMTD_TXN_GETTREE_REQ,
sizeof(struct txn_req_get_tree));
@ -531,23 +512,6 @@ static void mgmt_txn_req_free(struct mgmt_txn_req **txn_req)
XFREE(MTYPE_MGMTD_TXN_GETDATA_REQ, (*txn_req)->req.get_data);
break;
case MGMTD_TXN_PROC_GETDATA:
for (indx = 0; indx < (*txn_req)->req.get_data->num_xpaths;
indx++) {
if ((*txn_req)->req.get_data->xpaths[indx])
free((void *)(*txn_req)
->req.get_data->xpaths[indx]);
}
pending_list = &(*txn_req)->txn->pending_get_datas;
req_list = &(*txn_req)->txn->get_data_reqs;
MGMTD_TXN_DBG("Deleting GETDATA req-id: %" PRIu64
" txn-id: %" PRIu64,
(*txn_req)->req_id, (*txn_req)->txn->txn_id);
if ((*txn_req)->req.get_data->reply)
XFREE(MTYPE_MGMTD_TXN_GETDATA_REPLY,
(*txn_req)->req.get_data->reply);
XFREE(MTYPE_MGMTD_TXN_GETDATA_REQ, (*txn_req)->req.get_data);
break;
case MGMTD_TXN_PROC_GETTREE:
MGMTD_TXN_DBG("Deleting GETTREE req-id: %" PRIu64
" of txn-id: %" PRIu64,
@ -1579,18 +1543,6 @@ static void mgmt_txn_send_getcfg_reply_data(struct mgmt_txn_req *txn_req,
txn_req->txn->session_id, txn_req->req_id);
}
break;
case MGMTD_TXN_PROC_GETDATA:
if (mgmt_fe_send_get_reply(txn_req->txn->session_id,
txn_req->txn->txn_id, get_req->ds_id,
txn_req->req_id, MGMTD_SUCCESS,
data_reply, NULL) != 0) {
MGMTD_TXN_ERR("Failed to send GET-DATA-REPLY txn-id: %" PRIu64
" session-id: %" PRIu64
" req-id: %" PRIu64,
txn_req->txn->txn_id,
txn_req->txn->session_id, txn_req->req_id);
}
break;
case MGMTD_TXN_PROC_SETCFG:
case MGMTD_TXN_PROC_COMMITCFG:
case MGMTD_TXN_PROC_GETTREE:
@ -1623,8 +1575,7 @@ static void txn_iter_get_config_data_cb(const char *xpath, struct lyd_node *node
if (!(node->schema->nodetype & LYD_NODE_TERM))
return;
assert(txn_req->req_event == MGMTD_TXN_PROC_GETCFG ||
txn_req->req_event == MGMTD_TXN_PROC_GETDATA);
assert(txn_req->req_event == MGMTD_TXN_PROC_GETCFG);
get_req = txn_req->req.get_data;
assert(get_req);
@ -1769,54 +1720,6 @@ static void mgmt_txn_process_get_cfg(struct event *thread)
}
}
static void mgmt_txn_process_get_data(struct event *thread)
{
struct mgmt_txn_ctx *txn;
struct mgmt_txn_req *txn_req;
int num_processed = 0;
txn = (struct mgmt_txn_ctx *)EVENT_ARG(thread);
assert(txn);
MGMTD_TXN_DBG("Processing %zu GET_DATA requests txn-id: %" PRIu64
" session-id: %" PRIu64,
mgmt_txn_reqs_count(&txn->get_data_reqs), txn->txn_id,
txn->session_id);
FOREACH_TXN_REQ_IN_LIST (&txn->get_data_reqs, txn_req) {
assert(txn_req->req_event == MGMTD_TXN_PROC_GETDATA);
/*
* TODO: Trigger GET procedures for Backend
* For now return back error.
*/
mgmt_fe_send_get_reply(txn->session_id, txn->txn_id,
txn_req->req.get_data->ds_id,
txn_req->req_id, MGMTD_INTERNAL_ERROR,
NULL, "GET-DATA is not supported yet!");
/*
* Delete the txn request.
* Note: The following will remove it from the list
* as well.
*/
mgmt_txn_req_free(&txn_req);
/*
* Else the transaction would have been already deleted or
* moved to corresponding pending list. No need to delete it.
*/
num_processed++;
if (num_processed == MGMTD_TXN_MAX_NUM_GETDATA_PROC)
break;
}
if (mgmt_txn_reqs_count(&txn->get_data_reqs)) {
MGMTD_TXN_DBG("Processed maximum number of Get-Data requests (%d/%d). Rescheduling for rest.",
num_processed, MGMTD_TXN_MAX_NUM_GETDATA_PROC);
mgmt_txn_register_event(txn, MGMTD_TXN_PROC_GETDATA);
}
}
static struct mgmt_txn_ctx *
mgmt_fe_find_txn_by_session_id(struct mgmt_master *cm, uint64_t session_id,
enum mgmt_txn_type type)
@ -1857,8 +1760,6 @@ static struct mgmt_txn_ctx *mgmt_txn_create_new(uint64_t session_id,
/* TODO: why do we need N lists for one transaction */
mgmt_txn_reqs_init(&txn->set_cfg_reqs);
mgmt_txn_reqs_init(&txn->get_cfg_reqs);
mgmt_txn_reqs_init(&txn->get_data_reqs);
mgmt_txn_reqs_init(&txn->pending_get_datas);
mgmt_txn_reqs_init(&txn->get_tree_reqs);
txn->commit_cfg_req = NULL;
txn->refcount = 0;
@ -2037,10 +1938,6 @@ static void mgmt_txn_register_event(struct mgmt_txn_ctx *txn,
event_add_timer_tv(mgmt_txn_tm, mgmt_txn_process_get_cfg, txn,
&tv, &txn->proc_get_cfg);
break;
case MGMTD_TXN_PROC_GETDATA:
event_add_timer_tv(mgmt_txn_tm, mgmt_txn_process_get_data, txn,
&tv, &txn->proc_get_data);
break;
case MGMTD_TXN_COMMITCFG_TIMEOUT:
event_add_timer(mgmt_txn_tm, mgmt_txn_cfg_commit_timedout, txn,
MGMTD_TXN_CFG_COMMIT_MAX_DELAY_SEC,
@ -2438,8 +2335,7 @@ int mgmt_txn_send_get_req(uint64_t txn_id, uint64_t req_id,
if (!txn)
return -1;
req_event = cfg_root ? MGMTD_TXN_PROC_GETCFG : MGMTD_TXN_PROC_GETDATA;
req_event = MGMTD_TXN_PROC_GETCFG;
txn_req = mgmt_txn_req_alloc(txn, req_id, req_event);
txn_req->req.get_data->ds_id = ds_id;
txn_req->req.get_data->cfg_root = cfg_root;
@ -2567,7 +2463,6 @@ int mgmt_txn_notify_error(struct mgmt_be_client_adapter *adapter,
case MGMTD_TXN_PROC_SETCFG:
case MGMTD_TXN_PROC_COMMITCFG:
case MGMTD_TXN_PROC_GETCFG:
case MGMTD_TXN_PROC_GETDATA:
case MGMTD_TXN_COMMITCFG_TIMEOUT:
case MGMTD_TXN_GETTREE_TIMEOUT:
case MGMTD_TXN_CLEANUP:

View File

@ -199,29 +199,10 @@ DEFPY(show_mgmt_get_config, show_mgmt_get_config_cmd,
}
DEFPY(show_mgmt_get_data, show_mgmt_get_data_cmd,
"show mgmt get-data [candidate|operational|running]$dsname WORD$path",
SHOW_STR MGMTD_STR
"Get data from a specific datastore\n"
"Candidate datastore\n"
"Operational datastore (default)\n"
"Running datastore\n"
"XPath expression specifying the YANG data path\n")
{
const char *xpath_list[VTY_MAXCFGCHANGES] = {0};
Mgmtd__DatastoreId datastore = MGMTD_DS_OPERATIONAL;
if (dsname)
datastore = mgmt_ds_name2id(dsname);
xpath_list[0] = path;
vty_mgmt_send_get_req(vty, false, datastore, xpath_list, 1);
return CMD_SUCCESS;
}
DEFPY(show_mgmt_get_data_tree, show_mgmt_get_data_tree_cmd,
"show mgmt get-data-tree WORD$path [json|xml]$fmt",
SHOW_STR MGMTD_STR
"Get a data tree from the operational datastore\n"
"show mgmt get-data WORD$path [json|xml]$fmt",
SHOW_STR
MGMTD_STR
"Get a data from the operational datastore\n"
"XPath expression specifying the YANG data root\n"
"JSON output format\n"
"XML output format\n")
@ -541,7 +522,6 @@ void mgmt_vty_init(void)
install_element(VIEW_NODE, &show_mgmt_ds_cmd);
install_element(VIEW_NODE, &show_mgmt_get_config_cmd);
install_element(VIEW_NODE, &show_mgmt_get_data_cmd);
install_element(VIEW_NODE, &show_mgmt_get_data_tree_cmd);
install_element(VIEW_NODE, &show_mgmt_dump_data_cmd);
install_element(VIEW_NODE, &show_mgmt_map_xpath_cmd);
install_element(VIEW_NODE, &show_mgmt_cmt_hist_cmd);