diff options
Diffstat (limited to 'bgpd/bgp_route.c')
-rw-r--r-- | bgpd/bgp_route.c | 1067 |
1 files changed, 534 insertions, 533 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index f3144fea..206cf702 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -58,18 +58,18 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA /* Extern from bgp_dump.c */ extern const char *bgp_origin_str[]; extern const char *bgp_origin_long_str[]; - + static struct bgp_node * bgp_afi_node_get (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p, struct prefix_rd *prd) { struct bgp_node *rn; struct bgp_node *prn = NULL; - + assert (table); if (!table) return NULL; - + if (safi == SAFI_MPLS_VPN) { prn = bgp_node_get (table, (struct prefix *) prd); @@ -88,7 +88,7 @@ bgp_afi_node_get (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix return rn; } - + /* Allocate bgp_info_extra */ static struct bgp_info_extra * bgp_info_extra_new (void) @@ -105,11 +105,11 @@ bgp_info_extra_free (struct bgp_info_extra **extra) { if ((*extra)->damp_info) bgp_damp_info_free ((*extra)->damp_info, 0); - + (*extra)->damp_info = NULL; - + XFREE (MTYPE_BGP_ROUTE_EXTRA, *extra); - + *extra = NULL; } } @@ -138,7 +138,7 @@ bgp_info_free (struct bgp_info *binfo) { if (binfo->attr) bgp_attr_unintern (binfo->attr); - + bgp_info_extra_free (&binfo->extra); peer_unlock (binfo->peer); /* bgp_info peer reference */ @@ -158,7 +158,7 @@ bgp_info_unlock (struct bgp_info *binfo) { assert (binfo && binfo->lock > 0); binfo->lock--; - + if (binfo->lock == 0) { #if 0 @@ -176,7 +176,7 @@ bgp_info_unlock (struct bgp_info *binfo) zlog_backtrace (LOG_DEBUG); } #endif - + return binfo; } @@ -186,19 +186,19 @@ bgp_info_add (struct bgp_node *rn, struct bgp_info *ri) struct bgp_info *top; top = rn->info; - + ri->next = rn->info; ri->prev = NULL; if (top) top->prev = ri; rn->info = ri; - + bgp_info_lock (ri); bgp_lock_node (rn); peer_lock (ri->peer); /* bgp_info peer reference */ } -/* Do the actual removal of info from RIB, for use by bgp_process +/* Do the actual removal of info from RIB, for use by bgp_process completion callback *only* */ static void bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri) @@ -209,7 +209,7 @@ bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri) ri->prev->next = ri->next; else rn->info = ri->next; - + bgp_info_unlock (ri); bgp_unlock_node (rn); } @@ -233,7 +233,7 @@ bgp_info_restore (struct bgp_node *rn, struct bgp_info *ri) SET_FLAG (ri->flags, BGP_INFO_VALID); } -/* Adjust pcount as required */ +/* Adjust pcount as required */ static void bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri) { @@ -244,13 +244,13 @@ bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri) if (rn->table->type != BGP_TABLE_MAIN || ri->peer == ri->peer->bgp->peer_self) return; - + if (BGP_INFO_HOLDDOWN (ri) && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) { - + UNSET_FLAG (ri->flags, BGP_INFO_COUNTED); - + /* slight hack, but more robust against errors. */ if (ri->peer->pcount[rn->table->afi][rn->table->safi]) ri->peer->pcount[rn->table->afi][rn->table->safi]--; @@ -260,9 +260,9 @@ bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri) __func__, ri->peer->host); zlog_backtrace (LOG_WARNING); zlog_warn ("%s: Please report to Quagga bugzilla", __func__); - } + } } - else if (!BGP_INFO_HOLDDOWN (ri) + else if (!BGP_INFO_HOLDDOWN (ri) && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) { SET_FLAG (ri->flags, BGP_INFO_COUNTED); @@ -278,11 +278,11 @@ void bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) { SET_FLAG (ri->flags, flag); - + /* early bath if we know it's not a flag that changes useability state */ if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) return; - + bgp_pcount_adjust (rn, ri); } @@ -290,11 +290,11 @@ void bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag) { UNSET_FLAG (ri->flags, flag); - + /* early bath if we know it's not a flag that changes useability state */ if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE)) return; - + bgp_pcount_adjust (rn, ri); } @@ -358,7 +358,7 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist) exist_pref = exist->attr->local_pref; else exist_pref = bgp->default_local_pref; - + if (new_pref > exist_pref) return 1; if (new_pref < exist_pref) @@ -385,14 +385,14 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist) { int exist_hops = aspath_count_hops (exist->attr->aspath); int exist_confeds = aspath_count_confeds (exist->attr->aspath); - + if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED)) { int aspath_hops; - + aspath_hops = aspath_count_hops (new->attr->aspath); aspath_hops += aspath_count_confeds (new->attr->aspath); - + if ( aspath_hops < (exist_hops + exist_confeds)) return 1; if ( aspath_hops > (exist_hops + exist_confeds)) @@ -401,7 +401,7 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist) else { int newhops = aspath_count_hops (new->attr->aspath); - + if (newhops < exist_hops) return 1; if (newhops > exist_hops) @@ -422,7 +422,7 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist) && aspath_count_confeds (exist->attr->aspath) > 0 && aspath_count_hops (new->attr->aspath) == 0 && aspath_count_hops (exist->attr->aspath) == 0); - + if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED) || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED) && confed_as_route) @@ -440,16 +440,16 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist) } /* 7. Peer type check. */ - if (peer_sort (new->peer) == BGP_PEER_EBGP + if (peer_sort (new->peer) == BGP_PEER_EBGP && peer_sort (exist->peer) == BGP_PEER_IBGP) return 1; - if (peer_sort (new->peer) == BGP_PEER_EBGP + if (peer_sort (new->peer) == BGP_PEER_EBGP && peer_sort (exist->peer) == BGP_PEER_CONFED) return 1; - if (peer_sort (new->peer) == BGP_PEER_IBGP + if (peer_sort (new->peer) == BGP_PEER_IBGP && peer_sort (exist->peer) == BGP_PEER_EBGP) return 0; - if (peer_sort (new->peer) == BGP_PEER_CONFED + if (peer_sort (new->peer) == BGP_PEER_CONFED && peer_sort (exist->peer) == BGP_PEER_EBGP) return 0; @@ -458,7 +458,7 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist) { uint32_t newm = (new->extra ? new->extra->igpmetric : 0); uint32_t existm = (exist->extra ? exist->extra->igpmetric : 0); - + if (newm < existm) return 1; if (newm > existm) @@ -532,31 +532,31 @@ bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr, #define FILTER_EXIST_WARN(F,f,filter) \ if (BGP_DEBUG (update, UPDATE_IN) \ - && !(F ## _IN (filter))) \ + && !(F ## _IN_LIST (filter))) \ plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \ peer->host, #f, F ## _IN_NAME(filter)); - + if (DISTRIBUTE_IN_NAME (filter)) { FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); - - if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY) + + if (access_list_apply (DISTRIBUTE_IN_LIST (filter), p) == FILTER_DENY) return FILTER_DENY; } if (PREFIX_LIST_IN_NAME (filter)) { FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); - - if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY) + + if (prefix_list_apply (PREFIX_LIST_IN_LIST(filter), p) == PREFIX_DENY) return FILTER_DENY; } - + if (FILTER_LIST_IN_NAME (filter)) { FILTER_EXIST_WARN(FILTER_LIST, as, filter); - - if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY) + + if (as_list_apply (FILTER_LIST_IN_LIST (filter), attr->aspath)== AS_FILTER_DENY) return FILTER_DENY; } - + return FILTER_PERMIT; #undef FILTER_EXIST_WARN } @@ -571,28 +571,29 @@ bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr, #define FILTER_EXIST_WARN(F,f,filter) \ if (BGP_DEBUG (update, UPDATE_OUT) \ - && !(F ## _OUT (filter))) \ + && !(F ## _OUT_LIST (filter))) \ plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \ peer->host, #f, F ## _OUT_NAME(filter)); if (DISTRIBUTE_OUT_NAME (filter)) { FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter); - - if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY) + + if (access_list_apply (DISTRIBUTE_OUT_LIST (filter), p) == FILTER_DENY) return FILTER_DENY; } - if (PREFIX_LIST_OUT_NAME (filter)) { + if (PREFIX_LIST_OUT_REF (filter)) { FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter); - - if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY) + + if (prefix_list_apply (PREFIX_LIST_OUT_LIST (filter), p) == PREFIX_DENY) return FILTER_DENY; } if (FILTER_LIST_OUT_NAME (filter)) { FILTER_EXIST_WARN(FILTER_LIST, as, filter); - - if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY) + + if (as_list_apply (FILTER_LIST_OUT_LIST (filter), attr->aspath) + == AS_FILTER_DENY) return FILTER_DENY; } @@ -616,7 +617,7 @@ bgp_community_filter (struct peer *peer, struct attr *attr) return 1; /* NO_EXPORT_SUBCONFED check. */ - if (peer_sort (peer) == BGP_PEER_EBGP + if (peer_sort (peer) == BGP_PEER_EBGP || peer_sort (peer) == BGP_PEER_CONFED) if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED)) return 1; @@ -636,13 +637,13 @@ bgp_cluster_filter (struct peer *peer, struct attr *attr) cluster_id = peer->bgp->cluster_id; else cluster_id = peer->bgp->router_id; - + if (cluster_loop_check (attr->extra->cluster, cluster_id)) return 1; } return 0; } - + static int bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) @@ -664,7 +665,7 @@ bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, info.peer = peer; info.attr = attr; - SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); + SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN); /* Apply BGP route map to the attribute. */ ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info); @@ -680,7 +681,7 @@ bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr, } return RMAP_PERMIT; } - + static int bgp_export_modifier (struct peer *rsclient, struct peer *peer, struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) @@ -752,7 +753,7 @@ bgp_import_modifier (struct peer *rsclient, struct peer *peer, } return RMAP_PERMIT; } - + static int bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, struct attr *attr, afi_t afi, safi_t safi) @@ -768,7 +769,7 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, from = ri->peer; filter = &peer->filter[afi][safi]; bgp = peer->bgp; - + if (DISABLE_BGP_ANNOUNCE) return 0; @@ -814,7 +815,7 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, transparent = 0; /* If community is not disabled check the no-export and local. */ - if (! transparent && bgp_community_filter (peer, ri->attr)) + if (! transparent && bgp_community_filter (peer, ri->attr)) return 0; /* If the attribute has originator-id and it is same as remote @@ -823,7 +824,7 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, { if (IPV4_ADDR_SAME (&peer->remote_id, &ri->attr->extra->originator_id)) { - if (BGP_DEBUG (filter, FILTER)) + if (BGP_DEBUG (filter, FILTER)) zlog (peer->log, LOG_DEBUG, "%s [Update:SEND] %s/%d originator-id is same as remote router-id", peer->host, @@ -832,7 +833,7 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, return 0; } } - + /* ORF prefix-list filter check */ if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) @@ -859,8 +860,8 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, /* AS path loop check. */ if (aspath_loop_check (ri->attr->aspath, peer->as)) { - if (BGP_DEBUG (filter, FILTER)) - zlog (peer->log, LOG_DEBUG, + if (BGP_DEBUG (filter, FILTER)) + zlog (peer->log, LOG_DEBUG, "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", peer->host, peer->as); return 0; @@ -872,13 +873,13 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, { if (aspath_loop_check(ri->attr->aspath, bgp->confed_id)) { - if (BGP_DEBUG (filter, FILTER)) - zlog (peer->log, LOG_DEBUG, + if (BGP_DEBUG (filter, FILTER)) + zlog (peer->log, LOG_DEBUG, "%s [Update:SEND] suppress announcement to peer AS %u is AS path.", peer->host, bgp->confed_id); return 0; - } + } } /* Route-Reflect check. */ @@ -909,7 +910,7 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, return 0; } } - + /* AS-Pathlimit check */ if (ri->attr->pathlimit.ttl && peer_sort (peer) == BGP_PEER_EBGP) /* Our ASN has not yet been pre-pended, that's done in packet_attribute @@ -922,13 +923,13 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, peer->host, ri->attr->pathlimit.ttl); return 0; } - + /* For modify attribute, copy it to temporary structure. */ bgp_attr_dup (attr, ri->attr); - + /* If local-preference is not set. */ - if ((peer_sort (peer) == BGP_PEER_IBGP - || peer_sort (peer) == BGP_PEER_CONFED) + if ((peer_sort (peer) == BGP_PEER_IBGP + || peer_sort (peer) == BGP_PEER_CONFED) && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))) { attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); @@ -936,7 +937,7 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, } /* Remove MED if its an EBGP peer - will get overwritten by route-maps */ - if (peer_sort (peer) == BGP_PEER_EBGP + if (peer_sort (peer) == BGP_PEER_EBGP && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) { if (ri->peer != bgp->peer_self && ! transparent @@ -949,7 +950,7 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED) && ((p->family == AF_INET && attr->nexthop.s_addr) #ifdef HAVE_IPV6 - || (p->family == AF_INET6 && + || (p->family == AF_INET6 && ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) #endif /* HAVE_IPV6 */ ))) @@ -959,7 +960,7 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || (p->family == AF_INET && attr->nexthop.s_addr == 0) #ifdef HAVE_IPV6 - || (p->family == AF_INET6 && + || (p->family == AF_INET6 && IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global)) #endif /* HAVE_IPV6 */ || (peer_sort (peer) == BGP_PEER_EBGP @@ -979,7 +980,7 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, if (p->family == AF_INET6) { /* IPv6 global nexthop must be included. */ - memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global, + memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global, IPV6_MAX_BYTELEN); attr->extra->mp_nexthop_len = 16; } @@ -989,8 +990,8 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, #ifdef HAVE_IPV6 if (p->family == AF_INET6) { - /* Left nexthop_local unchanged if so configured. */ - if ( CHECK_FLAG (peer->af_flags[afi][safi], + /* Left nexthop_local unchanged if so configured. */ + if ( CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) { if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) ) @@ -1000,16 +1001,16 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, } /* Default nexthop_local treatment for non-RS-Clients */ - else + else { /* Link-local address should not be transit to different peer. */ attr->extra->mp_nexthop_len = 16; /* Set link-local address for shared network peer. */ - if (peer->shared_network + if (peer->shared_network && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) { - memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local, + memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local, IPV6_MAX_BYTELEN); attr->extra->mp_nexthop_len = 32; } @@ -1033,13 +1034,13 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, /* locally originated update */ if (!attr->pathlimit.as) attr->pathlimit.as = peer->local_as; - + /* if the AS_PATHLIMIT attribute is attached to a prefix by a member of a confederation, then when the prefix is advertised outside of the confederation boundary, then the AS number of the confederation member inside of the AS_PATHLIMIT attribute should be replaced by the confederation's AS number. */ - if (peer_sort (from) == BGP_PEER_CONFED + if (peer_sort (from) == BGP_PEER_CONFED && peer_sort (peer) != BGP_PEER_CONFED) attr->pathlimit.as = peer->local_as; @@ -1050,7 +1051,7 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, if (attr->pathlimit.as >= BGP_PRIVATE_AS_MIN && attr->pathlimit.as <= BGP_PRIVATE_AS_MAX) { - if (peer->local_as < BGP_PRIVATE_AS_MIN + if (peer->local_as < BGP_PRIVATE_AS_MIN || peer->local_as > BGP_PRIVATE_AS_MAX) attr->pathlimit.as = peer->local_as; /* Ours is private, try using theirs.. */ @@ -1059,7 +1060,7 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, attr->pathlimit.as = peer->as; } } - + /* If this is EBGP peer and remove-private-AS is set. */ if (peer_sort (peer) == BGP_PEER_EBGP && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) @@ -1072,20 +1073,20 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, { struct bgp_info info; struct attr dummy_attr = { 0 }; - + info.peer = peer; info.attr = attr; /* The route reflector is not allowed to modify the attributes of the reflected IBGP routes. */ - if (peer_sort (from) == BGP_PEER_IBGP + if (peer_sort (from) == BGP_PEER_IBGP && peer_sort (peer) == BGP_PEER_IBGP) { bgp_attr_dup (&dummy_attr, attr); info.attr = &dummy_attr; } - SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); + SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); if (ri->extra && ri->extra->suppress) ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info); @@ -1093,10 +1094,10 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info); peer->rmap_type = 0; - + if (dummy_attr.extra) bgp_attr_extra_free (&dummy_attr); - + if (ret == RMAP_DENYMATCH) { bgp_attr_flush (attr); @@ -1149,7 +1150,7 @@ bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, peer's id. */ if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)) { - if (IPV4_ADDR_SAME (&rsclient->remote_id, + if (IPV4_ADDR_SAME (&rsclient->remote_id, &ri->attr->extra->originator_id)) { if (BGP_DEBUG (filter, FILTER)) @@ -1232,11 +1233,11 @@ bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, if (p->family == AF_INET6) { struct attr_extra *attre = attr->extra; - + assert (attr->extra); - + /* Left nexthop_local unchanged if so configured. */ - if ( CHECK_FLAG (rsclient->af_flags[afi][safi], + if ( CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ) { if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) ) @@ -1244,11 +1245,11 @@ bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, else attre->mp_nexthop_len=16; } - + /* Default nexthop_local treatment for RS-Clients */ - else - { - /* Announcer and RS-Client are both in the same network */ + else + { + /* Announcer and RS-Client are both in the same network */ if (rsclient->shared_network && from->shared_network && (rsclient->ifindex == from->ifindex)) { @@ -1321,7 +1322,7 @@ bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, struct bgp_info_pair * struct bgp_info *ri1; struct bgp_info *ri2; struct bgp_info *nextri = NULL; - + /* bgp deterministic-med */ new_select = NULL; if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)) @@ -1368,13 +1369,13 @@ bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, struct bgp_info_pair * if (BGP_INFO_HOLDDOWN (ri)) { - /* reap REMOVED routes, if needs be + /* reap REMOVED routes, if needs be * selected route must stay for a while longer though */ if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) && (ri != old_select)) bgp_info_reap (rn, ri); - + continue; } @@ -1390,7 +1391,7 @@ bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, struct bgp_info_pair * if (bgp_info_cmp (bgp, ri, new_select)) new_select = ri; } - + result->old = old_select; result->new = new_select; @@ -1430,22 +1431,22 @@ bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected, bgp_adj_out_unset (rn, peer, p, afi, safi); break; case BGP_TABLE_RSCLIENT: - /* Announcement to peer->conf. If the route is filtered, + /* Announcement to peer->conf. If the route is filtered, withdraw it. */ - if (selected && + if (selected && bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi)) bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected); else bgp_adj_out_unset (rn, peer, p, afi, safi); break; } - + bgp_attr_extra_free (&attr); - + return 0; } -struct bgp_process_queue +struct bgp_process_queue { struct bgp *bgp; struct bgp_node *rn; @@ -1466,7 +1467,7 @@ bgp_process_rsclient (struct work_queue *wq, void *data) struct bgp_info_pair old_and_new; struct listnode *node, *nnode; struct peer *rsclient = rn->table->owner; - + /* Best path selection. */ bgp_best_selection (bgp, rn, &old_and_new); new_select = old_and_new.new; @@ -1508,7 +1509,7 @@ bgp_process_rsclient (struct work_queue *wq, void *data) if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) bgp_info_reap (rn, old_select); - + UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); return WQ_SUCCESS; } @@ -1527,7 +1528,7 @@ bgp_process_main (struct work_queue *wq, void *data) struct bgp_info_pair old_and_new; struct listnode *node, *nnode; struct peer *peer; - + /* Best path selection. */ bgp_best_selection (bgp, rn, &old_and_new); old_select = old_and_new.old; @@ -1540,7 +1541,7 @@ bgp_process_main (struct work_queue *wq, void *data) { if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED)) bgp_zebra_announce (p, old_select, bgp); - + UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); return WQ_SUCCESS; } @@ -1565,24 +1566,24 @@ bgp_process_main (struct work_queue *wq, void *data) if (safi == SAFI_UNICAST && ! bgp->name && ! bgp_option_check (BGP_OPT_NO_FIB)) { - if (new_select - && new_select->type == ZEBRA_ROUTE_BGP + if (new_select + && new_select->type == ZEBRA_ROUTE_BGP && new_select->sub_type == BGP_ROUTE_NORMAL) bgp_zebra_announce (p, new_select, bgp); else { /* Withdraw the route from the kernel. */ - if (old_select + if (old_select && old_select->type == ZEBRA_ROUTE_BGP && old_select->sub_type == BGP_ROUTE_NORMAL) bgp_zebra_withdraw (p, old_select); } } - + /* Reap old select bgp_info, it it has been removed */ if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED)) bgp_info_reap (rn, old_select); - + UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); return WQ_SUCCESS; } @@ -1592,7 +1593,7 @@ bgp_processq_del (struct work_queue *wq, void *data) { struct bgp_process_queue *pq = data; struct bgp_table *table = pq->rn->table; - + bgp_unlock (pq->bgp); bgp_unlock_node (pq->rn); bgp_table_unlock (table); @@ -1606,13 +1607,13 @@ bgp_process_queue_init (void) = work_queue_new (bm->master, "process_main_queue"); bm->process_rsclient_queue = work_queue_new (bm->master, "process_rsclient_queue"); - + if ( !(bm->process_main_queue && bm->process_rsclient_queue) ) { zlog_err ("%s: Failed to allocate work queue", __func__); exit (1); } - + bm->process_main_queue->spec.workfunc = &bgp_process_main; bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient; bm->process_main_queue->spec.del_item_data = &bgp_processq_del; @@ -1628,16 +1629,16 @@ void bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) { struct bgp_process_queue *pqnode; - + /* already scheduled for processing? */ if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) return; - + if ( (bm->process_main_queue == NULL) || (bm->process_rsclient_queue == NULL) ) bgp_process_queue_init (); - - pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, + + pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, sizeof (struct bgp_process_queue)); if (!pqnode) return; @@ -1649,7 +1650,7 @@ bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) bgp_lock (bgp); pqnode->afi = afi; pqnode->safi = safi; - + switch (rn->table->type) { case BGP_TABLE_MAIN: @@ -1659,7 +1660,7 @@ bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) work_queue_add (bm->process_rsclient_queue, pqnode); break; } - + return; } @@ -1681,7 +1682,7 @@ bgp_maximum_prefix_restart_timer (struct thread *thread) } int -bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, +bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, safi_t safi, int always) { if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) @@ -1707,7 +1708,7 @@ bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, if (safi == SAFI_MPLS_VPN) safi = BGP_SAFI_VPNV4; - + ndata[0] = (afi >> 8); ndata[1] = afi; ndata[2] = safi; @@ -1764,10 +1765,10 @@ bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, afi_t afi, safi_t safi) { bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); - + if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) bgp_info_delete (rn, ri); /* keep historical info */ - + bgp_process (peer->bgp, rn, afi, safi); } @@ -1777,18 +1778,18 @@ bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer, { int status = BGP_DAMP_NONE; - /* apply dampening, if result is suppressed, we'll be retaining + /* apply dampening, if result is suppressed, we'll be retaining * the bgp_info in the RIB for historical reference. */ if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) && peer_sort (peer) == BGP_PEER_EBGP) - if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) + if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0)) == BGP_DAMP_SUPPRESSED) { bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); return; } - + bgp_rib_remove (rn, ri, peer, afi, safi); } @@ -1833,7 +1834,7 @@ bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, reason = "originator is us;"; goto filtered; } - + bgp_attr_dup (&new_attr, attr); /* Apply export policy. */ @@ -1845,7 +1846,7 @@ bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, } attr_new2 = bgp_attr_intern (&new_attr); - + /* Apply import policy. */ if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY) { @@ -1871,10 +1872,10 @@ bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, goto filtered; } } - + /* new_attr isn't passed to any functions after here */ bgp_attr_extra_free (&new_attr); - + /* If the update is implicit withdraw. */ if (ri) { @@ -1903,7 +1904,7 @@ bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, /* Withdraw/Announce before we fully processed the withdraw */ if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) bgp_info_restore (rn, ri); - + /* Received Logging. */ if (BGP_DEBUG (update, UPDATE_IN)) zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s", @@ -1956,18 +1957,18 @@ bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, /* Register new BGP information. */ bgp_info_add (rn, new); - + /* route_node_get lock */ bgp_unlock_node (rn); - + /* Process change. */ bgp_process (bgp, rn, afi, safi); - + bgp_attr_extra_free (&new_attr); - + return; - filtered: + filtered: /* This BGP update is filtered. Log the reason then update BGP entry. */ if (BGP_DEBUG (update, UPDATE_IN)) @@ -1981,10 +1982,10 @@ bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, bgp_rib_remove (rn, ri, peer, afi, safi); bgp_unlock_node (rn); - + if (new_attr.extra) bgp_attr_extra_free (&new_attr); - + return; } @@ -2038,7 +2039,7 @@ bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, bgp = peer->bgp; rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); - + /* When peer's soft reconfiguration enabled. Record input packet in Adj-RIBs-In. */ if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG) @@ -2056,7 +2057,7 @@ bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) aspath_loop_count = 1; - if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) + if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) { reason = "as-path contains our own AS;"; goto filtered; @@ -2136,7 +2137,7 @@ bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, ri->uptime = time (NULL); /* Same attribute comes in. */ - if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) + if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED) && attrhash_cmp (ri->attr, attr_new)) { bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED); @@ -2145,7 +2146,7 @@ bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, && peer_sort (peer) == BGP_PEER_EBGP && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) { - if (BGP_DEBUG (update, UPDATE_IN)) + if (BGP_DEBUG (update, UPDATE_IN)) zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", peer->host, inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), @@ -2159,7 +2160,7 @@ bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, } else /* Duplicate - odd */ { - if (BGP_DEBUG (update, UPDATE_IN)) + if (BGP_DEBUG (update, UPDATE_IN)) zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d...duplicate ignored", peer->host, @@ -2177,7 +2178,7 @@ bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, bgp_unlock_node (rn); bgp_attr_unintern (attr_new); bgp_attr_extra_free (&new_attr); - + return 0; } @@ -2193,7 +2194,7 @@ bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, } /* Received Logging. */ - if (BGP_DEBUG (update, UPDATE_IN)) + if (BGP_DEBUG (update, UPDATE_IN)) zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", peer->host, inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), @@ -2205,12 +2206,12 @@ bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, /* The attribute is changed. */ bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED); - + /* implicit withdraw, decrement aggregate and pcount here. * only if update is accepted, they'll increment below. */ bgp_aggregate_decrement (bgp, p, ri, afi, safi); - + /* Update bgp route dampening information. */ if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING) && peer_sort (peer) == BGP_PEER_EBGP) @@ -2218,9 +2219,9 @@ bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, /* This is implicit withdraw so we should update dampening information. */ if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) - bgp_damp_withdraw (ri, rn, afi, safi, 1); + bgp_damp_withdraw (ri, rn, afi, safi, 1); } - + /* Update to new attribute. */ bgp_attr_unintern (ri->attr); ri->attr = attr_new; @@ -2245,7 +2246,7 @@ bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, /* Nexthop reachability check. */ if ((afi == AFI_IP || afi == AFI_IP6) - && safi == SAFI_UNICAST + && safi == SAFI_UNICAST && (peer_sort (peer) == BGP_PEER_IBGP || peer_sort (peer) == BGP_PEER_CONFED || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1) @@ -2265,12 +2266,12 @@ bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, bgp_process (bgp, rn, afi, safi); bgp_unlock_node (rn); bgp_attr_extra_free (&new_attr); - + return 0; } /* Received Logging. */ - if (BGP_DEBUG (update, UPDATE_IN)) + if (BGP_DEBUG (update, UPDATE_IN)) { zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d", peer->host, @@ -2308,15 +2309,15 @@ bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, /* Increment prefix */ bgp_aggregate_increment (bgp, p, new, afi, safi); - + /* Register new BGP information. */ bgp_info_add (rn, new); - + /* route_node_get lock */ bgp_unlock_node (rn); - + bgp_attr_extra_free (&new_attr); - + /* If maximum prefix count is configured and current prefix count exeed it. */ if (bgp_maximum_prefix_overflow (peer, afi, safi, 0)) @@ -2341,9 +2342,9 @@ bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, bgp_rib_remove (rn, ri, peer, afi, safi); bgp_unlock_node (rn); - + bgp_attr_extra_free (&new_attr); - + return 0; } @@ -2374,8 +2375,8 @@ bgp_update (struct peer *peer, struct prefix *p, struct attr *attr, } int -bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, - afi_t afi, safi_t safi, int type, int sub_type, +bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, + afi_t afi, safi_t safi, int type, int sub_type, struct prefix_rd *prd, u_char *tag) { struct bgp *bgp; @@ -2395,7 +2396,7 @@ bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, } /* Logging. */ - if (BGP_DEBUG (update, UPDATE_IN)) + if (BGP_DEBUG (update, UPDATE_IN)) zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn", peer->host, inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), @@ -2419,7 +2420,7 @@ bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) bgp_rib_withdraw (rn, ri, peer, afi, safi); else if (BGP_DEBUG (update, UPDATE_IN)) - zlog (peer->log, LOG_DEBUG, + zlog (peer->log, LOG_DEBUG, "%s Can't find the route %s/%d", peer->host, inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), p->prefixlen); @@ -2429,7 +2430,7 @@ bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, return 0; } - + void bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) { @@ -2440,13 +2441,13 @@ bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) struct bgp_info binfo; struct peer *from; int ret = RMAP_DENYMATCH; - + if (!(afi == AFI_IP || afi == AFI_IP6)) return; - + bgp = peer->bgp; from = bgp->peer_self; - + bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); aspath = attr.aspath; attr.local_pref = bgp->default_local_pref; @@ -2459,23 +2460,23 @@ bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) { struct attr_extra *ae; attr.extra = NULL; - + ae = bgp_attr_extra_get (&attr); attr.extra = ae; - + str2prefix ("::/0", &p); /* IPv6 global nexthop must be included. */ - memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, + memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global, IPV6_MAX_BYTELEN); ae->mp_nexthop_len = 16; - + /* If the peer is on shared nextwork and we have link-local nexthop set it. */ - if (peer->shared_network + if (peer->shared_network && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) { - memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, + memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local, IPV6_MAX_BYTELEN); ae->mp_nexthop_len = 32; } @@ -2512,11 +2513,11 @@ bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw) SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE); bgp_default_update_send (peer, &attr, afi, safi, from); } - + bgp_attr_extra_free (&attr); aspath_unintern (aspath); } - + static void bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, struct bgp_table *table, int rsclient) @@ -2524,7 +2525,7 @@ bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, struct bgp_node *rn; struct bgp_info *ri; struct attr attr = { 0 }; - + if (! table) table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi]; @@ -2542,7 +2543,7 @@ bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi, bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); else bgp_adj_out_unset (rn, peer, &rn->p, afi, safi); - + bgp_attr_extra_free (&attr); } } @@ -2580,12 +2581,12 @@ bgp_announce_route_all (struct peer *peer) { afi_t afi; safi_t safi; - + for (afi = AFI_IP; afi < AFI_MAX; afi++) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) bgp_announce_route (peer, afi, safi); } - + static void bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi, safi_t safi, struct bgp_table *table) @@ -2609,7 +2610,7 @@ bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) { struct bgp_table *table; struct bgp_node *rn; - + if (safi != SAFI_MPLS_VPN) bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL); @@ -2619,7 +2620,7 @@ bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi) if ((table = rn->info) != NULL) bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table); } - + static void bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi, struct bgp_table *table) @@ -2666,7 +2667,7 @@ bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi) if ((table = rn->info) != NULL) bgp_soft_reconfig_table (peer, afi, safi, table); } - + struct bgp_clear_node_queue { @@ -2683,9 +2684,9 @@ bgp_clear_route_node (struct work_queue *wq, void *data) struct bgp_info *ri; afi_t afi = rn->table->afi; safi_t safi = rn->table->safi; - + assert (rn && peer); - + for (ri = rn->info; ri; ri = ri->next) if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT) { @@ -2708,8 +2709,8 @@ bgp_clear_node_queue_del (struct work_queue *wq, void *data) struct bgp_clear_node_queue *cnq = data; struct bgp_node *rn = cnq->rn; struct bgp_table *table = rn->table; - - bgp_unlock_node (rn); + + bgp_unlock_node (rn); bgp_table_unlock (table); XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq); } @@ -2718,7 +2719,7 @@ static void bgp_clear_node_complete (struct work_queue *wq) { struct peer *peer = wq->spec.data; - + /* Tickle FSM to start moving again */ BGP_EVENT_ADD (peer, Clearing_Completed); @@ -2729,7 +2730,7 @@ static void bgp_clear_node_queue_init (struct peer *peer) { char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")]; - + snprintf (wname, sizeof(wname), "clear %s", peer->host); #undef CLEAR_QUEUE_NAME_LEN @@ -2743,7 +2744,7 @@ bgp_clear_node_queue_init (struct peer *peer) peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del; peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete; peer->clear_node_queue->spec.max_retries = 0; - + /* we only 'lock' this peer reference when the queue is actually active */ peer->clear_node_queue->spec.data = peer; } @@ -2754,21 +2755,21 @@ bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi, enum bgp_clear_route_type purpose) { struct bgp_node *rn; - - + + if (! table) table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi]; - + /* If still no table => afi/safi isn't configured at all or smth. */ if (! table) return; - + for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) { struct bgp_info *ri; struct bgp_adj_in *ain; struct bgp_adj_out *aout; - + if (rn->info == NULL) continue; @@ -2848,7 +2849,7 @@ bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, if (peer->clear_node_queue == NULL) bgp_clear_node_queue_init (peer); - + /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to * Idle until it receives a Clearing_Completed event. This protects * against peers which flap faster than we can we clear, which could @@ -2889,9 +2890,9 @@ bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, assert (0); break; } - + /* If no routes were cleared, nothing was added to workqueue, the - * completion function won't be run by workqueue code - call it here. + * completion function won't be run by workqueue code - call it here. * XXX: Actually, this assumption doesn't hold, see * bgp_clear_route_table(), we queue all non-empty nodes. * @@ -2912,7 +2913,7 @@ bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi, if (!peer->clear_node_queue->thread) bgp_clear_node_complete (peer->clear_node_queue); } - + void bgp_clear_route_all (struct peer *peer) { @@ -2963,7 +2964,7 @@ bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) } } } - + /* Delete all kernel routes. */ void bgp_cleanup_routes (void) @@ -2981,7 +2982,7 @@ bgp_cleanup_routes (void) for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) for (ri = rn->info; ri; ri = ri->next) if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) - && ri->type == ZEBRA_ROUTE_BGP + && ri->type == ZEBRA_ROUTE_BGP && ri->sub_type == BGP_ROUTE_NORMAL) bgp_zebra_withdraw (&rn->p, ri); @@ -2990,7 +2991,7 @@ bgp_cleanup_routes (void) for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) for (ri = rn->info; ri; ri = ri->next) if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) - && ri->type == ZEBRA_ROUTE_BGP + && ri->type == ZEBRA_ROUTE_BGP && ri->sub_type == BGP_ROUTE_NORMAL) bgp_zebra_withdraw (&rn->p, ri); } @@ -3004,7 +3005,7 @@ bgp_reset (void) access_list_reset (); prefix_list_reset (); } - + /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr value. */ int @@ -3019,7 +3020,7 @@ bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) /* Check peer status. */ if (peer->status != Established) return 0; - + pnt = packet->nlri; lim = pnt + packet->length; @@ -3031,7 +3032,7 @@ bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) /* Fetch prefix length. */ p.prefixlen = *pnt++; p.family = afi2family (packet->afi); - + /* Already checked in nlri_sanity_check(). We do double check here. */ if ((packet->afi == AFI_IP && p.prefixlen > 32) @@ -3053,14 +3054,14 @@ bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) { if (IN_CLASSD (ntohl (p.u.prefix4.s_addr))) { - /* - * From draft-ietf-idr-bgp4-22, Section 6.3: + /* + * From draft-ietf-idr-bgp4-22, Section 6.3: * If a BGP router receives an UPDATE message with a * semantically incorrect NLRI field, in which a prefix is * semantically incorrect (eg. an unexpected multicast IP * address), it should ignore the prefix. */ - zlog (peer->log, LOG_ERR, + zlog (peer->log, LOG_ERR, "IPv4 unicast NLRI is multicast address %s", inet_ntoa (p.u.prefix4)); @@ -3076,7 +3077,7 @@ bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) { char buf[BUFSIZ]; - zlog (peer->log, LOG_WARNING, + zlog (peer->log, LOG_WARNING, "IPv6 link-local NLRI received %s ignore this NLRI", inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ)); @@ -3087,10 +3088,10 @@ bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) /* Normal process. */ if (attr) - ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, + ret = bgp_update (peer, &p, attr, packet->afi, packet->safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0); else - ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, + ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL); /* Address family configuration mismatch or maximum-prefix count @@ -3124,15 +3125,15 @@ bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, while (pnt < end) { prefixlen = *pnt++; - + /* Prefix length check. */ if ((afi == AFI_IP && prefixlen > 32) || (afi == AFI_IP6 && prefixlen > 128)) { - plog_err (peer->log, + plog_err (peer->log, "%s [Error] Update packet error (wrong prefix length %d)", peer->host, prefixlen); - bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, + bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, BGP_NOTIFY_UPDATE_INVAL_NETWORK); return -1; } @@ -3142,11 +3143,11 @@ bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, if (pnt + psize > end) { - plog_err (peer->log, + plog_err (peer->log, "%s [Error] Update packet error" " (prefix data overflow prefix size is %d)", peer->host, psize); - bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, + bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, BGP_NOTIFY_UPDATE_INVAL_NETWORK); return -1; } @@ -3161,13 +3162,13 @@ bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, "%s [Error] Update packet error" " (prefix length mismatch with total length)", peer->host); - bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, + bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, BGP_NOTIFY_UPDATE_INVAL_NETWORK); return -1; } return 0; } - + static struct bgp_static * bgp_static_new (void) { @@ -3238,7 +3239,7 @@ bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, attr.nexthop = bgp_static->igpnexthop; attr.med = bgp_static->igpmetric; attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); - + if (bgp_static->ttl) { attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_AS_PATHLIMIT); @@ -3246,17 +3247,17 @@ bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, attr.pathlimit.as = 0; attr.pathlimit.ttl = bgp_static->ttl; } - + if (bgp_static->atomic) attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); - + /* Apply network route-map for export to this rsclient. */ if (bgp_static->rmap.name) { struct attr attr_tmp = attr; info.peer = rsclient; info.attr = &attr_tmp; - + SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT); SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK); @@ -3273,19 +3274,19 @@ bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, aspath_unintern (attr.aspath); bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); bgp_attr_extra_free (&attr); - + return; } attr_new = bgp_attr_intern (&attr_tmp); } else attr_new = bgp_attr_intern (&attr); - + new_attr = *attr_new; - + SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK); - if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) + if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) == RMAP_DENY) { /* This BGP update is filtered. Log the reason then update BGP entry. */ @@ -3302,7 +3303,7 @@ bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, bgp_attr_extra_free (&attr); bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi); - + return; } @@ -3347,7 +3348,7 @@ bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, return; } } - + /* Make new BGP info. */ new = bgp_info_new (); new->type = ZEBRA_ROUTE_BGP; @@ -3359,10 +3360,10 @@ bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p, /* Register new BGP information. */ bgp_info_add (rn, new); - + /* route_node_get lock */ bgp_unlock_node (rn); - + /* Process change. */ bgp_process (bgp, rn, afi, safi); @@ -3390,7 +3391,7 @@ bgp_static_update_main (struct bgp *bgp, struct prefix *p, rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL); bgp_attr_default_set (&attr, BGP_ORIGIN_IGP); - + attr.nexthop = bgp_static->igpnexthop; attr.med = bgp_static->igpmetric; attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); @@ -3420,7 +3421,7 @@ bgp_static_update_main (struct bgp *bgp, struct prefix *p, bgp->peer_self->rmap_type = 0; if (ret == RMAP_DENYMATCH) - { + { /* Free uninterned attribute. */ bgp_attr_flush (&attr_tmp); @@ -3486,13 +3487,13 @@ bgp_static_update_main (struct bgp *bgp, struct prefix *p, /* Aggregate address increment. */ bgp_aggregate_increment (bgp, p, new, afi, safi); - + /* Register new BGP information. */ bgp_info_add (rn, new); - + /* route_node_get lock */ bgp_unlock_node (rn); - + /* Process change. */ bgp_process (bgp, rn, afi, safi); @@ -3523,7 +3524,7 @@ bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi, { struct bgp_node *rn; struct bgp_info *new; - + rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd); /* Make new BGP info. */ @@ -3539,13 +3540,13 @@ bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi, /* Aggregate address increment. */ bgp_aggregate_increment (bgp, p, new, afi, safi); - + /* Register new BGP information. */ bgp_info_add (rn, new); /* route_node_get lock */ bgp_unlock_node (rn); - + /* Process change. */ bgp_process (bgp, rn, afi, safi); } @@ -3561,7 +3562,7 @@ bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi, /* Check selected route and self inserted route. */ for (ri = rn->info; ri; ri = ri->next) - if (ri->peer == bgp->peer_self + if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP && ri->sub_type == BGP_ROUTE_STATIC) break; @@ -3609,7 +3610,7 @@ bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi, /* Check selected route and self inserted route. */ for (ri = rn->info; ri; ri = ri->next) - if (ri->peer == bgp->peer_self + if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP && ri->sub_type == BGP_ROUTE_STATIC) break; @@ -3632,14 +3633,14 @@ bgp_pathlimit_update_parents (struct bgp *bgp, struct bgp_node *rn, { struct bgp_node *parent = rn; struct bgp_static *sp; - + /* Existing static changed TTL, search parents and adjust their atomic */ while ((parent = parent->parent)) if ((sp = parent->info)) { int sp_level = (sp->atomic ? 1 : 0); ttl_edge ? sp->atomic++ : sp->atomic--; - + /* did we change state of parent whether atomic is set or not? */ if (sp_level != (sp->atomic ? 1 : 0)) { @@ -3652,7 +3653,7 @@ bgp_pathlimit_update_parents (struct bgp *bgp, struct bgp_node *rn, /* Configure static BGP network. When user don't run zebra, static route should be installed as valid. */ static int -bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, +bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, u_int16_t afi, u_char safi, const char *rmap, int backdoor, u_char ttl) { @@ -3698,16 +3699,16 @@ bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, || bgp_static->ttl != ttl) need_update = 1; } - + /* need to catch TTL set/unset transitions for handling of - * ATOMIC_AGGREGATE - */ + * ATOMIC_AGGREGATE + */ if ((bgp_static->ttl ? 1 : 0) != ttl_edge) ttl_change = 1; - + bgp_static->backdoor = backdoor; bgp_static->ttl = ttl; - + if (rmap) { if (bgp_static->rmap.name) @@ -3736,7 +3737,7 @@ bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, bgp_static->ttl = ttl; ttl_change = ttl_edge; new = 1; - + if (rmap) { if (bgp_static->rmap.name) @@ -3765,12 +3766,12 @@ bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, /* Existing static changed TTL, search parents and adjust their atomic */ bgp_pathlimit_update_parents (bgp, rn, ttl_edge); } - + if (new) { struct bgp_node *child; struct bgp_static *sc; - + /* New static, search children and bump this statics atomic.. */ child = bgp_lock_node (rn); /* route_next_until unlocks it.. */ while ((child = bgp_route_next_until (child, rn))) @@ -3779,7 +3780,7 @@ bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str, bgp_static->atomic++; } } - + /* If BGP scan is not enabled, we should install this route here. */ if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK)) { @@ -3832,10 +3833,10 @@ bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str, } bgp_static = rn->info; - + /* decrement atomic in parents, see bgp_static_set */ bgp_pathlimit_update_parents (bgp, rn, 0); - + /* Update BGP RIB. */ if (! bgp_static->backdoor) bgp_static_withdraw (bgp, &p, afi, safi); @@ -3865,7 +3866,7 @@ bgp_static_delete (struct bgp *bgp) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) if (rn->info != NULL) - { + { if (safi == SAFI_MPLS_VPN) { table = rn->info; @@ -3962,7 +3963,7 @@ bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, /* Configure static BGP network. */ int -bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, +bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str, const char *tag_str) { int ret; @@ -4025,7 +4026,7 @@ bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str, return CMD_SUCCESS; } - + DEFUN (bgp_network, bgp_network_cmd, "network A.B.C.D/M", @@ -4033,10 +4034,10 @@ DEFUN (bgp_network, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") { u_char ttl = 0; - + if (argc == 2) VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl, argv[1], 1, 255); - + return bgp_static_set (vty, vty->index, argv[0], AFI_IP, bgp_node_safi (vty), NULL, 0, ttl); } @@ -4069,10 +4070,10 @@ DEFUN (bgp_network_backdoor, "Specify a BGP backdoor route\n") { u_char ttl = 0; - + if (argc == 2) VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl, argv[1], 1, 255); - + return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, ttl); } @@ -4097,10 +4098,10 @@ DEFUN (bgp_network_mask, int ret; char prefix_str[BUFSIZ]; u_char ttl = 0; - + if (argc == 3) VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl, argv[2], 1, 255); - + ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); if (! ret) { @@ -4134,7 +4135,7 @@ DEFUN (bgp_network_mask_route_map, { int ret; char prefix_str[BUFSIZ]; - + ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str); if (! ret) { @@ -4158,7 +4159,7 @@ DEFUN (bgp_network_mask_backdoor, int ret; char prefix_str[BUFSIZ]; u_char ttl = 0; - + if (argc == 3) VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl, argv[2], 1, 255); @@ -4193,7 +4194,7 @@ DEFUN (bgp_network_mask_natural, int ret; char prefix_str[BUFSIZ]; u_char ttl = 0; - + if (argc == 2) VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl, argv[1], 1, 255); @@ -4248,7 +4249,7 @@ DEFUN (bgp_network_mask_natural_backdoor, int ret; char prefix_str[BUFSIZ]; u_char ttl = 0; - + if (argc == 2) VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl, argv[1], 1, 255); @@ -4279,7 +4280,7 @@ DEFUN (no_bgp_network, "Specify a network to announce via BGP\n" "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") { - return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, + return bgp_static_unset (vty, vty->index, argv[0], AFI_IP, bgp_node_safi (vty)); } @@ -4338,7 +4339,7 @@ DEFUN (no_bgp_network_mask, return CMD_WARNING; } - return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, + return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, bgp_node_safi (vty)); } @@ -4403,7 +4404,7 @@ DEFUN (no_bgp_network_mask_natural, return CMD_WARNING; } - return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, + return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP, bgp_node_safi (vty)); } @@ -4451,7 +4452,7 @@ DEFUN (ipv6_bgp_network, "IPv6 prefix <network>/<length>\n") { u_char ttl = 0; - + if (argc == 2) VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl, argv[1], 1, 255); @@ -4524,7 +4525,7 @@ ALIAS (no_ipv6_bgp_network, "Specify a network to announce via BGP\n" "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") #endif /* HAVE_IPV6 */ - + /* Aggreagete address: advertise-map Set condition to advertise attribute @@ -4563,11 +4564,11 @@ static void bgp_aggregate_free (struct bgp_aggregate *aggregate) { XFREE (MTYPE_BGP_AGGREGATE, aggregate); -} +} static void bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, - afi_t afi, safi_t safi, struct bgp_info *del, + afi_t afi, safi_t safi, struct bgp_info *del, struct bgp_aggregate *aggregate) { struct bgp_table *table; @@ -4687,7 +4688,7 @@ bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, if (rinew) { aggregate->count++; - + if (aggregate->summary_only) (bgp_info_extra_get (rinew))->suppress++; @@ -4778,7 +4779,7 @@ bgp_aggregate_increment (struct bgp *bgp, struct prefix *p, } void -bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, +bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p, struct bgp_info *del, afi_t afi, safi_t safi) { struct bgp_node *child; @@ -4827,7 +4828,7 @@ bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, return; if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN) return; - + /* If routes exists below this node, generate aggregate routes. */ top = bgp_node_get (table, p); for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top)) @@ -4882,7 +4883,7 @@ bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, aggregate->count++; } } - + /* If this node is suppressed, process the change. */ if (match) bgp_process (bgp, rn, afi, safi); @@ -4904,14 +4905,14 @@ bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, bgp_info_add (rn, new); bgp_unlock_node (rn); - + /* Process change. */ bgp_process (bgp, rn, afi, safi); } } void -bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, +bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi, struct bgp_aggregate *aggregate) { struct bgp_table *table; @@ -4965,7 +4966,7 @@ bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, rn = bgp_node_get (table, p); for (ri = rn->info; ri; ri = ri->next) - if (ri->peer == bgp->peer_self + if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP && ri->sub_type == BGP_ROUTE_AGGREGATE) break; @@ -4986,7 +4987,7 @@ bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi, #define AGGREGATE_AS_SET 1 static int -bgp_aggregate_set (struct vty *vty, const char *prefix_str, +bgp_aggregate_set (struct vty *vty, const char *prefix_str, afi_t afi, safi_t safi, u_char summary_only, u_char as_set) { @@ -5035,7 +5036,7 @@ bgp_aggregate_set (struct vty *vty, const char *prefix_str, } static int -bgp_aggregate_unset (struct vty *vty, const char *prefix_str, +bgp_aggregate_unset (struct vty *vty, const char *prefix_str, afi_t afi, safi_t safi) { int ret; @@ -5354,7 +5355,7 @@ DEFUN (ipv6_aggregate_address_summary_only, "Aggregate prefix\n" "Filter more specific routes from updates\n") { - return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, + return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, AGGREGATE_SUMMARY_ONLY, 0); } @@ -5415,7 +5416,7 @@ ALIAS (no_ipv6_aggregate_address_summary_only, "Aggregate prefix\n" "Filter more specific routes from updates\n") #endif /* HAVE_IPV6 */ - + /* Redistribute route treatment. */ void bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop, @@ -5471,7 +5472,7 @@ bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop, /* Free uninterned attribute. */ bgp_attr_flush (&attr_new); bgp_attr_extra_free (&attr_new); - + /* Unintern original. */ aspath_unintern (attr.aspath); bgp_attr_extra_free (&attr); @@ -5480,17 +5481,17 @@ bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop, } } - bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], + bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL); - + new_attr = bgp_attr_intern (&attr_new); bgp_attr_extra_free (&attr_new); - + for (bi = bn->info; bi; bi = bi->next) if (bi->peer == bgp->peer_self && bi->sub_type == BGP_ROUTE_REDISTRIBUTE) break; - + if (bi) { if (attrhash_cmp (bi->attr, new_attr) && @@ -5506,7 +5507,7 @@ bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop, { /* The attribute is changed. */ bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED); - + /* Rewrite BGP route information. */ if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED)) bgp_info_restore(bn, bi); @@ -5515,7 +5516,7 @@ bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop, bgp_attr_unintern (bi->attr); bi->attr = new_attr; bi->uptime = time (NULL); - + /* Process change. */ bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); bgp_process (bgp, bn, afi, SAFI_UNICAST); @@ -5523,7 +5524,7 @@ bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop, aspath_unintern (attr.aspath); bgp_attr_extra_free (&attr); return; - } + } } new = bgp_info_new (); @@ -5604,13 +5605,13 @@ bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type) } } } - + /* Static function to display route. */ static void route_vty_out_route (struct prefix *p, struct vty *vty) { int len; - u_int32_t destination; + u_int32_t destination; char buf[BUFSIZ]; if (p->family == AF_INET) @@ -5674,7 +5675,7 @@ route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo) if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as)) vty_out (vty, "i"); else - vty_out (vty, " "); + vty_out (vty, " "); } /* called from terminal list command */ @@ -5683,10 +5684,10 @@ route_vty_out (struct vty *vty, struct prefix *p, struct bgp_info *binfo, int display, safi_t safi) { struct attr *attr; - - /* short status lead text */ + + /* short status lead text */ route_vty_short_status_out (vty, binfo); - + /* print prefix and mask */ if (! display) route_vty_out_route (p, vty); @@ -5695,7 +5696,7 @@ route_vty_out (struct vty *vty, struct prefix *p, /* Print attribute */ attr = binfo->attr; - if (attr) + if (attr) { if (p->family == AF_INET) { @@ -5705,13 +5706,13 @@ route_vty_out (struct vty *vty, struct prefix *p, else vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); } -#ifdef HAVE_IPV6 +#ifdef HAVE_IPV6 else if (p->family == AF_INET6) { int len; char buf[BUFSIZ]; - len = vty_out (vty, "%s", + len = vty_out (vty, "%s", inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, buf, BUFSIZ)); len = 16 - len; @@ -5733,7 +5734,7 @@ route_vty_out (struct vty *vty, struct prefix *p, vty_out (vty, " "); vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); - + /* Print aspath */ if (attr->aspath) aspath_print_vty (vty, "%s", attr->aspath, " "); @@ -5742,7 +5743,7 @@ route_vty_out (struct vty *vty, struct prefix *p, vty_out (vty, "%s", bgp_origin_str[attr->origin]); } vty_out (vty, "%s", VTY_NEWLINE); -} +} /* called from terminal list command */ void @@ -5758,7 +5759,7 @@ route_vty_out_tmp (struct vty *vty, struct prefix *p, route_vty_out_route (p, vty); /* Print attribute */ - if (attr) + if (attr) { if (p->family == AF_INET) { @@ -5773,7 +5774,7 @@ route_vty_out_tmp (struct vty *vty, struct prefix *p, { int len; char buf[BUFSIZ]; - + assert (attr->extra); len = vty_out (vty, "%s", @@ -5796,9 +5797,9 @@ route_vty_out_tmp (struct vty *vty, struct prefix *p, vty_out (vty, "%7d", attr->local_pref); else vty_out (vty, " "); - + vty_out (vty, "%7d ", (attr->extra ? attr->extra->weight : 0)); - + /* Print aspath */ if (attr->aspath) aspath_print_vty (vty, "%s", attr->aspath, " "); @@ -5808,7 +5809,7 @@ route_vty_out_tmp (struct vty *vty, struct prefix *p, } vty_out (vty, "%s", VTY_NEWLINE); -} +} void route_vty_out_tag (struct vty *vty, struct prefix *p, @@ -5816,13 +5817,13 @@ route_vty_out_tag (struct vty *vty, struct prefix *p, { struct attr *attr; u_int32_t label = 0; - + if (!binfo->extra) return; - - /* short status lead text */ + + /* short status lead text */ route_vty_short_status_out (vty, binfo); - + /* print prefix and mask */ if (! display) route_vty_out_route (p, vty); @@ -5831,7 +5832,7 @@ route_vty_out_tag (struct vty *vty, struct prefix *p, /* Print attribute */ attr = binfo->attr; - if (attr) + if (attr) { if (p->family == AF_INET) { @@ -5841,14 +5842,14 @@ route_vty_out_tag (struct vty *vty, struct prefix *p, else vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); } -#ifdef HAVE_IPV6 +#ifdef HAVE_IPV6 else if (p->family == AF_INET6) { assert (attr->extra); char buf[BUFSIZ]; char buf1[BUFSIZ]; if (attr->extra->mp_nexthop_len == 16) - vty_out (vty, "%s", + vty_out (vty, "%s", inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, buf, BUFSIZ)); else if (attr->extra->mp_nexthop_len == 32) @@ -5857,7 +5858,7 @@ route_vty_out_tag (struct vty *vty, struct prefix *p, buf, BUFSIZ), inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, buf1, BUFSIZ)); - + } #endif /* HAVE_IPV6 */ } @@ -5867,7 +5868,7 @@ route_vty_out_tag (struct vty *vty, struct prefix *p, vty_out (vty, "notag/%d", label); vty_out (vty, "%s", VTY_NEWLINE); -} +} /* dampening route */ static void @@ -5878,9 +5879,9 @@ damp_route_vty_out (struct vty *vty, struct prefix *p, int len; char timebuf[BGP_UPTIME_LEN]; - /* short status lead text */ + /* short status lead text */ route_vty_short_status_out (vty, binfo); - + /* print prefix and mask */ if (! display) route_vty_out_route (p, vty); @@ -5919,15 +5920,15 @@ flap_route_vty_out (struct vty *vty, struct prefix *p, struct bgp_damp_info *bdi; char timebuf[BGP_UPTIME_LEN]; int len; - + if (!binfo->extra) return; - + bdi = binfo->extra->damp_info; /* short status lead text */ route_vty_short_status_out (vty, binfo); - + /* print prefix and mask */ if (! display) route_vty_out_route (p, vty); @@ -5947,7 +5948,7 @@ flap_route_vty_out (struct vty *vty, struct prefix *p, vty_out (vty, " "); else vty_out (vty, "%*s ", len, " "); - + vty_out (vty, "%s ", peer_uptime (bdi->start_time, timebuf, BGP_UPTIME_LEN)); @@ -5972,14 +5973,14 @@ flap_route_vty_out (struct vty *vty, struct prefix *p, } static void -route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, +route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, struct bgp_info *binfo, afi_t afi, safi_t safi) { char buf[INET6_ADDRSTRLEN]; char buf1[BUFSIZ]; struct attr *attr; int sockunion_vty_out (struct vty *, union sockunion *); - + attr = binfo->attr; if (attr) @@ -5999,7 +6000,7 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE)) vty_out (vty, ", (stale)"); if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) - vty_out (vty, ", (aggregated by %u %s)", + vty_out (vty, ", (aggregated by %u %s)", attr->extra->aggregator_as, inet_ntoa (attr->extra->aggregator_addr)); if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) @@ -6011,7 +6012,7 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)) vty_out (vty, ", (suppressed due to dampening)"); vty_out (vty, "%s", VTY_NEWLINE); - + /* Line2 display Next-hop, Neighbor, Router-id */ if (p->family == AF_INET) { @@ -6031,14 +6032,14 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, if (binfo->peer == bgp->peer_self) { - vty_out (vty, " from %s ", + vty_out (vty, " from %s ", p->family == AF_INET ? "0.0.0.0" : "::"); vty_out (vty, "(%s)", inet_ntoa(bgp->router_id)); } else { if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) - vty_out (vty, " (inaccessible)"); + vty_out (vty, " (inaccessible)"); else if (binfo->extra && binfo->extra->igpmetric) vty_out (vty, " (metric %d)", binfo->extra->igpmetric); vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); @@ -6062,10 +6063,10 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */ vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]); - + if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) vty_out (vty, ", metric %d", attr->med); - + if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) vty_out (vty, ", localpref %d", attr->local_pref); else @@ -6073,7 +6074,7 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, if (attr->extra && attr->extra->weight != 0) vty_out (vty, ", weight %d", attr->extra->weight); - + if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)) vty_out (vty, ", valid"); @@ -6081,8 +6082,8 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, { if (binfo->peer->as == binfo->peer->local_as) vty_out (vty, ", internal"); - else - vty_out (vty, ", %s", + else + vty_out (vty, ", %s", (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external")); } else if (binfo->sub_type == BGP_ROUTE_AGGREGATE) @@ -6094,29 +6095,29 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) vty_out (vty, ", atomic-aggregate"); - + if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED)) vty_out (vty, ", best"); vty_out (vty, "%s", VTY_NEWLINE); - + /* Line 4 display Community */ if (attr->community) vty_out (vty, " Community: %s%s", attr->community->str, VTY_NEWLINE); - + /* Line 5 display Extended-community */ if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) - vty_out (vty, " Extended Community: %s%s", + vty_out (vty, " Extended Community: %s%s", attr->extra->ecommunity->str, VTY_NEWLINE); - + /* Line 6 display Originator, Cluster-id */ if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) { assert (attr->extra); if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) - vty_out (vty, " Originator: %s", + vty_out (vty, " Originator: %s", inet_ntoa (attr->extra->originator_id)); if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) @@ -6124,23 +6125,23 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, int i; vty_out (vty, ", Cluster list: "); for (i = 0; i < attr->extra->cluster->length / 4; i++) - vty_out (vty, "%s ", + vty_out (vty, "%s ", inet_ntoa (attr->extra->cluster->list[i])); } vty_out (vty, "%s", VTY_NEWLINE); } - + /* 7: AS Pathlimit */ if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_AS_PATHLIMIT)) { - + vty_out (vty, " AS-Pathlimit: %u", attr->pathlimit.ttl); if (attr->pathlimit.as) vty_out (vty, " (%u)", attr->pathlimit.as); vty_out (vty, "%s", VTY_NEWLINE); } - + if (binfo->extra && binfo->extra->damp_info) bgp_damp_info_vty (vty, binfo); @@ -6148,8 +6149,8 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, vty_out (vty, " Last update: %s", ctime (&binfo->uptime)); } vty_out (vty, "%s", VTY_NEWLINE); -} - +} + #define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,%s r RIB-failure, S Stale, R Removed%s" #define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s" #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s" @@ -6199,7 +6200,7 @@ bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router output_count = 0; /* Start processing of routes. */ - for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) + for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) if (rn->info != NULL) { display = 0; @@ -6226,7 +6227,7 @@ bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router || type == bgp_show_type_flap_regexp) { regex_t *regex = output_arg; - + if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH) continue; } @@ -6234,7 +6235,7 @@ bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router || type == bgp_show_type_flap_prefix_list) { struct prefix_list *plist = output_arg; - + if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT) continue; } @@ -6251,7 +6252,7 @@ bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router { struct route_map *rmap = output_arg; struct bgp_info binfo; - struct attr dummy_attr = { 0 }; + struct attr dummy_attr = { 0 }; int ret; bgp_attr_dup (&dummy_attr, ri->attr); @@ -6259,9 +6260,9 @@ bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router binfo.attr = &dummy_attr; ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo); - + bgp_attr_extra_free (&dummy_attr); - + if (ret == RMAP_DENYMATCH) continue; } @@ -6516,7 +6517,7 @@ route_vty_out_detail_header (struct vty *vty, struct bgp *bgp, /* Display specified route of BGP table. */ static int -bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, +bgp_show_route_in_table (struct vty *vty, struct bgp *bgp, struct bgp_table *rib, const char *ip_str, afi_t afi, safi_t safi, struct prefix_rd *prd, int prefix_check) @@ -6630,8 +6631,8 @@ bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str, return CMD_WARNING; } } - - return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, + + return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str, afi, safi, prd, prefix_check); } @@ -6659,7 +6660,7 @@ DEFUN (show_ip_bgp_ipv4, if (strncmp (argv[0], "m", 1) == 0) return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, NULL); - + return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL); } @@ -6946,7 +6947,7 @@ DEFUN (show_bgp_view, vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); return CMD_WARNING; } - + return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL); } @@ -6954,11 +6955,11 @@ ALIAS (show_bgp_view, show_bgp_view_ipv6_cmd, "show bgp view WORD ipv6", SHOW_STR - BGP_STR + BGP_STR "BGP view\n" "View name\n" "Address family\n") - + DEFUN (show_bgp_view_route, show_bgp_view_route_cmd, "show bgp view WORD X:X::X:X", @@ -6987,10 +6988,10 @@ DEFUN (show_bgp_view_prefix, SHOW_STR BGP_STR "BGP view\n" - "View name\n" + "View name\n" "IPv6 prefix <network>/<length>\n") { - return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); + return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1); } ALIAS (show_bgp_view_prefix, @@ -7001,7 +7002,7 @@ ALIAS (show_bgp_view_prefix, "BGP view\n" "View name\n" "Address family\n" - "IPv6 prefix <network>/<length>\n") + "IPv6 prefix <network>/<length>\n") /* old command */ DEFUN (show_ipv6_mbgp, @@ -7039,7 +7040,7 @@ DEFUN (show_ipv6_mbgp_prefix, return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1); } #endif - + static int bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi, @@ -7051,7 +7052,7 @@ bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi, int first; regex_t *regex; int rc; - + first = 0; b = buffer_new (1024); for (i = 0; i < argc; i++) @@ -7086,7 +7087,7 @@ bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi, return rc; } -DEFUN (show_ip_bgp_regexp, +DEFUN (show_ip_bgp_regexp, show_ip_bgp_regexp_cmd, "show ip bgp regexp .LINE", SHOW_STR @@ -7099,7 +7100,7 @@ DEFUN (show_ip_bgp_regexp, bgp_show_type_regexp); } -DEFUN (show_ip_bgp_flap_regexp, +DEFUN (show_ip_bgp_flap_regexp, show_ip_bgp_flap_regexp_cmd, "show ip bgp flap-statistics regexp .LINE", SHOW_STR @@ -7113,7 +7114,7 @@ DEFUN (show_ip_bgp_flap_regexp, bgp_show_type_flap_regexp); } -DEFUN (show_ip_bgp_ipv4_regexp, +DEFUN (show_ip_bgp_ipv4_regexp, show_ip_bgp_ipv4_regexp_cmd, "show ip bgp ipv4 (unicast|multicast) regexp .LINE", SHOW_STR @@ -7134,7 +7135,7 @@ DEFUN (show_ip_bgp_ipv4_regexp, } #ifdef HAVE_IPV6 -DEFUN (show_bgp_regexp, +DEFUN (show_bgp_regexp, show_bgp_regexp_cmd, "show bgp regexp .LINE", SHOW_STR @@ -7146,7 +7147,7 @@ DEFUN (show_bgp_regexp, bgp_show_type_regexp); } -ALIAS (show_bgp_regexp, +ALIAS (show_bgp_regexp, show_bgp_ipv6_regexp_cmd, "show bgp ipv6 regexp .LINE", SHOW_STR @@ -7156,7 +7157,7 @@ ALIAS (show_bgp_regexp, "A regular-expression to match the BGP AS paths\n") /* old command */ -DEFUN (show_ipv6_bgp_regexp, +DEFUN (show_ipv6_bgp_regexp, show_ipv6_bgp_regexp_cmd, "show ipv6 bgp regexp .LINE", SHOW_STR @@ -7170,7 +7171,7 @@ DEFUN (show_ipv6_bgp_regexp, } /* old command */ -DEFUN (show_ipv6_mbgp_regexp, +DEFUN (show_ipv6_mbgp_regexp, show_ipv6_mbgp_regexp_cmd, "show ipv6 mbgp regexp .LINE", SHOW_STR @@ -7183,7 +7184,7 @@ DEFUN (show_ipv6_mbgp_regexp, bgp_show_type_regexp); } #endif /* HAVE_IPV6 */ - + static int bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi, safi_t safi, enum bgp_show_type type) @@ -7194,14 +7195,14 @@ bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi, if (plist == NULL) { vty_out (vty, "%% %s is not a valid prefix-list name%s", - prefix_list_str, VTY_NEWLINE); + prefix_list_str, VTY_NEWLINE); return CMD_WARNING; } return bgp_show (vty, NULL, afi, safi, type, plist); } -DEFUN (show_ip_bgp_prefix_list, +DEFUN (show_ip_bgp_prefix_list, show_ip_bgp_prefix_list_cmd, "show ip bgp prefix-list WORD", SHOW_STR @@ -7214,7 +7215,7 @@ DEFUN (show_ip_bgp_prefix_list, bgp_show_type_prefix_list); } -DEFUN (show_ip_bgp_flap_prefix_list, +DEFUN (show_ip_bgp_flap_prefix_list, show_ip_bgp_flap_prefix_list_cmd, "show ip bgp flap-statistics prefix-list WORD", SHOW_STR @@ -7228,7 +7229,7 @@ DEFUN (show_ip_bgp_flap_prefix_list, bgp_show_type_flap_prefix_list); } -DEFUN (show_ip_bgp_ipv4_prefix_list, +DEFUN (show_ip_bgp_ipv4_prefix_list, show_ip_bgp_ipv4_prefix_list_cmd, "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", SHOW_STR @@ -7249,7 +7250,7 @@ DEFUN (show_ip_bgp_ipv4_prefix_list, } #ifdef HAVE_IPV6 -DEFUN (show_bgp_prefix_list, +DEFUN (show_bgp_prefix_list, show_bgp_prefix_list_cmd, "show bgp prefix-list WORD", SHOW_STR @@ -7261,7 +7262,7 @@ DEFUN (show_bgp_prefix_list, bgp_show_type_prefix_list); } -ALIAS (show_bgp_prefix_list, +ALIAS (show_bgp_prefix_list, show_bgp_ipv6_prefix_list_cmd, "show bgp ipv6 prefix-list WORD", SHOW_STR @@ -7271,7 +7272,7 @@ ALIAS (show_bgp_prefix_list, "IPv6 prefix-list name\n") /* old command */ -DEFUN (show_ipv6_bgp_prefix_list, +DEFUN (show_ipv6_bgp_prefix_list, show_ipv6_bgp_prefix_list_cmd, "show ipv6 bgp prefix-list WORD", SHOW_STR @@ -7285,7 +7286,7 @@ DEFUN (show_ipv6_bgp_prefix_list, } /* old command */ -DEFUN (show_ipv6_mbgp_prefix_list, +DEFUN (show_ipv6_mbgp_prefix_list, show_ipv6_mbgp_prefix_list_cmd, "show ipv6 mbgp prefix-list WORD", SHOW_STR @@ -7298,7 +7299,7 @@ DEFUN (show_ipv6_mbgp_prefix_list, bgp_show_type_prefix_list); } #endif /* HAVE_IPV6 */ - + static int bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, safi_t safi, enum bgp_show_type type) @@ -7308,14 +7309,14 @@ bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi, as_list = as_list_lookup (filter); if (as_list == NULL) { - vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); + vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE); return CMD_WARNING; } return bgp_show (vty, NULL, afi, safi, type, as_list); } -DEFUN (show_ip_bgp_filter_list, +DEFUN (show_ip_bgp_filter_list, show_ip_bgp_filter_list_cmd, "show ip bgp filter-list WORD", SHOW_STR @@ -7328,7 +7329,7 @@ DEFUN (show_ip_bgp_filter_list, bgp_show_type_filter_list); } -DEFUN (show_ip_bgp_flap_filter_list, +DEFUN (show_ip_bgp_flap_filter_list, show_ip_bgp_flap_filter_list_cmd, "show ip bgp flap-statistics filter-list WORD", SHOW_STR @@ -7342,7 +7343,7 @@ DEFUN (show_ip_bgp_flap_filter_list, bgp_show_type_flap_filter_list); } -DEFUN (show_ip_bgp_ipv4_filter_list, +DEFUN (show_ip_bgp_ipv4_filter_list, show_ip_bgp_ipv4_filter_list_cmd, "show ip bgp ipv4 (unicast|multicast) filter-list WORD", SHOW_STR @@ -7357,13 +7358,13 @@ DEFUN (show_ip_bgp_ipv4_filter_list, if (strncmp (argv[0], "m", 1) == 0) return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST, bgp_show_type_filter_list); - + return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST, bgp_show_type_filter_list); } #ifdef HAVE_IPV6 -DEFUN (show_bgp_filter_list, +DEFUN (show_bgp_filter_list, show_bgp_filter_list_cmd, "show bgp filter-list WORD", SHOW_STR @@ -7375,7 +7376,7 @@ DEFUN (show_bgp_filter_list, bgp_show_type_filter_list); } -ALIAS (show_bgp_filter_list, +ALIAS (show_bgp_filter_list, show_bgp_ipv6_filter_list_cmd, "show bgp ipv6 filter-list WORD", SHOW_STR @@ -7385,7 +7386,7 @@ ALIAS (show_bgp_filter_list, "Regular expression access list name\n") /* old command */ -DEFUN (show_ipv6_bgp_filter_list, +DEFUN (show_ipv6_bgp_filter_list, show_ipv6_bgp_filter_list_cmd, "show ipv6 bgp filter-list WORD", SHOW_STR @@ -7399,7 +7400,7 @@ DEFUN (show_ipv6_bgp_filter_list, } /* old command */ -DEFUN (show_ipv6_mbgp_filter_list, +DEFUN (show_ipv6_mbgp_filter_list, show_ipv6_mbgp_filter_list_cmd, "show ipv6 mbgp filter-list WORD", SHOW_STR @@ -7412,7 +7413,7 @@ DEFUN (show_ipv6_mbgp_filter_list, bgp_show_type_filter_list); } #endif /* HAVE_IPV6 */ - + static int bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi, safi_t safi, enum bgp_show_type type) @@ -7423,14 +7424,14 @@ bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi, if (! rmap) { vty_out (vty, "%% %s is not a valid route-map name%s", - rmap_str, VTY_NEWLINE); + rmap_str, VTY_NEWLINE); return CMD_WARNING; } return bgp_show (vty, NULL, afi, safi, type, rmap); } -DEFUN (show_ip_bgp_route_map, +DEFUN (show_ip_bgp_route_map, show_ip_bgp_route_map_cmd, "show ip bgp route-map WORD", SHOW_STR @@ -7443,7 +7444,7 @@ DEFUN (show_ip_bgp_route_map, bgp_show_type_route_map); } -DEFUN (show_ip_bgp_flap_route_map, +DEFUN (show_ip_bgp_flap_route_map, show_ip_bgp_flap_route_map_cmd, "show ip bgp flap-statistics route-map WORD", SHOW_STR @@ -7457,7 +7458,7 @@ DEFUN (show_ip_bgp_flap_route_map, bgp_show_type_flap_route_map); } -DEFUN (show_ip_bgp_ipv4_route_map, +DEFUN (show_ip_bgp_ipv4_route_map, show_ip_bgp_ipv4_route_map_cmd, "show ip bgp ipv4 (unicast|multicast) route-map WORD", SHOW_STR @@ -7477,7 +7478,7 @@ DEFUN (show_ip_bgp_ipv4_route_map, bgp_show_type_route_map); } -DEFUN (show_bgp_route_map, +DEFUN (show_bgp_route_map, show_bgp_route_map_cmd, "show bgp route-map WORD", SHOW_STR @@ -7489,7 +7490,7 @@ DEFUN (show_bgp_route_map, bgp_show_type_route_map); } -ALIAS (show_bgp_route_map, +ALIAS (show_bgp_route_map, show_bgp_ipv6_route_map_cmd, "show bgp ipv6 route-map WORD", SHOW_STR @@ -7497,7 +7498,7 @@ ALIAS (show_bgp_route_map, "Address family\n" "Display routes matching the route-map\n" "A route-map to match on\n") - + DEFUN (show_ip_bgp_cidr_only, show_ip_bgp_cidr_only_cmd, "show ip bgp cidr-only", @@ -7541,7 +7542,7 @@ DEFUN (show_ip_bgp_ipv4_cidr_only, return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_cidr_only, NULL); } - + DEFUN (show_ip_bgp_community_all, show_ip_bgp_community_all_cmd, "show ip bgp community", @@ -7568,7 +7569,7 @@ DEFUN (show_ip_bgp_ipv4_community_all, if (strncmp (argv[0], "m", 1) == 0) return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_community_all, NULL); - + return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_community_all, NULL); } @@ -7619,7 +7620,7 @@ DEFUN (show_ipv6_mbgp_community_all, bgp_show_type_community_all, NULL); } #endif /* HAVE_IPV6 */ - + static int bgp_show_community (struct vty *vty, int argc, const char **argv, int exact, u_int16_t afi, u_char safi) @@ -7641,7 +7642,7 @@ bgp_show_community (struct vty *vty, int argc, const char **argv, int exact, continue; first = 1; } - + buffer_putstr (b, argv[i]); } buffer_putc (b, '\0'); @@ -7692,7 +7693,7 @@ ALIAS (show_ip_bgp_community, "Do not send outside local AS (well-known community)\n" "Do not advertise to any peer (well-known community)\n" "Do not export to next AS (well-known community)\n") - + ALIAS (show_ip_bgp_community, show_ip_bgp_community3_cmd, "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", @@ -7712,7 +7713,7 @@ ALIAS (show_ip_bgp_community, "Do not send outside local AS (well-known community)\n" "Do not advertise to any peer (well-known community)\n" "Do not export to next AS (well-known community)\n") - + ALIAS (show_ip_bgp_community, show_ip_bgp_community4_cmd, "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", @@ -7754,7 +7755,7 @@ DEFUN (show_ip_bgp_ipv4_community, { if (strncmp (argv[0], "m", 1) == 0) return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_MULTICAST); - + return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST); } @@ -7776,7 +7777,7 @@ ALIAS (show_ip_bgp_ipv4_community, "Do not send outside local AS (well-known community)\n" "Do not advertise to any peer (well-known community)\n" "Do not export to next AS (well-known community)\n") - + ALIAS (show_ip_bgp_ipv4_community, show_ip_bgp_ipv4_community3_cmd, "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", @@ -7799,7 +7800,7 @@ ALIAS (show_ip_bgp_ipv4_community, "Do not send outside local AS (well-known community)\n" "Do not advertise to any peer (well-known community)\n" "Do not export to next AS (well-known community)\n") - + ALIAS (show_ip_bgp_ipv4_community, show_ip_bgp_ipv4_community4_cmd, "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", @@ -7924,7 +7925,7 @@ DEFUN (show_ip_bgp_ipv4_community_exact, { if (strncmp (argv[0], "m", 1) == 0) return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_MULTICAST); - + return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST); } @@ -7971,7 +7972,7 @@ ALIAS (show_ip_bgp_ipv4_community_exact, "Do not advertise to any peer (well-known community)\n" "Do not export to next AS (well-known community)\n" "Exact match of the communities") - + ALIAS (show_ip_bgp_ipv4_community_exact, show_ip_bgp_ipv4_community4_exact_cmd, "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", @@ -8057,7 +8058,7 @@ ALIAS (show_bgp_community, "Do not send outside local AS (well-known community)\n" "Do not advertise to any peer (well-known community)\n" "Do not export to next AS (well-known community)\n") - + ALIAS (show_bgp_community, show_bgp_community3_cmd, "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", @@ -8348,7 +8349,7 @@ ALIAS (show_bgp_community_exact, "Do not advertise to any peer (well-known community)\n" "Do not export to next AS (well-known community)\n" "Exact match of the communities") - + ALIAS (show_bgp_community_exact, show_bgp_ipv6_community4_exact_cmd, "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", @@ -8456,7 +8457,7 @@ ALIAS (show_ipv6_bgp_community_exact, "Do not advertise to any peer (well-known community)\n" "Do not export to next AS (well-known community)\n" "Exact match of the communities") - + /* old command */ DEFUN (show_ipv6_mbgp_community, show_ipv6_mbgp_community_cmd, @@ -8619,7 +8620,7 @@ ALIAS (show_ipv6_mbgp_community_exact, "Do not export to next AS (well-known community)\n" "Exact match of the communities") #endif /* HAVE_IPV6 */ - + static int bgp_show_community_list (struct vty *vty, const char *com, int exact, u_int16_t afi, u_char safi) @@ -8667,7 +8668,7 @@ DEFUN (show_ip_bgp_ipv4_community_list, { if (strncmp (argv[0], "m", 1) == 0) return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST); - + return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST); } @@ -8701,7 +8702,7 @@ DEFUN (show_ip_bgp_ipv4_community_list_exact, { if (strncmp (argv[0], "m", 1) == 0) return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST); - + return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST); } @@ -8806,7 +8807,7 @@ DEFUN (show_ipv6_mbgp_community_list_exact, return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST); } #endif /* HAVE_IPV6 */ - + static int bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi, safi_t safi, enum bgp_show_type type) @@ -8952,7 +8953,7 @@ DEFUN (show_ipv6_mbgp_prefix_longer, #endif /* HAVE_IPV6 */ static struct peer * -peer_lookup_in_view (struct vty *vty, const char *view_name, +peer_lookup_in_view (struct vty *vty, const char *view_name, const char *ip_str) { int ret; @@ -8968,7 +8969,7 @@ peer_lookup_in_view (struct vty *vty, const char *view_name, { vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE); return NULL; - } + } } else { @@ -8980,7 +8981,7 @@ peer_lookup_in_view (struct vty *vty, const char *view_name, } } - /* Get peer sockunion. */ + /* Get peer sockunion. */ ret = str2sockunion (ip_str, &su); if (ret < 0) { @@ -8995,10 +8996,10 @@ peer_lookup_in_view (struct vty *vty, const char *view_name, vty_out (vty, "No such neighbor%s", VTY_NEWLINE); return NULL; } - + return peer; } - + enum bgp_stats { BGP_STATS_MAXBITLEN = 0, @@ -9050,7 +9051,7 @@ ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); unsigned long res = (newtot * TALLY_SIGFIG) / count; unsigned long ret = newtot / count; - + if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) return ret + 1; else @@ -9065,7 +9066,7 @@ bgp_table_stats_walker (struct thread *t) 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; @@ -9078,7 +9079,7 @@ bgp_table_stats_walker (struct thread *t) space = IPV6_MAX_BITLEN; break; } - + ts->counts[BGP_STATS_MAXBITLEN] = space; for (rn = top; rn; rn = bgp_route_next (rn)) @@ -9086,13 +9087,13 @@ bgp_table_stats_walker (struct thread *t) struct bgp_info *ri; struct bgp_node *prn = rn->parent; unsigned int rinum = 0; - + if (rn == top) continue; - + if (!rn->info) continue; - + ts->counts[BGP_STATS_PREFIXES]++; ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen; @@ -9102,11 +9103,11 @@ bgp_table_stats_walker (struct thread *t) ts->counts[BGP_STATS_AVGPLEN], rn->p.prefixlen); #endif - + /* check if the prefix is included by any other announcements */ while (prn && !prn->info) prn = prn->parent; - + if (prn == NULL || prn == top) { ts->counts[BGP_STATS_UNAGGREGATEABLE]++; @@ -9116,36 +9117,36 @@ bgp_table_stats_walker (struct thread *t) } else if (prn->info) ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; - + for (ri = rn->info; ri; ri = ri->next) { rinum++; ts->counts[BGP_STATS_RIB]++; - + if (ri->attr && (CHECK_FLAG (ri->attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))) ts->counts[BGP_STATS_AGGREGATES]++; - + /* as-path stats */ if (ri->attr && ri->attr->aspath) { unsigned int hops = aspath_count_hops (ri->attr->aspath); unsigned int size = aspath_size (ri->attr->aspath); as_t highest = aspath_highest (ri->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] + ts->counts[BGP_STATS_ASPATH_AVGHOPS] = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], ts->counts[BGP_STATS_ASPATH_AVGHOPS], hops); @@ -9167,25 +9168,25 @@ bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) { struct bgp_table_stats ts; unsigned int i; - + if (!bgp->rib[afi][safi]) { vty_out (vty, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE); return CMD_WARNING; } - + memset (&ts, 0, sizeof (ts)); ts.table = bgp->rib[afi][safi]; thread_execute (bm->master, bgp_table_stats_walker, &ts, 0); vty_out (vty, "BGP %s RIB statistics%s%s", afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE); - + for (i = 0; i < BGP_STATS_MAX; i++) { if (!table_stats_strs[i]) continue; - + switch (i) { #if 0 @@ -9202,7 +9203,7 @@ bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) vty_out (vty, "%-30s: ", table_stats_strs[i]); vty_out (vty, "%12.2f", ts.counts[i] ? - (float)ts.counts[i] / + (float)ts.counts[i] / (float)ts.counts[BGP_STATS_ASPATH_COUNT] : 0); break; @@ -9210,7 +9211,7 @@ bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) vty_out (vty, "%-30s: ", table_stats_strs[i]); vty_out (vty, "%12.2f", ts.counts[i] ? - (float)ts.counts[i] / + (float)ts.counts[i] / (float)ts.counts[BGP_STATS_PREFIXES] : 0); break; @@ -9220,27 +9221,27 @@ bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) if (ts.counts[BGP_STATS_MAXBITLEN] < 9) break; vty_out (vty, "%30s: ", "%% announced "); - vty_out (vty, "%12.2f%s", - 100 * (float)ts.counts[BGP_STATS_SPACE] / + vty_out (vty, "%12.2f%s", + 100 * (float)ts.counts[BGP_STATS_SPACE] / (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), VTY_NEWLINE); vty_out (vty, "%30s: ", "/8 equivalent "); - vty_out (vty, "%12.2f%s", - (float)ts.counts[BGP_STATS_SPACE] / + vty_out (vty, "%12.2f%s", + (float)ts.counts[BGP_STATS_SPACE] / (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)), VTY_NEWLINE); if (ts.counts[BGP_STATS_MAXBITLEN] < 25) break; vty_out (vty, "%30s: ", "/24 equivalent "); - vty_out (vty, "%12.2f", - (float)ts.counts[BGP_STATS_SPACE] / + vty_out (vty, "%12.2f", + (float)ts.counts[BGP_STATS_SPACE] / (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24))); break; default: vty_out (vty, "%-30s: ", table_stats_strs[i]); vty_out (vty, "%12llu", ts.counts[i]); } - + vty_out (vty, "%s", VTY_NEWLINE); } return CMD_SUCCESS; @@ -9253,7 +9254,7 @@ bgp_table_stats_vty (struct vty *vty, const char *name, struct bgp *bgp; afi_t afi; safi_t safi; - + if (name) bgp = bgp_lookup_by_name (name); else @@ -9355,7 +9356,7 @@ ALIAS (show_bgp_statistics_view, "Address family\n" "Address Family modifier\n" "BGP RIB advertisement statistics\n") - + enum bgp_pcounts { PCOUNT_ADJ_IN = 0, @@ -9397,12 +9398,12 @@ bgp_peer_count_walker (struct thread *t) struct bgp_node *rn; struct peer_pcounts *pc = THREAD_ARG (t); const struct peer *peer = pc->peer; - + for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn)) { struct bgp_adj_in *ain; struct bgp_info *ri; - + for (ain = rn->adj_in; ain; ain = ain->next) if (ain->peer == peer) pc->count[PCOUNT_ADJ_IN]++; @@ -9410,12 +9411,12 @@ bgp_peer_count_walker (struct thread *t) for (ri = rn->info; ri; ri = ri->next) { char buf[SU_ADDRSTRLEN]; - + if (ri->peer != peer) continue; - + pc->count[PCOUNT_ALL]++; - + if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)) pc->count[PCOUNT_DAMPED]++; if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)) @@ -9428,7 +9429,7 @@ bgp_peer_count_walker (struct thread *t) pc->count[PCOUNT_VALID]++; if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE)) pc->count[PCOUNT_PFCNT]++; - + if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED)) { pc->count[PCOUNT_COUNTED]++; @@ -9462,28 +9463,28 @@ bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) { struct peer_pcounts pcounts = { .peer = peer }; unsigned int i; - + if (!peer || !peer->bgp || !peer->afc[afi][safi] || !peer->bgp->rib[afi][safi]) { vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); return CMD_WARNING; } - + memset (&pcounts, 0, sizeof(pcounts)); pcounts.peer = peer; pcounts.table = peer->bgp->rib[afi][safi]; - + /* in-place call via thread subsystem so as to record execution time * stats for the thread-walk (i.e. ensure this can't be blamed on * on just vty_read()). */ thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0); - - vty_out (vty, "Prefix counts for %s, %s%s", + + vty_out (vty, "Prefix counts for %s, %s%s", peer->host, afi_safi_print (afi, safi), VTY_NEWLINE); vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE); - vty_out (vty, "%sCounts from RIB table walk:%s%s", + vty_out (vty, "%sCounts from RIB table walk:%s%s", VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); for (i = 0; i < PCOUNT_MAX; i++) @@ -9497,7 +9498,7 @@ bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi) vty_out (vty, "Please report this bug, with the above command output%s", VTY_NEWLINE); } - + return CMD_SUCCESS; } @@ -9514,10 +9515,10 @@ DEFUN (show_ip_bgp_neighbor_prefix_counts, { struct peer *peer; - peer = peer_lookup_in_view (vty, NULL, argv[0]); - if (! peer) + peer = peer_lookup_in_view (vty, NULL, argv[0]); + if (! peer) return CMD_WARNING; - + return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST); } @@ -9534,10 +9535,10 @@ DEFUN (show_bgp_ipv6_neighbor_prefix_counts, { struct peer *peer; - peer = peer_lookup_in_view (vty, NULL, argv[0]); - if (! peer) + peer = peer_lookup_in_view (vty, NULL, argv[0]); + if (! peer) return CMD_WARNING; - + return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST); } @@ -9586,7 +9587,7 @@ DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, peer = peer_lookup_in_view (vty, NULL, argv[0]); if (! peer) return CMD_WARNING; - + return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN); } @@ -9612,7 +9613,7 @@ show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, table = bgp->rib[afi][safi]; output_count = 0; - + if (! in && CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE)) { @@ -9644,7 +9645,7 @@ show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, header2 = 0; } if (ain->attr) - { + { route_vty_out_tmp (vty, &rn->p, ain->attr, safi); output_count++; } @@ -9668,13 +9669,13 @@ show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, header2 = 0; } if (adj->attr) - { + { route_vty_out_tmp (vty, &rn->p, adj->attr, safi); output_count++; } } } - + if (output_count != 0) vty_out (vty, "%sTotal number of prefixes %ld%s", VTY_NEWLINE, output_count, VTY_NEWLINE); @@ -9682,7 +9683,7 @@ show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, static int peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in) -{ +{ if (! peer || ! peer->afc[afi][safi]) { vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); @@ -9721,9 +9722,9 @@ DEFUN (show_ip_bgp_view_neighbor_advertised_route, else peer = peer_lookup_in_view (vty, NULL, argv[0]); - if (! peer) + if (! peer) return CMD_WARNING; - + return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0); } @@ -9785,7 +9786,7 @@ DEFUN (show_bgp_view_neighbor_advertised_route, peer = peer_lookup_in_view (vty, NULL, argv[0]); if (! peer) - return CMD_WARNING; + return CMD_WARNING; return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0); } @@ -9850,7 +9851,7 @@ ALIAS (show_bgp_view_neighbor_advertised_route, "Neighbor to display information about\n" "Neighbor to display information about\n" "Display the routes advertised to a BGP neighbor\n") - + ALIAS (show_bgp_view_neighbor_advertised_route, show_bgp_ipv6_neighbor_advertised_route_cmd, "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes", @@ -9873,7 +9874,7 @@ ALIAS (show_bgp_view_neighbor_advertised_route, "Neighbor to display information about\n" "Neighbor to display information about\n" "Display the routes advertised to a BGP neighbor\n") - + /* old command */ DEFUN (ipv6_mbgp_neighbor_advertised_route, ipv6_mbgp_neighbor_advertised_route_cmd, @@ -9890,12 +9891,12 @@ DEFUN (ipv6_mbgp_neighbor_advertised_route, peer = peer_lookup_in_view (vty, NULL, argv[0]); if (! peer) - return CMD_WARNING; + return CMD_WARNING; return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0); } #endif /* HAVE_IPV6 */ - + DEFUN (show_ip_bgp_view_neighbor_received_routes, show_ip_bgp_view_neighbor_received_routes_cmd, "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes", @@ -9952,7 +9953,7 @@ DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, peer = peer_lookup_in_view (vty, NULL, argv[1]); if (! peer) return CMD_WARNING; - + if (strncmp (argv[0], "m", 1) == 0) return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1); @@ -10033,7 +10034,7 @@ DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, prefix_bgp_show_prefix_list (vty, AFI_IP, name); } } - else + else { sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name); @@ -10172,11 +10173,11 @@ DEFUN (show_bgp_view_neighbor_received_prefix_filter, /* BGP structure lookup. */ bgp = bgp_lookup_by_name (argv[0]); if (bgp == NULL) - { + { vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE); return CMD_WARNING; } - + su = sockunion_str2su (argv[1]); if (su == NULL) return CMD_WARNING; @@ -10210,7 +10211,7 @@ ALIAS (show_bgp_view_neighbor_received_prefix_filter, "Display information received from a BGP neighbor\n" "Display the prefixlist filter\n") #endif /* HAVE_IPV6 */ - + static int bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, enum bgp_show_type type) @@ -10220,7 +10221,7 @@ bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi, vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); return CMD_WARNING; } - + return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su); } @@ -10240,7 +10241,7 @@ DEFUN (show_ip_bgp_neighbor_routes, peer = peer_lookup_in_view (vty, NULL, argv[0]); if (! peer) return CMD_WARNING; - + return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, bgp_show_type_neighbor); } @@ -10261,7 +10262,7 @@ DEFUN (show_ip_bgp_neighbor_flap, peer = peer_lookup_in_view (vty, NULL, argv[0]); if (! peer) return CMD_WARNING; - + return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, bgp_show_type_flap_neighbor); } @@ -10282,7 +10283,7 @@ DEFUN (show_ip_bgp_neighbor_damp, peer = peer_lookup_in_view (vty, NULL, argv[0]); if (! peer) return CMD_WARNING; - + return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, bgp_show_type_damp_neighbor); } @@ -10306,7 +10307,7 @@ DEFUN (show_ip_bgp_ipv4_neighbor_routes, peer = peer_lookup_in_view (vty, NULL, argv[1]); if (! peer) return CMD_WARNING; - + if (strncmp (argv[0], "m", 1) == 0) return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, bgp_show_type_neighbor); @@ -10423,8 +10424,8 @@ DEFUN (show_ip_bgp_view_rsclient_route, VTY_NEWLINE); return CMD_WARNING; } - - return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], + + return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], (argc == 3) ? argv[2] : argv[1], AFI_IP, SAFI_UNICAST, NULL, 0); } @@ -10481,7 +10482,7 @@ DEFUN (show_ip_bgp_view_rsclient_prefix, if (! peer) return CMD_WARNING; - + if (! peer->afc[AFI_IP][SAFI_UNICAST]) { vty_out (vty, "%% Activate the neighbor for the address family first%s", @@ -10496,8 +10497,8 @@ DEFUN (show_ip_bgp_view_rsclient_prefix, VTY_NEWLINE); return CMD_WARNING; } - - return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], + + return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST], (argc == 3) ? argv[2] : argv[1], AFI_IP, SAFI_UNICAST, NULL, 1); } @@ -10532,7 +10533,7 @@ DEFUN (show_bgp_view_neighbor_routes, peer = peer_lookup_in_view (vty, argv[0], argv[1]); else peer = peer_lookup_in_view (vty, NULL, argv[0]); - + if (! peer) return CMD_WARNING; @@ -10630,7 +10631,7 @@ ALIAS (show_bgp_view_neighbor_flap, "Neighbor to display information about\n" "Neighbor to display information about\n" "Display flap statistics of the routes learned from neighbor\n") - + ALIAS (show_bgp_view_neighbor_routes, show_bgp_neighbor_routes_cmd, "show bgp neighbors (A.B.C.D|X:X::X:X) routes", @@ -10682,7 +10683,7 @@ DEFUN (ipv6_mbgp_neighbor_routes, peer = peer_lookup_in_view (vty, NULL, argv[0]); if (! peer) return CMD_WARNING; - + return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST, bgp_show_type_neighbor); } @@ -10921,7 +10922,7 @@ ALIAS (show_bgp_view_rsclient_prefix, "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n") #endif /* HAVE_IPV6 */ - + struct bgp_table *bgp_distance_table; struct bgp_distance @@ -10946,7 +10947,7 @@ bgp_distance_free (struct bgp_distance *bdistance) } static int -bgp_distance_set (struct vty *vty, const char *distance_str, +bgp_distance_set (struct vty *vty, const char *distance_str, const char *ip_str, const char *access_list_str) { int ret; @@ -10993,7 +10994,7 @@ bgp_distance_set (struct vty *vty, const char *distance_str, } static int -bgp_distance_unset (struct vty *vty, const char *distance_str, +bgp_distance_unset (struct vty *vty, const char *distance_str, const char *ip_str, const char *access_list_str) { int ret; @@ -11198,7 +11199,7 @@ DEFUN (no_bgp_distance_source_access_list, bgp_distance_unset (vty, argv[0], argv[1], argv[2]); return CMD_SUCCESS; } - + DEFUN (bgp_damp_set, bgp_damp_set_cmd, "bgp dampening <1-45> <1-20000> <1-20000> <1-255>", @@ -11293,11 +11294,11 @@ DEFUN (show_ip_bgp_flap_statistics, return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_flap_statistics, NULL); } - + /* Display specified route of BGP table. */ static int -bgp_clear_damp_route (struct vty *vty, const char *view_name, - const char *ip_str, afi_t afi, safi_t safi, +bgp_clear_damp_route (struct vty *vty, const char *view_name, + const char *ip_str, afi_t afi, safi_t safi, struct prefix_rd *prd, int prefix_check) { int ret; @@ -11449,7 +11450,7 @@ DEFUN (clear_ip_bgp_dampening_address_mask, return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 0); } - + static int bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, int *write) @@ -11463,11 +11464,11 @@ bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, u_int32_t label; char buf[SU_ADDRSTRLEN]; char rdbuf[RD_ADDRSTRLEN]; - + /* Network configuration. */ for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn)) if ((table = prn->info) != NULL) - for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) + for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) if ((bgp_static = rn->info) != NULL) { p = &rn->p; @@ -11481,7 +11482,7 @@ bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, label = decode_label (bgp_static->tag); vty_out (vty, " network %s/%d rd %s tag %d", - inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), + inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), p->prefixlen, rdbuf, label); vty_out (vty, "%s", VTY_NEWLINE); @@ -11500,12 +11501,12 @@ bgp_config_write_network (struct vty *vty, struct bgp *bgp, struct bgp_static *bgp_static; struct bgp_aggregate *bgp_aggregate; char buf[SU_ADDRSTRLEN]; - + if (afi == AFI_IP && safi == SAFI_MPLS_VPN) return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); /* Network configuration. */ - for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) + for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) if ((bgp_static = rn->info) != NULL) { p = &rn->p; @@ -11516,7 +11517,7 @@ bgp_config_write_network (struct vty *vty, struct bgp *bgp, /* "network" configuration display. */ if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) { - u_int32_t destination; + u_int32_t destination; struct in_addr netmask; destination = ntohl (p->u.prefix4.s_addr); @@ -11537,13 +11538,13 @@ bgp_config_write_network (struct vty *vty, struct bgp *bgp, else { vty_out (vty, " network %s/%d", - inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), + inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), p->prefixlen); } if (bgp_static->rmap.name) vty_out (vty, " route-map %s", bgp_static->rmap.name); - else + else { if (bgp_static->backdoor) vty_out (vty, " backdoor"); @@ -11581,7 +11582,7 @@ bgp_config_write_network (struct vty *vty, struct bgp *bgp, if (bgp_aggregate->as_set) vty_out (vty, " as-set"); - + if (bgp_aggregate->summary_only) vty_out (vty, " summary-only"); @@ -11607,7 +11608,7 @@ bgp_config_write_distance (struct vty *vty, struct bgp *bgp) vty_out (vty, " distance bgp %d %d %d%s", bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local, VTY_NEWLINE); - + for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn)) if ((bdistance = rn->info) != NULL) { @@ -11846,7 +11847,7 @@ bgp_route_init (void) install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd); install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd); install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd); - + /* Restricted node: VIEW_NODE - (set of dangerous commands) */ install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd); install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd); @@ -12059,13 +12060,13 @@ bgp_route_init (void) install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd); install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd); install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd); - install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); + install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd); install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd); install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd); install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd); - + /* Restricted: - * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) + * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev) */ install_element (RESTRICTED_NODE, &show_bgp_route_cmd); install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd); @@ -12172,13 +12173,13 @@ bgp_route_init (void) install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd); install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd); install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd); - + /* Statistics */ install_element (ENABLE_NODE, &show_bgp_statistics_cmd); install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd); install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd); - + /* old command */ install_element (VIEW_NODE, &show_ipv6_bgp_cmd); install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd); @@ -12216,7 +12217,7 @@ bgp_route_init (void) install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd); install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd); install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd); - + /* old command */ install_element (ENABLE_NODE, &show_ipv6_bgp_cmd); install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd); |