diff options
author | Christian Hopps <chopps@labn.net> | 2023-10-30 10:09:19 +0100 |
---|---|---|
committer | Christian Hopps <chopps@labn.net> | 2023-12-28 18:52:57 +0100 |
commit | ad1ccb6e621b2050697e738457b1ac7a465dae71 (patch) | |
tree | 5e34071091dcb91acf503bcdb892f00f18fb2c8c /lib/northbound_cli.c | |
parent | lib: darr: add ability to set MTYPE for dynamic arrays (diff) | |
download | frr-ad1ccb6e621b2050697e738457b1ac7a465dae71.tar.xz frr-ad1ccb6e621b2050697e738457b1ac7a465dae71.zip |
lib: northbound: add yielding and batching to oper-state queries
Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'lib/northbound_cli.c')
-rw-r--r-- | lib/northbound_cli.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/northbound_cli.c b/lib/northbound_cli.c index cba40035a..20f030e28 100644 --- a/lib/northbound_cli.c +++ b/lib/northbound_cli.c @@ -1437,11 +1437,9 @@ static int nb_cli_oper_data_cb(const struct lysc_node *snode, } exit: - yang_data_free(data); return NB_OK; error: - yang_data_free(data); return NB_ERR; } @@ -1490,9 +1488,14 @@ DEFPY (show_yang_operational_data, ly_ctx = ly_native_ctx; /* Obtain data. */ - dnode = yang_dnode_new(ly_ctx, false); - ret = nb_oper_data_iterate(xpath, translator, 0, nb_cli_oper_data_cb, - dnode, NULL); + if (translator) { + dnode = yang_dnode_new(ly_ctx, false); + ret = nb_oper_iterate_legacy(xpath, translator, 0, + nb_cli_oper_data_cb, dnode, NULL); + } else { + dnode = NULL; + ret = nb_oper_iterate_legacy(xpath, NULL, 0, NULL, NULL, &dnode); + } if (ret != NB_OK) { if (format == LYD_JSON) vty_out(vty, "{}\n"); @@ -1500,7 +1503,8 @@ DEFPY (show_yang_operational_data, /* embed ly_last_errmsg() when we get newer libyang */ vty_out(vty, "<!-- Not found -->\n"); } - yang_dnode_free(dnode); + if (dnode) + yang_dnode_free(dnode); return CMD_WARNING; } |