mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-27 10:04:18 +00:00
Merge pull request #15268 from LabNConsulting/chopps/quieter-code
lowercase and localize debug/err macros
This commit is contained in:
commit
a2caf2b5e1
@ -149,7 +149,7 @@ mgmt_be_batch_create(struct mgmt_be_txn_ctx *txn)
|
||||
|
||||
mgmt_be_batches_add_tail(&txn->cfg_batches, batch);
|
||||
|
||||
MGMTD_BE_CLIENT_DBG("Added new batch to transaction");
|
||||
debug_be_client("Added new batch to transaction");
|
||||
|
||||
return batch;
|
||||
}
|
||||
@ -202,8 +202,8 @@ mgmt_be_find_txn_by_id(struct mgmt_be_client *client_ctx, uint64_t txn_id,
|
||||
if (txn->txn_id == txn_id)
|
||||
return txn;
|
||||
if (warn)
|
||||
MGMTD_BE_CLIENT_ERR("client %s unkonwn txn-id: %" PRIu64,
|
||||
client_ctx->name, txn_id);
|
||||
log_err_be_client("client %s unkonwn txn-id: %" PRIu64,
|
||||
client_ctx->name, txn_id);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@ -215,8 +215,8 @@ mgmt_be_txn_create(struct mgmt_be_client *client_ctx, uint64_t txn_id)
|
||||
|
||||
txn = mgmt_be_find_txn_by_id(client_ctx, txn_id, false);
|
||||
if (txn) {
|
||||
MGMTD_BE_CLIENT_ERR("Can't create existing txn-id: %" PRIu64,
|
||||
txn_id);
|
||||
log_err_be_client("Can't create existing txn-id: %" PRIu64,
|
||||
txn_id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -227,7 +227,7 @@ mgmt_be_txn_create(struct mgmt_be_client *client_ctx, uint64_t txn_id)
|
||||
mgmt_be_batches_init(&txn->apply_cfgs);
|
||||
mgmt_be_txns_add_tail(&client_ctx->txn_head, txn);
|
||||
|
||||
MGMTD_BE_CLIENT_DBG("Created new txn-id: %" PRIu64, txn_id);
|
||||
debug_be_client("Created new txn-id: %" PRIu64, txn_id);
|
||||
|
||||
return txn;
|
||||
}
|
||||
@ -321,8 +321,8 @@ void mgmt_be_send_notification(struct lyd_node *tree)
|
||||
|
||||
assert(tree);
|
||||
|
||||
MGMTD_BE_CLIENT_DBG("%s: sending YANG notification: %s", __func__,
|
||||
tree->schema->name);
|
||||
debug_be_client("%s: sending YANG notification: %s", __func__,
|
||||
tree->schema->name);
|
||||
/*
|
||||
* Allocate a message and append the data to it using `format`
|
||||
*/
|
||||
@ -361,7 +361,7 @@ static int mgmt_be_notification_send(void *arg, const char *xpath,
|
||||
struct listnode *ln;
|
||||
LY_ERR err;
|
||||
|
||||
MGMTD_BE_CLIENT_DBG("%s: sending notification: %s", __func__, xpath);
|
||||
debug_be_client("%s: sending notification: %s", __func__, xpath);
|
||||
|
||||
/*
|
||||
* Convert yang data args list to a libyang data tree
|
||||
@ -410,7 +410,7 @@ static int mgmt_be_send_txn_reply(struct mgmt_be_client *client_ctx,
|
||||
be_msg.message_case = MGMTD__BE_MESSAGE__MESSAGE_TXN_REPLY;
|
||||
be_msg.txn_reply = &txn_reply;
|
||||
|
||||
MGMTD_BE_CLIENT_DBG("Sending TXN_REPLY txn-id %" PRIu64, txn_id);
|
||||
debug_be_client("Sending TXN_REPLY txn-id %" PRIu64, txn_id);
|
||||
|
||||
return mgmt_be_client_send_msg(client_ctx, &be_msg);
|
||||
}
|
||||
@ -421,7 +421,7 @@ static int mgmt_be_process_txn_req(struct mgmt_be_client *client_ctx,
|
||||
struct mgmt_be_txn_ctx *txn;
|
||||
|
||||
if (create) {
|
||||
MGMTD_BE_CLIENT_DBG("Creating new txn-id %" PRIu64, txn_id);
|
||||
debug_be_client("Creating new txn-id %" PRIu64, txn_id);
|
||||
|
||||
txn = mgmt_be_txn_create(client_ctx, txn_id);
|
||||
if (!txn)
|
||||
@ -432,7 +432,7 @@ static int mgmt_be_process_txn_req(struct mgmt_be_client *client_ctx,
|
||||
client_ctx->user_data,
|
||||
&txn->client_data, false);
|
||||
} else {
|
||||
MGMTD_BE_CLIENT_DBG("Deleting txn-id: %" PRIu64, txn_id);
|
||||
debug_be_client("Deleting txn-id: %" PRIu64, txn_id);
|
||||
txn = mgmt_be_find_txn_by_id(client_ctx, txn_id, false);
|
||||
if (txn)
|
||||
mgmt_be_txn_delete(client_ctx, &txn);
|
||||
@ -462,8 +462,7 @@ static int mgmt_be_send_cfgdata_create_reply(struct mgmt_be_client *client_ctx,
|
||||
be_msg.message_case = MGMTD__BE_MESSAGE__MESSAGE_CFG_DATA_REPLY;
|
||||
be_msg.cfg_data_reply = &cfgdata_reply;
|
||||
|
||||
MGMTD_BE_CLIENT_DBG("Sending CFGDATA_CREATE_REPLY txn-id: %" PRIu64,
|
||||
txn_id);
|
||||
debug_be_client("Sending CFGDATA_CREATE_REPLY txn-id: %" PRIu64, txn_id);
|
||||
|
||||
return mgmt_be_client_send_msg(client_ctx, &be_msg);
|
||||
}
|
||||
@ -474,9 +473,8 @@ static void mgmt_be_txn_cfg_abort(struct mgmt_be_txn_ctx *txn)
|
||||
|
||||
assert(txn && txn->client);
|
||||
if (txn->nb_txn) {
|
||||
MGMTD_BE_CLIENT_ERR(
|
||||
"Aborting configs after prep for txn-id: %" PRIu64,
|
||||
txn->txn_id);
|
||||
log_err_be_client("Aborting configs after prep for txn-id: %" PRIu64,
|
||||
txn->txn_id);
|
||||
nb_candidate_commit_abort(txn->nb_txn, errmsg, sizeof(errmsg));
|
||||
txn->nb_txn = 0;
|
||||
}
|
||||
@ -487,9 +485,8 @@ static void mgmt_be_txn_cfg_abort(struct mgmt_be_txn_ctx *txn)
|
||||
* This is one txn ctx but the candidate_config is per client ctx, how
|
||||
* does that work?
|
||||
*/
|
||||
MGMTD_BE_CLIENT_DBG(
|
||||
"Reset candidate configurations after abort of txn-id: %" PRIu64,
|
||||
txn->txn_id);
|
||||
debug_be_client("Reset candidate configurations after abort of txn-id: %" PRIu64,
|
||||
txn->txn_id);
|
||||
nb_config_replace(txn->client->candidate_config,
|
||||
txn->client->running_config, true);
|
||||
}
|
||||
@ -537,10 +534,9 @@ static int mgmt_be_txn_cfg_prepare(struct mgmt_be_txn_ctx *txn)
|
||||
NULL, true, err_buf, sizeof(err_buf), &error);
|
||||
if (error) {
|
||||
err_buf[sizeof(err_buf) - 1] = 0;
|
||||
MGMTD_BE_CLIENT_ERR(
|
||||
"Failed to update configs for txn-id: %" PRIu64
|
||||
" to candidate, err: '%s'",
|
||||
txn->txn_id, err_buf);
|
||||
log_err_be_client("Failed to update configs for txn-id: %" PRIu64
|
||||
" to candidate, err: '%s'",
|
||||
txn->txn_id, err_buf);
|
||||
return -1;
|
||||
}
|
||||
gettimeofday(&edit_nb_cfg_end, NULL);
|
||||
@ -578,21 +574,19 @@ static int mgmt_be_txn_cfg_prepare(struct mgmt_be_txn_ctx *txn)
|
||||
if (err != NB_OK) {
|
||||
err_buf[sizeof(err_buf) - 1] = 0;
|
||||
if (err == NB_ERR_VALIDATION)
|
||||
MGMTD_BE_CLIENT_ERR(
|
||||
"Failed to validate configs txn-id: %" PRIu64
|
||||
" %zu batches, err: '%s'",
|
||||
txn->txn_id, num_processed, err_buf);
|
||||
log_err_be_client("Failed to validate configs txn-id: %" PRIu64
|
||||
" %zu batches, err: '%s'",
|
||||
txn->txn_id, num_processed, err_buf);
|
||||
else
|
||||
MGMTD_BE_CLIENT_ERR(
|
||||
"Failed to prepare configs for txn-id: %" PRIu64
|
||||
" %zu batches, err: '%s'",
|
||||
txn->txn_id, num_processed, err_buf);
|
||||
log_err_be_client("Failed to prepare configs for txn-id: %" PRIu64
|
||||
" %zu batches, err: '%s'",
|
||||
txn->txn_id, num_processed, err_buf);
|
||||
error = true;
|
||||
SET_FLAG(txn->flags, MGMTD_BE_TXN_FLAGS_CFGPREP_FAILED);
|
||||
} else
|
||||
MGMTD_BE_CLIENT_DBG("Prepared configs for txn-id: %" PRIu64
|
||||
" %zu batches",
|
||||
txn->txn_id, num_processed);
|
||||
debug_be_client("Prepared configs for txn-id: %" PRIu64
|
||||
" %zu batches",
|
||||
txn->txn_id, num_processed);
|
||||
|
||||
gettimeofday(&prep_nb_cfg_end, NULL);
|
||||
prep_nb_cfg_tm = timeval_elapsed(prep_nb_cfg_end, prep_nb_cfg_start);
|
||||
@ -614,10 +608,9 @@ static int mgmt_be_txn_cfg_prepare(struct mgmt_be_txn_ctx *txn)
|
||||
mgmt_be_send_cfgdata_create_reply(client_ctx, txn->txn_id,
|
||||
error ? false : true, error ? err_buf : NULL);
|
||||
|
||||
MGMTD_BE_CLIENT_DBG(
|
||||
"Avg-nb-edit-duration %lu uSec, nb-prep-duration %lu (avg: %lu) uSec, batch size %u",
|
||||
client_ctx->avg_edit_nb_cfg_tm, prep_nb_cfg_tm,
|
||||
client_ctx->avg_prep_nb_cfg_tm, (uint32_t)num_processed);
|
||||
debug_be_client("Avg-nb-edit-duration %lu uSec, nb-prep-duration %lu (avg: %lu) uSec, batch size %u",
|
||||
client_ctx->avg_edit_nb_cfg_tm, prep_nb_cfg_tm,
|
||||
client_ctx->avg_prep_nb_cfg_tm, (uint32_t)num_processed);
|
||||
|
||||
if (error)
|
||||
mgmt_be_txn_cfg_abort(txn);
|
||||
@ -643,8 +636,9 @@ static int mgmt_be_update_setcfg_in_batch(struct mgmt_be_client *client_ctx,
|
||||
|
||||
txn_req = &batch->txn_req;
|
||||
txn_req->event = MGMTD_BE_TXN_PROC_SETCFG;
|
||||
MGMTD_BE_CLIENT_DBG("Created SETCFG request for txn-id: %" PRIu64
|
||||
" cfg-items:%d", txn->txn_id, num_req);
|
||||
debug_be_client("Created SETCFG request for txn-id: %" PRIu64
|
||||
" cfg-items:%d",
|
||||
txn->txn_id, num_req);
|
||||
|
||||
txn_req->req.set_cfg.num_cfg_changes = num_req;
|
||||
for (index = 0; index < num_req; index++) {
|
||||
@ -706,7 +700,7 @@ static int mgmt_be_process_cfgdata_req(struct mgmt_be_client *client_ctx,
|
||||
mgmt_be_update_setcfg_in_batch(client_ctx, txn, cfg_req, num_req);
|
||||
|
||||
if (txn && end_of_data) {
|
||||
MGMTD_BE_CLIENT_DBG("End of data; CFG_PREPARE_REQ processing");
|
||||
debug_be_client("End of data; CFG_PREPARE_REQ processing");
|
||||
if (mgmt_be_txn_cfg_prepare(txn))
|
||||
goto failed;
|
||||
}
|
||||
@ -735,7 +729,7 @@ static int mgmt_be_send_apply_reply(struct mgmt_be_client *client_ctx,
|
||||
be_msg.message_case = MGMTD__BE_MESSAGE__MESSAGE_CFG_APPLY_REPLY;
|
||||
be_msg.cfg_apply_reply = &apply_reply;
|
||||
|
||||
MGMTD_BE_CLIENT_DBG("Sending CFG_APPLY_REPLY txn-id %" PRIu64, txn_id);
|
||||
debug_be_client("Sending CFG_APPLY_REPLY txn-id %" PRIu64, txn_id);
|
||||
|
||||
return mgmt_be_client_send_msg(client_ctx, &be_msg);
|
||||
}
|
||||
@ -782,8 +776,8 @@ static int mgmt_be_txn_proc_cfgapply(struct mgmt_be_txn_ctx *txn)
|
||||
|
||||
mgmt_be_send_apply_reply(client_ctx, txn->txn_id, true, NULL);
|
||||
|
||||
MGMTD_BE_CLIENT_DBG("Nb-apply-duration %lu (avg: %lu) uSec",
|
||||
apply_nb_cfg_tm, client_ctx->avg_apply_nb_cfg_tm);
|
||||
debug_be_client("Nb-apply-duration %lu (avg: %lu) uSec",
|
||||
apply_nb_cfg_tm, client_ctx->avg_apply_nb_cfg_tm);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -797,7 +791,7 @@ static int mgmt_be_process_cfg_apply(struct mgmt_be_client *client_ctx,
|
||||
if (!txn)
|
||||
goto failed;
|
||||
|
||||
MGMTD_BE_CLIENT_DBG("Trigger CFG_APPLY_REQ processing");
|
||||
debug_be_client("Trigger CFG_APPLY_REQ processing");
|
||||
if (mgmt_be_txn_proc_cfgapply(txn))
|
||||
goto failed;
|
||||
|
||||
@ -820,8 +814,8 @@ static int mgmt_be_client_handle_msg(struct mgmt_be_client *client_ctx,
|
||||
*/
|
||||
switch ((int)be_msg->message_case) {
|
||||
case MGMTD__BE_MESSAGE__MESSAGE_SUBSCR_REPLY:
|
||||
MGMTD_BE_CLIENT_DBG("Got SUBSCR_REPLY success %u",
|
||||
be_msg->subscr_reply->success);
|
||||
debug_be_client("Got SUBSCR_REPLY success %u",
|
||||
be_msg->subscr_reply->success);
|
||||
|
||||
if (client_ctx->cbs.subscr_done)
|
||||
(*client_ctx->cbs.subscr_done)(client_ctx,
|
||||
@ -830,19 +824,18 @@ static int mgmt_be_client_handle_msg(struct mgmt_be_client *client_ctx,
|
||||
->success);
|
||||
break;
|
||||
case MGMTD__BE_MESSAGE__MESSAGE_TXN_REQ:
|
||||
MGMTD_BE_CLIENT_DBG("Got TXN_REQ %s txn-id: %" PRIu64,
|
||||
be_msg->txn_req->create ? "Create"
|
||||
: "Delete",
|
||||
be_msg->txn_req->txn_id);
|
||||
debug_be_client("Got TXN_REQ %s txn-id: %" PRIu64,
|
||||
be_msg->txn_req->create ? "Create" : "Delete",
|
||||
be_msg->txn_req->txn_id);
|
||||
mgmt_be_process_txn_req(client_ctx,
|
||||
be_msg->txn_req->txn_id,
|
||||
be_msg->txn_req->create);
|
||||
break;
|
||||
case MGMTD__BE_MESSAGE__MESSAGE_CFG_DATA_REQ:
|
||||
MGMTD_BE_CLIENT_DBG("Got CFG_DATA_REQ txn-id: %" PRIu64
|
||||
" end-of-data %u",
|
||||
be_msg->cfg_data_req->txn_id,
|
||||
be_msg->cfg_data_req->end_of_data);
|
||||
debug_be_client("Got CFG_DATA_REQ txn-id: %" PRIu64
|
||||
" end-of-data %u",
|
||||
be_msg->cfg_data_req->txn_id,
|
||||
be_msg->cfg_data_req->end_of_data);
|
||||
mgmt_be_process_cfgdata_req(
|
||||
client_ctx, be_msg->cfg_data_req->txn_id,
|
||||
be_msg->cfg_data_req->data_req,
|
||||
@ -850,8 +843,8 @@ static int mgmt_be_client_handle_msg(struct mgmt_be_client *client_ctx,
|
||||
be_msg->cfg_data_req->end_of_data);
|
||||
break;
|
||||
case MGMTD__BE_MESSAGE__MESSAGE_CFG_APPLY_REQ:
|
||||
MGMTD_BE_CLIENT_DBG("Got CFG_APPLY_REQ txn-id: %" PRIu64,
|
||||
be_msg->cfg_data_req->txn_id);
|
||||
debug_be_client("Got CFG_APPLY_REQ txn-id: %" PRIu64,
|
||||
be_msg->cfg_data_req->txn_id);
|
||||
mgmt_be_process_cfg_apply(
|
||||
client_ctx, (uint64_t)be_msg->cfg_apply_req->txn_id);
|
||||
break;
|
||||
@ -946,9 +939,9 @@ static void be_client_handle_get_tree(struct mgmt_be_client *client,
|
||||
struct mgmt_msg_get_tree *get_tree_msg = msgbuf;
|
||||
struct be_client_tree_data_batch_args *args;
|
||||
|
||||
MGMTD_BE_CLIENT_DBG("Received get-tree request for client %s txn-id %" PRIu64
|
||||
" req-id %" PRIu64,
|
||||
client->name, txn_id, get_tree_msg->req_id);
|
||||
debug_be_client("Received get-tree request for client %s txn-id %" PRIu64
|
||||
" req-id %" PRIu64,
|
||||
client->name, txn_id, get_tree_msg->req_id);
|
||||
|
||||
/* NOTE: removed the translator, if put back merge with northbound_cli
|
||||
* code
|
||||
@ -974,7 +967,7 @@ static void be_client_handle_notify(struct mgmt_be_client *client, void *msgbuf,
|
||||
const char *notif;
|
||||
uint i;
|
||||
|
||||
MGMTD_BE_CLIENT_DBG("Received notification for client %s", client->name);
|
||||
debug_be_client("Received notification for client %s", client->name);
|
||||
|
||||
/* "{\"modname:notification-name\": ...}" */
|
||||
notif = (const char *)notif_msg->result + 2;
|
||||
@ -1007,10 +1000,9 @@ static void be_client_handle_native_msg(struct mgmt_be_client *client,
|
||||
be_client_handle_notify(client, msg, msg_len);
|
||||
break;
|
||||
default:
|
||||
MGMTD_BE_CLIENT_ERR("unknown native message txn-id %" PRIu64
|
||||
" req-id %" PRIu64 " code %u to client %s",
|
||||
txn_id, msg->req_id, msg->code,
|
||||
client->name);
|
||||
log_err_be_client("unknown native message txn-id %" PRIu64
|
||||
" req-id %" PRIu64 " code %u to client %s",
|
||||
txn_id, msg->req_id, msg->code, client->name);
|
||||
be_client_send_error(client, msg->refer_id, msg->req_id, false,
|
||||
-1,
|
||||
"BE cilent %s recv msg unknown txn-id %" PRIu64,
|
||||
@ -1035,19 +1027,18 @@ static void mgmt_be_client_process_msg(uint8_t version, uint8_t *data,
|
||||
if (len >= sizeof(*msg))
|
||||
be_client_handle_native_msg(client_ctx, msg, len);
|
||||
else
|
||||
MGMTD_BE_CLIENT_ERR("native message to client %s too short %zu",
|
||||
client_ctx->name, len);
|
||||
log_err_be_client("native message to client %s too short %zu",
|
||||
client_ctx->name, len);
|
||||
return;
|
||||
}
|
||||
|
||||
be_msg = mgmtd__be_message__unpack(NULL, len, data);
|
||||
if (!be_msg) {
|
||||
MGMTD_BE_CLIENT_DBG("Failed to decode %zu bytes from server",
|
||||
len);
|
||||
debug_be_client("Failed to decode %zu bytes from server", len);
|
||||
return;
|
||||
}
|
||||
MGMTD_BE_CLIENT_DBG("Decoded %zu bytes of message(msg: %u/%u) from server",
|
||||
len, be_msg->message_case, be_msg->message_case);
|
||||
debug_be_client("Decoded %zu bytes of message(msg: %u/%u) from server",
|
||||
len, be_msg->message_case, be_msg->message_case);
|
||||
(void)mgmt_be_client_handle_msg(client_ctx, be_msg);
|
||||
mgmtd__be_message__free_unpacked(be_msg, NULL);
|
||||
}
|
||||
@ -1084,9 +1075,9 @@ int mgmt_be_send_subscr_req(struct mgmt_be_client *client_ctx,
|
||||
be_msg.message_case = MGMTD__BE_MESSAGE__MESSAGE_SUBSCR_REQ;
|
||||
be_msg.subscr_req = &subscr_req;
|
||||
|
||||
MGMTD_BE_CLIENT_DBG("Sending SUBSCR_REQ name: %s xpaths: config %zu oper: %zu notif: %zu",
|
||||
subscr_req.client_name, subscr_req.n_config_xpaths,
|
||||
subscr_req.n_oper_xpaths, subscr_req.n_notif_xpaths);
|
||||
debug_be_client("Sending SUBSCR_REQ name: %s xpaths: config %zu oper: %zu notif: %zu",
|
||||
subscr_req.client_name, subscr_req.n_config_xpaths,
|
||||
subscr_req.n_oper_xpaths, subscr_req.n_notif_xpaths);
|
||||
|
||||
ret = mgmt_be_client_send_msg(client_ctx, &be_msg);
|
||||
darr_free(notif_xpaths);
|
||||
@ -1167,7 +1158,7 @@ static int mgmt_debug_be_client_config_write(struct vty *vty)
|
||||
|
||||
void mgmt_debug_be_client_show_debug(struct vty *vty)
|
||||
{
|
||||
if (MGMTD_DBG_BE_CLIENT_CHECK())
|
||||
if (debug_check_be_client())
|
||||
vty_out(vty, "debug mgmt client backend\n");
|
||||
}
|
||||
|
||||
@ -1213,13 +1204,13 @@ struct mgmt_be_client *mgmt_be_client_create(const char *client_name,
|
||||
mgmt_be_client_notify_disconenct,
|
||||
mgmt_be_client_process_msg, MGMTD_BE_MAX_NUM_MSG_PROC,
|
||||
MGMTD_BE_MAX_NUM_MSG_WRITE, MGMTD_BE_MAX_MSG_LEN, false,
|
||||
"BE-client", MGMTD_DBG_BE_CLIENT_CHECK());
|
||||
"BE-client", debug_check_be_client());
|
||||
|
||||
/* Hook to receive notifications */
|
||||
hook_register_arg(nb_notification_send, mgmt_be_notification_send,
|
||||
client);
|
||||
|
||||
MGMTD_BE_CLIENT_DBG("Initialized client '%s'", client_name);
|
||||
debug_be_client("Initialized client '%s'", client_name);
|
||||
|
||||
return client;
|
||||
}
|
||||
@ -1237,8 +1228,7 @@ void mgmt_be_client_destroy(struct mgmt_be_client *client)
|
||||
{
|
||||
assert(client == __be_client);
|
||||
|
||||
MGMTD_BE_CLIENT_DBG("Destroying MGMTD Backend Client '%s'",
|
||||
client->name);
|
||||
debug_be_client("Destroying MGMTD Backend Client '%s'", client->name);
|
||||
|
||||
nb_oper_cancel_all_walks();
|
||||
msg_client_cleanup(&client->client);
|
||||
|
@ -95,12 +95,12 @@ extern struct debug mgmt_dbg_be_client;
|
||||
* API prototypes
|
||||
***************************************************************/
|
||||
|
||||
#define MGMTD_BE_CLIENT_DBG(fmt, ...) \
|
||||
#define debug_be_client(fmt, ...) \
|
||||
DEBUGD(&mgmt_dbg_be_client, "BE-CLIENT: %s: " fmt, __func__, \
|
||||
##__VA_ARGS__)
|
||||
#define MGMTD_BE_CLIENT_ERR(fmt, ...) \
|
||||
#define log_err_be_client(fmt, ...) \
|
||||
zlog_err("BE-CLIENT: %s: ERROR: " fmt, __func__, ##__VA_ARGS__)
|
||||
#define MGMTD_DBG_BE_CLIENT_CHECK() \
|
||||
#define debug_check_be_client() \
|
||||
DEBUG_MODE_CHECK(&mgmt_dbg_be_client, DEBUG_MODE_ALL)
|
||||
|
||||
/**
|
||||
|
@ -79,14 +79,13 @@ mgmt_fe_find_session_by_client_id(struct mgmt_fe_client *client,
|
||||
|
||||
FOREACH_SESSION_IN_LIST (client, session) {
|
||||
if (session->client_id == client_id) {
|
||||
MGMTD_FE_CLIENT_DBG("Found session-id %" PRIu64
|
||||
" using client-id %" PRIu64,
|
||||
session->session_id, client_id);
|
||||
debug_fe_client("Found session-id %" PRIu64
|
||||
" using client-id %" PRIu64,
|
||||
session->session_id, client_id);
|
||||
return session;
|
||||
}
|
||||
}
|
||||
MGMTD_FE_CLIENT_DBG("Session not found using client-id %" PRIu64,
|
||||
client_id);
|
||||
debug_fe_client("Session not found using client-id %" PRIu64, client_id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -98,15 +97,14 @@ mgmt_fe_find_session_by_session_id(struct mgmt_fe_client *client,
|
||||
|
||||
FOREACH_SESSION_IN_LIST (client, session) {
|
||||
if (session->session_id == session_id) {
|
||||
MGMTD_FE_CLIENT_DBG(
|
||||
"Found session of client-id %" PRIu64
|
||||
" using session-id %" PRIu64,
|
||||
session->client_id, session_id);
|
||||
debug_fe_client("Found session of client-id %" PRIu64
|
||||
" using session-id %" PRIu64,
|
||||
session->client_id, session_id);
|
||||
return session;
|
||||
}
|
||||
}
|
||||
MGMTD_FE_CLIENT_DBG("Session not found using session-id %" PRIu64,
|
||||
session_id);
|
||||
debug_fe_client("Session not found using session-id %" PRIu64,
|
||||
session_id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -133,8 +131,7 @@ static int mgmt_fe_send_register_req(struct mgmt_fe_client *client)
|
||||
fe_msg.message_case = MGMTD__FE_MESSAGE__MESSAGE_REGISTER_REQ;
|
||||
fe_msg.register_req = &rgstr_req;
|
||||
|
||||
MGMTD_FE_CLIENT_DBG(
|
||||
"Sending REGISTER_REQ message to MGMTD Frontend server");
|
||||
debug_fe_client("Sending REGISTER_REQ message to MGMTD Frontend server");
|
||||
|
||||
return mgmt_fe_client_send_msg(client, &fe_msg, true);
|
||||
}
|
||||
@ -160,9 +157,8 @@ static int mgmt_fe_send_session_req(struct mgmt_fe_client *client,
|
||||
fe_msg.message_case = MGMTD__FE_MESSAGE__MESSAGE_SESSION_REQ;
|
||||
fe_msg.session_req = &sess_req;
|
||||
|
||||
MGMTD_FE_CLIENT_DBG(
|
||||
"Sending SESSION_REQ %s message for client-id %" PRIu64,
|
||||
create ? "create" : "destroy", session->client_id);
|
||||
debug_fe_client("Sending SESSION_REQ %s message for client-id %" PRIu64,
|
||||
create ? "create" : "destroy", session->client_id);
|
||||
|
||||
return mgmt_fe_client_send_msg(client, &fe_msg, true);
|
||||
}
|
||||
@ -185,9 +181,8 @@ int mgmt_fe_send_lockds_req(struct mgmt_fe_client *client, uint64_t session_id,
|
||||
fe_msg.message_case = MGMTD__FE_MESSAGE__MESSAGE_LOCKDS_REQ;
|
||||
fe_msg.lockds_req = &lockds_req;
|
||||
|
||||
MGMTD_FE_CLIENT_DBG(
|
||||
"Sending LOCKDS_REQ (%sLOCK) message for DS:%s session-id %" PRIu64,
|
||||
lock ? "" : "UN", dsid2name(ds_id), session_id);
|
||||
debug_fe_client("Sending LOCKDS_REQ (%sLOCK) message for DS:%s session-id %" PRIu64,
|
||||
lock ? "" : "UN", dsid2name(ds_id), session_id);
|
||||
|
||||
|
||||
return mgmt_fe_client_send_msg(client, &fe_msg, scok);
|
||||
@ -215,10 +210,9 @@ int mgmt_fe_send_setcfg_req(struct mgmt_fe_client *client, uint64_t session_id,
|
||||
fe_msg.message_case = MGMTD__FE_MESSAGE__MESSAGE_SETCFG_REQ;
|
||||
fe_msg.setcfg_req = &setcfg_req;
|
||||
|
||||
MGMTD_FE_CLIENT_DBG(
|
||||
"Sending SET_CONFIG_REQ message for DS:%s session-id %" PRIu64
|
||||
" (#xpaths:%d)",
|
||||
dsid2name(ds_id), session_id, num_data_reqs);
|
||||
debug_fe_client("Sending SET_CONFIG_REQ message for DS:%s session-id %" PRIu64
|
||||
" (#xpaths:%d)",
|
||||
dsid2name(ds_id), session_id, num_data_reqs);
|
||||
|
||||
return mgmt_fe_client_send_msg(client, &fe_msg, false);
|
||||
}
|
||||
@ -245,9 +239,8 @@ int mgmt_fe_send_commitcfg_req(struct mgmt_fe_client *client,
|
||||
fe_msg.message_case = MGMTD__FE_MESSAGE__MESSAGE_COMMCFG_REQ;
|
||||
fe_msg.commcfg_req = &commitcfg_req;
|
||||
|
||||
MGMTD_FE_CLIENT_DBG(
|
||||
"Sending COMMIT_CONFIG_REQ message for Src-DS:%s, Dst-DS:%s session-id %" PRIu64,
|
||||
dsid2name(src_ds_id), dsid2name(dest_ds_id), session_id);
|
||||
debug_fe_client("Sending COMMIT_CONFIG_REQ message for Src-DS:%s, Dst-DS:%s session-id %" PRIu64,
|
||||
dsid2name(src_ds_id), dsid2name(dest_ds_id), session_id);
|
||||
|
||||
return mgmt_fe_client_send_msg(client, &fe_msg, false);
|
||||
}
|
||||
@ -273,10 +266,9 @@ int mgmt_fe_send_get_req(struct mgmt_fe_client *client, uint64_t session_id,
|
||||
fe_msg.message_case = MGMTD__FE_MESSAGE__MESSAGE_GET_REQ;
|
||||
fe_msg.get_req = &getcfg_req;
|
||||
|
||||
MGMTD_FE_CLIENT_DBG("Sending GET_REQ (iscfg %d) message for DS:%s session-id %" PRIu64
|
||||
" (#xpaths:%d)",
|
||||
is_config, dsid2name(ds_id), session_id,
|
||||
num_data_reqs);
|
||||
debug_fe_client("Sending GET_REQ (iscfg %d) message for DS:%s session-id %" PRIu64
|
||||
" (#xpaths:%d)",
|
||||
is_config, dsid2name(ds_id), session_id, num_data_reqs);
|
||||
|
||||
return mgmt_fe_client_send_msg(client, &fe_msg, false);
|
||||
}
|
||||
@ -328,9 +320,9 @@ int mgmt_fe_send_get_data_req(struct mgmt_fe_client *client,
|
||||
msg->datastore = datastore;
|
||||
strlcpy(msg->xpath, xpath, xplen + 1);
|
||||
|
||||
MGMTD_FE_CLIENT_DBG("Sending GET_DATA_REQ session-id %" PRIu64
|
||||
" req-id %" PRIu64 " xpath: %s",
|
||||
session_id, req_id, xpath);
|
||||
debug_fe_client("Sending GET_DATA_REQ session-id %" PRIu64
|
||||
" req-id %" PRIu64 " xpath: %s",
|
||||
session_id, req_id, xpath);
|
||||
|
||||
ret = mgmt_msg_native_send_msg(&client->client.conn, msg, false);
|
||||
mgmt_msg_native_free_msg(msg);
|
||||
@ -351,30 +343,28 @@ static int mgmt_fe_client_handle_msg(struct mgmt_fe_client *client,
|
||||
case MGMTD__FE_MESSAGE__MESSAGE_SESSION_REPLY:
|
||||
if (fe_msg->session_reply->create &&
|
||||
fe_msg->session_reply->has_client_conn_id) {
|
||||
MGMTD_FE_CLIENT_DBG(
|
||||
"Got SESSION_REPLY (create) for client-id %" PRIu64
|
||||
" with session-id: %" PRIu64,
|
||||
fe_msg->session_reply->client_conn_id,
|
||||
fe_msg->session_reply->session_id);
|
||||
debug_fe_client("Got SESSION_REPLY (create) for client-id %" PRIu64
|
||||
" with session-id: %" PRIu64,
|
||||
fe_msg->session_reply->client_conn_id,
|
||||
fe_msg->session_reply->session_id);
|
||||
|
||||
session = mgmt_fe_find_session_by_client_id(
|
||||
client, fe_msg->session_reply->client_conn_id);
|
||||
|
||||
if (session && fe_msg->session_reply->success) {
|
||||
MGMTD_FE_CLIENT_DBG(
|
||||
"Session Created for client-id %" PRIu64,
|
||||
fe_msg->session_reply->client_conn_id);
|
||||
debug_fe_client("Session Created for client-id %" PRIu64,
|
||||
fe_msg->session_reply
|
||||
->client_conn_id);
|
||||
session->session_id =
|
||||
fe_msg->session_reply->session_id;
|
||||
} else {
|
||||
MGMTD_FE_CLIENT_ERR(
|
||||
log_err_fe_client(
|
||||
"Session Create failed for client-id %" PRIu64,
|
||||
fe_msg->session_reply->client_conn_id);
|
||||
}
|
||||
} else if (!fe_msg->session_reply->create) {
|
||||
MGMTD_FE_CLIENT_DBG(
|
||||
"Got SESSION_REPLY (destroy) for session-id %" PRIu64,
|
||||
fe_msg->session_reply->session_id);
|
||||
debug_fe_client("Got SESSION_REPLY (destroy) for session-id %" PRIu64,
|
||||
fe_msg->session_reply->session_id);
|
||||
|
||||
session = mgmt_fe_find_session_by_session_id(
|
||||
client, fe_msg->session_req->session_id);
|
||||
@ -391,8 +381,8 @@ static int mgmt_fe_client_handle_msg(struct mgmt_fe_client *client,
|
||||
session->user_ctx);
|
||||
break;
|
||||
case MGMTD__FE_MESSAGE__MESSAGE_LOCKDS_REPLY:
|
||||
MGMTD_FE_CLIENT_DBG("Got LOCKDS_REPLY for session-id %" PRIu64,
|
||||
fe_msg->lockds_reply->session_id);
|
||||
debug_fe_client("Got LOCKDS_REPLY for session-id %" PRIu64,
|
||||
fe_msg->lockds_reply->session_id);
|
||||
session = mgmt_fe_find_session_by_session_id(
|
||||
client, fe_msg->lockds_reply->session_id);
|
||||
|
||||
@ -408,8 +398,8 @@ static int mgmt_fe_client_handle_msg(struct mgmt_fe_client *client,
|
||||
fe_msg->lockds_reply->error_if_any);
|
||||
break;
|
||||
case MGMTD__FE_MESSAGE__MESSAGE_SETCFG_REPLY:
|
||||
MGMTD_FE_CLIENT_DBG("Got SETCFG_REPLY for session-id %" PRIu64,
|
||||
fe_msg->setcfg_reply->session_id);
|
||||
debug_fe_client("Got SETCFG_REPLY for session-id %" PRIu64,
|
||||
fe_msg->setcfg_reply->session_id);
|
||||
|
||||
session = mgmt_fe_find_session_by_session_id(
|
||||
client, fe_msg->setcfg_reply->session_id);
|
||||
@ -426,8 +416,8 @@ static int mgmt_fe_client_handle_msg(struct mgmt_fe_client *client,
|
||||
fe_msg->setcfg_reply->error_if_any);
|
||||
break;
|
||||
case MGMTD__FE_MESSAGE__MESSAGE_COMMCFG_REPLY:
|
||||
MGMTD_FE_CLIENT_DBG("Got COMMCFG_REPLY for session-id %" PRIu64,
|
||||
fe_msg->commcfg_reply->session_id);
|
||||
debug_fe_client("Got COMMCFG_REPLY for session-id %" PRIu64,
|
||||
fe_msg->commcfg_reply->session_id);
|
||||
|
||||
session = mgmt_fe_find_session_by_session_id(
|
||||
client, fe_msg->commcfg_reply->session_id);
|
||||
@ -446,8 +436,8 @@ static int mgmt_fe_client_handle_msg(struct mgmt_fe_client *client,
|
||||
fe_msg->commcfg_reply->error_if_any);
|
||||
break;
|
||||
case MGMTD__FE_MESSAGE__MESSAGE_GET_REPLY:
|
||||
MGMTD_FE_CLIENT_DBG("Got GET_REPLY for session-id %" PRIu64,
|
||||
fe_msg->get_reply->session_id);
|
||||
debug_fe_client("Got GET_REPLY for session-id %" PRIu64,
|
||||
fe_msg->get_reply->session_id);
|
||||
|
||||
session =
|
||||
mgmt_fe_find_session_by_session_id(client,
|
||||
@ -516,16 +506,15 @@ static void fe_client_handle_native_msg(struct mgmt_fe_client *client,
|
||||
struct mgmt_msg_error *err_msg;
|
||||
char *notify_data = NULL;
|
||||
|
||||
MGMTD_FE_CLIENT_DBG("Got native message for session-id %" PRIu64,
|
||||
msg->refer_id);
|
||||
debug_fe_client("Got native message for session-id %" PRIu64,
|
||||
msg->refer_id);
|
||||
|
||||
if (msg->code != MGMT_MSG_CODE_NOTIFY) {
|
||||
session = mgmt_fe_find_session_by_session_id(client,
|
||||
msg->refer_id);
|
||||
if (!session || !session->client) {
|
||||
MGMTD_FE_CLIENT_ERR(
|
||||
"No session for received native msg session-id %" PRIu64,
|
||||
msg->refer_id);
|
||||
log_err_fe_client("No session for received native msg session-id %" PRIu64,
|
||||
msg->refer_id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -537,7 +526,7 @@ static void fe_client_handle_native_msg(struct mgmt_fe_client *client,
|
||||
|
||||
err_msg = (typeof(err_msg))msg;
|
||||
if (!MGMT_MSG_VALIDATE_NUL_TERM(err_msg, msg_len)) {
|
||||
MGMTD_FE_CLIENT_ERR("Corrupt error msg recv");
|
||||
log_err_fe_client("Corrupt error msg recv");
|
||||
return;
|
||||
}
|
||||
session->client->cbs.error_notify(client, client->user_data,
|
||||
@ -553,7 +542,7 @@ static void fe_client_handle_native_msg(struct mgmt_fe_client *client,
|
||||
|
||||
tree_msg = (typeof(tree_msg))msg;
|
||||
if (msg_len < sizeof(*tree_msg)) {
|
||||
MGMTD_FE_CLIENT_ERR("Corrupt tree-data msg recv");
|
||||
log_err_fe_client("Corrupt tree-data msg recv");
|
||||
return;
|
||||
}
|
||||
session->client->cbs.get_tree_notify(client, client->user_data,
|
||||
@ -570,13 +559,13 @@ static void fe_client_handle_native_msg(struct mgmt_fe_client *client,
|
||||
case MGMT_MSG_CODE_NOTIFY:
|
||||
notify_msg = (typeof(notify_msg))msg;
|
||||
if (msg_len < sizeof(*notify_msg)) {
|
||||
MGMTD_FE_CLIENT_ERR("Corrupt notify-data msg recv");
|
||||
log_err_fe_client("Corrupt notify-data msg recv");
|
||||
return;
|
||||
}
|
||||
|
||||
if (notify_msg->result_type != LYD_LYB &&
|
||||
!MGMT_MSG_VALIDATE_NUL_TERM(notify_msg, msg_len)) {
|
||||
MGMTD_FE_CLIENT_ERR("Corrupt error msg recv");
|
||||
log_err_fe_client("Corrupt error msg recv");
|
||||
return;
|
||||
}
|
||||
if (notify_msg->result_type == LYD_JSON)
|
||||
@ -588,8 +577,8 @@ static void fe_client_handle_native_msg(struct mgmt_fe_client *client,
|
||||
notify_msg->result_type,
|
||||
LYD_JSON, true);
|
||||
if (!notify_data) {
|
||||
MGMTD_FE_CLIENT_ERR("Can't convert format %d to JSON",
|
||||
notify_msg->result_type);
|
||||
log_err_fe_client("Can't convert format %d to JSON",
|
||||
notify_msg->result_type);
|
||||
return;
|
||||
}
|
||||
FOREACH_SESSION_IN_LIST (client, session) {
|
||||
@ -606,9 +595,9 @@ static void fe_client_handle_native_msg(struct mgmt_fe_client *client,
|
||||
darr_free(notify_data);
|
||||
break;
|
||||
default:
|
||||
MGMTD_FE_CLIENT_ERR("unknown native message session-id %" PRIu64
|
||||
" req-id %" PRIu64 " code %u",
|
||||
msg->refer_id, msg->req_id, msg->code);
|
||||
log_err_fe_client("unknown native message session-id %" PRIu64
|
||||
" req-id %" PRIu64 " code %u",
|
||||
msg->refer_id, msg->req_id, msg->code);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -629,20 +618,18 @@ static void mgmt_fe_client_process_msg(uint8_t version, uint8_t *data,
|
||||
if (len >= sizeof(*msg))
|
||||
fe_client_handle_native_msg(client, msg, len);
|
||||
else
|
||||
MGMTD_FE_CLIENT_ERR("native message to FE client %s too short %zu",
|
||||
client->name, len);
|
||||
log_err_fe_client("native message to FE client %s too short %zu",
|
||||
client->name, len);
|
||||
return;
|
||||
}
|
||||
|
||||
fe_msg = mgmtd__fe_message__unpack(NULL, len, data);
|
||||
if (!fe_msg) {
|
||||
MGMTD_FE_CLIENT_DBG("Failed to decode %zu bytes from server.",
|
||||
len);
|
||||
debug_fe_client("Failed to decode %zu bytes from server.", len);
|
||||
return;
|
||||
}
|
||||
MGMTD_FE_CLIENT_DBG(
|
||||
"Decoded %zu bytes of message(msg: %u/%u) from server", len,
|
||||
fe_msg->message_case, fe_msg->message_case);
|
||||
debug_fe_client("Decoded %zu bytes of message(msg: %u/%u) from server",
|
||||
len, fe_msg->message_case, fe_msg->message_case);
|
||||
(void)mgmt_fe_client_handle_msg(client, fe_msg);
|
||||
mgmtd__fe_message__free_unpacked(fe_msg, NULL);
|
||||
}
|
||||
@ -663,7 +650,7 @@ static int _notify_connect_disconnect(struct msg_client *msg_client,
|
||||
|
||||
/* Walk list of sessions for this FE client deleting them */
|
||||
if (!connected && mgmt_sessions_count(&client->sessions)) {
|
||||
MGMTD_FE_CLIENT_DBG("Cleaning up existing sessions");
|
||||
debug_fe_client("Cleaning up existing sessions");
|
||||
|
||||
FOREACH_SESSION_IN_LIST (client, session) {
|
||||
assert(session->client);
|
||||
@ -734,7 +721,7 @@ static int mgmt_debug_fe_client_config_write(struct vty *vty)
|
||||
|
||||
void mgmt_debug_fe_client_show_debug(struct vty *vty)
|
||||
{
|
||||
if (MGMTD_DBG_FE_CLIENT_CHECK())
|
||||
if (debug_check_fe_client())
|
||||
vty_out(vty, "debug mgmt client frontend\n");
|
||||
}
|
||||
|
||||
@ -780,9 +767,9 @@ struct mgmt_fe_client *mgmt_fe_client_create(const char *client_name,
|
||||
mgmt_fe_client_notify_disconnect,
|
||||
mgmt_fe_client_process_msg, MGMTD_FE_MAX_NUM_MSG_PROC,
|
||||
MGMTD_FE_MAX_NUM_MSG_WRITE, MGMTD_FE_MAX_MSG_LEN, true,
|
||||
"FE-client", MGMTD_DBG_FE_CLIENT_CHECK());
|
||||
"FE-client", debug_check_fe_client());
|
||||
|
||||
MGMTD_FE_CLIENT_DBG("Initialized client '%s'", client_name);
|
||||
debug_fe_client("Initialized client '%s'", client_name);
|
||||
|
||||
return client;
|
||||
}
|
||||
@ -851,9 +838,8 @@ enum mgmt_result mgmt_fe_destroy_client_session(struct mgmt_fe_client *client,
|
||||
|
||||
if (session->session_id &&
|
||||
mgmt_fe_send_session_req(client, session, false) != 0)
|
||||
MGMTD_FE_CLIENT_ERR(
|
||||
"Failed to send session destroy request for the session-id %" PRIu64,
|
||||
session->session_id);
|
||||
log_err_fe_client("Failed to send session destroy request for the session-id %" PRIu64,
|
||||
session->session_id);
|
||||
|
||||
mgmt_sessions_del(&client->sessions, session);
|
||||
XFREE(MTYPE_MGMTD_FE_SESSION, session);
|
||||
@ -870,8 +856,7 @@ void mgmt_fe_client_destroy(struct mgmt_fe_client *client)
|
||||
|
||||
assert(client == __fe_client);
|
||||
|
||||
MGMTD_FE_CLIENT_DBG("Destroying MGMTD Frontend Client '%s'",
|
||||
client->name);
|
||||
debug_fe_client("Destroying MGMTD Frontend Client '%s'", client->name);
|
||||
|
||||
FOREACH_SESSION_IN_LIST (client, session)
|
||||
mgmt_fe_destroy_client_session(client, session->client_id);
|
||||
|
@ -132,12 +132,12 @@ extern struct debug mgmt_dbg_fe_client;
|
||||
* API prototypes
|
||||
***************************************************************/
|
||||
|
||||
#define MGMTD_FE_CLIENT_DBG(fmt, ...) \
|
||||
#define debug_fe_client(fmt, ...) \
|
||||
DEBUGD(&mgmt_dbg_fe_client, "FE-CLIENT: %s: " fmt, __func__, \
|
||||
##__VA_ARGS__)
|
||||
#define MGMTD_FE_CLIENT_ERR(fmt, ...) \
|
||||
#define log_err_fe_client(fmt, ...) \
|
||||
zlog_err("FE-CLIENT: %s: ERROR: " fmt, __func__, ##__VA_ARGS__)
|
||||
#define MGMTD_DBG_FE_CLIENT_CHECK() \
|
||||
#define debug_check_fe_client() \
|
||||
DEBUG_MODE_CHECK(&mgmt_dbg_fe_client, DEBUG_MODE_ALL)
|
||||
|
||||
/*
|
||||
|
75
lib/vty.c
75
lib/vty.c
@ -178,10 +178,10 @@ void vty_mgmt_resume_response(struct vty *vty, int ret)
|
||||
return;
|
||||
}
|
||||
|
||||
MGMTD_FE_CLIENT_DBG("resuming CLI cmd after %s on vty session-id: %" PRIu64
|
||||
" with '%s'",
|
||||
vty->mgmt_req_pending_cmd, vty->mgmt_session_id,
|
||||
ret == CMD_SUCCESS ? "success" : "failed");
|
||||
debug_fe_client("resuming CLI cmd after %s on vty session-id: %" PRIu64
|
||||
" with '%s'",
|
||||
vty->mgmt_req_pending_cmd, vty->mgmt_session_id,
|
||||
ret == CMD_SUCCESS ? "success" : "failed");
|
||||
|
||||
vty->mgmt_req_pending_cmd = NULL;
|
||||
|
||||
@ -2402,10 +2402,9 @@ static void vtysh_read(struct event *thread)
|
||||
* we get response through callback.
|
||||
*/
|
||||
if (vty->mgmt_req_pending_cmd) {
|
||||
MGMTD_FE_CLIENT_DBG(
|
||||
"postpone CLI response pending mgmtd %s on vty session-id %" PRIu64,
|
||||
vty->mgmt_req_pending_cmd,
|
||||
vty->mgmt_session_id);
|
||||
debug_fe_client("postpone CLI response pending mgmtd %s on vty session-id %" PRIu64,
|
||||
vty->mgmt_req_pending_cmd,
|
||||
vty->mgmt_session_id);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2486,14 +2485,14 @@ void vty_close(struct vty *vty)
|
||||
* so warn the user.
|
||||
*/
|
||||
if (vty->mgmt_num_pending_setcfg)
|
||||
MGMTD_FE_CLIENT_ERR(
|
||||
log_err_fe_client(
|
||||
"vty closed, uncommitted config will be lost.");
|
||||
|
||||
/* Drop out of configure / transaction if needed. */
|
||||
vty_config_exit(vty);
|
||||
|
||||
if (mgmt_fe_client && vty->mgmt_session_id) {
|
||||
MGMTD_FE_CLIENT_DBG("closing vty session");
|
||||
debug_fe_client("closing vty session");
|
||||
mgmt_fe_destroy_client_session(mgmt_fe_client,
|
||||
vty->mgmt_client_id);
|
||||
vty->mgmt_session_id = 0;
|
||||
@ -3473,9 +3472,8 @@ void vty_init_vtysh(void)
|
||||
static void vty_mgmt_server_connected(struct mgmt_fe_client *client,
|
||||
uintptr_t usr_data, bool connected)
|
||||
{
|
||||
MGMTD_FE_CLIENT_DBG("Got %sconnected %s MGMTD Frontend Server",
|
||||
!connected ? "dis: " : "",
|
||||
!connected ? "from" : "to");
|
||||
debug_fe_client("Got %sconnected %s MGMTD Frontend Server",
|
||||
!connected ? "dis: " : "", !connected ? "from" : "to");
|
||||
|
||||
/*
|
||||
* We should not have any sessions for connecting or disconnecting case.
|
||||
@ -3511,8 +3509,8 @@ static void vty_mgmt_session_notify(struct mgmt_fe_client *client,
|
||||
return;
|
||||
}
|
||||
|
||||
MGMTD_FE_CLIENT_DBG("%s session for client %" PRIu64 " successfully",
|
||||
create ? "Created" : "Destroyed", client_id);
|
||||
debug_fe_client("%s session for client %" PRIu64 " successfully",
|
||||
create ? "Created" : "Destroyed", client_id);
|
||||
|
||||
if (create) {
|
||||
assert(session_id != 0);
|
||||
@ -3543,8 +3541,8 @@ static void vty_mgmt_ds_lock_notified(struct mgmt_fe_client *client,
|
||||
zlog_err("%socking for DS %u failed, Err: '%s' vty %p",
|
||||
lock_ds ? "L" : "Unl", ds_id, errmsg_if_any, vty);
|
||||
else {
|
||||
MGMTD_FE_CLIENT_DBG("%socked DS %u successfully",
|
||||
lock_ds ? "L" : "Unl", ds_id);
|
||||
debug_fe_client("%socked DS %u successfully",
|
||||
lock_ds ? "L" : "Unl", ds_id);
|
||||
if (ds_id == MGMTD_DS_CANDIDATE)
|
||||
vty->mgmt_locked_candidate_ds = lock_ds;
|
||||
else
|
||||
@ -3575,9 +3573,9 @@ static void vty_mgmt_set_config_result_notified(
|
||||
vty_out(vty, "ERROR: SET_CONFIG request failed, Error: %s\n",
|
||||
errmsg_if_any ? errmsg_if_any : "Unknown");
|
||||
} else {
|
||||
MGMTD_FE_CLIENT_DBG("SET_CONFIG request for client 0x%" PRIx64
|
||||
" req-id %" PRIu64 " was successfull",
|
||||
client_id, req_id);
|
||||
debug_fe_client("SET_CONFIG request for client 0x%" PRIx64
|
||||
" req-id %" PRIu64 " was successfull",
|
||||
client_id, req_id);
|
||||
}
|
||||
|
||||
if (implicit_commit) {
|
||||
@ -3607,10 +3605,9 @@ static void vty_mgmt_commit_config_result_notified(
|
||||
vty_out(vty, "ERROR: COMMIT_CONFIG request failed, Error: %s\n",
|
||||
errmsg_if_any ? errmsg_if_any : "Unknown");
|
||||
} else {
|
||||
MGMTD_FE_CLIENT_DBG(
|
||||
"COMMIT_CONFIG request for client 0x%" PRIx64
|
||||
" req-id %" PRIu64 " was successfull",
|
||||
client_id, req_id);
|
||||
debug_fe_client("COMMIT_CONFIG request for client 0x%" PRIx64
|
||||
" req-id %" PRIu64 " was successfull",
|
||||
client_id, req_id);
|
||||
if (errmsg_if_any)
|
||||
vty_out(vty, "MGMTD: %s\n", errmsg_if_any);
|
||||
}
|
||||
@ -3640,9 +3637,9 @@ static int vty_mgmt_get_data_result_notified(
|
||||
return -1;
|
||||
}
|
||||
|
||||
MGMTD_FE_CLIENT_DBG("GET_DATA request succeeded, client 0x%" PRIx64
|
||||
" req-id %" PRIu64,
|
||||
client_id, req_id);
|
||||
debug_fe_client("GET_DATA request succeeded, client 0x%" PRIx64
|
||||
" req-id %" PRIu64,
|
||||
client_id, req_id);
|
||||
|
||||
if (req_id != mgmt_last_req_id) {
|
||||
mgmt_last_req_id = req_id;
|
||||
@ -3788,10 +3785,9 @@ static int vty_mgmt_get_tree_result_notified(
|
||||
|
||||
vty = (struct vty *)session_ctx;
|
||||
|
||||
MGMTD_FE_CLIENT_DBG("GET_TREE request %ssucceeded, client 0x%" PRIx64
|
||||
" req-id %" PRIu64,
|
||||
partial_error ? "partially " : "", client_id,
|
||||
req_id);
|
||||
debug_fe_client("GET_TREE request %ssucceeded, client 0x%" PRIx64
|
||||
" req-id %" PRIu64,
|
||||
partial_error ? "partially " : "", client_id, req_id);
|
||||
|
||||
assert(result_type == LYD_LYB ||
|
||||
result_type == vty->mgmt_req_pending_data);
|
||||
@ -3838,21 +3834,20 @@ static int vty_mgmt_error_notified(struct mgmt_fe_client *client,
|
||||
const char *cname = mgmt_fe_client_name(client);
|
||||
|
||||
if (!vty->mgmt_req_pending_cmd) {
|
||||
MGMTD_FE_CLIENT_DBG("Erorr with no pending command: %d returned for client %s 0x%" PRIx64
|
||||
" session-id %" PRIu64 " req-id %" PRIu64
|
||||
"error-str %s",
|
||||
error, cname, client_id, session_id, req_id,
|
||||
errstr);
|
||||
debug_fe_client("Erorr with no pending command: %d returned for client %s 0x%" PRIx64
|
||||
" session-id %" PRIu64 " req-id %" PRIu64
|
||||
"error-str %s",
|
||||
error, cname, client_id, session_id, req_id,
|
||||
errstr);
|
||||
vty_out(vty,
|
||||
"%% Error %d from MGMTD for %s with no pending command: %s\n",
|
||||
error, cname, errstr);
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
MGMTD_FE_CLIENT_DBG("Erorr %d returned for client %s 0x%" PRIx64
|
||||
" session-id %" PRIu64 " req-id %" PRIu64
|
||||
"error-str %s",
|
||||
error, cname, client_id, session_id, req_id, errstr);
|
||||
debug_fe_client("Erorr %d returned for client %s 0x%" PRIx64
|
||||
" session-id %" PRIu64 " req-id %" PRIu64 "error-str %s",
|
||||
error, cname, client_id, session_id, req_id, errstr);
|
||||
|
||||
vty_out(vty, "%% %s (for %s, client %s)\n", errstr,
|
||||
vty->mgmt_req_pending_cmd, cname);
|
||||
|
@ -22,9 +22,9 @@
|
||||
#include "mgmt_be_client.h"
|
||||
#include "mgmtd/mgmt_be_adapter.h"
|
||||
|
||||
#define MGMTD_BE_ADAPTER_DBG(fmt, ...) \
|
||||
#define __dbg(fmt, ...) \
|
||||
DEBUGD(&mgmt_debug_be, "BE-ADAPTER: %s: " fmt, __func__, ##__VA_ARGS__)
|
||||
#define MGMTD_BE_ADAPTER_ERR(fmt, ...) \
|
||||
#define __log_err(fmt, ...) \
|
||||
zlog_err("BE-ADAPTER: %s: ERROR: " fmt, __func__, ##__VA_ARGS__)
|
||||
|
||||
#define FOREACH_ADAPTER_IN_LIST(adapter) \
|
||||
@ -252,26 +252,24 @@ static void mgmt_be_xpath_map_init(void)
|
||||
enum mgmt_be_client_id id;
|
||||
const char *const *init;
|
||||
|
||||
MGMTD_BE_ADAPTER_DBG("Init XPath Maps");
|
||||
__dbg("Init XPath Maps");
|
||||
|
||||
FOREACH_MGMTD_BE_CLIENT_ID (id) {
|
||||
/* Initialize the common config init map */
|
||||
for (init = be_client_config_xpaths[id]; init && *init; init++) {
|
||||
MGMTD_BE_ADAPTER_DBG(" - CFG XPATH: '%s'", *init);
|
||||
__dbg(" - CFG XPATH: '%s'", *init);
|
||||
mgmt_register_client_xpath(id, *init, true, false);
|
||||
}
|
||||
|
||||
/* Initialize the common oper init map */
|
||||
for (init = be_client_oper_xpaths[id]; init && *init; init++) {
|
||||
MGMTD_BE_ADAPTER_DBG(" - OPER XPATH: '%s'", *init);
|
||||
__dbg(" - OPER XPATH: '%s'", *init);
|
||||
mgmt_register_client_xpath(id, *init, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
MGMTD_BE_ADAPTER_DBG("Total Cfg XPath Maps: %u",
|
||||
darr_len(be_cfg_xpath_map));
|
||||
MGMTD_BE_ADAPTER_DBG("Total Oper XPath Maps: %u",
|
||||
darr_len(be_oper_xpath_map));
|
||||
__dbg("Total Cfg XPath Maps: %u", darr_len(be_cfg_xpath_map));
|
||||
__dbg("Total Oper XPath Maps: %u", darr_len(be_oper_xpath_map));
|
||||
}
|
||||
|
||||
static void mgmt_be_xpath_map_cleanup(void)
|
||||
@ -319,7 +317,7 @@ static bool mgmt_be_xpath_prefix(const char *path, const char *xpath)
|
||||
|
||||
static void mgmt_be_adapter_delete(struct mgmt_be_client_adapter *adapter)
|
||||
{
|
||||
MGMTD_BE_ADAPTER_DBG("deleting client adapter '%s'", adapter->name);
|
||||
__dbg("deleting client adapter '%s'", adapter->name);
|
||||
|
||||
/*
|
||||
* Notify about disconnect for appropriate cleanup
|
||||
@ -338,8 +336,7 @@ static int mgmt_be_adapter_notify_disconnect(struct msg_conn *conn)
|
||||
{
|
||||
struct mgmt_be_client_adapter *adapter = conn->user;
|
||||
|
||||
MGMTD_BE_ADAPTER_DBG("notify disconnect for client adapter '%s'",
|
||||
adapter->name);
|
||||
__dbg("notify disconnect for client adapter '%s'", adapter->name);
|
||||
|
||||
mgmt_be_adapter_delete(adapter);
|
||||
|
||||
@ -357,10 +354,8 @@ mgmt_be_adapter_cleanup_old_conn(struct mgmt_be_client_adapter *adapter)
|
||||
/*
|
||||
* We have a Zombie lingering around
|
||||
*/
|
||||
MGMTD_BE_ADAPTER_DBG(
|
||||
"Client '%s' (FD:%d) seems to have reconnected. Removing old connection (FD:%d)!",
|
||||
adapter->name, adapter->conn->fd,
|
||||
old->conn->fd);
|
||||
__dbg("Client '%s' (FD:%d) seems to have reconnected. Removing old connection (FD:%d)!",
|
||||
adapter->name, adapter->conn->fd, old->conn->fd);
|
||||
/* this will/should delete old */
|
||||
msg_conn_disconnect(old->conn, false);
|
||||
}
|
||||
@ -389,8 +384,8 @@ static int mgmt_be_send_subscr_reply(struct mgmt_be_client_adapter *adapter,
|
||||
be_msg.message_case = MGMTD__BE_MESSAGE__MESSAGE_SUBSCR_REPLY;
|
||||
be_msg.subscr_reply = &reply;
|
||||
|
||||
MGMTD_BE_CLIENT_DBG("Sending SUBSCR_REPLY client: %s sucess: %u",
|
||||
adapter->name, success);
|
||||
__dbg("Sending SUBSCR_REPLY client: %s sucess: %u", adapter->name,
|
||||
success);
|
||||
|
||||
return mgmt_be_adapter_send_msg(adapter, &be_msg);
|
||||
}
|
||||
@ -408,20 +403,19 @@ mgmt_be_adapter_handle_msg(struct mgmt_be_client_adapter *adapter,
|
||||
*/
|
||||
switch ((int)be_msg->message_case) {
|
||||
case MGMTD__BE_MESSAGE__MESSAGE_SUBSCR_REQ:
|
||||
MGMTD_BE_ADAPTER_DBG("Got SUBSCR_REQ from '%s' to register xpaths config: %zu oper: %zu notif: %zu",
|
||||
be_msg->subscr_req->client_name,
|
||||
be_msg->subscr_req->n_config_xpaths,
|
||||
be_msg->subscr_req->n_oper_xpaths,
|
||||
be_msg->subscr_req->n_notif_xpaths);
|
||||
__dbg("Got SUBSCR_REQ from '%s' to register xpaths config: %zu oper: %zu notif: %zu",
|
||||
be_msg->subscr_req->client_name,
|
||||
be_msg->subscr_req->n_config_xpaths,
|
||||
be_msg->subscr_req->n_oper_xpaths,
|
||||
be_msg->subscr_req->n_notif_xpaths);
|
||||
|
||||
if (strlen(be_msg->subscr_req->client_name)) {
|
||||
strlcpy(adapter->name, be_msg->subscr_req->client_name,
|
||||
sizeof(adapter->name));
|
||||
adapter->id = mgmt_be_client_name2id(adapter->name);
|
||||
if (adapter->id >= MGMTD_BE_CLIENT_ID_MAX) {
|
||||
MGMTD_BE_ADAPTER_ERR(
|
||||
"Unable to resolve adapter '%s' to a valid ID. Disconnecting!",
|
||||
adapter->name);
|
||||
__log_err("Unable to resolve adapter '%s' to a valid ID. Disconnecting!",
|
||||
adapter->name);
|
||||
/* this will/should delete old */
|
||||
msg_conn_disconnect(adapter->conn, false);
|
||||
break;
|
||||
@ -457,12 +451,10 @@ mgmt_be_adapter_handle_msg(struct mgmt_be_client_adapter *adapter,
|
||||
mgmt_be_send_subscr_reply(adapter, true);
|
||||
break;
|
||||
case MGMTD__BE_MESSAGE__MESSAGE_TXN_REPLY:
|
||||
MGMTD_BE_ADAPTER_DBG(
|
||||
"Got %s TXN_REPLY from '%s' txn-id %" PRIx64
|
||||
" with '%s'",
|
||||
be_msg->txn_reply->create ? "Create" : "Delete",
|
||||
adapter->name, be_msg->txn_reply->txn_id,
|
||||
be_msg->txn_reply->success ? "success" : "failure");
|
||||
__dbg("Got %s TXN_REPLY from '%s' txn-id %" PRIx64 " with '%s'",
|
||||
be_msg->txn_reply->create ? "Create" : "Delete",
|
||||
adapter->name, be_msg->txn_reply->txn_id,
|
||||
be_msg->txn_reply->success ? "success" : "failure");
|
||||
/*
|
||||
* Forward the TXN_REPLY to txn module.
|
||||
*/
|
||||
@ -472,13 +464,11 @@ mgmt_be_adapter_handle_msg(struct mgmt_be_client_adapter *adapter,
|
||||
be_msg->txn_reply->success, adapter);
|
||||
break;
|
||||
case MGMTD__BE_MESSAGE__MESSAGE_CFG_DATA_REPLY:
|
||||
MGMTD_BE_ADAPTER_DBG(
|
||||
"Got CFGDATA_REPLY from '%s' txn-id %" PRIx64
|
||||
" err:'%s'", adapter->name,
|
||||
be_msg->cfg_data_reply->txn_id,
|
||||
be_msg->cfg_data_reply->error_if_any
|
||||
? be_msg->cfg_data_reply->error_if_any
|
||||
: "None");
|
||||
__dbg("Got CFGDATA_REPLY from '%s' txn-id %" PRIx64 " err:'%s'",
|
||||
adapter->name, be_msg->cfg_data_reply->txn_id,
|
||||
be_msg->cfg_data_reply->error_if_any
|
||||
? be_msg->cfg_data_reply->error_if_any
|
||||
: "None");
|
||||
/*
|
||||
* Forward the CGFData-create reply to txn module.
|
||||
*/
|
||||
@ -488,15 +478,13 @@ mgmt_be_adapter_handle_msg(struct mgmt_be_client_adapter *adapter,
|
||||
be_msg->cfg_data_reply->error_if_any, adapter);
|
||||
break;
|
||||
case MGMTD__BE_MESSAGE__MESSAGE_CFG_APPLY_REPLY:
|
||||
MGMTD_BE_ADAPTER_DBG(
|
||||
"Got %s CFG_APPLY_REPLY from '%s' txn-id %" PRIx64
|
||||
" err:'%s'",
|
||||
be_msg->cfg_apply_reply->success ? "successful"
|
||||
: "failed",
|
||||
adapter->name, be_msg->cfg_apply_reply->txn_id,
|
||||
be_msg->cfg_apply_reply->error_if_any
|
||||
? be_msg->cfg_apply_reply->error_if_any
|
||||
: "None");
|
||||
__dbg("Got %s CFG_APPLY_REPLY from '%s' txn-id %" PRIx64
|
||||
" err:'%s'",
|
||||
be_msg->cfg_apply_reply->success ? "successful" : "failed",
|
||||
adapter->name, be_msg->cfg_apply_reply->txn_id,
|
||||
be_msg->cfg_apply_reply->error_if_any
|
||||
? be_msg->cfg_apply_reply->error_if_any
|
||||
: "None");
|
||||
/*
|
||||
* Forward the CGFData-apply reply to txn module.
|
||||
*/
|
||||
@ -541,8 +529,7 @@ int mgmt_be_send_txn_req(struct mgmt_be_client_adapter *adapter,
|
||||
be_msg.message_case = MGMTD__BE_MESSAGE__MESSAGE_TXN_REQ;
|
||||
be_msg.txn_req = &txn_req;
|
||||
|
||||
MGMTD_BE_ADAPTER_DBG("Sending TXN_REQ to '%s' txn-id: %" PRIu64,
|
||||
adapter->name, txn_id);
|
||||
__dbg("Sending TXN_REQ to '%s' txn-id: %" PRIu64, adapter->name, txn_id);
|
||||
|
||||
return mgmt_be_adapter_send_msg(adapter, &be_msg);
|
||||
}
|
||||
@ -565,10 +552,8 @@ int mgmt_be_send_cfgdata_req(struct mgmt_be_client_adapter *adapter,
|
||||
be_msg.message_case = MGMTD__BE_MESSAGE__MESSAGE_CFG_DATA_REQ;
|
||||
be_msg.cfg_data_req = &cfgdata_req;
|
||||
|
||||
MGMTD_BE_ADAPTER_DBG(
|
||||
"Sending CFGDATA_CREATE_REQ to '%s' txn-id: %" PRIu64
|
||||
" last: %s",
|
||||
adapter->name, txn_id, end_of_data ? "yes" : "no");
|
||||
__dbg("Sending CFGDATA_CREATE_REQ to '%s' txn-id: %" PRIu64 " last: %s",
|
||||
adapter->name, txn_id, end_of_data ? "yes" : "no");
|
||||
|
||||
return mgmt_be_adapter_send_msg(adapter, &be_msg);
|
||||
}
|
||||
@ -586,8 +571,8 @@ int mgmt_be_send_cfgapply_req(struct mgmt_be_client_adapter *adapter,
|
||||
be_msg.message_case = MGMTD__BE_MESSAGE__MESSAGE_CFG_APPLY_REQ;
|
||||
be_msg.cfg_apply_req = &apply_req;
|
||||
|
||||
MGMTD_BE_ADAPTER_DBG("Sending CFG_APPLY_REQ to '%s' txn-id: %" PRIu64,
|
||||
adapter->name, txn_id);
|
||||
__dbg("Sending CFG_APPLY_REQ to '%s' txn-id: %" PRIu64, adapter->name,
|
||||
txn_id);
|
||||
|
||||
return mgmt_be_adapter_send_msg(adapter, &be_msg);
|
||||
}
|
||||
@ -646,8 +631,8 @@ static void be_adapter_handle_native_msg(struct mgmt_be_client_adapter *adapter,
|
||||
switch (msg->code) {
|
||||
case MGMT_MSG_CODE_ERROR:
|
||||
error_msg = (typeof(error_msg))msg;
|
||||
MGMTD_BE_ADAPTER_DBG("Got ERROR from '%s' txn-id %" PRIx64,
|
||||
adapter->name, msg->refer_id);
|
||||
__dbg("Got ERROR from '%s' txn-id %" PRIx64, adapter->name,
|
||||
msg->refer_id);
|
||||
|
||||
/* Forward the reply to the txn module */
|
||||
mgmt_txn_notify_error(adapter, msg->refer_id, msg->req_id,
|
||||
@ -657,24 +642,23 @@ static void be_adapter_handle_native_msg(struct mgmt_be_client_adapter *adapter,
|
||||
case MGMT_MSG_CODE_TREE_DATA:
|
||||
/* tree data from a backend client */
|
||||
tree_msg = (typeof(tree_msg))msg;
|
||||
MGMTD_BE_ADAPTER_DBG("Got TREE_DATA from '%s' txn-id %" PRIx64,
|
||||
adapter->name, msg->refer_id);
|
||||
__dbg("Got TREE_DATA from '%s' txn-id %" PRIx64, adapter->name,
|
||||
msg->refer_id);
|
||||
|
||||
/* Forward the reply to the txn module */
|
||||
mgmt_txn_notify_tree_data_reply(adapter, tree_msg, msg_len);
|
||||
break;
|
||||
case MGMT_MSG_CODE_NOTIFY:
|
||||
notify_msg = (typeof(notify_msg))msg;
|
||||
MGMTD_BE_ADAPTER_DBG("Got NOTIFY from '%s'", adapter->name);
|
||||
__dbg("Got NOTIFY from '%s'", adapter->name);
|
||||
mgmt_be_adapter_send_notify(notify_msg, msg_len);
|
||||
mgmt_fe_adapter_send_notify(notify_msg, msg_len);
|
||||
break;
|
||||
default:
|
||||
MGMTD_BE_ADAPTER_ERR("unknown native message txn-id %" PRIu64
|
||||
" req-id %" PRIu64
|
||||
" code %u from BE client for adapter %s",
|
||||
msg->refer_id, msg->req_id, msg->code,
|
||||
adapter->name);
|
||||
__log_err("unknown native message txn-id %" PRIu64
|
||||
" req-id %" PRIu64
|
||||
" code %u from BE client for adapter %s",
|
||||
msg->refer_id, msg->req_id, msg->code, adapter->name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -692,20 +676,19 @@ static void mgmt_be_adapter_process_msg(uint8_t version, uint8_t *data,
|
||||
if (len >= sizeof(*msg))
|
||||
be_adapter_handle_native_msg(adapter, msg, len);
|
||||
else
|
||||
MGMTD_BE_ADAPTER_ERR("native message to adapter %s too short %zu",
|
||||
adapter->name, len);
|
||||
__log_err("native message to adapter %s too short %zu",
|
||||
adapter->name, len);
|
||||
return;
|
||||
}
|
||||
|
||||
be_msg = mgmtd__be_message__unpack(NULL, len, data);
|
||||
if (!be_msg) {
|
||||
MGMTD_BE_ADAPTER_DBG(
|
||||
"Failed to decode %zu bytes for adapter: %s", len,
|
||||
adapter->name);
|
||||
__dbg("Failed to decode %zu bytes for adapter: %s", len,
|
||||
adapter->name);
|
||||
return;
|
||||
}
|
||||
MGMTD_BE_ADAPTER_DBG("Decoded %zu bytes of message: %u for adapter: %s",
|
||||
len, be_msg->message_case, adapter->name);
|
||||
__dbg("Decoded %zu bytes of message: %u for adapter: %s", len,
|
||||
be_msg->message_case, adapter->name);
|
||||
(void)mgmt_be_adapter_handle_msg(adapter, be_msg);
|
||||
mgmtd__be_message__free_unpacked(be_msg, NULL);
|
||||
}
|
||||
@ -839,8 +822,7 @@ struct msg_conn *mgmt_be_create_adapter(int conn_fd, union sockunion *from)
|
||||
|
||||
adapter->conn->debug = DEBUG_MODE_CHECK(&mgmt_debug_be, DEBUG_MODE_ALL);
|
||||
|
||||
MGMTD_BE_ADAPTER_DBG("Added new MGMTD Backend adapter '%s'",
|
||||
adapter->name);
|
||||
__dbg("Added new MGMTD Backend adapter '%s'", adapter->name);
|
||||
|
||||
return adapter->conn;
|
||||
}
|
||||
@ -907,15 +889,15 @@ uint64_t mgmt_be_interested_clients(const char *xpath, bool config)
|
||||
|
||||
clients = 0;
|
||||
|
||||
MGMTD_BE_ADAPTER_DBG("XPATH: '%s'", xpath);
|
||||
__dbg("XPATH: '%s'", xpath);
|
||||
darr_foreach_p (maps, map)
|
||||
if (mgmt_be_xpath_prefix(map->xpath_prefix, xpath))
|
||||
clients |= map->clients;
|
||||
|
||||
if (DEBUG_MODE_CHECK(&mgmt_debug_be, DEBUG_MODE_ALL)) {
|
||||
FOREACH_BE_CLIENT_BITS (id, clients)
|
||||
MGMTD_BE_ADAPTER_DBG("Cient: %s: subscribed",
|
||||
mgmt_be_client_id2name(id));
|
||||
__dbg("Cient: %s: subscribed",
|
||||
mgmt_be_client_id2name(id));
|
||||
}
|
||||
return clients;
|
||||
}
|
||||
@ -939,23 +921,21 @@ static bool be_is_client_interested(const char *xpath,
|
||||
|
||||
assert(id < MGMTD_BE_CLIENT_ID_MAX);
|
||||
|
||||
MGMTD_BE_ADAPTER_DBG("Checking client: %s for xpath: '%s'",
|
||||
mgmt_be_client_id2name(id), xpath);
|
||||
__dbg("Checking client: %s for xpath: '%s'", mgmt_be_client_id2name(id),
|
||||
xpath);
|
||||
|
||||
xpaths = config ? be_client_config_xpaths[id]
|
||||
: be_client_oper_xpaths[id];
|
||||
if (xpaths) {
|
||||
for (; *xpaths; xpaths++) {
|
||||
if (mgmt_be_xpath_prefix(*xpaths, xpath)) {
|
||||
MGMTD_BE_ADAPTER_DBG("xpath: %s: matched: %s",
|
||||
*xpaths, xpath);
|
||||
__dbg("xpath: %s: matched: %s", *xpaths, xpath);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MGMTD_BE_ADAPTER_DBG("client: %s: not interested",
|
||||
mgmt_be_client_id2name(id));
|
||||
__dbg("client: %s: not interested", mgmt_be_client_id2name(id));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -15,10 +15,9 @@
|
||||
#include "mgmtd/mgmt_txn.h"
|
||||
#include "libyang/libyang.h"
|
||||
|
||||
#define MGMTD_DS_DBG(fmt, ...) \
|
||||
#define __dbg(fmt, ...) \
|
||||
DEBUGD(&mgmt_debug_ds, "DS: %s: " fmt, __func__, ##__VA_ARGS__)
|
||||
#define MGMTD_DS_ERR(fmt, ...) \
|
||||
zlog_err("%s: ERROR: " fmt, __func__, ##__VA_ARGS__)
|
||||
#define __log_err(fmt, ...) zlog_err("%s: ERROR: " fmt, __func__, ##__VA_ARGS__)
|
||||
|
||||
struct mgmt_ds_ctx {
|
||||
Mgmtd__DatastoreId ds_id;
|
||||
@ -81,8 +80,8 @@ static int mgmt_ds_replace_dst_with_src_ds(struct mgmt_ds_ctx *src,
|
||||
if (!src || !dst)
|
||||
return -1;
|
||||
|
||||
MGMTD_DS_DBG("Replacing %s with %s", mgmt_ds_id2name(dst->ds_id),
|
||||
mgmt_ds_id2name(src->ds_id));
|
||||
__dbg("Replacing %s with %s", mgmt_ds_id2name(dst->ds_id),
|
||||
mgmt_ds_id2name(src->ds_id));
|
||||
|
||||
if (src->config_ds && dst->config_ds)
|
||||
nb_config_replace(dst->root.cfg_root, src->root.cfg_root, true);
|
||||
@ -104,7 +103,7 @@ static int mgmt_ds_merge_src_with_dst_ds(struct mgmt_ds_ctx *src,
|
||||
if (!src || !dst)
|
||||
return -1;
|
||||
|
||||
MGMTD_DS_DBG("Merging DS %d with %d", dst->ds_id, src->ds_id);
|
||||
__dbg("Merging DS %d with %d", dst->ds_id, src->ds_id);
|
||||
if (src->config_ds && dst->config_ds)
|
||||
ret = nb_config_merge(dst->root.cfg_root, src->root.cfg_root,
|
||||
true);
|
||||
@ -114,7 +113,7 @@ static int mgmt_ds_merge_src_with_dst_ds(struct mgmt_ds_ctx *src,
|
||||
src->root.dnode_root, 0);
|
||||
}
|
||||
if (ret != 0) {
|
||||
MGMTD_DS_ERR("merge failed with err: %d", ret);
|
||||
__log_err("merge failed with err: %d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -299,7 +298,7 @@ static int mgmt_walk_ds_nodes(
|
||||
|
||||
assert(mgmt_ds_node_iter_fn);
|
||||
|
||||
MGMTD_DS_DBG(" -- START: base xpath: '%s'", base_xpath);
|
||||
__dbg(" -- START: base xpath: '%s'", base_xpath);
|
||||
|
||||
if (!base_dnode)
|
||||
/*
|
||||
@ -310,9 +309,9 @@ static int mgmt_walk_ds_nodes(
|
||||
if (!base_dnode)
|
||||
return -1;
|
||||
|
||||
MGMTD_DS_DBG(" search base schema: '%s'",
|
||||
lysc_path(base_dnode->schema, LYSC_PATH_LOG, xpath,
|
||||
sizeof(xpath)));
|
||||
__dbg(" search base schema: '%s'",
|
||||
lysc_path(base_dnode->schema, LYSC_PATH_LOG, xpath,
|
||||
sizeof(xpath)));
|
||||
|
||||
nbnode = (struct nb_node *)base_dnode->schema->priv;
|
||||
(*mgmt_ds_node_iter_fn)(base_xpath, base_dnode, nbnode, ctx);
|
||||
@ -335,7 +334,7 @@ static int mgmt_walk_ds_nodes(
|
||||
|
||||
(void)lyd_path(dnode, LYD_PATH_STD, xpath, sizeof(xpath));
|
||||
|
||||
MGMTD_DS_DBG(" -- Child xpath: %s", xpath);
|
||||
__dbg(" -- Child xpath: %s", xpath);
|
||||
|
||||
ret = mgmt_walk_ds_nodes(root, xpath, dnode,
|
||||
mgmt_ds_node_iter_fn, ctx);
|
||||
@ -343,7 +342,7 @@ static int mgmt_walk_ds_nodes(
|
||||
break;
|
||||
}
|
||||
|
||||
MGMTD_DS_DBG(" -- END: base xpath: '%s'", base_xpath);
|
||||
__dbg(" -- END: base xpath: '%s'", base_xpath);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -407,8 +406,7 @@ int mgmt_ds_load_config_from_file(struct mgmt_ds_ctx *dst,
|
||||
return -1;
|
||||
|
||||
if (mgmt_ds_load_cfg_from_file(file_path, &iter) != 0) {
|
||||
MGMTD_DS_ERR("Failed to load config from the file %s",
|
||||
file_path);
|
||||
__log_err("Failed to load config from the file %s", file_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -451,7 +449,7 @@ int mgmt_ds_iter_data(Mgmtd__DatastoreId ds_id, struct nb_config *root,
|
||||
* Oper-state should be kept in mind though for the prefix walk
|
||||
*/
|
||||
|
||||
MGMTD_DS_DBG(" -- START DS walk for DSid: %d", ds_id);
|
||||
__dbg(" -- START DS walk for DSid: %d", ds_id);
|
||||
|
||||
/* If the base_xpath is empty then crawl the sibblings */
|
||||
if (xpath[0] == 0) {
|
||||
|
@ -23,9 +23,9 @@
|
||||
#include "mgmtd/mgmt_memory.h"
|
||||
#include "mgmtd/mgmt_fe_adapter.h"
|
||||
|
||||
#define MGMTD_FE_ADAPTER_DBG(fmt, ...) \
|
||||
#define __dbg(fmt, ...) \
|
||||
DEBUGD(&mgmt_debug_fe, "FE-ADAPTER: %s: " fmt, __func__, ##__VA_ARGS__)
|
||||
#define MGMTD_FE_ADAPTER_ERR(fmt, ...) \
|
||||
#define __log_err(fmt, ...) \
|
||||
zlog_err("FE-ADAPTER: %s: ERROR: " fmt, __func__, ##__VA_ARGS__)
|
||||
|
||||
#define FOREACH_ADAPTER_IN_LIST(adapter) \
|
||||
@ -78,20 +78,18 @@ mgmt_fe_session_write_lock_ds(Mgmtd__DatastoreId ds_id,
|
||||
session->session_id, mgmt_ds_id2name(ds_id));
|
||||
else {
|
||||
if (mgmt_ds_lock(ds_ctx, session->session_id)) {
|
||||
MGMTD_FE_ADAPTER_DBG(
|
||||
"Failed to lock the DS:%s for session-id: %" PRIu64
|
||||
" from %s!",
|
||||
mgmt_ds_id2name(ds_id), session->session_id,
|
||||
session->adapter->name);
|
||||
__dbg("Failed to lock the DS:%s for session-id: %" PRIu64
|
||||
" from %s!",
|
||||
mgmt_ds_id2name(ds_id), session->session_id,
|
||||
session->adapter->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
session->ds_locked[ds_id] = true;
|
||||
MGMTD_FE_ADAPTER_DBG(
|
||||
"Write-Locked the DS:%s for session-id: %" PRIu64
|
||||
" from %s",
|
||||
mgmt_ds_id2name(ds_id), session->session_id,
|
||||
session->adapter->name);
|
||||
__dbg("Write-Locked the DS:%s for session-id: %" PRIu64
|
||||
" from %s",
|
||||
mgmt_ds_id2name(ds_id), session->session_id,
|
||||
session->adapter->name);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -107,11 +105,10 @@ static void mgmt_fe_session_unlock_ds(Mgmtd__DatastoreId ds_id,
|
||||
|
||||
session->ds_locked[ds_id] = false;
|
||||
mgmt_ds_unlock(ds_ctx);
|
||||
MGMTD_FE_ADAPTER_DBG(
|
||||
"Unlocked DS:%s write-locked earlier by session-id: %" PRIu64
|
||||
" from %s",
|
||||
mgmt_ds_id2name(ds_id), session->session_id,
|
||||
session->adapter->name);
|
||||
__dbg("Unlocked DS:%s write-locked earlier by session-id: %" PRIu64
|
||||
" from %s",
|
||||
mgmt_ds_id2name(ds_id), session->session_id,
|
||||
session->adapter->name);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -206,14 +203,13 @@ mgmt_fe_find_session_by_client_id(struct mgmt_fe_client_adapter *adapter,
|
||||
|
||||
FOREACH_SESSION_IN_LIST (adapter, session) {
|
||||
if (session->client_id == client_id) {
|
||||
MGMTD_FE_ADAPTER_DBG("Found session-id %" PRIu64
|
||||
" using client-id %" PRIu64,
|
||||
session->session_id, client_id);
|
||||
__dbg("Found session-id %" PRIu64
|
||||
" using client-id %" PRIu64,
|
||||
session->session_id, client_id);
|
||||
return session;
|
||||
}
|
||||
}
|
||||
MGMTD_FE_ADAPTER_DBG("Session not found using client-id %" PRIu64,
|
||||
client_id);
|
||||
__dbg("Session not found using client-id %" PRIu64, client_id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -330,9 +326,8 @@ static int fe_adapter_send_session_reply(struct mgmt_fe_client_adapter *adapter,
|
||||
fe_msg.message_case = MGMTD__FE_MESSAGE__MESSAGE_SESSION_REPLY;
|
||||
fe_msg.session_reply = &session_reply;
|
||||
|
||||
MGMTD_FE_ADAPTER_DBG(
|
||||
"Sending SESSION_REPLY message to MGMTD Frontend client '%s'",
|
||||
adapter->name);
|
||||
__dbg("Sending SESSION_REPLY message to MGMTD Frontend client '%s'",
|
||||
adapter->name);
|
||||
|
||||
return fe_adapter_send_msg(adapter, &fe_msg, true);
|
||||
}
|
||||
@ -361,9 +356,8 @@ static int fe_adapter_send_lockds_reply(struct mgmt_fe_session_ctx *session,
|
||||
fe_msg.message_case = MGMTD__FE_MESSAGE__MESSAGE_LOCKDS_REPLY;
|
||||
fe_msg.lockds_reply = &lockds_reply;
|
||||
|
||||
MGMTD_FE_ADAPTER_DBG(
|
||||
"Sending LOCK_DS_REPLY message to MGMTD Frontend client '%s' scok: %d",
|
||||
session->adapter->name, scok);
|
||||
__dbg("Sending LOCK_DS_REPLY message to MGMTD Frontend client '%s' scok: %d",
|
||||
session->adapter->name, scok);
|
||||
|
||||
return fe_adapter_send_msg(session->adapter, &fe_msg, scok);
|
||||
}
|
||||
@ -396,9 +390,8 @@ static int fe_adapter_send_set_cfg_reply(struct mgmt_fe_session_ctx *session,
|
||||
fe_msg.message_case = MGMTD__FE_MESSAGE__MESSAGE_SETCFG_REPLY;
|
||||
fe_msg.setcfg_reply = &setcfg_reply;
|
||||
|
||||
MGMTD_FE_ADAPTER_DBG(
|
||||
"Sending SETCFG_REPLY message to MGMTD Frontend client '%s'",
|
||||
session->adapter->name);
|
||||
__dbg("Sending SETCFG_REPLY message to MGMTD Frontend client '%s'",
|
||||
session->adapter->name);
|
||||
|
||||
if (implicit_commit) {
|
||||
if (mm->perf_stats_en)
|
||||
@ -442,9 +435,8 @@ static int fe_adapter_send_commit_cfg_reply(
|
||||
fe_msg.message_case = MGMTD__FE_MESSAGE__MESSAGE_COMMCFG_REPLY;
|
||||
fe_msg.commcfg_reply = &commcfg_reply;
|
||||
|
||||
MGMTD_FE_ADAPTER_DBG(
|
||||
"Sending COMMIT_CONFIG_REPLY message to MGMTD Frontend client '%s'",
|
||||
session->adapter->name);
|
||||
__dbg("Sending COMMIT_CONFIG_REPLY message to MGMTD Frontend client '%s'",
|
||||
session->adapter->name);
|
||||
|
||||
/*
|
||||
* Cleanup the CONFIG transaction associated with this session.
|
||||
@ -484,8 +476,8 @@ static int fe_adapter_send_get_reply(struct mgmt_fe_session_ctx *session,
|
||||
fe_msg.message_case = MGMTD__FE_MESSAGE__MESSAGE_GET_REPLY;
|
||||
fe_msg.get_reply = &get_reply;
|
||||
|
||||
MGMTD_FE_ADAPTER_DBG("Sending GET_REPLY message to MGMTD Frontend client '%s'",
|
||||
session->adapter->name);
|
||||
__dbg("Sending GET_REPLY message to MGMTD Frontend client '%s'",
|
||||
session->adapter->name);
|
||||
|
||||
/*
|
||||
* Cleanup the SHOW transaction associated with this session.
|
||||
@ -572,7 +564,7 @@ mgmt_fe_find_adapter_by_fd(int conn_fd)
|
||||
static void mgmt_fe_adapter_delete(struct mgmt_fe_client_adapter *adapter)
|
||||
{
|
||||
struct mgmt_fe_session_ctx *session;
|
||||
MGMTD_FE_ADAPTER_DBG("deleting client adapter '%s'", adapter->name);
|
||||
__dbg("deleting client adapter '%s'", adapter->name);
|
||||
|
||||
/* TODO: notify about client disconnect for appropriate cleanup */
|
||||
FOREACH_SESSION_IN_LIST (adapter, session)
|
||||
@ -587,8 +579,7 @@ static int mgmt_fe_adapter_notify_disconnect(struct msg_conn *conn)
|
||||
{
|
||||
struct mgmt_fe_client_adapter *adapter = conn->user;
|
||||
|
||||
MGMTD_FE_ADAPTER_DBG("notify disconnect for client adapter '%s'",
|
||||
adapter->name);
|
||||
__dbg("notify disconnect for client adapter '%s'", adapter->name);
|
||||
|
||||
mgmt_fe_adapter_delete(adapter);
|
||||
|
||||
@ -609,10 +600,8 @@ mgmt_fe_adapter_cleanup_old_conn(struct mgmt_fe_client_adapter *adapter)
|
||||
if (strncmp(adapter->name, old->name, sizeof(adapter->name)))
|
||||
continue;
|
||||
|
||||
MGMTD_FE_ADAPTER_DBG(
|
||||
"Client '%s' (FD:%d) seems to have reconnected. Removing old connection (FD:%d)",
|
||||
adapter->name, adapter->conn->fd,
|
||||
old->conn->fd);
|
||||
__dbg("Client '%s' (FD:%d) seems to have reconnected. Removing old connection (FD:%d)",
|
||||
adapter->name, adapter->conn->fd, old->conn->fd);
|
||||
msg_conn_disconnect(old->conn, false);
|
||||
}
|
||||
}
|
||||
@ -665,11 +654,10 @@ mgmt_fe_session_handle_lockds_req_msg(struct mgmt_fe_session_ctx *session,
|
||||
if (fe_adapter_send_lockds_reply(session, lockds_req->ds_id,
|
||||
lockds_req->req_id, lockds_req->lock,
|
||||
true, NULL) != 0) {
|
||||
MGMTD_FE_ADAPTER_DBG(
|
||||
"Failed to send LOCK_DS_REPLY for DS %u session-id: %" PRIu64
|
||||
" from %s",
|
||||
lockds_req->ds_id, session->session_id,
|
||||
session->adapter->name);
|
||||
__dbg("Failed to send LOCK_DS_REPLY for DS %u session-id: %" PRIu64
|
||||
" from %s",
|
||||
lockds_req->ds_id, session->session_id,
|
||||
session->adapter->name);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -739,14 +727,13 @@ mgmt_fe_session_handle_setcfg_req_msg(struct mgmt_fe_session_ctx *session,
|
||||
}
|
||||
txn_created = true;
|
||||
|
||||
MGMTD_FE_ADAPTER_DBG("Created new Config txn-id: %" PRIu64
|
||||
" for session-id %" PRIu64,
|
||||
session->cfg_txn_id, session->session_id);
|
||||
__dbg("Created new Config txn-id: %" PRIu64
|
||||
" for session-id %" PRIu64,
|
||||
session->cfg_txn_id, session->session_id);
|
||||
} else {
|
||||
MGMTD_FE_ADAPTER_DBG("Config txn-id: %" PRIu64
|
||||
" for session-id: %" PRIu64
|
||||
" already created",
|
||||
session->cfg_txn_id, session->session_id);
|
||||
__dbg("Config txn-id: %" PRIu64 " for session-id: %" PRIu64
|
||||
" already created",
|
||||
session->cfg_txn_id, session->session_id);
|
||||
|
||||
if (setcfg_req->implicit_commit) {
|
||||
/*
|
||||
@ -811,15 +798,15 @@ static int mgmt_fe_session_handle_get_req_msg(struct mgmt_fe_session_ctx *sessio
|
||||
return -1;
|
||||
}
|
||||
|
||||
MGMTD_FE_ADAPTER_DBG("Created new show txn-id: %" PRIu64
|
||||
" for session-id: %" PRIu64,
|
||||
session->txn_id, session->session_id);
|
||||
__dbg("Created new show txn-id: %" PRIu64
|
||||
" for session-id: %" PRIu64,
|
||||
session->txn_id, session->session_id);
|
||||
} else {
|
||||
fe_adapter_send_get_reply(session, ds_id, req_id, false, NULL,
|
||||
"Request processing for GET failed!");
|
||||
MGMTD_FE_ADAPTER_DBG("Transaction in progress txn-id: %" PRIu64
|
||||
" for session-id: %" PRIu64,
|
||||
session->txn_id, session->session_id);
|
||||
__dbg("Transaction in progress txn-id: %" PRIu64
|
||||
" for session-id: %" PRIu64,
|
||||
session->txn_id, session->session_id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -906,10 +893,9 @@ static int mgmt_fe_session_handle_commit_config_req_msg(
|
||||
"Failed to create a Configuration session!");
|
||||
return 0;
|
||||
}
|
||||
MGMTD_FE_ADAPTER_DBG("Created txn-id: %" PRIu64
|
||||
" for session-id %" PRIu64
|
||||
" for COMMIT-CFG-REQ",
|
||||
session->cfg_txn_id, session->session_id);
|
||||
__dbg("Created txn-id: %" PRIu64 " for session-id %" PRIu64
|
||||
" for COMMIT-CFG-REQ",
|
||||
session->cfg_txn_id, session->session_id);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -943,8 +929,8 @@ mgmt_fe_adapter_handle_msg(struct mgmt_fe_client_adapter *adapter,
|
||||
*/
|
||||
switch ((int)fe_msg->message_case) {
|
||||
case MGMTD__FE_MESSAGE__MESSAGE_REGISTER_REQ:
|
||||
MGMTD_FE_ADAPTER_DBG("Got REGISTER_REQ from '%s'",
|
||||
fe_msg->register_req->client_name);
|
||||
__dbg("Got REGISTER_REQ from '%s'",
|
||||
fe_msg->register_req->client_name);
|
||||
|
||||
if (strlen(fe_msg->register_req->client_name)) {
|
||||
strlcpy(adapter->name,
|
||||
@ -957,11 +943,10 @@ mgmt_fe_adapter_handle_msg(struct mgmt_fe_client_adapter *adapter,
|
||||
if (fe_msg->session_req->create
|
||||
&& fe_msg->session_req->id_case
|
||||
== MGMTD__FE_SESSION_REQ__ID_CLIENT_CONN_ID) {
|
||||
MGMTD_FE_ADAPTER_DBG(
|
||||
"Got SESSION_REQ (create) for client-id %" PRIu64
|
||||
" from '%s'",
|
||||
fe_msg->session_req->client_conn_id,
|
||||
adapter->name);
|
||||
__dbg("Got SESSION_REQ (create) for client-id %" PRIu64
|
||||
" from '%s'",
|
||||
fe_msg->session_req->client_conn_id,
|
||||
adapter->name);
|
||||
|
||||
session = mgmt_fe_create_session(
|
||||
adapter, fe_msg->session_req->client_conn_id);
|
||||
@ -971,10 +956,9 @@ mgmt_fe_adapter_handle_msg(struct mgmt_fe_client_adapter *adapter,
|
||||
!fe_msg->session_req->create
|
||||
&& fe_msg->session_req->id_case
|
||||
== MGMTD__FE_SESSION_REQ__ID_SESSION_ID) {
|
||||
MGMTD_FE_ADAPTER_DBG(
|
||||
"Got SESSION_REQ (destroy) for session-id %" PRIu64
|
||||
"from '%s'",
|
||||
fe_msg->session_req->session_id, adapter->name);
|
||||
__dbg("Got SESSION_REQ (destroy) for session-id %" PRIu64
|
||||
"from '%s'",
|
||||
fe_msg->session_req->session_id, adapter->name);
|
||||
|
||||
session = mgmt_session_id2ctx(
|
||||
fe_msg->session_req->session_id);
|
||||
@ -986,12 +970,11 @@ mgmt_fe_adapter_handle_msg(struct mgmt_fe_client_adapter *adapter,
|
||||
case MGMTD__FE_MESSAGE__MESSAGE_LOCKDS_REQ:
|
||||
session = mgmt_session_id2ctx(
|
||||
fe_msg->lockds_req->session_id);
|
||||
MGMTD_FE_ADAPTER_DBG(
|
||||
"Got LOCKDS_REQ (%sLOCK) for DS:%s for session-id %" PRIu64
|
||||
" from '%s'",
|
||||
fe_msg->lockds_req->lock ? "" : "UN",
|
||||
mgmt_ds_id2name(fe_msg->lockds_req->ds_id),
|
||||
fe_msg->lockds_req->session_id, adapter->name);
|
||||
__dbg("Got LOCKDS_REQ (%sLOCK) for DS:%s for session-id %" PRIu64
|
||||
" from '%s'",
|
||||
fe_msg->lockds_req->lock ? "" : "UN",
|
||||
mgmt_ds_id2name(fe_msg->lockds_req->ds_id),
|
||||
fe_msg->lockds_req->session_id, adapter->name);
|
||||
mgmt_fe_session_handle_lockds_req_msg(
|
||||
session, fe_msg->lockds_req);
|
||||
break;
|
||||
@ -999,13 +982,12 @@ mgmt_fe_adapter_handle_msg(struct mgmt_fe_client_adapter *adapter,
|
||||
session = mgmt_session_id2ctx(
|
||||
fe_msg->setcfg_req->session_id);
|
||||
session->adapter->setcfg_stats.set_cfg_count++;
|
||||
MGMTD_FE_ADAPTER_DBG(
|
||||
"Got SETCFG_REQ (%d Xpaths, Implicit:%c) on DS:%s for session-id %" PRIu64
|
||||
" from '%s'",
|
||||
(int)fe_msg->setcfg_req->n_data,
|
||||
fe_msg->setcfg_req->implicit_commit ? 'T' : 'F',
|
||||
mgmt_ds_id2name(fe_msg->setcfg_req->ds_id),
|
||||
fe_msg->setcfg_req->session_id, adapter->name);
|
||||
__dbg("Got SETCFG_REQ (%d Xpaths, Implicit:%c) on DS:%s for session-id %" PRIu64
|
||||
" from '%s'",
|
||||
(int)fe_msg->setcfg_req->n_data,
|
||||
fe_msg->setcfg_req->implicit_commit ? 'T' : 'F',
|
||||
mgmt_ds_id2name(fe_msg->setcfg_req->ds_id),
|
||||
fe_msg->setcfg_req->session_id, adapter->name);
|
||||
|
||||
mgmt_fe_session_handle_setcfg_req_msg(
|
||||
session, fe_msg->setcfg_req);
|
||||
@ -1013,30 +995,28 @@ mgmt_fe_adapter_handle_msg(struct mgmt_fe_client_adapter *adapter,
|
||||
case MGMTD__FE_MESSAGE__MESSAGE_COMMCFG_REQ:
|
||||
session = mgmt_session_id2ctx(
|
||||
fe_msg->commcfg_req->session_id);
|
||||
MGMTD_FE_ADAPTER_DBG(
|
||||
"Got COMMCFG_REQ for src-DS:%s dst-DS:%s (Abort:%c) on session-id %" PRIu64
|
||||
" from '%s'",
|
||||
mgmt_ds_id2name(fe_msg->commcfg_req->src_ds_id),
|
||||
mgmt_ds_id2name(fe_msg->commcfg_req->dst_ds_id),
|
||||
fe_msg->commcfg_req->abort ? 'T' : 'F',
|
||||
fe_msg->commcfg_req->session_id, adapter->name);
|
||||
__dbg("Got COMMCFG_REQ for src-DS:%s dst-DS:%s (Abort:%c) on session-id %" PRIu64
|
||||
" from '%s'",
|
||||
mgmt_ds_id2name(fe_msg->commcfg_req->src_ds_id),
|
||||
mgmt_ds_id2name(fe_msg->commcfg_req->dst_ds_id),
|
||||
fe_msg->commcfg_req->abort ? 'T' : 'F',
|
||||
fe_msg->commcfg_req->session_id, adapter->name);
|
||||
mgmt_fe_session_handle_commit_config_req_msg(
|
||||
session, fe_msg->commcfg_req);
|
||||
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 for DS:%s (xpaths: %d) on session-id %" PRIu64
|
||||
" from '%s'",
|
||||
mgmt_ds_id2name(fe_msg->get_req->ds_id),
|
||||
(int)fe_msg->get_req->n_data,
|
||||
fe_msg->get_req->session_id, adapter->name);
|
||||
__dbg("Got GET_REQ for DS:%s (xpaths: %d) on session-id %" PRIu64
|
||||
" from '%s'",
|
||||
mgmt_ds_id2name(fe_msg->get_req->ds_id),
|
||||
(int)fe_msg->get_req->n_data, fe_msg->get_req->session_id,
|
||||
adapter->name);
|
||||
mgmt_fe_session_handle_get_req_msg(session, fe_msg->get_req);
|
||||
break;
|
||||
case MGMTD__FE_MESSAGE__MESSAGE_NOTIFY_DATA_REQ:
|
||||
case MGMTD__FE_MESSAGE__MESSAGE_REGNOTIFY_REQ:
|
||||
MGMTD_FE_ADAPTER_ERR(
|
||||
"Got unhandled message of type %u from '%s'",
|
||||
fe_msg->message_case, adapter->name);
|
||||
__log_err("Got unhandled message of type %u from '%s'",
|
||||
fe_msg->message_case, adapter->name);
|
||||
/*
|
||||
* TODO: Add handling code in future.
|
||||
*/
|
||||
@ -1101,19 +1081,17 @@ static int fe_adapter_send_tree_data(struct mgmt_fe_session_ctx *session,
|
||||
ret = yang_print_tree_append(darrp, tree, result_type,
|
||||
(wd_options | LYD_PRINT_WITHSIBLINGS));
|
||||
if (ret != LY_SUCCESS) {
|
||||
MGMTD_FE_ADAPTER_ERR("Error building get-tree result for client %s session-id %" PRIu64
|
||||
" req-id %" PRIu64
|
||||
" scok %d result type %u",
|
||||
session->adapter->name, session->session_id,
|
||||
req_id, short_circuit_ok, result_type);
|
||||
__log_err("Error building get-tree result for client %s session-id %" PRIu64
|
||||
" req-id %" PRIu64 " scok %d result type %u",
|
||||
session->adapter->name, session->session_id, req_id,
|
||||
short_circuit_ok, result_type);
|
||||
goto done;
|
||||
}
|
||||
|
||||
MGMTD_FE_ADAPTER_DBG("Sending get-tree result from adapter %s to session-id %" PRIu64
|
||||
" req-id %" PRIu64 " scok %d result type %u len %u",
|
||||
session->adapter->name, session->session_id,
|
||||
req_id, short_circuit_ok, result_type,
|
||||
mgmt_msg_native_get_msg_len(msg));
|
||||
__dbg("Sending get-tree result from adapter %s to session-id %" PRIu64
|
||||
" req-id %" PRIu64 " scok %d result type %u len %u",
|
||||
session->adapter->name, session->session_id, req_id,
|
||||
short_circuit_ok, result_type, mgmt_msg_native_get_msg_len(msg));
|
||||
|
||||
ret = fe_adapter_send_native_msg(session->adapter, msg,
|
||||
mgmt_msg_native_get_msg_len(msg),
|
||||
@ -1144,10 +1122,9 @@ static void fe_adapter_handle_get_data(struct mgmt_fe_session_ctx *session,
|
||||
LY_ERR err;
|
||||
int ret;
|
||||
|
||||
MGMTD_FE_ADAPTER_DBG("Received get-data request from client %s for session-id %" PRIu64
|
||||
" req-id %" PRIu64,
|
||||
session->adapter->name, session->session_id,
|
||||
msg->req_id);
|
||||
__dbg("Received get-data request from client %s for session-id %" PRIu64
|
||||
" req-id %" PRIu64,
|
||||
session->adapter->name, session->session_id, msg->req_id);
|
||||
|
||||
if (!MGMT_MSG_VALIDATE_NUL_TERM(msg, msg_len)) {
|
||||
fe_adapter_send_error(session, req_id, false, -EINVAL,
|
||||
@ -1214,10 +1191,9 @@ static void fe_adapter_handle_get_data(struct mgmt_fe_session_ctx *session,
|
||||
|
||||
clients = mgmt_be_interested_clients(msg->xpath, false);
|
||||
if (!clients && !CHECK_FLAG(msg->flags, GET_DATA_FLAG_CONFIG)) {
|
||||
MGMTD_FE_ADAPTER_DBG("No backends provide xpath: %s for txn-id: %" PRIu64
|
||||
" session-id: %" PRIu64,
|
||||
msg->xpath, session->txn_id,
|
||||
session->session_id);
|
||||
__dbg("No backends provide xpath: %s for txn-id: %" PRIu64
|
||||
" session-id: %" PRIu64,
|
||||
msg->xpath, session->txn_id, session->session_id);
|
||||
|
||||
fe_adapter_send_tree_data(session, req_id, false,
|
||||
msg->result_type, wd_options, NULL, 0);
|
||||
@ -1233,9 +1209,8 @@ static void fe_adapter_handle_get_data(struct mgmt_fe_session_ctx *session,
|
||||
goto done;
|
||||
}
|
||||
|
||||
MGMTD_FE_ADAPTER_DBG("Created new show txn-id: %" PRIu64
|
||||
" for session-id: %" PRIu64,
|
||||
session->txn_id, session->session_id);
|
||||
__dbg("Created new show txn-id: %" PRIu64 " for session-id: %" PRIu64,
|
||||
session->txn_id, session->session_id);
|
||||
|
||||
/* Create a GET-TREE request under the transaction */
|
||||
ret = mgmt_txn_send_get_tree_oper(session->txn_id, req_id, clients,
|
||||
@ -1263,8 +1238,8 @@ static void fe_adapter_handle_native_msg(struct mgmt_fe_client_adapter *adapter,
|
||||
|
||||
session = mgmt_session_id2ctx(msg->refer_id);
|
||||
if (!session) {
|
||||
MGMTD_FE_ADAPTER_ERR("adapter %s: recv msg unknown session-id %" PRIu64,
|
||||
adapter->name, msg->refer_id);
|
||||
__log_err("adapter %s: recv msg unknown session-id %" PRIu64,
|
||||
adapter->name, msg->refer_id);
|
||||
return;
|
||||
}
|
||||
assert(session->adapter == adapter);
|
||||
@ -1274,11 +1249,9 @@ static void fe_adapter_handle_native_msg(struct mgmt_fe_client_adapter *adapter,
|
||||
fe_adapter_handle_get_data(session, msg, msg_len);
|
||||
break;
|
||||
default:
|
||||
MGMTD_FE_ADAPTER_ERR("unknown native message session-id %" PRIu64
|
||||
" req-id %" PRIu64
|
||||
" code %u to FE adapter %s",
|
||||
msg->refer_id, msg->req_id, msg->code,
|
||||
adapter->name);
|
||||
__log_err("unknown native message session-id %" PRIu64
|
||||
" req-id %" PRIu64 " code %u to FE adapter %s",
|
||||
msg->refer_id, msg->req_id, msg->code, adapter->name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1296,21 +1269,19 @@ static void mgmt_fe_adapter_process_msg(uint8_t version, uint8_t *data,
|
||||
if (len >= sizeof(*msg))
|
||||
fe_adapter_handle_native_msg(adapter, msg, len);
|
||||
else
|
||||
MGMTD_FE_ADAPTER_ERR("native message to adapter %s too short %zu",
|
||||
adapter->name, len);
|
||||
__log_err("native message to adapter %s too short %zu",
|
||||
adapter->name, len);
|
||||
return;
|
||||
}
|
||||
|
||||
fe_msg = mgmtd__fe_message__unpack(NULL, len, data);
|
||||
if (!fe_msg) {
|
||||
MGMTD_FE_ADAPTER_DBG(
|
||||
"Failed to decode %zu bytes for adapter: %s", len,
|
||||
adapter->name);
|
||||
__dbg("Failed to decode %zu bytes for adapter: %s", len,
|
||||
adapter->name);
|
||||
return;
|
||||
}
|
||||
MGMTD_FE_ADAPTER_DBG(
|
||||
"Decoded %zu bytes of message: %u from adapter: %s", len,
|
||||
fe_msg->message_case, adapter->name);
|
||||
__dbg("Decoded %zu bytes of message: %u from adapter: %s", len,
|
||||
fe_msg->message_case, adapter->name);
|
||||
(void)mgmt_fe_adapter_handle_msg(adapter, fe_msg);
|
||||
mgmtd__fe_message__free_unpacked(fe_msg, NULL);
|
||||
}
|
||||
@ -1380,11 +1351,10 @@ static void mgmt_fe_abort_if_session(void *data)
|
||||
{
|
||||
struct mgmt_fe_session_ctx *session = data;
|
||||
|
||||
MGMTD_FE_ADAPTER_ERR("found orphaned session id %" PRIu64
|
||||
" client id %" PRIu64 " adapter %s",
|
||||
session->session_id, session->client_id,
|
||||
session->adapter ? session->adapter->name
|
||||
: "NULL");
|
||||
__log_err("found orphaned session id %" PRIu64 " client id %" PRIu64
|
||||
" adapter %s",
|
||||
session->session_id, session->client_id,
|
||||
session->adapter ? session->adapter->name : "NULL");
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -1433,8 +1403,7 @@ struct msg_conn *mgmt_fe_create_adapter(int conn_fd, union sockunion *from)
|
||||
|
||||
adapter->setcfg_stats.min_tm = ULONG_MAX;
|
||||
adapter->cmt_stats.min_tm = ULONG_MAX;
|
||||
MGMTD_FE_ADAPTER_DBG("Added new MGMTD Frontend adapter '%s'",
|
||||
adapter->name);
|
||||
__dbg("Added new MGMTD Frontend adapter '%s'", adapter->name);
|
||||
}
|
||||
return adapter->conn;
|
||||
}
|
||||
@ -1450,10 +1419,9 @@ int mgmt_fe_send_set_cfg_reply(uint64_t session_id, uint64_t txn_id,
|
||||
session = mgmt_session_id2ctx(session_id);
|
||||
if (!session || session->cfg_txn_id != txn_id) {
|
||||
if (session)
|
||||
MGMTD_FE_ADAPTER_ERR(
|
||||
"txn-id doesn't match, session txn-id is %" PRIu64
|
||||
" current txnid: %" PRIu64,
|
||||
session->cfg_txn_id, txn_id);
|
||||
__log_err("txn-id doesn't match, session txn-id is %" PRIu64
|
||||
" current txnid: %" PRIu64,
|
||||
session->cfg_txn_id, txn_id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1531,9 +1499,9 @@ int mgmt_fe_adapter_txn_error(uint64_t txn_id, uint64_t req_id,
|
||||
|
||||
session = fe_adapter_session_by_txn_id(txn_id);
|
||||
if (!session) {
|
||||
MGMTD_FE_ADAPTER_ERR("failed sending error for txn-id %" PRIu64
|
||||
" session not found",
|
||||
txn_id);
|
||||
__log_err("failed sending error for txn-id %" PRIu64
|
||||
" session not found",
|
||||
txn_id);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
|
361
mgmtd/mgmt_txn.c
361
mgmtd/mgmt_txn.c
@ -17,10 +17,9 @@
|
||||
#include "mgmtd/mgmt_memory.h"
|
||||
#include "mgmtd/mgmt_txn.h"
|
||||
|
||||
#define MGMTD_TXN_DBG(fmt, ...) \
|
||||
#define __dbg(fmt, ...) \
|
||||
DEBUGD(&mgmt_debug_txn, "TXN: %s: " fmt, __func__, ##__VA_ARGS__)
|
||||
#define MGMTD_TXN_ERR(fmt, ...) \
|
||||
zlog_err("%s: ERROR: " fmt, __func__, ##__VA_ARGS__)
|
||||
#define __log_err(fmt, ...) zlog_err("%s: ERROR: " fmt, __func__, ##__VA_ARGS__)
|
||||
|
||||
#define MGMTD_TXN_LOCK(txn) mgmt_txn_lock(txn, __FILE__, __LINE__)
|
||||
#define MGMTD_TXN_UNLOCK(txn) mgmt_txn_unlock(txn, __FILE__, __LINE__)
|
||||
@ -315,7 +314,7 @@ static void mgmt_txn_cfg_batch_free(struct mgmt_txn_be_cfg_batch **batch)
|
||||
size_t indx;
|
||||
struct mgmt_commit_cfg_req *cmtcfg_req;
|
||||
|
||||
MGMTD_TXN_DBG(" freeing batch txn-id %" PRIu64, (*batch)->txn->txn_id);
|
||||
__dbg(" freeing batch txn-id %" PRIu64, (*batch)->txn->txn_id);
|
||||
|
||||
assert((*batch)->txn && (*batch)->txn->type == MGMTD_TXN_TYPE_CONFIG);
|
||||
|
||||
@ -372,15 +371,15 @@ static struct mgmt_txn_req *mgmt_txn_req_alloc(struct mgmt_txn_ctx *txn,
|
||||
sizeof(struct mgmt_set_cfg_req));
|
||||
assert(txn_req->req.set_cfg);
|
||||
mgmt_txn_reqs_add_tail(&txn->set_cfg_reqs, txn_req);
|
||||
MGMTD_TXN_DBG("Added a new SETCFG req-id: %" PRIu64
|
||||
" txn-id: %" PRIu64 ", session-id: %" PRIu64,
|
||||
txn_req->req_id, txn->txn_id, txn->session_id);
|
||||
__dbg("Added a new SETCFG req-id: %" PRIu64 " txn-id: %" PRIu64
|
||||
", session-id: %" PRIu64,
|
||||
txn_req->req_id, txn->txn_id, txn->session_id);
|
||||
break;
|
||||
case MGMTD_TXN_PROC_COMMITCFG:
|
||||
txn->commit_cfg_req = txn_req;
|
||||
MGMTD_TXN_DBG("Added a new COMMITCFG req-id: %" PRIu64
|
||||
" txn-id: %" PRIu64 " session-id: %" PRIu64,
|
||||
txn_req->req_id, txn->txn_id, txn->session_id);
|
||||
__dbg("Added a new COMMITCFG req-id: %" PRIu64
|
||||
" txn-id: %" PRIu64 " session-id: %" PRIu64,
|
||||
txn_req->req_id, txn->txn_id, txn->session_id);
|
||||
|
||||
FOREACH_MGMTD_BE_CLIENT_ID (id) {
|
||||
txn_req->req.commit_cfg.be_phase[id] =
|
||||
@ -397,17 +396,17 @@ static struct mgmt_txn_req *mgmt_txn_req_alloc(struct mgmt_txn_ctx *txn,
|
||||
sizeof(struct mgmt_get_data_req));
|
||||
assert(txn_req->req.get_data);
|
||||
mgmt_txn_reqs_add_tail(&txn->get_cfg_reqs, txn_req);
|
||||
MGMTD_TXN_DBG("Added a new GETCFG req-id: %" PRIu64
|
||||
" txn-id: %" PRIu64 " session-id: %" PRIu64,
|
||||
txn_req->req_id, txn->txn_id, txn->session_id);
|
||||
__dbg("Added a new GETCFG 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));
|
||||
mgmt_txn_reqs_add_tail(&txn->get_tree_reqs, txn_req);
|
||||
MGMTD_TXN_DBG("Added a new GETTREE req-id: %" PRIu64
|
||||
" txn-id: %" PRIu64 " session-id: %" PRIu64,
|
||||
txn_req->req_id, txn->txn_id, txn->session_id);
|
||||
__dbg("Added a new GETTREE req-id: %" PRIu64 " txn-id: %" PRIu64
|
||||
" session-id: %" PRIu64,
|
||||
txn_req->req_id, txn->txn_id, txn->session_id);
|
||||
break;
|
||||
case MGMTD_TXN_COMMITCFG_TIMEOUT:
|
||||
case MGMTD_TXN_GETTREE_TIMEOUT:
|
||||
@ -426,41 +425,24 @@ static void mgmt_txn_req_free(struct mgmt_txn_req **txn_req)
|
||||
enum mgmt_be_client_id id;
|
||||
struct mgmt_be_client_adapter *adapter;
|
||||
struct mgmt_commit_cfg_req *ccreq;
|
||||
struct mgmt_set_cfg_req *set_cfg;
|
||||
bool cleanup;
|
||||
|
||||
switch ((*txn_req)->req_event) {
|
||||
case MGMTD_TXN_PROC_SETCFG:
|
||||
for (indx = 0; indx < (*txn_req)->req.set_cfg->num_cfg_changes;
|
||||
indx++) {
|
||||
if ((*txn_req)->req.set_cfg->cfg_changes[indx].value) {
|
||||
MGMTD_TXN_DBG("Freeing value for %s at %p ==> '%s'",
|
||||
(*txn_req)
|
||||
->req.set_cfg
|
||||
->cfg_changes[indx]
|
||||
.xpath,
|
||||
(*txn_req)
|
||||
->req.set_cfg
|
||||
->cfg_changes[indx]
|
||||
.value,
|
||||
(*txn_req)
|
||||
->req.set_cfg
|
||||
->cfg_changes[indx]
|
||||
.value);
|
||||
free((void *)(*txn_req)
|
||||
->req.set_cfg->cfg_changes[indx]
|
||||
.value);
|
||||
}
|
||||
set_cfg = (*txn_req)->req.set_cfg;
|
||||
for (indx = 0; indx < set_cfg->num_cfg_changes; indx++) {
|
||||
if (set_cfg->cfg_changes[indx].value)
|
||||
free((void *)set_cfg->cfg_changes[indx].value);
|
||||
}
|
||||
req_list = &(*txn_req)->txn->set_cfg_reqs;
|
||||
MGMTD_TXN_DBG("Deleting SETCFG req-id: %" PRIu64
|
||||
" txn-id: %" PRIu64,
|
||||
(*txn_req)->req_id, (*txn_req)->txn->txn_id);
|
||||
__dbg("Deleting SETCFG req-id: %" PRIu64 " txn-id: %" PRIu64,
|
||||
(*txn_req)->req_id, (*txn_req)->txn->txn_id);
|
||||
XFREE(MTYPE_MGMTD_TXN_SETCFG_REQ, (*txn_req)->req.set_cfg);
|
||||
break;
|
||||
case MGMTD_TXN_PROC_COMMITCFG:
|
||||
MGMTD_TXN_DBG("Deleting COMMITCFG req-id: %" PRIu64
|
||||
" txn-id: %" PRIu64,
|
||||
(*txn_req)->req_id, (*txn_req)->txn->txn_id);
|
||||
__dbg("Deleting COMMITCFG req-id: %" PRIu64 " txn-id: %" PRIu64,
|
||||
(*txn_req)->req_id, (*txn_req)->txn->txn_id);
|
||||
|
||||
ccreq = &(*txn_req)->req.commit_cfg;
|
||||
cleanup = (ccreq->phase >= MGMTD_COMMIT_PHASE_TXN_CREATE &&
|
||||
@ -496,9 +478,8 @@ static void mgmt_txn_req_free(struct mgmt_txn_req **txn_req)
|
||||
->req.get_data->xpaths[indx]);
|
||||
}
|
||||
req_list = &(*txn_req)->txn->get_cfg_reqs;
|
||||
MGMTD_TXN_DBG("Deleting GETCFG req-id: %" PRIu64
|
||||
" txn-id: %" PRIu64,
|
||||
(*txn_req)->req_id, (*txn_req)->txn->txn_id);
|
||||
__dbg("Deleting GETCFG 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);
|
||||
@ -509,9 +490,8 @@ 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_GETTREE:
|
||||
MGMTD_TXN_DBG("Deleting GETTREE req-id: %" PRIu64
|
||||
" of txn-id: %" PRIu64,
|
||||
(*txn_req)->req_id, (*txn_req)->txn->txn_id);
|
||||
__dbg("Deleting GETTREE req-id: %" PRIu64 " of txn-id: %" PRIu64,
|
||||
(*txn_req)->req_id, (*txn_req)->txn->txn_id);
|
||||
req_list = &(*txn_req)->txn->get_tree_reqs;
|
||||
lyd_free_all((*txn_req)->req.get_tree->client_results);
|
||||
XFREE(MTYPE_MGMTD_XPATH, (*txn_req)->req.get_tree->xpath);
|
||||
@ -524,9 +504,8 @@ static void mgmt_txn_req_free(struct mgmt_txn_req **txn_req)
|
||||
|
||||
if (req_list) {
|
||||
mgmt_txn_reqs_del(req_list, *txn_req);
|
||||
MGMTD_TXN_DBG("Removed req-id: %" PRIu64
|
||||
" from request-list (left:%zu)",
|
||||
(*txn_req)->req_id, mgmt_txn_reqs_count(req_list));
|
||||
__dbg("Removed req-id: %" PRIu64 " from request-list (left:%zu)",
|
||||
(*txn_req)->req_id, mgmt_txn_reqs_count(req_list));
|
||||
}
|
||||
|
||||
MGMTD_TXN_UNLOCK(&(*txn_req)->txn);
|
||||
@ -551,10 +530,10 @@ static void mgmt_txn_process_set_cfg(struct event *thread)
|
||||
assert(txn);
|
||||
cmt_stats = mgmt_fe_get_session_commit_stats(txn->session_id);
|
||||
|
||||
MGMTD_TXN_DBG("Processing %zu SET_CONFIG requests txn-id:%" PRIu64
|
||||
" session-id: %" PRIu64,
|
||||
mgmt_txn_reqs_count(&txn->set_cfg_reqs), txn->txn_id,
|
||||
txn->session_id);
|
||||
__dbg("Processing %zu SET_CONFIG requests txn-id:%" PRIu64
|
||||
" session-id: %" PRIu64,
|
||||
mgmt_txn_reqs_count(&txn->set_cfg_reqs), txn->txn_id,
|
||||
txn->session_id);
|
||||
|
||||
FOREACH_TXN_REQ_IN_LIST (&txn->set_cfg_reqs, txn_req) {
|
||||
assert(txn_req->req_event == MGMTD_TXN_PROC_SETCFG);
|
||||
@ -606,11 +585,11 @@ static void mgmt_txn_process_set_cfg(struct event *thread)
|
||||
/* We expect the user to have locked the DST DS */
|
||||
if (!mgmt_ds_is_locked(txn_req->req.set_cfg->dst_ds_ctx,
|
||||
txn->session_id)) {
|
||||
MGMTD_TXN_ERR("DS %u not locked for implicit commit txn-id: %" PRIu64
|
||||
" session-id: %" PRIu64 " err: %s",
|
||||
txn_req->req.set_cfg->dst_ds_id,
|
||||
txn->txn_id, txn->session_id,
|
||||
strerror(ret));
|
||||
__log_err("DS %u not locked for implicit commit txn-id: %" PRIu64
|
||||
" session-id: %" PRIu64 " err: %s",
|
||||
txn_req->req.set_cfg->dst_ds_id,
|
||||
txn->txn_id, txn->session_id,
|
||||
strerror(ret));
|
||||
mgmt_fe_send_set_cfg_reply(
|
||||
txn->session_id, txn->txn_id,
|
||||
txn_req->req.set_cfg->ds_id,
|
||||
@ -641,9 +620,9 @@ static void mgmt_txn_process_set_cfg(struct event *thread)
|
||||
txn_req->req_id,
|
||||
MGMTD_SUCCESS, NULL,
|
||||
false) != 0) {
|
||||
MGMTD_TXN_ERR("Failed to send SET_CONFIG_REPLY txn-id %" PRIu64
|
||||
" session-id: %" PRIu64,
|
||||
txn->txn_id, txn->session_id);
|
||||
__log_err("Failed to send SET_CONFIG_REPLY txn-id %" PRIu64
|
||||
" session-id: %" PRIu64,
|
||||
txn->txn_id, txn->session_id);
|
||||
}
|
||||
|
||||
mgmt_txn_process_set_cfg_done:
|
||||
@ -660,9 +639,8 @@ mgmt_txn_process_set_cfg_done:
|
||||
|
||||
left = mgmt_txn_reqs_count(&txn->set_cfg_reqs);
|
||||
if (left) {
|
||||
MGMTD_TXN_DBG("Processed maximum number of Set-Config requests (%d/%d/%d). Rescheduling for rest.",
|
||||
num_processed, MGMTD_TXN_MAX_NUM_SETCFG_PROC,
|
||||
(int)left);
|
||||
__dbg("Processed maximum number of Set-Config requests (%d/%d/%d). Rescheduling for rest.",
|
||||
num_processed, MGMTD_TXN_MAX_NUM_SETCFG_PROC, (int)left);
|
||||
mgmt_txn_register_event(txn, MGMTD_TXN_PROC_SETCFG);
|
||||
}
|
||||
}
|
||||
@ -693,9 +671,9 @@ static int mgmt_txn_send_commit_cfg_reply(struct mgmt_txn_ctx *txn,
|
||||
txn->commit_cfg_req->req.commit_cfg
|
||||
.validate_only,
|
||||
result, error_if_any) != 0) {
|
||||
MGMTD_TXN_ERR("Failed to send COMMIT-CONFIG-REPLY txn-id: %" PRIu64
|
||||
" session-id: %" PRIu64,
|
||||
txn->txn_id, txn->session_id);
|
||||
__log_err("Failed to send COMMIT-CONFIG-REPLY txn-id: %" PRIu64
|
||||
" session-id: %" PRIu64,
|
||||
txn->txn_id, txn->session_id);
|
||||
}
|
||||
|
||||
if (txn->commit_cfg_req->req.commit_cfg.implicit && txn->session_id &&
|
||||
@ -707,9 +685,9 @@ static int mgmt_txn_send_commit_cfg_reply(struct mgmt_txn_ctx *txn,
|
||||
success ? MGMTD_SUCCESS
|
||||
: MGMTD_INTERNAL_ERROR,
|
||||
error_if_any, true) != 0) {
|
||||
MGMTD_TXN_ERR("Failed to send SET-CONFIG-REPLY txn-id: %" PRIu64
|
||||
" session-id: %" PRIu64,
|
||||
txn->txn_id, txn->session_id);
|
||||
__log_err("Failed to send SET-CONFIG-REPLY txn-id: %" PRIu64
|
||||
" session-id: %" PRIu64,
|
||||
txn->txn_id, txn->session_id);
|
||||
}
|
||||
|
||||
if (success) {
|
||||
@ -792,8 +770,8 @@ mgmt_try_move_commit_to_next_phase(struct mgmt_txn_ctx *txn,
|
||||
{
|
||||
enum mgmt_be_client_id id;
|
||||
|
||||
MGMTD_TXN_DBG("txn-id: %" PRIu64 ", Phase '%s'",
|
||||
txn->txn_id, mgmt_txn_commit_phase_str(txn));
|
||||
__dbg("txn-id: %" PRIu64 ", Phase '%s'", txn->txn_id,
|
||||
mgmt_txn_commit_phase_str(txn));
|
||||
|
||||
/*
|
||||
* Check if all clients has moved to next phase or not.
|
||||
@ -819,8 +797,8 @@ mgmt_try_move_commit_to_next_phase(struct mgmt_txn_ctx *txn,
|
||||
*/
|
||||
cmtcfg_req->phase++;
|
||||
|
||||
MGMTD_TXN_DBG("Move entire txn-id: %" PRIu64 " to phase '%s'",
|
||||
txn->txn_id, mgmt_txn_commit_phase_str(txn));
|
||||
__dbg("Move entire txn-id: %" PRIu64 " to phase '%s'", txn->txn_id,
|
||||
mgmt_txn_commit_phase_str(txn));
|
||||
|
||||
mgmt_txn_register_event(txn, MGMTD_TXN_PROC_COMMITCFG);
|
||||
|
||||
@ -867,8 +845,7 @@ static int mgmt_txn_create_config_batches(struct mgmt_txn_req *txn_req,
|
||||
if (!value)
|
||||
value = (char *)MGMTD_BE_CONTAINER_NODE_VAL;
|
||||
|
||||
MGMTD_TXN_DBG("XPATH: %s, Value: '%s'", xpath,
|
||||
value ? value : "NIL");
|
||||
__dbg("XPATH: %s, Value: '%s'", xpath, value ? value : "NIL");
|
||||
|
||||
clients = mgmt_be_interested_clients(xpath, true);
|
||||
|
||||
@ -926,8 +903,8 @@ static int mgmt_txn_create_config_batches(struct mgmt_txn_req *txn_req,
|
||||
batch->value[batch->num_cfg_data].encoded_str_val =
|
||||
value;
|
||||
|
||||
MGMTD_TXN_DBG(" -- %s, batch item:%d", adapter->name,
|
||||
(int)batch->num_cfg_data);
|
||||
__dbg(" -- %s, batch item:%d", adapter->name,
|
||||
(int)batch->num_cfg_data);
|
||||
|
||||
batch->num_cfg_data++;
|
||||
num_chgs++;
|
||||
@ -937,7 +914,7 @@ static int mgmt_txn_create_config_batches(struct mgmt_txn_req *txn_req,
|
||||
snprintf(err_buf, sizeof(err_buf),
|
||||
"No validator module found for XPATH: '%s",
|
||||
xpath);
|
||||
MGMTD_TXN_ERR("***** %s", err_buf);
|
||||
__log_err("***** %s", err_buf);
|
||||
}
|
||||
|
||||
cmtcfg_req->clients |= chg_clients;
|
||||
@ -1158,10 +1135,8 @@ static int mgmt_txn_send_be_txn_create(struct mgmt_txn_ctx *txn)
|
||||
* come back.
|
||||
*/
|
||||
|
||||
MGMTD_TXN_DBG("txn-id: %" PRIu64 " session-id: %" PRIu64
|
||||
" Phase '%s'",
|
||||
txn->txn_id, txn->session_id,
|
||||
mgmt_txn_commit_phase_str(txn));
|
||||
__dbg("txn-id: %" PRIu64 " session-id: %" PRIu64 " Phase '%s'",
|
||||
txn->txn_id, txn->session_id, mgmt_txn_commit_phase_str(txn));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1194,8 +1169,9 @@ static int mgmt_txn_send_be_cfg_data(struct mgmt_txn_ctx *txn,
|
||||
(void)mgmt_txn_send_commit_cfg_reply(
|
||||
txn, MGMTD_INTERNAL_ERROR,
|
||||
"Internal Error! Could not send config data to backend!");
|
||||
MGMTD_TXN_ERR("Could not send CFGDATA_CREATE txn-id: %" PRIu64
|
||||
" to client '%s", txn->txn_id, adapter->name);
|
||||
__log_err("Could not send CFGDATA_CREATE txn-id: %" PRIu64
|
||||
" to client '%s",
|
||||
txn->txn_id, adapter->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1239,8 +1215,8 @@ static void mgmt_txn_cfg_commit_timedout(struct event *thread)
|
||||
if (!txn->commit_cfg_req)
|
||||
return;
|
||||
|
||||
MGMTD_TXN_ERR("Backend timeout txn-id: %" PRIu64 " aborting commit",
|
||||
txn->txn_id);
|
||||
__log_err("Backend timeout txn-id: %" PRIu64 " aborting commit",
|
||||
txn->txn_id);
|
||||
|
||||
/*
|
||||
* Send a COMMIT_CONFIG_REPLY with failure.
|
||||
@ -1292,9 +1268,9 @@ static int txn_get_tree_data_done(struct mgmt_txn_ctx *txn,
|
||||
mgmt_txn_req_free(&txn_req);
|
||||
|
||||
if (ret) {
|
||||
MGMTD_TXN_ERR("Error sending the results of GETTREE for txn-id %" PRIu64
|
||||
" req_id %" PRIu64 " to requested type %u",
|
||||
txn->txn_id, req_id, get_tree->result_type);
|
||||
__log_err("Error sending the results of GETTREE for txn-id %" PRIu64
|
||||
" req_id %" PRIu64 " to requested type %u",
|
||||
txn->txn_id, req_id, get_tree->result_type);
|
||||
|
||||
(void)mgmt_fe_adapter_txn_error(txn->txn_id, req_id, false, ret,
|
||||
"Error converting results of GETTREE");
|
||||
@ -1316,8 +1292,8 @@ static void txn_get_tree_timeout(struct event *thread)
|
||||
assert(txn->type == MGMTD_TXN_TYPE_SHOW);
|
||||
|
||||
|
||||
MGMTD_TXN_ERR("Backend timeout txn-id: %" PRIu64 " ending get-tree",
|
||||
txn->txn_id);
|
||||
__log_err("Backend timeout txn-id: %" PRIu64 " ending get-tree",
|
||||
txn->txn_id);
|
||||
|
||||
/*
|
||||
* Send a get-tree data reply.
|
||||
@ -1390,10 +1366,9 @@ static void mgmt_txn_process_commit_cfg(struct event *thread)
|
||||
txn = (struct mgmt_txn_ctx *)EVENT_ARG(thread);
|
||||
assert(txn);
|
||||
|
||||
MGMTD_TXN_DBG("Processing COMMIT_CONFIG for txn-id: %" PRIu64
|
||||
" session-id: %" PRIu64 " Phase '%s'",
|
||||
txn->txn_id, txn->session_id,
|
||||
mgmt_txn_commit_phase_str(txn));
|
||||
__dbg("Processing COMMIT_CONFIG for txn-id: %" PRIu64
|
||||
" session-id: %" PRIu64 " Phase '%s'",
|
||||
txn->txn_id, txn->session_id, mgmt_txn_commit_phase_str(txn));
|
||||
|
||||
assert(txn->commit_cfg_req);
|
||||
cmtcfg_req = &txn->commit_cfg_req->req.commit_cfg;
|
||||
@ -1419,13 +1394,13 @@ static void mgmt_txn_process_commit_cfg(struct event *thread)
|
||||
* Backend by now.
|
||||
*/
|
||||
#ifndef MGMTD_LOCAL_VALIDATIONS_ENABLED
|
||||
MGMTD_TXN_DBG("txn-id: %" PRIu64 " session-id: %" PRIu64
|
||||
" trigger sending CFG_VALIDATE_REQ to all backend clients",
|
||||
txn->txn_id, txn->session_id);
|
||||
__dbg("txn-id: %" PRIu64 " session-id: %" PRIu64
|
||||
" trigger sending CFG_VALIDATE_REQ to all backend clients",
|
||||
txn->txn_id, txn->session_id);
|
||||
#else /* ifndef MGMTD_LOCAL_VALIDATIONS_ENABLED */
|
||||
MGMTD_TXN_DBG("txn-id: %" PRIu64 " session-id: %" PRIu64
|
||||
" trigger sending CFG_APPLY_REQ to all backend clients",
|
||||
txn->txn_id, txn->session_id);
|
||||
__dbg("txn-id: %" PRIu64 " session-id: %" PRIu64
|
||||
" trigger sending CFG_APPLY_REQ to all backend clients",
|
||||
txn->txn_id, txn->session_id);
|
||||
#endif /* ifndef MGMTD_LOCAL_VALIDATIONS_ENABLED */
|
||||
break;
|
||||
case MGMTD_COMMIT_PHASE_APPLY_CFG:
|
||||
@ -1514,8 +1489,8 @@ static void mgmt_txn_send_getcfg_reply_data(struct mgmt_txn_req *txn_req,
|
||||
data_reply->next_indx = (!get_reply->last_batch ? get_req->total_reply
|
||||
: -1);
|
||||
|
||||
MGMTD_TXN_DBG("Sending %zu Get-Config/Data replies next-index:%" PRId64,
|
||||
data_reply->n_data, data_reply->next_indx);
|
||||
__dbg("Sending %zu Get-Config/Data replies next-index:%" PRId64,
|
||||
data_reply->n_data, data_reply->next_indx);
|
||||
|
||||
switch (txn_req->req_event) {
|
||||
case MGMTD_TXN_PROC_GETCFG:
|
||||
@ -1523,11 +1498,10 @@ static void mgmt_txn_send_getcfg_reply_data(struct mgmt_txn_req *txn_req,
|
||||
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-CONFIG-REPLY txn-id: %" PRIu64
|
||||
" session-id: %" PRIu64
|
||||
" req-id: %" PRIu64,
|
||||
txn_req->txn->txn_id,
|
||||
txn_req->txn->session_id, txn_req->req_id);
|
||||
__log_err("Failed to send GET-CONFIG-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:
|
||||
@ -1535,7 +1509,7 @@ static void mgmt_txn_send_getcfg_reply_data(struct mgmt_txn_req *txn_req,
|
||||
case MGMTD_TXN_PROC_GETTREE:
|
||||
case MGMTD_TXN_GETTREE_TIMEOUT:
|
||||
case MGMTD_TXN_COMMITCFG_TIMEOUT:
|
||||
MGMTD_TXN_ERR("Invalid Txn-Req-Event %u", txn_req->req_event);
|
||||
__log_err("Invalid Txn-Req-Event %u", txn_req->req_event);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1578,8 +1552,8 @@ static void txn_iter_get_config_data_cb(const char *xpath, struct lyd_node *node
|
||||
|
||||
get_reply->num_reply++;
|
||||
get_req->total_reply++;
|
||||
MGMTD_TXN_DBG(" [%d] XPATH: '%s', Value: '%s'", get_req->total_reply,
|
||||
data->xpath, data_value->encoded_str_val);
|
||||
__dbg(" [%d] XPATH: '%s', Value: '%s'", get_req->total_reply,
|
||||
data->xpath, data_value->encoded_str_val);
|
||||
|
||||
if (get_reply->num_reply == MGMTD_MAX_NUM_DATA_REPLY_IN_BATCH)
|
||||
mgmt_txn_send_getcfg_reply_data(txn_req, get_req);
|
||||
@ -1613,8 +1587,8 @@ static int mgmt_txn_get_config(struct mgmt_txn_ctx *txn,
|
||||
*/
|
||||
get_reply = get_data->reply;
|
||||
for (indx = 0; indx < get_data->num_xpaths; indx++) {
|
||||
MGMTD_TXN_DBG("Trying to get all data under '%s'",
|
||||
get_data->xpaths[indx]);
|
||||
__dbg("Trying to get all data under '%s'",
|
||||
get_data->xpaths[indx]);
|
||||
mgmt_init_get_data_reply(get_reply);
|
||||
/*
|
||||
* mgmt_ds_iter_data works on path prefixes, but the user may
|
||||
@ -1625,16 +1599,15 @@ static int mgmt_txn_get_config(struct mgmt_txn_ctx *txn,
|
||||
get_data->xpaths[indx],
|
||||
txn_iter_get_config_data_cb,
|
||||
(void *)txn_req) == -1) {
|
||||
MGMTD_TXN_DBG("Invalid Xpath '%s",
|
||||
get_data->xpaths[indx]);
|
||||
__dbg("Invalid Xpath '%s", get_data->xpaths[indx]);
|
||||
mgmt_fe_send_get_reply(txn->session_id, txn->txn_id,
|
||||
get_data->ds_id, txn_req->req_id,
|
||||
MGMTD_INTERNAL_ERROR, NULL,
|
||||
"Invalid xpath");
|
||||
goto mgmt_txn_get_config_failed;
|
||||
}
|
||||
MGMTD_TXN_DBG("Got %d remaining data-replies for xpath '%s'",
|
||||
get_reply->num_reply, get_data->xpaths[indx]);
|
||||
__dbg("Got %d remaining data-replies for xpath '%s'",
|
||||
get_reply->num_reply, get_data->xpaths[indx]);
|
||||
get_reply->last_batch = true;
|
||||
mgmt_txn_send_getcfg_reply_data(txn_req, get_data);
|
||||
}
|
||||
@ -1661,10 +1634,10 @@ static void mgmt_txn_process_get_cfg(struct event *thread)
|
||||
txn = (struct mgmt_txn_ctx *)EVENT_ARG(thread);
|
||||
assert(txn);
|
||||
|
||||
MGMTD_TXN_DBG("Processing %zu GET_CONFIG requests txn-id: %" PRIu64
|
||||
" session-id: %" PRIu64,
|
||||
mgmt_txn_reqs_count(&txn->get_cfg_reqs), txn->txn_id,
|
||||
txn->session_id);
|
||||
__dbg("Processing %zu GET_CONFIG requests txn-id: %" PRIu64
|
||||
" session-id: %" PRIu64,
|
||||
mgmt_txn_reqs_count(&txn->get_cfg_reqs), txn->txn_id,
|
||||
txn->session_id);
|
||||
|
||||
FOREACH_TXN_REQ_IN_LIST (&txn->get_cfg_reqs, txn_req) {
|
||||
error = false;
|
||||
@ -1673,11 +1646,10 @@ static void mgmt_txn_process_get_cfg(struct event *thread)
|
||||
assert(cfg_root);
|
||||
|
||||
if (mgmt_txn_get_config(txn, txn_req, cfg_root) != 0) {
|
||||
MGMTD_TXN_ERR("Unable to retrieve config from DS %d txn-id: %" PRIu64
|
||||
" session-id: %" PRIu64
|
||||
" req-id: %" PRIu64,
|
||||
txn_req->req.get_data->ds_id, txn->txn_id,
|
||||
txn->session_id, txn_req->req_id);
|
||||
__log_err("Unable to retrieve config from DS %d txn-id: %" PRIu64
|
||||
" session-id: %" PRIu64 " req-id: %" PRIu64,
|
||||
txn_req->req.get_data->ds_id, txn->txn_id,
|
||||
txn->session_id, txn_req->req_id);
|
||||
error = true;
|
||||
}
|
||||
|
||||
@ -1700,8 +1672,8 @@ static void mgmt_txn_process_get_cfg(struct event *thread)
|
||||
}
|
||||
|
||||
if (mgmt_txn_reqs_count(&txn->get_cfg_reqs)) {
|
||||
MGMTD_TXN_DBG("Processed maximum number of Get-Config requests (%d/%d). Rescheduling for rest.",
|
||||
num_processed, MGMTD_TXN_MAX_NUM_GETCFG_PROC);
|
||||
__dbg("Processed maximum number of Get-Config requests (%d/%d). Rescheduling for rest.",
|
||||
num_processed, MGMTD_TXN_MAX_NUM_GETCFG_PROC);
|
||||
mgmt_txn_register_event(txn, MGMTD_TXN_PROC_GETCFG);
|
||||
}
|
||||
}
|
||||
@ -1748,8 +1720,8 @@ static struct mgmt_txn_ctx *mgmt_txn_create_new(uint64_t session_id,
|
||||
txn->txn_id = mgmt_txn_mm->next_txn_id++;
|
||||
hash_get(mgmt_txn_mm->txn_hash, txn, hash_alloc_intern);
|
||||
|
||||
MGMTD_TXN_DBG("Added new '%s' txn-id: %" PRIu64,
|
||||
mgmt_txn_type2str(type), txn->txn_id);
|
||||
__dbg("Added new '%s' txn-id: %" PRIu64,
|
||||
mgmt_txn_type2str(type), txn->txn_id);
|
||||
|
||||
if (type == MGMTD_TXN_TYPE_CONFIG)
|
||||
mgmt_txn_mm->cfg_txn = txn;
|
||||
@ -1831,9 +1803,8 @@ uint64_t mgmt_txn_get_session_id(uint64_t txn_id)
|
||||
static void mgmt_txn_lock(struct mgmt_txn_ctx *txn, const char *file, int line)
|
||||
{
|
||||
txn->refcount++;
|
||||
MGMTD_TXN_DBG("%s:%d --> Lock %s txn-id: %" PRIu64 " refcnt: %d", file,
|
||||
line, mgmt_txn_type2str(txn->type), txn->txn_id,
|
||||
txn->refcount);
|
||||
__dbg("%s:%d --> Lock %s txn-id: %" PRIu64 " refcnt: %d", file, line,
|
||||
mgmt_txn_type2str(txn->type), txn->txn_id, txn->refcount);
|
||||
}
|
||||
|
||||
static void mgmt_txn_unlock(struct mgmt_txn_ctx **txn, const char *file,
|
||||
@ -1842,9 +1813,8 @@ static void mgmt_txn_unlock(struct mgmt_txn_ctx **txn, const char *file,
|
||||
assert(*txn && (*txn)->refcount);
|
||||
|
||||
(*txn)->refcount--;
|
||||
MGMTD_TXN_DBG("%s:%d --> Unlock %s txn-id: %" PRIu64 " refcnt: %d",
|
||||
file, line, mgmt_txn_type2str((*txn)->type),
|
||||
(*txn)->txn_id, (*txn)->refcount);
|
||||
__dbg("%s:%d --> Unlock %s txn-id: %" PRIu64 " refcnt: %d", file, line,
|
||||
mgmt_txn_type2str((*txn)->type), (*txn)->txn_id, (*txn)->refcount);
|
||||
if (!(*txn)->refcount) {
|
||||
if ((*txn)->type == MGMTD_TXN_TYPE_CONFIG)
|
||||
if (mgmt_txn_mm->cfg_txn == *txn)
|
||||
@ -1857,10 +1827,9 @@ static void mgmt_txn_unlock(struct mgmt_txn_ctx **txn, const char *file,
|
||||
hash_release(mgmt_txn_mm->txn_hash, *txn);
|
||||
mgmt_txns_del(&mgmt_txn_mm->txn_list, *txn);
|
||||
|
||||
MGMTD_TXN_DBG("Deleted %s txn-id: %" PRIu64
|
||||
" session-id: %" PRIu64,
|
||||
mgmt_txn_type2str((*txn)->type), (*txn)->txn_id,
|
||||
(*txn)->session_id);
|
||||
__dbg("Deleted %s txn-id: %" PRIu64 " session-id: %" PRIu64,
|
||||
mgmt_txn_type2str((*txn)->type), (*txn)->txn_id,
|
||||
(*txn)->session_id);
|
||||
|
||||
XFREE(MTYPE_MGMTD_TXN, *txn);
|
||||
}
|
||||
@ -1992,7 +1961,7 @@ int mgmt_txn_send_set_config_req(uint64_t txn_id, uint64_t req_id,
|
||||
return -1;
|
||||
|
||||
if (implicit_commit && mgmt_txn_reqs_count(&txn->set_cfg_reqs)) {
|
||||
MGMTD_TXN_ERR(
|
||||
__log_err(
|
||||
"For implicit commit config only one SETCFG-REQ can be allowed!");
|
||||
return -1;
|
||||
}
|
||||
@ -2035,12 +2004,11 @@ int mgmt_txn_send_set_config_req(uint64_t txn_id, uint64_t req_id,
|
||||
continue;
|
||||
}
|
||||
|
||||
MGMTD_TXN_DBG("XPath: '%s', Value: '%s'",
|
||||
cfg_req[indx]->data->xpath,
|
||||
(cfg_req[indx]->data->value &&
|
||||
cfg_req[indx]->data->value->encoded_str_val
|
||||
? cfg_req[indx]->data->value->encoded_str_val
|
||||
: "NULL"));
|
||||
__dbg("XPath: '%s', Value: '%s'", cfg_req[indx]->data->xpath,
|
||||
(cfg_req[indx]->data->value &&
|
||||
cfg_req[indx]->data->value->encoded_str_val
|
||||
? cfg_req[indx]->data->value->encoded_str_val
|
||||
: "NULL"));
|
||||
strlcpy(cfg_chg->xpath, cfg_req[indx]->data->xpath,
|
||||
sizeof(cfg_chg->xpath));
|
||||
cfg_chg->value =
|
||||
@ -2050,8 +2018,8 @@ int mgmt_txn_send_set_config_req(uint64_t txn_id, uint64_t req_id,
|
||||
->data->value->encoded_str_val)
|
||||
: NULL);
|
||||
if (cfg_chg->value)
|
||||
MGMTD_TXN_DBG("Allocated value at %p ==> '%s'",
|
||||
cfg_chg->value, cfg_chg->value);
|
||||
__dbg("Allocated value at %p ==> '%s'", cfg_chg->value,
|
||||
cfg_chg->value);
|
||||
|
||||
(*num_chgs)++;
|
||||
}
|
||||
@ -2081,9 +2049,9 @@ int mgmt_txn_send_commit_config_req(uint64_t txn_id, uint64_t req_id,
|
||||
return -1;
|
||||
|
||||
if (txn->commit_cfg_req) {
|
||||
MGMTD_TXN_ERR("Commit already in-progress txn-id: %" PRIu64
|
||||
" session-id: %" PRIu64 ". Cannot start another",
|
||||
txn->txn_id, txn->session_id);
|
||||
__log_err("Commit already in-progress txn-id: %" PRIu64
|
||||
" session-id: %" PRIu64 ". Cannot start another",
|
||||
txn->txn_id, txn->session_id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -2131,15 +2099,14 @@ int mgmt_txn_notify_be_adapter_conn(struct mgmt_be_client_adapter *adapter,
|
||||
*/
|
||||
txn = mgmt_txn_create_new(0, MGMTD_TXN_TYPE_CONFIG);
|
||||
if (!txn) {
|
||||
MGMTD_TXN_ERR("Failed to create CONFIG Transaction for downloading CONFIGs for client '%s'",
|
||||
adapter->name);
|
||||
__log_err("Failed to create CONFIG Transaction for downloading CONFIGs for client '%s'",
|
||||
adapter->name);
|
||||
nb_config_diff_del_changes(adapter_cfgs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
MGMTD_TXN_DBG("Created initial txn-id: %" PRIu64
|
||||
" for BE client '%s'",
|
||||
txn->txn_id, adapter->name);
|
||||
__dbg("Created initial txn-id: %" PRIu64 " for BE client '%s'",
|
||||
txn->txn_id, adapter->name);
|
||||
/*
|
||||
* Set the changeset for transaction to commit and trigger the
|
||||
* commit request.
|
||||
@ -2240,9 +2207,10 @@ int mgmt_txn_notify_be_cfgdata_reply(uint64_t txn_id, bool success,
|
||||
cmtcfg_req = &txn->commit_cfg_req->req.commit_cfg;
|
||||
|
||||
if (!success) {
|
||||
MGMTD_TXN_ERR("CFGDATA_CREATE_REQ sent to '%s' failed txn-id: %" PRIu64
|
||||
" err: %s", adapter->name, txn->txn_id,
|
||||
error_if_any ? error_if_any : "None");
|
||||
__log_err("CFGDATA_CREATE_REQ sent to '%s' failed txn-id: %" PRIu64
|
||||
" err: %s",
|
||||
adapter->name, txn->txn_id,
|
||||
error_if_any ? error_if_any : "None");
|
||||
mgmt_txn_send_commit_cfg_reply(
|
||||
txn, MGMTD_INTERNAL_ERROR,
|
||||
error_if_any
|
||||
@ -2251,9 +2219,9 @@ int mgmt_txn_notify_be_cfgdata_reply(uint64_t txn_id, bool success,
|
||||
return 0;
|
||||
}
|
||||
|
||||
MGMTD_TXN_DBG("CFGDATA_CREATE_REQ sent to '%s' was successful txn-id: %" PRIu64
|
||||
" err: %s", adapter->name, txn->txn_id,
|
||||
error_if_any ? error_if_any : "None");
|
||||
__dbg("CFGDATA_CREATE_REQ sent to '%s' was successful txn-id: %" PRIu64
|
||||
" err: %s",
|
||||
adapter->name, txn->txn_id, error_if_any ? error_if_any : "None");
|
||||
|
||||
cmtcfg_req->be_phase[adapter->id] = MGMTD_COMMIT_PHASE_APPLY_CFG;
|
||||
|
||||
@ -2276,10 +2244,10 @@ int mgmt_txn_notify_be_cfg_apply_reply(uint64_t txn_id, bool success,
|
||||
cmtcfg_req = &txn->commit_cfg_req->req.commit_cfg;
|
||||
|
||||
if (!success) {
|
||||
MGMTD_TXN_ERR("CFGDATA_APPLY_REQ sent to '%s' failed txn-id: %" PRIu64
|
||||
" err: %s",
|
||||
adapter->name, txn->txn_id,
|
||||
error_if_any ? error_if_any : "None");
|
||||
__log_err("CFGDATA_APPLY_REQ sent to '%s' failed txn-id: %" PRIu64
|
||||
" err: %s",
|
||||
adapter->name, txn->txn_id,
|
||||
error_if_any ? error_if_any : "None");
|
||||
mgmt_txn_send_commit_cfg_reply(
|
||||
txn, MGMTD_INTERNAL_ERROR,
|
||||
error_if_any
|
||||
@ -2324,7 +2292,7 @@ int mgmt_txn_send_get_req(uint64_t txn_id, uint64_t req_id,
|
||||
for (indx = 0;
|
||||
indx < num_reqs && indx < MGMTD_MAX_NUM_DATA_REPLY_IN_BATCH;
|
||||
indx++) {
|
||||
MGMTD_TXN_DBG("XPath: '%s'", data_req[indx]->data->xpath);
|
||||
__dbg("XPath: '%s'", data_req[indx]->data->xpath);
|
||||
txn_req->req.get_data->xpaths[indx] =
|
||||
strdup(data_req[indx]->data->xpath);
|
||||
txn_req->req.get_data->num_xpaths++;
|
||||
@ -2438,13 +2406,13 @@ state:
|
||||
FOREACH_BE_CLIENT_BITS (id, clients) {
|
||||
ret = mgmt_be_send_native(id, msg);
|
||||
if (ret) {
|
||||
MGMTD_TXN_ERR("Could not send get-tree message to backend client %s",
|
||||
mgmt_be_client_id2name(id));
|
||||
__log_err("Could not send get-tree message to backend client %s",
|
||||
mgmt_be_client_id2name(id));
|
||||
continue;
|
||||
}
|
||||
|
||||
MGMTD_TXN_DBG("Sent get-tree req to backend client %s",
|
||||
mgmt_be_client_id2name(id));
|
||||
__dbg("Sent get-tree req to backend client %s",
|
||||
mgmt_be_client_id2name(id));
|
||||
|
||||
/* record that we sent the request to the client */
|
||||
get_tree->sent_clients |= (1u << id);
|
||||
@ -2478,8 +2446,8 @@ int mgmt_txn_notify_error(struct mgmt_be_client_adapter *adapter,
|
||||
struct mgmt_txn_req *txn_req;
|
||||
|
||||
if (!txn) {
|
||||
MGMTD_TXN_ERR("Error reply from %s cannot find txn-id %" PRIu64,
|
||||
adapter->name, txn_id);
|
||||
__log_err("Error reply from %s cannot find txn-id %" PRIu64,
|
||||
adapter->name, txn_id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -2488,15 +2456,14 @@ int mgmt_txn_notify_error(struct mgmt_be_client_adapter *adapter,
|
||||
if (txn_req->req_id == req_id)
|
||||
break;
|
||||
if (!txn_req) {
|
||||
MGMTD_TXN_ERR("Error reply from %s for txn-id %" PRIu64
|
||||
" cannot find req_id %" PRIu64,
|
||||
adapter->name, txn_id, req_id);
|
||||
__log_err("Error reply from %s for txn-id %" PRIu64
|
||||
" cannot find req_id %" PRIu64,
|
||||
adapter->name, txn_id, req_id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
MGMTD_TXN_ERR("Error reply from %s for txn-id %" PRIu64
|
||||
" req_id %" PRIu64,
|
||||
adapter->name, txn_id, req_id);
|
||||
__log_err("Error reply from %s for txn-id %" PRIu64 " req_id %" PRIu64,
|
||||
adapter->name, txn_id, req_id);
|
||||
|
||||
switch (txn_req->req_event) {
|
||||
case MGMTD_TXN_PROC_GETTREE:
|
||||
@ -2539,8 +2506,8 @@ int mgmt_txn_notify_tree_data_reply(struct mgmt_be_client_adapter *adapter,
|
||||
LY_ERR err;
|
||||
|
||||
if (!txn) {
|
||||
MGMTD_TXN_ERR("GETTREE reply from %s for a missing txn-id %" PRIu64,
|
||||
adapter->name, txn_id);
|
||||
__log_err("GETTREE reply from %s for a missing txn-id %" PRIu64,
|
||||
adapter->name, txn_id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -2549,9 +2516,9 @@ int mgmt_txn_notify_tree_data_reply(struct mgmt_be_client_adapter *adapter,
|
||||
if (txn_req->req_id == req_id)
|
||||
break;
|
||||
if (!txn_req) {
|
||||
MGMTD_TXN_ERR("GETTREE reply from %s for txn-id %" PRIu64
|
||||
" missing req_id %" PRIu64,
|
||||
adapter->name, txn_id, req_id);
|
||||
__log_err("GETTREE reply from %s for txn-id %" PRIu64
|
||||
" missing req_id %" PRIu64,
|
||||
adapter->name, txn_id, req_id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -2563,11 +2530,9 @@ int mgmt_txn_notify_tree_data_reply(struct mgmt_be_client_adapter *adapter,
|
||||
LYD_PARSE_STRICT | LYD_PARSE_ONLY,
|
||||
0 /*LYD_VALIDATE_OPERATIONAL*/, &tree);
|
||||
if (err) {
|
||||
MGMTD_TXN_ERR("GETTREE reply from %s for txn-id %" PRIu64
|
||||
" req_id %" PRIu64
|
||||
" error parsing result of type %u",
|
||||
adapter->name, txn_id, req_id,
|
||||
data_msg->result_type);
|
||||
__log_err("GETTREE reply from %s for txn-id %" PRIu64
|
||||
" req_id %" PRIu64 " error parsing result of type %u",
|
||||
adapter->name, txn_id, req_id, data_msg->result_type);
|
||||
}
|
||||
if (!err) {
|
||||
/* TODO: we could merge ly_errs here if it's not binary */
|
||||
@ -2578,9 +2543,9 @@ int mgmt_txn_notify_tree_data_reply(struct mgmt_be_client_adapter *adapter,
|
||||
err = lyd_merge_siblings(&get_tree->client_results,
|
||||
tree, LYD_MERGE_DESTRUCT);
|
||||
if (err) {
|
||||
MGMTD_TXN_ERR("GETTREE reply from %s for txn-id %" PRIu64
|
||||
" req_id %" PRIu64 " error merging result",
|
||||
adapter->name, txn_id, req_id);
|
||||
__log_err("GETTREE reply from %s for txn-id %" PRIu64
|
||||
" req_id %" PRIu64 " error merging result",
|
||||
adapter->name, txn_id, req_id);
|
||||
}
|
||||
}
|
||||
if (!get_tree->partial_error)
|
||||
@ -2653,12 +2618,12 @@ int mgmt_txn_rollback_trigger_cfg_apply(struct mgmt_ds_ctx *src_ds_ctx,
|
||||
*/
|
||||
txn = mgmt_txn_create_new(0, MGMTD_TXN_TYPE_CONFIG);
|
||||
if (!txn) {
|
||||
MGMTD_TXN_ERR(
|
||||
__log_err(
|
||||
"Failed to create CONFIG Transaction for downloading CONFIGs");
|
||||
return -1;
|
||||
}
|
||||
|
||||
MGMTD_TXN_DBG("Created rollback txn-id: %" PRIu64, txn->txn_id);
|
||||
__dbg("Created rollback txn-id: %" PRIu64, txn->txn_id);
|
||||
|
||||
/*
|
||||
* Set the changeset for transaction to commit and trigger the commit
|
||||
|
Loading…
Reference in New Issue
Block a user