]> git.proxmox.com Git - mirror_frr.git/blobdiff - staticd/static_vty.c
Merge pull request #13541 from LabNConsulting/chopps/fixtestdefconf
[mirror_frr.git] / staticd / static_vty.c
index d87ca16c6198de10e8b1bb669b71a048dfaa90fd..3e58a44aa73afcaac033991c36b2ffc1ce872379 100644 (file)
@@ -13,6 +13,7 @@
 #include "nexthop.h"
 #include "table.h"
 #include "srcdest_table.h"
+#include "mgmt_be_client.h"
 #include "mpls.h"
 #include "northbound.h"
 #include "libfrr.h"
@@ -285,10 +286,10 @@ static int static_route_nb_run(struct vty *vty, struct static_route_args *args)
                                nb_cli_enqueue_change(vty, ab_xpath,
                                                      NB_OP_MODIFY, "false");
                }
-               if (type == STATIC_IPV4_GATEWAY
-                   || type == STATIC_IPV6_GATEWAY
-                   || type == STATIC_IPV4_GATEWAY_IFNAME
-                   || type == STATIC_IPV6_GATEWAY_IFNAME) {
+               if (type == STATIC_IPV4_GATEWAY ||
+                   type == STATIC_IPV6_GATEWAY ||
+                   type == STATIC_IPV4_GATEWAY_IFNAME ||
+                   type == STATIC_IPV6_GATEWAY_IFNAME) {
                        strlcpy(ab_xpath, xpath_nexthop, sizeof(ab_xpath));
                        strlcat(ab_xpath, FRR_STATIC_ROUTE_NH_COLOR_XPATH,
                                sizeof(ab_xpath));
@@ -368,25 +369,51 @@ static int static_route_nb_run(struct vty *vty, struct static_route_args *args)
 
                ret = nb_cli_apply_changes(vty, "%s", xpath_prefix);
        } else {
-               if (args->source)
-                       snprintf(ab_xpath, sizeof(ab_xpath),
-                                FRR_DEL_S_ROUTE_SRC_NH_KEY_NO_DISTANCE_XPATH,
-                                "frr-staticd:staticd", "staticd", args->vrf,
-                                buf_prefix,
-                                yang_afi_safi_value2identity(args->afi,
-                                                             args->safi),
-                                buf_src_prefix, table_id, buf_nh_type,
-                                args->nexthop_vrf, buf_gate_str,
-                                args->interface_name);
-               else
-                       snprintf(ab_xpath, sizeof(ab_xpath),
-                                FRR_DEL_S_ROUTE_NH_KEY_NO_DISTANCE_XPATH,
-                                "frr-staticd:staticd", "staticd", args->vrf,
-                                buf_prefix,
-                                yang_afi_safi_value2identity(args->afi,
-                                                             args->safi),
-                                table_id, buf_nh_type, args->nexthop_vrf,
-                                buf_gate_str, args->interface_name);
+               if (args->source) {
+                       if (args->distance)
+                               snprintf(ab_xpath, sizeof(ab_xpath),
+                                        FRR_DEL_S_ROUTE_SRC_NH_KEY_XPATH,
+                                        "frr-staticd:staticd", "staticd",
+                                        args->vrf, buf_prefix,
+                                        yang_afi_safi_value2identity(
+                                                args->afi, args->safi),
+                                        buf_src_prefix, table_id, distance,
+                                        buf_nh_type, args->nexthop_vrf,
+                                        buf_gate_str, args->interface_name);
+                       else
+                               snprintf(
+                                       ab_xpath, sizeof(ab_xpath),
+                                       FRR_DEL_S_ROUTE_SRC_NH_KEY_NO_DISTANCE_XPATH,
+                                       "frr-staticd:staticd", "staticd",
+                                       args->vrf, buf_prefix,
+                                       yang_afi_safi_value2identity(
+                                               args->afi, args->safi),
+                                       buf_src_prefix, table_id, buf_nh_type,
+                                       args->nexthop_vrf, buf_gate_str,
+                                       args->interface_name);
+               } else {
+                       if (args->distance)
+                               snprintf(ab_xpath, sizeof(ab_xpath),
+                                        FRR_DEL_S_ROUTE_NH_KEY_XPATH,
+                                        "frr-staticd:staticd", "staticd",
+                                        args->vrf, buf_prefix,
+                                        yang_afi_safi_value2identity(
+                                                args->afi, args->safi),
+                                        table_id, distance, buf_nh_type,
+                                        args->nexthop_vrf, buf_gate_str,
+                                        args->interface_name);
+                       else
+                               snprintf(
+                                       ab_xpath, sizeof(ab_xpath),
+                                       FRR_DEL_S_ROUTE_NH_KEY_NO_DISTANCE_XPATH,
+                                       "frr-staticd:staticd", "staticd",
+                                       args->vrf, buf_prefix,
+                                       yang_afi_safi_value2identity(
+                                               args->afi, args->safi),
+                                       table_id, buf_nh_type,
+                                       args->nexthop_vrf, buf_gate_str,
+                                       args->interface_name);
+               }
 
                dnode = yang_dnode_get(vty->candidate_config->dnode, ab_xpath);
                if (!dnode) {
@@ -1452,15 +1479,18 @@ DEFPY_YANG(debug_staticd, debug_staticd_cmd,
           "Debug route\n"
           "Debug bfd\n")
 {
+#ifndef INCLUDE_MGMTD_CMDDEFS_ONLY
        /* If no specific category, change all */
        if (strmatch(argv[argc - 1]->text, "static"))
                static_debug_set(vty->node, !no, true, true, true);
        else
                static_debug_set(vty->node, !no, !!events, !!route, !!bfd);
+#endif /* ifndef INCLUDE_MGMTD_CMDDEFS_ONLY */
 
        return CMD_SUCCESS;
 }
 
+#ifndef INCLUDE_MGMTD_CMDDEFS_ONLY
 DEFPY(staticd_show_bfd_routes, staticd_show_bfd_routes_cmd,
       "show bfd static route [json]$isjson",
       SHOW_STR
@@ -1496,9 +1526,15 @@ static struct cmd_node debug_node = {
        .config_write = static_config_write_debug,
 };
 
+#endif /* ifndef INCLUDE_MGMTD_CMDDEFS_ONLY */
+
 void static_vty_init(void)
 {
+#ifndef INCLUDE_MGMTD_CMDDEFS_ONLY
        install_node(&debug_node);
+       install_element(ENABLE_NODE, &show_debugging_static_cmd);
+       install_element(ENABLE_NODE, &staticd_show_bfd_routes_cmd);
+#endif /* ifndef INCLUDE_MGMTD_CMDDEFS_ONLY */
 
        install_element(CONFIG_NODE, &ip_mroute_dist_cmd);
 
@@ -1516,9 +1552,8 @@ void static_vty_init(void)
        install_element(CONFIG_NODE, &ipv6_route_cmd);
        install_element(VRF_NODE, &ipv6_route_vrf_cmd);
 
-       install_element(ENABLE_NODE, &show_debugging_static_cmd);
        install_element(ENABLE_NODE, &debug_staticd_cmd);
        install_element(CONFIG_NODE, &debug_staticd_cmd);
 
-       install_element(ENABLE_NODE, &staticd_show_bfd_routes_cmd);
+       mgmt_be_client_lib_vty_init();
 }