]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/northbound.c
Merge pull request #5104 from opensourcerouting/route-map-nbv2
[mirror_frr.git] / lib / northbound.c
index a814f23e14421d0b65a832d7fc4e5b33758c234a..206a88d9800650d4de56b753f73fe90c4d93771e 100644 (file)
@@ -64,6 +64,9 @@ static bool transaction_in_progress;
 
 static int nb_callback_configuration(const enum nb_event event,
                                     struct nb_config_change *change);
+static void nb_log_callback(const enum nb_event event,
+                           enum nb_operation operation, const char *xpath,
+                           const char *value);
 static struct nb_transaction *nb_transaction_new(struct nb_config *config,
                                                 struct nb_config_cbs *changes,
                                                 enum nb_client client,
@@ -180,7 +183,18 @@ static int nb_node_validate_cb(const struct nb_node *nb_node,
 
        valid = nb_operation_is_valid(operation, nb_node->snode);
 
-       if (!valid && callback_implemented)
+       /*
+        * Add an exception for operational data callbacks. A rw list usually
+        * doesn't need any associated operational data callbacks. But if this
+        * rw list is augmented by another module which adds state nodes under
+        * it, then this list will need to have the 'get_next()', 'get_keys()'
+        * and 'lookup_entry()' callbacks. As such, never log a warning when
+        * these callbacks are implemented when they are not needed, since this
+        * depends on context (e.g. some daemons might augment "frr-interface"
+        * while others don't).
+        */
+       if (!valid && callback_implemented && operation != NB_OP_GET_NEXT
+           && operation != NB_OP_GET_KEYS && operation != NB_OP_LOOKUP_ENTRY)
                flog_warn(EC_LIB_NB_CB_UNNEEDED,
                          "unneeded '%s' callback for '%s'",
                          nb_operation_name(operation), nb_node->xpath);
@@ -211,6 +225,8 @@ static unsigned int nb_node_validate_cbs(const struct nb_node *nb_node)
                                     !!nb_node->cbs.destroy, false);
        error += nb_node_validate_cb(nb_node, NB_OP_MOVE, !!nb_node->cbs.move,
                                     false);
+       error += nb_node_validate_cb(nb_node, NB_OP_PRE_VALIDATE,
+                                    !!nb_node->cbs.pre_validate, true);
        error += nb_node_validate_cb(nb_node, NB_OP_APPLY_FINISH,
                                     !!nb_node->cbs.apply_finish, true);
        error += nb_node_validate_cb(nb_node, NB_OP_GET_ELEM,
@@ -265,7 +281,6 @@ struct nb_config *nb_config_new(struct lyd_node *dnode)
        else
                config->dnode = yang_dnode_new(ly_native_ctx, true);
        config->version = 0;
-       pthread_rwlock_init(&config->lock, NULL);
 
        return config;
 }
@@ -274,7 +289,6 @@ void nb_config_free(struct nb_config *config)
 {
        if (config->dnode)
                yang_dnode_free(config->dnode);
-       pthread_rwlock_destroy(&config->lock);
        XFREE(MTYPE_NB_CONFIG, config);
 }
 
@@ -285,7 +299,6 @@ struct nb_config *nb_config_dup(const struct nb_config *config)
        dup = XCALLOC(MTYPE_NB_CONFIG, sizeof(*dup));
        dup->dnode = yang_dnode_dup(config->dnode);
        dup->version = config->version;
-       pthread_rwlock_init(&dup->lock, NULL);
 
        return dup;
 }
