lib: dont be tricky with session_id just make it a session_id

- Previously was substituting a pointer to local allocated session for the
session_id returned from the FE adapter. This complexity isn't needed.
- Get rid of "%llu" format and the casts that came with it, instead use PRIu64
and the actual (uint64_t) type.

Signed-off-by: Christian Hopps <chopps@labn.net>
This commit is contained in:
Christian Hopps 2023-05-03 23:49:16 -04:00
parent bcc350971f
commit d6665cf63f
5 changed files with 239 additions and 292 deletions

View File

@ -31,8 +31,8 @@ struct mgmt_fe_client_ctx;
PREDECL_LIST(mgmt_sessions); PREDECL_LIST(mgmt_sessions);
struct mgmt_fe_client_session { struct mgmt_fe_client_session {
uint64_t client_id; uint64_t client_id; /* FE client identifies itself with this ID */
uint64_t session_id; uint64_t session_id; /* FE adapter identified session with this ID */
struct mgmt_fe_client_ctx *client_ctx; struct mgmt_fe_client_ctx *client_ctx;
uintptr_t user_ctx; uintptr_t user_ctx;
@ -59,37 +59,40 @@ static struct mgmt_fe_client_ctx mgmt_fe_client_ctx = {
static struct mgmt_fe_client_session * static struct mgmt_fe_client_session *
mgmt_fe_find_session_by_client_id(struct mgmt_fe_client_ctx *client_ctx, mgmt_fe_find_session_by_client_id(struct mgmt_fe_client_ctx *client_ctx,
uint64_t client_id) uint64_t client_id)
{ {
struct mgmt_fe_client_session *session; struct mgmt_fe_client_session *session;
FOREACH_SESSION_IN_LIST (client_ctx, session) { FOREACH_SESSION_IN_LIST (client_ctx, session) {
if (session->client_id == client_id) { if (session->client_id == client_id) {
MGMTD_FE_CLIENT_DBG( MGMTD_FE_CLIENT_DBG("Found session-id %" PRIu64
"Found session %p for client-id %llu.", session, " using client-id %" PRIu64,
(unsigned long long)client_id); session->session_id, client_id);
return session; return session;
} }
} }
MGMTD_FE_CLIENT_DBG("Session not found using client-id %" PRIu64,
client_id);
return NULL; return NULL;
} }
static struct mgmt_fe_client_session * static struct mgmt_fe_client_session *
mgmt_fe_find_session_by_session_id(struct mgmt_fe_client_ctx *client_ctx, mgmt_fe_find_session_by_session_id(struct mgmt_fe_client_ctx *client_ctx,
uint64_t session_id) uint64_t session_id)
{ {
struct mgmt_fe_client_session *session; struct mgmt_fe_client_session *session;
FOREACH_SESSION_IN_LIST (client_ctx, session) { FOREACH_SESSION_IN_LIST (client_ctx, session) {
if (session->session_id == session_id) { if (session->session_id == session_id) {
MGMTD_FE_CLIENT_DBG( MGMTD_FE_CLIENT_DBG(
"Found session %p for session-id %llu.", "Found session of client-id %" PRIu64
session, (unsigned long long)session_id); " using session-id %" PRIu64,
session->client_id, session_id);
return session; return session;
} }
} }
MGMTD_FE_CLIENT_DBG("Session not found using session-id %" PRIu64,
session_id);
return NULL; return NULL;
} }
@ -102,8 +105,7 @@ static int mgmt_fe_client_send_msg(struct mgmt_fe_client_ctx *client_ctx,
(size_t(*)(void *, void *))mgmtd__fe_message__pack); (size_t(*)(void *, void *))mgmtd__fe_message__pack);
} }
static int static int mgmt_fe_send_register_req(struct mgmt_fe_client_ctx *client_ctx)
mgmt_fe_send_register_req(struct mgmt_fe_client_ctx *client_ctx)
{ {
Mgmtd__FeMessage fe_msg; Mgmtd__FeMessage fe_msg;
Mgmtd__FeRegisterReq rgstr_req; Mgmtd__FeRegisterReq rgstr_req;
@ -121,10 +123,9 @@ mgmt_fe_send_register_req(struct mgmt_fe_client_ctx *client_ctx)
return mgmt_fe_client_send_msg(client_ctx, &fe_msg); return mgmt_fe_client_send_msg(client_ctx, &fe_msg);
} }
static int static int mgmt_fe_send_session_req(struct mgmt_fe_client_ctx *client_ctx,
mgmt_fe_send_session_req(struct mgmt_fe_client_ctx *client_ctx, struct mgmt_fe_client_session *session,
struct mgmt_fe_client_session *session, bool create)
bool create)
{ {
Mgmtd__FeMessage fe_msg; Mgmtd__FeMessage fe_msg;
Mgmtd__FeSessionReq sess_req; Mgmtd__FeSessionReq sess_req;
@ -144,24 +145,22 @@ mgmt_fe_send_session_req(struct mgmt_fe_client_ctx *client_ctx,
fe_msg.session_req = &sess_req; fe_msg.session_req = &sess_req;
MGMTD_FE_CLIENT_DBG( MGMTD_FE_CLIENT_DBG(
"Sending SESSION_REQ message for %s session %llu to MGMTD Frontend server", "Sending SESSION_REQ %s message for client-id %" PRIu64,
create ? "creating" : "destroying", create ? "create" : "destroy", session->client_id);
(unsigned long long)session->client_id);
return mgmt_fe_client_send_msg(client_ctx, &fe_msg); return mgmt_fe_client_send_msg(client_ctx, &fe_msg);
} }
static int static int mgmt_fe_send_lockds_req(struct mgmt_fe_client_ctx *client_ctx,
mgmt_fe_send_lockds_req(struct mgmt_fe_client_ctx *client_ctx, uint64_t session_id, bool lock,
struct mgmt_fe_client_session *session, bool lock, uint64_t req_id, Mgmtd__DatastoreId ds_id)
uint64_t req_id, Mgmtd__DatastoreId ds_id)
{ {
(void)req_id; (void)req_id;
Mgmtd__FeMessage fe_msg; Mgmtd__FeMessage fe_msg;
Mgmtd__FeLockDsReq lockds_req; Mgmtd__FeLockDsReq lockds_req;
mgmtd__fe_lock_ds_req__init(&lockds_req); mgmtd__fe_lock_ds_req__init(&lockds_req);
lockds_req.session_id = session->session_id; lockds_req.session_id = session_id;
lockds_req.req_id = req_id; lockds_req.req_id = req_id;
lockds_req.ds_id = ds_id; lockds_req.ds_id = ds_id;
lockds_req.lock = lock; lockds_req.lock = lock;
@ -171,26 +170,25 @@ mgmt_fe_send_lockds_req(struct mgmt_fe_client_ctx *client_ctx,
fe_msg.lockds_req = &lockds_req; fe_msg.lockds_req = &lockds_req;
MGMTD_FE_CLIENT_DBG( MGMTD_FE_CLIENT_DBG(
"Sending %sLOCK_REQ message for Ds:%d session %llu to MGMTD Frontend server", "Sending %sLOCK_REQ message for Ds:%d session-id %" PRIu64,
lock ? "" : "UN", ds_id, lock ? "" : "UN", ds_id, session_id);
(unsigned long long)session->client_id);
return mgmt_fe_client_send_msg(client_ctx, &fe_msg); return mgmt_fe_client_send_msg(client_ctx, &fe_msg);
} }
static int static int mgmt_fe_send_setcfg_req(struct mgmt_fe_client_ctx *client_ctx,
mgmt_fe_send_setcfg_req(struct mgmt_fe_client_ctx *client_ctx, uint64_t session_id, uint64_t req_id,
struct mgmt_fe_client_session *session, Mgmtd__DatastoreId ds_id,
uint64_t req_id, Mgmtd__DatastoreId ds_id, Mgmtd__YangCfgDataReq **data_req,
Mgmtd__YangCfgDataReq **data_req, int num_data_reqs, int num_data_reqs, bool implicit_commit,
bool implicit_commit, Mgmtd__DatastoreId dst_ds_id) Mgmtd__DatastoreId dst_ds_id)
{ {
(void)req_id; (void)req_id;
Mgmtd__FeMessage fe_msg; Mgmtd__FeMessage fe_msg;
Mgmtd__FeSetConfigReq setcfg_req; Mgmtd__FeSetConfigReq setcfg_req;
mgmtd__fe_set_config_req__init(&setcfg_req); mgmtd__fe_set_config_req__init(&setcfg_req);
setcfg_req.session_id = session->session_id; setcfg_req.session_id = session_id;
setcfg_req.ds_id = ds_id; setcfg_req.ds_id = ds_id;
setcfg_req.req_id = req_id; setcfg_req.req_id = req_id;
setcfg_req.data = data_req; setcfg_req.data = data_req;
@ -203,15 +201,15 @@ mgmt_fe_send_setcfg_req(struct mgmt_fe_client_ctx *client_ctx,
fe_msg.setcfg_req = &setcfg_req; fe_msg.setcfg_req = &setcfg_req;
MGMTD_FE_CLIENT_DBG( MGMTD_FE_CLIENT_DBG(
"Sending SET_CONFIG_REQ message for Ds:%d session %llu (#xpaths:%d) to MGMTD Frontend server", "Sending SET_CONFIG_REQ message for Ds:%d session-id %" PRIu64
ds_id, (unsigned long long)session->client_id, num_data_reqs); " (#xpaths:%d)",
ds_id, session_id, num_data_reqs);
return mgmt_fe_client_send_msg(client_ctx, &fe_msg); return mgmt_fe_client_send_msg(client_ctx, &fe_msg);
} }
static int mgmt_fe_send_commitcfg_req(struct mgmt_fe_client_ctx *client_ctx, static int mgmt_fe_send_commitcfg_req(struct mgmt_fe_client_ctx *client_ctx,
struct mgmt_fe_client_session *session, uint64_t session_id, uint64_t req_id,
uint64_t req_id,
Mgmtd__DatastoreId src_ds_id, Mgmtd__DatastoreId src_ds_id,
Mgmtd__DatastoreId dest_ds_id, Mgmtd__DatastoreId dest_ds_id,
bool validate_only, bool abort) bool validate_only, bool abort)
@ -221,7 +219,7 @@ static int mgmt_fe_send_commitcfg_req(struct mgmt_fe_client_ctx *client_ctx,
Mgmtd__FeCommitConfigReq commitcfg_req; Mgmtd__FeCommitConfigReq commitcfg_req;
mgmtd__fe_commit_config_req__init(&commitcfg_req); mgmtd__fe_commit_config_req__init(&commitcfg_req);
commitcfg_req.session_id = session->session_id; commitcfg_req.session_id = session_id;
commitcfg_req.src_ds_id = src_ds_id; commitcfg_req.src_ds_id = src_ds_id;
commitcfg_req.dst_ds_id = dest_ds_id; commitcfg_req.dst_ds_id = dest_ds_id;
commitcfg_req.req_id = req_id; commitcfg_req.req_id = req_id;
@ -233,25 +231,24 @@ static int mgmt_fe_send_commitcfg_req(struct mgmt_fe_client_ctx *client_ctx,
fe_msg.commcfg_req = &commitcfg_req; fe_msg.commcfg_req = &commitcfg_req;
MGMTD_FE_CLIENT_DBG( MGMTD_FE_CLIENT_DBG(
"Sending COMMIT_CONFIG_REQ message for Src-Ds:%d, Dst-Ds:%d session %llu to MGMTD Frontend server", "Sending COMMIT_CONFIG_REQ message for Src-Ds:%d, Dst-Ds:%d session-id %" PRIu64,
src_ds_id, dest_ds_id, (unsigned long long)session->client_id); src_ds_id, dest_ds_id, session_id);
return mgmt_fe_client_send_msg(client_ctx, &fe_msg); return mgmt_fe_client_send_msg(client_ctx, &fe_msg);
} }
static int static int mgmt_fe_send_getcfg_req(struct mgmt_fe_client_ctx *client_ctx,
mgmt_fe_send_getcfg_req(struct mgmt_fe_client_ctx *client_ctx, uint64_t session_id, uint64_t req_id,
struct mgmt_fe_client_session *session, Mgmtd__DatastoreId ds_id,
uint64_t req_id, Mgmtd__DatastoreId ds_id, Mgmtd__YangGetDataReq *data_req[],
Mgmtd__YangGetDataReq * data_req[], int num_data_reqs)
int num_data_reqs)
{ {
(void)req_id; (void)req_id;
Mgmtd__FeMessage fe_msg; Mgmtd__FeMessage fe_msg;
Mgmtd__FeGetConfigReq getcfg_req; Mgmtd__FeGetConfigReq getcfg_req;
mgmtd__fe_get_config_req__init(&getcfg_req); mgmtd__fe_get_config_req__init(&getcfg_req);
getcfg_req.session_id = session->session_id; getcfg_req.session_id = session_id;
getcfg_req.ds_id = ds_id; getcfg_req.ds_id = ds_id;
getcfg_req.req_id = req_id; getcfg_req.req_id = req_id;
getcfg_req.data = data_req; getcfg_req.data = data_req;
@ -262,25 +259,25 @@ mgmt_fe_send_getcfg_req(struct mgmt_fe_client_ctx *client_ctx,
fe_msg.getcfg_req = &getcfg_req; fe_msg.getcfg_req = &getcfg_req;
MGMTD_FE_CLIENT_DBG( MGMTD_FE_CLIENT_DBG(
"Sending GET_CONFIG_REQ message for Ds:%d session %llu (#xpaths:%d) to MGMTD Frontend server", "Sending GET_CONFIG_REQ message for Ds:%d session-id %" PRIu64
ds_id, (unsigned long long)session->client_id, num_data_reqs); " (#xpaths:%d)",
ds_id, session_id, num_data_reqs);
return mgmt_fe_client_send_msg(client_ctx, &fe_msg); return mgmt_fe_client_send_msg(client_ctx, &fe_msg);
} }
static int static int mgmt_fe_send_getdata_req(struct mgmt_fe_client_ctx *client_ctx,
mgmt_fe_send_getdata_req(struct mgmt_fe_client_ctx *client_ctx, uint64_t session_id, uint64_t req_id,
struct mgmt_fe_client_session *session, Mgmtd__DatastoreId ds_id,
uint64_t req_id, Mgmtd__DatastoreId ds_id, Mgmtd__YangGetDataReq *data_req[],
Mgmtd__YangGetDataReq * data_req[], int num_data_reqs)
int num_data_reqs)
{ {
(void)req_id; (void)req_id;
Mgmtd__FeMessage fe_msg; Mgmtd__FeMessage fe_msg;
Mgmtd__FeGetDataReq getdata_req; Mgmtd__FeGetDataReq getdata_req;
mgmtd__fe_get_data_req__init(&getdata_req); mgmtd__fe_get_data_req__init(&getdata_req);
getdata_req.session_id = session->session_id; getdata_req.session_id = session_id;
getdata_req.ds_id = ds_id; getdata_req.ds_id = ds_id;
getdata_req.req_id = req_id; getdata_req.req_id = req_id;
getdata_req.data = data_req; getdata_req.data = data_req;
@ -291,24 +288,26 @@ mgmt_fe_send_getdata_req(struct mgmt_fe_client_ctx *client_ctx,
fe_msg.getdata_req = &getdata_req; fe_msg.getdata_req = &getdata_req;
MGMTD_FE_CLIENT_DBG( MGMTD_FE_CLIENT_DBG(
"Sending GET_CONFIG_REQ message for Ds:%d session %llu (#xpaths:%d) to MGMTD Frontend server", "Sending GET_CONFIG_REQ message for Ds:%d session-id %" PRIu64
ds_id, (unsigned long long)session->client_id, num_data_reqs); " (#xpaths:%d)",
ds_id, session_id, num_data_reqs);
return mgmt_fe_client_send_msg(client_ctx, &fe_msg); return mgmt_fe_client_send_msg(client_ctx, &fe_msg);
} }
static int mgmt_fe_send_regnotify_req( static int mgmt_fe_send_regnotify_req(struct mgmt_fe_client_ctx *client_ctx,
struct mgmt_fe_client_ctx *client_ctx, uint64_t session_id, uint64_t req_id,
struct mgmt_fe_client_session *session, uint64_t req_id, Mgmtd__DatastoreId ds_id,
Mgmtd__DatastoreId ds_id, bool register_req, bool register_req,
Mgmtd__YangDataXPath * data_req[], int num_data_reqs) Mgmtd__YangDataXPath *data_req[],
int num_data_reqs)
{ {
(void)req_id; (void)req_id;
Mgmtd__FeMessage fe_msg; Mgmtd__FeMessage fe_msg;
Mgmtd__FeRegisterNotifyReq regntfy_req; Mgmtd__FeRegisterNotifyReq regntfy_req;
mgmtd__fe_register_notify_req__init(&regntfy_req); mgmtd__fe_register_notify_req__init(&regntfy_req);
regntfy_req.session_id = session->session_id; regntfy_req.session_id = session_id;
regntfy_req.ds_id = ds_id; regntfy_req.ds_id = ds_id;
regntfy_req.register_req = register_req; regntfy_req.register_req = register_req;
regntfy_req.data_xpath = data_req; regntfy_req.data_xpath = data_req;
@ -321,9 +320,8 @@ static int mgmt_fe_send_regnotify_req(
return mgmt_fe_client_send_msg(client_ctx, &fe_msg); return mgmt_fe_client_send_msg(client_ctx, &fe_msg);
} }
static int static int mgmt_fe_client_handle_msg(struct mgmt_fe_client_ctx *client_ctx,
mgmt_fe_client_handle_msg(struct mgmt_fe_client_ctx *client_ctx, Mgmtd__FeMessage *fe_msg)
Mgmtd__FeMessage *fe_msg)
{ {
struct mgmt_fe_client_session *session = NULL; struct mgmt_fe_client_session *session = NULL;
@ -333,14 +331,13 @@ mgmt_fe_client_handle_msg(struct mgmt_fe_client_ctx *client_ctx,
*/ */
switch ((int)fe_msg->message_case) { switch ((int)fe_msg->message_case) {
case MGMTD__FE_MESSAGE__MESSAGE_SESSION_REPLY: case MGMTD__FE_MESSAGE__MESSAGE_SESSION_REPLY:
if (fe_msg->session_reply->create if (fe_msg->session_reply->create &&
&& fe_msg->session_reply->has_client_conn_id) { fe_msg->session_reply->has_client_conn_id) {
MGMTD_FE_CLIENT_DBG( MGMTD_FE_CLIENT_DBG(
"Got Session Create Reply Msg for client-id %llu with session-id: %llu.", "Got SESSION_REPLY (create) for client-id %" PRIu64
(unsigned long long) " with session-id: %" PRIu64,
fe_msg->session_reply->client_conn_id, fe_msg->session_reply->client_conn_id,
(unsigned long long) fe_msg->session_reply->session_id);
fe_msg->session_reply->session_id);
session = mgmt_fe_find_session_by_client_id( session = mgmt_fe_find_session_by_client_id(
client_ctx, client_ctx,
@ -348,32 +345,26 @@ mgmt_fe_client_handle_msg(struct mgmt_fe_client_ctx *client_ctx,
if (session && fe_msg->session_reply->success) { if (session && fe_msg->session_reply->success) {
MGMTD_FE_CLIENT_DBG( MGMTD_FE_CLIENT_DBG(
"Session Create for client-id %llu successful.", "Session Created for client-id %" PRIu64,
(unsigned long long) fe_msg->session_reply->client_conn_id);
fe_msg->session_reply
->client_conn_id);
session->session_id = session->session_id =
fe_msg->session_reply->session_id; fe_msg->session_reply->session_id;
} else { } else {
MGMTD_FE_CLIENT_ERR( MGMTD_FE_CLIENT_ERR(
"Session Create for client-id %llu failed.", "Session Create failed for client-id %" PRIu64,
(unsigned long long) fe_msg->session_reply->client_conn_id);
fe_msg->session_reply
->client_conn_id);
} }
} else if (!fe_msg->session_reply->create) { } else if (!fe_msg->session_reply->create) {
MGMTD_FE_CLIENT_DBG( MGMTD_FE_CLIENT_DBG(
"Got Session Destroy Reply Msg for session-id %llu", "Got SESSION_REPLY (destroy) for session-id %" PRIu64,
(unsigned long long) fe_msg->session_reply->session_id);
fe_msg->session_reply->session_id);
session = mgmt_fe_find_session_by_session_id( session = mgmt_fe_find_session_by_session_id(
client_ctx, fe_msg->session_req->session_id); client_ctx, fe_msg->session_req->session_id);
} }
if (session && session->client_ctx if (session && session->client_ctx &&
&& session->client_ctx->client_params session->client_ctx->client_params.client_session_notify)
.client_session_notify)
(*session->client_ctx->client_params (*session->client_ctx->client_params
.client_session_notify)( .client_session_notify)(
(uintptr_t)client_ctx, (uintptr_t)client_ctx,
@ -381,71 +372,62 @@ mgmt_fe_client_handle_msg(struct mgmt_fe_client_ctx *client_ctx,
session->client_id, session->client_id,
fe_msg->session_reply->create, fe_msg->session_reply->create,
fe_msg->session_reply->success, fe_msg->session_reply->success,
(uintptr_t)session, session->user_ctx); fe_msg->session_reply->session_id,
session->user_ctx);
break; break;
case MGMTD__FE_MESSAGE__MESSAGE_LOCKDS_REPLY: case MGMTD__FE_MESSAGE__MESSAGE_LOCKDS_REPLY:
MGMTD_FE_CLIENT_DBG( MGMTD_FE_CLIENT_DBG("Got LOCKDS_REPLY for session-id %" PRIu64,
"Got LockDs Reply Msg for session-id %llu", fe_msg->lockds_reply->session_id);
(unsigned long long)
fe_msg->lockds_reply->session_id);
session = mgmt_fe_find_session_by_session_id( session = mgmt_fe_find_session_by_session_id(
client_ctx, fe_msg->lockds_reply->session_id); client_ctx, fe_msg->lockds_reply->session_id);
if (session && session->client_ctx if (session && session->client_ctx &&
&& session->client_ctx->client_params session->client_ctx->client_params.lock_ds_notify)
.lock_ds_notify) (*session->client_ctx->client_params.lock_ds_notify)(
(*session->client_ctx->client_params
.lock_ds_notify)(
(uintptr_t)client_ctx, (uintptr_t)client_ctx,
client_ctx->client_params.user_data, client_ctx->client_params.user_data,
session->client_id, (uintptr_t)session, session->client_id,
session->user_ctx, fe_msg->lockds_reply->session_id,
fe_msg->lockds_reply->req_id, session->user_ctx, fe_msg->lockds_reply->req_id,
fe_msg->lockds_reply->lock, fe_msg->lockds_reply->lock,
fe_msg->lockds_reply->success, fe_msg->lockds_reply->success,
fe_msg->lockds_reply->ds_id, fe_msg->lockds_reply->ds_id,
fe_msg->lockds_reply->error_if_any); fe_msg->lockds_reply->error_if_any);
break; break;
case MGMTD__FE_MESSAGE__MESSAGE_SETCFG_REPLY: case MGMTD__FE_MESSAGE__MESSAGE_SETCFG_REPLY:
MGMTD_FE_CLIENT_DBG( MGMTD_FE_CLIENT_DBG("Got SETCFG_REPLY for session-id %" PRIu64,
"Got Set Config Reply Msg for session-id %llu", fe_msg->setcfg_reply->session_id);
(unsigned long long)
fe_msg->setcfg_reply->session_id);
session = mgmt_fe_find_session_by_session_id( session = mgmt_fe_find_session_by_session_id(
client_ctx, fe_msg->setcfg_reply->session_id); client_ctx, fe_msg->setcfg_reply->session_id);
if (session && session->client_ctx if (session && session->client_ctx &&
&& session->client_ctx->client_params session->client_ctx->client_params.set_config_notify)
.set_config_notify) (*session->client_ctx->client_params.set_config_notify)(
(*session->client_ctx->client_params
.set_config_notify)(
(uintptr_t)client_ctx, (uintptr_t)client_ctx,
client_ctx->client_params.user_data, client_ctx->client_params.user_data,
session->client_id, (uintptr_t)session, session->client_id,
session->user_ctx, fe_msg->setcfg_reply->session_id,
fe_msg->setcfg_reply->req_id, session->user_ctx, fe_msg->setcfg_reply->req_id,
fe_msg->setcfg_reply->success, fe_msg->setcfg_reply->success,
fe_msg->setcfg_reply->ds_id, fe_msg->setcfg_reply->ds_id,
fe_msg->setcfg_reply->error_if_any); fe_msg->setcfg_reply->error_if_any);
break; break;
case MGMTD__FE_MESSAGE__MESSAGE_COMMCFG_REPLY: case MGMTD__FE_MESSAGE__MESSAGE_COMMCFG_REPLY:
MGMTD_FE_CLIENT_DBG( MGMTD_FE_CLIENT_DBG("Got COMMCFG_REPLY for session-id %" PRIu64,
"Got Commit Config Reply Msg for session-id %llu", fe_msg->commcfg_reply->session_id);
(unsigned long long)
fe_msg->commcfg_reply->session_id);
session = mgmt_fe_find_session_by_session_id( session = mgmt_fe_find_session_by_session_id(
client_ctx, fe_msg->commcfg_reply->session_id); client_ctx, fe_msg->commcfg_reply->session_id);
if (session && session->client_ctx if (session && session->client_ctx &&
&& session->client_ctx->client_params session->client_ctx->client_params.commit_config_notify)
.commit_config_notify)
(*session->client_ctx->client_params (*session->client_ctx->client_params
.commit_config_notify)( .commit_config_notify)(
(uintptr_t)client_ctx, (uintptr_t)client_ctx,
client_ctx->client_params.user_data, client_ctx->client_params.user_data,
session->client_id, (uintptr_t)session, session->client_id,
fe_msg->commcfg_reply->session_id,
session->user_ctx, session->user_ctx,
fe_msg->commcfg_reply->req_id, fe_msg->commcfg_reply->req_id,
fe_msg->commcfg_reply->success, fe_msg->commcfg_reply->success,
@ -455,24 +437,20 @@ mgmt_fe_client_handle_msg(struct mgmt_fe_client_ctx *client_ctx,
fe_msg->commcfg_reply->error_if_any); fe_msg->commcfg_reply->error_if_any);
break; break;
case MGMTD__FE_MESSAGE__MESSAGE_GETCFG_REPLY: case MGMTD__FE_MESSAGE__MESSAGE_GETCFG_REPLY:
MGMTD_FE_CLIENT_DBG( MGMTD_FE_CLIENT_DBG("Got GETCFG_REPLY for session-id %" PRIu64,
"Got Get Config Reply Msg for session-id %llu", fe_msg->getcfg_reply->session_id);
(unsigned long long)
fe_msg->getcfg_reply->session_id);
session = mgmt_fe_find_session_by_session_id( session = mgmt_fe_find_session_by_session_id(
client_ctx, fe_msg->getcfg_reply->session_id); client_ctx, fe_msg->getcfg_reply->session_id);
if (session && session->client_ctx if (session && session->client_ctx &&
&& session->client_ctx->client_params session->client_ctx->client_params.get_data_notify)
.get_data_notify) (*session->client_ctx->client_params.get_data_notify)(
(*session->client_ctx->client_params
.get_data_notify)(
(uintptr_t)client_ctx, (uintptr_t)client_ctx,
client_ctx->client_params.user_data, client_ctx->client_params.user_data,
session->client_id, (uintptr_t)session, session->client_id,
session->user_ctx, fe_msg->getcfg_reply->session_id,
fe_msg->getcfg_reply->req_id, session->user_ctx, fe_msg->getcfg_reply->req_id,
fe_msg->getcfg_reply->success, fe_msg->getcfg_reply->success,
fe_msg->getcfg_reply->ds_id, fe_msg->getcfg_reply->ds_id,
fe_msg->getcfg_reply->data fe_msg->getcfg_reply->data
@ -482,28 +460,24 @@ mgmt_fe_client_handle_msg(struct mgmt_fe_client_ctx *client_ctx,
? fe_msg->getcfg_reply->data->n_data ? fe_msg->getcfg_reply->data->n_data
: 0, : 0,
fe_msg->getcfg_reply->data fe_msg->getcfg_reply->data
? fe_msg->getcfg_reply->data ? fe_msg->getcfg_reply->data->next_indx
->next_indx
: 0, : 0,
fe_msg->getcfg_reply->error_if_any); fe_msg->getcfg_reply->error_if_any);
break; break;
case MGMTD__FE_MESSAGE__MESSAGE_GETDATA_REPLY: case MGMTD__FE_MESSAGE__MESSAGE_GETDATA_REPLY:
MGMTD_FE_CLIENT_DBG( MGMTD_FE_CLIENT_DBG("Got GETDATA_REPLY for session-id %" PRIu64,
"Got Get Data Reply Msg for session-id %llu", fe_msg->getdata_reply->session_id);
(unsigned long long)
fe_msg->getdata_reply->session_id);
session = mgmt_fe_find_session_by_session_id( session = mgmt_fe_find_session_by_session_id(
client_ctx, fe_msg->getdata_reply->session_id); client_ctx, fe_msg->getdata_reply->session_id);
if (session && session->client_ctx if (session && session->client_ctx &&
&& session->client_ctx->client_params session->client_ctx->client_params.get_data_notify)
.get_data_notify) (*session->client_ctx->client_params.get_data_notify)(
(*session->client_ctx->client_params
.get_data_notify)(
(uintptr_t)client_ctx, (uintptr_t)client_ctx,
client_ctx->client_params.user_data, client_ctx->client_params.user_data,
session->client_id, (uintptr_t)session, session->client_id,
fe_msg->getdata_reply->session_id,
session->user_ctx, session->user_ctx,
fe_msg->getdata_reply->req_id, fe_msg->getdata_reply->req_id,
fe_msg->getdata_reply->success, fe_msg->getdata_reply->success,
@ -512,12 +486,10 @@ mgmt_fe_client_handle_msg(struct mgmt_fe_client_ctx *client_ctx,
? fe_msg->getdata_reply->data->data ? fe_msg->getdata_reply->data->data
: NULL, : NULL,
fe_msg->getdata_reply->data fe_msg->getdata_reply->data
? fe_msg->getdata_reply->data ? fe_msg->getdata_reply->data->n_data
->n_data
: 0, : 0,
fe_msg->getdata_reply->data fe_msg->getdata_reply->data
? fe_msg->getdata_reply->data ? fe_msg->getdata_reply->data->next_indx
->next_indx
: 0, : 0,
fe_msg->getdata_reply->error_if_any); fe_msg->getdata_reply->error_if_any);
break; break;
@ -687,8 +659,8 @@ void mgmt_fe_client_lib_vty_init(void)
* Create a new Session for a Frontend Client connection. * Create a new Session for a Frontend Client connection.
*/ */
enum mgmt_result mgmt_fe_create_client_session(uintptr_t lib_hndl, enum mgmt_result mgmt_fe_create_client_session(uintptr_t lib_hndl,
uint64_t client_id, uint64_t client_id,
uintptr_t user_ctx) uintptr_t user_ctx)
{ {
struct mgmt_fe_client_ctx *client_ctx; struct mgmt_fe_client_ctx *client_ctx;
struct mgmt_fe_client_session *session; struct mgmt_fe_client_session *session;
@ -698,7 +670,7 @@ enum mgmt_result mgmt_fe_create_client_session(uintptr_t lib_hndl,
return MGMTD_INVALID_PARAM; return MGMTD_INVALID_PARAM;
session = XCALLOC(MTYPE_MGMTD_FE_SESSION, session = XCALLOC(MTYPE_MGMTD_FE_SESSION,
sizeof(struct mgmt_fe_client_session)); sizeof(struct mgmt_fe_client_session));
assert(session); assert(session);
session->user_ctx = user_ctx; session->user_ctx = user_ctx;
session->client_id = client_id; session->client_id = client_id;
@ -759,24 +731,18 @@ static void mgmt_fe_destroy_client_sessions(uintptr_t lib_hndl)
/* /*
* Send UN/LOCK_DS_REQ to MGMTD for a specific Datastore DS. * Send UN/LOCK_DS_REQ to MGMTD for a specific Datastore DS.
*/ */
enum mgmt_result mgmt_fe_lock_ds(uintptr_t lib_hndl, uintptr_t session_id, enum mgmt_result mgmt_fe_lock_ds(uintptr_t lib_hndl, uint64_t session_id,
uint64_t req_id, Mgmtd__DatastoreId ds_id, uint64_t req_id, Mgmtd__DatastoreId ds_id,
bool lock_ds) bool lock_ds)
{ {
struct mgmt_fe_client_ctx *client_ctx; struct mgmt_fe_client_ctx *client_ctx;
struct mgmt_fe_client_session *session;
client_ctx = (struct mgmt_fe_client_ctx *)lib_hndl; client_ctx = (struct mgmt_fe_client_ctx *)lib_hndl;
if (!client_ctx) if (!client_ctx)
return MGMTD_INVALID_PARAM; return MGMTD_INVALID_PARAM;
session = (struct mgmt_fe_client_session *)session_id; if (mgmt_fe_send_lockds_req(client_ctx, session_id, lock_ds, req_id,
if (!session || session->client_ctx != client_ctx) ds_id) != 0)
return MGMTD_INVALID_PARAM;
if (mgmt_fe_send_lockds_req(client_ctx, session, lock_ds, req_id,
ds_id)
!= 0)
return MGMTD_INTERNAL_ERROR; return MGMTD_INTERNAL_ERROR;
return MGMTD_SUCCESS; return MGMTD_SUCCESS;
@ -785,27 +751,22 @@ enum mgmt_result mgmt_fe_lock_ds(uintptr_t lib_hndl, uintptr_t session_id,
/* /*
* Send SET_CONFIG_REQ to MGMTD for one or more config data(s). * Send SET_CONFIG_REQ to MGMTD for one or more config data(s).
*/ */
enum mgmt_result enum mgmt_result mgmt_fe_set_config_data(uintptr_t lib_hndl,
mgmt_fe_set_config_data(uintptr_t lib_hndl, uintptr_t session_id, uint64_t session_id, uint64_t req_id,
uint64_t req_id, Mgmtd__DatastoreId ds_id, Mgmtd__DatastoreId ds_id,
Mgmtd__YangCfgDataReq **config_req, int num_reqs, Mgmtd__YangCfgDataReq **config_req,
bool implicit_commit, Mgmtd__DatastoreId dst_ds_id) int num_reqs, bool implicit_commit,
Mgmtd__DatastoreId dst_ds_id)
{ {
struct mgmt_fe_client_ctx *client_ctx; struct mgmt_fe_client_ctx *client_ctx;
struct mgmt_fe_client_session *session;
client_ctx = (struct mgmt_fe_client_ctx *)lib_hndl; client_ctx = (struct mgmt_fe_client_ctx *)lib_hndl;
if (!client_ctx) if (!client_ctx)
return MGMTD_INVALID_PARAM; return MGMTD_INVALID_PARAM;
session = (struct mgmt_fe_client_session *)session_id; if (mgmt_fe_send_setcfg_req(client_ctx, session_id, req_id, ds_id,
if (!session || session->client_ctx != client_ctx) config_req, num_reqs, implicit_commit,
return MGMTD_INVALID_PARAM; dst_ds_id) != 0)
if (mgmt_fe_send_setcfg_req(client_ctx, session, req_id, ds_id,
config_req, num_reqs, implicit_commit,
dst_ds_id)
!= 0)
return MGMTD_INTERNAL_ERROR; return MGMTD_INTERNAL_ERROR;
return MGMTD_SUCCESS; return MGMTD_SUCCESS;
@ -815,26 +776,21 @@ mgmt_fe_set_config_data(uintptr_t lib_hndl, uintptr_t session_id,
* Send SET_CONFIG_REQ to MGMTD for one or more config data(s). * Send SET_CONFIG_REQ to MGMTD for one or more config data(s).
*/ */
enum mgmt_result mgmt_fe_commit_config_data(uintptr_t lib_hndl, enum mgmt_result mgmt_fe_commit_config_data(uintptr_t lib_hndl,
uintptr_t session_id, uint64_t session_id,
uint64_t req_id, uint64_t req_id,
Mgmtd__DatastoreId src_ds_id, Mgmtd__DatastoreId src_ds_id,
Mgmtd__DatastoreId dst_ds_id, Mgmtd__DatastoreId dst_ds_id,
bool validate_only, bool abort) bool validate_only, bool abort)
{ {
struct mgmt_fe_client_ctx *client_ctx; struct mgmt_fe_client_ctx *client_ctx;
struct mgmt_fe_client_session *session;
client_ctx = (struct mgmt_fe_client_ctx *)lib_hndl; client_ctx = (struct mgmt_fe_client_ctx *)lib_hndl;
if (!client_ctx) if (!client_ctx)
return MGMTD_INVALID_PARAM; return MGMTD_INVALID_PARAM;
session = (struct mgmt_fe_client_session *)session_id; if (mgmt_fe_send_commitcfg_req(client_ctx, session_id, req_id,
if (!session || session->client_ctx != client_ctx) src_ds_id, dst_ds_id, validate_only,
return MGMTD_INVALID_PARAM; abort) != 0)
if (mgmt_fe_send_commitcfg_req(client_ctx, session, req_id, src_ds_id,
dst_ds_id, validate_only, abort)
!= 0)
return MGMTD_INTERNAL_ERROR; return MGMTD_INTERNAL_ERROR;
return MGMTD_SUCCESS; return MGMTD_SUCCESS;
@ -843,25 +799,20 @@ enum mgmt_result mgmt_fe_commit_config_data(uintptr_t lib_hndl,
/* /*
* Send GET_CONFIG_REQ to MGMTD for one or more config data item(s). * Send GET_CONFIG_REQ to MGMTD for one or more config data item(s).
*/ */
enum mgmt_result enum mgmt_result mgmt_fe_get_config_data(uintptr_t lib_hndl,
mgmt_fe_get_config_data(uintptr_t lib_hndl, uintptr_t session_id, uint64_t session_id, uint64_t req_id,
uint64_t req_id, Mgmtd__DatastoreId ds_id, Mgmtd__DatastoreId ds_id,
Mgmtd__YangGetDataReq * data_req[], int num_reqs) Mgmtd__YangGetDataReq *data_req[],
int num_reqs)
{ {
struct mgmt_fe_client_ctx *client_ctx; struct mgmt_fe_client_ctx *client_ctx;
struct mgmt_fe_client_session *session;
client_ctx = (struct mgmt_fe_client_ctx *)lib_hndl; client_ctx = (struct mgmt_fe_client_ctx *)lib_hndl;
if (!client_ctx) if (!client_ctx)
return MGMTD_INVALID_PARAM; return MGMTD_INVALID_PARAM;
session = (struct mgmt_fe_client_session *)session_id; if (mgmt_fe_send_getcfg_req(client_ctx, session_id, req_id, ds_id,
if (!session || session->client_ctx != client_ctx) data_req, num_reqs) != 0)
return MGMTD_INVALID_PARAM;
if (mgmt_fe_send_getcfg_req(client_ctx, session, req_id, ds_id,
data_req, num_reqs)
!= 0)
return MGMTD_INTERNAL_ERROR; return MGMTD_INTERNAL_ERROR;
return MGMTD_SUCCESS; return MGMTD_SUCCESS;
@ -870,25 +821,19 @@ mgmt_fe_get_config_data(uintptr_t lib_hndl, uintptr_t session_id,
/* /*
* Send GET_DATA_REQ to MGMTD for one or more config data item(s). * Send GET_DATA_REQ to MGMTD for one or more config data item(s).
*/ */
enum mgmt_result mgmt_fe_get_data(uintptr_t lib_hndl, uintptr_t session_id, enum mgmt_result mgmt_fe_get_data(uintptr_t lib_hndl, uint64_t session_id,
uint64_t req_id, Mgmtd__DatastoreId ds_id, uint64_t req_id, Mgmtd__DatastoreId ds_id,
Mgmtd__YangGetDataReq * data_req[], Mgmtd__YangGetDataReq *data_req[],
int num_reqs) int num_reqs)
{ {
struct mgmt_fe_client_ctx *client_ctx; struct mgmt_fe_client_ctx *client_ctx;
struct mgmt_fe_client_session *session;
client_ctx = (struct mgmt_fe_client_ctx *)lib_hndl; client_ctx = (struct mgmt_fe_client_ctx *)lib_hndl;
if (!client_ctx) if (!client_ctx)
return MGMTD_INVALID_PARAM; return MGMTD_INVALID_PARAM;
session = (struct mgmt_fe_client_session *)session_id; if (mgmt_fe_send_getdata_req(client_ctx, session_id, req_id, ds_id,
if (!session || session->client_ctx != client_ctx) data_req, num_reqs) != 0)
return MGMTD_INVALID_PARAM;
if (mgmt_fe_send_getdata_req(client_ctx, session, req_id, ds_id,
data_req, num_reqs)
!= 0)
return MGMTD_INTERNAL_ERROR; return MGMTD_INTERNAL_ERROR;
return MGMTD_SUCCESS; return MGMTD_SUCCESS;
@ -898,26 +843,19 @@ enum mgmt_result mgmt_fe_get_data(uintptr_t lib_hndl, uintptr_t session_id,
* Send NOTIFY_REGISTER_REQ to MGMTD daemon. * Send NOTIFY_REGISTER_REQ to MGMTD daemon.
*/ */
enum mgmt_result enum mgmt_result
mgmt_fe_register_yang_notify(uintptr_t lib_hndl, uintptr_t session_id, mgmt_fe_register_yang_notify(uintptr_t lib_hndl, uint64_t session_id,
uint64_t req_id, Mgmtd__DatastoreId ds_id, uint64_t req_id, Mgmtd__DatastoreId ds_id,
bool register_req, bool register_req,
Mgmtd__YangDataXPath * data_req[], Mgmtd__YangDataXPath *data_req[], int num_reqs)
int num_reqs)
{ {
struct mgmt_fe_client_ctx *client_ctx; struct mgmt_fe_client_ctx *client_ctx;
struct mgmt_fe_client_session *session;
client_ctx = (struct mgmt_fe_client_ctx *)lib_hndl; client_ctx = (struct mgmt_fe_client_ctx *)lib_hndl;
if (!client_ctx) if (!client_ctx)
return MGMTD_INVALID_PARAM; return MGMTD_INVALID_PARAM;
session = (struct mgmt_fe_client_session *)session_id; if (mgmt_fe_send_regnotify_req(client_ctx, session_id, req_id, ds_id,
if (!session || session->client_ctx != client_ctx) register_req, data_req, num_reqs) != 0)
return MGMTD_INVALID_PARAM;
if (mgmt_fe_send_regnotify_req(client_ctx, session, req_id, ds_id,
register_req, data_req, num_reqs)
!= 0)
return MGMTD_INTERNAL_ERROR; return MGMTD_INTERNAL_ERROR;
return MGMTD_SUCCESS; return MGMTD_SUCCESS;
@ -931,7 +869,7 @@ void mgmt_fe_client_lib_destroy(void)
struct mgmt_fe_client_ctx *client_ctx = &mgmt_fe_client_ctx; struct mgmt_fe_client_ctx *client_ctx = &mgmt_fe_client_ctx;
MGMTD_FE_CLIENT_DBG("Destroying MGMTD Frontend Client '%s'", MGMTD_FE_CLIENT_DBG("Destroying MGMTD Frontend Client '%s'",
client_ctx->client_params.name); client_ctx->client_params.name);
mgmt_fe_destroy_client_sessions((uintptr_t)client_ctx); mgmt_fe_destroy_client_sessions((uintptr_t)client_ctx);
msg_client_cleanup(&client_ctx->client); msg_client_cleanup(&client_ctx->client);

View File

@ -202,9 +202,9 @@ extern enum mgmt_result mgmt_fe_destroy_client_session(uintptr_t lib_hndl,
* Returns: * Returns:
* MGMTD_SUCCESS on success, MGMTD_* otherwise. * MGMTD_SUCCESS on success, MGMTD_* otherwise.
*/ */
extern enum mgmt_result extern enum mgmt_result mgmt_fe_lock_ds(uintptr_t lib_hndl, uint64_t session_id,
mgmt_fe_lock_ds(uintptr_t lib_hndl, uintptr_t session_id, uint64_t req_id, uint64_t req_id,
Mgmtd__DatastoreId ds_id, bool lock_ds); Mgmtd__DatastoreId ds_id, bool lock_ds);
/* /*
* Send SET_CONFIG_REQ to MGMTD for one or more config data(s). * Send SET_CONFIG_REQ to MGMTD for one or more config data(s).
@ -237,10 +237,10 @@ mgmt_fe_lock_ds(uintptr_t lib_hndl, uintptr_t session_id, uint64_t req_id,
* MGMTD_SUCCESS on success, MGMTD_* otherwise. * MGMTD_SUCCESS on success, MGMTD_* otherwise.
*/ */
extern enum mgmt_result extern enum mgmt_result
mgmt_fe_set_config_data(uintptr_t lib_hndl, uintptr_t session_id, mgmt_fe_set_config_data(uintptr_t lib_hndl, uint64_t session_id,
uint64_t req_id, Mgmtd__DatastoreId ds_id, uint64_t req_id, Mgmtd__DatastoreId ds_id,
Mgmtd__YangCfgDataReq **config_req, int num_req, Mgmtd__YangCfgDataReq **config_req, int num_req,
bool implicit_commit, Mgmtd__DatastoreId dst_ds_id); bool implicit_commit, Mgmtd__DatastoreId dst_ds_id);
/* /*
* Send SET_COMMMIT_REQ to MGMTD for one or more config data(s). * Send SET_COMMMIT_REQ to MGMTD for one or more config data(s).
@ -270,10 +270,10 @@ mgmt_fe_set_config_data(uintptr_t lib_hndl, uintptr_t session_id,
* MGMTD_SUCCESS on success, MGMTD_* otherwise. * MGMTD_SUCCESS on success, MGMTD_* otherwise.
*/ */
extern enum mgmt_result extern enum mgmt_result
mgmt_fe_commit_config_data(uintptr_t lib_hndl, uintptr_t session_id, mgmt_fe_commit_config_data(uintptr_t lib_hndl, uint64_t session_id,
uint64_t req_id, Mgmtd__DatastoreId src_ds_id, uint64_t req_id, Mgmtd__DatastoreId src_ds_id,
Mgmtd__DatastoreId dst_ds_id, bool validate_only, Mgmtd__DatastoreId dst_ds_id, bool validate_only,
bool abort); bool abort);
/* /*
* Send GET_CONFIG_REQ to MGMTD for one or more config data item(s). * Send GET_CONFIG_REQ to MGMTD for one or more config data item(s).
@ -300,9 +300,9 @@ mgmt_fe_commit_config_data(uintptr_t lib_hndl, uintptr_t session_id,
* MGMTD_SUCCESS on success, MGMTD_* otherwise. * MGMTD_SUCCESS on success, MGMTD_* otherwise.
*/ */
extern enum mgmt_result extern enum mgmt_result
mgmt_fe_get_config_data(uintptr_t lib_hndl, uintptr_t session_id, mgmt_fe_get_config_data(uintptr_t lib_hndl, uint64_t session_id,
uint64_t req_id, Mgmtd__DatastoreId ds_id, uint64_t req_id, Mgmtd__DatastoreId ds_id,
Mgmtd__YangGetDataReq **data_req, int num_reqs); Mgmtd__YangGetDataReq **data_req, int num_reqs);
/* /*
* Send GET_DATA_REQ to MGMTD for one or more data item(s). * Send GET_DATA_REQ to MGMTD for one or more data item(s).
@ -310,10 +310,11 @@ mgmt_fe_get_config_data(uintptr_t lib_hndl, uintptr_t session_id,
* Similar to get config request but supports getting data * Similar to get config request but supports getting data
* from operational ds aka backend clients directly. * from operational ds aka backend clients directly.
*/ */
extern enum mgmt_result extern enum mgmt_result mgmt_fe_get_data(uintptr_t lib_hndl,
mgmt_fe_get_data(uintptr_t lib_hndl, uintptr_t session_id, uint64_t req_id, uint64_t session_id, uint64_t req_id,
Mgmtd__DatastoreId ds_id, Mgmtd__YangGetDataReq **data_req, Mgmtd__DatastoreId ds_id,
int num_reqs); Mgmtd__YangGetDataReq **data_req,
int num_reqs);
/* /*
* Send NOTIFY_REGISTER_REQ to MGMTD daemon. * Send NOTIFY_REGISTER_REQ to MGMTD daemon.
@ -343,10 +344,10 @@ mgmt_fe_get_data(uintptr_t lib_hndl, uintptr_t session_id, uint64_t req_id,
* MGMTD_SUCCESS on success, MGMTD_* otherwise. * MGMTD_SUCCESS on success, MGMTD_* otherwise.
*/ */
extern enum mgmt_result extern enum mgmt_result
mgmt_fe_register_yang_notify(uintptr_t lib_hndl, uintptr_t session_id, mgmt_fe_register_yang_notify(uintptr_t lib_hndl, uint64_t session_id,
uint64_t req_id, Mgmtd__DatastoreId ds_id, uint64_t req_id, Mgmtd__DatastoreId ds_id,
bool register_req, bool register_req, Mgmtd__YangDataXPath **data_req,
Mgmtd__YangDataXPath **data_req, int num_reqs); int num_reqs);
/* /*
* Destroy library and cleanup everything. * Destroy library and cleanup everything.

View File

@ -1633,6 +1633,8 @@ struct vty *vty_new(void)
new->pass_fd = -1; new->pass_fd = -1;
if (mgmt_lib_hndl) { if (mgmt_lib_hndl) {
if (!mgmt_client_id_next)
mgmt_client_id_next++;
new->mgmt_client_id = mgmt_client_id_next++; new->mgmt_client_id = mgmt_client_id_next++;
if (mgmt_fe_create_client_session( if (mgmt_fe_create_client_session(
mgmt_lib_hndl, new->mgmt_client_id, mgmt_lib_hndl, new->mgmt_client_id,

View File

@ -218,8 +218,8 @@ struct vty {
size_t frame_pos; size_t frame_pos;
char frame[1024]; char frame[1024];
uintptr_t mgmt_session_id; uint64_t mgmt_session_id; /* FE adapter identifies session w/ this */
uint64_t mgmt_client_id; uint64_t mgmt_client_id; /* FE vty client identifies w/ this ID */
uint64_t mgmt_req_id; uint64_t mgmt_req_id;
bool mgmt_req_pending; bool mgmt_req_pending;
bool mgmt_locked_candidate_ds; bool mgmt_locked_candidate_ds;

View File

@ -256,10 +256,15 @@ mgmt_fe_find_session_by_client_id(struct mgmt_fe_client_adapter *adapter,
struct mgmt_fe_session_ctx *session; struct mgmt_fe_session_ctx *session;
FOREACH_SESSION_IN_LIST (adapter, session) { FOREACH_SESSION_IN_LIST (adapter, session) {
if (session->client_id == client_id) if (session->client_id == client_id) {
MGMTD_FE_ADAPTER_DBG("Found session-id %" PRIu64
" using client-id %" PRIu64,
session->session_id, client_id);
return session; return session;
}
} }
MGMTD_FE_ADAPTER_DBG("Session not found using client-id %" PRIu64,
client_id);
return NULL; return NULL;
} }
@ -416,7 +421,7 @@ static int mgmt_fe_send_setcfg_reply(struct mgmt_fe_session_ctx *session,
fe_msg.setcfg_reply = &setcfg_reply; fe_msg.setcfg_reply = &setcfg_reply;
MGMTD_FE_ADAPTER_DBG( MGMTD_FE_ADAPTER_DBG(
"Sending SET_CONFIG_REPLY message to MGMTD Frontend client '%s'", "Sending SETCFG_REPLY message to MGMTD Frontend client '%s'",
session->adapter->name); session->adapter->name);
if (implicit_commit) { if (implicit_commit) {
@ -676,7 +681,7 @@ mgmt_fe_session_handle_lockds_req_msg(struct mgmt_fe_session_ctx *session,
struct mgmt_ds_ctx *ds_ctx; struct mgmt_ds_ctx *ds_ctx;
/* /*
* Next check first if the SET_CONFIG_REQ is for Candidate DS * Next check first if the SETCFG_REQ is for Candidate DS
* or not. Report failure if its not. MGMTD currently only * or not. Report failure if its not. MGMTD currently only
* supports editing the Candidate DS. * supports editing the Candidate DS.
*/ */
@ -745,7 +750,7 @@ mgmt_fe_session_handle_setcfg_req_msg(struct mgmt_fe_session_ctx *session,
gettimeofday(&session->adapter->setcfg_stats.last_start, NULL); gettimeofday(&session->adapter->setcfg_stats.last_start, NULL);
/* /*
* Next check first if the SET_CONFIG_REQ is for Candidate DS * Next check first if the SETCFG_REQ is for Candidate DS
* or not. Report failure if its not. MGMTD currently only * or not. Report failure if its not. MGMTD currently only
* supports editing the Candidate DS. * supports editing the Candidate DS.
*/ */
@ -903,7 +908,7 @@ mgmt_fe_session_handle_getcfg_req_msg(struct mgmt_fe_session_ctx *session,
} }
/* /*
* Next check first if the SET_CONFIG_REQ is for Candidate DS * Next check first if the GETCFG_REQ is for Candidate DS
* or not. Report failure if its not. MGMTD currently only * or not. Report failure if its not. MGMTD currently only
* supports editing the Candidate DS. * supports editing the Candidate DS.
*/ */
@ -1116,7 +1121,7 @@ static int mgmt_fe_session_handle_commit_config_req_msg(
} }
/* /*
* Next check first if the SET_CONFIG_REQ is for Candidate DS * Next check first if the COMMCFG_REQ is for Candidate DS
* or not. Report failure if its not. MGMTD currently only * or not. Report failure if its not. MGMTD currently only
* supports editing the Candidate DS. * supports editing the Candidate DS.
*/ */
@ -1144,8 +1149,8 @@ static int mgmt_fe_session_handle_commit_config_req_msg(
"Failed to create a Configuration session!"); "Failed to create a Configuration session!");
return 0; return 0;
} }
MGMTD_FE_ADAPTER_DBG("Created txn %" PRIu64 MGMTD_FE_ADAPTER_DBG("Created txn-id: %" PRIu64
" for session %" PRIu64 " for session-id %" PRIu64
" for COMMIT-CFG-REQ", " for COMMIT-CFG-REQ",
session->cfg_txn_id, session->session_id); session->cfg_txn_id, session->session_id);
} }
@ -1202,8 +1207,8 @@ mgmt_fe_adapter_handle_msg(struct mgmt_fe_client_adapter *adapter,
*/ */
switch ((int)fe_msg->message_case) { switch ((int)fe_msg->message_case) {
case MGMTD__FE_MESSAGE__MESSAGE_REGISTER_REQ: case MGMTD__FE_MESSAGE__MESSAGE_REGISTER_REQ:
MGMTD_FE_ADAPTER_DBG("Got Register Req Msg from '%s'", MGMTD_FE_ADAPTER_DBG("Got REGISTER_REQ from '%s'",
fe_msg->register_req->client_name); fe_msg->register_req->client_name);
if (strlen(fe_msg->register_req->client_name)) { if (strlen(fe_msg->register_req->client_name)) {
strlcpy(adapter->name, strlcpy(adapter->name,
@ -1217,9 +1222,9 @@ mgmt_fe_adapter_handle_msg(struct mgmt_fe_client_adapter *adapter,
&& fe_msg->session_req->id_case && fe_msg->session_req->id_case
== MGMTD__FE_SESSION_REQ__ID_CLIENT_CONN_ID) { == MGMTD__FE_SESSION_REQ__ID_CLIENT_CONN_ID) {
MGMTD_FE_ADAPTER_DBG( MGMTD_FE_ADAPTER_DBG(
"Got Session Create Req Msg for client-id %llu from '%s'", "Got SESSION_REQ (create) for client-id %" PRIu64
(unsigned long long) " from '%s'",
fe_msg->session_req->client_conn_id, fe_msg->session_req->client_conn_id,
adapter->name); adapter->name);
session = mgmt_fe_create_session( session = mgmt_fe_create_session(
@ -1231,10 +1236,9 @@ mgmt_fe_adapter_handle_msg(struct mgmt_fe_client_adapter *adapter,
&& fe_msg->session_req->id_case && fe_msg->session_req->id_case
== MGMTD__FE_SESSION_REQ__ID_SESSION_ID) { == MGMTD__FE_SESSION_REQ__ID_SESSION_ID) {
MGMTD_FE_ADAPTER_DBG( MGMTD_FE_ADAPTER_DBG(
"Got Session Destroy Req Msg for session-id %llu from '%s'", "Got SESSION_REQ (destroy) for session-id %" PRIu64
(unsigned long long) "from '%s'",
fe_msg->session_req->session_id, fe_msg->session_req->session_id, adapter->name);
adapter->name);
session = mgmt_session_id2ctx( session = mgmt_session_id2ctx(
fe_msg->session_req->session_id); fe_msg->session_req->session_id);
@ -1247,11 +1251,11 @@ mgmt_fe_adapter_handle_msg(struct mgmt_fe_client_adapter *adapter,
session = mgmt_session_id2ctx( session = mgmt_session_id2ctx(
fe_msg->lockds_req->session_id); fe_msg->lockds_req->session_id);
MGMTD_FE_ADAPTER_DBG( MGMTD_FE_ADAPTER_DBG(
"Got %sockDS Req Msg for DS:%d for session-id %llx from '%s'", "Got %sLOCKDS_REQ for DS:%d for session-id %" PRIu64
fe_msg->lockds_req->lock ? "L" : "Unl", " from '%s'",
fe_msg->lockds_req->lock ? "" : "UN",
fe_msg->lockds_req->ds_id, fe_msg->lockds_req->ds_id,
(unsigned long long)fe_msg->lockds_req->session_id, fe_msg->lockds_req->session_id, adapter->name);
adapter->name);
mgmt_fe_session_handle_lockds_req_msg( mgmt_fe_session_handle_lockds_req_msg(
session, fe_msg->lockds_req); session, fe_msg->lockds_req);
break; break;
@ -1260,12 +1264,12 @@ mgmt_fe_adapter_handle_msg(struct mgmt_fe_client_adapter *adapter,
fe_msg->setcfg_req->session_id); fe_msg->setcfg_req->session_id);
session->adapter->setcfg_stats.set_cfg_count++; session->adapter->setcfg_stats.set_cfg_count++;
MGMTD_FE_ADAPTER_DBG( MGMTD_FE_ADAPTER_DBG(
"Got Set Config Req Msg (%d Xpaths, Implicit:%c) on DS:%d for session-id %llu from '%s'", "Got SETCFG_REQ (%d Xpaths, Implicit:%c) on DS:%d for session-id %" PRIu64
" from '%s'",
(int)fe_msg->setcfg_req->n_data, (int)fe_msg->setcfg_req->n_data,
fe_msg->setcfg_req->implicit_commit ? 'T':'F', fe_msg->setcfg_req->implicit_commit ? 'T' : 'F',
fe_msg->setcfg_req->ds_id, fe_msg->setcfg_req->ds_id,
(unsigned long long)fe_msg->setcfg_req->session_id, fe_msg->setcfg_req->session_id, adapter->name);
adapter->name);
mgmt_fe_session_handle_setcfg_req_msg( mgmt_fe_session_handle_setcfg_req_msg(
session, fe_msg->setcfg_req); session, fe_msg->setcfg_req);
@ -1274,12 +1278,12 @@ mgmt_fe_adapter_handle_msg(struct mgmt_fe_client_adapter *adapter,
session = mgmt_session_id2ctx( session = mgmt_session_id2ctx(
fe_msg->commcfg_req->session_id); fe_msg->commcfg_req->session_id);
MGMTD_FE_ADAPTER_DBG( MGMTD_FE_ADAPTER_DBG(
"Got Commit Config Req Msg for src-DS:%d dst-DS:%d (Abort:%c) on session-id %llu from '%s'", "Got COMMCFG_REQ for src-DS:%d dst-DS:%d (Abort:%c) on session-id %" PRIu64
" from '%s'",
fe_msg->commcfg_req->src_ds_id, fe_msg->commcfg_req->src_ds_id,
fe_msg->commcfg_req->dst_ds_id, fe_msg->commcfg_req->dst_ds_id,
fe_msg->commcfg_req->abort ? 'T':'F', fe_msg->commcfg_req->abort ? 'T' : 'F',
(unsigned long long)fe_msg->commcfg_req->session_id, fe_msg->commcfg_req->session_id, adapter->name);
adapter->name);
mgmt_fe_session_handle_commit_config_req_msg( mgmt_fe_session_handle_commit_config_req_msg(
session, fe_msg->commcfg_req); session, fe_msg->commcfg_req);
break; break;
@ -1287,11 +1291,11 @@ mgmt_fe_adapter_handle_msg(struct mgmt_fe_client_adapter *adapter,
session = mgmt_session_id2ctx( session = mgmt_session_id2ctx(
fe_msg->getcfg_req->session_id); fe_msg->getcfg_req->session_id);
MGMTD_FE_ADAPTER_DBG( MGMTD_FE_ADAPTER_DBG(
"Got Get-Config Req Msg for DS:%d (xpaths: %d) on session-id %llu from '%s'", "Got GETCFG_REQ for DS:%d (xpaths: %d) on session-id %" PRIu64
" from '%s'",
fe_msg->getcfg_req->ds_id, fe_msg->getcfg_req->ds_id,
(int)fe_msg->getcfg_req->n_data, (int)fe_msg->getcfg_req->n_data,
(unsigned long long)fe_msg->getcfg_req->session_id, fe_msg->getcfg_req->session_id, adapter->name);
adapter->name);
mgmt_fe_session_handle_getcfg_req_msg( mgmt_fe_session_handle_getcfg_req_msg(
session, fe_msg->getcfg_req); session, fe_msg->getcfg_req);
break; break;
@ -1299,16 +1303,19 @@ mgmt_fe_adapter_handle_msg(struct mgmt_fe_client_adapter *adapter,
session = mgmt_session_id2ctx( session = mgmt_session_id2ctx(
fe_msg->getdata_req->session_id); fe_msg->getdata_req->session_id);
MGMTD_FE_ADAPTER_DBG( MGMTD_FE_ADAPTER_DBG(
"Got Get-Data Req Msg for DS:%d (xpaths: %d) on session-id %llu from '%s'", "Got GETDATA_REQ for DS:%d (xpaths: %d) on session-id %" PRIu64
" from '%s'",
fe_msg->getdata_req->ds_id, fe_msg->getdata_req->ds_id,
(int)fe_msg->getdata_req->n_data, (int)fe_msg->getdata_req->n_data,
(unsigned long long)fe_msg->getdata_req->session_id, fe_msg->getdata_req->session_id, adapter->name);
adapter->name);
mgmt_fe_session_handle_getdata_req_msg( mgmt_fe_session_handle_getdata_req_msg(
session, fe_msg->getdata_req); session, fe_msg->getdata_req);
break; break;
case MGMTD__FE_MESSAGE__MESSAGE_NOTIFY_DATA_REQ: case MGMTD__FE_MESSAGE__MESSAGE_NOTIFY_DATA_REQ:
case MGMTD__FE_MESSAGE__MESSAGE_REGNOTIFY_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);
/* /*
* TODO: Add handling code in future. * TODO: Add handling code in future.
*/ */
@ -1361,8 +1368,7 @@ void mgmt_fe_adapter_lock(struct mgmt_fe_client_adapter *adapter)
adapter->refcount++; adapter->refcount++;
} }
extern void extern void mgmt_fe_adapter_unlock(struct mgmt_fe_client_adapter **adapter)
mgmt_fe_adapter_unlock(struct mgmt_fe_client_adapter **adapter)
{ {
struct mgmt_fe_client_adapter *a = *adapter; struct mgmt_fe_client_adapter *a = *adapter;
assert(a && a->refcount); assert(a && a->refcount);