mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-25 20:08:40 +00:00
mgmtd: fix printing an empty data tree
We don't need to create an actual tree to print an empty tree, libyang handles NULL just fine. The actual problem is that `yang_dnode_new` creates a tree by validating it, and the validation creates all implicit default nodes. Therefore, when called with "with-default" flags, instead of getting an empty tree, we get a tree with all top-level default set. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
parent
e13c590abe
commit
dda5de0340
@ -1086,7 +1086,6 @@ static int fe_adapter_send_tree_data(struct mgmt_fe_session_ctx *session,
|
|||||||
|
|
||||||
{
|
{
|
||||||
struct mgmt_msg_tree_data *msg;
|
struct mgmt_msg_tree_data *msg;
|
||||||
struct lyd_node *empty = NULL;
|
|
||||||
uint8_t **darrp = NULL;
|
uint8_t **darrp = NULL;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
@ -1098,11 +1097,6 @@ static int fe_adapter_send_tree_data(struct mgmt_fe_session_ctx *session,
|
|||||||
msg->partial_error = partial_error;
|
msg->partial_error = partial_error;
|
||||||
msg->result_type = result_type;
|
msg->result_type = result_type;
|
||||||
|
|
||||||
if (!tree) {
|
|
||||||
empty = yang_dnode_new(ly_native_ctx, false);
|
|
||||||
tree = empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
darrp = mgmt_msg_native_get_darrp(msg);
|
darrp = mgmt_msg_native_get_darrp(msg);
|
||||||
ret = yang_print_tree_append(darrp, tree, result_type,
|
ret = yang_print_tree_append(darrp, tree, result_type,
|
||||||
(wd_options | LYD_PRINT_WITHSIBLINGS));
|
(wd_options | LYD_PRINT_WITHSIBLINGS));
|
||||||
@ -1125,8 +1119,6 @@ static int fe_adapter_send_tree_data(struct mgmt_fe_session_ctx *session,
|
|||||||
mgmt_msg_native_get_msg_len(msg),
|
mgmt_msg_native_get_msg_len(msg),
|
||||||
short_circuit_ok);
|
short_circuit_ok);
|
||||||
done:
|
done:
|
||||||
if (empty)
|
|
||||||
yang_dnode_free(empty);
|
|
||||||
mgmt_msg_native_free_msg(msg);
|
mgmt_msg_native_free_msg(msg);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user