]> git.puffer.fish Git - matthieu/frr.git/commitdiff
mgmtd: Enroll Staticd as a backend client for MGMTD
authorYash Ranjan <ranjany@vmware.com>
Thu, 28 Oct 2021 13:35:37 +0000 (06:35 -0700)
committerChristian Hopps <chopps@labn.net>
Wed, 6 Apr 2022 01:41:23 +0000 (21:41 -0400)
This commmit introduces Staticd as a backend client for the MGMTd
framework. All the static commands will be diverted to the MGMT
daemon and will use the transactional model to make changes to the
internal state. Similar mechanism can be used by other daemons to use
the MGMT framework in the future.

This commit includes the following functionalities in the changeset:
1. Diverts all the staticd (config only) commands to MGMTd.
2. Enrolls staticd as a backend client to use the MGMT framework.
3. Modify the staticd NB config handlers so that they can be compiled
   into a library and loaded in the MGMTd process context.

Co-authored-by: Pushpasis Sarkar <pushpasis@gmail.com>
Co-authored-by: Abhinay Ramesh <rabhinay@vmware.com>
Co-authored-by: Ujwal P <ujwalp@vmware.com>
Signed-off-by: Yash Ranjan <ranjany@vmware.com>
15 files changed:
debian/frr.install
mgmtd/mgmt_main.c
mgmtd/mgmt_vty.c
mgmtd/mgmt_vty.h
mgmtd/subdir.am
staticd/static_main.c
staticd/static_nb.c
staticd/static_nb.h
staticd/static_nb_config.c
staticd/static_routes.c
staticd/static_routes.h
staticd/static_vty.c
staticd/static_vty.h
staticd/static_zebra.c
vtysh/extract.pl.in