@@ -335,23 +348,39 @@ static inline int nb_config_cb_compare(const struct nb_config_cb *a,
                return 1;
 
        /*
-        * Use XPath as a tie-breaker. This will naturally sort parent nodes
-        * before their children.
+        * Preserve the order of the configuration changes as told by libyang.
         */
-       return strcmp(a->xpath, b->xpath);
+       if (a->seq < b->seq)
+               return -1;
+       if (a->seq > b->seq)
+               return 1;
+
+       /*
+        * All 'apply_finish' callbacks have their sequence number set to zero.
+        * In this case, compare them using their dnode pointers (the order
+        * doesn't matter for callbacks that have the same priority).
+        */
+       if (a->dnode < b->dnode)
+               return -1;
+       if (a->dnode > b->dnode)
+               return 1;
+
+       return 0;
 }
 RB_GENERATE(nb_config_cbs, nb_config_cb, entry, nb_config_cb_compare);
 
 static void nb_config_diff_add_change(struct nb_config_cbs *changes,
                                      enum nb_operation operation,
+                                     uint32_t *seq,
                                      const struct lyd_node *dnode)
 {
        struct nb_config_change *change;
 
        change = XCALLOC(MTYPE_TMP, sizeof(*change));
        change->cb.operation = operation;
+       change->cb.seq = *seq;
+       *seq = *seq + 1;
        change->cb.nb_node = dnode->schema->priv;
-       yang_dnode_get_path(dnode, change->cb.xpath, sizeof(change->cb.xpath));
        change->cb.dnode = dnode;
 
        RB_INSERT(nb_config_cbs, changes, &change->cb);
@@ -374,7 +403,7 @@ static void nb_config_diff_del_changes(struct nb_config_cbs *changes)
  * configurations. Given a new subtree, calculate all new YANG data nodes,
  * excluding default leafs and leaf-lists. This is a recursive function.
  */
-static void nb_config_diff_created(const struct lyd_node *dnode,
+static void nb_config_diff_created(const struct lyd_node *dnode, uint32_t *seq,
                                   struct nb_config_cbs *changes)
 {
        enum nb_operation operation;
@@ -393,16 +422,17 @@ static void nb_config_diff_created(const struct lyd_node *dnode,
                else
                        return;
 
-               nb_config_diff_add_change(changes, operation, dnode);
+               nb_config_diff_add_change(changes, operation, seq, dnode);
                break;
        case LYS_CONTAINER:
        case LYS_LIST:
                if (nb_operation_is_valid(NB_OP_CREATE, dnode->schema))
-                       nb_config_diff_add_change(changes, NB_OP_CREATE, dnode);
+                       nb_config_diff_add_change(changes, NB_OP_CREATE, seq,
+                                                 dnode);
 
                /* Process child nodes recursively. */
                LY_TREE_FOR (dnode->child, child) {
-                       nb_config_diff_created(child, changes);
+                       nb_config_diff_created(child, seq, changes);
                }
                break;
        default:
@@ -410,11 +440,11 @@ static void nb_config_diff_created(const struct lyd_node *dnode,
        }
 }
 
-static void nb_config_diff_deleted(const struct lyd_node *dnode,
+static void nb_config_diff_deleted(const struct lyd_node *dnode, uint32_t *seq,
                                   struct nb_config_cbs *changes)
 {
        if (nb_operation_is_valid(NB_OP_DESTROY, dnode->schema))
-               nb_config_diff_add_change(changes, NB_OP_DESTROY, dnode);
+               nb_config_diff_add_change(changes, NB_OP_DESTROY, seq, dnode);
        else if (CHECK_FLAG(dnode->schema->nodetype, LYS_CONTAINER)) {
                struct lyd_node *child;
 
@@ -425,7 +455,7 @@ static void nb_config_diff_deleted(const struct lyd_node *dnode,
                 * when applicable (i.e. optional nodes).
                 */
                LY_TREE_FOR (dnode->child, child) {
-                       nb_config_diff_deleted(child, changes);
+                       nb_config_diff_deleted(child, seq, changes);
                }
        }
 }
@@ -436,6 +466,7 @@ static void nb_config_diff(const struct nb_config *config1,
                           struct nb_config_cbs *changes)
 {
        struct lyd_difflist *diff;
+       uint32_t seq = 0;
 
        diff = lyd_diff(config1->dnode, config2->dnode,
                        LYD_DIFFOPT_WITHDEFAULTS);
@@ -450,15 +481,16 @@ static void nb_config_diff(const struct nb_config *config1,
                switch (type) {
                case LYD_DIFF_CREATED:
                        dnode = diff->second[i];
-                       nb_config_diff_created(dnode, changes);
+                       nb_config_diff_created(dnode, &seq, changes);
                        break;
                case LYD_DIFF_DELETED:
                        dnode = diff->first[i];
-                       nb_config_diff_deleted(dnode, changes);
+                       nb_config_diff_deleted(dnode, &seq, changes);
                        break;
                case LYD_DIFF_CHANGED:
                        dnode = diff->second[i];
-                       nb_config_diff_add_change(changes, NB_OP_MODIFY, dnode);
+                       nb_config_diff_add_change(changes, NB_OP_MODIFY, &seq,
+                                                 dnode);
                        break;
                case LYD_DIFF_MOVEDAFTER1:
                case LYD_DIFF_MOVEDAFTER2:
@@ -498,17 +530,6 @@ int nb_candidate_edit(struct nb_config *candidate,
                                  __func__);
                        return NB_ERR;
                }
-
-               /*
-                * If a new node was created, call lyd_validate() only to create
-                * default child nodes.
-                */
-               if (dnode) {
-                       lyd_schema_sort(dnode, 0);
-                       lyd_validate(&dnode,
-                                    LYD_OPT_CONFIG | LYD_OPT_WHENAUTODEL,
-                                    ly_native_ctx);
-               }
                break;
        case NB_OP_DESTROY:
                dnode = yang_dnode_get(candidate->dnode, xpath_edit);
@@ -535,28 +556,17 @@ int nb_candidate_edit(struct nb_config *candidate,
 
 bool nb_candidate_needs_update(const struct nb_config *candidate)
 {
-       bool ret = false;
-
-       pthread_rwlock_rdlock(&running_config->lock);
-       {
-               if (candidate->version < running_config->version)
-                       ret = true;
-       }
-       pthread_rwlock_unlock(&running_config->lock);
+       if (candidate->version < running_config->version)
+               return true;
 
-       return ret;
+       return false;
 }
 
 int nb_candidate_update(struct nb_config *candidate)
 {
        struct nb_config *updated_config;
 
-       pthread_rwlock_rdlock(&running_config->lock);
-       {
-               updated_config = nb_config_dup(running_config);
-       }
-       pthread_rwlock_unlock(&running_config->lock);
-
+       updated_config = nb_config_dup(running_config);
        if (nb_config_merge(updated_config, candidate, true) != NB_OK)
                return NB_ERR;
 
@@ -583,14 +593,45 @@ static int nb_candidate_validate_yang(struct nb_config *candidate)
 }
 
 /* Perform code-level validation using the northbound callbacks. */
-static int nb_candidate_validate_changes(struct nb_config *candidate,
-                                        struct nb_config_cbs *changes)
+static int nb_candidate_validate_code(struct nb_config *candidate,
+                                     struct nb_config_cbs *changes)
 {
        struct nb_config_cb *cb;
+       struct lyd_node *root, *next, *child;
+       int ret;
+
+       /* First validate the candidate as a whole. */
+       LY_TREE_FOR (candidate->dnode, root) {
+               LY_TREE_DFS_BEGIN (root, next, child) {
+                       struct nb_node *nb_node;
+
+                       nb_node = child->schema->priv;
+                       if (!nb_node->cbs.pre_validate)
+                               goto next;
 
+                       if (DEBUG_MODE_CHECK(&nb_dbg_cbs_config,
+                                            DEBUG_MODE_ALL)) {
+                               char xpath[XPATH_MAXLEN];
+
+                               yang_dnode_get_path(child, xpath,
+                                                   sizeof(xpath));
+                               nb_log_callback(NB_EV_VALIDATE,
+                                               NB_OP_PRE_VALIDATE, xpath,
+                                               NULL);
+                       }
+
+                       ret = (*nb_node->cbs.pre_validate)(child);
+                       if (ret != NB_OK)
+                               return NB_ERR_VALIDATION;
+
+               next:
+                       LY_TREE_DFS_END(root, next, child);
+               }
+       }
+
+       /* Now validate the configuration changes. */
        RB_FOREACH (cb, nb_config_cbs, changes) {
                struct nb_config_change *change = (struct nb_config_change *)cb;
-               int ret;
 
                ret = nb_callback_configuration(NB_EV_VALIDATE, change);
                if (ret != NB_OK)
@@ -609,13 +650,9 @@ int nb_candidate_validate(struct nb_config *candidate)
                return NB_ERR_VALIDATION;
 
        RB_INIT(nb_config_cbs, &changes);
-       pthread_rwlock_rdlock(&running_config->lock);
-       {
-               nb_config_diff(running_config, candidate, &changes);
-               ret = nb_candidate_validate_changes(candidate, &changes);
-               nb_config_diff_del_changes(&changes);
-       }
-       pthread_rwlock_unlock(&running_config->lock);
+       nb_config_diff(running_config, candidate, &changes);
+       ret = nb_candidate_validate_code(candidate, &changes);
+       nb_config_diff_del_changes(&changes);
 
        return ret;
 }
@@ -635,36 +672,26 @@ int nb_candidate_commit_prepare(struct nb_config *candidate,
        }
 
        RB_INIT(nb_config_cbs, &changes);
-       pthread_rwlock_rdlock(&running_config->lock);
-       {
-               nb_config_diff(running_config, candidate, &changes);
-               if (RB_EMPTY(nb_config_cbs, &changes)) {
-                       pthread_rwlock_unlock(&running_config->lock);
-                       return NB_ERR_NO_CHANGES;
-               }
+       nb_config_diff(running_config, candidate, &changes);
+       if (RB_EMPTY(nb_config_cbs, &changes))
+               return NB_ERR_NO_CHANGES;
 
-               if (nb_candidate_validate_changes(candidate, &changes)
-                   != NB_OK) {
-                       flog_warn(
-                               EC_LIB_NB_CANDIDATE_INVALID,
-                               "%s: failed to validate candidate configuration",
-                               __func__);
-                       nb_config_diff_del_changes(&changes);
-                       pthread_rwlock_unlock(&running_config->lock);
-                       return NB_ERR_VALIDATION;
-               }
+       if (nb_candidate_validate_code(candidate, &changes) != NB_OK) {
+               flog_warn(EC_LIB_NB_CANDIDATE_INVALID,
+                         "%s: failed to validate candidate configuration",
+                         __func__);
+               nb_config_diff_del_changes(&changes);
+               return NB_ERR_VALIDATION;
+       }
 
-               *transaction = nb_transaction_new(candidate, &changes, client,
-                                                 user, comment);
-               if (*transaction == NULL) {
-                       flog_warn(EC_LIB_NB_TRANSACTION_CREATION_FAILED,
-                                 "%s: failed to create transaction", __func__);
-                       nb_config_diff_del_changes(&changes);
-                       pthread_rwlock_unlock(&running_config->lock);
-                       return NB_ERR_LOCKED;
-               }
+       *transaction =
+               nb_transaction_new(candidate, &changes, client, user, comment);
+       if (*transaction == NULL) {
+               flog_warn(EC_LIB_NB_TRANSACTION_CREATION_FAILED,
+                         "%s: failed to create transaction", __func__);
+               nb_config_diff_del_changes(&changes);
+               return NB_ERR_LOCKED;
        }
-       pthread_rwlock_unlock(&running_config->lock);
 
        return nb_transaction_process(NB_EV_PREPARE, *transaction);
 }
@@ -683,11 +710,7 @@ void nb_candidate_commit_apply(struct nb_transaction *transaction,
 
        /* Replace running by candidate. */
        transaction->config->version++;
-       pthread_rwlock_wrlock(&running_config->lock);
-       {
-               nb_config_replace(running_config, transaction->config, true);
-       }
-       pthread_rwlock_unlock(&running_config->lock);
+       nb_config_replace(running_config, transaction->config, true);
 
        /* Record transaction. */
        if (save_transaction
@@ -786,7 +809,7 @@ static int nb_callback_configuration(const enum nb_event event,
                                     struct nb_config_change *change)
 {
        enum nb_operation operation = change->cb.operation;
-       const char *xpath = change->cb.xpath;
+       char xpath[XPATH_MAXLEN];
        const struct nb_node *nb_node = change->cb.nb_node;
        const struct lyd_node *dnode = change->cb.dnode;
        union nb_resource *resource;
@@ -798,6 +821,7 @@ static int nb_callback_configuration(const enum nb_event event,
                if (dnode && !yang_snode_is_typeless_data(dnode->schema))
                        value = yang_dnode_get_string(dnode, NULL);
 
+               yang_dnode_get_path(dnode, xpath, sizeof(xpath));
                nb_log_callback(event, operation, xpath, value);
        }
 
@@ -820,6 +844,7 @@ static int nb_callback_configuration(const enum nb_event event,
                ret = (*nb_node->cbs.move)(event, dnode);
                break;
        default:
+               yang_dnode_get_path(dnode, xpath, sizeof(xpath));
                flog_err(EC_LIB_DEVELOPMENT,
                         "%s: unknown operation (%u) [xpath %s]", __func__,
                         operation, xpath);
@@ -830,6 +855,8 @@ static int nb_callback_configuration(const enum nb_event event,
                int priority;
                enum lib_log_refs ref;
 
+               yang_dnode_get_path(dnode, xpath, sizeof(xpath));
+
                switch (event) {
                case NB_EV_VALIDATE:
                        priority = LOG_WARNING;
@@ -961,65 +988,51 @@ static int nb_transaction_process(enum nb_event event,
 {
        struct nb_config_cb *cb;
 
-       /*
-        * Need to lock the running configuration since transaction->changes
-        * can contain pointers to data nodes from the running configuration.
-        */
-       pthread_rwlock_rdlock(&running_config->lock);
-       {
-               RB_FOREACH (cb, nb_config_cbs, &transaction->changes) {
-                       struct nb_config_change *change =
-                               (struct nb_config_change *)cb;
-                       int ret;
+       RB_FOREACH (cb, nb_config_cbs, &transaction->changes) {
+               struct nb_config_change *change = (struct nb_config_change *)cb;
+               int ret;
 
+               /*
+                * Only try to release resources that were allocated
+                * successfully.
+                */
+               if (event == NB_EV_ABORT && change->prepare_ok == false)
+                       break;
+
+               /* Call the appropriate callback. */
+               ret = nb_callback_configuration(event, change);
+               switch (event) {
+               case NB_EV_PREPARE:
+                       if (ret != NB_OK)
+                               return ret;
+                       change->prepare_ok = true;
+                       break;
+               case NB_EV_ABORT:
+               case NB_EV_APPLY:
                        /*
-                        * Only try to release resources that were allocated
-                        * successfully.
+                        * At this point it's not possible to reject the
+                        * transaction anymore, so any failure here can lead to
+                        * inconsistencies and should be treated as a bug.
+                        * Operations prone to errors, like validations and
+                        * resource allocations, should be performed during the
+                        * 'prepare' phase.
                         */
-                       if (event == NB_EV_ABORT && change->prepare_ok == false)
-                               break;
-
-                       /* Call the appropriate callback. */
-                       ret = nb_callback_configuration(event, change);
-                       switch (event) {
-                       case NB_EV_PREPARE:
-                               if (ret != NB_OK) {
-                                       pthread_rwlock_unlock(
-                                               &running_config->lock);
-                                       return ret;
-                               }
-                               change->prepare_ok = true;
-                               break;
-                       case NB_EV_ABORT:
-                       case NB_EV_APPLY:
-                               /*
-                                * At this point it's not possible to reject the
-                                * transaction anymore, so any failure here can
-                                * lead to inconsistencies and should be treated
-                                * as a bug. Operations prone to errors, like
-                                * validations and resource allocations, should
-                                * be performed during the 'prepare' phase.
-                                */
-                               break;
-                       default:
-                               break;
-                       }
+                       break;
+               default:
+                       break;
                }
        }
-       pthread_rwlock_unlock(&running_config->lock);
 
        return NB_OK;
 }
 
 static struct nb_config_cb *
-nb_apply_finish_cb_new(struct nb_config_cbs *cbs, const char *xpath,
-                      const struct nb_node *nb_node,
+nb_apply_finish_cb_new(struct nb_config_cbs *cbs, const struct nb_node *nb_node,
                       const struct lyd_node *dnode)
 {
        struct nb_config_cb *cb;
 
        cb = XCALLOC(MTYPE_TMP, sizeof(*cb));
-       strlcpy(cb->xpath, xpath, sizeof(cb->xpath));
        cb->nb_node = nb_node;
        cb->dnode = dnode;
        RB_INSERT(nb_config_cbs, cbs, cb);
@@ -1028,13 +1041,15 @@ nb_apply_finish_cb_new(struct nb_config_cbs *cbs, const char *xpath,
 }
 
 static struct nb_config_cb *
-nb_apply_finish_cb_find(struct nb_config_cbs *cbs, const char *xpath,
-                       const struct nb_node *nb_node)
+nb_apply_finish_cb_find(struct nb_config_cbs *cbs,
+                       const struct nb_node *nb_node,
+                       const struct lyd_node *dnode)
 {
        struct nb_config_cb s;
 
-       strlcpy(s.xpath, xpath, sizeof(s.xpath));
+       s.seq = 0;
        s.nb_node = nb_node;
+       s.dnode = dnode;
        return RB_FIND(nb_config_cbs, cbs, &s);
 }
 
@@ -1043,6 +1058,7 @@ static void nb_transaction_apply_finish(struct nb_transaction *transaction)
 {
        struct nb_config_cbs cbs;
        struct nb_config_cb *cb;
+       char xpath[XPATH_MAXLEN];
 
        /* Initialize tree of 'apply_finish' callbacks. */
        RB_INIT(nb_config_cbs, &cbs);
@@ -1059,8 +1075,6 @@ static void nb_transaction_apply_finish(struct nb_transaction *transaction)
                 * be called though).
                 */
                if (change->cb.operation == NB_OP_DESTROY) {
-                       char xpath[XPATH_MAXLEN];
-
                        dnode = dnode->parent;
                        if (!dnode)
                                break;
@@ -1076,7 +1090,6 @@ static void nb_transaction_apply_finish(struct nb_transaction *transaction)
                                               xpath);
                }
                while (dnode) {
-                       char xpath[XPATH_MAXLEN];
                        struct nb_node *nb_node;
 
                        nb_node = dnode->schema->priv;
@@ -1087,11 +1100,10 @@ static void nb_transaction_apply_finish(struct nb_transaction *transaction)
                         * Don't call the callback more than once for the same
                         * data node.
                         */
-                       yang_dnode_get_path(dnode, xpath, sizeof(xpath));
-                       if (nb_apply_finish_cb_find(&cbs, xpath, nb_node))
+                       if (nb_apply_finish_cb_find(&cbs, nb_node, dnode))
                                goto next;
 
-                       nb_apply_finish_cb_new(&cbs, xpath, nb_node, dnode);
+                       nb_apply_finish_cb_new(&cbs, nb_node, dnode);
 
                next:
                        dnode = dnode->parent;
@@ -1100,9 +1112,11 @@ static void nb_transaction_apply_finish(struct nb_transaction *transaction)
 
        /* Call the 'apply_finish' callbacks, sorted by their priorities. */
        RB_FOREACH (cb, nb_config_cbs, &cbs) {
-               if (DEBUG_MODE_CHECK(&nb_dbg_cbs_config, DEBUG_MODE_ALL))
-                       nb_log_callback(NB_EV_APPLY, NB_OP_APPLY_FINISH,
-                                       cb->xpath, NULL);
+               if (DEBUG_MODE_CHECK(&nb_dbg_cbs_config, DEBUG_MODE_ALL)) {
+                       yang_dnode_get_path(cb->dnode, xpath, sizeof(xpath));
+                       nb_log_callback(NB_EV_APPLY, NB_OP_APPLY_FINISH, xpath,
+                                       NULL);
+               }
 
                (*cb->nb_node->cbs.apply_finish)(cb->dnode);
        }
@@ -1310,9 +1324,27 @@ static int nb_oper_data_iter_node(const struct lys_node *snode,
 
        /* Update XPath. */
        strlcpy(xpath, xpath_parent, sizeof(xpath));
-       if (!first && snode->nodetype != LYS_USES)
-               snprintf(xpath + strlen(xpath), sizeof(xpath) - strlen(xpath),
-                        "/%s", snode->name);
+       if (!first && snode->nodetype != LYS_USES) {
+               struct lys_node *parent;
+
+               /* Get the real parent. */
+               parent = snode->parent;
+               while (parent && parent->nodetype == LYS_USES)
+                       parent = parent->parent;
+
+               /*
+                * When necessary, include the namespace of the augmenting
+                * module.
+                */
+               if (parent && parent->nodetype == LYS_AUGMENT)
+                       snprintf(xpath + strlen(xpath),
+                                sizeof(xpath) - strlen(xpath), "/%s:%s",
+                                snode->module->name, snode->name);
+               else
+                       snprintf(xpath + strlen(xpath),
+                                sizeof(xpath) - strlen(xpath), "/%s",
+                                snode->name);
+       }
 
        nb_node = snode->priv;
        switch (snode->nodetype) {
@@ -1550,6 +1582,7 @@ bool nb_operation_is_valid(enum nb_operation operation,
                        return false;
                }
                return true;
+       case NB_OP_PRE_VALIDATE:
        case NB_OP_APPLY_FINISH:
                if (!CHECK_FLAG(snode->flags, LYS_CONFIG_W))
                        return false;
@@ -1768,6 +1801,8 @@ const char *nb_operation_name(enum nb_operation operation)
                return "destroy";
        case NB_OP_MOVE:
                return "move";
+       case NB_OP_PRE_VALIDATE:
+               return "pre_validate";
        case NB_OP_APPLY_FINISH:
                return "apply_finish";
        case NB_OP_GET_ELEM:
@@ -1847,7 +1882,8 @@ static void nb_load_callbacks(const struct frr_yang_module_info *module)
 }
 
 void nb_init(struct thread_master *tm,
-            const struct frr_yang_module_info *modules[], size_t nmodules)
+            const struct frr_yang_module_info *const modules[],
+            size_t nmodules)
 {
        unsigned int errors = 0;