forked from Mirror/frr
zebra: convert vrf configuration output to NB
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
parent
d6bd4fca97
commit
741d1d0090
21
lib/vrf.c
21
lib/vrf.c
|
@ -956,6 +956,25 @@ static int lib_vrf_destroy(struct nb_cb_destroy_args *args)
|
|||
return NB_OK;
|
||||
}
|
||||
|
||||
static void lib_vrf_cli_write(struct vty *vty, const struct lyd_node *dnode,
|
||||
bool show_defaults)
|
||||
{
|
||||
const char *name = yang_dnode_get_string(dnode, "name");
|
||||
|
||||
if (strcmp(name, VRF_DEFAULT_NAME)) {
|
||||
vty_out(vty, "!\n");
|
||||
vty_out(vty, "vrf %s\n", name);
|
||||
}
|
||||
}
|
||||
|
||||
static void lib_vrf_cli_write_end(struct vty *vty, const struct lyd_node *dnode)
|
||||
{
|
||||
const char *name = yang_dnode_get_string(dnode, "name");
|
||||
|
||||
if (strcmp(name, VRF_DEFAULT_NAME))
|
||||
vty_out(vty, "exit-vrf\n");
|
||||
}
|
||||
|
||||
static const void *lib_vrf_get_next(struct nb_cb_get_next_args *args)
|
||||
{
|
||||
struct vrf *vrfp = (struct vrf *)args->list_entry;
|
||||
|
@ -1035,6 +1054,8 @@ const struct frr_yang_module_info frr_vrf_info = {
|
|||
.cbs = {
|
||||
.create = lib_vrf_create,
|
||||
.destroy = lib_vrf_destroy,
|
||||
.cli_show = lib_vrf_cli_write,
|
||||
.cli_show_end = lib_vrf_cli_write_end,
|
||||
.get_next = lib_vrf_get_next,
|
||||
.get_keys = lib_vrf_get_keys,
|
||||
.lookup_entry = lib_vrf_lookup_entry,
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "zebra/zebra_vrf.h"
|
||||
#include "zebra/router-id.h"
|
||||
#include "zebra/redistribute.h"
|
||||
#include "zebra/zebra_nb.h"
|
||||
|
||||
#include "router-id_clippy.c"
|
||||
|
||||
|
@ -244,25 +245,6 @@ void router_id_del_address(struct connected *ifc)
|
|||
zsend_router_id_update(client, afi, &after, zvrf_id(zvrf));
|
||||
}
|
||||
|
||||
void router_id_write(struct vty *vty, struct zebra_vrf *zvrf)
|
||||
{
|
||||
char space[2];
|
||||
|
||||
memset(space, 0, sizeof(space));
|
||||
|
||||
if (zvrf_id(zvrf) != VRF_DEFAULT)
|
||||
snprintf(space, sizeof(space), "%s", " ");
|
||||
|
||||
if (zvrf->rid_user_assigned.u.prefix4.s_addr != INADDR_ANY) {
|
||||
vty_out(vty, "%sip router-id %pI4\n", space,
|
||||
&zvrf->rid_user_assigned.u.prefix4);
|
||||
}
|
||||
if (!router_id_v6_is_any(&zvrf->rid6_user_assigned)) {
|
||||
vty_out(vty, "%sipv6 router-id %pI6\n", space,
|
||||
&zvrf->rid6_user_assigned.u.prefix6);
|
||||
}
|
||||
}
|
||||
|
||||
DEFPY_YANG (ip_router_id,
|
||||
ip_router_id_cmd,
|
||||
"ip router-id A.B.C.D$id vrf NAME",
|
||||
|
@ -320,6 +302,17 @@ ALIAS_YANG (ip_router_id_in_vrf,
|
|||
"Manually set the router-id\n"
|
||||
"IP address to use for router-id\n");
|
||||
|
||||
void lib_vrf_zebra_router_id_cli_write(struct vty *vty,
|
||||
const struct lyd_node *dnode,
|
||||
bool show_defaults)
|
||||
{
|
||||
const char *id = yang_dnode_get_string(dnode, NULL);
|
||||
|
||||
zebra_vrf_indent_cli_write(vty, dnode);
|
||||
|
||||
vty_out(vty, "ip router-id %s\n", id);
|
||||
}
|
||||
|
||||
DEFPY_YANG (ipv6_router_id_in_vrf,
|
||||
ipv6_router_id_in_vrf_cmd,
|
||||
"ipv6 router-id X:X::X:X$id",
|
||||
|
@ -337,6 +330,17 @@ DEFPY_YANG (ipv6_router_id_in_vrf,
|
|||
return nb_cli_apply_changes(vty, NULL);
|
||||
}
|
||||
|
||||
void lib_vrf_zebra_ipv6_router_id_cli_write(struct vty *vty,
|
||||
const struct lyd_node *dnode,
|
||||
bool show_defaults)
|
||||
{
|
||||
const char *id = yang_dnode_get_string(dnode, NULL);
|
||||
|
||||
zebra_vrf_indent_cli_write(vty, dnode);
|
||||
|
||||
vty_out(vty, "ipv6 router-id %s\n", id);
|
||||
}
|
||||
|
||||
DEFPY_YANG (no_ip_router_id,
|
||||
no_ip_router_id_cmd,
|
||||
"no ip router-id A.B.C.D vrf NAME",
|
||||
|
|
|
@ -25,7 +25,6 @@ extern void router_id_add_address(struct connected *c);
|
|||
extern void router_id_del_address(struct connected *c);
|
||||
extern void router_id_init(struct zebra_vrf *zvrf);
|
||||
extern void router_id_cmd_init(void);
|
||||
extern void router_id_write(struct vty *vty, struct zebra_vrf *zvrf);
|
||||
extern int router_id_get(afi_t afi, struct prefix *p, struct zebra_vrf *zvrf);
|
||||
extern int router_id_set(afi_t afi, struct prefix *p, struct zebra_vrf *zvrf);
|
||||
|
||||
|
|
|
@ -107,6 +107,7 @@ const struct frr_yang_module_info frr_zebra_info = {
|
|||
.xpath = "/frr-zebra:zebra/route-map-delay",
|
||||
.cbs = {
|
||||
.modify = zebra_route_map_delay_modify,
|
||||
.cli_show = zebra_route_map_delay_cli_write,
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -844,6 +845,7 @@ const struct frr_yang_module_info frr_zebra_info = {
|
|||
.cbs = {
|
||||
.modify = lib_vrf_zebra_router_id_modify,
|
||||
.destroy = lib_vrf_zebra_router_id_destroy,
|
||||
.cli_show = lib_vrf_zebra_router_id_cli_write,
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -851,6 +853,7 @@ const struct frr_yang_module_info frr_zebra_info = {
|
|||
.cbs = {
|
||||
.modify = lib_vrf_zebra_ipv6_router_id_modify,
|
||||
.destroy = lib_vrf_zebra_ipv6_router_id_destroy,
|
||||
.cli_show = lib_vrf_zebra_ipv6_router_id_cli_write,
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -858,6 +861,7 @@ const struct frr_yang_module_info frr_zebra_info = {
|
|||
.cbs = {
|
||||
.create = lib_vrf_zebra_filter_protocol_create,
|
||||
.destroy = lib_vrf_zebra_filter_protocol_destroy,
|
||||
.cli_show = lib_vrf_zebra_filter_protocol_cli_write,
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -871,6 +875,7 @@ const struct frr_yang_module_info frr_zebra_info = {
|
|||
.cbs = {
|
||||
.create = lib_vrf_zebra_filter_nht_create,
|
||||
.destroy = lib_vrf_zebra_filter_nht_destroy,
|
||||
.cli_show = lib_vrf_zebra_filter_nht_cli_write,
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -884,6 +889,7 @@ const struct frr_yang_module_info frr_zebra_info = {
|
|||
.cbs = {
|
||||
.modify = lib_vrf_zebra_resolve_via_default_modify,
|
||||
.destroy = lib_vrf_zebra_resolve_via_default_destroy,
|
||||
.cli_show = lib_vrf_zebra_resolve_via_default_cli_write,
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -891,6 +897,7 @@ const struct frr_yang_module_info frr_zebra_info = {
|
|||
.cbs = {
|
||||
.modify = lib_vrf_zebra_ipv6_resolve_via_default_modify,
|
||||
.destroy = lib_vrf_zebra_ipv6_resolve_via_default_destroy,
|
||||
.cli_show = lib_vrf_zebra_ipv6_resolve_via_default_cli_write,
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -898,6 +905,7 @@ const struct frr_yang_module_info frr_zebra_info = {
|
|||
.cbs = {
|
||||
.create = lib_vrf_zebra_netns_table_range_create,
|
||||
.destroy = lib_vrf_zebra_netns_table_range_destroy,
|
||||
.cli_show = lib_vrf_zebra_netns_table_range_cli_write,
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -1173,6 +1181,7 @@ const struct frr_yang_module_info frr_zebra_info = {
|
|||
.cbs = {
|
||||
.modify = lib_vrf_zebra_l3vni_id_modify,
|
||||
.destroy = lib_vrf_zebra_l3vni_id_destroy,
|
||||
.cli_show = lib_vrf_zebra_l3vni_id_cli_write,
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -50,6 +50,9 @@ void zebra_ptm_enable_cli_write(struct vty *vty, const struct lyd_node *dnode,
|
|||
bool show_defaults);
|
||||
#endif
|
||||
int zebra_route_map_delay_modify(struct nb_cb_modify_args *args);
|
||||
void zebra_route_map_delay_cli_write(struct vty *vty,
|
||||
const struct lyd_node *dnode,
|
||||
bool show_defaults);
|
||||
int zebra_debugs_debug_events_modify(struct nb_cb_modify_args *args);
|
||||
int zebra_debugs_debug_events_destroy(struct nb_cb_destroy_args *args);
|
||||
int zebra_debugs_debug_zapi_send_modify(struct nb_cb_modify_args *args);
|
||||
|
@ -419,22 +422,42 @@ struct yang_data *lib_interface_zebra_state_mcast_group_get_elem(
|
|||
struct nb_cb_get_elem_args *args);
|
||||
int lib_vrf_zebra_router_id_modify(struct nb_cb_modify_args *args);
|
||||
int lib_vrf_zebra_router_id_destroy(struct nb_cb_destroy_args *args);
|
||||
void lib_vrf_zebra_router_id_cli_write(struct vty *vty,
|
||||
const struct lyd_node *dnode,
|
||||
bool show_defaults);
|
||||
int lib_vrf_zebra_ipv6_router_id_modify(struct nb_cb_modify_args *args);
|
||||
int lib_vrf_zebra_ipv6_router_id_destroy(struct nb_cb_destroy_args *args);
|
||||
void lib_vrf_zebra_ipv6_router_id_cli_write(struct vty *vty,
|
||||
const struct lyd_node *dnode,
|
||||
bool show_defaults);
|
||||
int lib_vrf_zebra_filter_protocol_create(struct nb_cb_create_args *args);
|
||||
int lib_vrf_zebra_filter_protocol_destroy(struct nb_cb_destroy_args *args);
|
||||
void lib_vrf_zebra_filter_protocol_cli_write(struct vty *vty,
|
||||
const struct lyd_node *dnode,
|
||||
bool show_defaults);
|
||||
int lib_vrf_zebra_filter_protocol_route_map_modify(
|
||||
struct nb_cb_modify_args *args);
|
||||
int lib_vrf_zebra_filter_nht_create(struct nb_cb_create_args *args);
|
||||
int lib_vrf_zebra_filter_nht_destroy(struct nb_cb_destroy_args *args);
|
||||
void lib_vrf_zebra_filter_nht_cli_write(struct vty *vty,
|
||||
const struct lyd_node *dnode,
|
||||
bool show_defaults);
|
||||
int lib_vrf_zebra_filter_nht_route_map_modify(struct nb_cb_modify_args *args);
|
||||
int lib_vrf_zebra_resolve_via_default_modify(struct nb_cb_modify_args *args);
|
||||
int lib_vrf_zebra_resolve_via_default_destroy(struct nb_cb_destroy_args *args);
|
||||
void lib_vrf_zebra_resolve_via_default_cli_write(struct vty *vty,
|
||||
const struct lyd_node *dnode,
|
||||
bool show_defaults);
|
||||
int lib_vrf_zebra_ipv6_resolve_via_default_modify(struct nb_cb_modify_args *args);
|
||||
int lib_vrf_zebra_ipv6_resolve_via_default_destroy(
|
||||
struct nb_cb_destroy_args *args);
|
||||
void lib_vrf_zebra_ipv6_resolve_via_default_cli_write(
|
||||
struct vty *vty, const struct lyd_node *dnode, bool show_defaults);
|
||||
int lib_vrf_zebra_netns_table_range_create(struct nb_cb_create_args *args);
|
||||
int lib_vrf_zebra_netns_table_range_destroy(struct nb_cb_destroy_args *args);
|
||||
void lib_vrf_zebra_netns_table_range_cli_write(struct vty *vty,
|
||||
const struct lyd_node *dnode,
|
||||
bool show_defaults);
|
||||
int lib_vrf_zebra_netns_table_range_start_modify(struct nb_cb_modify_args *args);
|
||||
int lib_vrf_zebra_netns_table_range_end_modify(struct nb_cb_modify_args *args);
|
||||
const void *lib_vrf_zebra_ribs_rib_get_next(struct nb_cb_get_next_args *args);
|
||||
|
@ -610,6 +633,9 @@ lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_weight_get_elem(
|
|||
struct nb_cb_get_elem_args *args);
|
||||
int lib_vrf_zebra_l3vni_id_modify(struct nb_cb_modify_args *args);
|
||||
int lib_vrf_zebra_l3vni_id_destroy(struct nb_cb_destroy_args *args);
|
||||
void lib_vrf_zebra_l3vni_id_cli_write(struct vty *vty,
|
||||
const struct lyd_node *dnode,
|
||||
bool show_defaults);
|
||||
int lib_vrf_zebra_prefix_only_modify(struct nb_cb_modify_args *args);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -238,10 +238,3 @@ int zebra_ns_init(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int zebra_ns_config_write(struct vty *vty, struct ns *ns)
|
||||
{
|
||||
if (ns && ns->name != NULL)
|
||||
vty_out(vty, " netns %s\n", ns->name);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -70,7 +70,6 @@ int zebra_ns_early_shutdown(struct ns *ns,
|
|||
int zebra_ns_final_shutdown(struct ns *ns,
|
||||
void *param_in __attribute__((unused)),
|
||||
void **param_out __attribute__((unused)));
|
||||
int zebra_ns_config_write(struct vty *vty, struct ns *ns);
|
||||
|
||||
void zebra_ns_startup_continue(struct zebra_dplane_ctx *ctx);
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include "zebra/debug.h"
|
||||
#include "zebra/zebra_rnh.h"
|
||||
#include "zebra/zebra_routemap.h"
|
||||
#include "zebra/zebra_vrf.h"
|
||||
#include "zebra/zebra_nb.h"
|
||||
|
||||
#include "zebra/zebra_routemap_clippy.c"
|
||||
|
||||
|
@ -659,6 +661,15 @@ DEFPY_YANG (no_zebra_route_map_timer,
|
|||
return nb_cli_apply_changes(vty, NULL);
|
||||
}
|
||||
|
||||
void zebra_route_map_delay_cli_write(struct vty *vty,
|
||||
const struct lyd_node *dnode,
|
||||
bool show_defaults)
|
||||
{
|
||||
uint32_t delay = yang_dnode_get_uint32(dnode, NULL);
|
||||
|
||||
vty_out(vty, "zebra route-map delay-timer %u\n", delay);
|
||||
}
|
||||
|
||||
DEFPY_YANG (ip_protocol,
|
||||
ip_protocol_cmd,
|
||||
"ip protocol " FRR_IP_PROTOCOL_MAP_STR_ZEBRA
|
||||
|
@ -793,6 +804,29 @@ DEFPY_YANG (show_ipv6_protocol,
|
|||
return ret;
|
||||
}
|
||||
|
||||
void lib_vrf_zebra_filter_protocol_cli_write(struct vty *vty,
|
||||
const struct lyd_node *dnode,
|
||||
bool show_defaults)
|
||||
{
|
||||
const char *afi_safi = yang_dnode_get_string(dnode, "afi-safi");
|
||||
const char *proto = yang_dnode_get_string(dnode, "protocol");
|
||||
const char *rmap = yang_dnode_get_string(dnode, "route-map");
|
||||
afi_t afi;
|
||||
safi_t safi;
|
||||
|
||||
yang_afi_safi_identity2value(afi_safi, &afi, &safi);
|
||||
|
||||
if (safi != SAFI_UNICAST)
|
||||
return;
|
||||
|
||||
zebra_vrf_indent_cli_write(vty, dnode);
|
||||
|
||||
if (afi == AFI_IP)
|
||||
vty_out(vty, "ip protocol %s route-map %s\n", proto, rmap);
|
||||
else
|
||||
vty_out(vty, "ipv6 protocol %s route-map %s\n", proto, rmap);
|
||||
}
|
||||
|
||||
DEFPY_YANG (ip_protocol_nht_rmap,
|
||||
ip_protocol_nht_rmap_cmd,
|
||||
"ip nht " FRR_IP_PROTOCOL_MAP_STR_ZEBRA
|
||||
|
@ -939,6 +973,29 @@ DEFPY_YANG (show_ipv6_protocol_nht,
|
|||
return ret;
|
||||
}
|
||||
|
||||
void lib_vrf_zebra_filter_nht_cli_write(struct vty *vty,
|
||||
const struct lyd_node *dnode,
|
||||
bool show_defaults)
|
||||
{
|
||||
const char *afi_safi = yang_dnode_get_string(dnode, "afi-safi");
|
||||
const char *proto = yang_dnode_get_string(dnode, "protocol");
|
||||
const char *rmap = yang_dnode_get_string(dnode, "route-map");
|
||||
afi_t afi;
|
||||
safi_t safi;
|
||||
|
||||
yang_afi_safi_identity2value(afi_safi, &afi, &safi);
|
||||
|
||||
if (safi != SAFI_UNICAST)
|
||||
return;
|
||||
|
||||
zebra_vrf_indent_cli_write(vty, dnode);
|
||||
|
||||
if (afi == AFI_IP)
|
||||
vty_out(vty, "ip nht %s route-map %s\n", proto, rmap);
|
||||
else
|
||||
vty_out(vty, "ipv6 nht %s route-map %s\n", proto, rmap);
|
||||
}
|
||||
|
||||
/*XXXXXXXXXXXXXXXXXXXXXXXXXXXX*/
|
||||
|
||||
/* `match ip next-hop IP_ACCESS_LIST' */
|
||||
|
@ -1838,62 +1895,6 @@ void zebra_routemap_vrf_delete(struct zebra_vrf *zvrf)
|
|||
}
|
||||
}
|
||||
|
||||
/* ip protocol configuration write function */
|
||||
void zebra_routemap_config_write_protocol(struct vty *vty,
|
||||
struct zebra_vrf *zvrf)
|
||||
{
|
||||
int i;
|
||||
char space[2];
|
||||
|
||||
memset(space, 0, sizeof(space));
|
||||
|
||||
if (zvrf_id(zvrf) != VRF_DEFAULT)
|
||||
snprintf(space, sizeof(space), "%s", " ");
|
||||
|
||||
for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
|
||||
if (PROTO_RM_NAME(zvrf, AFI_IP, i))
|
||||
vty_out(vty, "%sip protocol %s route-map %s\n", space,
|
||||
zebra_route_string(i),
|
||||
PROTO_RM_NAME(zvrf, AFI_IP, i));
|
||||
|
||||
if (PROTO_RM_NAME(zvrf, AFI_IP6, i))
|
||||
vty_out(vty, "%sipv6 protocol %s route-map %s\n", space,
|
||||
zebra_route_string(i),
|
||||
PROTO_RM_NAME(zvrf, AFI_IP6, i));
|
||||
|
||||
if (NHT_RM_NAME(zvrf, AFI_IP, i))
|
||||
vty_out(vty, "%sip nht %s route-map %s\n", space,
|
||||
zebra_route_string(i),
|
||||
NHT_RM_NAME(zvrf, AFI_IP, i));
|
||||
|
||||
if (NHT_RM_NAME(zvrf, AFI_IP6, i))
|
||||
vty_out(vty, "%sipv6 nht %s route-map %s\n", space,
|
||||
zebra_route_string(i),
|
||||
NHT_RM_NAME(zvrf, AFI_IP6, i));
|
||||
}
|
||||
|
||||
if (PROTO_RM_NAME(zvrf, AFI_IP, ZEBRA_ROUTE_MAX))
|
||||
vty_out(vty, "%sip protocol %s route-map %s\n", space, "any",
|
||||
PROTO_RM_NAME(zvrf, AFI_IP, ZEBRA_ROUTE_MAX));
|
||||
|
||||
if (PROTO_RM_NAME(zvrf, AFI_IP6, ZEBRA_ROUTE_MAX))
|
||||
vty_out(vty, "%sipv6 protocol %s route-map %s\n", space, "any",
|
||||
PROTO_RM_NAME(zvrf, AFI_IP6, ZEBRA_ROUTE_MAX));
|
||||
|
||||
if (NHT_RM_NAME(zvrf, AFI_IP, ZEBRA_ROUTE_MAX))
|
||||
vty_out(vty, "%sip nht %s route-map %s\n", space, "any",
|
||||
NHT_RM_NAME(zvrf, AFI_IP, ZEBRA_ROUTE_MAX));
|
||||
|
||||
if (NHT_RM_NAME(zvrf, AFI_IP6, ZEBRA_ROUTE_MAX))
|
||||
vty_out(vty, "%sipv6 nht %s route-map %s\n", space, "any",
|
||||
NHT_RM_NAME(zvrf, AFI_IP6, ZEBRA_ROUTE_MAX));
|
||||
|
||||
if (zvrf_id(zvrf) == VRF_DEFAULT
|
||||
&& zebra_rmap_update_timer != ZEBRA_RMAP_DEFAULT_UPDATE_TIMER)
|
||||
vty_out(vty, "zebra route-map delay-timer %d\n",
|
||||
zebra_rmap_update_timer);
|
||||
}
|
||||
|
||||
void zebra_route_map_init(void)
|
||||
{
|
||||
install_element(CONFIG_NODE, &ip_protocol_cmd);
|
||||
|
|
|
@ -14,8 +14,6 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
extern void zebra_route_map_init(void);
|
||||
extern void zebra_routemap_config_write_protocol(struct vty *vty,
|
||||
struct zebra_vrf *vrf);
|
||||
extern char *zebra_get_import_table_route_map(afi_t afi, uint32_t table);
|
||||
extern void zebra_add_import_table_route_map(afi_t afi, const char *rmap_name,
|
||||
uint32_t table);
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "srcdest_table.h"
|
||||
#include "vrf.h"
|
||||
#include "vty.h"
|
||||
#include "northbound_cli.h"
|
||||
|
||||
#include "zebra/zebra_router.h"
|
||||
#include "zebra/rtadv.h"
|
||||
|
@ -33,6 +34,7 @@
|
|||
#include "zebra/zebra_routemap.h"
|
||||
#include "zebra/zebra_vrf_clippy.c"
|
||||
#include "zebra/table_manager.h"
|
||||
#include "zebra/zebra_nb.h"
|
||||
|
||||
static void zebra_vrf_table_create(struct zebra_vrf *zvrf, afi_t afi,
|
||||
safi_t safi);
|
||||
|
@ -450,84 +452,32 @@ struct route_table *zebra_vrf_table(afi_t afi, safi_t safi, vrf_id_t vrf_id)
|
|||
return zvrf->table[afi][safi];
|
||||
}
|
||||
|
||||
void zebra_vrf_indent_cli_write(struct vty *vty, const struct lyd_node *dnode)
|
||||
{
|
||||
const struct lyd_node *vrf = yang_dnode_get_parent(dnode, "vrf");
|
||||
|
||||
if (vrf && strcmp(yang_dnode_get_string(vrf, "name"), VRF_DEFAULT_NAME))
|
||||
vty_out(vty, " ");
|
||||
}
|
||||
|
||||
static int vrf_config_write_single(const struct lyd_node *dnode, void *arg)
|
||||
{
|
||||
nb_cli_show_dnode_cmds(arg, dnode, false);
|
||||
|
||||
return YANG_ITER_CONTINUE;
|
||||
}
|
||||
|
||||
static int vrf_config_write(struct vty *vty)
|
||||
{
|
||||
struct vrf *vrf;
|
||||
struct zebra_vrf *zvrf;
|
||||
const struct lyd_node *dnode;
|
||||
|
||||
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
|
||||
zvrf = vrf->info;
|
||||
yang_dnode_iterate(vrf_config_write_single, vty, running_config->dnode,
|
||||
"/frr-vrf:lib/vrf");
|
||||
dnode = yang_dnode_get(running_config->dnode, "/frr-zebra:zebra");
|
||||
if (dnode)
|
||||
nb_cli_show_dnode_cmds(vty, dnode, false);
|
||||
|
||||
if (!zvrf)
|
||||
continue;
|
||||
|
||||
if (zvrf_id(zvrf) == VRF_DEFAULT) {
|
||||
if (zvrf->l3vni)
|
||||
vty_out(vty, "vni %u%s\n", zvrf->l3vni,
|
||||
is_l3vni_for_prefix_routes_only(
|
||||
zvrf->l3vni)
|
||||
? " prefix-routes-only"
|
||||
: "");
|
||||
|
||||
if (zvrf->zebra_rnh_ip_default_route !=
|
||||
SAVE_ZEBRA_IP_NHT_RESOLVE_VIA_DEFAULT)
|
||||
vty_out(vty, "%sip nht resolve-via-default\n",
|
||||
zvrf->zebra_rnh_ip_default_route
|
||||
? ""
|
||||
: "no ");
|
||||
|
||||
if (zvrf->zebra_rnh_ipv6_default_route !=
|
||||
SAVE_ZEBRA_IP_NHT_RESOLVE_VIA_DEFAULT)
|
||||
vty_out(vty, "%sipv6 nht resolve-via-default\n",
|
||||
zvrf->zebra_rnh_ipv6_default_route
|
||||
? ""
|
||||
: "no ");
|
||||
|
||||
if (zvrf->tbl_mgr
|
||||
&& (zvrf->tbl_mgr->start || zvrf->tbl_mgr->end))
|
||||
vty_out(vty, "ip table range %u %u\n",
|
||||
zvrf->tbl_mgr->start,
|
||||
zvrf->tbl_mgr->end);
|
||||
} else {
|
||||
vty_frame(vty, "vrf %s\n", zvrf_name(zvrf));
|
||||
if (zvrf->l3vni)
|
||||
vty_out(vty, " vni %u%s\n", zvrf->l3vni,
|
||||
is_l3vni_for_prefix_routes_only(
|
||||
zvrf->l3vni)
|
||||
? " prefix-routes-only"
|
||||
: "");
|
||||
zebra_ns_config_write(vty, (struct ns *)vrf->ns_ctxt);
|
||||
if (zvrf->zebra_rnh_ip_default_route !=
|
||||
SAVE_ZEBRA_IP_NHT_RESOLVE_VIA_DEFAULT)
|
||||
vty_out(vty, " %sip nht resolve-via-default\n",
|
||||
zvrf->zebra_rnh_ip_default_route
|
||||
? ""
|
||||
: "no ");
|
||||
|
||||
if (zvrf->zebra_rnh_ipv6_default_route !=
|
||||
SAVE_ZEBRA_IP_NHT_RESOLVE_VIA_DEFAULT)
|
||||
vty_out(vty, " %sipv6 nht resolve-via-default\n",
|
||||
zvrf->zebra_rnh_ipv6_default_route
|
||||
? ""
|
||||
: "no ");
|
||||
|
||||
if (zvrf->tbl_mgr && vrf_is_backend_netns()
|
||||
&& (zvrf->tbl_mgr->start || zvrf->tbl_mgr->end))
|
||||
vty_out(vty, " ip table range %u %u\n",
|
||||
zvrf->tbl_mgr->start,
|
||||
zvrf->tbl_mgr->end);
|
||||
}
|
||||
|
||||
|
||||
zebra_routemap_config_write_protocol(vty, zvrf);
|
||||
router_id_write(vty, zvrf);
|
||||
|
||||
if (zvrf_id(zvrf) != VRF_DEFAULT)
|
||||
vty_endframe(vty, "exit-vrf\n!\n");
|
||||
else
|
||||
vty_out(vty, "!\n");
|
||||
}
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEFPY (vrf_netns,
|
||||
|
|
|
@ -260,6 +260,9 @@ extern void zebra_vrf_init(void);
|
|||
extern void zebra_rtable_node_cleanup(struct route_table *table,
|
||||
struct route_node *node);
|
||||
|
||||
extern void zebra_vrf_indent_cli_write(struct vty *vty,
|
||||
const struct lyd_node *dnode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1697,6 +1697,21 @@ DEFUN (no_ip_nht_default_route,
|
|||
return nb_cli_apply_changes(vty, NULL);
|
||||
}
|
||||
|
||||
void lib_vrf_zebra_resolve_via_default_cli_write(struct vty *vty,
|
||||
const struct lyd_node *dnode,
|
||||
bool show_defaults)
|
||||
{
|
||||
bool resolve_via_default = yang_dnode_get_bool(dnode, NULL);
|
||||
|
||||
if (resolve_via_default != SAVE_ZEBRA_IP_NHT_RESOLVE_VIA_DEFAULT ||
|
||||
show_defaults) {
|
||||
zebra_vrf_indent_cli_write(vty, dnode);
|
||||
|
||||
vty_out(vty, "%sip nht resolve-via-default\n",
|
||||
resolve_via_default ? "" : "no ");
|
||||
}
|
||||
}
|
||||
|
||||
DEFUN (ipv6_nht_default_route,
|
||||
ipv6_nht_default_route_cmd,
|
||||
"ipv6 nht resolve-via-default",
|
||||
|
@ -1732,6 +1747,20 @@ DEFUN (no_ipv6_nht_default_route,
|
|||
return nb_cli_apply_changes(vty, NULL);
|
||||
}
|
||||
|
||||
void lib_vrf_zebra_ipv6_resolve_via_default_cli_write(
|
||||
struct vty *vty, const struct lyd_node *dnode, bool show_defaults)
|
||||
{
|
||||
bool resolve_via_default = yang_dnode_get_bool(dnode, NULL);
|
||||
|
||||
if (resolve_via_default != SAVE_ZEBRA_IP_NHT_RESOLVE_VIA_DEFAULT ||
|
||||
show_defaults) {
|
||||
zebra_vrf_indent_cli_write(vty, dnode);
|
||||
|
||||
vty_out(vty, "%sipv6 nht resolve-via-default\n",
|
||||
resolve_via_default ? "" : "no ");
|
||||
}
|
||||
}
|
||||
|
||||
DEFPY_HIDDEN(rnh_hide_backups, rnh_hide_backups_cmd,
|
||||
"[no] ip nht hide-backup-events",
|
||||
NO_STR
|
||||
|
@ -2761,6 +2790,23 @@ DEFPY_YANG (no_vni_mapping,
|
|||
return nb_cli_apply_changes(vty, NULL);
|
||||
}
|
||||
|
||||
void lib_vrf_zebra_l3vni_id_cli_write(struct vty *vty,
|
||||
const struct lyd_node *dnode,
|
||||
bool show_defaults)
|
||||
{
|
||||
vni_t vni = yang_dnode_get_uint32(dnode, NULL);
|
||||
bool prefix_only = yang_dnode_get_bool(dnode, "../prefix-only");
|
||||
|
||||
zebra_vrf_indent_cli_write(vty, dnode);
|
||||
|
||||
vty_out(vty, "vni %u", vni);
|
||||
|
||||
if (prefix_only)
|
||||
vty_out(vty, " prefix-routes-only");
|
||||
|
||||
vty_out(vty, "\n");
|
||||
}
|
||||
|
||||
/* show vrf */
|
||||
DEFPY (show_vrf_vni,
|
||||
show_vrf_vni_cmd,
|
||||
|
@ -4423,6 +4469,18 @@ DEFPY_YANG (ip_table_range, ip_table_range_cmd,
|
|||
return nb_cli_apply_changes(vty, NULL);
|
||||
}
|
||||
|
||||
void lib_vrf_zebra_netns_table_range_cli_write(struct vty *vty,
|
||||
const struct lyd_node *dnode,
|
||||
bool show_defaults)
|
||||
{
|
||||
uint32_t start = yang_dnode_get_uint32(dnode, "start");
|
||||
uint32_t end = yang_dnode_get_uint32(dnode, "end");
|
||||
|
||||
zebra_vrf_indent_cli_write(vty, dnode);
|
||||
|
||||
vty_out(vty, "ip table range %u %u\n", start, end);
|
||||
}
|
||||
|
||||
#ifdef HAVE_SCRIPTING
|
||||
|
||||
DEFUN(zebra_on_rib_process_script, zebra_on_rib_process_script_cmd,
|
||||
|
|
Loading…
Reference in a new issue