tree data BUGFIX ext node callback for implicit nodes
diff --git a/src/parser_json.c b/src/parser_json.c
index 82275b6..79b62a9 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -1402,7 +1402,8 @@
 
                 /* add any missing default children */
                 ret = lyd_new_implicit_r(*node, lyd_node_child_p(*node), NULL, NULL, &lydctx->node_when,
-                        &lydctx->node_types, (lydctx->val_opts & LYD_VALIDATE_NO_STATE) ? LYD_IMPLICIT_NO_STATE : 0, NULL);
+                        &lydctx->node_types, &lydctx->ext_node,
+                        (lydctx->val_opts & LYD_VALIDATE_NO_STATE) ? LYD_IMPLICIT_NO_STATE : 0, NULL);
                 LY_CHECK_ERR_RET(ret, LOG_LOCBACK(1, 1, 0, 0), ret);
             }
 
diff --git a/src/parser_lyb.c b/src/parser_lyb.c
index fb7d3a1..ddfb5c0 100644
--- a/src/parser_lyb.c
+++ b/src/parser_lyb.c
@@ -1079,7 +1079,7 @@
         /* add any missing default children */
         impl_opts = (lybctx->val_opts & LYD_VALIDATE_NO_STATE) ? LYD_IMPLICIT_NO_STATE : 0;
         ret = lyd_new_implicit_r(node, lyd_node_child_p(node), NULL, NULL, &lybctx->node_when, &lybctx->node_types,
-                impl_opts, NULL);
+                &lybctx->ext_node, impl_opts, NULL);
         LY_CHECK_RET(ret);
     }
 
diff --git a/src/parser_xml.c b/src/parser_xml.c
index da43b40..a321280 100644
--- a/src/parser_xml.c
+++ b/src/parser_xml.c
@@ -779,7 +779,7 @@
 
             /* add any missing default children */
             ret = lyd_new_implicit_r(node, lyd_node_child_p(node), NULL, NULL, &lydctx->node_when, &lydctx->node_types,
-                    (lydctx->val_opts & LYD_VALIDATE_NO_STATE) ? LYD_IMPLICIT_NO_STATE : 0, NULL);
+                    &lydctx->ext_node, (lydctx->val_opts & LYD_VALIDATE_NO_STATE) ? LYD_IMPLICIT_NO_STATE : 0, NULL);
             LY_CHECK_GOTO(ret, error);
         }
 
diff --git a/src/tree_data_internal.h b/src/tree_data_internal.h
index 8450580..97b0f53 100644
--- a/src/tree_data_internal.h
+++ b/src/tree_data_internal.h
@@ -345,13 +345,14 @@
  * @param[in] mod Module of the default values, NULL for nested siblings.
  * @param[in] node_when Optional set to add nodes with "when" conditions into.
  * @param[in] node_types Optional set to add nodes with unresolved types into.
+ * @param[in] ext_node Optional set to add nodes with extension instance node callbacks into.
  * @param[in] impl_opts Implicit options (@ref implicitoptions).
  * @param[in,out] diff Validation diff.
  * @return LY_ERR value.
  */
 LY_ERR lyd_new_implicit_r(struct lyd_node *parent, struct lyd_node **first, const struct lysc_node *sparent,
-        const struct lys_module *mod, struct ly_set *node_when, struct ly_set *node_types, uint32_t impl_opts,
-        struct lyd_node **diff);
+        const struct lys_module *mod, struct ly_set *node_when, struct ly_set *node_types, struct ly_set *ext_node,
+        uint32_t impl_opts, struct lyd_node **diff);
 
 /**
  * @brief Find the next node, before which to insert the new node.
diff --git a/src/tree_data_new.c b/src/tree_data_new.c
index 04fc32c..5a93324 100644
--- a/src/tree_data_new.c
+++ b/src/tree_data_new.c
@@ -1560,8 +1560,8 @@
 
 LY_ERR
 lyd_new_implicit_r(struct lyd_node *parent, struct lyd_node **first, const struct lysc_node *sparent,
-        const struct lys_module *mod, struct ly_set *node_when, struct ly_set *node_types, uint32_t impl_opts,
-        struct lyd_node **diff)
+        const struct lys_module *mod, struct ly_set *node_when, struct ly_set *node_types, struct ly_set *ext_node,
+        uint32_t impl_opts, struct lyd_node **diff)
 {
     LY_ERR ret;
     const struct lysc_node *iter = NULL;
@@ -1594,12 +1594,12 @@
             if (!node && ((struct lysc_node_choice *)iter)->dflt) {
                 /* create default case data */
                 LY_CHECK_RET(lyd_new_implicit_r(parent, first, &((struct lysc_node_choice *)iter)->dflt->node,
-                        NULL, node_when, node_types, impl_opts, diff));
+                        NULL, node_when, node_types, ext_node, impl_opts, diff));
             } else if (node) {
                 /* create any default data in the existing case */
                 assert(node->schema->parent->nodetype == LYS_CASE);
                 LY_CHECK_RET(lyd_new_implicit_r(parent, first, node->schema->parent, NULL, node_when, node_types,
-                        impl_opts, diff));
+                        ext_node, impl_opts, diff));
             }
             break;
         case LYS_CONTAINER:
@@ -1613,6 +1613,10 @@
                     /* remember to resolve when */
                     LY_CHECK_RET(ly_set_add(node_when, node, 1, NULL));
                 }
