]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/routemap_northbound.c
Merge pull request #7063 from idryzhov/yang-leafref
[mirror_frr.git] / lib / routemap_northbound.c
index 2d04a3d65c3c919a4a2914ed25b0f2fef69087b0..597a6b1ecfdbfb940dde0907ef62330f78675eb7 100644 (file)
  * lib_route_map_entry_set_destroy: unset `set` commands.
  * lib_route_map_entry_match_destroy: unset `match` commands.
  */
-int lib_route_map_entry_match_destroy(enum nb_event event,
-                                     const struct lyd_node *dnode)
+int lib_route_map_entry_match_destroy(struct nb_cb_destroy_args *args)
 {
        struct routemap_hook_context *rhc;
        int rv;
 
-       if (event != NB_EV_APPLY)
+       if (args->event != NB_EV_APPLY)
                return NB_OK;
 
-       rhc = nb_running_get_entry(dnode, NULL, true);
+       rhc = nb_running_get_entry(args->dnode, NULL, true);
        if (rhc->rhc_mhook == NULL)
                return NB_OK;
 
@@ -54,16 +53,15 @@ int lib_route_map_entry_match_destroy(enum nb_event event,
        return NB_OK;
 }
 
-int lib_route_map_entry_set_destroy(enum nb_event event,
-                                   const struct lyd_node *dnode)
+int lib_route_map_entry_set_destroy(struct nb_cb_destroy_args *args)
 {
        struct routemap_hook_context *rhc;
        int rv;
 
-       if (event != NB_EV_APPLY)
+       if (args->event != NB_EV_APPLY)
                return NB_OK;
 
-       rhc = nb_running_get_entry(dnode, NULL, true);
+       rhc = nb_running_get_entry(args->dnode, NULL, true);
        if (rhc->rhc_shook == NULL)
                return NB_OK;
 
@@ -89,8 +87,7 @@ routemap_hook_context_insert(struct route_map_index *rmi)
        return rhc;
 }
 
-void
-routemap_hook_context_free(struct routemap_hook_context *rhc)
+void routemap_hook_context_free(struct routemap_hook_context *rhc)
 {
        struct route_map_index *rmi = rhc->rhc_rmi;
 
@@ -101,42 +98,39 @@ routemap_hook_context_free(struct routemap_hook_context *rhc)
 /*
  * XPath: /frr-route-map:lib/route-map
  */
-static int lib_route_map_create(enum nb_event event,
-                               const struct lyd_node *dnode,
-                               union nb_resource *resource)
+static int lib_route_map_create(struct nb_cb_create_args *args)
 {
        struct route_map *rm;
        const char *rm_name;
 
-       switch (event) {
+       switch (args->event) {
        case NB_EV_VALIDATE:
        case NB_EV_PREPARE:
        case NB_EV_ABORT:
                /* NOTHING */
                break;
        case NB_EV_APPLY:
-               rm_name = yang_dnode_get_string(dnode, "./name");
+               rm_name = yang_dnode_get_string(args->dnode, "./name");
                rm = route_map_get(rm_name);
-               nb_running_set_entry(dnode, rm);
+               nb_running_set_entry(args->dnode, rm);
                break;
        }
 
        return NB_OK;
 }
 
-static int lib_route_map_destroy(enum nb_event event,
-                                const struct lyd_node *dnode)
+static int lib_route_map_destroy(struct nb_cb_destroy_args *args)
 {
        struct route_map *rm;
 
-       switch (event) {
+       switch (args->event) {
        case NB_EV_VALIDATE:
        case NB_EV_PREPARE:
        case NB_EV_ABORT:
                /* NOTHING */
                break;
        case NB_EV_APPLY:
-               rm = nb_running_unset_entry(dnode);
+               rm = nb_running_unset_entry(args->dnode);
                route_map_delete(rm);
                break;
        }
@@ -147,48 +141,45 @@ static int lib_route_map_destroy(enum nb_event event,
 /*
  * XPath: /frr-route-map:lib/route-map/entry
  */
-static int lib_route_map_entry_create(enum nb_event event,
-                                     const struct lyd_node *dnode,
-                                     union nb_resource *resource)
+static int lib_route_map_entry_create(struct nb_cb_create_args *args)
 {
        struct route_map_index *rmi;
        struct route_map *rm;
        uint16_t sequence;
        int action;
 
-       switch (event) {
+       switch (args->event) {
        case NB_EV_VALIDATE:
        case NB_EV_PREPARE:
        case NB_EV_ABORT:
                /* NOTHING */
                break;
        case NB_EV_APPLY:
-               sequence = yang_dnode_get_uint16(dnode, "./sequence");
-               action = yang_dnode_get_enum(dnode, "./action") == 0
+               sequence = yang_dnode_get_uint16(args->dnode, "./sequence");
+               action = yang_dnode_get_enum(args->dnode, "./action") == 0
                                 ? RMAP_PERMIT
                                 : RMAP_DENY;
-               rm = nb_running_get_entry(dnode, NULL, true);
+               rm = nb_running_get_entry(args->dnode, NULL, true);
                rmi = route_map_index_get(rm, action, sequence);
-               nb_running_set_entry(dnode, rmi);
+               nb_running_set_entry(args->dnode, rmi);
                break;
        }
 
        return NB_OK;
 }
 
-static int lib_route_map_entry_destroy(enum nb_event event,
-                                      const struct lyd_node *dnode)
+static int lib_route_map_entry_destroy(struct nb_cb_destroy_args *args)
 {
        struct route_map_index *rmi;
 
-       switch (event) {
+       switch (args->event) {
        case NB_EV_VALIDATE:
        case NB_EV_PREPARE:
        case NB_EV_ABORT:
                /* NOTHING */
                break;
        case NB_EV_APPLY:
-               rmi = nb_running_unset_entry(dnode);
+               rmi = nb_running_unset_entry(args->dnode);
                route_map_index_delete(rmi, 1);
                break;
        }
@@ -199,50 +190,48 @@ static int lib_route_map_entry_destroy(enum nb_event event,
 /*
  * XPath: /frr-route-map:lib/route-map/entry/description
  */
-static int lib_route_map_entry_description_modify(enum nb_event event,
-                                                 const struct lyd_node *dnode,
-                                                 union nb_resource *resource)
+static int
+lib_route_map_entry_description_modify(struct nb_cb_modify_args *args)
 {
        struct route_map_index *rmi;
        const char *description;
 
-       switch (event) {
+       switch (args->event) {
        case NB_EV_VALIDATE:
                /* NOTHING */
                break;
        case NB_EV_PREPARE:
-               description = yang_dnode_get_string(dnode, NULL);
-               resource->ptr = XSTRDUP(MTYPE_TMP, description);
-               if (resource->ptr == NULL)
+               description = yang_dnode_get_string(args->dnode, NULL);
+               args->resource->ptr = XSTRDUP(MTYPE_TMP, description);
+               if (args->resource->ptr == NULL)
                        return NB_ERR_RESOURCE;
                break;
        case NB_EV_ABORT:
-               XFREE(MTYPE_TMP, resource->ptr);
+               XFREE(MTYPE_TMP, args->resource->ptr);
                break;
        case NB_EV_APPLY:
-               rmi = nb_running_get_entry(dnode, NULL, true);
-               if (rmi->description != NULL)
-                       XFREE(MTYPE_TMP, rmi->description);
-               rmi->description = resource->ptr;
+               rmi = nb_running_get_entry(args->dnode, NULL, true);
+               XFREE(MTYPE_TMP, rmi->description);
+               rmi->description = args->resource->ptr;
                break;
        }
 
        return NB_OK;
 }
 
-static int lib_route_map_entry_description_destroy(enum nb_event event,
-                                                  const struct lyd_node *dnode)
+static int
+lib_route_map_entry_description_destroy(struct nb_cb_destroy_args *args)
 {
        struct route_map_index *rmi;
 
-       switch (event) {
+       switch (args->event) {
        case NB_EV_VALIDATE:
        case NB_EV_PREPARE:
        case NB_EV_ABORT:
                /* NOTHING */
                break;
        case NB_EV_APPLY:
-               rmi = nb_running_get_entry(dnode, NULL, true);
+               rmi = nb_running_get_entry(args->dnode, NULL, true);
                XFREE(MTYPE_TMP, rmi->description);
                break;
        }
@@ -253,21 +242,19 @@ static int lib_route_map_entry_description_destroy(enum nb_event event,
 /*
  * XPath: /frr-route-map:lib/route-map/entry/action
  */
-static int lib_route_map_entry_action_modify(enum nb_event event,
-                                            const struct lyd_node *dnode,
-                                            union nb_resource *resource)
+static int lib_route_map_entry_action_modify(struct nb_cb_modify_args *args)
 {
        struct route_map_index *rmi;
 
-       switch (event) {
+       switch (args->event) {
        case NB_EV_VALIDATE:
        case NB_EV_PREPARE:
        case NB_EV_ABORT:
                /* NOTHING */
                break;
        case NB_EV_APPLY:
-               rmi = nb_running_get_entry(dnode, NULL, true);
-               rmi->type = yang_dnode_get_enum(dnode, NULL);
+               rmi = nb_running_get_entry(args->dnode, NULL, true);
+               rmi->type = yang_dnode_get_enum(args->dnode, NULL);
                /* TODO: notify? */
                break;
        }
@@ -278,17 +265,15 @@ static int lib_route_map_entry_action_modify(enum nb_event event,
 /*
  * XPath: /frr-route-map:lib/route-map/entry/call
  */
-static int lib_route_map_entry_call_modify(enum nb_event event,
-                                          const struct lyd_node *dnode,
-                                          union nb_resource *resource)
+static int lib_route_map_entry_call_modify(struct nb_cb_modify_args *args)
 {
        struct route_map_index *rmi;
        const char *rm_name, *rmn_name;
 
-       switch (event) {
+       switch (args->event) {
        case NB_EV_VALIDATE:
-               rm_name = yang_dnode_get_string(dnode, "../../name");
-               rmn_name = yang_dnode_get_string(dnode, NULL);
+               rm_name = yang_dnode_get_string(args->dnode, "../../name");
+               rmn_name = yang_dnode_get_string(args->dnode, NULL);
                /* Don't allow to jump to the same route map instance. */
                if (strcmp(rm_name, rmn_name) == 0)
                        return NB_ERR_VALIDATION;
@@ -296,20 +281,20 @@ static int lib_route_map_entry_call_modify(enum nb_event event,
                /* TODO: detect circular route map sequences. */
                break;
        case NB_EV_PREPARE:
-               rmn_name = yang_dnode_get_string(dnode, NULL);
-               resource->ptr = XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmn_name);
+               rmn_name = yang_dnode_get_string(args->dnode, NULL);
+               args->resource->ptr = XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmn_name);
                break;
        case NB_EV_ABORT:
-               XFREE(MTYPE_ROUTE_MAP_NAME, resource->ptr);
+               XFREE(MTYPE_ROUTE_MAP_NAME, args->resource->ptr);
                break;
        case NB_EV_APPLY:
-               rmi = nb_running_get_entry(dnode, NULL, true);
+               rmi = nb_running_get_entry(args->dnode, NULL, true);
                if (rmi->nextrm) {
                        route_map_upd8_dependency(RMAP_EVENT_CALL_DELETED,
                                                  rmi->nextrm, rmi->map->name);
                        XFREE(MTYPE_ROUTE_MAP_NAME, rmi->nextrm);
                }
-               rmi->nextrm = resource->ptr;
+               rmi->nextrm = args->resource->ptr;
                route_map_upd8_dependency(RMAP_EVENT_CALL_ADDED, rmi->nextrm,
                                          rmi->map->name);
                break;
@@ -318,19 +303,18 @@ static int lib_route_map_entry_call_modify(enum nb_event event,
        return NB_OK;
 }
 
-static int lib_route_map_entry_call_destroy(enum nb_event event,
-                                           const struct lyd_node *dnode)
+static int lib_route_map_entry_call_destroy(struct nb_cb_destroy_args *args)
 {
        struct route_map_index *rmi;
 
-       switch (event) {
+       switch (args->event) {
        case NB_EV_VALIDATE:
        case NB_EV_PREPARE:
        case NB_EV_ABORT:
                /* NOTHING */
                break;
        case NB_EV_APPLY:
-               rmi = nb_running_get_entry(dnode, NULL, true);
+               rmi = nb_running_get_entry(args->dnode, NULL, true);
                route_map_upd8_dependency(RMAP_EVENT_CALL_DELETED, rmi->nextrm,
                                          rmi->map->name);
                XFREE(MTYPE_ROUTE_MAP_NAME, rmi->nextrm);
@@ -344,24 +328,24 @@ static int lib_route_map_entry_call_destroy(enum nb_event event,
 /*
  * XPath: /frr-route-map:lib/route-map/entry/exit-policy
  */
-static int lib_route_map_entry_exit_policy_modify(enum nb_event event,
-                                                 const struct lyd_node *dnode,
-                                                 union nb_resource *resource)
+static int
+lib_route_map_entry_exit_policy_modify(struct nb_cb_modify_args *args)
 {
        struct route_map_index *rmi;
        int rm_action;
        int policy;
 
-       switch (event) {
+       switch (args->event) {
        case NB_EV_VALIDATE:
-               policy = yang_dnode_get_enum(dnode, NULL);
+               policy = yang_dnode_get_enum(args->dnode, NULL);
                switch (policy) {
                case 0: /* permit-or-deny */
                        break;
                case 1: /* next */
                        /* FALLTHROUGH */
                case 2: /* goto */
-                       rm_action = yang_dnode_get_enum(dnode, "../action");
+                       rm_action =
+                               yang_dnode_get_enum(args->dnode, "../action");
                        if (rm_action == 1 /* deny */) {
                                /*
                                 * On deny it is not possible to 'goto'
@@ -376,8 +360,8 @@ static int lib_route_map_entry_exit_policy_modify(enum nb_event event,
        case NB_EV_ABORT:
                break;
        case NB_EV_APPLY:
-               rmi = nb_running_get_entry(dnode, NULL, true);
-               policy = yang_dnode_get_enum(dnode, NULL);
+               rmi = nb_running_get_entry(args->dnode, NULL, true);
+               policy = yang_dnode_get_enum(args->dnode, NULL);
 
                switch (policy) {
                case 0: /* permit-or-deny */
@@ -399,18 +383,16 @@ static int lib_route_map_entry_exit_policy_modify(enum nb_event event,
 /*
  * XPath: /frr-route-map:lib/route-map/entry/goto-value
  */
-static int lib_route_map_entry_goto_value_modify(enum nb_event event,
-                                                const struct lyd_node *dnode,
-                                                union nb_resource *resource)
+static int lib_route_map_entry_goto_value_modify(struct nb_cb_modify_args *args)
 {
        struct route_map_index *rmi;
        uint16_t rmi_index;
        uint16_t rmi_next;
 
-       switch (event) {
+       switch (args->event) {
        case NB_EV_VALIDATE:
-               rmi_index = yang_dnode_get_uint16(dnode, "../sequence");
-               rmi_next = yang_dnode_get_uint16(dnode, NULL);
+               rmi_index = yang_dnode_get_uint16(args->dnode, "../sequence");
+               rmi_next = yang_dnode_get_uint16(args->dnode, NULL);
                if (rmi_next <= rmi_index) {
                        /* Can't jump backwards on a route map. */
                        return NB_ERR_VALIDATION;
@@ -421,27 +403,27 @@ static int lib_route_map_entry_goto_value_modify(enum nb_event event,
                /* NOTHING */
                break;
        case NB_EV_APPLY:
-               rmi = nb_running_get_entry(dnode, NULL, true);
-               rmi->nextpref = yang_dnode_get_uint16(dnode, NULL);
+               rmi = nb_running_get_entry(args->dnode, NULL, true);
+               rmi->nextpref = yang_dnode_get_uint16(args->dnode, NULL);
                break;
        }
 
        return NB_OK;
 }
 
-static int lib_route_map_entry_goto_value_destroy(enum nb_event event,
-                                                 const struct lyd_node *dnode)
+static int
+lib_route_map_entry_goto_value_destroy(struct nb_cb_destroy_args *args)
 {
        struct route_map_index *rmi;
 
-       switch (event) {
+       switch (args->event) {
        case NB_EV_VALIDATE:
        case NB_EV_PREPARE:
        case NB_EV_ABORT:
                /* NOTHING */
                break;
        case NB_EV_APPLY:
-               rmi = nb_running_get_entry(dnode, NULL, true);
+               rmi = nb_running_get_entry(args->dnode, NULL, true);
                rmi->nextpref = 0;
                break;
        }
@@ -453,23 +435,21 @@ static int lib_route_map_entry_goto_value_destroy(enum nb_event event,
  * XPath: /frr-route-map:lib/route-map/entry/match-condition
  */
 static int
-lib_route_map_entry_match_condition_create(enum nb_event event,
-                                          const struct lyd_node *dnode,
-                                          union nb_resource *resource)
+lib_route_map_entry_match_condition_create(struct nb_cb_create_args *args)
 {
        struct routemap_hook_context *rhc;
        struct route_map_index *rmi;
 
-       switch (event) {
+       switch (args->event) {
        case NB_EV_VALIDATE:
        case NB_EV_PREPARE:
        case NB_EV_ABORT:
                /* NOTHING */
                break;
        case NB_EV_APPLY:
-               rmi = nb_running_get_entry(dnode, NULL, true);
+               rmi = nb_running_get_entry(args->dnode, NULL, true);
                rhc = routemap_hook_context_insert(rmi);
-               nb_running_set_entry(dnode, rhc);
+               nb_running_set_entry(args->dnode, rhc);
                break;
        }
 
@@ -477,17 +457,16 @@ lib_route_map_entry_match_condition_create(enum nb_event event,
 }
 
 static int
-lib_route_map_entry_match_condition_destroy(enum nb_event event,
-                                           const struct lyd_node *dnode)
+lib_route_map_entry_match_condition_destroy(struct nb_cb_destroy_args *args)
 {
        struct routemap_hook_context *rhc;
        int rv;
 
-       if (event != NB_EV_APPLY)
+       if (args->event != NB_EV_APPLY)
                return NB_OK;
 
-       rv = lib_route_map_entry_match_destroy(event, dnode);
-       rhc = nb_running_unset_entry(dnode);
+       rv = lib_route_map_entry_match_destroy(args);
+       rhc = nb_running_unset_entry(args->dnode);
        routemap_hook_context_free(rhc);
 
        return rv;
@@ -497,14 +476,13 @@ lib_route_map_entry_match_condition_destroy(enum nb_event event,
  * XPath: /frr-route-map:lib/route-map/entry/match-condition/interface
  */
 static int lib_route_map_entry_match_condition_interface_modify(
-       enum nb_event event, const struct lyd_node *dnode,
-       union nb_resource *resource)
+       struct nb_cb_modify_args *args)
 {
        struct routemap_hook_context *rhc;
        const char *ifname;
        int rv;
 
-       if (event != NB_EV_APPLY)
+       if (args->event != NB_EV_APPLY)
                return NB_OK;
 
        /* Check for hook function. */
@@ -512,8 +490,8 @@ static int lib_route_map_entry_match_condition_interface_modify(
                return NB_OK;
 
        /* Add configuration. */
-       rhc = nb_running_get_entry(dnode, NULL, true);
-       ifname = yang_dnode_get_string(dnode, NULL);
+       rhc = nb_running_get_entry(args->dnode, NULL, true);
+       ifname = yang_dnode_get_string(args->dnode, NULL);
 
        /* Set destroy information. */
        rhc->rhc_mhook = rmap_match_set_hook.no_match_interface;
@@ -532,104 +510,29 @@ static int lib_route_map_entry_match_condition_interface_modify(
 }
 
 static int lib_route_map_entry_match_condition_interface_destroy(
-       enum nb_event event, const struct lyd_node *dnode)
-{
-       return lib_route_map_entry_match_destroy(event, dnode);
-}
-
-/*
- * XPath: /frr-route-map:lib/route-map/entry/match-condition/access-list-num
- */
-static int lib_route_map_entry_match_condition_access_list_num_modify(
-       enum nb_event event, const struct lyd_node *dnode,
-       union nb_resource *resource)
-{
-       struct routemap_hook_context *rhc;
-       const char *acl;
-       int condition, rv;
-
-       if (event != NB_EV_APPLY)
-               return NB_OK;
-
-       /* Check for hook function. */
-       rv = CMD_SUCCESS;
-       acl = yang_dnode_get_string(dnode, NULL);
-       rhc = nb_running_get_entry(dnode, NULL, true);
-       condition = yang_dnode_get_enum(dnode, "../condition");
-       switch (condition) {
-       case 1: /* ipv4-address-list */
-               if (rmap_match_set_hook.match_ip_address == NULL)
-                       break;
-               rhc->rhc_mhook = rmap_match_set_hook.no_match_ip_address;
-               rhc->rhc_rule = "ip address";
-               rhc->rhc_event = RMAP_EVENT_FILTER_DELETED;
-               rv = rmap_match_set_hook.match_ip_address(
-                       NULL, rhc->rhc_rmi, "ip address", acl,
-                       RMAP_EVENT_FILTER_ADDED);
-               break;
-       case 3: /* ipv4-next-hop-list */
-               if (rmap_match_set_hook.match_ip_next_hop == NULL)
-                       break;
-               rhc->rhc_mhook = rmap_match_set_hook.no_match_ip_next_hop;
-               rhc->rhc_rule = "ip next-hop";
-               rhc->rhc_event = RMAP_EVENT_FILTER_DELETED;
-               rv = rmap_match_set_hook.match_ip_next_hop(
-                       NULL, rhc->rhc_rmi, "ip next-hop", acl,
-                       RMAP_EVENT_FILTER_ADDED);
-               break;
-       }
-       if (rv != CMD_SUCCESS) {
-               rhc->rhc_mhook = NULL;
-               return NB_ERR_INCONSISTENCY;
-       }
-
-       return NB_OK;
-}
-
-static int lib_route_map_entry_match_condition_access_list_num_destroy(
-       enum nb_event event, const struct lyd_node *dnode)
-{
-       return lib_route_map_entry_match_destroy(event, dnode);
-}
-
-/*
- * XPath:
- * /frr-route-map:lib/route-map/entry/match-condition/access-list-num-extended
- */
-static int lib_route_map_entry_match_condition_access_list_num_extended_modify(
-       enum nb_event event, const struct lyd_node *dnode,
-       union nb_resource *resource)
-{
-       return lib_route_map_entry_match_condition_access_list_num_modify(
-               event, dnode, resource);
-}
-
-static int lib_route_map_entry_match_condition_access_list_num_extended_destroy(
-       enum nb_event event, const struct lyd_node *dnode)
+       struct nb_cb_destroy_args *args)
 {
-       return lib_route_map_entry_match_condition_access_list_num_destroy(
-               event, dnode);
+       return lib_route_map_entry_match_destroy(args);
 }
 
 /*
  * XPath: /frr-route-map:lib/route-map/entry/match-condition/list-name
  */
 static int lib_route_map_entry_match_condition_list_name_modify(
-       enum nb_event event, const struct lyd_node *dnode,
-       union nb_resource *resource)
+       struct nb_cb_modify_args *args)
 {
        struct routemap_hook_context *rhc;
        const char *acl;
        int condition;
        int rv;
 
-       if (event != NB_EV_APPLY)
+       if (args->event != NB_EV_APPLY)
                return NB_OK;
 
        /* Check for hook installation, otherwise we can just stop. */
-       acl = yang_dnode_get_string(dnode, NULL);
-       rhc = nb_running_get_entry(dnode, NULL, true);
-       condition = yang_dnode_get_enum(dnode, "../condition");
+       acl = yang_dnode_get_string(args->dnode, NULL);
+       rhc = nb_running_get_entry(args->dnode, NULL, true);
+       condition = yang_dnode_get_enum(args->dnode, "../condition");
        switch (condition) {
        case 1: /* ipv4-address-list */
                if (rmap_match_set_hook.match_ip_address == NULL)
@@ -707,23 +610,22 @@ static int lib_route_map_entry_match_condition_list_name_modify(
 }
 
 static int lib_route_map_entry_match_condition_list_name_destroy(
-       enum nb_event event, const struct lyd_node *dnode)
+       struct nb_cb_destroy_args *args)
 {
-       return lib_route_map_entry_match_destroy(event, dnode);
+       return lib_route_map_entry_match_destroy(args);
 }
 
 /*
  * XPath: /frr-route-map:lib/route-map/entry/match-condition/ipv4-next-hop-type
  */
 static int lib_route_map_entry_match_condition_ipv4_next_hop_type_modify(
-       enum nb_event event, const struct lyd_node *dnode,
-       union nb_resource *resource)
+       struct nb_cb_modify_args *args)
 {
        struct routemap_hook_context *rhc;
        const char *type;
        int rv;
 
-       if (event != NB_EV_APPLY)
+       if (args->event != NB_EV_APPLY)
                return NB_OK;
 
        /* Check for hook function. */
@@ -731,8 +633,8 @@ static int lib_route_map_entry_match_condition_ipv4_next_hop_type_modify(
                return NB_OK;
 
        /* Add configuration. */
-       rhc = nb_running_get_entry(dnode, NULL, true);
-       type = yang_dnode_get_string(dnode, NULL);
+       rhc = nb_running_get_entry(args->dnode, NULL, true);
+       type = yang_dnode_get_string(args->dnode, NULL);
 
        /* Set destroy information. */
        rhc->rhc_mhook = rmap_match_set_hook.no_match_ip_next_hop_type;
@@ -751,23 +653,22 @@ static int lib_route_map_entry_match_condition_ipv4_next_hop_type_modify(
 }
 
 static int lib_route_map_entry_match_condition_ipv4_next_hop_type_destroy(
-       enum nb_event event, const struct lyd_node *dnode)
+       struct nb_cb_destroy_args *args)
 {
-       return lib_route_map_entry_match_destroy(event, dnode);
+       return lib_route_map_entry_match_destroy(args);
 }
 
 /*
  * XPath: /frr-route-map:lib/route-map/entry/match-condition/ipv6-next-hop-type
  */
 static int lib_route_map_entry_match_condition_ipv6_next_hop_type_modify(
-       enum nb_event event, const struct lyd_node *dnode,
-       union nb_resource *resource)
+       struct nb_cb_modify_args *args)
 {
        struct routemap_hook_context *rhc;
        const char *type;
        int rv;
 
-       if (event != NB_EV_APPLY)
+       if (args->event != NB_EV_APPLY)
                return NB_OK;
 
        /* Check for hook function. */
@@ -775,8 +676,8 @@ static int lib_route_map_entry_match_condition_ipv6_next_hop_type_modify(
                return NB_OK;
 
        /* Add configuration. */
-       rhc = nb_running_get_entry(dnode, NULL, true);
-       type = yang_dnode_get_string(dnode, NULL);
+       rhc = nb_running_get_entry(args->dnode, NULL, true);
+       type = yang_dnode_get_string(args->dnode, NULL);
 
        /* Set destroy information. */
        rhc->rhc_mhook = rmap_match_set_hook.no_match_ipv6_next_hop_type;
@@ -795,24 +696,22 @@ static int lib_route_map_entry_match_condition_ipv6_next_hop_type_modify(
 }
 
 static int lib_route_map_entry_match_condition_ipv6_next_hop_type_destroy(
-       enum nb_event event, const struct lyd_node *dnode)
+       struct nb_cb_destroy_args *args)
 {
-       return lib_route_map_entry_match_destroy(event, dnode);
+       return lib_route_map_entry_match_destroy(args);
 }
 
 /*
  * XPath: /frr-route-map:lib/route-map/entry/match-condition/metric
  */
-static int
-lib_route_map_entry_match_condition_metric_modify(enum nb_event event,
-                                                 const struct lyd_node *dnode,
-                                                 union nb_resource *resource)
+static int lib_route_map_entry_match_condition_metric_modify(
+       struct nb_cb_modify_args *args)
 {
        struct routemap_hook_context *rhc;
        const char *type;
        int rv;
 
-       if (event != NB_EV_APPLY)
+       if (args->event != NB_EV_APPLY)
                return NB_OK;
 
        /* Check for hook function. */
@@ -820,8 +719,8 @@ lib_route_map_entry_match_condition_metric_modify(enum nb_event event,
                return NB_OK;
 
        /* Add configuration. */
-       rhc = nb_running_get_entry(dnode, NULL, true);
-       type = yang_dnode_get_string(dnode, NULL);
+       rhc = nb_running_get_entry(args->dnode, NULL, true);
+       type = yang_dnode_get_string(args->dnode, NULL);
 
        /* Set destroy information. */
        rhc->rhc_mhook = rmap_match_set_hook.no_match_metric;
@@ -838,26 +737,23 @@ lib_route_map_entry_match_condition_metric_modify(enum nb_event event,
        return NB_OK;
 }
 
-static int
-lib_route_map_entry_match_condition_metric_destroy(enum nb_event event,
-                                                  const struct lyd_node *dnode)
+static int lib_route_map_entry_match_condition_metric_destroy(
+       struct nb_cb_destroy_args *args)
 {
-       return lib_route_map_entry_match_destroy(event, dnode);
+       return lib_route_map_entry_match_destroy(args);
 }
 
 /*
  * XPath: /frr-route-map:lib/route-map/entry/match-condition/tag
  */
 static int
-lib_route_map_entry_match_condition_tag_modify(enum nb_event event,
-                                              const struct lyd_node *dnode,
-                                              union nb_resource *resource)
+lib_route_map_entry_match_condition_tag_modify(struct nb_cb_modify_args *args)
 {
        struct routemap_hook_context *rhc;
        const char *tag;
        int rv;
 
-       if (event != NB_EV_APPLY)
+       if (args->event != NB_EV_APPLY)
                return NB_OK;
 
        /* Check for hook function. */
@@ -865,8 +761,8 @@ lib_route_map_entry_match_condition_tag_modify(enum nb_event event,
                return NB_OK;
 
        /* Add configuration. */
-       rhc = nb_running_get_entry(dnode, NULL, true);
-       tag = yang_dnode_get_string(dnode, NULL);
+       rhc = nb_running_get_entry(args->dnode, NULL, true);
+       tag = yang_dnode_get_string(args->dnode, NULL);
 
        /* Set destroy information. */
        rhc->rhc_mhook = rmap_match_set_hook.no_match_tag;
@@ -884,34 +780,30 @@ lib_route_map_entry_match_condition_tag_modify(enum nb_event event,
 }
 
 static int
-lib_route_map_entry_match_condition_tag_destroy(enum nb_event event,
-                                               const struct lyd_node *dnode)
+lib_route_map_entry_match_condition_tag_destroy(struct nb_cb_destroy_args *args)
 {
-       return lib_route_map_entry_match_destroy(event, dnode);
+       return lib_route_map_entry_match_destroy(args);
 }
 
 /*
  * XPath: /frr-route-map:lib/route-map/entry/set-action
  */
-static int lib_route_map_entry_set_action_create(enum nb_event event,
-                                                const struct lyd_node *dnode,
-                                                union nb_resource *resource)
+static int lib_route_map_entry_set_action_create(struct nb_cb_create_args *args)
 {
-       return lib_route_map_entry_match_condition_create(event, dnode,
-                                                         resource);
+       return lib_route_map_entry_match_condition_create(args);
 }
 
-static int lib_route_map_entry_set_action_destroy(enum nb_event event,
-                                                 const struct lyd_node *dnode)
+static int
+lib_route_map_entry_set_action_destroy(struct nb_cb_destroy_args *args)
 {
        struct routemap_hook_context *rhc;
        int rv;
 
-       if (event != NB_EV_APPLY)
+       if (args->event != NB_EV_APPLY)
                return NB_OK;
 
-       rv = lib_route_map_entry_set_destroy(event, dnode);
-       rhc = nb_running_unset_entry(dnode);
+       rv = lib_route_map_entry_set_destroy(args);
+       rhc = nb_running_unset_entry(args->dnode);
        routemap_hook_context_free(rhc);
 
        return rv;
@@ -920,24 +812,22 @@ static int lib_route_map_entry_set_action_destroy(enum nb_event event,
 /*
  * XPath: /frr-route-map:lib/route-map/entry/set-action/ipv4-address
  */
-static int
-lib_route_map_entry_set_action_ipv4_address_modify(enum nb_event event,
-                                                  const struct lyd_node *dnode,
-                                                  union nb_resource *resource)
+static int lib_route_map_entry_set_action_ipv4_address_modify(
+       struct nb_cb_modify_args *args)
 {
        struct routemap_hook_context *rhc;
        const char *address;
        struct in_addr ia;
        int rv;
 
-       switch (event) {
+       switch (args->event) {
        case NB_EV_VALIDATE:
                /*
                 * NOTE: validate if 'action' is 'ipv4-next-hop',
                 * currently it is not necessary because this is the
                 * only implemented action.
                 */
-               yang_dnode_get_ipv4(&ia, dnode, NULL);
+               yang_dnode_get_ipv4(&ia, args->dnode, NULL);
                if (ia.s_addr == INADDR_ANY || IPV4_CLASS_DE(ntohl(ia.s_addr)))
                        return NB_ERR_VALIDATION;
                /* FALLTHROUGH */
@@ -953,8 +843,8 @@ lib_route_map_entry_set_action_ipv4_address_modify(enum nb_event event,
                return NB_OK;
 
        /* Add configuration. */
-       rhc = nb_running_get_entry(dnode, NULL, true);
-       address = yang_dnode_get_string(dnode, NULL);
+       rhc = nb_running_get_entry(args->dnode, NULL, true);
+       address = yang_dnode_get_string(args->dnode, NULL);
 
        /* Set destroy information. */
        rhc->rhc_shook = rmap_match_set_hook.no_set_ip_nexthop;
@@ -971,25 +861,23 @@ lib_route_map_entry_set_action_ipv4_address_modify(enum nb_event event,
 }
 
 static int lib_route_map_entry_set_action_ipv4_address_destroy(
-       enum nb_event event, const struct lyd_node *dnode)
+       struct nb_cb_destroy_args *args)
 {
-       return lib_route_map_entry_set_destroy(event, dnode);
+       return lib_route_map_entry_set_destroy(args);
 }
 
 /*
  * XPath: /frr-route-map:lib/route-map/entry/set-action/ipv6-address
  */
-static int
-lib_route_map_entry_set_action_ipv6_address_modify(enum nb_event event,
-                                                  const struct lyd_node *dnode,
-                                                  union nb_resource *resource)
+static int lib_route_map_entry_set_action_ipv6_address_modify(
+       struct nb_cb_modify_args *args)
 {
        struct routemap_hook_context *rhc;
        const char *address;
        struct in6_addr i6a;
        int rv;
 
-       switch (event) {
+       switch (args->event) {
        case NB_EV_VALIDATE:
                /*
                 * NOTE: validate if 'action' is 'ipv6-next-hop',
@@ -997,7 +885,7 @@ lib_route_map_entry_set_action_ipv6_address_modify(enum nb_event event,
                 * only implemented action. Other actions might have
                 * different validations.
                 */
-               yang_dnode_get_ipv6(&i6a, dnode, NULL);
+               yang_dnode_get_ipv6(&i6a, args->dnode, NULL);
                if (!IN6_IS_ADDR_LINKLOCAL(&i6a))
                        return NB_ERR_VALIDATION;
                /* FALLTHROUGH */
@@ -1013,8 +901,8 @@ lib_route_map_entry_set_action_ipv6_address_modify(enum nb_event event,
                return NB_OK;
 
        /* Add configuration. */
-       rhc = nb_running_get_entry(dnode, NULL, true);
-       address = yang_dnode_get_string(dnode, NULL);
+       rhc = nb_running_get_entry(args->dnode, NULL, true);
+       address = yang_dnode_get_string(args->dnode, NULL);
 
        /* Set destroy information. */
        rhc->rhc_shook = rmap_match_set_hook.no_set_ipv6_nexthop_local;
@@ -1031,9 +919,9 @@ lib_route_map_entry_set_action_ipv6_address_modify(enum nb_event event,
 }
 
 static int lib_route_map_entry_set_action_ipv6_address_destroy(
-       enum nb_event event, const struct lyd_node *dnode)
+       struct nb_cb_destroy_args *args)
 {
-       return lib_route_map_entry_set_destroy(event, dnode);
+       return lib_route_map_entry_set_destroy(args);
 }
 
 /*
@@ -1075,111 +963,127 @@ static int set_action_modify(enum nb_event event, const struct lyd_node *dnode,
 }
 
 static int
-lib_route_map_entry_set_action_value_modify(enum nb_event event,
-                                           const struct lyd_node *dnode,
-                                           union nb_resource *resource)
+lib_route_map_entry_set_action_value_modify(struct nb_cb_modify_args *args)
 {
-       const char *metric = yang_dnode_get_string(dnode, NULL);
+       const char *metric = yang_dnode_get_string(args->dnode, NULL);
 
-       return set_action_modify(event, dnode, resource, metric);
+       return set_action_modify(args->event, args->dnode, args->resource,
+                                metric);
 }
 
 static int
-lib_route_map_entry_set_action_value_destroy(enum nb_event event,
-                                            const struct lyd_node *dnode)
+lib_route_map_entry_set_action_value_destroy(struct nb_cb_destroy_args *args)
 {
-       return lib_route_map_entry_set_destroy(event, dnode);
+       return lib_route_map_entry_set_destroy(args);
 }
 
 /*
  * XPath: /frr-route-map:lib/route-map/entry/set-action/add-metric
  */
 static int
-lib_route_map_entry_set_action_add_metric_modify(enum nb_event event,
-                                                const struct lyd_node *dnode,
-                                                union nb_resource *resource)
+lib_route_map_entry_set_action_add_metric_modify(struct nb_cb_modify_args *args)
 {
-       return set_action_modify(event, dnode, resource, "+metric");
+       char metric_str[16];
+
+       if (args->event == NB_EV_VALIDATE
+           && yang_dnode_get_uint32(args->dnode, NULL) == 0) {
+               snprintf(args->errmsg, args->errmsg_len,
+                        "Can't add zero to metric");
+               return NB_ERR_VALIDATION;
+       }
+
+       snprintf(metric_str, sizeof(metric_str), "+%s",
+                yang_dnode_get_string(args->dnode, NULL));
+       return set_action_modify(args->event, args->dnode, args->resource,
+                                metric_str);
 }
 
-static int
-lib_route_map_entry_set_action_add_metric_destroy(enum nb_event event,
-                                                 const struct lyd_node *dnode)
+static int lib_route_map_entry_set_action_add_metric_destroy(
+       struct nb_cb_destroy_args *args)
 {
-       return lib_route_map_entry_set_action_value_destroy(event, dnode);
+       return lib_route_map_entry_set_action_value_destroy(args);
 }
 
 /*
  * XPath: /frr-route-map:lib/route-map/entry/set-action/subtract-metric
  */
 static int lib_route_map_entry_set_action_subtract_metric_modify(
-       enum nb_event event, const struct lyd_node *dnode,
-       union nb_resource *resource)
+       struct nb_cb_modify_args *args)
 {
-       return set_action_modify(event, dnode, resource, "-metric");
+       char metric_str[16];
+
+       if (args->event == NB_EV_VALIDATE
+           && yang_dnode_get_uint32(args->dnode, NULL) == 0) {
+               snprintf(args->errmsg, args->errmsg_len,
+                        "Can't subtract zero from metric");
+               return NB_ERR_VALIDATION;
+       }
+
+       snprintf(metric_str, sizeof(metric_str), "-%s",
+                yang_dnode_get_string(args->dnode, NULL));
+       return set_action_modify(args->event, args->dnode, args->resource,
+                                metric_str);
 }
 
 static int lib_route_map_entry_set_action_subtract_metric_destroy(
-       enum nb_event event, const struct lyd_node *dnode)
+       struct nb_cb_destroy_args *args)
 {
-       return lib_route_map_entry_set_action_value_destroy(event, dnode);
+       return lib_route_map_entry_set_action_value_destroy(args);
 }
 
 /*
  * XPath: /frr-route-map:lib/route-map/entry/set-action/use-round-trip-time
  */
 static int lib_route_map_entry_set_action_use_round_trip_time_modify(
-       enum nb_event event, const struct lyd_node *dnode,
-       union nb_resource *resource)
+       struct nb_cb_modify_args *args)
 {
-       return set_action_modify(event, dnode, resource, "rtt");
+       return set_action_modify(args->event, args->dnode, args->resource,
+                                "rtt");
 }
 
 static int lib_route_map_entry_set_action_use_round_trip_time_destroy(
-       enum nb_event event, const struct lyd_node *dnode)
+       struct nb_cb_destroy_args *args)
 {
-       return lib_route_map_entry_set_action_value_destroy(event, dnode);
+       return lib_route_map_entry_set_action_value_destroy(args);
 }
 
 /*
  * XPath: /frr-route-map:lib/route-map/entry/set-action/add-round-trip-time
  */
 static int lib_route_map_entry_set_action_add_round_trip_time_modify(
-       enum nb_event event, const struct lyd_node *dnode,
-       union nb_resource *resource)
+       struct nb_cb_modify_args *args)
 {
-       return set_action_modify(event, dnode, resource, "+rtt");
+       return set_action_modify(args->event, args->dnode, args->resource,
+                                "+rtt");
 }
 
 static int lib_route_map_entry_set_action_add_round_trip_time_destroy(
-       enum nb_event event, const struct lyd_node *dnode)
+       struct nb_cb_destroy_args *args)
 {
-       return lib_route_map_entry_set_action_value_destroy(event, dnode);
+       return lib_route_map_entry_set_action_value_destroy(args);
 }
 
 /*
  * XPath: /frr-route-map:lib/route-map/entry/set-action/subtract-round-trip-time
  */
 static int lib_route_map_entry_set_action_subtract_round_trip_time_modify(
-       enum nb_event event, const struct lyd_node *dnode,
-       union nb_resource *resource)
+       struct nb_cb_modify_args *args)
 {
-       return set_action_modify(event, dnode, resource, "-rtt");
+       return set_action_modify(args->event, args->dnode, args->resource,
+                                "-rtt");
 }
 
 static int lib_route_map_entry_set_action_subtract_round_trip_time_destroy(
-       enum nb_event event, const struct lyd_node *dnode)
+       struct nb_cb_destroy_args *args)
 {
-       return lib_route_map_entry_set_action_value_destroy(event, dnode);
+       return lib_route_map_entry_set_action_value_destroy(args);
 }
 
 /*
  * XPath: /frr-route-map:lib/route-map/entry/set-action/tag
  */
 static int
-lib_route_map_entry_set_action_tag_modify(enum nb_event event,
-                                         const struct lyd_node *dnode,
-                                         union nb_resource *resource)
+lib_route_map_entry_set_action_tag_modify(struct nb_cb_modify_args *args)
 {
        struct routemap_hook_context *rhc;
        const char *tag;
@@ -1190,7 +1094,7 @@ lib_route_map_entry_set_action_tag_modify(enum nb_event event,
         * necessary because this is the only implemented action. Other
         * actions might have different validations.
         */
-       if (event != NB_EV_APPLY)
+       if (args->event != NB_EV_APPLY)
                return NB_OK;
 
        /* Check for hook function. */
@@ -1198,8 +1102,8 @@ lib_route_map_entry_set_action_tag_modify(enum nb_event event,
                return NB_OK;
 
        /* Add configuration. */
-       rhc = nb_running_get_entry(dnode, NULL, true);
-       tag = yang_dnode_get_string(dnode, NULL);
+       rhc = nb_running_get_entry(args->dnode, NULL, true);
+       tag = yang_dnode_get_string(args->dnode, NULL);
 
        /* Set destroy information. */
        rhc->rhc_shook = rmap_match_set_hook.no_set_tag;
@@ -1215,39 +1119,13 @@ lib_route_map_entry_set_action_tag_modify(enum nb_event event,
 }
 
 static int
-lib_route_map_entry_set_action_tag_destroy(enum nb_event event,
-                                          const struct lyd_node *dnode)
+lib_route_map_entry_set_action_tag_destroy(struct nb_cb_destroy_args *args)
 {
-       return lib_route_map_entry_set_destroy(event, dnode);
+       return lib_route_map_entry_set_destroy(args);
 }
 
 /* clang-format off */
-#if defined(__GNUC__) && ((__GNUC__ - 0) < 5) && !defined(__clang__)
-/*
- * gcc versions before 5.x miscalculate the size for structs with variable
- * length arrays (they just count it as size 0)
- */
-struct frr_yang_module_info_sizen {
-       /* YANG module name. */
-       const char *name;
-
-       /* Northbound callbacks. */
-       const struct {
-               /* Data path of this YANG node. */
-               const char *xpath;
-
-               /* Callbacks implemented for this node. */
-               struct nb_callbacks cbs;
-
-               /* Priority - lower priorities are processed first. */
-               uint32_t priority;
-       } nodes[28];
-};
-
-const struct frr_yang_module_info_sizen frr_route_map_info_sizen asm("frr_route_map_info") = {
-#else
 const struct frr_yang_module_info frr_route_map_info = {
-#endif
        .name = "frr-route-map",
        .nodes = {
                {
@@ -1317,20 +1195,6 @@ const struct frr_yang_module_info frr_route_map_info = {
                                .destroy = lib_route_map_entry_match_condition_interface_destroy,
                        }
                },
-               {
-                       .xpath = "/frr-route-map:lib/route-map/entry/match-condition/access-list-num",
-                       .cbs = {
-                               .modify = lib_route_map_entry_match_condition_access_list_num_modify,
-                               .destroy = lib_route_map_entry_match_condition_access_list_num_destroy,
-                       }
-               },
-               {
-                       .xpath = "/frr-route-map:lib/route-map/entry/match-condition/access-list-num-extended",
-                       .cbs = {
-                               .modify = lib_route_map_entry_match_condition_access_list_num_extended_modify,
-                               .destroy = lib_route_map_entry_match_condition_access_list_num_extended_destroy,
-                       }
-               },
                {
                        .xpath = "/frr-route-map:lib/route-map/entry/match-condition/list-name",
                        .cbs = {