index 48263222f82b958e19f1d7a6e181edca45fbfafb..fab7d353aa0c65cea2423b557899d2fb4c9d5ebf 100644 (file)
@@ -7,6 +7,7 @@ usr/bin/vtysh
 usr/lib/*/frr/libfrr.*
 usr/lib/*/frr/libfrrcares.*
 usr/lib/*/frr/libfrrospfapiclient.*
+usr/lib/*/frr/libmgmt_bcknd_nb.*
 usr/lib/*/frr/modules/bgpd_bmp.so
 usr/lib/*/frr/modules/dplane_fpm_nl.so
 usr/lib/*/frr/modules/zebra_cumulus_mlag.so
index 3933838a26523015ef12a86655efe5c82b227b26..adb0d6a0aea8a2cedf3b247639f6076f13501a2d 100644 (file)
@@ -213,7 +213,7 @@ static void mgmt_vrf_terminate(void)
  */
 static const struct frr_yang_module_info *const mgmt_yang_modules[] = {
        &frr_filter_info,  &frr_interface_info, &frr_route_map_info,
-       &frr_routing_info, &frr_vrf_info,
+       &frr_routing_info, &frr_vrf_info,       &frr_staticd_info,
 };
 
 FRR_DAEMON_INFO(mgmtd, MGMTD, .vty_port = MGMTD_VTY_PORT,
index b15a597a650e9117cd359aea0e555d2e99ce477e..4f534a0a22016fc046bf0482c5dbb29ecc3798e2 100644 (file)
@@ -34,6 +34,8 @@
 #include "mgmtd/mgmt_vty_clippy.c"
 #endif
 
+#define INCLUDE_MGMTD_CMDDEFS_ONLY
+
 /*
  * mgmt_enqueue_nb_command
  *
@@ -711,6 +713,14 @@ DEFPY(debug_mgmt_all,
 
 void mgmt_vty_init(void)
 {
+       /*
+        * Initialize command handling from VTYSH connection.
+        * Call command initialization routines defined by
+        * backend components that are moved to new MGMTD infra
+        * here one by one.
+        */
+       static_vty_init();
+
        install_node(&debug_node);
 
        install_element(VIEW_NODE, &show_mgmt_bcknd_adapter_cmd);
index 91e39f1aa74b4a57568efb2d32b3a1a0d2dd5831..a40d0322fcf589fbe4ea1790e4e224651efbf767 100644 (file)
 #ifndef _MGMTD_VTY_H
 #define _MGMTD_VTY_H
 
-#include "lib/command.h"
 #include "northbound_cli.h"
 
+/*
+ * Declare prototypes for command initialization routines defined by
+ * backend components that have been moved to new MGMTD infra here
+ * one by one. These are supposed to be compiled into
+ * mgmt/ibmgmt_bcknd_nb.la first and then called from mgmt_vty_init()
+ * below to load all backend client command handlers on MGMTd
+ * process context.
+ */
+extern void static_vty_init(void);
+
 extern void mgmt_enqueue_vty_nb_command(struct vty *vty, const char *xpath,
                                        enum nb_operation operation,
                                        const char *value);
index 2a5bd8e32df7414cc60295890567e0c3891144ab..e96f99eb0ed90646d8c16caa803a86653ca51422 100644 (file)
@@ -13,10 +13,24 @@ vtysh_daemons += mgmtd
 # man8 += $(MANBUILD)/frr-mgmtd.8
 # endif
 
+$(mgmtd_mgmtd_OBJECTS): yang/frr-staticd.yang.c
+CLEANFILES += yang/frr-staticd.yang.c
+
 clippy_scan += \
        mgmtd/mgmt_vty.c \
        # end
 
+lib_LTLIBRARIES += mgmtd/libmgmt_bcknd_nb.la
+nodist_mgmtd_libmgmt_bcknd_nb_la_SOURCES = \
+       yang/frr-staticd.yang.c \
+       staticd/static_vty.c \
+       staticd/static_nb.c \
+       staticd/static_nb_config.c \
+       # end
+mgmtd_libmgmt_bcknd_nb_la_CFLAGS = $(AM_CFLAGS) -DINCLUDE_MGMTD_CMDDEFS_ONLY -DINCLUDE_MGMTD_VALIDATE_ONLY
+mgmtd_libmgmt_bcknd_nb_la_CPPFLAGS = $(AM_CPPFLAGS) -DINCLUDE_MGMTD_CMDDEFS_ONLY -DINCLUDE_MGMTD_VALIDATE_ONLY
+mgmtd_libmgmt_bcknd_nb_la_LDFLAGS = -version-info 0:0:0
+
 noinst_LIBRARIES += mgmtd/libmgmtd.a
 mgmtd_libmgmtd_a_SOURCES = \
        mgmtd/mgmt.c \
@@ -54,3 +68,4 @@ mgmtd_mgmtd_SOURCES = \
        # end
 mgmtd_mgmtd_CFLAGS = $(AM_CFLAGS) -I ./
 mgmtd_mgmtd_LDADD = mgmtd/libmgmtd.a lib/libfrr.la $(LIBCAP) $(LIBM) $(LIBYANG_LIBS) $(UST_LIBS)
+mgmtd_mgmtd_LDADD += mgmtd/libmgmt_bcknd_nb.la
index 7badd5004954f2cf6026e9b3b90eaae122d9e94a..5824eb933339a07bfaeee681f170019090ad2aae 100644 (file)
@@ -77,6 +77,8 @@ static void sigint(void)
 {
        zlog_notice("Terminating on signal");
 
+       static_mgmt_destroy();
+
        static_vrf_terminate();
 
        frr_fini();
@@ -159,6 +161,9 @@ int main(int argc, char **argv, char **envp)
        static_zebra_init();
        static_vty_init();
 
+       /* Initialize MGMT backend functionalities */
+       static_mgmt_init(master);
+
        hook_register(routing_conf_event,
                      routing_control_plane_protocols_name_validate);
 
index 5935364d5a61b35c3adcf9a83a97c6930433bcfe..dd413a5b8f48d94e348127b2852526656af15d2b 100644 (file)
@@ -60,7 +60,9 @@ const struct frr_yang_module_info frr_staticd_info = {
                {
                        .xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop",
                        .cbs = {
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
                                .apply_finish = routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_apply_finish,
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                                .create = routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_create,
                                .destroy = routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_destroy,
                                .pre_validate = routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_pre_validate,
@@ -141,7 +143,9 @@ const struct frr_yang_module_info frr_staticd_info = {
                {
                        .xpath = "/frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop",
                        .cbs = {
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
                                .apply_finish = routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_apply_finish,
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                                .create = routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_create,
                                .destroy = routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_destroy,
                                .pre_validate = routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_pre_validate,
index 5c3030fcfa5d4bd848971991dff6293121cdc63c..899f4a5c385e660f3e775fa1d41d6f73faa67ffa 100644 (file)
@@ -171,7 +171,7 @@ int routing_control_plane_protocols_name_validate(
        FRR_STATIC_ROUTE_NH_KEY_XPATH
 
 /* route-list/frr-nexthops */
-#define FRR_DEL_S_ROUTE_NH_KEY_NO_DISTANCE_XPATH                               \
+#define FRR_DEL_S_ROUTE_NH_KEY_NO_DIST_XPATH                                   \
        FRR_STATIC_ROUTE_INFO_KEY_NO_DISTANCE_XPATH                            \
        FRR_STATIC_ROUTE_NH_KEY_XPATH
 
@@ -181,7 +181,7 @@ int routing_control_plane_protocols_name_validate(
        FRR_STATIC_ROUTE_NH_KEY_XPATH
 
 /* route-list/src/src-list/frr-nexthops*/
-#define FRR_DEL_S_ROUTE_SRC_NH_KEY_NO_DISTANCE_XPATH                           \
+#define FRR_DEL_S_ROUTE_SRC_NH_KEY_NODIST_XPATH                                \
        FRR_S_ROUTE_SRC_INFO_KEY_NO_DISTANCE_XPATH                             \
        FRR_STATIC_ROUTE_NH_KEY_XPATH
 
index 9ccffe53d9afdc935432f749a0185f1ba7901586..0e7e5e55cb565d770475b7005b7b833fb12da56e 100644 (file)
 #include "static_routes.h"
 #include "static_nb.h"
 
+uint32_t zebra_ecmp_count = MULTIPATH_NUM;
 
 static int static_path_list_create(struct nb_cb_create_args *args)
 {
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
        struct route_node *rn;
        struct static_path *pn;
+       uint8_t distance;
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
        const struct lyd_node *vrf_dnode;
        const char *vrf;
-       uint8_t distance;
        uint32_t table_id;
 
        switch (args->event) {
@@ -67,11 +70,14 @@ static int static_path_list_create(struct nb_cb_create_args *args)
        case NB_EV_PREPARE:
                break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
                rn = nb_running_get_entry(args->dnode, NULL, true);
                distance = yang_dnode_get_uint8(args->dnode, "./distance");
                table_id = yang_dnode_get_uint32(args->dnode, "./table-id");
                pn = static_add_path(rn, table_id, distance);
                nb_running_set_entry(args->dnode, pn);
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
+               break;
        }
 
        return NB_OK;
@@ -79,7 +85,9 @@ static int static_path_list_create(struct nb_cb_create_args *args)
 
 static int static_path_list_destroy(struct nb_cb_destroy_args *args)
 {
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
        struct static_path *pn;
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
 
        switch (args->event) {
        case NB_EV_VALIDATE:
@@ -87,8 +95,10 @@ static int static_path_list_destroy(struct nb_cb_destroy_args *args)
        case NB_EV_ABORT:
                break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
                pn = nb_running_unset_entry(args->dnode);
                static_del_path(pn);
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
 
@@ -97,7 +107,9 @@ static int static_path_list_destroy(struct nb_cb_destroy_args *args)
 
 static int static_path_list_tag_modify(struct nb_cb_modify_args *args)
 {
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
        struct static_path *pn;
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
 
        switch (args->event) {
        case NB_EV_VALIDATE:
@@ -105,9 +117,11 @@ static int static_path_list_tag_modify(struct nb_cb_modify_args *args)
        case NB_EV_PREPARE:
                break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
                pn = nb_running_get_entry(args->dnode, NULL, true);
                pn->tag = yang_dnode_get_uint32(args->dnode, NULL);
                static_install_path(pn);
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
 
@@ -138,12 +152,14 @@ static bool static_nexthop_create(struct nb_cb_create_args *args)
 {
        const struct lyd_node *pn_dnode;
        struct nexthop_iter iter;
+       const char *ifname;
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
        struct static_path *pn;
        struct ipaddr ipaddr;
        struct static_nexthop *nh;
        enum static_nh_type nh_type;
-       const char *ifname;
        const char *nh_vrf;
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
 
        switch (args->event) {
        case NB_EV_VALIDATE:
@@ -182,6 +198,7 @@ static bool static_nexthop_create(struct nb_cb_create_args *args)
        case NB_EV_ABORT:
                break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
                yang_dnode_get_ip(&ipaddr, args->dnode, "./gateway");
                nh_type = yang_dnode_get_enum(args->dnode, "./nh-type");
                ifname = yang_dnode_get_string(args->dnode, "./interface");
@@ -197,6 +214,7 @@ static bool static_nexthop_create(struct nb_cb_create_args *args)
                nh = static_add_nexthop(pn, nh_type, &ipaddr, ifname, nh_vrf,
                                        0);
                nb_running_set_entry(args->dnode, nh);
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
 
@@ -205,7 +223,9 @@ static bool static_nexthop_create(struct nb_cb_create_args *args)
 
 static bool static_nexthop_destroy(struct nb_cb_destroy_args *args)
 {
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
        struct static_nexthop *nh;
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
 
        switch (args->event) {
        case NB_EV_VALIDATE:
@@ -213,8 +233,10 @@ static bool static_nexthop_destroy(struct nb_cb_destroy_args *args)
        case NB_EV_ABORT:
                break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
                nh = nb_running_unset_entry(args->dnode);
                static_delete_nexthop(nh);
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
 
@@ -223,23 +245,28 @@ static bool static_nexthop_destroy(struct nb_cb_destroy_args *args)
 
 static int nexthop_mpls_label_stack_entry_create(struct nb_cb_create_args *args)
 {
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
        struct static_nexthop *nh;
        uint32_t pos;
        uint8_t index;
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
 
        switch (args->event) {
        case NB_EV_VALIDATE:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
                if (!mpls_enabled) {
                        snprintf(
                                args->errmsg, args->errmsg_len,
                                "%% MPLS not turned on in kernel ignoring static route");
                        return NB_ERR_VALIDATION;
                }
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        case NB_EV_PREPARE:
        case NB_EV_ABORT:
                break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
                nh = nb_running_get_entry(args->dnode, NULL, true);
                pos = yang_get_list_pos(args->dnode);
                if (!pos) {
@@ -251,6 +278,7 @@ static int nexthop_mpls_label_stack_entry_create(struct nb_cb_create_args *args)
                index = pos - 1;
                nh->snh_label.label[index] = 0;
                nh->snh_label.num_labels++;
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
 
@@ -260,9 +288,11 @@ static int nexthop_mpls_label_stack_entry_create(struct nb_cb_create_args *args)
 static int
 nexthop_mpls_label_stack_entry_destroy(struct nb_cb_destroy_args *args)
 {
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
        struct static_nexthop *nh;
        uint32_t pos;
        uint8_t index;
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
 
        switch (args->event) {
        case NB_EV_VALIDATE:
@@ -270,6 +300,7 @@ nexthop_mpls_label_stack_entry_destroy(struct nb_cb_destroy_args *args)
        case NB_EV_ABORT:
                break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
                nh = nb_running_get_entry(args->dnode, NULL, true);
                pos = yang_get_list_pos(args->dnode);
                if (!pos) {
@@ -280,12 +311,14 @@ nexthop_mpls_label_stack_entry_destroy(struct nb_cb_destroy_args *args)
                index = pos - 1;
                nh->snh_label.label[index] = 0;
                nh->snh_label.num_labels--;
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
 
        return NB_OK;
 }
 
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
 static int static_nexthop_mpls_label_modify(struct nb_cb_modify_args *args)
 {
        struct static_nexthop *nh;
@@ -305,10 +338,13 @@ static int static_nexthop_mpls_label_modify(struct nb_cb_modify_args *args)
 
        return NB_OK;
 }
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
 
 static int static_nexthop_onlink_modify(struct nb_cb_modify_args *args)
 {
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
        struct static_nexthop *nh;
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
        enum static_nh_type nh_type;
 
        switch (args->event) {
@@ -326,14 +362,17 @@ static int static_nexthop_onlink_modify(struct nb_cb_modify_args *args)
        case NB_EV_ABORT:
                break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
                nh = nb_running_get_entry(args->dnode, NULL, true);
                nh->onlink = yang_dnode_get_bool(args->dnode, NULL);
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
 
        return NB_OK;
 }
 
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
 static int static_nexthop_color_modify(struct nb_cb_modify_args *args)
 {
        struct static_nexthop *nh;
@@ -353,10 +392,13 @@ static int static_nexthop_color_destroy(struct nb_cb_destroy_args *args)
 
        return NB_OK;
 }
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
 
 static int static_nexthop_bh_type_modify(struct nb_cb_modify_args *args)
 {
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
        struct static_nexthop *nh;
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
        enum static_nh_type nh_type;
 
        switch (args->event) {
@@ -372,14 +414,17 @@ static int static_nexthop_bh_type_modify(struct nb_cb_modify_args *args)
        case NB_EV_ABORT:
                break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
                nh = nb_running_get_entry(args->dnode, NULL, true);
                nh->bh_type = yang_dnode_get_enum(args->dnode, NULL);
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
 
        return NB_OK;
 }
 
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
 void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_apply_finish(
        struct nb_cb_apply_finish_args *args)
 {
@@ -399,6 +444,7 @@ void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_s
 
        static_install_nexthop(nh);
 }
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
 
 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_pre_validate(
        struct nb_cb_pre_validate_args *args)
@@ -438,10 +484,12 @@ int routing_control_plane_protocols_name_validate(
 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_create(
        struct nb_cb_create_args *args)
 {
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
+       const struct lyd_node *vrf_dnode;
        struct vrf *vrf;
        struct static_vrf *s_vrf;
        struct route_node *rn;
-       const struct lyd_node *vrf_dnode;
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
        struct prefix prefix;
        const char *afi_safi;
        afi_t prefix_afi;
@@ -466,6 +514,7 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_cr
        case NB_EV_ABORT:
                break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
                vrf_dnode = yang_dnode_get_parent(args->dnode,
                                                  "control-plane-protocol");
                vrf = nb_running_get_entry(vrf_dnode, NULL, true);
@@ -482,6 +531,7 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_cr
                                "Static Route to %s not installed currently because dependent config not fully available",
                                yang_dnode_get_string(args->dnode, "./prefix"));
                nb_running_set_entry(args->dnode, rn);
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
        return NB_OK;
@@ -490,7 +540,9 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_cr
 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_destroy(
        struct nb_cb_destroy_args *args)
 {
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
        struct route_node *rn;
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
 
        switch (args->event) {
        case NB_EV_VALIDATE:
@@ -498,8 +550,10 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_de
        case NB_EV_ABORT:
                break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
                rn = nb_running_unset_entry(args->dnode);
                static_del_route(rn);
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
        return NB_OK;
@@ -580,9 +634,11 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_pa
        case NB_EV_ABORT:
                break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
                if (static_nexthop_color_modify(args) != NB_OK)
                        return NB_ERR;
 
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
        return NB_OK;
@@ -597,8 +653,10 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_pa
        case NB_EV_ABORT:
                break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
                if (static_nexthop_color_destroy(args) != NB_OK)
                        return NB_ERR;
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
        return NB_OK;
@@ -633,8 +691,10 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_pa
        case NB_EV_ABORT:
                break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
                if (static_nexthop_mpls_label_modify(args) != NB_OK)
                        return NB_ERR;
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
        return NB_OK;
@@ -652,7 +712,13 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_pa
        case NB_EV_VALIDATE:
        case NB_EV_PREPARE:
        case NB_EV_ABORT:
+               break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
+               /*
+                * TODO: Add Backend-specific processing code here.
+                */
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
        return NB_OK;
@@ -669,7 +735,13 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_pa
        case NB_EV_VALIDATE:
        case NB_EV_PREPARE:
        case NB_EV_ABORT:
+               break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
+               /*
+                * TODO: Add Backend-specific processing code here.
+                */
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
 
@@ -683,7 +755,13 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_pa
        case NB_EV_VALIDATE:
        case NB_EV_PREPARE:
        case NB_EV_ABORT:
+               break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
+               /*
+                * TODO: Add Backend-specific processing code here.
+                */
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
 
@@ -701,7 +779,13 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_pa
        case NB_EV_VALIDATE:
        case NB_EV_PREPARE:
        case NB_EV_ABORT:
+               break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
+               /*
+                * TODO: Add Backend-specific processing code here.
+                */
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
 
@@ -715,7 +799,13 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_pa
        case NB_EV_VALIDATE:
        case NB_EV_PREPARE:
        case NB_EV_ABORT:
+               break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
+               /*
+                * TODO: Add Backend-specific processing code here.
+                */
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
 
@@ -729,6 +819,7 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_pa
 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_create(
        struct nb_cb_create_args *args)
 {
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
        struct static_vrf *s_vrf;
        struct route_node *rn;
        struct route_node *src_rn;
@@ -736,6 +827,7 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_sr
        struct stable_info *info;
        afi_t afi;
        safi_t safi = SAFI_UNICAST;
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
 
        switch (args->event) {
        case NB_EV_VALIDATE:
@@ -743,6 +835,7 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_sr
        case NB_EV_ABORT:
                break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
                rn = nb_running_get_entry(args->dnode, NULL, true);
                info = route_table_get_info(rn->table);
                s_vrf = info->svrf;
@@ -751,6 +844,7 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_sr
                src_rn =
                        static_add_route(afi, safi, &rn->p, &src_prefix, s_vrf);
                nb_running_set_entry(args->dnode, src_rn);
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
        return NB_OK;
@@ -759,7 +853,9 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_sr
 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_destroy(
        struct nb_cb_destroy_args *args)
 {
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
        struct route_node *src_rn;
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
 
        switch (args->event) {
        case NB_EV_VALIDATE:
@@ -767,8 +863,10 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_sr
        case NB_EV_ABORT:
                break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
                src_rn = nb_running_unset_entry(args->dnode);
                static_del_route(src_rn);
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
 
@@ -850,9 +948,10 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_sr
        case NB_EV_ABORT:
                break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
                if (static_nexthop_color_modify(args) != NB_OK)
                        return NB_ERR;
-
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
        return NB_OK;
@@ -868,8 +967,10 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_sr
        case NB_EV_ABORT:
                break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
                if (static_nexthop_color_destroy(args) != NB_OK)
                        return NB_ERR;
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
        return NB_OK;
@@ -904,8 +1005,10 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_sr
        case NB_EV_ABORT:
                break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
                if (static_nexthop_mpls_label_modify(args) != NB_OK)
                        return NB_ERR;
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
        return NB_OK;
@@ -923,7 +1026,13 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_sr
        case NB_EV_VALIDATE:
        case NB_EV_PREPARE:
        case NB_EV_ABORT:
+               break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
+               /*
+                * TODO: Add Backend-specific processing code here.
+                */
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
        return NB_OK;
@@ -940,7 +1049,13 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_sr
        case NB_EV_VALIDATE:
        case NB_EV_PREPARE:
        case NB_EV_ABORT:
+               break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
+               /*
+                * TODO: Add Backend-specific processing code here.
+                */
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
 
@@ -954,7 +1069,13 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_sr
        case NB_EV_VALIDATE:
        case NB_EV_PREPARE:
        case NB_EV_ABORT:
+               break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
+               /*
+                * TODO: Add Backend-specific processing code here.
+                */
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
 
@@ -972,7 +1093,13 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_sr
        case NB_EV_VALIDATE:
        case NB_EV_PREPARE:
        case NB_EV_ABORT:
+               break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
+               /*
+                * TODO: Add Backend-specific processing code here.
+                */
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
 
@@ -986,7 +1113,13 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_sr
        case NB_EV_VALIDATE:
        case NB_EV_PREPARE:
        case NB_EV_ABORT:
+               break;
        case NB_EV_APPLY:
+#ifndef INCLUDE_MGMTD_VALIDATE_ONLY
+               /*
+                * TODO: Add Backend-specific processing code here.
+                */
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
                break;
        }
 
index 589d509a59989d0ca1a1fddf4e4284e2f9d38668..e0b3fc1f400495c61e3df45cde2a1c64ce0bed75 100644 (file)
@@ -764,30 +764,6 @@ void static_ifindex_update(struct interface *ifp, bool up)
        static_ifindex_update_af(ifp, up, AFI_IP6, SAFI_MULTICAST);
 }
 
-void static_get_nh_type(enum static_nh_type stype, char *type, size_t size)
-{
-       switch (stype) {
-       case STATIC_IFNAME:
-               strlcpy(type, "ifindex", size);
-               break;
-       case STATIC_IPV4_GATEWAY:
-               strlcpy(type, "ip4", size);
-               break;
-       case STATIC_IPV4_GATEWAY_IFNAME:
-               strlcpy(type, "ip4-ifindex", size);
-               break;
-       case STATIC_BLACKHOLE:
-               strlcpy(type, "blackhole", size);
-               break;
-       case STATIC_IPV6_GATEWAY:
-               strlcpy(type, "ip6", size);
-               break;
-       case STATIC_IPV6_GATEWAY_IFNAME:
-               strlcpy(type, "ip6-ifindex", size);
-               break;
-       };
-}
-
 struct stable_info *static_get_stable_info(struct route_node *rn)
 {
        struct route_table *table;
index 71c3689be54ad3eb60e6d41b64a7350cda18721e..d378a6ec4b9d064a249c5e24ed71de9a79176469 100644 (file)
@@ -162,6 +162,31 @@ static_route_info_from_rnode(struct route_node *rn)
        return (struct static_route_info *)(rn->info);
 }
 
+static inline void static_get_nh_type(enum static_nh_type stype, char *type,
+                                     size_t size)
+{
+       switch (stype) {
+       case STATIC_IFNAME:
+               strlcpy(type, "ifindex", size);
+               break;
+       case STATIC_IPV4_GATEWAY:
+               strlcpy(type, "ip4", size);
+               break;
+       case STATIC_IPV4_GATEWAY_IFNAME:
+               strlcpy(type, "ip4-ifindex", size);
+               break;
+       case STATIC_BLACKHOLE:
+               strlcpy(type, "blackhole", size);
+               break;
+       case STATIC_IPV6_GATEWAY:
+               strlcpy(type, "ip6", size);
+               break;
+       case STATIC_IPV6_GATEWAY_IFNAME:
+               strlcpy(type, "ip6-ifindex", size);
+               break;
+       };
+}
+
 extern bool mpls_enabled;
 extern uint32_t zebra_ecmp_count;
 
@@ -195,8 +220,6 @@ extern struct static_path *static_add_path(struct route_node *rn,
                                           uint32_t table_id, uint8_t distance);
 extern void static_del_path(struct static_path *pn);
 
-extern void static_get_nh_type(enum static_nh_type stype, char *type,
-                              size_t size);
 extern bool static_add_nexthop_validate(const char *nh_vrf_name,
                                        enum static_nh_type type,
                                        struct ipaddr *ipaddr);
index c0ace0e2588ca9d1f65c8595ea6585ba4685357a..cf699c3e494651fe9b2bb6ff1b997b6d5cd0038d 100644 (file)
@@ -41,6 +41,8 @@
 #endif
 #include "static_nb.h"
 
+#include "mgmt_bcknd_client.h"
+
 #define STATICD_STR "Static route daemon\n"
 
 static int static_route_leak(struct vty *vty, const char *svrf,
@@ -56,7 +58,7 @@ static int static_route_leak(struct vty *vty, const char *svrf,
        int ret;
        struct prefix p, src;
        struct in_addr mask;
-       enum static_nh_type type;
+       uint8_t type;
        const char *bh_type;
        char xpath_prefix[XPATH_MAXLEN];
        char xpath_nexthop[XPATH_MAXLEN];
@@ -153,7 +155,7 @@ static int static_route_leak(struct vty *vty, const char *svrf,
        if (!negate) {
                if (src_str)
                        snprintf(ab_xpath, sizeof(ab_xpath),
-                                FRR_DEL_S_ROUTE_SRC_NH_KEY_NO_DISTANCE_XPATH,
+                                FRR_DEL_S_ROUTE_SRC_NH_KEY_NODIST_XPATH,
                                 "frr-staticd:staticd", "staticd", svrf,
                                 buf_prefix,
                                 yang_afi_safi_value2identity(afi, safi),
@@ -161,7 +163,7 @@ static int static_route_leak(struct vty *vty, const char *svrf,
                                 buf_gate_str, ifname);
                else
                        snprintf(ab_xpath, sizeof(ab_xpath),
-                                FRR_DEL_S_ROUTE_NH_KEY_NO_DISTANCE_XPATH,
+                                FRR_DEL_S_ROUTE_NH_KEY_NO_DIST_XPATH,
                                 "frr-staticd:staticd", "staticd", svrf,
                                 buf_prefix,
                                 yang_afi_safi_value2identity(afi, safi),
@@ -257,8 +259,7 @@ static int static_route_leak(struct vty *vty, const char *svrf,
                                nb_cli_enqueue_change(vty, ab_xpath,
                                                      NB_OP_MODIFY, "false");
                }
-               if (type == STATIC_IPV4_GATEWAY
-                   || type == STATIC_IPV6_GATEWAY
+               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));
@@ -304,22 +305,46 @@ static int static_route_leak(struct vty *vty, const char *svrf,
                }
                ret = nb_cli_apply_changes(vty, xpath_prefix);
        } else {
-               if (src_str)
-                       snprintf(ab_xpath, sizeof(ab_xpath),
-                                FRR_DEL_S_ROUTE_SRC_NH_KEY_NO_DISTANCE_XPATH,
-                                "frr-staticd:staticd", "staticd", svrf,
-                                buf_prefix,
-                                yang_afi_safi_value2identity(afi, safi),
-                                buf_src_prefix, table_id, buf_nh_type, nh_svrf,
-                                buf_gate_str, ifname);
-               else
-                       snprintf(ab_xpath, sizeof(ab_xpath),
-                                FRR_DEL_S_ROUTE_NH_KEY_NO_DISTANCE_XPATH,
-                                "frr-staticd:staticd", "staticd", svrf,
-                                buf_prefix,
-                                yang_afi_safi_value2identity(afi, safi),
-                                table_id, buf_nh_type, nh_svrf, buf_gate_str,
-                                ifname);
+               if (src_str) {
+                       if (distance_str)
+                               snprintf(
+                                       ab_xpath, sizeof(ab_xpath),
+                                       FRR_DEL_S_ROUTE_SRC_NH_KEY_XPATH,
+                                       "frr-staticd:staticd", "staticd", svrf,
+                                       buf_prefix,
+                                       yang_afi_safi_value2identity(afi, safi),
+                                       buf_src_prefix, table_id, distance,
+                                       buf_nh_type, nh_svrf, buf_gate_str,
+                                       ifname);
+                       else
+                               snprintf(
+                                       ab_xpath, sizeof(ab_xpath),
+                                       FRR_DEL_S_ROUTE_SRC_NH_KEY_NODIST_XPATH,
+                                       "frr-staticd:staticd", "staticd", svrf,
+                                       buf_prefix,
+                                       yang_afi_safi_value2identity(afi, safi),
+                                       buf_src_prefix, table_id, buf_nh_type,
+                                       nh_svrf, buf_gate_str, ifname);
+               } else {
+                       if (distance_str)
+                               snprintf(
+                                       ab_xpath, sizeof(ab_xpath),
+                                       FRR_DEL_S_ROUTE_NH_KEY_XPATH,
+                                       "frr-staticd:staticd", "staticd", svrf,
+                                       buf_prefix,
+                                       yang_afi_safi_value2identity(afi, safi),
+                                       table_id, distance, buf_nh_type,
+                                       nh_svrf, buf_gate_str, ifname);
+                       else
+                               snprintf(
+                                       ab_xpath, sizeof(ab_xpath),
+                                       FRR_DEL_S_ROUTE_NH_KEY_NO_DIST_XPATH,
+                                       "frr-staticd:staticd", "staticd", svrf,
+                                       buf_prefix,
+                                       yang_afi_safi_value2identity(afi, safi),
+                                       table_id, buf_nh_type, nh_svrf,
+                                       buf_gate_str, ifname);
+               }
 
                dnode = yang_dnode_get(vty->candidate_config->dnode, ab_xpath);
                if (!dnode) {
@@ -338,6 +363,7 @@ static int static_route_leak(struct vty *vty, const char *svrf,
 
        return ret;
 }
+
 static int static_route(struct vty *vty, afi_t afi, safi_t safi,
                        const char *negate, const char *dest_str,
                        const char *mask_str, const char *src_str,
@@ -1281,15 +1307,18 @@ DEFPY_YANG(debug_staticd, debug_staticd_cmd,
           "Debug events\n"
           "Debug route\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);
        else
                static_debug_set(vty->node, !no, !!events, !!route);
+#endif /* ifndef INCLUDE_MGMTD_CMDDEFS_ONLY */
 
        return CMD_SUCCESS;
 }
 
+#ifndef INCLUDE_MGMTD_CMDDEFS_ONLY
 DEFUN_NOSH (show_debugging_static,
            show_debugging_static_cmd,
            "show debugging [static]",
@@ -1311,9 +1340,75 @@ static struct cmd_node debug_node = {
        .config_write = static_config_write_debug,
 };
 
+/*
+ * The following set of functions will take care of initializing the
+ * MGMT Backend lib within the context of the staticd process.
+ */
+
+uintptr_t mgmt_lib_hndl;
+
+static void static_mgmt_bcknd_client_connect(uintptr_t lib_hndl,
+                                            uintptr_t usr_data, bool connected)
+{
+       (void)usr_data;
+
+       assert(lib_hndl == mgmt_lib_hndl);
+
+       zlog_debug("Got %s %s MGMTD Backend Client Server",
+                  connected ? "connected" : "disconnected",
+                  connected ? "to" : "from");
+
+       if (connected)
+               (void)mgmt_bcknd_subscribe_yang_data(mgmt_lib_hndl, NULL, 0);
+}
+
+static void
+static_mgmt_trxn_notify(uintptr_t lib_hndl, uintptr_t usr_data,
+                       struct mgmt_bcknd_client_trxn_ctxt *trxn_ctxt,
+                       bool destroyed)
+{
+       zlog_debug("Got Trxn %s Notify from MGMTD server",
+                  destroyed ? "DESTROY" : "CREATE");
+
+       if (!destroyed) {
+               /*
+                * TODO: Allocate and install a private scratchpad for this
+                * transaction if required
+                */
+       } else {
+               /*
+                * TODO: Uninstall and deallocate the private scratchpad for
+                * this transaction if installed earlier.
+                */
+       }
+}
+
+static struct mgmt_bcknd_client_params mgmt_params = {
+       .name = MGMTD_BCKND_CLIENT_STATICD,
+       .conn_retry_intvl_sec = 3,
+       .client_connect_notify = static_mgmt_bcknd_client_connect,
+       .trxn_notify = static_mgmt_trxn_notify};
+
+void static_mgmt_init(struct thread_master *master)
+{
+       mgmt_lib_hndl = mgmt_bcknd_client_lib_init(&mgmt_params, master);
+       if (!mgmt_lib_hndl) {
+               zlog_err("Failed to initialize MGMTD Backend Client library!");
+               exit(-1);
+       }
+}
+
+void static_mgmt_destroy(void)
+{
+       mgmt_bcknd_client_lib_destroy(mgmt_lib_hndl);
+}
+#endif /* ifndef INCLUDE_MGMTD_CMDDEFS_ONLY */
+
 void static_vty_init(void)
 {
+#ifndef INCLUDE_MGMTD_CMDDEFS_ONLY
        install_node(&debug_node);
+#endif /* ifndef INCLUDE_MGMTD_CMDDEFS_ONLY */
 
        install_element(CONFIG_NODE, &ip_mroute_dist_cmd);
 
@@ -1331,7 +1426,9 @@ void static_vty_init(void)
        install_element(CONFIG_NODE, &ipv6_route_cmd);
        install_element(VRF_NODE, &ipv6_route_vrf_cmd);
 
+#ifndef INCLUDE_MGMTD_CMDDEFS_ONLY
        install_element(ENABLE_NODE, &show_debugging_static_cmd);
+#endif /* ifndef INCLUDE_MGMTD_CMDDEFS_ONLY */
        install_element(ENABLE_NODE, &debug_staticd_cmd);
        install_element(CONFIG_NODE, &debug_staticd_cmd);
 }
index 84a359593f344d6318f3eff71870d92590c89e1e..39035ab1569efcf2fcee62765203e3a4ef9d9794 100644 (file)
 extern "C" {
 #endif
 
+#ifndef INCLUDE_MGMTD_CMDDEFS_ONLY
+void static_mgmt_init(struct thread_master *master);
+void static_mgmt_destroy(void);
+#endif /* ifndef INCLUDE_MGMTD_CMDDEFS_ONLY */
+
 void static_cli_show(struct vty *vty, const struct lyd_node *dnode,
                     bool show_defaults);
 void static_cli_show_end(struct vty *vty, const struct lyd_node *dnode);
index bf0e4e8ab926791596d5d76882fb9d6f038b0c67..e9f4010cb8678778e32921032e9d4bd3707f9f15 100644 (file)
@@ -85,7 +85,8 @@ static struct static_nht_hash_head static_nht_hash[1];
 
 /* Zebra structure to hold current status. */
 struct zclient *zclient;
-uint32_t zebra_ecmp_count = MULTIPATH_NUM;
+
+extern uint32_t zebra_ecmp_count;
 
 /* Interface addition message from zebra. */
 static int static_ifp_create(struct interface *ifp)
index 228a136b71feb8df259d3b9386036badea3b99df..2822f74635733ab7d03094b706e661ae60ba5763 100755 (executable)
@@ -72,6 +72,12 @@ sub scan_file {
             $hidden = 0;
         }
 
+        if ($defun_or_alias =~ /_YANG/) {
+            $yang = 1;
+        } else {
+            $yang = 0;
+        }
+
         $defun_array[0] = '';
 
         # Actual input command string.
@@ -151,6 +157,18 @@ sub scan_file {
            $protocol = "VTYSH_" . uc $protocol;
         }
 
+        if ($yang) {
+            #
+            # MGMTD-NOTE: Slowly bit-by-bit we will move all components and
+            # their command handling to MGMTD daemon. For now following
+            # component commands will be handled by the new MGMTD daemon.
+            #
+            if ($protocol =~ /VTYSH_STATICD$/) {
+                # Move all Static YANG commands to new MGMTD daemon
+                $protocol = "VTYSH_MGMTD";
+            }
+        }
+
         # Append _vtysh to structure then build DEFUN again
         $defun_array[1] = $cmd . "_vtysh";
         $defun_body = join (", ", @defun_array);