diff --git a/isisd/isis_nb_config.c b/isisd/isis_nb_config.c index d47d966f71..c8ad816b58 100644 --- a/isisd/isis_nb_config.c +++ b/isisd/isis_nb_config.c @@ -133,7 +133,7 @@ int isis_instance_area_address_create(struct nb_cb_create_args *args) switch (args->event) { case NB_EV_VALIDATE: - area = nb_running_get_entry(args->dnode, NULL, true); + area = nb_running_get_entry(args->dnode, NULL, false); if (area == NULL) return NB_ERR_VALIDATION; addr.addr_len = dotformat2buff(buff, net_title); diff --git a/pathd/path_nb_config.c b/pathd/path_nb_config.c index 669db169ae..af54f5bce2 100644 --- a/pathd/path_nb_config.c +++ b/pathd/path_nb_config.c @@ -302,7 +302,6 @@ int pathd_srte_policy_binding_sid_modify(struct nb_cb_modify_args *args) struct srte_policy *policy; mpls_label_t binding_sid; - policy = nb_running_get_entry(args->dnode, NULL, true); binding_sid = yang_dnode_get_uint32(args->dnode, NULL); switch (args->event) { @@ -315,6 +314,7 @@ int pathd_srte_policy_binding_sid_modify(struct nb_cb_modify_args *args) case NB_EV_ABORT: break; case NB_EV_APPLY: + policy = nb_running_get_entry(args->dnode, NULL, true); srte_policy_update_binding_sid(policy, binding_sid); SET_FLAG(policy->flags, F_POLICY_MODIFIED); break; @@ -668,12 +668,12 @@ int pathd_srte_policy_candidate_path_segment_list_name_modify( struct srte_candidate *candidate; const char *segment_list_name; - candidate = nb_running_get_entry(args->dnode, NULL, true); - segment_list_name = yang_dnode_get_string(args->dnode, NULL); - if (args->event != NB_EV_APPLY) return NB_OK; + candidate = nb_running_get_entry(args->dnode, NULL, true); + segment_list_name = yang_dnode_get_string(args->dnode, NULL); + candidate->segment_list = srte_segment_list_find(segment_list_name); candidate->lsp->segment_list = candidate->segment_list; assert(candidate->segment_list); diff --git a/pimd/pim_nb_config.c b/pimd/pim_nb_config.c index a7d7551cbd..e852a87683 100644 --- a/pimd/pim_nb_config.c +++ b/pimd/pim_nb_config.c @@ -2394,13 +2394,6 @@ int lib_interface_pim_address_family_mroute_oif_modify( struct ipaddr group_addr; const struct lyd_node *if_dnode; - iif = nb_running_get_entry(args->dnode, NULL, true); - pim_iifp = iif->info; - pim = pim_iifp->pim; - - oifname = yang_dnode_get_string(args->dnode, NULL); - oif = if_lookup_by_name(oifname, pim->vrf_id); - switch (args->event) { case NB_EV_VALIDATE: if_dnode = yang_dnode_get_parent(args->dnode, "interface"); @@ -2411,6 +2404,17 @@ int lib_interface_pim_address_family_mroute_oif_modify( } #ifdef PIM_ENFORCE_LOOPFREE_MFC + iif = nb_running_get_entry(args->dnode, NULL, false); + if (!iif) { + return NB_OK; + } + + pim_iifp = iif->info; + pim = pim_iifp->pim; + + oifname = yang_dnode_get_string(args->dnode, NULL); + oif = if_lookup_by_name(oifname, pim->vrf_id); + if (oif && (iif->ifindex == oif->ifindex)) { strlcpy(args->errmsg, "% IIF same as OIF and loopfree enforcement is enabled; rejecting", @@ -2423,6 +2427,12 @@ int lib_interface_pim_address_family_mroute_oif_modify( case NB_EV_ABORT: break; case NB_EV_APPLY: + iif = nb_running_get_entry(args->dnode, NULL, true); + pim_iifp = iif->info; + pim = pim_iifp->pim; + + oifname = yang_dnode_get_string(args->dnode, NULL); + oif = if_lookup_by_name(oifname, pim->vrf_id); if (!oif) { snprintf(args->errmsg, args->errmsg_len, "No such interface name %s", diff --git a/yang/frr-zebra.yang b/yang/frr-zebra.yang index 782e0a4b74..be2f7b5a68 100644 --- a/yang/frr-zebra.yang +++ b/yang/frr-zebra.yang @@ -597,6 +597,7 @@ module frr-zebra { grouping ribs { container ribs { + config false; description "RIBs supported by FRR."; list rib { @@ -617,7 +618,6 @@ module frr-zebra { list route { key "prefix"; - config false; leaf prefix { type inet:ip-prefix; description diff --git a/zebra/zebra_nb.c b/zebra/zebra_nb.c index 1fc1faff67..bdeb84486d 100644 --- a/zebra/zebra_nb.c +++ b/zebra/zebra_nb.c @@ -401,13 +401,23 @@ const struct frr_yang_module_info frr_zebra_info = { { .xpath = "/frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib", .cbs = { - .create = lib_vrf_zebra_ribs_rib_create, - .destroy = lib_vrf_zebra_ribs_rib_destroy, .get_next = lib_vrf_zebra_ribs_rib_get_next, .get_keys = lib_vrf_zebra_ribs_rib_get_keys, .lookup_entry = lib_vrf_zebra_ribs_rib_lookup_entry, } }, + { + .xpath = "/frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/afi-safi-name", + .cbs = { + .get_elem = lib_vrf_zebra_ribs_rib_afi_safi_name_get_elem, + } + }, + { + .xpath = "/frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/table-id", + .cbs = { + .get_elem = lib_vrf_zebra_ribs_rib_table_id_get_elem, + } + }, { .xpath = "/frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route", .cbs = { diff --git a/zebra/zebra_nb.h b/zebra/zebra_nb.h index 82529663ba..79632dc83e 100644 --- a/zebra/zebra_nb.h +++ b/zebra/zebra_nb.h @@ -149,12 +149,14 @@ struct yang_data *lib_interface_zebra_state_remote_vtep_get_elem( struct nb_cb_get_elem_args *args); struct yang_data *lib_interface_zebra_state_mcast_group_get_elem( struct nb_cb_get_elem_args *args); -int lib_vrf_zebra_ribs_rib_create(struct nb_cb_create_args *args); -int lib_vrf_zebra_ribs_rib_destroy(struct nb_cb_destroy_args *args); const void *lib_vrf_zebra_ribs_rib_get_next(struct nb_cb_get_next_args *args); int lib_vrf_zebra_ribs_rib_get_keys(struct nb_cb_get_keys_args *args); const void * lib_vrf_zebra_ribs_rib_lookup_entry(struct nb_cb_lookup_entry_args *args); +struct yang_data * +lib_vrf_zebra_ribs_rib_afi_safi_name_get_elem(struct nb_cb_get_elem_args *args); +struct yang_data * +lib_vrf_zebra_ribs_rib_table_id_get_elem(struct nb_cb_get_elem_args *args); const void * lib_vrf_zebra_ribs_rib_route_get_next(struct nb_cb_get_next_args *args); int lib_vrf_zebra_ribs_rib_route_get_keys(struct nb_cb_get_keys_args *args); diff --git a/zebra/zebra_nb_config.c b/zebra/zebra_nb_config.c index ea2e20ed3b..ba9f96b7de 100644 --- a/zebra/zebra_nb_config.c +++ b/zebra/zebra_nb_config.c @@ -841,7 +841,6 @@ int lib_interface_zebra_ip_addrs_create(struct nb_cb_create_args *args) struct interface *ifp; struct prefix prefix; - ifp = nb_running_get_entry(args->dnode, NULL, true); // addr_family = yang_dnode_get_enum(dnode, "./address-family"); yang_dnode_get_prefix(&prefix, args->dnode, "./ip-prefix"); apply_mask(&prefix); @@ -864,6 +863,7 @@ int lib_interface_zebra_ip_addrs_create(struct nb_cb_create_args *args) case NB_EV_ABORT: break; case NB_EV_APPLY: + ifp = nb_running_get_entry(args->dnode, NULL, true); if (prefix.family == AF_INET) if_ip_address_install(ifp, &prefix, NULL, NULL); else if (prefix.family == AF_INET6) @@ -881,12 +881,15 @@ int lib_interface_zebra_ip_addrs_destroy(struct nb_cb_destroy_args *args) struct prefix prefix; struct connected *ifc; - ifp = nb_running_get_entry(args->dnode, NULL, true); yang_dnode_get_prefix(&prefix, args->dnode, "./ip-prefix"); apply_mask(&prefix); switch (args->event) { case NB_EV_VALIDATE: + ifp = nb_running_get_entry(args->dnode, NULL, false); + if (!ifp) + return NB_OK; + if (prefix.family == AF_INET) { /* Check current interface address. */ ifc = connected_check_ptp(ifp, &prefix, NULL); @@ -927,6 +930,7 @@ int lib_interface_zebra_ip_addrs_destroy(struct nb_cb_destroy_args *args) case NB_EV_ABORT: break; case NB_EV_APPLY: + ifp = nb_running_get_entry(args->dnode, NULL, true); if_ip_address_uinstall(ifp, &prefix); break; } @@ -1068,6 +1072,9 @@ int lib_interface_zebra_link_detect_destroy(struct nb_cb_destroy_args *args) */ int lib_interface_zebra_shutdown_modify(struct nb_cb_modify_args *args) { + if (args->event != NB_EV_APPLY) + return NB_OK; + struct interface *ifp; ifp = nb_running_get_entry(args->dnode, NULL, true); @@ -1079,6 +1086,9 @@ int lib_interface_zebra_shutdown_modify(struct nb_cb_modify_args *args) int lib_interface_zebra_shutdown_destroy(struct nb_cb_destroy_args *args) { + if (args->event != NB_EV_APPLY) + return NB_OK; + struct interface *ifp; ifp = nb_running_get_entry(args->dnode, NULL, true); @@ -1129,61 +1139,6 @@ int lib_interface_zebra_bandwidth_destroy(struct nb_cb_destroy_args *args) return NB_OK; } -/* - * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib - */ -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"); - yang_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) { - snprintf(args->errmsg, args->errmsg_len, - "vrf %s table is not found.", vrf->name); - return NB_ERR_VALIDATION; - } - break; - case NB_EV_PREPARE: - case NB_EV_ABORT: - break; - case NB_EV_APPLY: - - nb_running_set_entry(args->dnode, zrt); - - break; - } - - return NB_OK; -} - -int lib_vrf_zebra_ribs_rib_destroy(struct nb_cb_destroy_args *args) -{ - if (args->event != NB_EV_APPLY) - return NB_OK; - - nb_running_unset_entry(args->dnode); - - return NB_OK; -} - /* * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/l3vni-id */ diff --git a/zebra/zebra_nb_state.c b/zebra/zebra_nb_state.c index 21c89f64ed..a9cb096aee 100644 --- a/zebra/zebra_nb_state.c +++ b/zebra/zebra_nb_state.c @@ -213,6 +213,29 @@ lib_vrf_zebra_ribs_rib_lookup_entry(struct nb_cb_lookup_entry_args *args) return zebra_router_find_zrt(zvrf, table_id, afi, safi); } +/* + * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/afi-safi-name + */ +struct yang_data * +lib_vrf_zebra_ribs_rib_afi_safi_name_get_elem(struct nb_cb_get_elem_args *args) +{ + const struct zebra_router_table *zrt = args->list_entry; + + return yang_data_new_string(args->xpath, + yang_afi_safi_value2identity(zrt->afi, zrt->safi)); +} + +/* + * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/table-id + */ +struct yang_data * +lib_vrf_zebra_ribs_rib_table_id_get_elem(struct nb_cb_get_elem_args *args) +{ + const struct zebra_router_table *zrt = args->list_entry; + + return yang_data_new_uint32(args->xpath, zrt->tableid); +} + /* * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route */