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
*/
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,
#include "mgmtd/mgmt_vty_clippy.c"
#endif
+#define INCLUDE_MGMTD_CMDDEFS_ONLY
+
/*
* mgmt_enqueue_nb_command
*
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);
#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);
# 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 \
# 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
{
zlog_notice("Terminating on signal");
+ static_mgmt_destroy();
+
static_vrf_terminate();
frr_fini();
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);
{
.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,
{
.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,
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
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
#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) {
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;
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:
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;
}
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:
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;
}
{
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:
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");
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;
}
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:
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;
}
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) {
index = pos - 1;
nh->snh_label.label[index] = 0;
nh->snh_label.num_labels++;
+#endif /* ifndef INCLUDE_MGMTD_VALIDATE_ONLY */
break;
}
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:
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) {
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;
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) {
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;
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) {
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)
{
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)
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;
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);
"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;
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:
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;
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;
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;
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;
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;
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;
}
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;
}
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;
}
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;
}
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;
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:
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;
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;
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:
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;
}
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;
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;
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;
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;
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;
}
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;
}
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;
}
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;
}
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;
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;
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);
#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,
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];
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),
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),
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));
}
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) {
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,
"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]",
.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);
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);
}
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);
/* 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)
$hidden = 0;
}
+ if ($defun_or_alias =~ /_YANG/) {
+ $yang = 1;
+ } else {
+ $yang = 0;
+ }
+
$defun_array[0] = '';
# Actual input command string.
$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);