+                if (ext_node) {
+                    /* store for ext instance node validation, if needed */
+                    LY_CHECK_RET(lyd_validate_node_ext(node, ext_node));
+                }
                 if (diff) {
                     /* add into diff */
                     LY_CHECK_RET(lyd_val_diff_add(node, LYD_DIFF_OP_CREATE, diff));
@@ -1620,7 +1624,7 @@
 
                 /* create any default children */
                 LY_CHECK_RET(lyd_new_implicit_r(node, lyd_node_child_p(node), NULL, NULL, node_when, node_types,
-                        impl_opts, diff));
+                        ext_node, impl_opts, diff));
             }
             break;
         case LYS_LEAF:
@@ -1643,6 +1647,10 @@
                     /* remember to resolve when */
                     LY_CHECK_RET(ly_set_add(node_when, node, 1, NULL));
                 }
+                if (ext_node) {
+                    /* store for ext instance node validation, if needed */
+                    LY_CHECK_RET(lyd_validate_node_ext(node, ext_node));
+                }
                 if (diff) {
                     /* add into diff */
                     LY_CHECK_RET(lyd_val_diff_add(node, LYD_DIFF_OP_CREATE, diff));
@@ -1671,6 +1679,10 @@
                         /* remember to resolve when */
                         LY_CHECK_RET(ly_set_add(node_when, node, 1, NULL));
                     }
+                    if (ext_node) {
+                        /* store for ext instance node validation, if needed */
+                        LY_CHECK_RET(lyd_validate_node_ext(node, ext_node));
+                    }
                     if (diff) {
                         /* add into diff */
                         LY_CHECK_RET(lyd_val_diff_add(node, LYD_DIFF_OP_CREATE, diff));
@@ -1704,7 +1716,7 @@
         if (((node->flags & (LYD_DEFAULT | LYD_NEW)) != (LYD_DEFAULT | LYD_NEW)) &&
                 (node->schema->nodetype & LYD_NODE_INNER)) {
             LY_CHECK_GOTO(ret = lyd_new_implicit_r(node, lyd_node_child_p(node), NULL, NULL, &node_when, NULL,
-                    implicit_options, diff), cleanup);
+                    NULL, implicit_options, diff), cleanup);
         }
 
         LYD_TREE_DFS_END(tree, node);
@@ -1778,11 +1790,12 @@
     }
 
     /* add all top-level defaults for this module */
-    LY_CHECK_GOTO(ret = lyd_new_implicit_r(NULL, tree, NULL, module, &node_when, NULL, implicit_options, diff), cleanup);
+    LY_CHECK_GOTO(ret = lyd_new_implicit_r(NULL, tree, NULL, module, &node_when, NULL, NULL, implicit_options, diff),
+            cleanup);
 
     /* resolve when and remove any invalid defaults */
-    LY_CHECK_GOTO(ret = lyd_validate_unres(tree, module, 0, &node_when, LYXP_IGNORE_WHEN, NULL, NULL, NULL, NULL, 0, diff),
-            cleanup);
+    LY_CHECK_GOTO(ret = lyd_validate_unres(tree, module, 0, &node_when, LYXP_IGNORE_WHEN, NULL, NULL, NULL, NULL,
+            0, diff), cleanup);
 
     /* process nested nodes */
     LY_LIST_FOR(*tree, root) {
diff --git a/src/validation.c b/src/validation.c
index b95d0b2..d86b391 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -1551,7 +1551,7 @@
             LY_CHECK_RET(lyd_validate_new(lyd_node_child_p(node), node->schema, NULL, diff));
 
             /* add nested defaults */
-            LY_CHECK_RET(lyd_new_implicit_r(node, lyd_node_child_p(node), NULL, NULL, NULL, NULL, impl_opts, diff));
+            LY_CHECK_RET(lyd_new_implicit_r(node, lyd_node_child_p(node), NULL, NULL, NULL, NULL, NULL, impl_opts, diff));
         }
 
         if (lysc_has_when(node->schema)) {
@@ -1613,7 +1613,8 @@
         /* add all top-level defaults for this module, if going to validate subtree, do not add into unres sets
          * (lyd_validate_subtree() adds all the nodes in that case) */
         ret = lyd_new_implicit_r(NULL, first2, NULL, mod, validate_subtree ? NULL : node_when_p,
-                validate_subtree ? NULL : node_types_p, (val_opts & LYD_VALIDATE_NO_STATE) ? LYD_IMPLICIT_NO_STATE : 0, diff);
+                validate_subtree ? NULL : node_types_p, validate_subtree ? NULL : ext_node_p,
+                (val_opts & LYD_VALIDATE_NO_STATE) ? LYD_IMPLICIT_NO_STATE : 0, diff);
         LY_CHECK_GOTO(ret, cleanup);
 
         /* our first module node pointer may no longer be the first */
@@ -1804,7 +1805,7 @@
     if (int_opts & LYD_INTOPT_REPLY) {
         /* add output children defaults */
         rc = lyd_new_implicit_r(op_node, lyd_node_child_p(op_node), NULL, NULL, node_when_p, node_types_p,
-                LYD_IMPLICIT_OUTPUT, diff);
+                ext_node_p, LYD_IMPLICIT_OUTPUT, diff);
         LY_CHECK_GOTO(rc, cleanup);
 
         if (validate_subtree) {