Skip to content

Commit

Permalink
zebra: rib operational model formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Chirag Shah <[email protected]>
  • Loading branch information
chiragshah6 committed Apr 17, 2020
1 parent be64f46 commit 14e8b7d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 30 deletions.
20 changes: 9 additions & 11 deletions zebra/zebra_nb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,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
Expand Down Expand Up @@ -1021,7 +1022,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);

Expand Down Expand Up @@ -1330,7 +1332,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;
Expand All @@ -1340,19 +1341,14 @@ 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);

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;
Expand All @@ -1379,7 +1375,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;
}

Expand Down
28 changes: 9 additions & 19 deletions zebra/zebra_nb_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand All @@ -838,8 +827,9 @@ 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);
zlog_debug("%s: blackhole type %s ", __func__, type_str);

return yang_data_new_string(xpath, type_str);
}
Expand Down

0 comments on commit 14e8b7d

Please sign in to comment.