diff options
Diffstat (limited to 'bgpd/bgp_route.c')
| -rw-r--r-- | bgpd/bgp_route.c | 184 |
1 files changed, 100 insertions, 84 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 90a8f8cec5..ad9d22a7a5 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -2476,8 +2476,9 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn, /* advertise/withdraw type-5 routes */ if ((afi == AFI_IP || afi == AFI_IP6) && (safi == SAFI_UNICAST)) { - if (advertise_type5_routes(bgp, afi) && new_select && - (!new_select->extra || !new_select->extra->parent)) { + if (advertise_type5_routes(bgp, afi) && + new_select && + is_route_injectable_into_evpn(new_select)) { /* apply the route-map */ if (bgp->adv_cmd_rmap[afi][safi].map) { @@ -2500,8 +2501,9 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn, afi, safi); } - } else if (advertise_type5_routes(bgp, afi) && old_select && - (!old_select->extra || !old_select->extra->parent)) + } else if (advertise_type5_routes(bgp, afi) && + old_select && + is_route_injectable_into_evpn(old_select)) bgp_evpn_withdraw_type5_route(bgp, &rn->p, afi, safi); } @@ -10223,40 +10225,20 @@ ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) } #endif -static int bgp_table_stats_walker(struct thread *t) +static void bgp_table_stats_rn(struct bgp_node *rn, struct bgp_node *top, + struct bgp_table_stats *ts, unsigned int space) { - struct bgp_node *rn; - struct bgp_node *top; - struct bgp_table_stats *ts = THREAD_ARG(t); - unsigned int space = 0; - - if (!(top = bgp_table_top(ts->table))) - return 0; - - switch (top->p.family) { - case AF_INET: - space = IPV4_MAX_BITLEN; - break; - case AF_INET6: - space = IPV6_MAX_BITLEN; - break; - } - - ts->counts[BGP_STATS_MAXBITLEN] = space; - - for (rn = top; rn; rn = bgp_route_next(rn)) { - struct bgp_path_info *pi; - struct bgp_node *prn = bgp_node_parent_nolock(rn); - unsigned int pinum = 0; + struct bgp_node *prn = bgp_node_parent_nolock(rn); + struct bgp_path_info *pi; - if (rn == top) - continue; + if (rn == top) + return; - if (!bgp_node_has_bgp_path_info_data(rn)) - continue; + if (!bgp_node_has_bgp_path_info_data(rn)) + return; - ts->counts[BGP_STATS_PREFIXES]++; - ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; + ts->counts[BGP_STATS_PREFIXES]++; + ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; #if 0 ts->counts[BGP_STATS_AVGPLEN] @@ -10265,49 +10247,43 @@ static int bgp_table_stats_walker(struct thread *t) rn->p.prefixlen); #endif - /* check if the prefix is included by any other announcements */ - while (prn && !bgp_node_has_bgp_path_info_data(prn)) - prn = bgp_node_parent_nolock(prn); + /* check if the prefix is included by any other announcements */ + while (prn && !bgp_node_has_bgp_path_info_data(prn)) + prn = bgp_node_parent_nolock(prn); - if (prn == NULL || prn == top) { - ts->counts[BGP_STATS_UNAGGREGATEABLE]++; - /* announced address space */ - if (space) - ts->total_space += - pow(2.0, space - rn->p.prefixlen); - } else if (bgp_node_has_bgp_path_info_data(prn)) - ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; + if (prn == NULL || prn == top) { + ts->counts[BGP_STATS_UNAGGREGATEABLE]++; + /* announced address space */ + if (space) + ts->total_space += pow(2.0, space - rn->p.prefixlen); + } else if (bgp_node_has_bgp_path_info_data(prn)) + ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; - for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) { - pinum++; - ts->counts[BGP_STATS_RIB]++; - - if (pi->attr - && (CHECK_FLAG(pi->attr->flag, - ATTR_FLAG_BIT( - BGP_ATTR_ATOMIC_AGGREGATE)))) - ts->counts[BGP_STATS_AGGREGATES]++; - - /* as-path stats */ - if (pi->attr && pi->attr->aspath) { - unsigned int hops = - aspath_count_hops(pi->attr->aspath); - unsigned int size = - aspath_size(pi->attr->aspath); - as_t highest = aspath_highest(pi->attr->aspath); - - ts->counts[BGP_STATS_ASPATH_COUNT]++; - - if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) - ts->counts[BGP_STATS_ASPATH_MAXHOPS] = - hops; - - if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) - ts->counts[BGP_STATS_ASPATH_MAXSIZE] = - size; - - ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; - ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; + + for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) { + ts->counts[BGP_STATS_RIB]++; + + if (pi->attr + && (CHECK_FLAG(pi->attr->flag, + ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)))) + ts->counts[BGP_STATS_AGGREGATES]++; + + /* as-path stats */ + if (pi->attr && pi->attr->aspath) { + unsigned int hops = aspath_count_hops(pi->attr->aspath); + unsigned int size = aspath_size(pi->attr->aspath); + as_t highest = aspath_highest(pi->attr->aspath); + + ts->counts[BGP_STATS_ASPATH_COUNT]++; + + if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS]) + ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops; + + if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE]) + ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size; + + ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; + ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; #if 0 ts->counts[BGP_STATS_ASPATH_AVGHOPS] = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], @@ -10318,12 +10294,52 @@ static int bgp_table_stats_walker(struct thread *t) ts->counts[BGP_STATS_ASPATH_AVGSIZE], size); #endif - if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) - ts->counts[BGP_STATS_ASN_HIGHEST] = - highest; - } + if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) + ts->counts[BGP_STATS_ASN_HIGHEST] = highest; } } +} + +static int bgp_table_stats_walker(struct thread *t) +{ + struct bgp_node *rn, *nrn; + struct bgp_node *top; + struct bgp_table_stats *ts = THREAD_ARG(t); + unsigned int space = 0; + + if (!(top = bgp_table_top(ts->table))) + return 0; + + switch (ts->table->afi) { + case AFI_IP: + space = IPV4_MAX_BITLEN; + break; + case AFI_IP6: + space = IPV6_MAX_BITLEN; + break; + default: + return 0; + } + + ts->counts[BGP_STATS_MAXBITLEN] = space; + + for (rn = top; rn; rn = bgp_route_next(rn)) { + if (ts->table->safi == SAFI_MPLS_VPN) { + struct bgp_table *table; + + table = bgp_node_get_bgp_table_info(rn); + if (!table) + continue; + + top = bgp_table_top(table); + for (nrn = bgp_table_top(table); nrn; + nrn = bgp_route_next(nrn)) + bgp_table_stats_rn(nrn, top, ts, space); + } else { + bgp_table_stats_rn(rn, top, ts, space); + } + } + return 0; } @@ -10772,7 +10788,11 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi, return; } - table = bgp->rib[afi][safi]; + /* labeled-unicast routes live in the unicast table */ + if (safi == SAFI_LABELED_UNICAST) + table = bgp->rib[afi][SAFI_UNICAST]; + else + table = bgp->rib[afi][safi]; output_count = filtered_count = 0; subgrp = peer_subgroup(peer, afi, safi); @@ -11026,10 +11046,6 @@ static int peer_adj_routes(struct vty *vty, struct peer *peer, afi_t afi, if (use_json) json = json_object_new_object(); - /* labeled-unicast routes live in the unicast table */ - if (safi == SAFI_LABELED_UNICAST) - safi = SAFI_UNICAST; - if (!peer || !peer->afc[afi][safi]) { if (use_json) { json_object_string_add( |
