diff options
Diffstat (limited to 'zebra/zebra_nb_config.c')
| -rw-r--r-- | zebra/zebra_nb_config.c | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/zebra/zebra_nb_config.c b/zebra/zebra_nb_config.c index dbe265da8c..5b87a18a06 100644 --- a/zebra/zebra_nb_config.c +++ b/zebra/zebra_nb_config.c @@ -29,6 +29,8 @@ #include "zebra_nb.h" #include "zebra/interface.h" #include "zebra/connected.h" +#include "zebra/zebra_router.h" +#include "zebra/debug.h" /* * XPath: /frr-zebra:zebra/mcast-rpf-lookup @@ -1216,32 +1218,56 @@ int lib_interface_zebra_bandwidth_destroy(struct nb_cb_destroy_args *args) } /* - * XPath: /frr-vrf:lib/vrf/frr-zebra:ribs/rib + * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib */ -int lib_vrf_ribs_rib_create(struct nb_cb_create_args *args) +int lib_vrf_zebra_ribs_rib_create(struct nb_cb_create_args *args) { + struct vrf *vrf; + afi_t afi; + safi_t safi; + struct zebra_vrf *zvrf; + struct zebra_router_table *zrt; + uint32_t table_id; + const char *afi_safi_name; + + vrf = nb_running_get_entry(args->dnode, NULL, false); + zvrf = vrf_info_lookup(vrf->vrf_id); + table_id = yang_dnode_get_uint32(args->dnode, "./table-id"); + if (!table_id) + table_id = zvrf->table_id; + + afi_safi_name = yang_dnode_get_string(args->dnode, "./afi-safi-name"); + zebra_afi_safi_identity2value(afi_safi_name, &afi, &safi); + + zrt = zebra_router_find_zrt(zvrf, table_id, afi, safi); + switch (args->event) { case NB_EV_VALIDATE: + if (!zrt) { + zlog_debug("%s: vrf %s table is not found.", __func__, + vrf->name); + return NB_ERR_VALIDATION; + } + break; case NB_EV_PREPARE: case NB_EV_ABORT: + break; case NB_EV_APPLY: - /* TODO: implement me. */ + + nb_running_set_entry(args->dnode, zrt); + break; } return NB_OK; } -int lib_vrf_ribs_rib_destroy(struct nb_cb_destroy_args *args) +int lib_vrf_zebra_ribs_rib_destroy(struct nb_cb_destroy_args *args) { - switch (args->event) { - case NB_EV_VALIDATE: - case NB_EV_PREPARE: - case NB_EV_ABORT: - case NB_EV_APPLY: - /* TODO: implement me. */ - break; - } + if (args->event != NB_EV_APPLY) + return NB_OK; + + nb_running_unset_entry(args->dnode); return NB_OK; } |
