From 4d13e841583c6ebde9692aefd2963030b4199b38 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Mon, 6 Apr 2020 23:22:42 -0700 Subject: [PATCH] zebra: rib operational model formatting Signed-off-by: Chirag Shah --- zebra/zebra_nb_config.c | 12 ++++++------ zebra/zebra_nb_state.c | 17 +++++------------ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/zebra/zebra_nb_config.c b/zebra/zebra_nb_config.c index 5c5f8ea31a24..c686cccdf7c8 100644 --- a/zebra/zebra_nb_config.c +++ b/zebra/zebra_nb_config.c @@ -1015,7 +1015,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); @@ -1324,7 +1325,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; @@ -1334,13 +1334,13 @@ 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"); + /* TODO: parse afi-safi-name and table_id + uint32_t table_id; + table_id = yang_dnode_get_uint32(dnode, "./table-id"); + */ zlog_debug("%s: vrf %s", __PRETTY_FUNCTION__, vrf->name); 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: diff --git a/zebra/zebra_nb_state.c b/zebra/zebra_nb_state.c index 8a7402802ec6..36d5ad507eb0 100644 --- a/zebra/zebra_nb_state.c +++ b/zebra/zebra_nb_state.c @@ -241,7 +241,7 @@ lib_vrf_zebra_ribs_rib_lookup_entry(const void *parent_list_entry, const struct yang_list_keys *keys) { struct vrf *vrf = (struct vrf *)parent_list_entry; - // uint32_t tableid = strtoul(keys->key[1], NULL, 10); + /* uint32_t tableid = strtoul(keys->key[1], NULL, 10); */ struct zebra_vrf *zvrf; afi_t afi = AFI_IP; safi_t safi = SAFI_UNICAST; @@ -263,8 +263,8 @@ const void *lib_vrf_zebra_ribs_rib_route_get_next(const void *parent_list_entry, { const struct zebra_router_table *zrt = parent_list_entry; const struct route_node *rn = list_entry; - char buf[PREFIX_STRLEN]; + if (list_entry == NULL) { rn = route_top(zrt->table); } else { @@ -667,11 +667,10 @@ lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_frr_nexthops_nexthop_get_ struct nexthop *nexthop = (struct nexthop *)list_entry; struct nhg_hash_entry *nhe = (struct nhg_hash_entry *)parent_list_entry; - if (list_entry == NULL) { + if (list_entry == NULL) nexthop = (nhe->nhg.nexthop); - } else { + else nexthop = nexthop_next(nexthop); - } return nexthop; } @@ -763,19 +762,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; } @@ -824,7 +818,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; } @@ -869,11 +862,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);