]> git.puffer.fish Git - mirror/frr.git/commitdiff
mgmtd: fix printing an empty data tree
authorIgor Ryzhov <iryzhov@nfware.com>
Sun, 28 Jan 2024 00:35:14 +0000 (02:35 +0200)
committerIgor Ryzhov <iryzhov@nfware.com>
Wed, 31 Jan 2024 00:20:13 +0000 (02:20 +0200)
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>
mgmtd/mgmt_fe_adapter.c

index 5dd6a7001256212c867e7a12e308f6e1a046e17c..23f2e5368ef176e3d4ab8bd09a2f340ad6ccbaab 100644 (file)
@@ -1086,7 +1086,6 @@ static int fe_adapter_send_tree_data(struct mgmt_fe_session_ctx *session,
 
 {
        struct mgmt_msg_tree_data *msg;
-       struct lyd_node *empty = NULL;
        uint8_t **darrp = NULL;
        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->result_type = result_type;
 
-       if (!tree) {
-               empty = yang_dnode_new(ly_native_ctx, false);
-               tree = empty;
-       }
-
        darrp = mgmt_msg_native_get_darrp(msg);
        ret = yang_print_tree_append(darrp, tree, result_type,
                                     (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),
                                         short_circuit_ok);
 done:
-       if (empty)
-               yang_dnode_free(empty);
        mgmt_msg_native_free_msg(msg);
 
        return ret;