diff --git a/zebra/zebra_nb_config.c b/zebra/zebra_nb_config.c index 6169624134a0..34b472142eac 100644 --- a/zebra/zebra_nb_config.c +++ b/zebra/zebra_nb_config.c @@ -29,6 +29,7 @@ #include "zebra/interface.h" #include "zebra/connected.h" #include "zebra/zebra_router.h" +#include "zebra/debug.h" /* * XPath: /frr-zebra:zebra/mcast-rpf-lookup @@ -1020,7 +1021,8 @@ int lib_interface_zebra_ip_addrs_create(enum nb_event event, char buf[PREFIX_STRLEN] = {0}; ifp = nb_running_get_entry(dnode, NULL, true); - // addr_family = yang_dnode_get_enum(dnode, "./address-family"); + /* TODO: wrapper for identityref */ + /* addr_family = yang_dnode_get_enum(dnode, "./address-family"); */ yang_dnode_get_prefix(&prefix, dnode, "./ip-prefix"); apply_mask(&prefix); @@ -1329,7 +1331,6 @@ int lib_vrf_zebra_ribs_rib_create(enum nb_event event, const struct lyd_node *dnode, union nb_resource *resource) { - // uint32_t table_id; struct vrf *vrf; afi_t afi = AFI_IP; safi_t safi = SAFI_UNICAST; @@ -1339,19 +1340,19 @@ int lib_vrf_zebra_ribs_rib_create(enum nb_event event, vrf = nb_running_get_entry(dnode, NULL, false); zvrf = vrf_info_lookup(vrf->vrf_id); - // TODO: parse afi-safi-name and table_id - // table_id = yang_dnode_get_uint32(dnode, "./table-id"); - zlog_debug("%s: vrf %s", __PRETTY_FUNCTION__, vrf->name); + /* TODO: parse afi-safi-name and table_id + uint32_t table_id; + table_id = yang_dnode_get_uint32(dnode, "./table-id"); + */ zrt = zebra_router_find_zrt(zvrf, zvrf->table_id, afi, safi); - // table = zebra_vrf_lookup_table_with_table_id(afi, safi, vrf->vrf_id, - // zvrf->table_id); switch (event) { case NB_EV_VALIDATE: if (!zrt) { - zlog_debug("%s: vrf %s table is not found.", - __PRETTY_FUNCTION__, vrf->name); + if (IS_ZEBRA_DEBUG_EVENT) + zlog_debug("%s: vrf %s table is not found.", + __PRETTY_FUNCTION__, vrf->name); return NB_ERR_VALIDATION; } break; @@ -1378,7 +1379,9 @@ int lib_vrf_zebra_ribs_rib_destroy(enum nb_event event, zrt = nb_running_unset_entry(dnode); if (!zrt) { - zlog_debug("%s: zrt is not found", __func__); + if (IS_ZEBRA_DEBUG_EVENT) + zlog_debug("%s: zrt is not found", __func__); + return NB_ERR_INCONSISTENCY; } diff --git a/zebra/zebra_nb_state.c b/zebra/zebra_nb_state.c index 66cdf810174a..f561d0576bf0 100644 --- a/zebra/zebra_nb_state.c +++ b/zebra/zebra_nb_state.c @@ -317,19 +317,14 @@ lib_vrf_zebra_ribs_rib_route_route_entry_get_next(const void *parent_list_entry, struct route_entry *re = (struct route_entry *)list_entry; struct route_node *rn = (struct route_node *)parent_list_entry; - if (list_entry == NULL) { + if (list_entry == NULL) RNODE_FIRST_RE(rn, re); - if (re) - zlog_debug( - "%s: list_entry is null. route_entry is found.", - __func__); - } else { + else RNODE_NEXT_RE(rn, re); - if (re) { - if (IS_ZEBRA_DEBUG_EVENT) - zlog_debug("%s: next route_entry is found.", - __func__); - } + + if (re) { + if (IS_ZEBRA_DEBUG_EVENT) + zlog_debug("%s: next route_entry is found.", __func__); } return re; @@ -713,19 +708,14 @@ lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_frr_nexthops_nexthop_nh_t switch (nexthop->type) { case NEXTHOP_TYPE_IFINDEX: return yang_data_new_string(xpath, "ifindex"); - break; case NEXTHOP_TYPE_IPV4: return yang_data_new_string(xpath, "ip4"); - break; case NEXTHOP_TYPE_IPV4_IFINDEX: return yang_data_new_string(xpath, "ip4-ifindex"); - break; case NEXTHOP_TYPE_IPV6: return yang_data_new_string(xpath, "ip6"); - break; case NEXTHOP_TYPE_IPV6_IFINDEX: return yang_data_new_string(xpath, "ip6-ifindex"); - break; default: break; } @@ -774,7 +764,6 @@ lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_frr_nexthops_nexthop_gate case NEXTHOP_TYPE_IFINDEX: /* No addr here */ return yang_data_new_string(xpath, ""); - break; default: break; } @@ -819,11 +808,11 @@ lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_frr_nexthops_nexthop_bh_t const char *xpath, const void *list_entry) { struct nexthop *nexthop = (struct nexthop *)list_entry; + char type_str[PREFIX2STR_BUFFER] = {'\0'}; if (nexthop->type != NEXTHOP_TYPE_BLACKHOLE) return NULL; - char type_str[PREFIX2STR_BUFFER] = {'\0'}; switch (nexthop->bh_type) { case BLACKHOLE_NULL: strlcpy(type_str, "null", 12); @@ -838,6 +827,7 @@ lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_frr_nexthops_nexthop_bh_t strlcpy(type_str, "unspec", 12); break; } + if (IS_ZEBRA_DEBUG_EVENT) zlog_debug("%s: type %s ", __func__, type_str);