{
struct route_node *rn;
struct rib *rib;
- struct nexthop *nexthop;
#define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
#define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
u_int32_t i;
+ u_int32_t is_ibgp;
memset (&rib_cnt, 0, sizeof(rib_cnt));
memset (&fib_cnt, 0, sizeof(fib_cnt));
for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
- for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
- {
- rib_cnt[ZEBRA_ROUTE_TOTAL]++;
- rib_cnt[rib->type]++;
- if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
- || nexthop_has_fib_child(nexthop))
- {
- fib_cnt[ZEBRA_ROUTE_TOTAL]++;
- fib_cnt[rib->type]++;
- }
- if (rib->type == ZEBRA_ROUTE_BGP &&
- CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
- {
- rib_cnt[ZEBRA_ROUTE_IBGP]++;
- if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
- || nexthop_has_fib_child(nexthop))
- fib_cnt[ZEBRA_ROUTE_IBGP]++;
- }
- }
+ {
+ is_ibgp = (rib->type == ZEBRA_ROUTE_BGP &&
+ CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP));
+
+ rib_cnt[ZEBRA_ROUTE_TOTAL]++;
+ if (is_ibgp)
+ rib_cnt[ZEBRA_ROUTE_IBGP]++;
+ else
+ rib_cnt[rib->type]++;
+
+ if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
+ {
+ fib_cnt[ZEBRA_ROUTE_TOTAL]++;
+
+ if (is_ibgp)
+ fib_cnt[ZEBRA_ROUTE_IBGP]++;
+ else
+ fib_cnt[rib->type]++;
+ }
+ }
vty_out (vty, "%-20s %-20s %s (vrf %s)%s",
"Route Source", "Routes", "FIB",
((rib_table_info_t *)table->info)->zvrf->name,
VTY_NEWLINE);
- for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
+ for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
{
if (rib_cnt[i] > 0)
- {
- if (i == ZEBRA_ROUTE_BGP)
- {
- vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
- rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
- fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
- VTY_NEWLINE);
- vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
- rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
- VTY_NEWLINE);
- }
- else
- vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
- rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
- }
+ {
+ if (i == ZEBRA_ROUTE_BGP)
+ {
+ vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
+ rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
+ fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
+ VTY_NEWLINE);
+ vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
+ rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
+ VTY_NEWLINE);
+ }
+ else
+ vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
+ rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
+ }
}
vty_out (vty, "------%s", VTY_NEWLINE);
- vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
- fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
+ vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
+ fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
vty_out (vty, "%s", VTY_NEWLINE);
}