Skip to content

Commit ef6584a

Browse files
committed
common UPDATE report NC SID in RPC notifications
Fixes sysrepo/sysrepo#3682
1 parent 7cc36cd commit ef6584a

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ module netopeer-notifications {
2626
description
2727
"Netopeer2 NETCONF server YANG notifications.";
2828

29+
revision "2025-10-10" {
30+
description
31+
"Added 'netconf-sid' node.";
32+
}
33+
2934
revision "2025-06-13" {
3035
description
3136
"Added 'netconf-user' and 'notification-stream' nodes.";
@@ -189,6 +194,13 @@ module netopeer-notifications {
189194
"Name of the executed RPC.";
190195
}
191196

197+
leaf netconf-sid {
198+
type uint32;
199+
mandatory true;
200+
description
201+
"NETCONF ID of the session executing the PRC.";
202+
}
203+
192204
leaf netconf-user {
193205
type string;
194206
mandatory true;

scripts/common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ NP2_MODULES=(
1212
1313
"[email protected] -e encode-xml -e replay -e subtree -e xpath"
1414
"[email protected] -e on-change"
15-
"netopeer-notifications@2025-06-13.yang"
15+
"netopeer-notifications@2025-10-10.yang"
1616
1717
1818
)

src/common.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ np_send_notif_confirmed_commit(const struct nc_session *session, sr_session_ctx_
580580
}
581581

582582
int
583-
np_send_notif_rpc(sr_session_ctx_t *sr_session, enum np_rpc_exec_stage stage, const char *rpc_name,
583+
np_send_notif_rpc(sr_session_ctx_t *sr_session, enum np_rpc_exec_stage stage, const char *rpc_name, uint32_t netconf_sid,
584584
const char *netconf_user, const char *ds_str, const struct lyd_node *filter_subtree, const char *filter_xpath,
585585
const char *sub_stream, uint32_t sr_timeout)
586586
{
@@ -631,6 +631,12 @@ np_send_notif_rpc(sr_session_ctx_t *sr_session, enum np_rpc_exec_stage stage, co
631631
goto cleanup;
632632
}
633633

634+
/* NETCONF SID */
635+
if (lyd_new_term_bin(notif, NULL, "netconf-sid", &netconf_sid, sizeof netconf_sid * 8, 0, NULL)) {
636+
rc = -1;
637+
goto cleanup;
638+
}
639+
634640
/* NETCONF user */
635641
if (lyd_new_term(notif, NULL, "netconf-user", netconf_user, 0, NULL)) {
636642
rc = -1;

src/common.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ enum np_rpc_exec_stage {
250250
* @param[in] sr_session Sysrepo session.
251251
* @param[in] stage RPC execution stage.
252252
* @param[in] rpc_name Executed RPC name.
253+
* @param[in] netconf_sid NETCONF SID of the session that executed the RPC.
253254
* @param[in] netconf_user NETCONF user that executed the RPC.
254255
* @param[in] ds_str Optional relevant RPC datastore.
255256
* @param[in] filter_subtree Optional RPC subtree filter.
@@ -260,8 +261,8 @@ enum np_rpc_exec_stage {
260261
* @return -1 on error.
261262
*/
262263
int np_send_notif_rpc(sr_session_ctx_t *sr_session, enum np_rpc_exec_stage stage, const char *rpc_name,
263-
const char *netconf_user, const char *ds_str, const struct lyd_node *filter_subtree, const char *filter_xpath,
264-
const char *sub_stream, uint32_t sr_timeout);
264+
uint32_t netconf_sid, const char *netconf_user, const char *ds_str, const struct lyd_node *filter_subtree,
265+
const char *filter_xpath, const char *sub_stream, uint32_t sr_timeout);
265266

266267
/**
267268
* @brief NP2 callback for acquiring context.

src/main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,8 @@ np2srv_rpc_cb(struct lyd_node *rpc, struct nc_session *ncs)
378378
np_rpc_get_stream(rpc, &sub_stream);
379379

380380
/* pre-NETCONF RPC */
381-
np_send_notif_rpc(user_sess->sess, NP_RPC_STAGE_PRE, LYD_NAME(rpc), nc_session_get_username(ncs), ds_str,
382-
filter_subtree, filter_xpath, sub_stream, np2srv.sr_timeout);
381+
np_send_notif_rpc(user_sess->sess, NP_RPC_STAGE_PRE, LYD_NAME(rpc), nc_session_get_id(ncs),
382+
nc_session_get_username(ncs), ds_str, filter_subtree, filter_xpath, sub_stream, np2srv.sr_timeout);
383383

384384
/* netopeer2 RPC execution */
385385
reply = rpc_cb(rpc, user_sess);
@@ -390,8 +390,8 @@ np2srv_rpc_cb(struct lyd_node *rpc, struct nc_session *ncs)
390390
/* post-NETCONF RPC */
391391
rpl_type = nc_server_reply_type(reply);
392392
np_send_notif_rpc(user_sess->sess, (rpl_type == NC_RPL_ERROR) ? NP_RPC_STAGE_POST_FAIL : NP_RPC_STAGE_POST_SUCCESS,
393-
LYD_NAME(rpc), nc_session_get_username(ncs), ds_str, filter_subtree, filter_xpath, sub_stream,
394-
np2srv.sr_timeout);
393+
LYD_NAME(rpc), nc_session_get_id(ncs), nc_session_get_username(ncs), ds_str, filter_subtree,
394+
filter_xpath, sub_stream, np2srv.sr_timeout);
395395
} else {
396396
/* sysrepo RPC, use the default timeout or slightly higher than the configured one */
397397
rc = sr_rpc_send_tree(user_sess->sess, rpc, np2srv.sr_timeout ? np2srv.sr_timeout + 2000 : 0, &output);

0 commit comments

Comments
 (0)