summaryrefslogtreecommitdiff
path: root/lib/mgmt_be_client.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mgmt_be_client.c')
-rw-r--r--lib/mgmt_be_client.c314
1 files changed, 220 insertions, 94 deletions
diff --git a/lib/mgmt_be_client.c b/lib/mgmt_be_client.c
index 463aefdf25..6530022db8 100644
--- a/lib/mgmt_be_client.c
+++ b/lib/mgmt_be_client.c
@@ -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;
}
@@ -311,6 +311,90 @@ static int be_client_send_error(struct mgmt_be_client *client, uint64_t txn_id,
return ret;
}
+void mgmt_be_send_notification(struct lyd_node *tree)
+{
+ struct mgmt_be_client *client = __be_client;
+ struct mgmt_msg_notify_data *msg = NULL;
+ LYD_FORMAT format = LYD_JSON;
+ uint8_t **darrp;
+ LY_ERR err;
+
+ assert(tree);
+
+ debug_be_client("%s: sending YANG notification: %s", __func__,
+ tree->schema->name);
+ /*
+ * Allocate a message and append the data to it using `format`
+ */
+ msg = mgmt_msg_native_alloc_msg(struct mgmt_msg_notify_data, 0,
+ MTYPE_MSG_NATIVE_NOTIFY);
+ msg->code = MGMT_MSG_CODE_NOTIFY;
+ msg->result_type = format;
+
+ darrp = mgmt_msg_native_get_darrp(msg);
+ err = yang_print_tree_append(darrp, tree, format,
+ (LYD_PRINT_SHRINK | LYD_PRINT_WD_EXPLICIT |
+ LYD_PRINT_WITHSIBLINGS));
+ if (err) {
+ flog_err(EC_LIB_LIBYANG,
+ "%s: error creating notification data: %s", __func__,
+ ly_strerrcode(err));
+ goto done;
+ }
+
+ (void)be_client_send_native_msg(client, msg,
+ mgmt_msg_native_get_msg_len(msg), false);
+done:
+ mgmt_msg_native_free_msg(msg);
+ lyd_free_all(tree);
+}
+
+/*
+ * Convert old style NB notification data into new MGMTD YANG tree and send.
+ */
+static int mgmt_be_notification_send(void *arg, const char *xpath,
+ struct list *args)
+{
+ struct lyd_node *root = NULL;
+ struct lyd_node *dnode;
+ struct yang_data *data;
+ struct listnode *ln;
+ LY_ERR err;
+
+ debug_be_client("%s: sending notification: %s", __func__, xpath);
+
+ /*
+ * Convert yang data args list to a libyang data tree
+ */
+ for (ALL_LIST_ELEMENTS_RO(args, ln, data)) {
+ err = lyd_new_path(root, ly_native_ctx, data->xpath,
+ data->value, LYD_NEW_PATH_UPDATE, &dnode);
+ if (err != LY_SUCCESS) {
+lyerr:
+ flog_err(EC_LIB_LIBYANG,
+ "%s: error creating notification data: %s",
+ __func__, ly_strerrcode(err));
+ if (root)
+ lyd_free_all(root);
+ return 1;
+ }
+ if (!root) {
+ root = dnode;
+ while (root->parent)
+ root = lyd_parent(root);
+ }
+ }
+
+ if (!root) {
+ err = lyd_new_path(NULL, ly_native_ctx, xpath, "", 0, &root);
+ if (err)
+ goto lyerr;
+ }
+
+ mgmt_be_send_notification(root);
+ return 0;
+}
+
static int mgmt_be_send_txn_reply(struct mgmt_be_client *client_ctx,
uint64_t txn_id, bool create)
{
@@ -326,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);
}
@@ -337,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)
@@ -348,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);
@@ -378,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);
}
@@ -390,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;
}
@@ -403,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);
}
@@ -453,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);
@@ -494,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);
@@ -530,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);
@@ -559,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++) {
@@ -622,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;
}
@@ -651,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);
}
@@ -698,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;
}
@@ -713,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;
@@ -736,23 +814,28 @@ 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,
+ client_ctx->user_data,
+ be_msg->subscr_reply
+ ->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,
@@ -760,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;
@@ -824,7 +907,7 @@ static enum nb_error be_client_send_tree_data_batch(const struct lyd_node *tree,
darrp = mgmt_msg_native_get_darrp(tree_msg);
err = yang_print_tree_append(darrp, tree, args->result_type,
- (LYD_PRINT_WD_EXPLICIT |
+ (LYD_PRINT_SHRINK | LYD_PRINT_WD_EXPLICIT |
LYD_PRINT_WITHSIBLINGS));
if (err) {
ret = NB_ERR;
@@ -856,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
@@ -874,6 +957,31 @@ static void be_client_handle_get_tree(struct mgmt_be_client *client,
}
/*
+ * Process the notification.
+ */
+static void be_client_handle_notify(struct mgmt_be_client *client, void *msgbuf,
+ size_t msg_len)
+{
+ struct mgmt_msg_notify_data *notif_msg = msgbuf;
+ struct mgmt_be_client_notification_cb *cb;
+ const char *notif;
+ uint i;
+
+ debug_be_client("Received notification for client %s", client->name);
+
+ /* "{\"modname:notification-name\": ...}" */
+ notif = (const char *)notif_msg->result + 2;
+
+ for (i = 0; i < client->cbs.nnotify_cbs; i++) {
+ cb = &client->cbs.notify_cbs[i];
+ if (strncmp(cb->xpath, notif, strlen(cb->xpath)))
+ continue;
+ cb->callback(client, client->user_data, cb,
+ (const char *)notif_msg->result);
+ }
+}
+
+/*
* Handle a native encoded message
*
* We don't create transactions with native messaging.
@@ -888,12 +996,15 @@ static void be_client_handle_native_msg(struct mgmt_be_client *client,
case MGMT_MSG_CODE_GET_TREE:
be_client_handle_get_tree(client, txn_id, msg, msg_len);
break;
+ case MGMT_MSG_CODE_NOTIFY:
+ 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);
- be_client_send_error(client, msg->refer_id, msg->req_id, false, -1,
+ 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,
client->name, txn_id);
break;
@@ -916,49 +1027,61 @@ 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);
}
int mgmt_be_send_subscr_req(struct mgmt_be_client *client_ctx,
- bool subscr_xpaths, int num_xpaths,
- char **reg_xpaths)
+ int n_config_xpaths, char **config_xpaths,
+ int n_oper_xpaths, char **oper_xpaths)
{
Mgmtd__BeMessage be_msg;
Mgmtd__BeSubscribeReq subscr_req;
+ const char **notif_xpaths = NULL;
+ int ret;
mgmtd__be_subscribe_req__init(&subscr_req);
subscr_req.client_name = client_ctx->name;
- subscr_req.n_xpath_reg = num_xpaths;
- if (num_xpaths)
- subscr_req.xpath_reg = reg_xpaths;
- else
- subscr_req.xpath_reg = NULL;
- subscr_req.subscribe_xpaths = subscr_xpaths;
+ subscr_req.n_config_xpaths = n_config_xpaths;
+ subscr_req.config_xpaths = config_xpaths;
+ subscr_req.n_oper_xpaths = n_oper_xpaths;
+ subscr_req.oper_xpaths = oper_xpaths;
+
+ /* See if we should register for notifications */
+ subscr_req.n_notif_xpaths = client_ctx->cbs.nnotify_cbs;
+ if (client_ctx->cbs.nnotify_cbs) {
+ struct mgmt_be_client_notification_cb *cb, *ecb;
+
+ cb = client_ctx->cbs.notify_cbs;
+ ecb = cb + client_ctx->cbs.nnotify_cbs;
+ for (; cb < ecb; cb++)
+ *darr_append(notif_xpaths) = cb->xpath;
+ }
+ subscr_req.notif_xpaths = (char **)notif_xpaths;
mgmtd__be_message__init(&be_msg);
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 subscr_xpaths: %u num_xpaths: %zu",
- subscr_req.client_name, subscr_req.subscribe_xpaths,
- subscr_req.n_xpath_reg);
+ 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);
- return mgmt_be_client_send_msg(client_ctx, &be_msg);
+ ret = mgmt_be_client_send_msg(client_ctx, &be_msg);
+ darr_free(notif_xpaths);
+ return ret;
}
static int _notify_conenct_disconnect(struct msg_client *msg_client,
@@ -970,15 +1093,16 @@ static int _notify_conenct_disconnect(struct msg_client *msg_client,
if (connected) {
assert(msg_client->conn.fd != -1);
- ret = mgmt_be_send_subscr_req(client, false, 0, NULL);
+ ret = mgmt_be_send_subscr_req(client, 0, NULL, 0, NULL);
if (ret)
return ret;
}
/* Notify BE client through registered callback (if any) */
if (client->cbs.client_connect_notify)
- (void)(*client->cbs.client_connect_notify)(
- client, client->user_data, connected);
+ (void)(*client->cbs.client_connect_notify)(client,
+ client->user_data,
+ connected);
/* Cleanup any in-progress TXN on disconnect */
if (!connected)
@@ -1016,9 +1140,8 @@ static void mgmt_debug_client_be_set(uint32_t flags, bool set)
DEFPY(debug_mgmt_client_be, debug_mgmt_client_be_cmd,
"[no] debug mgmt client backend",
- NO_STR DEBUG_STR MGMTD_STR
- "client\n"
- "backend\n")
+ NO_STR DEBUG_STR MGMTD_STR "client\n"
+ "backend\n")
{
mgmt_debug_client_be_set(DEBUG_NODE2MODE(vty->node), !no);
@@ -1035,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");
}
@@ -1081,9 +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;
}
@@ -1101,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);