]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/routemap_northbound.c
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / lib / routemap_northbound.c
index ab127dd0fcbf4e718136d0aa0e9c7bd1868f56aa..465985099429c3e45eff7b9d5ed9db5abbc3a7d1 100644 (file)
@@ -1027,6 +1027,110 @@ lib_route_map_entry_set_action_value_destroy(struct nb_cb_destroy_args *args)
        return lib_route_map_entry_set_destroy(args);
 }
 
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/set-action/min-metric
+ */
+static int set_action_min_metric_modify(enum nb_event event,
+                                       const struct lyd_node *dnode,
+                                       union nb_resource *resource,
+                                       const char *value, char *errmsg,
+                                       size_t errmsg_len)
+{
+       struct routemap_hook_context *rhc;
+       int rv;
+
+       if (event != NB_EV_APPLY)
+               return NB_OK;
+
+       /* Check for hook function. */
+       if (rmap_match_set_hook.set_min_metric == NULL)
+               return NB_OK;
+
+       /* Add configuration. */
+       rhc = nb_running_get_entry(dnode, NULL, true);
+
+       /* Set destroy information. */
+       rhc->rhc_shook = rmap_match_set_hook.no_set_min_metric;
+       rhc->rhc_rule = "min-metric";
+
+       rv = rmap_match_set_hook.set_min_metric(rhc->rhc_rmi, "min-metric",
+                                               value, errmsg, errmsg_len);
+       if (rv != CMD_SUCCESS) {
+               rhc->rhc_shook = NULL;
+               return NB_ERR_INCONSISTENCY;
+       }
+
+       return NB_OK;
+}
+
+static int
+lib_route_map_entry_set_action_min_metric_modify(struct nb_cb_modify_args *args)
+{
+       const char *min_metric = yang_dnode_get_string(args->dnode, NULL);
+
+       return set_action_min_metric_modify(args->event, args->dnode,
+                                           args->resource, min_metric,
+                                           args->errmsg, args->errmsg_len);
+}
+
+static int lib_route_map_entry_set_action_min_metric_destroy(
+       struct nb_cb_destroy_args *args)
+{
+       return lib_route_map_entry_set_destroy(args);
+}
+
+/*
+ * XPath: /frr-route-map:lib/route-map/entry/set-action/max-metric
+ */
+static int set_action_max_metric_modify(enum nb_event event,
+                                       const struct lyd_node *dnode,
+                                       union nb_resource *resource,
+                                       const char *value, char *errmsg,
+                                       size_t errmsg_len)
+{
+       struct routemap_hook_context *rhc;
+       int rv;
+
+       if (event != NB_EV_APPLY)
+               return NB_OK;
+
+       /* Check for hook function. */
+       if (rmap_match_set_hook.set_max_metric == NULL)
+               return NB_OK;
+
+       /* Add configuration. */
+       rhc = nb_running_get_entry(dnode, NULL, true);
+
+       /* Set destroy information. */
+       rhc->rhc_shook = rmap_match_set_hook.no_set_max_metric;
+       rhc->rhc_rule = "max-metric";
+
+       rv = rmap_match_set_hook.set_max_metric(rhc->rhc_rmi, "max-metric",
+                                               value, errmsg, errmsg_len);
+       if (rv != CMD_SUCCESS) {
+               rhc->rhc_shook = NULL;
+               return NB_ERR_INCONSISTENCY;
+       }
+
+       return NB_OK;
+}
+
+static int
+lib_route_map_entry_set_action_max_metric_modify(struct nb_cb_modify_args *args)
+{
+       const char *max_metric = yang_dnode_get_string(args->dnode, NULL);
+
+       return set_action_max_metric_modify(args->event, args->dnode,
+                                           args->resource, max_metric,
+                                           args->errmsg, args->errmsg_len);
+}
+
+static int lib_route_map_entry_set_action_max_metric_destroy(
+       struct nb_cb_destroy_args *args)
+{
+       return lib_route_map_entry_set_destroy(args);
+}
+
 /*
  * XPath: /frr-route-map:lib/route-map/entry/set-action/add-metric
  */
@@ -1368,6 +1472,20 @@ const struct frr_yang_module_info frr_route_map_info = {
                                .destroy = lib_route_map_entry_set_action_value_destroy,
                        }
                },
+               {
+                       .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/min-metric",
+                       .cbs = {
+                               .modify = lib_route_map_entry_set_action_min_metric_modify,
+                               .destroy = lib_route_map_entry_set_action_min_metric_destroy,
+                       }
+               },
+               {
+                       .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/max-metric",
+                       .cbs = {
+                               .modify = lib_route_map_entry_set_action_max_metric_modify,
+                               .destroy = lib_route_map_entry_set_action_max_metric_destroy,
+                       }
+               },
                {
                        .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/add-metric",
                        .cbs = {