From: Dinesh G Dutt Date: Thu, 21 Apr 2016 05:27:29 +0000 (-0700) Subject: Get route counts right for show ip route summary X-Git-Tag: frr-2.0-rc1~959 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=1ff0858e52519115ef21f9cc894b371bdda79830;p=matthieu%2Ffrr.git Get route counts right for show ip route summary Ticket: CM-9974 Reviewed By: CCR-4531 Testing Done: Testing with both single & multiple NHs Zebra is counting each NH as a separate route which leads to all wrong stats. Count routes, not NHs. --- diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 97a60460c6..ad7447b825 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -2587,65 +2587,66 @@ vty_show_ip_route_summary (struct vty *vty, struct route_table *table) { 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); }