1 /* BGP routing information
2 Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro
4 This file is part of GNU Zebra.
6 GNU Zebra is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 GNU Zebra is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Zebra; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
33 #include "sockunion.h"
36 #include "workqueue.h"
38 #include "bgpd/bgpd.h"
39 #include "bgpd/bgp_table.h"
40 #include "bgpd/bgp_route.h"
41 #include "bgpd/bgp_attr.h"
42 #include "bgpd/bgp_debug.h"
43 #include "bgpd/bgp_aspath.h"
44 #include "bgpd/bgp_regex.h"
45 #include "bgpd/bgp_community.h"
46 #include "bgpd/bgp_ecommunity.h"
47 #include "bgpd/bgp_clist.h"
48 #include "bgpd/bgp_packet.h"
49 #include "bgpd/bgp_filter.h"
50 #include "bgpd/bgp_fsm.h"
51 #include "bgpd/bgp_mplsvpn.h"
52 #include "bgpd/bgp_nexthop.h"
53 #include "bgpd/bgp_damp.h"
54 #include "bgpd/bgp_advertise.h"
55 #include "bgpd/bgp_zebra.h"
56 #include "bgpd/bgp_vty.h"
58 /* Extern from bgp_dump.c */
59 extern char *bgp_origin_str
[];
60 extern char *bgp_origin_long_str
[];
62 static struct bgp_node
*
63 bgp_afi_node_get (struct bgp_table
*table
, afi_t afi
, safi_t safi
, struct prefix
*p
,
64 struct prefix_rd
*prd
)
67 struct bgp_node
*prn
= NULL
;
73 if (safi
== SAFI_MPLS_VPN
)
75 prn
= bgp_node_get (table
, (struct prefix
*) prd
);
77 if (prn
->info
== NULL
)
78 prn
->info
= bgp_table_init (afi
, safi
);
80 bgp_unlock_node (prn
);
84 rn
= bgp_node_get (table
, p
);
86 if (safi
== SAFI_MPLS_VPN
)
92 /* Allocate new bgp info structure. */
93 static struct bgp_info
*
98 new = XMALLOC (MTYPE_BGP_ROUTE
, sizeof (struct bgp_info
));
99 memset (new, 0, sizeof (struct bgp_info
));
104 /* Free bgp route information. */
106 bgp_info_free (struct bgp_info
*binfo
)
109 bgp_attr_unintern (binfo
->attr
);
111 if (binfo
->damp_info
)
112 bgp_damp_info_free (binfo
->damp_info
, 0);
114 peer_unlock (binfo
->peer
); /* bgp_info peer reference */
116 XFREE (MTYPE_BGP_ROUTE
, binfo
);
120 bgp_info_lock (struct bgp_info
*binfo
)
127 bgp_info_unlock (struct bgp_info
*binfo
)
129 assert (binfo
&& binfo
->lock
> 0);
132 if (binfo
->lock
== 0)
135 zlog_debug ("%s: unlocked and freeing", __func__
);
136 zlog_backtrace (LOG_DEBUG
);
138 bgp_info_free (binfo
);
143 if (binfo
->lock
== 1)
145 zlog_debug ("%s: unlocked to 1", __func__
);
146 zlog_backtrace (LOG_DEBUG
);
154 bgp_info_add (struct bgp_node
*rn
, struct bgp_info
*ri
)
156 struct bgp_info
*top
;
168 peer_lock (ri
->peer
); /* bgp_info peer reference */
171 /* Do the actual removal of info from RIB, for use by bgp_process
172 completion callback *only* */
174 bgp_info_reap (struct bgp_node
*rn
, struct bgp_info
*ri
)
177 ri
->next
->prev
= ri
->prev
;
179 ri
->prev
->next
= ri
->next
;
183 bgp_info_unlock (ri
);
184 bgp_unlock_node (rn
);
188 bgp_info_delete (struct bgp_node
*rn
, struct bgp_info
*ri
)
190 bgp_info_set_flag (rn
, ri
, BGP_INFO_REMOVED
);
191 /* set of previous already took care of pcount */
192 UNSET_FLAG (ri
->flags
, BGP_INFO_VALID
);
195 /* undo the effects of a previous call to bgp_info_delete; typically
196 called when a route is deleted and then quickly re-added before the
197 deletion has been processed */
199 bgp_info_restore (struct bgp_node
*rn
, struct bgp_info
*ri
)
201 bgp_info_unset_flag (rn
, ri
, BGP_INFO_REMOVED
);
202 /* unset of previous already took care of pcount */
203 SET_FLAG (ri
->flags
, BGP_INFO_VALID
);
206 /* Adjust pcount as required */
208 bgp_pcount_adjust (struct bgp_node
*rn
, struct bgp_info
*ri
)
210 assert (rn
&& rn
->table
);
211 assert (ri
&& ri
->peer
&& ri
->peer
->bgp
);
213 /* Ignore 'pcount' for RS-client tables */
214 if (rn
->table
->type
!= BGP_TABLE_MAIN
215 || ri
->peer
== ri
->peer
->bgp
->peer_self
)
218 if (BGP_INFO_HOLDDOWN (ri
)
219 && CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
222 UNSET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
224 /* slight hack, but more robust against errors. */
225 if (ri
->peer
->pcount
[rn
->table
->afi
][rn
->table
->safi
])
226 ri
->peer
->pcount
[rn
->table
->afi
][rn
->table
->safi
]--;
229 zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s",
230 __func__
, ri
->peer
->host
);
231 zlog_backtrace (LOG_WARNING
);
232 zlog_warn ("%s: Please report to Quagga bugzilla", __func__
);
235 else if (!BGP_INFO_HOLDDOWN (ri
)
236 && !CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
238 SET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
239 ri
->peer
->pcount
[rn
->table
->afi
][rn
->table
->safi
]++;
244 /* Set/unset bgp_info flags, adjusting any other state as needed.
245 * This is here primarily to keep prefix-count in check.
248 bgp_info_set_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
250 SET_FLAG (ri
->flags
, flag
);
252 /* early bath if we know it's not a flag that changes useability state */
253 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_UNUSEABLE
))
256 bgp_pcount_adjust (rn
, ri
);
260 bgp_info_unset_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
262 UNSET_FLAG (ri
->flags
, flag
);
264 /* early bath if we know it's not a flag that changes useability state */
265 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_UNUSEABLE
))
268 bgp_pcount_adjust (rn
, ri
);
271 /* Get MED value. If MED value is missing and "bgp bestpath
272 missing-as-worst" is specified, treat it as the worst value. */
274 bgp_med_value (struct attr
*attr
, struct bgp
*bgp
)
276 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
280 if (bgp_flag_check (bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
287 /* Compare two bgp route entity. br is preferable then return 1. */
289 bgp_info_cmp (struct bgp
*bgp
, struct bgp_info
*new, struct bgp_info
*exist
)
292 u_int32_t exist_pref
;
295 struct in_addr new_id
;
296 struct in_addr exist_id
;
299 int internal_as_route
= 0;
300 int confed_as_route
= 0;
309 /* 1. Weight check. */
310 if (new->attr
->weight
> exist
->attr
->weight
)
312 if (new->attr
->weight
< exist
->attr
->weight
)
315 /* 2. Local preference check. */
316 if (new->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
317 new_pref
= new->attr
->local_pref
;
319 new_pref
= bgp
->default_local_pref
;
321 if (exist
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
322 exist_pref
= exist
->attr
->local_pref
;
324 exist_pref
= bgp
->default_local_pref
;
326 if (new_pref
> exist_pref
)
328 if (new_pref
< exist_pref
)
331 /* 3. Local route check. */
332 if (new->sub_type
== BGP_ROUTE_STATIC
)
334 if (exist
->sub_type
== BGP_ROUTE_STATIC
)
337 if (new->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
339 if (exist
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
342 if (new->sub_type
== BGP_ROUTE_AGGREGATE
)
344 if (exist
->sub_type
== BGP_ROUTE_AGGREGATE
)
347 /* 4. AS path length check. */
348 if (! bgp_flag_check (bgp
, BGP_FLAG_ASPATH_IGNORE
))
350 int exist_hops
= aspath_count_hops (exist
->attr
->aspath
);
351 int exist_confeds
= aspath_count_confeds (exist
->attr
->aspath
);
353 if (bgp_flag_check (bgp
, BGP_FLAG_ASPATH_CONFED
))
357 aspath_hops
= aspath_count_hops (new->attr
->aspath
);
358 aspath_hops
+= aspath_count_confeds (new->attr
->aspath
);
360 if ( aspath_hops
< (exist_hops
+ exist_confeds
))
362 if ( aspath_hops
> (exist_hops
+ exist_confeds
))
367 int newhops
= aspath_count_hops (new->attr
->aspath
);
369 if (newhops
< exist_hops
)
371 if (newhops
> exist_hops
)
376 /* 5. Origin check. */
377 if (new->attr
->origin
< exist
->attr
->origin
)
379 if (new->attr
->origin
> exist
->attr
->origin
)
383 internal_as_route
= (aspath_count_hops (new->attr
->aspath
) == 0
384 && aspath_count_hops (exist
->attr
->aspath
) == 0);
385 confed_as_route
= (aspath_count_confeds (new->attr
->aspath
) > 0
386 && aspath_count_confeds (exist
->attr
->aspath
) > 0
387 && aspath_count_hops (new->attr
->aspath
) == 0
388 && aspath_count_hops (exist
->attr
->aspath
) == 0);
390 if (bgp_flag_check (bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
)
391 || (bgp_flag_check (bgp
, BGP_FLAG_MED_CONFED
)
393 || aspath_cmp_left (new->attr
->aspath
, exist
->attr
->aspath
)
394 || aspath_cmp_left_confed (new->attr
->aspath
, exist
->attr
->aspath
)
395 || internal_as_route
)
397 new_med
= bgp_med_value (new->attr
, bgp
);
398 exist_med
= bgp_med_value (exist
->attr
, bgp
);
400 if (new_med
< exist_med
)
402 if (new_med
> exist_med
)
406 /* 7. Peer type check. */
407 if (peer_sort (new->peer
) == BGP_PEER_EBGP
408 && peer_sort (exist
->peer
) == BGP_PEER_IBGP
)
410 if (peer_sort (new->peer
) == BGP_PEER_EBGP
411 && peer_sort (exist
->peer
) == BGP_PEER_CONFED
)
413 if (peer_sort (new->peer
) == BGP_PEER_IBGP
414 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
416 if (peer_sort (new->peer
) == BGP_PEER_CONFED
417 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
420 /* 8. IGP metric check. */
421 if (new->igpmetric
< exist
->igpmetric
)
423 if (new->igpmetric
> exist
->igpmetric
)
426 /* 9. Maximum path check. */
428 /* 10. If both paths are external, prefer the path that was received
429 first (the oldest one). This step minimizes route-flap, since a
430 newer path won't displace an older one, even if it was the
431 preferred route based on the additional decision criteria below. */
432 if (! bgp_flag_check (bgp
, BGP_FLAG_COMPARE_ROUTER_ID
)
433 && peer_sort (new->peer
) == BGP_PEER_EBGP
434 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
436 if (CHECK_FLAG (new->flags
, BGP_INFO_SELECTED
))
438 if (CHECK_FLAG (exist
->flags
, BGP_INFO_SELECTED
))
442 /* 11. Rourter-ID comparision. */
443 if (new->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
444 new_id
.s_addr
= new->attr
->originator_id
.s_addr
;
446 new_id
.s_addr
= new->peer
->remote_id
.s_addr
;
447 if (exist
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
448 exist_id
.s_addr
= exist
->attr
->originator_id
.s_addr
;
450 exist_id
.s_addr
= exist
->peer
->remote_id
.s_addr
;
452 if (ntohl (new_id
.s_addr
) < ntohl (exist_id
.s_addr
))
454 if (ntohl (new_id
.s_addr
) > ntohl (exist_id
.s_addr
))
457 /* 12. Cluster length comparision. */
458 if (new->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
459 new_cluster
= new->attr
->cluster
->length
;
462 if (exist
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
463 exist_cluster
= exist
->attr
->cluster
->length
;
467 if (new_cluster
< exist_cluster
)
469 if (new_cluster
> exist_cluster
)
472 /* 13. Neighbor address comparision. */
473 ret
= sockunion_cmp (new->peer
->su_remote
, exist
->peer
->su_remote
);
483 static enum filter_type
484 bgp_input_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
485 afi_t afi
, safi_t safi
)
487 struct bgp_filter
*filter
;
489 filter
= &peer
->filter
[afi
][safi
];
491 if (DISTRIBUTE_IN_NAME (filter
))
492 if (access_list_apply (DISTRIBUTE_IN (filter
), p
) == FILTER_DENY
)
495 if (PREFIX_LIST_IN_NAME (filter
))
496 if (prefix_list_apply (PREFIX_LIST_IN (filter
), p
) == PREFIX_DENY
)
499 if (FILTER_LIST_IN_NAME (filter
))
500 if (as_list_apply (FILTER_LIST_IN (filter
), attr
->aspath
)== AS_FILTER_DENY
)
503 return FILTER_PERMIT
;
506 static enum filter_type
507 bgp_output_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
508 afi_t afi
, safi_t safi
)
510 struct bgp_filter
*filter
;
512 filter
= &peer
->filter
[afi
][safi
];
514 if (DISTRIBUTE_OUT_NAME (filter
))
515 if (access_list_apply (DISTRIBUTE_OUT (filter
), p
) == FILTER_DENY
)
518 if (PREFIX_LIST_OUT_NAME (filter
))
519 if (prefix_list_apply (PREFIX_LIST_OUT (filter
), p
) == PREFIX_DENY
)
522 if (FILTER_LIST_OUT_NAME (filter
))
523 if (as_list_apply (FILTER_LIST_OUT (filter
), attr
->aspath
) == AS_FILTER_DENY
)
526 return FILTER_PERMIT
;
529 /* If community attribute includes no_export then return 1. */
531 bgp_community_filter (struct peer
*peer
, struct attr
*attr
)
535 /* NO_ADVERTISE check. */
536 if (community_include (attr
->community
, COMMUNITY_NO_ADVERTISE
))
539 /* NO_EXPORT check. */
540 if (peer_sort (peer
) == BGP_PEER_EBGP
&&
541 community_include (attr
->community
, COMMUNITY_NO_EXPORT
))
544 /* NO_EXPORT_SUBCONFED check. */
545 if (peer_sort (peer
) == BGP_PEER_EBGP
546 || peer_sort (peer
) == BGP_PEER_CONFED
)
547 if (community_include (attr
->community
, COMMUNITY_NO_EXPORT_SUBCONFED
))
553 /* Route reflection loop check. */
555 bgp_cluster_filter (struct peer
*peer
, struct attr
*attr
)
557 struct in_addr cluster_id
;
561 if (peer
->bgp
->config
& BGP_CONFIG_CLUSTER_ID
)
562 cluster_id
= peer
->bgp
->cluster_id
;
564 cluster_id
= peer
->bgp
->router_id
;
566 if (cluster_loop_check (attr
->cluster
, cluster_id
))
573 bgp_input_modifier (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
574 afi_t afi
, safi_t safi
)
576 struct bgp_filter
*filter
;
577 struct bgp_info info
;
578 route_map_result_t ret
;
580 filter
= &peer
->filter
[afi
][safi
];
582 /* Apply default weight value. */
583 attr
->weight
= peer
->weight
;
585 /* Route map apply. */
586 if (ROUTE_MAP_IN_NAME (filter
))
588 /* Duplicate current value to new strucutre for modification. */
592 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IN
);
594 /* Apply BGP route map to the attribute. */
595 ret
= route_map_apply (ROUTE_MAP_IN (filter
), p
, RMAP_BGP
, &info
);
599 if (ret
== RMAP_DENYMATCH
)
601 /* Free newly generated AS path and community by route-map. */
602 bgp_attr_flush (attr
);
610 bgp_export_modifier (struct peer
*rsclient
, struct peer
*peer
,
611 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
613 struct bgp_filter
*filter
;
614 struct bgp_info info
;
615 route_map_result_t ret
;
617 filter
= &peer
->filter
[afi
][safi
];
619 /* Route map apply. */
620 if (ROUTE_MAP_EXPORT_NAME (filter
))
622 /* Duplicate current value to new strucutre for modification. */
623 info
.peer
= rsclient
;
626 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_EXPORT
);
628 /* Apply BGP route map to the attribute. */
629 ret
= route_map_apply (ROUTE_MAP_EXPORT (filter
), p
, RMAP_BGP
, &info
);
631 rsclient
->rmap_type
= 0;
633 if (ret
== RMAP_DENYMATCH
)
635 /* Free newly generated AS path and community by route-map. */
636 bgp_attr_flush (attr
);
644 bgp_import_modifier (struct peer
*rsclient
, struct peer
*peer
,
645 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
647 struct bgp_filter
*filter
;
648 struct bgp_info info
;
649 route_map_result_t ret
;
651 filter
= &rsclient
->filter
[afi
][safi
];
653 /* Apply default weight value. */
654 attr
->weight
= peer
->weight
;
656 /* Route map apply. */
657 if (ROUTE_MAP_IMPORT_NAME (filter
))
659 /* Duplicate current value to new strucutre for modification. */
663 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
);
665 /* Apply BGP route map to the attribute. */
666 ret
= route_map_apply (ROUTE_MAP_IMPORT (filter
), p
, RMAP_BGP
, &info
);
670 if (ret
== RMAP_DENYMATCH
)
672 /* Free newly generated AS path and community by route-map. */
673 bgp_attr_flush (attr
);
681 bgp_announce_check (struct bgp_info
*ri
, struct peer
*peer
, struct prefix
*p
,
682 struct attr
*attr
, afi_t afi
, safi_t safi
)
685 char buf
[SU_ADDRSTRLEN
];
686 struct bgp_filter
*filter
;
693 filter
= &peer
->filter
[afi
][safi
];
696 #ifdef DISABLE_BGP_ANNOUNCE
700 /* Do not send announces to RS-clients from the 'normal' bgp_table. */
701 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
704 /* Do not send back route to sender. */
708 /* If peer's id and route's nexthop are same. draft-ietf-idr-bgp4-23 5.1.3 */
709 if (p
->family
== AF_INET
710 && IPV4_ADDR_SAME(&peer
->remote_id
, &ri
->attr
->nexthop
))
713 if (p
->family
== AF_INET6
714 && IPV6_ADDR_SAME(&peer
->remote_id
, &ri
->attr
->nexthop
))
718 /* Aggregate-address suppress check. */
720 if (! UNSUPPRESS_MAP_NAME (filter
))
723 /* Default route check. */
724 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
))
726 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
)
729 else if (p
->family
== AF_INET6
&& p
->prefixlen
== 0)
731 #endif /* HAVE_IPV6 */
734 /* Transparency check. */
735 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
)
736 && CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
741 /* If community is not disabled check the no-export and local. */
742 if (! transparent
&& bgp_community_filter (peer
, ri
->attr
))
745 /* If the attribute has originator-id and it is same as remote
747 if (ri
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
))
749 if (IPV4_ADDR_SAME (&peer
->remote_id
, &ri
->attr
->originator_id
))
751 if (BGP_DEBUG (filter
, FILTER
))
752 zlog (peer
->log
, LOG_DEBUG
,
753 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
755 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
761 /* ORF prefix-list filter check */
762 if (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_RM_ADV
)
763 && (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_RCV
)
764 || CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)))
765 if (peer
->orf_plist
[afi
][safi
])
767 if (prefix_list_apply (peer
->orf_plist
[afi
][safi
], p
) == PREFIX_DENY
)
771 /* Output filter check. */
772 if (bgp_output_filter (peer
, p
, ri
->attr
, afi
, safi
) == FILTER_DENY
)
774 if (BGP_DEBUG (filter
, FILTER
))
775 zlog (peer
->log
, LOG_DEBUG
,
776 "%s [Update:SEND] %s/%d is filtered",
778 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
783 #ifdef BGP_SEND_ASPATH_CHECK
784 /* AS path loop check. */
785 if (aspath_loop_check (ri
->attr
->aspath
, peer
->as
))
787 if (BGP_DEBUG (filter
, FILTER
))
788 zlog (peer
->log
, LOG_DEBUG
,
789 "%s [Update:SEND] suppress announcement to peer AS %d is AS path.",
790 peer
->host
, peer
->as
);
793 #endif /* BGP_SEND_ASPATH_CHECK */
795 /* If we're a CONFED we need to loop check the CONFED ID too */
796 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
798 if (aspath_loop_check(ri
->attr
->aspath
, bgp
->confed_id
))
800 if (BGP_DEBUG (filter
, FILTER
))
801 zlog (peer
->log
, LOG_DEBUG
,
802 "%s [Update:SEND] suppress announcement to peer AS %d is AS path.",
809 /* Route-Reflect check. */
810 if (peer_sort (from
) == BGP_PEER_IBGP
&& peer_sort (peer
) == BGP_PEER_IBGP
)
815 /* IBGP reflection check. */
818 /* A route from a Client peer. */
819 if (CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
821 /* Reflect to all the Non-Client peers and also to the
822 Client peers other than the originator. Originator check
823 is already done. So there is noting to do. */
824 /* no bgp client-to-client reflection check. */
825 if (bgp_flag_check (bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
826 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
831 /* A route from a Non-client peer. Reflect to all other
833 if (! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
838 /* For modify attribute, copy it to temporary structure. */
841 /* If local-preference is not set. */
842 if ((peer_sort (peer
) == BGP_PEER_IBGP
843 || peer_sort (peer
) == BGP_PEER_CONFED
)
844 && (! (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))))
846 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
);
847 attr
->local_pref
= bgp
->default_local_pref
;
850 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
851 if (peer_sort (peer
) == BGP_PEER_EBGP
852 && attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
854 if (ri
->peer
!= bgp
->peer_self
&& ! transparent
855 && ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
856 attr
->flag
&= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
));
860 if (transparent
|| reflect
861 || (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_UNCHANGED
)
862 && ((p
->family
== AF_INET
&& attr
->nexthop
.s_addr
)
864 || (p
->family
== AF_INET6
&&
865 ! IN6_IS_ADDR_UNSPECIFIED(&attr
->mp_nexthop_global
))
866 #endif /* HAVE_IPV6 */
869 /* NEXT-HOP Unchanged. */
871 else if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
872 || (p
->family
== AF_INET
&& attr
->nexthop
.s_addr
== 0)
874 || (p
->family
== AF_INET6
&&
875 IN6_IS_ADDR_UNSPECIFIED(&attr
->mp_nexthop_global
))
876 #endif /* HAVE_IPV6 */
877 || (peer_sort (peer
) == BGP_PEER_EBGP
878 && bgp_multiaccess_check_v4 (attr
->nexthop
, peer
->host
) == 0))
880 /* Set IPv4 nexthop. */
881 if (p
->family
== AF_INET
)
883 if (safi
== SAFI_MPLS_VPN
)
884 memcpy (&attr
->mp_nexthop_global_in
, &peer
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
886 memcpy (&attr
->nexthop
, &peer
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
889 /* Set IPv6 nexthop. */
890 if (p
->family
== AF_INET6
)
892 /* IPv6 global nexthop must be included. */
893 memcpy (&attr
->mp_nexthop_global
, &peer
->nexthop
.v6_global
,
895 attr
->mp_nexthop_len
= 16;
897 #endif /* HAVE_IPV6 */
901 if (p
->family
== AF_INET6
)
903 /* Left nexthop_local unchanged if so configured. */
904 if ( CHECK_FLAG (peer
->af_flags
[afi
][safi
],
905 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) )
907 if ( IN6_IS_ADDR_LINKLOCAL (&attr
->mp_nexthop_local
) )
908 attr
->mp_nexthop_len
=32;
910 attr
->mp_nexthop_len
=16;
913 /* Default nexthop_local treatment for non-RS-Clients */
916 /* Link-local address should not be transit to different peer. */
917 attr
->mp_nexthop_len
= 16;
919 /* Set link-local address for shared network peer. */
920 if (peer
->shared_network
921 && ! IN6_IS_ADDR_UNSPECIFIED (&peer
->nexthop
.v6_local
))
923 memcpy (&attr
->mp_nexthop_local
, &peer
->nexthop
.v6_local
,
925 attr
->mp_nexthop_len
= 32;
928 /* If bgpd act as BGP-4+ route-reflector, do not send link-local
931 attr
->mp_nexthop_len
= 16;
933 /* If BGP-4+ link-local nexthop is not link-local nexthop. */
934 if (! IN6_IS_ADDR_LINKLOCAL (&peer
->nexthop
.v6_local
))
935 attr
->mp_nexthop_len
= 16;
939 #endif /* HAVE_IPV6 */
941 /* If this is EBGP peer and remove-private-AS is set. */
942 if (peer_sort (peer
) == BGP_PEER_EBGP
943 && peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)
944 && aspath_private_as_check (attr
->aspath
))
945 attr
->aspath
= aspath_empty_get ();
947 /* Route map & unsuppress-map apply. */
948 if (ROUTE_MAP_OUT_NAME (filter
)
951 struct bgp_info info
;
952 struct attr dummy_attr
;
957 /* The route reflector is not allowed to modify the attributes
958 of the reflected IBGP routes. */
959 if (peer_sort (from
) == BGP_PEER_IBGP
960 && peer_sort (peer
) == BGP_PEER_IBGP
)
963 info
.attr
= &dummy_attr
;
966 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
);
969 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
971 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
975 if (ret
== RMAP_DENYMATCH
)
977 bgp_attr_flush (attr
);
985 bgp_announce_check_rsclient (struct bgp_info
*ri
, struct peer
*rsclient
,
986 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
989 char buf
[SU_ADDRSTRLEN
];
990 struct bgp_filter
*filter
;
991 struct bgp_info info
;
996 filter
= &rsclient
->filter
[afi
][safi
];
999 #ifdef DISABLE_BGP_ANNOUNCE
1003 /* Do not send back route to sender. */
1004 if (from
== rsclient
)
1007 /* Aggregate-address suppress check. */
1009 if (! UNSUPPRESS_MAP_NAME (filter
))
1012 /* Default route check. */
1013 if (CHECK_FLAG (rsclient
->af_sflags
[afi
][safi
],
1014 PEER_STATUS_DEFAULT_ORIGINATE
))
1016 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
)
1019 else if (p
->family
== AF_INET6
&& p
->prefixlen
== 0)
1021 #endif /* HAVE_IPV6 */
1024 /* If the attribute has originator-id and it is same as remote
1026 if (ri
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
))
1028 if (IPV4_ADDR_SAME (&rsclient
->remote_id
, &ri
->attr
->originator_id
))
1030 if (BGP_DEBUG (filter
, FILTER
))
1031 zlog (rsclient
->log
, LOG_DEBUG
,
1032 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
1034 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1040 /* ORF prefix-list filter check */
1041 if (CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_RM_ADV
)
1042 && (CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_RCV
)
1043 || CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)))
1044 if (rsclient
->orf_plist
[afi
][safi
])
1046 if (prefix_list_apply (rsclient
->orf_plist
[afi
][safi
], p
) == PREFIX_DENY
)
1050 /* Output filter check. */
1051 if (bgp_output_filter (rsclient
, p
, ri
->attr
, afi
, safi
) == FILTER_DENY
)
1053 if (BGP_DEBUG (filter
, FILTER
))
1054 zlog (rsclient
->log
, LOG_DEBUG
,
1055 "%s [Update:SEND] %s/%d is filtered",
1057 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1062 #ifdef BGP_SEND_ASPATH_CHECK
1063 /* AS path loop check. */
1064 if (aspath_loop_check (ri
->attr
->aspath
, rsclient
->as
))
1066 if (BGP_DEBUG (filter
, FILTER
))
1067 zlog (rsclient
->log
, LOG_DEBUG
,
1068 "%s [Update:SEND] suppress announcement to peer AS %d is AS path.",
1069 rsclient
->host
, rsclient
->as
);
1072 #endif /* BGP_SEND_ASPATH_CHECK */
1074 /* For modify attribute, copy it to temporary structure. */
1078 if ((p
->family
== AF_INET
&& attr
->nexthop
.s_addr
== 0)
1080 || (p
->family
== AF_INET6
&&
1081 IN6_IS_ADDR_UNSPECIFIED(&attr
->mp_nexthop_global
))
1082 #endif /* HAVE_IPV6 */
1085 /* Set IPv4 nexthop. */
1086 if (p
->family
== AF_INET
)
1088 if (safi
== SAFI_MPLS_VPN
)
1089 memcpy (&attr
->mp_nexthop_global_in
, &rsclient
->nexthop
.v4
,
1092 memcpy (&attr
->nexthop
, &rsclient
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
1095 /* Set IPv6 nexthop. */
1096 if (p
->family
== AF_INET6
)
1098 /* IPv6 global nexthop must be included. */
1099 memcpy (&attr
->mp_nexthop_global
, &rsclient
->nexthop
.v6_global
,
1102 attr
->mp_nexthop_len
= 16;
1104 #endif /* HAVE_IPV6 */
1108 if (p
->family
== AF_INET6
)
1110 /* Left nexthop_local unchanged if so configured. */
1111 if ( CHECK_FLAG (rsclient
->af_flags
[afi
][safi
],
1112 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) )
1114 if ( IN6_IS_ADDR_LINKLOCAL (&attr
->mp_nexthop_local
) )
1115 attr
->mp_nexthop_len
=32;
1117 attr
->mp_nexthop_len
=16;
1120 /* Default nexthop_local treatment for RS-Clients */
1123 /* Announcer and RS-Client are both in the same network */
1124 if (rsclient
->shared_network
&& from
->shared_network
&&
1125 (rsclient
->ifindex
== from
->ifindex
))
1127 if ( IN6_IS_ADDR_LINKLOCAL (&attr
->mp_nexthop_local
) )
1128 attr
->mp_nexthop_len
=32;
1130 attr
->mp_nexthop_len
=16;
1133 /* Set link-local address for shared network peer. */
1134 else if (rsclient
->shared_network
1135 && IN6_IS_ADDR_LINKLOCAL (&rsclient
->nexthop
.v6_local
))
1137 memcpy (&attr
->mp_nexthop_local
, &rsclient
->nexthop
.v6_local
,
1139 attr
->mp_nexthop_len
= 32;
1143 attr
->mp_nexthop_len
= 16;
1147 #endif /* HAVE_IPV6 */
1150 /* If this is EBGP peer and remove-private-AS is set. */
1151 if (peer_sort (rsclient
) == BGP_PEER_EBGP
1152 && peer_af_flag_check (rsclient
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)
1153 && aspath_private_as_check (attr
->aspath
))
1154 attr
->aspath
= aspath_empty_get ();
1156 /* Route map & unsuppress-map apply. */
1157 if (ROUTE_MAP_OUT_NAME (filter
) || ri
->suppress
)
1159 info
.peer
= rsclient
;
1162 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1165 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
1167 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
1169 rsclient
->rmap_type
= 0;
1171 if (ret
== RMAP_DENYMATCH
)
1173 bgp_attr_flush (attr
);
1181 struct bgp_info_pair
1183 struct bgp_info
*old
;
1184 struct bgp_info
*new;
1188 bgp_best_selection (struct bgp
*bgp
, struct bgp_node
*rn
, struct bgp_info_pair
*result
)
1190 struct bgp_info
*new_select
;
1191 struct bgp_info
*old_select
;
1192 struct bgp_info
*ri
;
1193 struct bgp_info
*ri1
;
1194 struct bgp_info
*ri2
;
1195 struct bgp_info
*nextri
= NULL
;
1197 /* bgp deterministic-med */
1199 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
))
1200 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1202 if (CHECK_FLAG (ri1
->flags
, BGP_INFO_DMED_CHECK
))
1204 if (BGP_INFO_HOLDDOWN (ri1
))
1209 for (ri2
= ri1
->next
; ri2
; ri2
= ri2
->next
)
1211 if (CHECK_FLAG (ri2
->flags
, BGP_INFO_DMED_CHECK
))
1213 if (BGP_INFO_HOLDDOWN (ri2
))
1216 if (aspath_cmp_left (ri1
->attr
->aspath
, ri2
->attr
->aspath
)
1217 || aspath_cmp_left_confed (ri1
->attr
->aspath
,
1220 if (bgp_info_cmp (bgp
, ri2
, new_select
))
1222 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1226 bgp_info_set_flag (rn
, ri2
, BGP_INFO_DMED_CHECK
);
1229 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_CHECK
);
1230 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1233 /* Check old selected route and new selected route. */
1236 for (ri
= rn
->info
; (ri
!= NULL
) && (nextri
= ri
->next
, 1); ri
= nextri
)
1238 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1241 if (BGP_INFO_HOLDDOWN (ri
))
1243 /* reap REMOVED routes, if needs be
1244 * selected route must stay for a while longer though
1246 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
1247 && (ri
!= old_select
))
1248 bgp_info_reap (rn
, ri
);
1253 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
)
1254 && (! CHECK_FLAG (ri
->flags
, BGP_INFO_DMED_SELECTED
)))
1256 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1259 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1260 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_SELECTED
);
1262 if (bgp_info_cmp (bgp
, ri
, new_select
))
1266 result
->old
= old_select
;
1267 result
->new = new_select
;
1273 bgp_process_announce_selected (struct peer
*peer
, struct bgp_info
*selected
,
1274 struct bgp_node
*rn
, struct attr
*attr
, afi_t afi
, safi_t safi
)
1280 /* Announce route to Established peer. */
1281 if (peer
->status
!= Established
)
1284 /* Address family configuration check. */
1285 if (! peer
->afc_nego
[afi
][safi
])
1288 /* First update is deferred until ORF or ROUTE-REFRESH is received */
1289 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
],
1290 PEER_STATUS_ORF_WAIT_REFRESH
))
1293 switch (rn
->table
->type
)
1295 case BGP_TABLE_MAIN
:
1296 /* Announcement to peer->conf. If the route is filtered,
1298 if (selected
&& bgp_announce_check (selected
, peer
, p
, attr
, afi
, safi
))
1299 bgp_adj_out_set (rn
, peer
, p
, attr
, afi
, safi
, selected
);
1301 bgp_adj_out_unset (rn
, peer
, p
, afi
, safi
);
1303 case BGP_TABLE_RSCLIENT
:
1304 /* Announcement to peer->conf. If the route is filtered,
1306 if (selected
&& bgp_announce_check_rsclient
1307 (selected
, peer
, p
, attr
, afi
, safi
))
1308 bgp_adj_out_set (rn
, peer
, p
, attr
, afi
, safi
, selected
);
1310 bgp_adj_out_unset (rn
, peer
, p
, afi
, safi
);
1316 struct bgp_process_queue
1319 struct bgp_node
*rn
;
1324 static wq_item_status
1325 bgp_process_rsclient (struct work_queue
*wq
, void *data
)
1327 struct bgp_process_queue
*pq
= data
;
1328 struct bgp
*bgp
= pq
->bgp
;
1329 struct bgp_node
*rn
= pq
->rn
;
1330 afi_t afi
= pq
->afi
;
1331 safi_t safi
= pq
->safi
;
1332 struct bgp_info
*new_select
;
1333 struct bgp_info
*old_select
;
1334 struct bgp_info_pair old_and_new
;
1336 struct listnode
*node
, *nnode
;
1337 struct peer
*rsclient
= rn
->table
->owner
;
1339 /* Best path selection. */
1340 bgp_best_selection (bgp
, rn
, &old_and_new
);
1341 new_select
= old_and_new
.new;
1342 old_select
= old_and_new
.old
;
1344 if (CHECK_FLAG (rsclient
->sflags
, PEER_STATUS_GROUP
))
1346 for (ALL_LIST_ELEMENTS (rsclient
->group
->peer
, node
, nnode
, rsclient
))
1348 /* Nothing to do. */
1349 if (old_select
&& old_select
== new_select
)
1350 if (!CHECK_FLAG (old_select
->flags
, BGP_INFO_ATTR_CHANGED
))
1354 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1357 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1358 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1361 bgp_process_announce_selected (rsclient
, new_select
, rn
, &attr
,
1368 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1371 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1372 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1374 bgp_process_announce_selected (rsclient
, new_select
, rn
,
1378 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
1379 bgp_info_reap (rn
, old_select
);
1381 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1385 static wq_item_status
1386 bgp_process_main (struct work_queue
*wq
, void *data
)
1388 struct bgp_process_queue
*pq
= data
;
1389 struct bgp
*bgp
= pq
->bgp
;
1390 struct bgp_node
*rn
= pq
->rn
;
1391 afi_t afi
= pq
->afi
;
1392 safi_t safi
= pq
->safi
;
1393 struct prefix
*p
= &rn
->p
;
1394 struct bgp_info
*new_select
;
1395 struct bgp_info
*old_select
;
1396 struct bgp_info_pair old_and_new
;
1397 struct listnode
*node
, *nnode
;
1401 /* Best path selection. */
1402 bgp_best_selection (bgp
, rn
, &old_and_new
);
1403 old_select
= old_and_new
.old
;
1404 new_select
= old_and_new
.new;
1406 /* Nothing to do. */
1407 if (old_select
&& old_select
== new_select
)
1409 if (! CHECK_FLAG (old_select
->flags
, BGP_INFO_ATTR_CHANGED
))
1411 if (CHECK_FLAG (old_select
->flags
, BGP_INFO_IGP_CHANGED
))
1412 bgp_zebra_announce (p
, old_select
, bgp
);
1414 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1420 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1423 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1424 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1428 /* Check each BGP peer. */
1429 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
1431 bgp_process_announce_selected (peer
, new_select
, rn
, &attr
, afi
, safi
);
1435 if (safi
== SAFI_UNICAST
&& ! bgp
->name
&&
1436 ! bgp_option_check (BGP_OPT_NO_FIB
))
1439 && new_select
->type
== ZEBRA_ROUTE_BGP
1440 && new_select
->sub_type
== BGP_ROUTE_NORMAL
)
1441 bgp_zebra_announce (p
, new_select
, bgp
);
1444 /* Withdraw the route from the kernel. */
1446 && old_select
->type
== ZEBRA_ROUTE_BGP
1447 && old_select
->sub_type
== BGP_ROUTE_NORMAL
)
1448 bgp_zebra_withdraw (p
, old_select
);
1452 /* Reap old select bgp_info, it it has been removed */
1453 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
1454 bgp_info_reap (rn
, old_select
);
1456 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1461 bgp_processq_del (struct work_queue
*wq
, void *data
)
1463 struct bgp_process_queue
*pq
= data
;
1465 bgp_unlock_node (pq
->rn
);
1466 XFREE (MTYPE_BGP_PROCESS_QUEUE
, pq
);
1470 bgp_process_queue_init (void)
1472 bm
->process_main_queue
1473 = work_queue_new (bm
->master
, "process_main_queue");
1474 bm
->process_rsclient_queue
1475 = work_queue_new (bm
->master
, "process_rsclient_queue");
1477 if ( !(bm
->process_main_queue
&& bm
->process_rsclient_queue
) )
1479 zlog_err ("%s: Failed to allocate work queue", __func__
);
1483 bm
->process_main_queue
->spec
.workfunc
= &bgp_process_main
;
1484 bm
->process_rsclient_queue
->spec
.workfunc
= &bgp_process_rsclient
;
1485 bm
->process_main_queue
->spec
.del_item_data
= &bgp_processq_del
;
1486 bm
->process_rsclient_queue
->spec
.del_item_data
1487 = bm
->process_main_queue
->spec
.del_item_data
;
1488 bm
->process_main_queue
->spec
.max_retries
1489 = bm
->process_main_queue
->spec
.max_retries
= 0;
1490 bm
->process_rsclient_queue
->spec
.hold
1491 = bm
->process_main_queue
->spec
.hold
= 50;
1495 bgp_process (struct bgp
*bgp
, struct bgp_node
*rn
, afi_t afi
, safi_t safi
)
1497 struct bgp_process_queue
*pqnode
;
1499 /* already scheduled for processing? */
1500 if (CHECK_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
))
1503 if ( (bm
->process_main_queue
== NULL
) ||
1504 (bm
->process_rsclient_queue
== NULL
) )
1505 bgp_process_queue_init ();
1507 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
1508 sizeof (struct bgp_process_queue
));
1512 pqnode
->rn
= bgp_lock_node (rn
); /* unlocked by bgp_processq_del */
1515 pqnode
->safi
= safi
;
1517 switch (rn
->table
->type
)
1519 case BGP_TABLE_MAIN
:
1520 work_queue_add (bm
->process_main_queue
, pqnode
);
1522 case BGP_TABLE_RSCLIENT
:
1523 work_queue_add (bm
->process_rsclient_queue
, pqnode
);
1531 bgp_maximum_prefix_restart_timer (struct thread
*thread
)
1535 peer
= THREAD_ARG (thread
);
1536 peer
->t_pmax_restart
= NULL
;
1538 if (BGP_DEBUG (events
, EVENTS
))
1539 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
1548 bgp_maximum_prefix_overflow (struct peer
*peer
, afi_t afi
,
1549 safi_t safi
, int always
)
1551 if (!CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
))
1554 if (peer
->pcount
[afi
][safi
] > peer
->pmax
[afi
][safi
])
1556 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
)
1560 zlog (peer
->log
, LOG_INFO
,
1561 "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
1562 "limit %ld", afi_safi_print (afi
, safi
), peer
->host
,
1563 peer
->pcount
[afi
][safi
], peer
->pmax
[afi
][safi
]);
1564 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
1566 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_WARNING
))
1572 if (safi
== SAFI_MPLS_VPN
)
1573 safi
= BGP_SAFI_VPNV4
;
1575 ndata
[0] = (afi
>> 8);
1578 ndata
[3] = (peer
->pmax
[afi
][safi
] >> 24);
1579 ndata
[4] = (peer
->pmax
[afi
][safi
] >> 16);
1580 ndata
[5] = (peer
->pmax
[afi
][safi
] >> 8);
1581 ndata
[6] = (peer
->pmax
[afi
][safi
]);
1583 SET_FLAG (peer
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
);
1584 bgp_notify_send_with_data (peer
, BGP_NOTIFY_CEASE
,
1585 BGP_NOTIFY_CEASE_MAX_PREFIX
, ndata
, 7);
1588 /* restart timer start */
1589 if (peer
->pmax_restart
[afi
][safi
])
1591 peer
->v_pmax_restart
= peer
->pmax_restart
[afi
][safi
] * 60;
1593 if (BGP_DEBUG (events
, EVENTS
))
1594 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
1595 peer
->host
, peer
->v_pmax_restart
);
1597 BGP_TIMER_ON (peer
->t_pmax_restart
, bgp_maximum_prefix_restart_timer
,
1598 peer
->v_pmax_restart
);
1604 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
1606 if (peer
->pcount
[afi
][safi
] > (peer
->pmax
[afi
][safi
] * peer
->pmax_threshold
[afi
][safi
] / 100))
1608 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
)
1612 zlog (peer
->log
, LOG_INFO
,
1613 "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
1614 afi_safi_print (afi
, safi
), peer
->host
, peer
->pcount
[afi
][safi
],
1615 peer
->pmax
[afi
][safi
]);
1616 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
1619 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
1623 /* Unconditionally remove the route from the RIB, without taking
1624 * damping into consideration (eg, because the session went down)
1627 bgp_rib_remove (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
1628 afi_t afi
, safi_t safi
)
1630 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
1632 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
1633 bgp_info_delete (rn
, ri
); /* keep historical info */
1635 bgp_process (peer
->bgp
, rn
, afi
, safi
);
1639 bgp_rib_withdraw (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
1640 afi_t afi
, safi_t safi
)
1642 int status
= BGP_DAMP_NONE
;
1644 /* apply dampening, if result is suppressed, we'll be retaining
1645 * the bgp_info in the RIB for historical reference.
1647 if (CHECK_FLAG (peer
->bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
1648 && peer_sort (peer
) == BGP_PEER_EBGP
)
1649 if ( (status
= bgp_damp_withdraw (ri
, rn
, afi
, safi
, 0))
1650 == BGP_DAMP_SUPPRESSED
)
1652 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
1656 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
1660 bgp_update_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
,
1661 struct attr
*attr
, struct peer
*peer
, struct prefix
*p
, int type
,
1662 int sub_type
, struct prefix_rd
*prd
, u_char
*tag
)
1664 struct bgp_node
*rn
;
1666 struct attr new_attr
;
1667 struct attr
*attr_new
;
1668 struct attr
*attr_new2
;
1669 struct bgp_info
*ri
;
1670 struct bgp_info
*new;
1672 char buf
[SU_ADDRSTRLEN
];
1674 /* Do not insert announces from a rsclient into its own 'bgp_table'. */
1675 if (peer
== rsclient
)
1679 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
1681 /* Check previously received route. */
1682 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1683 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
1686 /* AS path loop check. */
1687 if (aspath_loop_check (attr
->aspath
, rsclient
->as
) > peer
->allowas_in
[afi
][safi
])
1689 reason
= "as-path contains our own AS;";
1693 /* Route reflector originator ID check. */
1694 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
1695 && IPV4_ADDR_SAME (&rsclient
->remote_id
, &attr
->originator_id
))
1697 reason
= "originator is us;";
1703 /* Apply export policy. */
1704 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
) &&
1705 bgp_export_modifier (rsclient
, peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
1707 reason
= "export-policy;";
1711 attr_new2
= bgp_attr_intern (&new_attr
);
1713 /* Apply import policy. */
1714 if (bgp_import_modifier (rsclient
, peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
1716 bgp_attr_unintern (attr_new2
);
1718 reason
= "import-policy;";
1722 attr_new
= bgp_attr_intern (&new_attr
);
1723 bgp_attr_unintern (attr_new2
);
1725 /* IPv4 unicast next hop check. */
1726 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
1728 /* Next hop must not be 0.0.0.0 nor Class E address. */
1729 if (new_attr
.nexthop
.s_addr
== 0
1730 || ntohl (new_attr
.nexthop
.s_addr
) >= 0xe0000000)
1732 bgp_attr_unintern (attr_new
);
1734 reason
= "martian next-hop;";
1739 /* If the update is implicit withdraw. */
1742 ri
->uptime
= time (NULL
);
1744 /* Same attribute comes in. */
1745 if (attrhash_cmp (ri
->attr
, attr_new
))
1748 bgp_info_unset_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
1750 if (BGP_DEBUG (update
, UPDATE_IN
))
1751 zlog (peer
->log
, LOG_DEBUG
,
1752 "%s rcvd %s/%d for RS-client %s...duplicate ignored",
1754 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1755 p
->prefixlen
, rsclient
->host
);
1757 bgp_unlock_node (rn
);
1758 bgp_attr_unintern (attr_new
);
1763 /* Received Logging. */
1764 if (BGP_DEBUG (update
, UPDATE_IN
))
1765 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d for RS-client %s",
1767 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1768 p
->prefixlen
, rsclient
->host
);
1770 /* The attribute is changed. */
1771 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
1773 /* Update to new attribute. */
1774 bgp_attr_unintern (ri
->attr
);
1775 ri
->attr
= attr_new
;
1777 /* Update MPLS tag. */
1778 if (safi
== SAFI_MPLS_VPN
)
1779 memcpy (ri
->tag
, tag
, 3);
1781 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
1783 /* Process change. */
1784 bgp_process (bgp
, rn
, afi
, safi
);
1785 bgp_unlock_node (rn
);
1790 /* Received Logging. */
1791 if (BGP_DEBUG (update
, UPDATE_IN
))
1793 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d for RS-client %s",
1795 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1796 p
->prefixlen
, rsclient
->host
);
1799 /* Make new BGP info. */
1800 new = bgp_info_new ();
1802 new->sub_type
= sub_type
;
1804 new->attr
= attr_new
;
1805 new->uptime
= time (NULL
);
1807 /* Update MPLS tag. */
1808 if (safi
== SAFI_MPLS_VPN
)
1809 memcpy (new->tag
, tag
, 3);
1811 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
1813 /* Register new BGP information. */
1814 bgp_info_add (rn
, new);
1816 /* route_node_get lock */
1817 bgp_unlock_node (rn
);
1819 /* Process change. */
1820 bgp_process (bgp
, rn
, afi
, safi
);
1826 /* This BGP update is filtered. Log the reason then update BGP entry. */
1827 if (BGP_DEBUG (update
, UPDATE_IN
))
1828 zlog (peer
->log
, LOG_DEBUG
,
1829 "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s",
1831 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1832 p
->prefixlen
, rsclient
->host
, reason
);
1835 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
1837 bgp_unlock_node (rn
);
1843 bgp_withdraw_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
,
1844 struct peer
*peer
, struct prefix
*p
, int type
, int sub_type
,
1845 struct prefix_rd
*prd
, u_char
*tag
)
1847 struct bgp_node
*rn
;
1848 struct bgp_info
*ri
;
1849 char buf
[SU_ADDRSTRLEN
];
1851 if (rsclient
== peer
)
1854 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
1856 /* Lookup withdrawn route. */
1857 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1858 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
1861 /* Withdraw specified route from routing table. */
1862 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
1863 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
1864 else if (BGP_DEBUG (update
, UPDATE_IN
))
1865 zlog (peer
->log
, LOG_DEBUG
,
1866 "%s Can't find the route %s/%d", peer
->host
,
1867 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1870 /* Unlock bgp_node_get() lock. */
1871 bgp_unlock_node (rn
);
1875 bgp_update_main (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
1876 afi_t afi
, safi_t safi
, int type
, int sub_type
,
1877 struct prefix_rd
*prd
, u_char
*tag
, int soft_reconfig
)
1880 int aspath_loop_count
= 0;
1881 struct bgp_node
*rn
;
1883 struct attr new_attr
;
1884 struct attr
*attr_new
;
1885 struct bgp_info
*ri
;
1886 struct bgp_info
*new;
1888 char buf
[SU_ADDRSTRLEN
];
1891 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
1893 /* When peer's soft reconfiguration enabled. Record input packet in
1895 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
1896 && peer
!= bgp
->peer_self
&& ! soft_reconfig
)
1897 bgp_adj_in_set (rn
, peer
, attr
);
1899 /* Check previously received route. */
1900 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1901 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
1904 /* AS path local-as loop check. */
1905 if (peer
->change_local_as
)
1907 if (! CHECK_FLAG (peer
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
1908 aspath_loop_count
= 1;
1910 if (aspath_loop_check (attr
->aspath
, peer
->change_local_as
) > aspath_loop_count
)
1912 reason
= "as-path contains our own AS;";
1917 /* AS path loop check. */
1918 if (aspath_loop_check (attr
->aspath
, bgp
->as
) > peer
->allowas_in
[afi
][safi
]
1919 || (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
1920 && aspath_loop_check(attr
->aspath
, bgp
->confed_id
)
1921 > peer
->allowas_in
[afi
][safi
]))
1923 reason
= "as-path contains our own AS;";
1927 /* Route reflector originator ID check. */
1928 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
1929 && IPV4_ADDR_SAME (&bgp
->router_id
, &attr
->originator_id
))
1931 reason
= "originator is us;";
1935 /* Route reflector cluster ID check. */
1936 if (bgp_cluster_filter (peer
, attr
))
1938 reason
= "reflected from the same cluster;";
1942 /* Apply incoming filter. */
1943 if (bgp_input_filter (peer
, p
, attr
, afi
, safi
) == FILTER_DENY
)
1949 /* Apply incoming route-map. */
1952 if (bgp_input_modifier (peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
1954 reason
= "route-map;";
1958 /* IPv4 unicast next hop check. */
1959 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
1961 /* If the peer is EBGP and nexthop is not on connected route,
1963 if (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
== 1
1964 && ! bgp_nexthop_check_ebgp (afi
, &new_attr
)
1965 && ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
1967 reason
= "non-connected next-hop;";
1971 /* Next hop must not be 0.0.0.0 nor Class E address. Next hop
1972 must not be my own address. */
1973 if (bgp_nexthop_self (afi
, &new_attr
)
1974 || new_attr
.nexthop
.s_addr
== 0
1975 || ntohl (new_attr
.nexthop
.s_addr
) >= 0xe0000000)
1977 reason
= "martian next-hop;";
1982 attr_new
= bgp_attr_intern (&new_attr
);
1984 /* If the update is implicit withdraw. */
1987 ri
->uptime
= time (NULL
);
1989 /* Same attribute comes in. */
1990 if (attrhash_cmp (ri
->attr
, attr_new
))
1992 bgp_info_unset_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
1994 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
1995 && peer_sort (peer
) == BGP_PEER_EBGP
1996 && CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
1998 if (BGP_DEBUG (update
, UPDATE_IN
))
1999 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2001 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2004 if (bgp_damp_update (ri
, rn
, afi
, safi
) != BGP_DAMP_SUPPRESSED
)
2006 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2007 bgp_process (bgp
, rn
, afi
, safi
);
2012 if (BGP_DEBUG (update
, UPDATE_IN
))
2013 zlog (peer
->log
, LOG_DEBUG
,
2014 "%s rcvd %s/%d...duplicate ignored",
2016 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2019 /* graceful restart STALE flag unset. */
2020 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2022 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2023 bgp_process (bgp
, rn
, afi
, safi
);
2027 bgp_unlock_node (rn
);
2028 bgp_attr_unintern (attr_new
);
2032 /* Received Logging. */
2033 if (BGP_DEBUG (update
, UPDATE_IN
))
2034 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2036 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2039 /* graceful restart STALE flag unset. */
2040 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2041 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2043 /* The attribute is changed. */
2044 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2046 /* implicit withdraw, decrement aggregate and pcount here.
2047 * only if update is accepted, they'll increment below.
2049 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
2051 /* Update bgp route dampening information. */
2052 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2053 && peer_sort (peer
) == BGP_PEER_EBGP
)
2055 /* This is implicit withdraw so we should update dampening
2057 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2058 bgp_damp_withdraw (ri
, rn
, afi
, safi
, 1);
2061 /* Update to new attribute. */
2062 bgp_attr_unintern (ri
->attr
);
2063 ri
->attr
= attr_new
;
2065 /* Update MPLS tag. */
2066 if (safi
== SAFI_MPLS_VPN
)
2067 memcpy (ri
->tag
, tag
, 3);
2069 /* Update bgp route dampening information. */
2070 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2071 && peer_sort (peer
) == BGP_PEER_EBGP
)
2073 /* Now we do normal update dampening. */
2074 ret
= bgp_damp_update (ri
, rn
, afi
, safi
);
2075 if (ret
== BGP_DAMP_SUPPRESSED
)
2077 bgp_unlock_node (rn
);
2082 /* Nexthop reachability check. */
2083 if ((afi
== AFI_IP
|| afi
== AFI_IP6
)
2084 && safi
== SAFI_UNICAST
2085 && (peer_sort (peer
) == BGP_PEER_IBGP
2086 || (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)
2087 || CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)))
2089 if (bgp_nexthop_lookup (afi
, peer
, ri
, NULL
, NULL
))
2090 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2092 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
2095 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2097 /* Process change. */
2098 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2100 bgp_process (bgp
, rn
, afi
, safi
);
2101 bgp_unlock_node (rn
);
2105 /* Received Logging. */
2106 if (BGP_DEBUG (update
, UPDATE_IN
))
2108 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2110 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2114 /* Make new BGP info. */
2115 new = bgp_info_new ();
2117 new->sub_type
= sub_type
;
2119 new->attr
= attr_new
;
2120 new->uptime
= time (NULL
);
2122 /* Update MPLS tag. */
2123 if (safi
== SAFI_MPLS_VPN
)
2124 memcpy (new->tag
, tag
, 3);
2126 /* Nexthop reachability check. */
2127 if ((afi
== AFI_IP
|| afi
== AFI_IP6
)
2128 && safi
== SAFI_UNICAST
2129 && (peer_sort (peer
) == BGP_PEER_IBGP
2130 || (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)
2131 || CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)))
2133 if (bgp_nexthop_lookup (afi
, peer
, new, NULL
, NULL
))
2134 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2136 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
2139 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2141 /* Increment prefix */
2142 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
2144 /* Register new BGP information. */
2145 bgp_info_add (rn
, new);
2147 /* route_node_get lock */
2148 bgp_unlock_node (rn
);
2150 /* If maximum prefix count is configured and current prefix
2152 if (bgp_maximum_prefix_overflow (peer
, afi
, safi
, 0))
2155 /* Process change. */
2156 bgp_process (bgp
, rn
, afi
, safi
);
2160 /* This BGP update is filtered. Log the reason then update BGP
2163 if (BGP_DEBUG (update
, UPDATE_IN
))
2164 zlog (peer
->log
, LOG_DEBUG
,
2165 "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
2167 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2168 p
->prefixlen
, reason
);
2171 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2173 bgp_unlock_node (rn
);
2179 bgp_update (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
2180 afi_t afi
, safi_t safi
, int type
, int sub_type
,
2181 struct prefix_rd
*prd
, u_char
*tag
, int soft_reconfig
)
2183 struct peer
*rsclient
;
2184 struct listnode
*node
, *nnode
;
2188 ret
= bgp_update_main (peer
, p
, attr
, afi
, safi
, type
, sub_type
, prd
, tag
,
2193 /* Process the update for each RS-client. */
2194 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
2196 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2197 bgp_update_rsclient (rsclient
, afi
, safi
, attr
, peer
, p
, type
,
2198 sub_type
, prd
, tag
);
2205 bgp_withdraw (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
2206 afi_t afi
, safi_t safi
, int type
, int sub_type
,
2207 struct prefix_rd
*prd
, u_char
*tag
)
2210 char buf
[SU_ADDRSTRLEN
];
2211 struct bgp_node
*rn
;
2212 struct bgp_info
*ri
;
2213 struct peer
*rsclient
;
2214 struct listnode
*node
, *nnode
;
2218 /* Process the withdraw for each RS-client. */
2219 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
2221 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2222 bgp_withdraw_rsclient (rsclient
, afi
, safi
, peer
, p
, type
, sub_type
, prd
, tag
);
2226 if (BGP_DEBUG (update
, UPDATE_IN
))
2227 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd UPDATE about %s/%d -- withdrawn",
2229 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2233 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2235 /* If peer is soft reconfiguration enabled. Record input packet for
2236 further calculation. */
2237 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2238 && peer
!= bgp
->peer_self
)
2239 bgp_adj_in_unset (rn
, peer
);
2241 /* Lookup withdrawn route. */
2242 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2243 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
2246 /* Withdraw specified route from routing table. */
2247 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2248 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
2249 else if (BGP_DEBUG (update
, UPDATE_IN
))
2250 zlog (peer
->log
, LOG_DEBUG
,
2251 "%s Can't find the route %s/%d", peer
->host
,
2252 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2255 /* Unlock bgp_node_get() lock. */
2256 bgp_unlock_node (rn
);
2262 bgp_default_originate (struct peer
*peer
, afi_t afi
, safi_t safi
, int withdraw
)
2266 struct aspath
*aspath
;
2268 struct bgp_info binfo
;
2270 int ret
= RMAP_DENYMATCH
;
2273 from
= bgp
->peer_self
;
2275 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
2276 aspath
= attr
.aspath
;
2277 attr
.local_pref
= bgp
->default_local_pref
;
2278 memcpy (&attr
.nexthop
, &peer
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
2281 str2prefix ("0.0.0.0/0", &p
);
2283 else if (afi
== AFI_IP6
)
2285 str2prefix ("::/0", &p
);
2287 /* IPv6 global nexthop must be included. */
2288 memcpy (&attr
.mp_nexthop_global
, &peer
->nexthop
.v6_global
,
2290 attr
.mp_nexthop_len
= 16;
2292 /* If the peer is on shared nextwork and we have link-local
2294 if (peer
->shared_network
2295 && !IN6_IS_ADDR_UNSPECIFIED (&peer
->nexthop
.v6_local
))
2297 memcpy (&attr
.mp_nexthop_local
, &peer
->nexthop
.v6_local
,
2299 attr
.mp_nexthop_len
= 32;
2302 #endif /* HAVE_IPV6 */
2306 if (peer
->default_rmap
[afi
][safi
].name
)
2308 binfo
.peer
= bgp
->peer_self
;
2311 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_DEFAULT
);
2313 ret
= route_map_apply (peer
->default_rmap
[afi
][safi
].map
, &p
,
2316 bgp
->peer_self
->rmap_type
= 0;
2318 if (ret
== RMAP_DENYMATCH
)
2320 bgp_attr_flush (&attr
);
2327 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
))
2328 bgp_default_withdraw_send (peer
, afi
, safi
);
2329 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
);
2333 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
);
2334 bgp_default_update_send (peer
, &attr
, afi
, safi
, from
);
2337 aspath_unintern (aspath
);
2341 bgp_announce_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2342 struct bgp_table
*table
, int rsclient
)
2344 struct bgp_node
*rn
;
2345 struct bgp_info
*ri
;
2349 table
= (rsclient
) ? peer
->rib
[afi
][safi
] : peer
->bgp
->rib
[afi
][safi
];
2351 if (safi
!= SAFI_MPLS_VPN
2352 && CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_DEFAULT_ORIGINATE
))
2353 bgp_default_originate (peer
, afi
, safi
, 0);
2355 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next(rn
))
2356 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2357 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
) && ri
->peer
!= peer
)
2360 (bgp_announce_check_rsclient (ri
, peer
, &rn
->p
, &attr
, afi
, safi
))
2361 : (bgp_announce_check (ri
, peer
, &rn
->p
, &attr
, afi
, safi
)))
2362 bgp_adj_out_set (rn
, peer
, &rn
->p
, &attr
, afi
, safi
, ri
);
2364 bgp_adj_out_unset (rn
, peer
, &rn
->p
, afi
, safi
);
2369 bgp_announce_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2371 struct bgp_node
*rn
;
2372 struct bgp_table
*table
;
2374 if (peer
->status
!= Established
)
2377 if (! peer
->afc_nego
[afi
][safi
])
2380 /* First update is deferred until ORF or ROUTE-REFRESH is received */
2381 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_ORF_WAIT_REFRESH
))
2384 if (safi
!= SAFI_MPLS_VPN
)
2385 bgp_announce_table (peer
, afi
, safi
, NULL
, 0);
2387 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2388 rn
= bgp_route_next(rn
))
2389 if ((table
= (rn
->info
)) != NULL
)
2390 bgp_announce_table (peer
, afi
, safi
, table
, 0);
2392 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2393 bgp_announce_table (peer
, afi
, safi
, NULL
, 1);
2397 bgp_announce_route_all (struct peer
*peer
)
2402 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2403 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2404 bgp_announce_route (peer
, afi
, safi
);
2408 bgp_soft_reconfig_table_rsclient (struct peer
*rsclient
, afi_t afi
,
2409 safi_t safi
, struct bgp_table
*table
)
2411 struct bgp_node
*rn
;
2412 struct bgp_adj_in
*ain
;
2415 table
= rsclient
->bgp
->rib
[afi
][safi
];
2417 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2418 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2420 bgp_update_rsclient (rsclient
, afi
, safi
, ain
->attr
, ain
->peer
,
2421 &rn
->p
, ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
2426 bgp_soft_reconfig_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
)
2428 struct bgp_table
*table
;
2429 struct bgp_node
*rn
;
2431 if (safi
!= SAFI_MPLS_VPN
)
2432 bgp_soft_reconfig_table_rsclient (rsclient
, afi
, safi
, NULL
);
2435 for (rn
= bgp_table_top (rsclient
->bgp
->rib
[afi
][safi
]); rn
;
2436 rn
= bgp_route_next (rn
))
2437 if ((table
= rn
->info
) != NULL
)
2438 bgp_soft_reconfig_table_rsclient (rsclient
, afi
, safi
, table
);
2442 bgp_soft_reconfig_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2443 struct bgp_table
*table
)
2446 struct bgp_node
*rn
;
2447 struct bgp_adj_in
*ain
;
2450 table
= peer
->bgp
->rib
[afi
][safi
];
2452 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2453 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2455 if (ain
->peer
== peer
)
2457 ret
= bgp_update (peer
, &rn
->p
, ain
->attr
, afi
, safi
,
2458 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
,
2462 bgp_unlock_node (rn
);
2471 bgp_soft_reconfig_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2473 struct bgp_node
*rn
;
2474 struct bgp_table
*table
;
2476 if (peer
->status
!= Established
)
2479 if (safi
!= SAFI_MPLS_VPN
)
2480 bgp_soft_reconfig_table (peer
, afi
, safi
, NULL
);
2482 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2483 rn
= bgp_route_next (rn
))
2484 if ((table
= rn
->info
) != NULL
)
2485 bgp_soft_reconfig_table (peer
, afi
, safi
, table
);
2488 static wq_item_status
2489 bgp_clear_route_node (struct work_queue
*wq
, void *data
)
2491 struct bgp_node
*rn
= data
;
2492 struct peer
*peer
= wq
->spec
.data
;
2493 struct bgp_adj_in
*ain
;
2494 struct bgp_adj_out
*aout
;
2495 struct bgp_info
*ri
;
2496 afi_t afi
= rn
->table
->afi
;
2497 safi_t safi
= rn
->table
->safi
;
2499 assert (rn
&& peer
);
2501 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2502 if (ri
->peer
== peer
)
2504 /* graceful restart STALE flag set. */
2505 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_NSF_WAIT
)
2506 && peer
->nsf
[afi
][safi
]
2507 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
)
2508 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
2509 bgp_info_set_flag (rn
, ri
, BGP_INFO_STALE
);
2511 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2514 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2515 if (ain
->peer
== peer
)
2517 bgp_adj_in_remove (rn
, ain
);
2518 bgp_unlock_node (rn
);
2521 for (aout
= rn
->adj_out
; aout
; aout
= aout
->next
)
2522 if (aout
->peer
== peer
)
2524 bgp_adj_out_remove (rn
, aout
, peer
, afi
, safi
);
2525 bgp_unlock_node (rn
);
2532 bgp_clear_node_queue_del (struct work_queue
*wq
, void *data
)
2534 struct bgp_node
*rn
= data
;
2536 bgp_unlock_node (rn
);
2540 bgp_clear_node_complete (struct work_queue
*wq
)
2542 struct peer
*peer
= wq
->spec
.data
;
2544 peer_unlock (peer
); /* bgp_clear_node_complete */
2546 /* Tickle FSM to start moving again */
2547 BGP_EVENT_ADD (peer
, Clearing_Completed
);
2551 bgp_clear_node_queue_init (struct peer
*peer
)
2553 #define CLEAR_QUEUE_NAME_LEN 26 /* "clear 2001:123:123:123::1" */
2554 char wname
[CLEAR_QUEUE_NAME_LEN
];
2556 snprintf (wname
, CLEAR_QUEUE_NAME_LEN
, "clear %s", peer
->host
);
2557 #undef CLEAR_QUEUE_NAME_LEN
2559 if ( (peer
->clear_node_queue
= work_queue_new (bm
->master
, wname
)) == NULL
)
2561 zlog_err ("%s: Failed to allocate work queue", __func__
);
2564 peer
->clear_node_queue
->spec
.hold
= 10;
2565 peer
->clear_node_queue
->spec
.workfunc
= &bgp_clear_route_node
;
2566 peer
->clear_node_queue
->spec
.del_item_data
= &bgp_clear_node_queue_del
;
2567 peer
->clear_node_queue
->spec
.completion_func
= &bgp_clear_node_complete
;
2568 peer
->clear_node_queue
->spec
.max_retries
= 0;
2570 /* we only 'lock' this peer reference when the queue is actually active */
2571 peer
->clear_node_queue
->spec
.data
= peer
;
2575 bgp_clear_route_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2576 struct bgp_table
*table
, struct peer
*rsclient
)
2578 struct bgp_node
*rn
;
2581 table
= (rsclient
) ? rsclient
->rib
[afi
][safi
] : peer
->bgp
->rib
[afi
][safi
];
2583 /* If still no table => afi/safi isn't configured at all or smth. */
2587 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2589 if (rn
->info
== NULL
)
2592 bgp_lock_node (rn
); /* unlocked: bgp_clear_node_queue_del */
2593 work_queue_add (peer
->clear_node_queue
, rn
);
2599 bgp_clear_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2601 struct bgp_node
*rn
;
2602 struct bgp_table
*table
;
2603 struct peer
*rsclient
;
2604 struct listnode
*node
, *nnode
;
2606 if (peer
->clear_node_queue
== NULL
)
2607 bgp_clear_node_queue_init (peer
);
2609 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
2610 * Idle until it receives a Clearing_Completed event. This protects
2611 * against peers which flap faster than we can we clear, which could
2614 * a) race with routes from the new session being installed before
2615 * clear_route_node visits the node (to delete the route of that
2617 * b) resource exhaustion, clear_route_node likely leads to an entry
2618 * on the process_main queue. Fast-flapping could cause that queue
2621 if (!peer
->clear_node_queue
->thread
)
2622 peer_lock (peer
); /* bgp_clear_node_complete */
2624 if (safi
!= SAFI_MPLS_VPN
)
2625 bgp_clear_route_table (peer
, afi
, safi
, NULL
, NULL
);
2627 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2628 rn
= bgp_route_next (rn
))
2629 if ((table
= rn
->info
) != NULL
)
2630 bgp_clear_route_table (peer
, afi
, safi
, table
, NULL
);
2632 for (ALL_LIST_ELEMENTS (peer
->bgp
->rsclient
, node
, nnode
, rsclient
))
2634 if (CHECK_FLAG(rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2635 bgp_clear_route_table (peer
, afi
, safi
, NULL
, rsclient
);
2638 /* If no routes were cleared, nothing was added to workqueue, the
2639 * completion function won't be run by workqueue code - call it here.
2641 * Additionally, there is a presumption in FSM that clearing is only
2642 * needed if peer state is Established - peers in pre-Established states
2643 * shouldn't have any route-update state associated with them (in or out).
2645 * We still get here from FSM through bgp_stop->clear_route_all in
2646 * pre-Established though, so this is a useful sanity check to ensure
2647 * the assumption above holds.
2649 * At some future point, this check could be move to the top of the
2650 * function, and do a quick early-return when state is
2651 * pre-Established, avoiding above list and table scans. Once we're
2654 if (!peer
->clear_node_queue
->thread
)
2655 bgp_clear_node_complete (peer
->clear_node_queue
);
2658 /* clearing queue scheduled. Normal if in Established state
2659 * (and about to transition out of it), but otherwise...
2661 if (peer
->status
!= Established
)
2663 plog_err (peer
->log
, "%s [Error] State %s is not Established,"
2664 " but routes were cleared - bug!",
2665 peer
->host
, LOOKUP (bgp_status_msg
, peer
->status
));
2666 assert (peer
->status
== Established
);
2672 bgp_clear_route_all (struct peer
*peer
)
2677 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2678 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2679 bgp_clear_route (peer
, afi
, safi
);
2683 bgp_clear_adj_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2685 struct bgp_table
*table
;
2686 struct bgp_node
*rn
;
2687 struct bgp_adj_in
*ain
;
2689 table
= peer
->bgp
->rib
[afi
][safi
];
2691 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2692 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2693 if (ain
->peer
== peer
)
2695 bgp_adj_in_remove (rn
, ain
);
2696 bgp_unlock_node (rn
);
2702 bgp_clear_stale_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2704 struct bgp_node
*rn
;
2705 struct bgp_info
*ri
;
2706 struct bgp_table
*table
;
2708 table
= peer
->bgp
->rib
[afi
][safi
];
2710 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2712 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2713 if (ri
->peer
== peer
)
2715 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2716 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2722 /* Delete all kernel routes. */
2724 bgp_cleanup_routes ()
2727 struct listnode
*node
, *nnode
;
2728 struct bgp_node
*rn
;
2729 struct bgp_table
*table
;
2730 struct bgp_info
*ri
;
2732 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
2734 table
= bgp
->rib
[AFI_IP
][SAFI_UNICAST
];
2736 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2737 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2738 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
2739 && ri
->type
== ZEBRA_ROUTE_BGP
2740 && ri
->sub_type
== BGP_ROUTE_NORMAL
)
2741 bgp_zebra_withdraw (&rn
->p
, ri
);
2743 table
= bgp
->rib
[AFI_IP6
][SAFI_UNICAST
];
2745 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2746 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2747 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
2748 && ri
->type
== ZEBRA_ROUTE_BGP
2749 && ri
->sub_type
== BGP_ROUTE_NORMAL
)
2750 bgp_zebra_withdraw (&rn
->p
, ri
);
2758 bgp_zclient_reset ();
2759 access_list_reset ();
2760 prefix_list_reset ();
2763 /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
2766 bgp_nlri_parse (struct peer
*peer
, struct attr
*attr
, struct bgp_nlri
*packet
)
2774 /* Check peer status. */
2775 if (peer
->status
!= Established
)
2779 lim
= pnt
+ packet
->length
;
2781 for (; pnt
< lim
; pnt
+= psize
)
2783 /* Clear prefix structure. */
2784 memset (&p
, 0, sizeof (struct prefix
));
2786 /* Fetch prefix length. */
2787 p
.prefixlen
= *pnt
++;
2788 p
.family
= afi2family (packet
->afi
);
2790 /* Already checked in nlri_sanity_check(). We do double check
2792 if ((packet
->afi
== AFI_IP
&& p
.prefixlen
> 32)
2793 || (packet
->afi
== AFI_IP6
&& p
.prefixlen
> 128))
2796 /* Packet size overflow check. */
2797 psize
= PSIZE (p
.prefixlen
);
2799 /* When packet overflow occur return immediately. */
2800 if (pnt
+ psize
> lim
)
2803 /* Fetch prefix from NLRI packet. */
2804 memcpy (&p
.u
.prefix
, pnt
, psize
);
2806 /* Check address. */
2807 if (packet
->afi
== AFI_IP
&& packet
->safi
== SAFI_UNICAST
)
2809 if (IN_CLASSD (ntohl (p
.u
.prefix4
.s_addr
)))
2812 * From draft-ietf-idr-bgp4-22, Section 6.3:
2813 * If a BGP router receives an UPDATE message with a
2814 * semantically incorrect NLRI field, in which a prefix is
2815 * semantically incorrect (eg. an unexpected multicast IP
2816 * address), it should ignore the prefix.
2818 zlog (peer
->log
, LOG_ERR
,
2819 "IPv4 unicast NLRI is multicast address %s",
2820 inet_ntoa (p
.u
.prefix4
));
2827 /* Check address. */
2828 if (packet
->afi
== AFI_IP6
&& packet
->safi
== SAFI_UNICAST
)
2830 if (IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
2834 zlog (peer
->log
, LOG_WARNING
,
2835 "IPv6 link-local NLRI received %s ignore this NLRI",
2836 inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
2841 #endif /* HAVE_IPV6 */
2843 /* Normal process. */
2845 ret
= bgp_update (peer
, &p
, attr
, packet
->afi
, packet
->safi
,
2846 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
2848 ret
= bgp_withdraw (peer
, &p
, attr
, packet
->afi
, packet
->safi
,
2849 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
2851 /* Address family configuration mismatch or maximum-prefix count
2857 /* Packet length consistency check. */
2864 /* NLRI encode syntax check routine. */
2866 bgp_nlri_sanity_check (struct peer
*peer
, int afi
, u_char
*pnt
,
2875 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
2876 syntactic validity. If the field is syntactically incorrect,
2877 then the Error Subcode is set to Invalid Network Field. */
2883 /* Prefix length check. */
2884 if ((afi
== AFI_IP
&& prefixlen
> 32)
2885 || (afi
== AFI_IP6
&& prefixlen
> 128))
2887 plog_err (peer
->log
,
2888 "%s [Error] Update packet error (wrong prefix length %d)",
2889 peer
->host
, prefixlen
);
2890 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
2891 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
2895 /* Packet size overflow check. */
2896 psize
= PSIZE (prefixlen
);
2898 if (pnt
+ psize
> end
)
2900 plog_err (peer
->log
,
2901 "%s [Error] Update packet error"
2902 " (prefix data overflow prefix size is %d)",
2904 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
2905 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
2912 /* Packet length consistency check. */
2915 plog_err (peer
->log
,
2916 "%s [Error] Update packet error"
2917 " (prefix length mismatch with total length)",
2919 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
2920 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
2926 static struct bgp_static
*
2929 struct bgp_static
*new;
2930 new = XMALLOC (MTYPE_BGP_STATIC
, sizeof (struct bgp_static
));
2931 memset (new, 0, sizeof (struct bgp_static
));
2936 bgp_static_free (struct bgp_static
*bgp_static
)
2938 if (bgp_static
->rmap
.name
)
2939 free (bgp_static
->rmap
.name
);
2940 XFREE (MTYPE_BGP_STATIC
, bgp_static
);
2944 bgp_static_withdraw_rsclient (struct bgp
*bgp
, struct peer
*rsclient
,
2945 struct prefix
*p
, afi_t afi
, safi_t safi
)
2947 struct bgp_node
*rn
;
2948 struct bgp_info
*ri
;
2950 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
2952 /* Check selected route and self inserted route. */
2953 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2954 if (ri
->peer
== bgp
->peer_self
2955 && ri
->type
== ZEBRA_ROUTE_BGP
2956 && ri
->sub_type
== BGP_ROUTE_STATIC
)
2959 /* Withdraw static BGP route from routing table. */
2962 bgp_info_delete (rn
, ri
);
2963 bgp_process (bgp
, rn
, afi
, safi
);
2966 /* Unlock bgp_node_lookup. */
2967 bgp_unlock_node (rn
);
2971 bgp_static_update_rsclient (struct peer
*rsclient
, struct prefix
*p
,
2972 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
2974 struct bgp_node
*rn
;
2975 struct bgp_info
*ri
;
2976 struct bgp_info
*new;
2977 struct bgp_info info
;
2978 struct attr new_attr
;
2979 struct attr
*attr_new
;
2983 char buf
[SU_ADDRSTRLEN
];
2985 bgp
= rsclient
->bgp
;
2987 assert (bgp_static
);
2991 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
2993 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
2995 attr
.nexthop
= bgp_static
->igpnexthop
;
2996 attr
.med
= bgp_static
->igpmetric
;
2997 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3001 /* Apply network route-map for export to this rsclient. */
3002 if (bgp_static
->rmap
.name
)
3004 info
.peer
= rsclient
;
3005 info
.attr
= &new_attr
;
3007 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_EXPORT
);
3008 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3010 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3012 rsclient
->rmap_type
= 0;
3014 if (ret
== RMAP_DENYMATCH
)
3016 /* Free uninterned attribute. */
3017 bgp_attr_flush (&new_attr
);
3019 /* Unintern original. */
3020 aspath_unintern (attr
.aspath
);
3021 bgp_static_withdraw_rsclient (bgp
, rsclient
, p
, afi
, safi
);
3025 attr_new
= bgp_attr_intern (&new_attr
);
3028 attr_new
= bgp_attr_intern (&attr
);
3030 new_attr
= *attr_new
;
3032 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3034 if (bgp_import_modifier (rsclient
, bgp
->peer_self
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
3036 /* This BGP update is filtered. Log the reason then update BGP entry. */
3037 if (BGP_DEBUG (update
, UPDATE_IN
))
3038 zlog (rsclient
->log
, LOG_DEBUG
,
3039 "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
3040 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
3041 p
->prefixlen
, rsclient
->host
);
3043 bgp
->peer_self
->rmap_type
= 0;
3045 bgp_attr_unintern (attr_new
);
3046 aspath_unintern (attr
.aspath
);
3048 bgp_static_withdraw_rsclient (bgp
, rsclient
, p
, afi
, safi
);
3053 bgp
->peer_self
->rmap_type
= 0;
3055 bgp_attr_unintern (attr_new
);
3056 attr_new
= bgp_attr_intern (&new_attr
);
3058 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3059 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3060 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3065 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3066 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3068 bgp_unlock_node (rn
);
3069 bgp_attr_unintern (attr_new
);
3070 aspath_unintern (attr
.aspath
);
3075 /* The attribute is changed. */
3076 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3078 /* Rewrite BGP route information. */
3079 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3080 bgp_info_restore(rn
, ri
);
3081 bgp_attr_unintern (ri
->attr
);
3082 ri
->attr
= attr_new
;
3083 ri
->uptime
= time (NULL
);
3085 /* Process change. */
3086 bgp_process (bgp
, rn
, afi
, safi
);
3087 bgp_unlock_node (rn
);
3088 aspath_unintern (attr
.aspath
);
3093 /* Make new BGP info. */
3094 new = bgp_info_new ();
3095 new->type
= ZEBRA_ROUTE_BGP
;
3096 new->sub_type
= BGP_ROUTE_STATIC
;
3097 new->peer
= bgp
->peer_self
;
3098 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3099 new->attr
= attr_new
;
3100 new->uptime
= time (NULL
);
3102 /* Register new BGP information. */
3103 bgp_info_add (rn
, new);
3105 /* route_node_get lock */
3106 bgp_unlock_node (rn
);
3108 /* Process change. */
3109 bgp_process (bgp
, rn
, afi
, safi
);
3111 /* Unintern original. */
3112 aspath_unintern (attr
.aspath
);
3116 bgp_static_update_main (struct bgp
*bgp
, struct prefix
*p
,
3117 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3119 struct bgp_node
*rn
;
3120 struct bgp_info
*ri
;
3121 struct bgp_info
*new;
3122 struct bgp_info info
;
3124 struct attr attr_tmp
;
3125 struct attr
*attr_new
;
3128 assert (bgp_static
);
3132 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3134 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3136 attr
.nexthop
= bgp_static
->igpnexthop
;
3137 attr
.med
= bgp_static
->igpmetric
;
3138 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3140 /* Apply route-map. */
3141 if (bgp_static
->rmap
.name
)
3144 info
.peer
= bgp
->peer_self
;
3145 info
.attr
= &attr_tmp
;
3147 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3149 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3151 bgp
->peer_self
->rmap_type
= 0;
3153 if (ret
== RMAP_DENYMATCH
)
3155 /* Free uninterned attribute. */
3156 bgp_attr_flush (&attr_tmp
);
3158 /* Unintern original. */
3159 aspath_unintern (attr
.aspath
);
3160 bgp_static_withdraw (bgp
, p
, afi
, safi
);
3163 attr_new
= bgp_attr_intern (&attr_tmp
);
3166 attr_new
= bgp_attr_intern (&attr
);
3168 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3169 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3170 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3175 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3176 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3178 bgp_unlock_node (rn
);
3179 bgp_attr_unintern (attr_new
);
3180 aspath_unintern (attr
.aspath
);
3185 /* The attribute is changed. */
3186 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3188 /* Rewrite BGP route information. */
3189 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3190 bgp_info_restore(rn
, ri
);
3192 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3193 bgp_attr_unintern (ri
->attr
);
3194 ri
->attr
= attr_new
;
3195 ri
->uptime
= time (NULL
);
3197 /* Process change. */
3198 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3199 bgp_process (bgp
, rn
, afi
, safi
);
3200 bgp_unlock_node (rn
);
3201 aspath_unintern (attr
.aspath
);
3206 /* Make new BGP info. */
3207 new = bgp_info_new ();
3208 new->type
= ZEBRA_ROUTE_BGP
;
3209 new->sub_type
= BGP_ROUTE_STATIC
;
3210 new->peer
= bgp
->peer_self
;
3211 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3212 new->attr
= attr_new
;
3213 new->uptime
= time (NULL
);
3215 /* Aggregate address increment. */
3216 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3218 /* Register new BGP information. */
3219 bgp_info_add (rn
, new);
3221 /* route_node_get lock */
3222 bgp_unlock_node (rn
);
3224 /* Process change. */
3225 bgp_process (bgp
, rn
, afi
, safi
);
3227 /* Unintern original. */
3228 aspath_unintern (attr
.aspath
);
3232 bgp_static_update (struct bgp
*bgp
, struct prefix
*p
,
3233 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3235 struct peer
*rsclient
;
3236 struct listnode
*node
, *nnode
;
3238 bgp_static_update_main (bgp
, p
, bgp_static
, afi
, safi
);
3240 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
3242 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
3243 bgp_static_update_rsclient (rsclient
, p
, bgp_static
, afi
, safi
);
3248 bgp_static_update_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, u_int16_t afi
,
3249 u_char safi
, struct prefix_rd
*prd
, u_char
*tag
)
3251 struct bgp_node
*rn
;
3252 struct bgp_info
*new;
3254 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3256 /* Make new BGP info. */
3257 new = bgp_info_new ();
3258 new->type
= ZEBRA_ROUTE_BGP
;
3259 new->sub_type
= BGP_ROUTE_STATIC
;
3260 new->peer
= bgp
->peer_self
;
3261 new->attr
= bgp_attr_default_intern (BGP_ORIGIN_IGP
);
3262 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3263 new->uptime
= time (NULL
);
3264 memcpy (new->tag
, tag
, 3);
3266 /* Aggregate address increment. */
3267 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3269 /* Register new BGP information. */
3270 bgp_info_add (rn
, new);
3272 /* route_node_get lock */
3273 bgp_unlock_node (rn
);
3275 /* Process change. */
3276 bgp_process (bgp
, rn
, afi
, safi
);
3280 bgp_static_withdraw (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3283 struct bgp_node
*rn
;
3284 struct bgp_info
*ri
;
3286 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3288 /* Check selected route and self inserted route. */
3289 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3290 if (ri
->peer
== bgp
->peer_self
3291 && ri
->type
== ZEBRA_ROUTE_BGP
3292 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3295 /* Withdraw static BGP route from routing table. */
3298 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3299 bgp_info_delete (rn
, ri
);
3300 bgp_process (bgp
, rn
, afi
, safi
);
3303 /* Unlock bgp_node_lookup. */
3304 bgp_unlock_node (rn
);
3308 bgp_check_local_routes_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
)
3310 struct bgp_static
*bgp_static
;
3312 struct bgp_node
*rn
;
3315 bgp
= rsclient
->bgp
;
3317 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3318 if ((bgp_static
= rn
->info
) != NULL
)
3322 bgp_static_update_rsclient (rsclient
, p
, bgp_static
,
3328 bgp_static_withdraw_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, u_int16_t afi
,
3329 u_char safi
, struct prefix_rd
*prd
, u_char
*tag
)
3331 struct bgp_node
*rn
;
3332 struct bgp_info
*ri
;
3334 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3336 /* Check selected route and self inserted route. */
3337 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3338 if (ri
->peer
== bgp
->peer_self
3339 && ri
->type
== ZEBRA_ROUTE_BGP
3340 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3343 /* Withdraw static BGP route from routing table. */
3346 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3347 bgp_info_delete (rn
, ri
);
3348 bgp_process (bgp
, rn
, afi
, safi
);
3351 /* Unlock bgp_node_lookup. */
3352 bgp_unlock_node (rn
);
3355 /* Configure static BGP network. When user don't run zebra, static
3356 route should be installed as valid. */
3358 bgp_static_set (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3359 u_int16_t afi
, u_char safi
, const char *rmap
, int backdoor
)
3363 struct bgp_static
*bgp_static
;
3364 struct bgp_node
*rn
;
3365 int need_update
= 0;
3367 /* Convert IP prefix string to struct prefix. */
3368 ret
= str2prefix (ip_str
, &p
);
3371 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3375 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3377 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3381 #endif /* HAVE_IPV6 */
3385 /* Set BGP static route configuration. */
3386 rn
= bgp_node_get (bgp
->route
[afi
][safi
], &p
);
3390 /* Configuration change. */
3391 bgp_static
= rn
->info
;
3393 /* Check previous routes are installed into BGP. */
3394 if (! bgp_static
->backdoor
&& bgp_static
->valid
)
3397 bgp_static
->backdoor
= backdoor
;
3400 if (bgp_static
->rmap
.name
)
3401 free (bgp_static
->rmap
.name
);
3402 bgp_static
->rmap
.name
= strdup (rmap
);
3403 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3407 if (bgp_static
->rmap
.name
)
3408 free (bgp_static
->rmap
.name
);
3409 bgp_static
->rmap
.name
= NULL
;
3410 bgp_static
->rmap
.map
= NULL
;
3411 bgp_static
->valid
= 0;
3413 bgp_unlock_node (rn
);
3417 /* New configuration. */
3418 bgp_static
= bgp_static_new ();
3419 bgp_static
->backdoor
= backdoor
;
3420 bgp_static
->valid
= 0;
3421 bgp_static
->igpmetric
= 0;
3422 bgp_static
->igpnexthop
.s_addr
= 0;
3425 if (bgp_static
->rmap
.name
)
3426 free (bgp_static
->rmap
.name
);
3427 bgp_static
->rmap
.name
= strdup (rmap
);
3428 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3430 rn
->info
= bgp_static
;
3433 /* If BGP scan is not enabled, we should install this route here. */
3434 if (! bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3436 bgp_static
->valid
= 1;
3439 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3441 if (! bgp_static
->backdoor
)
3442 bgp_static_update (bgp
, &p
, bgp_static
, afi
, safi
);
3448 /* Configure static BGP network. */
3450 bgp_static_unset (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3451 u_int16_t afi
, u_char safi
)
3455 struct bgp_static
*bgp_static
;
3456 struct bgp_node
*rn
;
3458 /* Convert IP prefix string to struct prefix. */
3459 ret
= str2prefix (ip_str
, &p
);
3462 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3466 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3468 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3472 #endif /* HAVE_IPV6 */
3476 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], &p
);
3479 vty_out (vty
, "%% Can't find specified static route configuration.%s",
3484 bgp_static
= rn
->info
;
3486 /* Update BGP RIB. */
3487 if (! bgp_static
->backdoor
)
3488 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3490 /* Clear configuration. */
3491 bgp_static_free (bgp_static
);
3493 bgp_unlock_node (rn
);
3494 bgp_unlock_node (rn
);
3499 /* Called from bgp_delete(). Delete all static routes from the BGP
3502 bgp_static_delete (struct bgp
*bgp
)
3506 struct bgp_node
*rn
;
3507 struct bgp_node
*rm
;
3508 struct bgp_table
*table
;
3509 struct bgp_static
*bgp_static
;
3511 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3512 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3513 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3514 if (rn
->info
!= NULL
)
3516 if (safi
== SAFI_MPLS_VPN
)
3520 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
3522 bgp_static
= rn
->info
;
3523 bgp_static_withdraw_vpnv4 (bgp
, &rm
->p
,
3524 AFI_IP
, SAFI_MPLS_VPN
,
3525 (struct prefix_rd
*)&rn
->p
,
3527 bgp_static_free (bgp_static
);
3529 bgp_unlock_node (rn
);
3534 bgp_static
= rn
->info
;
3535 bgp_static_withdraw (bgp
, &rn
->p
, afi
, safi
);
3536 bgp_static_free (bgp_static
);
3538 bgp_unlock_node (rn
);
3544 bgp_static_set_vpnv4 (struct vty
*vty
, const char *ip_str
, const char *rd_str
,
3545 const char *tag_str
)
3549 struct prefix_rd prd
;
3551 struct bgp_node
*prn
;
3552 struct bgp_node
*rn
;
3553 struct bgp_table
*table
;
3554 struct bgp_static
*bgp_static
;
3559 ret
= str2prefix (ip_str
, &p
);
3562 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3567 ret
= str2prefix_rd (rd_str
, &prd
);
3570 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3574 ret
= str2tag (tag_str
, tag
);
3577 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3581 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3582 (struct prefix
*)&prd
);
3583 if (prn
->info
== NULL
)
3584 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3586 bgp_unlock_node (prn
);
3589 rn
= bgp_node_get (table
, &p
);
3593 vty_out (vty
, "%% Same network configuration exists%s", VTY_NEWLINE
);
3594 bgp_unlock_node (rn
);
3598 /* New configuration. */
3599 bgp_static
= bgp_static_new ();
3600 bgp_static
->valid
= 1;
3601 memcpy (bgp_static
->tag
, tag
, 3);
3602 rn
->info
= bgp_static
;
3604 bgp_static_update_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3610 /* Configure static BGP network. */
3612 bgp_static_unset_vpnv4 (struct vty
*vty
, const char *ip_str
,
3613 const char *rd_str
, const char *tag_str
)
3618 struct prefix_rd prd
;
3619 struct bgp_node
*prn
;
3620 struct bgp_node
*rn
;
3621 struct bgp_table
*table
;
3622 struct bgp_static
*bgp_static
;
3627 /* Convert IP prefix string to struct prefix. */
3628 ret
= str2prefix (ip_str
, &p
);
3631 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3636 ret
= str2prefix_rd (rd_str
, &prd
);
3639 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3643 ret
= str2tag (tag_str
, tag
);
3646 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3650 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3651 (struct prefix
*)&prd
);
3652 if (prn
->info
== NULL
)
3653 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3655 bgp_unlock_node (prn
);
3658 rn
= bgp_node_lookup (table
, &p
);
3662 bgp_static_withdraw_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3664 bgp_static
= rn
->info
;
3665 bgp_static_free (bgp_static
);
3667 bgp_unlock_node (rn
);
3668 bgp_unlock_node (rn
);
3671 vty_out (vty
, "%% Can't find the route%s", VTY_NEWLINE
);
3678 "network A.B.C.D/M",
3679 "Specify a network to announce via BGP\n"
3680 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
3682 return bgp_static_set (vty
, vty
->index
, argv
[0],
3683 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
3686 DEFUN (bgp_network_route_map
,
3687 bgp_network_route_map_cmd
,
3688 "network A.B.C.D/M route-map WORD",
3689 "Specify a network to announce via BGP\n"
3690 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3691 "Route-map to modify the attributes\n"
3692 "Name of the route map\n")
3694 return bgp_static_set (vty
, vty
->index
, argv
[0],
3695 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
3698 DEFUN (bgp_network_backdoor
,
3699 bgp_network_backdoor_cmd
,
3700 "network A.B.C.D/M backdoor",
3701 "Specify a network to announce via BGP\n"
3702 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3703 "Specify a BGP backdoor route\n")
3705 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
3708 DEFUN (bgp_network_mask
,
3709 bgp_network_mask_cmd
,
3710 "network A.B.C.D mask A.B.C.D",
3711 "Specify a network to announce via BGP\n"
3717 char prefix_str
[BUFSIZ
];
3719 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3722 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3726 return bgp_static_set (vty
, vty
->index
, prefix_str
,
3727 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
3730 DEFUN (bgp_network_mask_route_map
,
3731 bgp_network_mask_route_map_cmd
,
3732 "network A.B.C.D mask A.B.C.D route-map WORD",
3733 "Specify a network to announce via BGP\n"
3737 "Route-map to modify the attributes\n"
3738 "Name of the route map\n")
3741 char prefix_str
[BUFSIZ
];
3743 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3746 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3750 return bgp_static_set (vty
, vty
->index
, prefix_str
,
3751 AFI_IP
, bgp_node_safi (vty
), argv
[2], 0);
3754 DEFUN (bgp_network_mask_backdoor
,
3755 bgp_network_mask_backdoor_cmd
,
3756 "network A.B.C.D mask A.B.C.D backdoor",
3757 "Specify a network to announce via BGP\n"
3761 "Specify a BGP backdoor route\n")
3764 char prefix_str
[BUFSIZ
];
3766 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3769 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3773 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
, NULL
, 1);
3776 DEFUN (bgp_network_mask_natural
,
3777 bgp_network_mask_natural_cmd
,
3779 "Specify a network to announce via BGP\n"
3783 char prefix_str
[BUFSIZ
];
3785 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
3788 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3792 return bgp_static_set (vty
, vty
->index
, prefix_str
,
3793 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
3796 DEFUN (bgp_network_mask_natural_route_map
,
3797 bgp_network_mask_natural_route_map_cmd
,
3798 "network A.B.C.D route-map WORD",
3799 "Specify a network to announce via BGP\n"
3801 "Route-map to modify the attributes\n"
3802 "Name of the route map\n")
3805 char prefix_str
[BUFSIZ
];
3807 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
3810 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3814 return bgp_static_set (vty
, vty
->index
, prefix_str
,
3815 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
3818 DEFUN (bgp_network_mask_natural_backdoor
,
3819 bgp_network_mask_natural_backdoor_cmd
,
3820 "network A.B.C.D backdoor",
3821 "Specify a network to announce via BGP\n"
3823 "Specify a BGP backdoor route\n")
3826 char prefix_str
[BUFSIZ
];
3828 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
3831 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3835 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
, NULL
, 1);
3838 DEFUN (no_bgp_network
,
3840 "no network A.B.C.D/M",
3842 "Specify a network to announce via BGP\n"
3843 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
3845 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP
,
3846 bgp_node_safi (vty
));
3849 ALIAS (no_bgp_network
,
3850 no_bgp_network_route_map_cmd
,
3851 "no network A.B.C.D/M route-map WORD",
3853 "Specify a network to announce via BGP\n"
3854 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3855 "Route-map to modify the attributes\n"
3856 "Name of the route map\n")
3858 ALIAS (no_bgp_network
,
3859 no_bgp_network_backdoor_cmd
,
3860 "no network A.B.C.D/M backdoor",
3862 "Specify a network to announce via BGP\n"
3863 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3864 "Specify a BGP backdoor route\n")
3866 DEFUN (no_bgp_network_mask
,
3867 no_bgp_network_mask_cmd
,
3868 "no network A.B.C.D mask A.B.C.D",
3870 "Specify a network to announce via BGP\n"
3876 char prefix_str
[BUFSIZ
];
3878 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3881 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3885 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
3886 bgp_node_safi (vty
));
3889 ALIAS (no_bgp_network_mask
,
3890 no_bgp_network_mask_route_map_cmd
,
3891 "no network A.B.C.D mask A.B.C.D route-map WORD",
3893 "Specify a network to announce via BGP\n"
3897 "Route-map to modify the attributes\n"
3898 "Name of the route map\n")
3900 ALIAS (no_bgp_network_mask
,
3901 no_bgp_network_mask_backdoor_cmd
,
3902 "no network A.B.C.D mask A.B.C.D backdoor",
3904 "Specify a network to announce via BGP\n"
3908 "Specify a BGP backdoor route\n")
3910 DEFUN (no_bgp_network_mask_natural
,
3911 no_bgp_network_mask_natural_cmd
,
3912 "no network A.B.C.D",
3914 "Specify a network to announce via BGP\n"
3918 char prefix_str
[BUFSIZ
];
3920 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
3923 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3927 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
3928 bgp_node_safi (vty
));
3931 ALIAS (no_bgp_network_mask_natural
,
3932 no_bgp_network_mask_natural_route_map_cmd
,
3933 "no network A.B.C.D route-map WORD",
3935 "Specify a network to announce via BGP\n"
3937 "Route-map to modify the attributes\n"
3938 "Name of the route map\n")
3940 ALIAS (no_bgp_network_mask_natural
,
3941 no_bgp_network_mask_natural_backdoor_cmd
,
3942 "no network A.B.C.D backdoor",
3944 "Specify a network to announce via BGP\n"
3946 "Specify a BGP backdoor route\n")
3949 DEFUN (ipv6_bgp_network
,
3950 ipv6_bgp_network_cmd
,
3951 "network X:X::X:X/M",
3952 "Specify a network to announce via BGP\n"
3953 "IPv6 prefix <network>/<length>\n")
3955 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
3958 DEFUN (ipv6_bgp_network_route_map
,
3959 ipv6_bgp_network_route_map_cmd
,
3960 "network X:X::X:X/M route-map WORD",
3961 "Specify a network to announce via BGP\n"
3962 "IPv6 prefix <network>/<length>\n"
3963 "Route-map to modify the attributes\n"
3964 "Name of the route map\n")
3966 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
,
3967 bgp_node_safi (vty
), argv
[1], 0);
3970 DEFUN (no_ipv6_bgp_network
,
3971 no_ipv6_bgp_network_cmd
,
3972 "no network X:X::X:X/M",
3974 "Specify a network to announce via BGP\n"
3975 "IPv6 prefix <network>/<length>\n")
3977 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
3980 ALIAS (no_ipv6_bgp_network
,
3981 no_ipv6_bgp_network_route_map_cmd
,
3982 "no network X:X::X:X/M route-map WORD",
3984 "Specify a network to announce via BGP\n"
3985 "IPv6 prefix <network>/<length>\n"
3986 "Route-map to modify the attributes\n"
3987 "Name of the route map\n")
3989 ALIAS (ipv6_bgp_network
,
3990 old_ipv6_bgp_network_cmd
,
3991 "ipv6 bgp network X:X::X:X/M",
3994 "Specify a network to announce via BGP\n"
3995 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
3997 ALIAS (no_ipv6_bgp_network
,
3998 old_no_ipv6_bgp_network_cmd
,
3999 "no ipv6 bgp network X:X::X:X/M",
4003 "Specify a network to announce via BGP\n"
4004 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4005 #endif /* HAVE_IPV6 */
4007 /* Aggreagete address:
4009 advertise-map Set condition to advertise attribute
4010 as-set Generate AS set path information
4011 attribute-map Set attributes of aggregate
4012 route-map Set parameters of aggregate
4013 summary-only Filter more specific routes from updates
4014 suppress-map Conditionally filter more specific routes from updates
4017 struct bgp_aggregate
4019 /* Summary-only flag. */
4020 u_char summary_only
;
4022 /* AS set generation. */
4025 /* Route-map for aggregated route. */
4026 struct route_map
*map
;
4028 /* Suppress-count. */
4029 unsigned long count
;
4031 /* SAFI configuration. */
4035 static struct bgp_aggregate
*
4036 bgp_aggregate_new ()
4038 struct bgp_aggregate
*new;
4039 new = XMALLOC (MTYPE_BGP_AGGREGATE
, sizeof (struct bgp_aggregate
));
4040 memset (new, 0, sizeof (struct bgp_aggregate
));
4045 bgp_aggregate_free (struct bgp_aggregate
*aggregate
)
4047 XFREE (MTYPE_BGP_AGGREGATE
, aggregate
);
4051 bgp_aggregate_route (struct bgp
*bgp
, struct prefix
*p
, struct bgp_info
*rinew
,
4052 afi_t afi
, safi_t safi
, struct bgp_info
*del
,
4053 struct bgp_aggregate
*aggregate
)
4055 struct bgp_table
*table
;
4056 struct bgp_node
*top
;
4057 struct bgp_node
*rn
;
4059 struct aspath
*aspath
= NULL
;
4060 struct aspath
*asmerge
= NULL
;
4061 struct community
*community
= NULL
;
4062 struct community
*commerge
= NULL
;
4063 struct in_addr nexthop
;
4065 struct bgp_info
*ri
;
4066 struct bgp_info
*new;
4068 unsigned long match
= 0;
4070 /* Record adding route's nexthop and med. */
4073 nexthop
= rinew
->attr
->nexthop
;
4074 med
= rinew
->attr
->med
;
4077 /* ORIGIN attribute: If at least one route among routes that are
4078 aggregated has ORIGIN with the value INCOMPLETE, then the
4079 aggregated route must have the ORIGIN attribute with the value
4080 INCOMPLETE. Otherwise, if at least one route among routes that
4081 are aggregated has ORIGIN with the value EGP, then the aggregated
4082 route must have the origin attribute with the value EGP. In all
4083 other case the value of the ORIGIN attribute of the aggregated
4084 route is INTERNAL. */
4085 origin
= BGP_ORIGIN_IGP
;
4087 table
= bgp
->rib
[afi
][safi
];
4089 top
= bgp_node_get (table
, p
);
4090 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4091 if (rn
->p
.prefixlen
> p
->prefixlen
)
4095 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4097 if (BGP_INFO_HOLDDOWN (ri
))
4100 if (del
&& ri
== del
)
4103 if (! rinew
&& first
)
4105 nexthop
= ri
->attr
->nexthop
;
4106 med
= ri
->attr
->med
;
4110 #ifdef AGGREGATE_NEXTHOP_CHECK
4111 if (! IPV4_ADDR_SAME (&ri
->attr
->nexthop
, &nexthop
)
4112 || ri
->attr
->med
!= med
)
4115 aspath_free (aspath
);
4117 community_free (community
);
4118 bgp_unlock_node (rn
);
4119 bgp_unlock_node (top
);
4122 #endif /* AGGREGATE_NEXTHOP_CHECK */
4124 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4126 if (aggregate
->summary_only
)
4129 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4135 if (aggregate
->as_set
)
4137 if (origin
< ri
->attr
->origin
)
4138 origin
= ri
->attr
->origin
;
4142 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4143 aspath_free (aspath
);
4147 aspath
= aspath_dup (ri
->attr
->aspath
);
4149 if (ri
->attr
->community
)
4153 commerge
= community_merge (community
,
4154 ri
->attr
->community
);
4155 community
= community_uniq_sort (commerge
);
4156 community_free (commerge
);
4159 community
= community_dup (ri
->attr
->community
);
4165 bgp_process (bgp
, rn
, afi
, safi
);
4167 bgp_unlock_node (top
);
4173 if (aggregate
->summary_only
)
4176 if (aggregate
->as_set
)
4178 if (origin
< rinew
->attr
->origin
)
4179 origin
= rinew
->attr
->origin
;
4183 asmerge
= aspath_aggregate (aspath
, rinew
->attr
->aspath
);
4184 aspath_free (aspath
);
4188 aspath
= aspath_dup (rinew
->attr
->aspath
);
4190 if (rinew
->attr
->community
)
4194 commerge
= community_merge (community
,
4195 rinew
->attr
->community
);
4196 community
= community_uniq_sort (commerge
);
4197 community_free (commerge
);
4200 community
= community_dup (rinew
->attr
->community
);
4205 if (aggregate
->count
> 0)
4207 rn
= bgp_node_get (table
, p
);
4208 new = bgp_info_new ();
4209 new->type
= ZEBRA_ROUTE_BGP
;
4210 new->sub_type
= BGP_ROUTE_AGGREGATE
;
4211 new->peer
= bgp
->peer_self
;
4212 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4213 new->attr
= bgp_attr_aggregate_intern (bgp
, origin
, aspath
, community
, aggregate
->as_set
);
4214 new->uptime
= time (NULL
);
4216 bgp_info_add (rn
, new);
4217 bgp_unlock_node (rn
);
4218 bgp_process (bgp
, rn
, afi
, safi
);
4223 aspath_free (aspath
);
4225 community_free (community
);
4229 void bgp_aggregate_delete (struct bgp
*, struct prefix
*, afi_t
, safi_t
,
4230 struct bgp_aggregate
*);
4233 bgp_aggregate_increment (struct bgp
*bgp
, struct prefix
*p
,
4234 struct bgp_info
*ri
, afi_t afi
, safi_t safi
)
4236 struct bgp_node
*child
;
4237 struct bgp_node
*rn
;
4238 struct bgp_aggregate
*aggregate
;
4240 /* MPLS-VPN aggregation is not yet supported. */
4241 if (safi
== SAFI_MPLS_VPN
)
4244 if (p
->prefixlen
== 0)
4247 if (BGP_INFO_HOLDDOWN (ri
))
4250 child
= bgp_node_get (bgp
->aggregate
[afi
][safi
], p
);
4252 /* Aggregate address configuration check. */
4253 for (rn
= child
; rn
; rn
= rn
->parent
)
4254 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4256 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4257 bgp_aggregate_route (bgp
, &rn
->p
, ri
, afi
, safi
, NULL
, aggregate
);
4259 bgp_unlock_node (child
);
4263 bgp_aggregate_decrement (struct bgp
*bgp
, struct prefix
*p
,
4264 struct bgp_info
*del
, afi_t afi
, safi_t safi
)
4266 struct bgp_node
*child
;
4267 struct bgp_node
*rn
;
4268 struct bgp_aggregate
*aggregate
;
4270 /* MPLS-VPN aggregation is not yet supported. */
4271 if (safi
== SAFI_MPLS_VPN
)
4274 if (p
->prefixlen
== 0)
4277 child
= bgp_node_get (bgp
->aggregate
[afi
][safi
], p
);
4279 /* Aggregate address configuration check. */
4280 for (rn
= child
; rn
; rn
= rn
->parent
)
4281 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4283 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4284 bgp_aggregate_route (bgp
, &rn
->p
, NULL
, afi
, safi
, del
, aggregate
);
4286 bgp_unlock_node (child
);
4290 bgp_aggregate_add (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
, safi_t safi
,
4291 struct bgp_aggregate
*aggregate
)
4293 struct bgp_table
*table
;
4294 struct bgp_node
*top
;
4295 struct bgp_node
*rn
;
4296 struct bgp_info
*new;
4297 struct bgp_info
*ri
;
4298 unsigned long match
;
4299 u_char origin
= BGP_ORIGIN_IGP
;
4300 struct aspath
*aspath
= NULL
;
4301 struct aspath
*asmerge
= NULL
;
4302 struct community
*community
= NULL
;
4303 struct community
*commerge
= NULL
;
4305 table
= bgp
->rib
[afi
][safi
];
4308 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4310 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4313 /* If routes exists below this node, generate aggregate routes. */
4314 top
= bgp_node_get (table
, p
);
4315 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4316 if (rn
->p
.prefixlen
> p
->prefixlen
)
4320 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4322 if (BGP_INFO_HOLDDOWN (ri
))
4325 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4327 /* summary-only aggregate route suppress aggregated
4328 route announcement. */
4329 if (aggregate
->summary_only
)
4332 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4335 /* as-set aggregate route generate origin, as path,
4336 community aggregation. */
4337 if (aggregate
->as_set
)
4339 if (origin
< ri
->attr
->origin
)
4340 origin
= ri
->attr
->origin
;
4344 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4345 aspath_free (aspath
);
4349 aspath
= aspath_dup (ri
->attr
->aspath
);
4351 if (ri
->attr
->community
)
4355 commerge
= community_merge (community
,
4356 ri
->attr
->community
);
4357 community
= community_uniq_sort (commerge
);
4358 community_free (commerge
);
4361 community
= community_dup (ri
->attr
->community
);
4368 /* If this node is suppressed, process the change. */
4370 bgp_process (bgp
, rn
, afi
, safi
);
4372 bgp_unlock_node (top
);
4374 /* Add aggregate route to BGP table. */
4375 if (aggregate
->count
)
4377 rn
= bgp_node_get (table
, p
);
4379 new = bgp_info_new ();
4380 new->type
= ZEBRA_ROUTE_BGP
;
4381 new->sub_type
= BGP_ROUTE_AGGREGATE
;
4382 new->peer
= bgp
->peer_self
;
4383 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4384 new->attr
= bgp_attr_aggregate_intern (bgp
, origin
, aspath
, community
, aggregate
->as_set
);
4385 new->uptime
= time (NULL
);
4387 bgp_info_add (rn
, new);
4388 bgp_unlock_node (rn
);
4390 /* Process change. */
4391 bgp_process (bgp
, rn
, afi
, safi
);
4396 bgp_aggregate_delete (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
4397 safi_t safi
, struct bgp_aggregate
*aggregate
)
4399 struct bgp_table
*table
;
4400 struct bgp_node
*top
;
4401 struct bgp_node
*rn
;
4402 struct bgp_info
*ri
;
4403 unsigned long match
;
4405 table
= bgp
->rib
[afi
][safi
];
4407 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4409 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4412 /* If routes exists below this node, generate aggregate routes. */
4413 top
= bgp_node_get (table
, p
);
4414 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4415 if (rn
->p
.prefixlen
> p
->prefixlen
)
4419 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4421 if (BGP_INFO_HOLDDOWN (ri
))
4424 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4426 if (aggregate
->summary_only
)
4430 if (ri
->suppress
== 0)
4432 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4440 /* If this node is suppressed, process the change. */
4442 bgp_process (bgp
, rn
, afi
, safi
);
4444 bgp_unlock_node (top
);
4446 /* Delete aggregate route from BGP table. */
4447 rn
= bgp_node_get (table
, p
);
4449 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4450 if (ri
->peer
== bgp
->peer_self
4451 && ri
->type
== ZEBRA_ROUTE_BGP
4452 && ri
->sub_type
== BGP_ROUTE_AGGREGATE
)
4455 /* Withdraw static BGP route from routing table. */
4458 bgp_info_delete (rn
, ri
);
4459 bgp_process (bgp
, rn
, afi
, safi
);
4462 /* Unlock bgp_node_lookup. */
4463 bgp_unlock_node (rn
);
4466 /* Aggregate route attribute. */
4467 #define AGGREGATE_SUMMARY_ONLY 1
4468 #define AGGREGATE_AS_SET 1
4471 bgp_aggregate_set (struct vty
*vty
, const char *prefix_str
,
4472 afi_t afi
, safi_t safi
,
4473 u_char summary_only
, u_char as_set
)
4477 struct bgp_node
*rn
;
4479 struct bgp_aggregate
*aggregate
;
4481 /* Convert string to prefix structure. */
4482 ret
= str2prefix (prefix_str
, &p
);
4485 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
4490 /* Get BGP structure. */
4493 /* Old configuration check. */
4494 rn
= bgp_node_get (bgp
->aggregate
[afi
][safi
], &p
);
4498 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
4499 bgp_unlock_node (rn
);
4503 /* Make aggregate address structure. */
4504 aggregate
= bgp_aggregate_new ();
4505 aggregate
->summary_only
= summary_only
;
4506 aggregate
->as_set
= as_set
;
4507 aggregate
->safi
= safi
;
4508 rn
->info
= aggregate
;
4510 /* Aggregate address insert into BGP routing table. */
4511 if (safi
& SAFI_UNICAST
)
4512 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
4513 if (safi
& SAFI_MULTICAST
)
4514 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
4520 bgp_aggregate_unset (struct vty
*vty
, const char *prefix_str
,
4521 afi_t afi
, safi_t safi
)
4525 struct bgp_node
*rn
;
4527 struct bgp_aggregate
*aggregate
;
4529 /* Convert string to prefix structure. */
4530 ret
= str2prefix (prefix_str
, &p
);
4533 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
4538 /* Get BGP structure. */
4541 /* Old configuration check. */
4542 rn
= bgp_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
4545 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
4550 aggregate
= rn
->info
;
4551 if (aggregate
->safi
& SAFI_UNICAST
)
4552 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
4553 if (aggregate
->safi
& SAFI_MULTICAST
)
4554 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
4556 /* Unlock aggregate address configuration. */
4558 bgp_aggregate_free (aggregate
);
4559 bgp_unlock_node (rn
);
4560 bgp_unlock_node (rn
);
4565 DEFUN (aggregate_address
,
4566 aggregate_address_cmd
,
4567 "aggregate-address A.B.C.D/M",
4568 "Configure BGP aggregate entries\n"
4569 "Aggregate prefix\n")
4571 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
), 0, 0);
4574 DEFUN (aggregate_address_mask
,
4575 aggregate_address_mask_cmd
,
4576 "aggregate-address A.B.C.D A.B.C.D",
4577 "Configure BGP aggregate entries\n"
4578 "Aggregate address\n"
4582 char prefix_str
[BUFSIZ
];
4584 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4588 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4592 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
4596 DEFUN (aggregate_address_summary_only
,
4597 aggregate_address_summary_only_cmd
,
4598 "aggregate-address A.B.C.D/M summary-only",
4599 "Configure BGP aggregate entries\n"
4600 "Aggregate prefix\n"
4601 "Filter more specific routes from updates\n")
4603 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
4604 AGGREGATE_SUMMARY_ONLY
, 0);
4607 DEFUN (aggregate_address_mask_summary_only
,
4608 aggregate_address_mask_summary_only_cmd
,
4609 "aggregate-address A.B.C.D A.B.C.D summary-only",
4610 "Configure BGP aggregate entries\n"
4611 "Aggregate address\n"
4613 "Filter more specific routes from updates\n")
4616 char prefix_str
[BUFSIZ
];
4618 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4622 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4626 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
4627 AGGREGATE_SUMMARY_ONLY
, 0);
4630 DEFUN (aggregate_address_as_set
,
4631 aggregate_address_as_set_cmd
,
4632 "aggregate-address A.B.C.D/M as-set",
4633 "Configure BGP aggregate entries\n"
4634 "Aggregate prefix\n"
4635 "Generate AS set path information\n")
4637 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
4638 0, AGGREGATE_AS_SET
);
4641 DEFUN (aggregate_address_mask_as_set
,
4642 aggregate_address_mask_as_set_cmd
,
4643 "aggregate-address A.B.C.D A.B.C.D as-set",
4644 "Configure BGP aggregate entries\n"
4645 "Aggregate address\n"
4647 "Generate AS set path information\n")
4650 char prefix_str
[BUFSIZ
];
4652 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4656 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4660 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
4661 0, AGGREGATE_AS_SET
);
4665 DEFUN (aggregate_address_as_set_summary
,
4666 aggregate_address_as_set_summary_cmd
,
4667 "aggregate-address A.B.C.D/M as-set summary-only",
4668 "Configure BGP aggregate entries\n"
4669 "Aggregate prefix\n"
4670 "Generate AS set path information\n"
4671 "Filter more specific routes from updates\n")
4673 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
4674 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
4677 ALIAS (aggregate_address_as_set_summary
,
4678 aggregate_address_summary_as_set_cmd
,
4679 "aggregate-address A.B.C.D/M summary-only as-set",
4680 "Configure BGP aggregate entries\n"
4681 "Aggregate prefix\n"
4682 "Filter more specific routes from updates\n"
4683 "Generate AS set path information\n")
4685 DEFUN (aggregate_address_mask_as_set_summary
,
4686 aggregate_address_mask_as_set_summary_cmd
,
4687 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
4688 "Configure BGP aggregate entries\n"
4689 "Aggregate address\n"
4691 "Generate AS set path information\n"
4692 "Filter more specific routes from updates\n")
4695 char prefix_str
[BUFSIZ
];
4697 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4701 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4705 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
4706 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
4709 ALIAS (aggregate_address_mask_as_set_summary
,
4710 aggregate_address_mask_summary_as_set_cmd
,
4711 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
4712 "Configure BGP aggregate entries\n"
4713 "Aggregate address\n"
4715 "Filter more specific routes from updates\n"
4716 "Generate AS set path information\n")
4718 DEFUN (no_aggregate_address
,
4719 no_aggregate_address_cmd
,
4720 "no aggregate-address A.B.C.D/M",
4722 "Configure BGP aggregate entries\n"
4723 "Aggregate prefix\n")
4725 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
));
4728 ALIAS (no_aggregate_address
,
4729 no_aggregate_address_summary_only_cmd
,
4730 "no aggregate-address A.B.C.D/M summary-only",
4732 "Configure BGP aggregate entries\n"
4733 "Aggregate prefix\n"
4734 "Filter more specific routes from updates\n")
4736 ALIAS (no_aggregate_address
,
4737 no_aggregate_address_as_set_cmd
,
4738 "no aggregate-address A.B.C.D/M as-set",
4740 "Configure BGP aggregate entries\n"
4741 "Aggregate prefix\n"
4742 "Generate AS set path information\n")
4744 ALIAS (no_aggregate_address
,
4745 no_aggregate_address_as_set_summary_cmd
,
4746 "no aggregate-address A.B.C.D/M as-set summary-only",
4748 "Configure BGP aggregate entries\n"
4749 "Aggregate prefix\n"
4750 "Generate AS set path information\n"
4751 "Filter more specific routes from updates\n")
4753 ALIAS (no_aggregate_address
,
4754 no_aggregate_address_summary_as_set_cmd
,
4755 "no aggregate-address A.B.C.D/M summary-only as-set",
4757 "Configure BGP aggregate entries\n"
4758 "Aggregate prefix\n"
4759 "Filter more specific routes from updates\n"
4760 "Generate AS set path information\n")
4762 DEFUN (no_aggregate_address_mask
,
4763 no_aggregate_address_mask_cmd
,
4764 "no aggregate-address A.B.C.D A.B.C.D",
4766 "Configure BGP aggregate entries\n"
4767 "Aggregate address\n"
4771 char prefix_str
[BUFSIZ
];
4773 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4777 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4781 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
4784 ALIAS (no_aggregate_address_mask
,
4785 no_aggregate_address_mask_summary_only_cmd
,
4786 "no aggregate-address A.B.C.D A.B.C.D summary-only",
4788 "Configure BGP aggregate entries\n"
4789 "Aggregate address\n"
4791 "Filter more specific routes from updates\n")
4793 ALIAS (no_aggregate_address_mask
,
4794 no_aggregate_address_mask_as_set_cmd
,
4795 "no aggregate-address A.B.C.D A.B.C.D as-set",
4797 "Configure BGP aggregate entries\n"
4798 "Aggregate address\n"
4800 "Generate AS set path information\n")
4802 ALIAS (no_aggregate_address_mask
,
4803 no_aggregate_address_mask_as_set_summary_cmd
,
4804 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
4806 "Configure BGP aggregate entries\n"
4807 "Aggregate address\n"
4809 "Generate AS set path information\n"
4810 "Filter more specific routes from updates\n")
4812 ALIAS (no_aggregate_address_mask
,
4813 no_aggregate_address_mask_summary_as_set_cmd
,
4814 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
4816 "Configure BGP aggregate entries\n"
4817 "Aggregate address\n"
4819 "Filter more specific routes from updates\n"
4820 "Generate AS set path information\n")
4823 DEFUN (ipv6_aggregate_address
,
4824 ipv6_aggregate_address_cmd
,
4825 "aggregate-address X:X::X:X/M",
4826 "Configure BGP aggregate entries\n"
4827 "Aggregate prefix\n")
4829 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0, 0);
4832 DEFUN (ipv6_aggregate_address_summary_only
,
4833 ipv6_aggregate_address_summary_only_cmd
,
4834 "aggregate-address X:X::X:X/M summary-only",
4835 "Configure BGP aggregate entries\n"
4836 "Aggregate prefix\n"
4837 "Filter more specific routes from updates\n")
4839 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
4840 AGGREGATE_SUMMARY_ONLY
, 0);
4843 DEFUN (no_ipv6_aggregate_address
,
4844 no_ipv6_aggregate_address_cmd
,
4845 "no aggregate-address X:X::X:X/M",
4847 "Configure BGP aggregate entries\n"
4848 "Aggregate prefix\n")
4850 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
4853 DEFUN (no_ipv6_aggregate_address_summary_only
,
4854 no_ipv6_aggregate_address_summary_only_cmd
,
4855 "no aggregate-address X:X::X:X/M summary-only",
4857 "Configure BGP aggregate entries\n"
4858 "Aggregate prefix\n"
4859 "Filter more specific routes from updates\n")
4861 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
4864 ALIAS (ipv6_aggregate_address
,
4865 old_ipv6_aggregate_address_cmd
,
4866 "ipv6 bgp aggregate-address X:X::X:X/M",
4869 "Configure BGP aggregate entries\n"
4870 "Aggregate prefix\n")
4872 ALIAS (ipv6_aggregate_address_summary_only
,
4873 old_ipv6_aggregate_address_summary_only_cmd
,
4874 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
4877 "Configure BGP aggregate entries\n"
4878 "Aggregate prefix\n"
4879 "Filter more specific routes from updates\n")
4881 ALIAS (no_ipv6_aggregate_address
,
4882 old_no_ipv6_aggregate_address_cmd
,
4883 "no ipv6 bgp aggregate-address X:X::X:X/M",
4887 "Configure BGP aggregate entries\n"
4888 "Aggregate prefix\n")
4890 ALIAS (no_ipv6_aggregate_address_summary_only
,
4891 old_no_ipv6_aggregate_address_summary_only_cmd
,
4892 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
4896 "Configure BGP aggregate entries\n"
4897 "Aggregate prefix\n"
4898 "Filter more specific routes from updates\n")
4899 #endif /* HAVE_IPV6 */
4901 /* Redistribute route treatment. */
4903 bgp_redistribute_add (struct prefix
*p
, struct in_addr
*nexthop
,
4904 u_int32_t metric
, u_char type
)
4907 struct listnode
*node
, *nnode
;
4908 struct bgp_info
*new;
4909 struct bgp_info
*bi
;
4910 struct bgp_info info
;
4911 struct bgp_node
*bn
;
4913 struct attr attr_new
;
4914 struct attr
*new_attr
;
4918 /* Make default attribute. */
4919 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
4921 attr
.nexthop
= *nexthop
;
4924 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
4926 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
4928 afi
= family2afi (p
->family
);
4930 if (bgp
->redist
[afi
][type
])
4932 /* Copy attribute for modification. */
4935 if (bgp
->redist_metric_flag
[afi
][type
])
4936 attr_new
.med
= bgp
->redist_metric
[afi
][type
];
4938 /* Apply route-map. */
4939 if (bgp
->rmap
[afi
][type
].map
)
4941 info
.peer
= bgp
->peer_self
;
4942 info
.attr
= &attr_new
;
4944 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
);
4946 ret
= route_map_apply (bgp
->rmap
[afi
][type
].map
, p
, RMAP_BGP
,
4949 bgp
->peer_self
->rmap_type
= 0;
4951 if (ret
== RMAP_DENYMATCH
)
4953 /* Free uninterned attribute. */
4954 bgp_attr_flush (&attr_new
);
4956 /* Unintern original. */
4957 aspath_unintern (attr
.aspath
);
4958 bgp_redistribute_delete (p
, type
);
4963 bn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
4964 new_attr
= bgp_attr_intern (&attr_new
);
4966 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
4967 if (bi
->peer
== bgp
->peer_self
4968 && bi
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
4973 if (attrhash_cmp (bi
->attr
, new_attr
) &&
4974 !CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
4976 bgp_attr_unintern (new_attr
);
4977 aspath_unintern (attr
.aspath
);
4978 bgp_unlock_node (bn
);
4983 /* The attribute is changed. */
4984 bgp_info_set_flag (bn
, bi
, BGP_INFO_ATTR_CHANGED
);
4986 /* Rewrite BGP route information. */
4987 if (CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
4988 bgp_info_restore(bn
, bi
);
4990 bgp_aggregate_decrement (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
4991 bgp_attr_unintern (bi
->attr
);
4992 bi
->attr
= new_attr
;
4993 bi
->uptime
= time (NULL
);
4995 /* Process change. */
4996 bgp_aggregate_increment (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
4997 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
4998 bgp_unlock_node (bn
);
4999 aspath_unintern (attr
.aspath
);
5004 new = bgp_info_new ();
5006 new->sub_type
= BGP_ROUTE_REDISTRIBUTE
;
5007 new->peer
= bgp
->peer_self
;
5008 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5009 new->attr
= new_attr
;
5010 new->uptime
= time (NULL
);
5012 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
5013 bgp_info_add (bn
, new);
5014 bgp_unlock_node (bn
);
5015 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5019 /* Unintern original. */
5020 aspath_unintern (attr
.aspath
);
5024 bgp_redistribute_delete (struct prefix
*p
, u_char type
)
5027 struct listnode
*node
, *nnode
;
5029 struct bgp_node
*rn
;
5030 struct bgp_info
*ri
;
5032 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
5034 afi
= family2afi (p
->family
);
5036 if (bgp
->redist
[afi
][type
])
5038 rn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
5040 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5041 if (ri
->peer
== bgp
->peer_self
5042 && ri
->type
== type
)
5047 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
5048 bgp_info_delete (rn
, ri
);
5049 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5051 bgp_unlock_node (rn
);
5056 /* Withdraw specified route type's route. */
5058 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
)
5060 struct bgp_node
*rn
;
5061 struct bgp_info
*ri
;
5062 struct bgp_table
*table
;
5064 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
5066 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
5068 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5069 if (ri
->peer
== bgp
->peer_self
5070 && ri
->type
== type
)
5075 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
5076 bgp_info_delete (rn
, ri
);
5077 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5082 /* Static function to display route. */
5084 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
5087 u_int32_t destination
;
5090 if (p
->family
== AF_INET
)
5092 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
5093 destination
= ntohl (p
->u
.prefix4
.s_addr
);
5095 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
5096 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
5097 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
5098 || p
->u
.prefix4
.s_addr
== 0)
5100 /* When mask is natural, mask is not displayed. */
5103 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
5106 len
= vty_out (vty
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
5111 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
5113 vty_out (vty
, "%*s", len
, " ");
5116 enum bgp_display_type
5121 /* Print the short form route status for a bgp_info */
5123 route_vty_short_status_out (struct vty
*vty
, struct bgp_info
*binfo
)
5125 /* Route status display. */
5126 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5128 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5130 else if (binfo
->suppress
)
5132 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5138 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5140 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5142 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5147 /* Internal route. */
5148 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
5154 /* called from terminal list command */
5156 route_vty_out (struct vty
*vty
, struct prefix
*p
,
5157 struct bgp_info
*binfo
, int display
, safi_t safi
)
5161 /* short status lead text */
5162 route_vty_short_status_out (vty
, binfo
);
5164 /* print prefix and mask */
5166 route_vty_out_route (p
, vty
);
5168 vty_out (vty
, "%*s", 17, " ");
5170 /* Print attribute */
5174 if (p
->family
== AF_INET
)
5176 if (safi
== SAFI_MPLS_VPN
)
5177 vty_out (vty
, "%-16s", inet_ntoa (attr
->mp_nexthop_global_in
));
5179 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5182 else if (p
->family
== AF_INET6
)
5187 len
= vty_out (vty
, "%s",
5188 inet_ntop (AF_INET6
, &attr
->mp_nexthop_global
, buf
, BUFSIZ
));
5191 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5193 vty_out (vty
, "%*s", len
, " ");
5195 #endif /* HAVE_IPV6 */
5197 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5198 vty_out (vty
, "%10d", attr
->med
);
5202 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5203 vty_out (vty
, "%7d", attr
->local_pref
);
5207 vty_out (vty
, "%7u ",attr
->weight
);
5211 aspath_print_vty (vty
, "%s ", attr
->aspath
);
5214 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5216 vty_out (vty
, "%s", VTY_NEWLINE
);
5219 /* called from terminal list command */
5221 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
,
5222 struct attr
*attr
, safi_t safi
)
5224 /* Route status display. */
5229 /* print prefix and mask */
5230 route_vty_out_route (p
, vty
);
5232 /* Print attribute */
5235 if (p
->family
== AF_INET
)
5237 if (safi
== SAFI_MPLS_VPN
)
5238 vty_out (vty
, "%-16s", inet_ntoa (attr
->mp_nexthop_global_in
));
5240 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5243 else if (p
->family
== AF_INET6
)
5248 len
= vty_out (vty
, "%s",
5249 inet_ntop (AF_INET6
, &attr
->mp_nexthop_global
, buf
, BUFSIZ
));
5252 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5254 vty_out (vty
, "%*s", len
, " ");
5256 #endif /* HAVE_IPV6 */
5258 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5259 vty_out (vty
, "%10d", attr
->med
);
5263 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5264 vty_out (vty
, "%7d", attr
->local_pref
);
5268 vty_out (vty
, "%7d ",attr
->weight
);
5272 aspath_print_vty (vty
, "%s ", attr
->aspath
);
5275 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5278 vty_out (vty
, "%s", VTY_NEWLINE
);
5282 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
5283 struct bgp_info
*binfo
, int display
, safi_t safi
)
5286 u_int32_t label
= 0;
5288 /* short status lead text */
5289 route_vty_short_status_out (vty
, binfo
);
5291 /* print prefix and mask */
5293 route_vty_out_route (p
, vty
);
5295 vty_out (vty
, "%*s", 17, " ");
5297 /* Print attribute */
5301 if (p
->family
== AF_INET
)
5303 if (safi
== SAFI_MPLS_VPN
)
5304 vty_out (vty
, "%-16s", inet_ntoa (attr
->mp_nexthop_global_in
));
5306 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5309 else if (p
->family
== AF_INET6
)
5313 if (attr
->mp_nexthop_len
== 16)
5315 inet_ntop (AF_INET6
, &attr
->mp_nexthop_global
, buf
, BUFSIZ
));
5316 else if (attr
->mp_nexthop_len
== 32)
5317 vty_out (vty
, "%s(%s)",
5318 inet_ntop (AF_INET6
, &attr
->mp_nexthop_global
, buf
, BUFSIZ
),
5319 inet_ntop (AF_INET6
, &attr
->mp_nexthop_local
, buf1
, BUFSIZ
));
5322 #endif /* HAVE_IPV6 */
5325 label
= decode_label (binfo
->tag
);
5327 vty_out (vty
, "notag/%d", label
);
5329 vty_out (vty
, "%s", VTY_NEWLINE
);
5332 /* dampening route */
5334 damp_route_vty_out (struct vty
*vty
, struct prefix
*p
,
5335 struct bgp_info
*binfo
, int display
, safi_t safi
)
5340 /* short status lead text */
5341 route_vty_short_status_out (vty
, binfo
);
5343 /* print prefix and mask */
5345 route_vty_out_route (p
, vty
);
5347 vty_out (vty
, "%*s", 17, " ");
5349 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
5352 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 34, " ");
5354 vty_out (vty
, "%*s", len
, " ");
5356 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
));
5358 /* Print attribute */
5364 aspath_print_vty (vty
, "%s ", attr
->aspath
);
5367 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5369 vty_out (vty
, "%s", VTY_NEWLINE
);
5372 #define BGP_UPTIME_LEN 25
5376 flap_route_vty_out (struct vty
*vty
, struct prefix
*p
,
5377 struct bgp_info
*binfo
, int display
, safi_t safi
)
5380 struct bgp_damp_info
*bdi
;
5381 char timebuf
[BGP_UPTIME_LEN
];
5384 bdi
= binfo
->damp_info
;
5386 /* short status lead text */
5387 route_vty_short_status_out (vty
, binfo
);
5389 /* print prefix and mask */
5391 route_vty_out_route (p
, vty
);
5393 vty_out (vty
, "%*s", 17, " ");
5395 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
5398 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 33, " ");
5400 vty_out (vty
, "%*s", len
, " ");
5402 len
= vty_out (vty
, "%d", bdi
->flap
);
5407 vty_out (vty
, "%*s ", len
, " ");
5409 vty_out (vty
, "%s ", peer_uptime (bdi
->start_time
,
5410 timebuf
, BGP_UPTIME_LEN
));
5412 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
)
5413 && ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5414 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
));
5416 vty_out (vty
, "%*s ", 8, " ");
5418 /* Print attribute */
5424 aspath_print_vty (vty
, "%s ", attr
->aspath
);
5427 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5429 vty_out (vty
, "%s", VTY_NEWLINE
);
5433 route_vty_out_detail (struct vty
*vty
, struct bgp
*bgp
, struct prefix
*p
,
5434 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
)
5436 char buf
[INET6_ADDRSTRLEN
];
5439 int sockunion_vty_out (struct vty
*, union sockunion
*);
5445 /* Line1 display AS-path, Aggregator */
5449 if (aspath_count_hops (attr
->aspath
) == 0)
5450 vty_out (vty
, "Local");
5452 aspath_print_vty (vty
, "%s", attr
->aspath
);
5455 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5456 vty_out (vty
, ", (removed)");
5457 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5458 vty_out (vty
, ", (stale)");
5459 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
5460 vty_out (vty
, ", (aggregated by %d %s)", attr
->aggregator_as
,
5461 inet_ntoa (attr
->aggregator_addr
));
5462 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
5463 vty_out (vty
, ", (Received from a RR-client)");
5464 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
5465 vty_out (vty
, ", (Received from a RS-client)");
5466 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5467 vty_out (vty
, ", (history entry)");
5468 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5469 vty_out (vty
, ", (suppressed due to dampening)");
5470 vty_out (vty
, "%s", VTY_NEWLINE
);
5472 /* Line2 display Next-hop, Neighbor, Router-id */
5473 if (p
->family
== AF_INET
)
5475 vty_out (vty
, " %s", safi
== SAFI_MPLS_VPN
?
5476 inet_ntoa (attr
->mp_nexthop_global_in
) :
5477 inet_ntoa (attr
->nexthop
));
5482 vty_out (vty
, " %s",
5483 inet_ntop (AF_INET6
, &attr
->mp_nexthop_global
,
5484 buf
, INET6_ADDRSTRLEN
));
5486 #endif /* HAVE_IPV6 */
5488 if (binfo
->peer
== bgp
->peer_self
)
5490 vty_out (vty
, " from %s ",
5491 p
->family
== AF_INET
? "0.0.0.0" : "::");
5492 vty_out (vty
, "(%s)", inet_ntoa(bgp
->router_id
));
5496 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
5497 vty_out (vty
, " (inaccessible)");
5498 else if (binfo
->igpmetric
)
5499 vty_out (vty
, " (metric %d)", binfo
->igpmetric
);
5500 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
5501 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
5502 vty_out (vty
, " (%s)", inet_ntoa (attr
->originator_id
));
5504 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
5506 vty_out (vty
, "%s", VTY_NEWLINE
);
5509 /* display nexthop local */
5510 if (attr
->mp_nexthop_len
== 32)
5512 vty_out (vty
, " (%s)%s",
5513 inet_ntop (AF_INET6
, &attr
->mp_nexthop_local
,
5514 buf
, INET6_ADDRSTRLEN
),
5517 #endif /* HAVE_IPV6 */
5519 /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */
5520 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
5522 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
5523 vty_out (vty
, ", metric %d", attr
->med
);
5525 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
5526 vty_out (vty
, ", localpref %d", attr
->local_pref
);
5528 vty_out (vty
, ", localpref %d", bgp
->default_local_pref
);
5530 if (attr
->weight
!= 0)
5531 vty_out (vty
, ", weight %d", attr
->weight
);
5533 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5534 vty_out (vty
, ", valid");
5536 if (binfo
->peer
!= bgp
->peer_self
)
5538 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
5539 vty_out (vty
, ", internal");
5541 vty_out (vty
, ", %s",
5542 (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
) ? "confed-external" : "external"));
5544 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
5545 vty_out (vty
, ", aggregated, local");
5546 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
5547 vty_out (vty
, ", sourced");
5549 vty_out (vty
, ", sourced, local");
5551 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
5552 vty_out (vty
, ", atomic-aggregate");
5554 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5555 vty_out (vty
, ", best");
5557 vty_out (vty
, "%s", VTY_NEWLINE
);
5559 /* Line 4 display Community */
5560 if (attr
->community
)
5561 vty_out (vty
, " Community: %s%s", attr
->community
->str
,
5564 /* Line 5 display Extended-community */
5565 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
5566 vty_out (vty
, " Extended Community: %s%s", attr
->ecommunity
->str
,
5569 /* Line 6 display Originator, Cluster-id */
5570 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
5571 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
5573 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
5574 vty_out (vty
, " Originator: %s", inet_ntoa (attr
->originator_id
));
5576 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
5579 vty_out (vty
, ", Cluster list: ");
5580 for (i
= 0; i
< attr
->cluster
->length
/ 4; i
++)
5581 vty_out (vty
, "%s ", inet_ntoa (attr
->cluster
->list
[i
]));
5583 vty_out (vty
, "%s", VTY_NEWLINE
);
5586 if (binfo
->damp_info
)
5587 bgp_damp_info_vty (vty
, binfo
);
5589 /* Line 7 display Uptime */
5590 vty_out (vty
, " Last update: %s", ctime (&binfo
->uptime
));
5592 vty_out (vty
, "%s", VTY_NEWLINE
);
5595 #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"
5596 #define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
5597 #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
5598 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
5599 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
5603 bgp_show_type_normal
,
5604 bgp_show_type_regexp
,
5605 bgp_show_type_prefix_list
,
5606 bgp_show_type_filter_list
,
5607 bgp_show_type_route_map
,
5608 bgp_show_type_neighbor
,
5609 bgp_show_type_cidr_only
,
5610 bgp_show_type_prefix_longer
,
5611 bgp_show_type_community_all
,
5612 bgp_show_type_community
,
5613 bgp_show_type_community_exact
,
5614 bgp_show_type_community_list
,
5615 bgp_show_type_community_list_exact
,
5616 bgp_show_type_flap_statistics
,
5617 bgp_show_type_flap_address
,
5618 bgp_show_type_flap_prefix
,
5619 bgp_show_type_flap_cidr_only
,
5620 bgp_show_type_flap_regexp
,
5621 bgp_show_type_flap_filter_list
,
5622 bgp_show_type_flap_prefix_list
,
5623 bgp_show_type_flap_prefix_longer
,
5624 bgp_show_type_flap_route_map
,
5625 bgp_show_type_flap_neighbor
,
5626 bgp_show_type_dampend_paths
,
5627 bgp_show_type_damp_neighbor
5631 bgp_show_table (struct vty
*vty
, struct bgp_table
*table
, struct in_addr
*router_id
,
5632 enum bgp_show_type type
, void *output_arg
)
5634 struct bgp_info
*ri
;
5635 struct bgp_node
*rn
;
5638 unsigned long output_count
;
5640 /* This is first entry point, so reset total line. */
5643 /* Start processing of routes. */
5644 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
5645 if (rn
->info
!= NULL
)
5649 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5651 if (type
== bgp_show_type_flap_statistics
5652 || type
== bgp_show_type_flap_address
5653 || type
== bgp_show_type_flap_prefix
5654 || type
== bgp_show_type_flap_cidr_only
5655 || type
== bgp_show_type_flap_regexp
5656 || type
== bgp_show_type_flap_filter_list
5657 || type
== bgp_show_type_flap_prefix_list
5658 || type
== bgp_show_type_flap_prefix_longer
5659 || type
== bgp_show_type_flap_route_map
5660 || type
== bgp_show_type_flap_neighbor
5661 || type
== bgp_show_type_dampend_paths
5662 || type
== bgp_show_type_damp_neighbor
)
5664 if (! ri
->damp_info
)
5667 if (type
== bgp_show_type_regexp
5668 || type
== bgp_show_type_flap_regexp
)
5670 regex_t
*regex
= output_arg
;
5672 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
5675 if (type
== bgp_show_type_prefix_list
5676 || type
== bgp_show_type_flap_prefix_list
)
5678 struct prefix_list
*plist
= output_arg
;
5680 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
5683 if (type
== bgp_show_type_filter_list
5684 || type
== bgp_show_type_flap_filter_list
)
5686 struct as_list
*as_list
= output_arg
;
5688 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
5691 if (type
== bgp_show_type_route_map
5692 || type
== bgp_show_type_flap_route_map
)
5694 struct route_map
*rmap
= output_arg
;
5695 struct bgp_info binfo
;
5696 struct attr dummy_attr
;
5699 dummy_attr
= *ri
->attr
;
5700 binfo
.peer
= ri
->peer
;
5701 binfo
.attr
= &dummy_attr
;
5703 ret
= route_map_apply (rmap
, &rn
->p
, RMAP_BGP
, &binfo
);
5705 if (ret
== RMAP_DENYMATCH
)
5708 if (type
== bgp_show_type_neighbor
5709 || type
== bgp_show_type_flap_neighbor
5710 || type
== bgp_show_type_damp_neighbor
)
5712 union sockunion
*su
= output_arg
;
5714 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
5717 if (type
== bgp_show_type_cidr_only
5718 || type
== bgp_show_type_flap_cidr_only
)
5720 u_int32_t destination
;
5722 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
5723 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
5725 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
5727 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
5730 if (type
== bgp_show_type_prefix_longer
5731 || type
== bgp_show_type_flap_prefix_longer
)
5733 struct prefix
*p
= output_arg
;
5735 if (! prefix_match (p
, &rn
->p
))
5738 if (type
== bgp_show_type_community_all
)
5740 if (! ri
->attr
->community
)
5743 if (type
== bgp_show_type_community
)
5745 struct community
*com
= output_arg
;
5747 if (! ri
->attr
->community
||
5748 ! community_match (ri
->attr
->community
, com
))
5751 if (type
== bgp_show_type_community_exact
)
5753 struct community
*com
= output_arg
;
5755 if (! ri
->attr
->community
||
5756 ! community_cmp (ri
->attr
->community
, com
))
5759 if (type
== bgp_show_type_community_list
)
5761 struct community_list
*list
= output_arg
;
5763 if (! community_list_match (ri
->attr
->community
, list
))
5766 if (type
== bgp_show_type_community_list_exact
)
5768 struct community_list
*list
= output_arg
;
5770 if (! community_list_exact_match (ri
->attr
->community
, list
))
5773 if (type
== bgp_show_type_flap_address
5774 || type
== bgp_show_type_flap_prefix
)
5776 struct prefix
*p
= output_arg
;
5778 if (! prefix_match (&rn
->p
, p
))
5781 if (type
== bgp_show_type_flap_prefix
)
5782 if (p
->prefixlen
!= rn
->p
.prefixlen
)
5785 if (type
== bgp_show_type_dampend_paths
5786 || type
== bgp_show_type_damp_neighbor
)
5788 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
)
5789 || CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
5795 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id
), VTY_NEWLINE
);
5796 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
5797 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
5798 if (type
== bgp_show_type_dampend_paths
5799 || type
== bgp_show_type_damp_neighbor
)
5800 vty_out (vty
, BGP_SHOW_DAMP_HEADER
, VTY_NEWLINE
);
5801 else if (type
== bgp_show_type_flap_statistics
5802 || type
== bgp_show_type_flap_address
5803 || type
== bgp_show_type_flap_prefix
5804 || type
== bgp_show_type_flap_cidr_only
5805 || type
== bgp_show_type_flap_regexp
5806 || type
== bgp_show_type_flap_filter_list
5807 || type
== bgp_show_type_flap_prefix_list
5808 || type
== bgp_show_type_flap_prefix_longer
5809 || type
== bgp_show_type_flap_route_map
5810 || type
== bgp_show_type_flap_neighbor
)
5811 vty_out (vty
, BGP_SHOW_FLAP_HEADER
, VTY_NEWLINE
);
5813 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
5817 if (type
== bgp_show_type_dampend_paths
5818 || type
== bgp_show_type_damp_neighbor
)
5819 damp_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
5820 else if (type
== bgp_show_type_flap_statistics
5821 || type
== bgp_show_type_flap_address
5822 || type
== bgp_show_type_flap_prefix
5823 || type
== bgp_show_type_flap_cidr_only
5824 || type
== bgp_show_type_flap_regexp
5825 || type
== bgp_show_type_flap_filter_list
5826 || type
== bgp_show_type_flap_prefix_list
5827 || type
== bgp_show_type_flap_prefix_longer
5828 || type
== bgp_show_type_flap_route_map
5829 || type
== bgp_show_type_flap_neighbor
)
5830 flap_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
5832 route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
5839 /* No route is displayed */
5840 if (output_count
== 0)
5842 if (type
== bgp_show_type_normal
)
5843 vty_out (vty
, "No BGP network exists%s", VTY_NEWLINE
);
5846 vty_out (vty
, "%sTotal number of prefixes %ld%s",
5847 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
5853 bgp_show (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
5854 enum bgp_show_type type
, void *output_arg
)
5856 struct bgp_table
*table
;
5859 bgp
= bgp_get_default ();
5864 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
5869 table
= bgp
->rib
[afi
][safi
];
5871 return bgp_show_table (vty
, table
, &bgp
->router_id
, type
, output_arg
);
5874 /* Header of detailed BGP route information */
5876 route_vty_out_detail_header (struct vty
*vty
, struct bgp
*bgp
,
5877 struct bgp_node
*rn
,
5878 struct prefix_rd
*prd
, afi_t afi
, safi_t safi
)
5880 struct bgp_info
*ri
;
5883 struct listnode
*node
, *nnode
;
5884 char buf1
[INET6_ADDRSTRLEN
];
5885 char buf2
[INET6_ADDRSTRLEN
];
5890 int no_advertise
= 0;
5895 vty_out (vty
, "BGP routing table entry for %s%s%s/%d%s",
5896 (safi
== SAFI_MPLS_VPN
?
5897 prefix_rd2str (prd
, buf1
, RD_ADDRSTRLEN
) : ""),
5898 safi
== SAFI_MPLS_VPN
? ":" : "",
5899 inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
),
5900 p
->prefixlen
, VTY_NEWLINE
);
5902 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5905 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
5910 if (ri
->attr
->community
!= NULL
)
5912 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
5914 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
5916 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
5922 vty_out (vty
, "Paths: (%d available", count
);
5925 vty_out (vty
, ", best #%d", best
);
5926 if (safi
== SAFI_UNICAST
)
5927 vty_out (vty
, ", table Default-IP-Routing-Table");
5930 vty_out (vty
, ", no best path");
5932 vty_out (vty
, ", not advertised to any peer");
5934 vty_out (vty
, ", not advertised to EBGP peer");
5936 vty_out (vty
, ", not advertised outside local AS");
5938 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
5939 vty_out (vty
, ")%s", VTY_NEWLINE
);
5941 /* advertised peer */
5942 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
5944 if (bgp_adj_out_lookup (peer
, p
, afi
, safi
, rn
))
5947 vty_out (vty
, " Advertised to non peer-group peers:%s ", VTY_NEWLINE
);
5948 vty_out (vty
, " %s", sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
5953 vty_out (vty
, " Not advertised to any peer");
5954 vty_out (vty
, "%s", VTY_NEWLINE
);
5957 /* Display specified route of BGP table. */
5959 bgp_show_route_in_table (struct vty
*vty
, struct bgp
*bgp
,
5960 struct bgp_table
*rib
, const char *ip_str
,
5961 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
5967 struct prefix match
;
5968 struct bgp_node
*rn
;
5969 struct bgp_node
*rm
;
5970 struct bgp_info
*ri
;
5971 struct bgp_table
*table
;
5973 /* Check IP address argument. */
5974 ret
= str2prefix (ip_str
, &match
);
5977 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
5981 match
.family
= afi2family (afi
);
5983 if (safi
== SAFI_MPLS_VPN
)
5985 for (rn
= bgp_table_top (rib
); rn
; rn
= bgp_route_next (rn
))
5987 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
5990 if ((table
= rn
->info
) != NULL
)
5994 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
5996 if (prefix_check
&& rm
->p
.prefixlen
!= match
.prefixlen
)
5999 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
6003 route_vty_out_detail_header (vty
, bgp
, rm
, (struct prefix_rd
*)&rn
->p
,
6004 AFI_IP
, SAFI_MPLS_VPN
);
6009 route_vty_out_detail (vty
, bgp
, &rm
->p
, ri
, AFI_IP
, SAFI_MPLS_VPN
);
6019 if ((rn
= bgp_node_match (rib
, &match
)) != NULL
)
6021 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
6023 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6027 route_vty_out_detail_header (vty
, bgp
, rn
, NULL
, afi
, safi
);
6031 route_vty_out_detail (vty
, bgp
, &rn
->p
, ri
, afi
, safi
);
6039 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
6046 /* Display specified route of Main RIB */
6048 bgp_show_route (struct vty
*vty
, const char *view_name
, const char *ip_str
,
6049 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
6054 /* BGP structure lookup. */
6057 bgp
= bgp_lookup_by_name (view_name
);
6060 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
6066 bgp
= bgp_get_default ();
6069 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
6074 return bgp_show_route_in_table (vty
, bgp
, bgp
->rib
[afi
][safi
], ip_str
,
6075 afi
, safi
, prd
, prefix_check
);
6078 /* BGP route print out function. */
6086 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6089 DEFUN (show_ip_bgp_ipv4
,
6090 show_ip_bgp_ipv4_cmd
,
6091 "show ip bgp ipv4 (unicast|multicast)",
6096 "Address Family modifier\n"
6097 "Address Family modifier\n")
6099 if (strncmp (argv
[0], "m", 1) == 0)
6100 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
, bgp_show_type_normal
,
6103 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6106 DEFUN (show_ip_bgp_route
,
6107 show_ip_bgp_route_cmd
,
6108 "show ip bgp A.B.C.D",
6112 "Network in the BGP routing table to display\n")
6114 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6117 DEFUN (show_ip_bgp_ipv4_route
,
6118 show_ip_bgp_ipv4_route_cmd
,
6119 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
6124 "Address Family modifier\n"
6125 "Address Family modifier\n"
6126 "Network in the BGP routing table to display\n")
6128 if (strncmp (argv
[0], "m", 1) == 0)
6129 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0);
6131 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6134 DEFUN (show_ip_bgp_vpnv4_all_route
,
6135 show_ip_bgp_vpnv4_all_route_cmd
,
6136 "show ip bgp vpnv4 all A.B.C.D",
6140 "Display VPNv4 NLRI specific information\n"
6141 "Display information about all VPNv4 NLRIs\n"
6142 "Network in the BGP routing table to display\n")
6144 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 0);
6147 DEFUN (show_ip_bgp_vpnv4_rd_route
,
6148 show_ip_bgp_vpnv4_rd_route_cmd
,
6149 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
6153 "Display VPNv4 NLRI specific information\n"
6154 "Display information for a route distinguisher\n"
6155 "VPN Route Distinguisher\n"
6156 "Network in the BGP routing table to display\n")
6159 struct prefix_rd prd
;
6161 ret
= str2prefix_rd (argv
[0], &prd
);
6164 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
6167 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0);
6170 DEFUN (show_ip_bgp_prefix
,
6171 show_ip_bgp_prefix_cmd
,
6172 "show ip bgp A.B.C.D/M",
6176 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6178 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6181 DEFUN (show_ip_bgp_ipv4_prefix
,
6182 show_ip_bgp_ipv4_prefix_cmd
,
6183 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
6188 "Address Family modifier\n"
6189 "Address Family modifier\n"
6190 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6192 if (strncmp (argv
[0], "m", 1) == 0)
6193 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1);
6195 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6198 DEFUN (show_ip_bgp_vpnv4_all_prefix
,
6199 show_ip_bgp_vpnv4_all_prefix_cmd
,
6200 "show ip bgp vpnv4 all A.B.C.D/M",
6204 "Display VPNv4 NLRI specific information\n"
6205 "Display information about all VPNv4 NLRIs\n"
6206 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6208 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 1);
6211 DEFUN (show_ip_bgp_vpnv4_rd_prefix
,
6212 show_ip_bgp_vpnv4_rd_prefix_cmd
,
6213 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
6217 "Display VPNv4 NLRI specific information\n"
6218 "Display information for a route distinguisher\n"
6219 "VPN Route Distinguisher\n"
6220 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6223 struct prefix_rd prd
;
6225 ret
= str2prefix_rd (argv
[0], &prd
);
6228 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
6231 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 1);
6234 DEFUN (show_ip_bgp_view
,
6235 show_ip_bgp_view_cmd
,
6236 "show ip bgp view WORD",
6245 /* BGP structure lookup. */
6246 bgp
= bgp_lookup_by_name (argv
[0]);
6249 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
6253 return bgp_show (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6256 DEFUN (show_ip_bgp_view_route
,
6257 show_ip_bgp_view_route_cmd
,
6258 "show ip bgp view WORD A.B.C.D",
6264 "Network in the BGP routing table to display\n")
6266 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6269 DEFUN (show_ip_bgp_view_prefix
,
6270 show_ip_bgp_view_prefix_cmd
,
6271 "show ip bgp view WORD A.B.C.D/M",
6277 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6279 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6289 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
6301 DEFUN (show_ipv6_bgp
,
6308 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
6312 DEFUN (show_bgp_route
,
6314 "show bgp X:X::X:X",
6317 "Network in the BGP routing table to display\n")
6319 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6322 ALIAS (show_bgp_route
,
6323 show_bgp_ipv6_route_cmd
,
6324 "show bgp ipv6 X:X::X:X",
6328 "Network in the BGP routing table to display\n")
6331 DEFUN (show_ipv6_bgp_route
,
6332 show_ipv6_bgp_route_cmd
,
6333 "show ipv6 bgp X:X::X:X",
6337 "Network in the BGP routing table to display\n")
6339 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6342 DEFUN (show_bgp_prefix
,
6343 show_bgp_prefix_cmd
,
6344 "show bgp X:X::X:X/M",
6347 "IPv6 prefix <network>/<length>\n")
6349 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6352 ALIAS (show_bgp_prefix
,
6353 show_bgp_ipv6_prefix_cmd
,
6354 "show bgp ipv6 X:X::X:X/M",
6358 "IPv6 prefix <network>/<length>\n")
6361 DEFUN (show_ipv6_bgp_prefix
,
6362 show_ipv6_bgp_prefix_cmd
,
6363 "show ipv6 bgp X:X::X:X/M",
6367 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6369 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6372 DEFUN (show_bgp_view
,
6374 "show bgp view WORD",
6382 /* BGP structure lookup. */
6383 bgp
= bgp_lookup_by_name (argv
[0]);
6386 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
6390 return bgp_show (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6393 ALIAS (show_bgp_view
,
6394 show_bgp_view_ipv6_cmd
,
6395 "show bgp view WORD ipv6",
6402 DEFUN (show_bgp_view_route
,
6403 show_bgp_view_route_cmd
,
6404 "show bgp view WORD X:X::X:X",
6409 "Network in the BGP routing table to display\n")
6411 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6414 ALIAS (show_bgp_view_route
,
6415 show_bgp_view_ipv6_route_cmd
,
6416 "show bgp view WORD ipv6 X:X::X:X",
6422 "Network in the BGP routing table to display\n")
6424 DEFUN (show_bgp_view_prefix
,
6425 show_bgp_view_prefix_cmd
,
6426 "show bgp view WORD X:X::X:X/M",
6431 "IPv6 prefix <network>/<length>\n")
6433 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6436 ALIAS (show_bgp_view_prefix
,
6437 show_bgp_view_ipv6_prefix_cmd
,
6438 "show bgp view WORD ipv6 X:X::X:X/M",
6444 "IPv6 prefix <network>/<length>\n")
6447 DEFUN (show_ipv6_mbgp
,
6454 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
6459 DEFUN (show_ipv6_mbgp_route
,
6460 show_ipv6_mbgp_route_cmd
,
6461 "show ipv6 mbgp X:X::X:X",
6465 "Network in the MBGP routing table to display\n")
6467 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0);
6471 DEFUN (show_ipv6_mbgp_prefix
,
6472 show_ipv6_mbgp_prefix_cmd
,
6473 "show ipv6 mbgp X:X::X:X/M",
6477 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6479 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1);
6485 bgp_show_regexp (struct vty
*vty
, int argc
, const char **argv
, afi_t afi
,
6486 safi_t safi
, enum bgp_show_type type
)
6496 b
= buffer_new (1024);
6497 for (i
= 0; i
< argc
; i
++)
6500 buffer_putc (b
, ' ');
6503 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
6508 buffer_putstr (b
, argv
[i
]);
6510 buffer_putc (b
, '\0');
6512 regstr
= buffer_getstr (b
);
6515 regex
= bgp_regcomp (regstr
);
6516 XFREE(MTYPE_TMP
, regstr
);
6519 vty_out (vty
, "Can't compile regexp %s%s", argv
[0],
6524 rc
= bgp_show (vty
, NULL
, afi
, safi
, type
, regex
);
6525 bgp_regex_free (regex
);
6529 DEFUN (show_ip_bgp_regexp
,
6530 show_ip_bgp_regexp_cmd
,
6531 "show ip bgp regexp .LINE",
6535 "Display routes matching the AS path regular expression\n"
6536 "A regular-expression to match the BGP AS paths\n")
6538 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
6539 bgp_show_type_regexp
);
6542 DEFUN (show_ip_bgp_flap_regexp
,
6543 show_ip_bgp_flap_regexp_cmd
,
6544 "show ip bgp flap-statistics regexp .LINE",
6548 "Display flap statistics of routes\n"
6549 "Display routes matching the AS path regular expression\n"
6550 "A regular-expression to match the BGP AS paths\n")
6552 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
6553 bgp_show_type_flap_regexp
);
6556 DEFUN (show_ip_bgp_ipv4_regexp
,
6557 show_ip_bgp_ipv4_regexp_cmd
,
6558 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
6563 "Address Family modifier\n"
6564 "Address Family modifier\n"
6565 "Display routes matching the AS path regular expression\n"
6566 "A regular-expression to match the BGP AS paths\n")
6568 if (strncmp (argv
[0], "m", 1) == 0)
6569 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_MULTICAST
,
6570 bgp_show_type_regexp
);
6572 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
6573 bgp_show_type_regexp
);
6577 DEFUN (show_bgp_regexp
,
6578 show_bgp_regexp_cmd
,
6579 "show bgp regexp .LINE",
6582 "Display routes matching the AS path regular expression\n"
6583 "A regular-expression to match the BGP AS paths\n")
6585 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
6586 bgp_show_type_regexp
);
6589 ALIAS (show_bgp_regexp
,
6590 show_bgp_ipv6_regexp_cmd
,
6591 "show bgp ipv6 regexp .LINE",
6595 "Display routes matching the AS path regular expression\n"
6596 "A regular-expression to match the BGP AS paths\n")
6599 DEFUN (show_ipv6_bgp_regexp
,
6600 show_ipv6_bgp_regexp_cmd
,
6601 "show ipv6 bgp regexp .LINE",
6605 "Display routes matching the AS path regular expression\n"
6606 "A regular-expression to match the BGP AS paths\n")
6608 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
6609 bgp_show_type_regexp
);
6613 DEFUN (show_ipv6_mbgp_regexp
,
6614 show_ipv6_mbgp_regexp_cmd
,
6615 "show ipv6 mbgp regexp .LINE",
6619 "Display routes matching the AS path regular expression\n"
6620 "A regular-expression to match the MBGP AS paths\n")
6622 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
,
6623 bgp_show_type_regexp
);
6625 #endif /* HAVE_IPV6 */
6628 bgp_show_prefix_list (struct vty
*vty
, const char *prefix_list_str
, afi_t afi
,
6629 safi_t safi
, enum bgp_show_type type
)
6631 struct prefix_list
*plist
;
6633 plist
= prefix_list_lookup (afi
, prefix_list_str
);
6636 vty_out (vty
, "%% %s is not a valid prefix-list name%s",
6637 prefix_list_str
, VTY_NEWLINE
);
6641 return bgp_show (vty
, NULL
, afi
, safi
, type
, plist
);
6644 DEFUN (show_ip_bgp_prefix_list
,
6645 show_ip_bgp_prefix_list_cmd
,
6646 "show ip bgp prefix-list WORD",
6650 "Display routes conforming to the prefix-list\n"
6651 "IP prefix-list name\n")
6653 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
6654 bgp_show_type_prefix_list
);
6657 DEFUN (show_ip_bgp_flap_prefix_list
,
6658 show_ip_bgp_flap_prefix_list_cmd
,
6659 "show ip bgp flap-statistics prefix-list WORD",
6663 "Display flap statistics of routes\n"
6664 "Display routes conforming to the prefix-list\n"
6665 "IP prefix-list name\n")
6667 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
6668 bgp_show_type_flap_prefix_list
);
6671 DEFUN (show_ip_bgp_ipv4_prefix_list
,
6672 show_ip_bgp_ipv4_prefix_list_cmd
,
6673 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
6678 "Address Family modifier\n"
6679 "Address Family modifier\n"
6680 "Display routes conforming to the prefix-list\n"
6681 "IP prefix-list name\n")
6683 if (strncmp (argv
[0], "m", 1) == 0)
6684 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
6685 bgp_show_type_prefix_list
);
6687 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
6688 bgp_show_type_prefix_list
);
6692 DEFUN (show_bgp_prefix_list
,
6693 show_bgp_prefix_list_cmd
,
6694 "show bgp prefix-list WORD",
6697 "Display routes conforming to the prefix-list\n"
6698 "IPv6 prefix-list name\n")
6700 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
6701 bgp_show_type_prefix_list
);
6704 ALIAS (show_bgp_prefix_list
,
6705 show_bgp_ipv6_prefix_list_cmd
,
6706 "show bgp ipv6 prefix-list WORD",
6710 "Display routes conforming to the prefix-list\n"
6711 "IPv6 prefix-list name\n")
6714 DEFUN (show_ipv6_bgp_prefix_list
,
6715 show_ipv6_bgp_prefix_list_cmd
,
6716 "show ipv6 bgp prefix-list WORD",
6720 "Display routes matching the prefix-list\n"
6721 "IPv6 prefix-list name\n")
6723 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
6724 bgp_show_type_prefix_list
);
6728 DEFUN (show_ipv6_mbgp_prefix_list
,
6729 show_ipv6_mbgp_prefix_list_cmd
,
6730 "show ipv6 mbgp prefix-list WORD",
6734 "Display routes matching the prefix-list\n"
6735 "IPv6 prefix-list name\n")
6737 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
6738 bgp_show_type_prefix_list
);
6740 #endif /* HAVE_IPV6 */
6743 bgp_show_filter_list (struct vty
*vty
, const char *filter
, afi_t afi
,
6744 safi_t safi
, enum bgp_show_type type
)
6746 struct as_list
*as_list
;
6748 as_list
= as_list_lookup (filter
);
6749 if (as_list
== NULL
)
6751 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
6755 return bgp_show (vty
, NULL
, afi
, safi
, type
, as_list
);
6758 DEFUN (show_ip_bgp_filter_list
,
6759 show_ip_bgp_filter_list_cmd
,
6760 "show ip bgp filter-list WORD",
6764 "Display routes conforming to the filter-list\n"
6765 "Regular expression access list name\n")
6767 return bgp_show_filter_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
6768 bgp_show_type_filter_list
);
6771 DEFUN (show_ip_bgp_flap_filter_list
,
6772 show_ip_bgp_flap_filter_list_cmd
,
6773 "show ip bgp flap-statistics filter-list WORD",
6777 "Display flap statistics of routes\n"
6778 "Display routes conforming to the filter-list\n"
6779 "Regular expression access list name\n")
6781 return bgp_show_filter_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
6782 bgp_show_type_flap_filter_list
);
6785 DEFUN (show_ip_bgp_ipv4_filter_list
,
6786 show_ip_bgp_ipv4_filter_list_cmd
,
6787 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
6792 "Address Family modifier\n"
6793 "Address Family modifier\n"
6794 "Display routes conforming to the filter-list\n"
6795 "Regular expression access list name\n")
6797 if (strncmp (argv
[0], "m", 1) == 0)
6798 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
6799 bgp_show_type_filter_list
);
6801 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
6802 bgp_show_type_filter_list
);
6806 DEFUN (show_bgp_filter_list
,
6807 show_bgp_filter_list_cmd
,
6808 "show bgp filter-list WORD",
6811 "Display routes conforming to the filter-list\n"
6812 "Regular expression access list name\n")
6814 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
6815 bgp_show_type_filter_list
);
6818 ALIAS (show_bgp_filter_list
,
6819 show_bgp_ipv6_filter_list_cmd
,
6820 "show bgp ipv6 filter-list WORD",
6824 "Display routes conforming to the filter-list\n"
6825 "Regular expression access list name\n")
6828 DEFUN (show_ipv6_bgp_filter_list
,
6829 show_ipv6_bgp_filter_list_cmd
,
6830 "show ipv6 bgp filter-list WORD",
6834 "Display routes conforming to the filter-list\n"
6835 "Regular expression access list name\n")
6837 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
6838 bgp_show_type_filter_list
);
6842 DEFUN (show_ipv6_mbgp_filter_list
,
6843 show_ipv6_mbgp_filter_list_cmd
,
6844 "show ipv6 mbgp filter-list WORD",
6848 "Display routes conforming to the filter-list\n"
6849 "Regular expression access list name\n")
6851 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
6852 bgp_show_type_filter_list
);
6854 #endif /* HAVE_IPV6 */
6857 bgp_show_route_map (struct vty
*vty
, const char *rmap_str
, afi_t afi
,
6858 safi_t safi
, enum bgp_show_type type
)
6860 struct route_map
*rmap
;
6862 rmap
= route_map_lookup_by_name (rmap_str
);
6865 vty_out (vty
, "%% %s is not a valid route-map name%s",
6866 rmap_str
, VTY_NEWLINE
);
6870 return bgp_show (vty
, NULL
, afi
, safi
, type
, rmap
);
6873 DEFUN (show_ip_bgp_route_map
,
6874 show_ip_bgp_route_map_cmd
,
6875 "show ip bgp route-map WORD",
6879 "Display routes matching the route-map\n"
6880 "A route-map to match on\n")
6882 return bgp_show_route_map (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
6883 bgp_show_type_route_map
);
6886 DEFUN (show_ip_bgp_flap_route_map
,
6887 show_ip_bgp_flap_route_map_cmd
,
6888 "show ip bgp flap-statistics route-map WORD",
6892 "Display flap statistics of routes\n"
6893 "Display routes matching the route-map\n"
6894 "A route-map to match on\n")
6896 return bgp_show_route_map (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
6897 bgp_show_type_flap_route_map
);
6900 DEFUN (show_ip_bgp_ipv4_route_map
,
6901 show_ip_bgp_ipv4_route_map_cmd
,
6902 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
6907 "Address Family modifier\n"
6908 "Address Family modifier\n"
6909 "Display routes matching the route-map\n"
6910 "A route-map to match on\n")
6912 if (strncmp (argv
[0], "m", 1) == 0)
6913 return bgp_show_route_map (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
6914 bgp_show_type_route_map
);
6916 return bgp_show_route_map (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
6917 bgp_show_type_route_map
);
6920 DEFUN (show_bgp_route_map
,
6921 show_bgp_route_map_cmd
,
6922 "show bgp route-map WORD",
6925 "Display routes matching the route-map\n"
6926 "A route-map to match on\n")
6928 return bgp_show_route_map (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
6929 bgp_show_type_route_map
);
6932 ALIAS (show_bgp_route_map
,
6933 show_bgp_ipv6_route_map_cmd
,
6934 "show bgp ipv6 route-map WORD",
6938 "Display routes matching the route-map\n"
6939 "A route-map to match on\n")
6941 DEFUN (show_ip_bgp_cidr_only
,
6942 show_ip_bgp_cidr_only_cmd
,
6943 "show ip bgp cidr-only",
6947 "Display only routes with non-natural netmasks\n")
6949 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
6950 bgp_show_type_cidr_only
, NULL
);
6953 DEFUN (show_ip_bgp_flap_cidr_only
,
6954 show_ip_bgp_flap_cidr_only_cmd
,
6955 "show ip bgp flap-statistics cidr-only",
6959 "Display flap statistics of routes\n"
6960 "Display only routes with non-natural netmasks\n")
6962 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
6963 bgp_show_type_flap_cidr_only
, NULL
);
6966 DEFUN (show_ip_bgp_ipv4_cidr_only
,
6967 show_ip_bgp_ipv4_cidr_only_cmd
,
6968 "show ip bgp ipv4 (unicast|multicast) cidr-only",
6973 "Address Family modifier\n"
6974 "Address Family modifier\n"
6975 "Display only routes with non-natural netmasks\n")
6977 if (strncmp (argv
[0], "m", 1) == 0)
6978 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
6979 bgp_show_type_cidr_only
, NULL
);
6981 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
6982 bgp_show_type_cidr_only
, NULL
);
6985 DEFUN (show_ip_bgp_community_all
,
6986 show_ip_bgp_community_all_cmd
,
6987 "show ip bgp community",
6991 "Display routes matching the communities\n")
6993 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
6994 bgp_show_type_community_all
, NULL
);
6997 DEFUN (show_ip_bgp_ipv4_community_all
,
6998 show_ip_bgp_ipv4_community_all_cmd
,
6999 "show ip bgp ipv4 (unicast|multicast) community",
7004 "Address Family modifier\n"
7005 "Address Family modifier\n"
7006 "Display routes matching the communities\n")
7008 if (strncmp (argv
[0], "m", 1) == 0)
7009 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
7010 bgp_show_type_community_all
, NULL
);
7012 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7013 bgp_show_type_community_all
, NULL
);
7017 DEFUN (show_bgp_community_all
,
7018 show_bgp_community_all_cmd
,
7019 "show bgp community",
7022 "Display routes matching the communities\n")
7024 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
7025 bgp_show_type_community_all
, NULL
);
7028 ALIAS (show_bgp_community_all
,
7029 show_bgp_ipv6_community_all_cmd
,
7030 "show bgp ipv6 community",
7034 "Display routes matching the communities\n")
7037 DEFUN (show_ipv6_bgp_community_all
,
7038 show_ipv6_bgp_community_all_cmd
,
7039 "show ipv6 bgp community",
7043 "Display routes matching the communities\n")
7045 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
7046 bgp_show_type_community_all
, NULL
);
7050 DEFUN (show_ipv6_mbgp_community_all
,
7051 show_ipv6_mbgp_community_all_cmd
,
7052 "show ipv6 mbgp community",
7056 "Display routes matching the communities\n")
7058 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
7059 bgp_show_type_community_all
, NULL
);
7061 #endif /* HAVE_IPV6 */
7064 bgp_show_community (struct vty
*vty
, int argc
, const char **argv
, int exact
,
7065 u_int16_t afi
, u_char safi
)
7067 struct community
*com
;
7073 b
= buffer_new (1024);
7074 for (i
= 0; i
< argc
; i
++)
7077 buffer_putc (b
, ' ');
7080 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
7085 buffer_putstr (b
, argv
[i
]);
7087 buffer_putc (b
, '\0');
7089 str
= buffer_getstr (b
);
7092 com
= community_str2com (str
);
7093 XFREE (MTYPE_TMP
, str
);
7096 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
7100 return bgp_show (vty
, NULL
, afi
, safi
,
7101 (exact
? bgp_show_type_community_exact
:
7102 bgp_show_type_community
), com
);
7105 DEFUN (show_ip_bgp_community
,
7106 show_ip_bgp_community_cmd
,
7107 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
7111 "Display routes matching the communities\n"
7112 "community number\n"
7113 "Do not send outside local AS (well-known community)\n"
7114 "Do not advertise to any peer (well-known community)\n"
7115 "Do not export to next AS (well-known community)\n")
7117 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
7120 ALIAS (show_ip_bgp_community
,
7121 show_ip_bgp_community2_cmd
,
7122 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7126 "Display routes matching the communities\n"
7127 "community number\n"
7128 "Do not send outside local AS (well-known community)\n"
7129 "Do not advertise to any peer (well-known community)\n"
7130 "Do not export to next AS (well-known community)\n"
7131 "community number\n"
7132 "Do not send outside local AS (well-known community)\n"
7133 "Do not advertise to any peer (well-known community)\n"
7134 "Do not export to next AS (well-known community)\n")
7136 ALIAS (show_ip_bgp_community
,
7137 show_ip_bgp_community3_cmd
,
7138 "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)",
7142 "Display routes matching the communities\n"
7143 "community number\n"
7144 "Do not send outside local AS (well-known community)\n"
7145 "Do not advertise to any peer (well-known community)\n"
7146 "Do not export to next AS (well-known community)\n"
7147 "community number\n"
7148 "Do not send outside local AS (well-known community)\n"
7149 "Do not advertise to any peer (well-known community)\n"
7150 "Do not export to next AS (well-known community)\n"
7151 "community number\n"
7152 "Do not send outside local AS (well-known community)\n"
7153 "Do not advertise to any peer (well-known community)\n"
7154 "Do not export to next AS (well-known community)\n")
7156 ALIAS (show_ip_bgp_community
,
7157 show_ip_bgp_community4_cmd
,
7158 "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)",
7162 "Display routes matching the communities\n"
7163 "community number\n"
7164 "Do not send outside local AS (well-known community)\n"
7165 "Do not advertise to any peer (well-known community)\n"
7166 "Do not export to next AS (well-known community)\n"
7167 "community number\n"
7168 "Do not send outside local AS (well-known community)\n"
7169 "Do not advertise to any peer (well-known community)\n"
7170 "Do not export to next AS (well-known community)\n"
7171 "community number\n"
7172 "Do not send outside local AS (well-known community)\n"
7173 "Do not advertise to any peer (well-known community)\n"
7174 "Do not export to next AS (well-known community)\n"
7175 "community number\n"
7176 "Do not send outside local AS (well-known community)\n"
7177 "Do not advertise to any peer (well-known community)\n"
7178 "Do not export to next AS (well-known community)\n")
7180 DEFUN (show_ip_bgp_ipv4_community
,
7181 show_ip_bgp_ipv4_community_cmd
,
7182 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
7187 "Address Family modifier\n"
7188 "Address Family modifier\n"
7189 "Display routes matching the communities\n"
7190 "community number\n"
7191 "Do not send outside local AS (well-known community)\n"
7192 "Do not advertise to any peer (well-known community)\n"
7193 "Do not export to next AS (well-known community)\n")
7195 if (strncmp (argv
[0], "m", 1) == 0)
7196 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_MULTICAST
);
7198 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
7201 ALIAS (show_ip_bgp_ipv4_community
,
7202 show_ip_bgp_ipv4_community2_cmd
,
7203 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7208 "Address Family modifier\n"
7209 "Address Family modifier\n"
7210 "Display routes matching the communities\n"
7211 "community number\n"
7212 "Do not send outside local AS (well-known community)\n"
7213 "Do not advertise to any peer (well-known community)\n"
7214 "Do not export to next AS (well-known community)\n"
7215 "community number\n"
7216 "Do not send outside local AS (well-known community)\n"
7217 "Do not advertise to any peer (well-known community)\n"
7218 "Do not export to next AS (well-known community)\n")
7220 ALIAS (show_ip_bgp_ipv4_community
,
7221 show_ip_bgp_ipv4_community3_cmd
,
7222 "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)",
7227 "Address Family modifier\n"
7228 "Address Family modifier\n"
7229 "Display routes matching the communities\n"
7230 "community number\n"
7231 "Do not send outside local AS (well-known community)\n"
7232 "Do not advertise to any peer (well-known community)\n"
7233 "Do not export to next AS (well-known community)\n"
7234 "community number\n"
7235 "Do not send outside local AS (well-known community)\n"
7236 "Do not advertise to any peer (well-known community)\n"
7237 "Do not export to next AS (well-known community)\n"
7238 "community number\n"
7239 "Do not send outside local AS (well-known community)\n"
7240 "Do not advertise to any peer (well-known community)\n"
7241 "Do not export to next AS (well-known community)\n")
7243 ALIAS (show_ip_bgp_ipv4_community
,
7244 show_ip_bgp_ipv4_community4_cmd
,
7245 "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)",
7250 "Address Family modifier\n"
7251 "Address Family modifier\n"
7252 "Display routes matching the communities\n"
7253 "community number\n"
7254 "Do not send outside local AS (well-known community)\n"
7255 "Do not advertise to any peer (well-known community)\n"
7256 "Do not export to next AS (well-known community)\n"
7257 "community number\n"
7258 "Do not send outside local AS (well-known community)\n"
7259 "Do not advertise to any peer (well-known community)\n"
7260 "Do not export to next AS (well-known community)\n"
7261 "community number\n"
7262 "Do not send outside local AS (well-known community)\n"
7263 "Do not advertise to any peer (well-known community)\n"
7264 "Do not export to next AS (well-known community)\n"
7265 "community number\n"
7266 "Do not send outside local AS (well-known community)\n"
7267 "Do not advertise to any peer (well-known community)\n"
7268 "Do not export to next AS (well-known community)\n")
7270 DEFUN (show_ip_bgp_community_exact
,
7271 show_ip_bgp_community_exact_cmd
,
7272 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7276 "Display routes matching the communities\n"
7277 "community number\n"
7278 "Do not send outside local AS (well-known community)\n"
7279 "Do not advertise to any peer (well-known community)\n"
7280 "Do not export to next AS (well-known community)\n"
7281 "Exact match of the communities")
7283 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
7286 ALIAS (show_ip_bgp_community_exact
,
7287 show_ip_bgp_community2_exact_cmd
,
7288 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7292 "Display routes matching the communities\n"
7293 "community number\n"
7294 "Do not send outside local AS (well-known community)\n"
7295 "Do not advertise to any peer (well-known community)\n"
7296 "Do not export to next AS (well-known community)\n"
7297 "community number\n"
7298 "Do not send outside local AS (well-known community)\n"
7299 "Do not advertise to any peer (well-known community)\n"
7300 "Do not export to next AS (well-known community)\n"
7301 "Exact match of the communities")
7303 ALIAS (show_ip_bgp_community_exact
,
7304 show_ip_bgp_community3_exact_cmd
,
7305 "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) exact-match",
7309 "Display routes matching the communities\n"
7310 "community number\n"
7311 "Do not send outside local AS (well-known community)\n"
7312 "Do not advertise to any peer (well-known community)\n"
7313 "Do not export to next AS (well-known community)\n"
7314 "community number\n"
7315 "Do not send outside local AS (well-known community)\n"
7316 "Do not advertise to any peer (well-known community)\n"
7317 "Do not export to next AS (well-known community)\n"
7318 "community number\n"
7319 "Do not send outside local AS (well-known community)\n"
7320 "Do not advertise to any peer (well-known community)\n"
7321 "Do not export to next AS (well-known community)\n"
7322 "Exact match of the communities")
7324 ALIAS (show_ip_bgp_community_exact
,
7325 show_ip_bgp_community4_exact_cmd
,
7326 "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) exact-match",
7330 "Display routes matching the communities\n"
7331 "community number\n"
7332 "Do not send outside local AS (well-known community)\n"
7333 "Do not advertise to any peer (well-known community)\n"
7334 "Do not export to next AS (well-known community)\n"
7335 "community number\n"
7336 "Do not send outside local AS (well-known community)\n"
7337 "Do not advertise to any peer (well-known community)\n"
7338 "Do not export to next AS (well-known community)\n"
7339 "community number\n"
7340 "Do not send outside local AS (well-known community)\n"
7341 "Do not advertise to any peer (well-known community)\n"
7342 "Do not export to next AS (well-known community)\n"
7343 "community number\n"
7344 "Do not send outside local AS (well-known community)\n"
7345 "Do not advertise to any peer (well-known community)\n"
7346 "Do not export to next AS (well-known community)\n"
7347 "Exact match of the communities")
7349 DEFUN (show_ip_bgp_ipv4_community_exact
,
7350 show_ip_bgp_ipv4_community_exact_cmd
,
7351 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7356 "Address Family modifier\n"
7357 "Address Family modifier\n"
7358 "Display routes matching the communities\n"
7359 "community number\n"
7360 "Do not send outside local AS (well-known community)\n"
7361 "Do not advertise to any peer (well-known community)\n"
7362 "Do not export to next AS (well-known community)\n"
7363 "Exact match of the communities")
7365 if (strncmp (argv
[0], "m", 1) == 0)
7366 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_MULTICAST
);
7368 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
7371 ALIAS (show_ip_bgp_ipv4_community_exact
,
7372 show_ip_bgp_ipv4_community2_exact_cmd
,
7373 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7378 "Address Family modifier\n"
7379 "Address Family modifier\n"
7380 "Display routes matching the communities\n"
7381 "community number\n"
7382 "Do not send outside local AS (well-known community)\n"
7383 "Do not advertise to any peer (well-known community)\n"
7384 "Do not export to next AS (well-known community)\n"
7385 "community number\n"
7386 "Do not send outside local AS (well-known community)\n"
7387 "Do not advertise to any peer (well-known community)\n"
7388 "Do not export to next AS (well-known community)\n"
7389 "Exact match of the communities")
7391 ALIAS (show_ip_bgp_ipv4_community_exact
,
7392 show_ip_bgp_ipv4_community3_exact_cmd
,
7393 "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) exact-match",
7398 "Address Family modifier\n"
7399 "Address Family modifier\n"
7400 "Display routes matching the communities\n"
7401 "community number\n"
7402 "Do not send outside local AS (well-known community)\n"
7403 "Do not advertise to any peer (well-known community)\n"
7404 "Do not export to next AS (well-known community)\n"
7405 "community number\n"
7406 "Do not send outside local AS (well-known community)\n"
7407 "Do not advertise to any peer (well-known community)\n"
7408 "Do not export to next AS (well-known community)\n"
7409 "community number\n"
7410 "Do not send outside local AS (well-known community)\n"
7411 "Do not advertise to any peer (well-known community)\n"
7412 "Do not export to next AS (well-known community)\n"
7413 "Exact match of the communities")
7415 ALIAS (show_ip_bgp_ipv4_community_exact
,
7416 show_ip_bgp_ipv4_community4_exact_cmd
,
7417 "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",
7422 "Address Family modifier\n"
7423 "Address Family modifier\n"
7424 "Display routes matching the communities\n"
7425 "community number\n"
7426 "Do not send outside local AS (well-known community)\n"
7427 "Do not advertise to any peer (well-known community)\n"
7428 "Do not export to next AS (well-known community)\n"
7429 "community number\n"
7430 "Do not send outside local AS (well-known community)\n"
7431 "Do not advertise to any peer (well-known community)\n"
7432 "Do not export to next AS (well-known community)\n"
7433 "community number\n"
7434 "Do not send outside local AS (well-known community)\n"
7435 "Do not advertise to any peer (well-known community)\n"
7436 "Do not export to next AS (well-known community)\n"
7437 "community number\n"
7438 "Do not send outside local AS (well-known community)\n"
7439 "Do not advertise to any peer (well-known community)\n"
7440 "Do not export to next AS (well-known community)\n"
7441 "Exact match of the communities")
7444 DEFUN (show_bgp_community
,
7445 show_bgp_community_cmd
,
7446 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
7449 "Display routes matching the communities\n"
7450 "community number\n"
7451 "Do not send outside local AS (well-known community)\n"
7452 "Do not advertise to any peer (well-known community)\n"
7453 "Do not export to next AS (well-known community)\n")
7455 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
7458 ALIAS (show_bgp_community
,
7459 show_bgp_ipv6_community_cmd
,
7460 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
7464 "Display routes matching the communities\n"
7465 "community number\n"
7466 "Do not send outside local AS (well-known community)\n"
7467 "Do not advertise to any peer (well-known community)\n"
7468 "Do not export to next AS (well-known community)\n")
7470 ALIAS (show_bgp_community
,
7471 show_bgp_community2_cmd
,
7472 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7475 "Display routes matching the communities\n"
7476 "community number\n"
7477 "Do not send outside local AS (well-known community)\n"
7478 "Do not advertise to any peer (well-known community)\n"
7479 "Do not export to next AS (well-known community)\n"
7480 "community number\n"
7481 "Do not send outside local AS (well-known community)\n"
7482 "Do not advertise to any peer (well-known community)\n"
7483 "Do not export to next AS (well-known community)\n")
7485 ALIAS (show_bgp_community
,
7486 show_bgp_ipv6_community2_cmd
,
7487 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7491 "Display routes matching the communities\n"
7492 "community number\n"
7493 "Do not send outside local AS (well-known community)\n"
7494 "Do not advertise to any peer (well-known community)\n"
7495 "Do not export to next AS (well-known community)\n"
7496 "community number\n"
7497 "Do not send outside local AS (well-known community)\n"
7498 "Do not advertise to any peer (well-known community)\n"
7499 "Do not export to next AS (well-known community)\n")
7501 ALIAS (show_bgp_community
,
7502 show_bgp_community3_cmd
,
7503 "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)",
7506 "Display routes matching the communities\n"
7507 "community number\n"
7508 "Do not send outside local AS (well-known community)\n"
7509 "Do not advertise to any peer (well-known community)\n"
7510 "Do not export to next AS (well-known community)\n"
7511 "community number\n"
7512 "Do not send outside local AS (well-known community)\n"
7513 "Do not advertise to any peer (well-known community)\n"
7514 "Do not export to next AS (well-known community)\n"
7515 "community number\n"
7516 "Do not send outside local AS (well-known community)\n"
7517 "Do not advertise to any peer (well-known community)\n"
7518 "Do not export to next AS (well-known community)\n")
7520 ALIAS (show_bgp_community
,
7521 show_bgp_ipv6_community3_cmd
,
7522 "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)",
7526 "Display routes matching the communities\n"
7527 "community number\n"
7528 "Do not send outside local AS (well-known community)\n"
7529 "Do not advertise to any peer (well-known community)\n"
7530 "Do not export to next AS (well-known community)\n"
7531 "community number\n"
7532 "Do not send outside local AS (well-known community)\n"
7533 "Do not advertise to any peer (well-known community)\n"
7534 "Do not export to next AS (well-known community)\n"
7535 "community number\n"
7536 "Do not send outside local AS (well-known community)\n"
7537 "Do not advertise to any peer (well-known community)\n"
7538 "Do not export to next AS (well-known community)\n")
7540 ALIAS (show_bgp_community
,
7541 show_bgp_community4_cmd
,
7542 "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) (AA:NN|local-AS|no-advertise|no-export)",
7545 "Display routes matching the communities\n"
7546 "community number\n"
7547 "Do not send outside local AS (well-known community)\n"
7548 "Do not advertise to any peer (well-known community)\n"
7549 "Do not export to next AS (well-known community)\n"
7550 "community number\n"
7551 "Do not send outside local AS (well-known community)\n"
7552 "Do not advertise to any peer (well-known community)\n"
7553 "Do not export to next AS (well-known community)\n"
7554 "community number\n"
7555 "Do not send outside local AS (well-known community)\n"
7556 "Do not advertise to any peer (well-known community)\n"
7557 "Do not export to next AS (well-known community)\n"
7558 "community number\n"
7559 "Do not send outside local AS (well-known community)\n"
7560 "Do not advertise to any peer (well-known community)\n"
7561 "Do not export to next AS (well-known community)\n")
7563 ALIAS (show_bgp_community
,
7564 show_bgp_ipv6_community4_cmd
,
7565 "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)",
7569 "Display routes matching the communities\n"
7570 "community number\n"
7571 "Do not send outside local AS (well-known community)\n"
7572 "Do not advertise to any peer (well-known community)\n"
7573 "Do not export to next AS (well-known community)\n"
7574 "community number\n"
7575 "Do not send outside local AS (well-known community)\n"
7576 "Do not advertise to any peer (well-known community)\n"
7577 "Do not export to next AS (well-known community)\n"
7578 "community number\n"
7579 "Do not send outside local AS (well-known community)\n"
7580 "Do not advertise to any peer (well-known community)\n"
7581 "Do not export to next AS (well-known community)\n"
7582 "community number\n"
7583 "Do not send outside local AS (well-known community)\n"
7584 "Do not advertise to any peer (well-known community)\n"
7585 "Do not export to next AS (well-known community)\n")
7588 DEFUN (show_ipv6_bgp_community
,
7589 show_ipv6_bgp_community_cmd
,
7590 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
7594 "Display routes matching the communities\n"
7595 "community number\n"
7596 "Do not send outside local AS (well-known community)\n"
7597 "Do not advertise to any peer (well-known community)\n"
7598 "Do not export to next AS (well-known community)\n")
7600 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
7604 ALIAS (show_ipv6_bgp_community
,
7605 show_ipv6_bgp_community2_cmd
,
7606 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7610 "Display routes matching the communities\n"
7611 "community number\n"
7612 "Do not send outside local AS (well-known community)\n"
7613 "Do not advertise to any peer (well-known community)\n"
7614 "Do not export to next AS (well-known community)\n"
7615 "community number\n"
7616 "Do not send outside local AS (well-known community)\n"
7617 "Do not advertise to any peer (well-known community)\n"
7618 "Do not export to next AS (well-known community)\n")
7621 ALIAS (show_ipv6_bgp_community
,
7622 show_ipv6_bgp_community3_cmd
,
7623 "show ipv6 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)",
7627 "Display routes matching the communities\n"
7628 "community number\n"
7629 "Do not send outside local AS (well-known community)\n"
7630 "Do not advertise to any peer (well-known community)\n"
7631 "Do not export to next AS (well-known community)\n"
7632 "community number\n"
7633 "Do not send outside local AS (well-known community)\n"
7634 "Do not advertise to any peer (well-known community)\n"
7635 "Do not export to next AS (well-known community)\n"
7636 "community number\n"
7637 "Do not send outside local AS (well-known community)\n"
7638 "Do not advertise to any peer (well-known community)\n"
7639 "Do not export to next AS (well-known community)\n")
7642 ALIAS (show_ipv6_bgp_community
,
7643 show_ipv6_bgp_community4_cmd
,
7644 "show ipv6 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)",
7648 "Display routes matching the communities\n"
7649 "community number\n"
7650 "Do not send outside local AS (well-known community)\n"
7651 "Do not advertise to any peer (well-known community)\n"
7652 "Do not export to next AS (well-known community)\n"
7653 "community number\n"
7654 "Do not send outside local AS (well-known community)\n"
7655 "Do not advertise to any peer (well-known community)\n"
7656 "Do not export to next AS (well-known community)\n"
7657 "community number\n"
7658 "Do not send outside local AS (well-known community)\n"
7659 "Do not advertise to any peer (well-known community)\n"
7660 "Do not export to next AS (well-known community)\n"
7661 "community number\n"
7662 "Do not send outside local AS (well-known community)\n"
7663 "Do not advertise to any peer (well-known community)\n"
7664 "Do not export to next AS (well-known community)\n")
7666 DEFUN (show_bgp_community_exact
,
7667 show_bgp_community_exact_cmd
,
7668 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7671 "Display routes matching the communities\n"
7672 "community number\n"
7673 "Do not send outside local AS (well-known community)\n"
7674 "Do not advertise to any peer (well-known community)\n"
7675 "Do not export to next AS (well-known community)\n"
7676 "Exact match of the communities")
7678 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
7681 ALIAS (show_bgp_community_exact
,
7682 show_bgp_ipv6_community_exact_cmd
,
7683 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7687 "Display routes matching the communities\n"
7688 "community number\n"
7689 "Do not send outside local AS (well-known community)\n"
7690 "Do not advertise to any peer (well-known community)\n"
7691 "Do not export to next AS (well-known community)\n"
7692 "Exact match of the communities")
7694 ALIAS (show_bgp_community_exact
,
7695 show_bgp_community2_exact_cmd
,
7696 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7699 "Display routes matching the communities\n"
7700 "community number\n"
7701 "Do not send outside local AS (well-known community)\n"
7702 "Do not advertise to any peer (well-known community)\n"
7703 "Do not export to next AS (well-known community)\n"
7704 "community number\n"
7705 "Do not send outside local AS (well-known community)\n"
7706 "Do not advertise to any peer (well-known community)\n"
7707 "Do not export to next AS (well-known community)\n"
7708 "Exact match of the communities")
7710 ALIAS (show_bgp_community_exact
,
7711 show_bgp_ipv6_community2_exact_cmd
,
7712 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7716 "Display routes matching the communities\n"
7717 "community number\n"
7718 "Do not send outside local AS (well-known community)\n"
7719 "Do not advertise to any peer (well-known community)\n"
7720 "Do not export to next AS (well-known community)\n"
7721 "community number\n"
7722 "Do not send outside local AS (well-known community)\n"
7723 "Do not advertise to any peer (well-known community)\n"
7724 "Do not export to next AS (well-known community)\n"
7725 "Exact match of the communities")
7727 ALIAS (show_bgp_community_exact
,
7728 show_bgp_community3_exact_cmd
,
7729 "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) exact-match",
7732 "Display routes matching the communities\n"
7733 "community number\n"
7734 "Do not send outside local AS (well-known community)\n"
7735 "Do not advertise to any peer (well-known community)\n"
7736 "Do not export to next AS (well-known community)\n"
7737 "community number\n"
7738 "Do not send outside local AS (well-known community)\n"
7739 "Do not advertise to any peer (well-known community)\n"
7740 "Do not export to next AS (well-known community)\n"
7741 "community number\n"
7742 "Do not send outside local AS (well-known community)\n"
7743 "Do not advertise to any peer (well-known community)\n"
7744 "Do not export to next AS (well-known community)\n"
7745 "Exact match of the communities")
7747 ALIAS (show_bgp_community_exact
,
7748 show_bgp_ipv6_community3_exact_cmd
,
7749 "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) exact-match",
7753 "Display routes matching the communities\n"
7754 "community number\n"
7755 "Do not send outside local AS (well-known community)\n"
7756 "Do not advertise to any peer (well-known community)\n"
7757 "Do not export to next AS (well-known community)\n"
7758 "community number\n"
7759 "Do not send outside local AS (well-known community)\n"
7760 "Do not advertise to any peer (well-known community)\n"
7761 "Do not export to next AS (well-known community)\n"
7762 "community number\n"
7763 "Do not send outside local AS (well-known community)\n"
7764 "Do not advertise to any peer (well-known community)\n"
7765 "Do not export to next AS (well-known community)\n"
7766 "Exact match of the communities")
7768 ALIAS (show_bgp_community_exact
,
7769 show_bgp_community4_exact_cmd
,
7770 "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) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7773 "Display routes matching the communities\n"
7774 "community number\n"
7775 "Do not send outside local AS (well-known community)\n"
7776 "Do not advertise to any peer (well-known community)\n"
7777 "Do not export to next AS (well-known community)\n"
7778 "community number\n"
7779 "Do not send outside local AS (well-known community)\n"
7780 "Do not advertise to any peer (well-known community)\n"
7781 "Do not export to next AS (well-known community)\n"
7782 "community number\n"
7783 "Do not send outside local AS (well-known community)\n"
7784 "Do not advertise to any peer (well-known community)\n"
7785 "Do not export to next AS (well-known community)\n"
7786 "community number\n"
7787 "Do not send outside local AS (well-known community)\n"
7788 "Do not advertise to any peer (well-known community)\n"
7789 "Do not export to next AS (well-known community)\n"
7790 "Exact match of the communities")
7792 ALIAS (show_bgp_community_exact
,
7793 show_bgp_ipv6_community4_exact_cmd
,
7794 "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",
7798 "Display routes matching the communities\n"
7799 "community number\n"
7800 "Do not send outside local AS (well-known community)\n"
7801 "Do not advertise to any peer (well-known community)\n"
7802 "Do not export to next AS (well-known community)\n"
7803 "community number\n"
7804 "Do not send outside local AS (well-known community)\n"
7805 "Do not advertise to any peer (well-known community)\n"
7806 "Do not export to next AS (well-known community)\n"
7807 "community number\n"
7808 "Do not send outside local AS (well-known community)\n"
7809 "Do not advertise to any peer (well-known community)\n"
7810 "Do not export to next AS (well-known community)\n"
7811 "community number\n"
7812 "Do not send outside local AS (well-known community)\n"
7813 "Do not advertise to any peer (well-known community)\n"
7814 "Do not export to next AS (well-known community)\n"
7815 "Exact match of the communities")
7818 DEFUN (show_ipv6_bgp_community_exact
,
7819 show_ipv6_bgp_community_exact_cmd
,
7820 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7824 "Display routes matching the communities\n"
7825 "community number\n"
7826 "Do not send outside local AS (well-known community)\n"
7827 "Do not advertise to any peer (well-known community)\n"
7828 "Do not export to next AS (well-known community)\n"
7829 "Exact match of the communities")
7831 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
7835 ALIAS (show_ipv6_bgp_community_exact
,
7836 show_ipv6_bgp_community2_exact_cmd
,
7837 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7841 "Display routes matching the communities\n"
7842 "community number\n"
7843 "Do not send outside local AS (well-known community)\n"
7844 "Do not advertise to any peer (well-known community)\n"
7845 "Do not export to next AS (well-known community)\n"
7846 "community number\n"
7847 "Do not send outside local AS (well-known community)\n"
7848 "Do not advertise to any peer (well-known community)\n"
7849 "Do not export to next AS (well-known community)\n"
7850 "Exact match of the communities")
7853 ALIAS (show_ipv6_bgp_community_exact
,
7854 show_ipv6_bgp_community3_exact_cmd
,
7855 "show ipv6 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) exact-match",
7859 "Display routes matching the communities\n"
7860 "community number\n"
7861 "Do not send outside local AS (well-known community)\n"
7862 "Do not advertise to any peer (well-known community)\n"
7863 "Do not export to next AS (well-known community)\n"
7864 "community number\n"
7865 "Do not send outside local AS (well-known community)\n"
7866 "Do not advertise to any peer (well-known community)\n"
7867 "Do not export to next AS (well-known community)\n"
7868 "community number\n"
7869 "Do not send outside local AS (well-known community)\n"
7870 "Do not advertise to any peer (well-known community)\n"
7871 "Do not export to next AS (well-known community)\n"
7872 "Exact match of the communities")
7875 ALIAS (show_ipv6_bgp_community_exact
,
7876 show_ipv6_bgp_community4_exact_cmd
,
7877 "show ipv6 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) exact-match",
7881 "Display routes matching the communities\n"
7882 "community number\n"
7883 "Do not send outside local AS (well-known community)\n"
7884 "Do not advertise to any peer (well-known community)\n"
7885 "Do not export to next AS (well-known community)\n"
7886 "community number\n"
7887 "Do not send outside local AS (well-known community)\n"
7888 "Do not advertise to any peer (well-known community)\n"
7889 "Do not export to next AS (well-known community)\n"
7890 "community number\n"
7891 "Do not send outside local AS (well-known community)\n"
7892 "Do not advertise to any peer (well-known community)\n"
7893 "Do not export to next AS (well-known community)\n"
7894 "community number\n"
7895 "Do not send outside local AS (well-known community)\n"
7896 "Do not advertise to any peer (well-known community)\n"
7897 "Do not export to next AS (well-known community)\n"
7898 "Exact match of the communities")
7901 DEFUN (show_ipv6_mbgp_community
,
7902 show_ipv6_mbgp_community_cmd
,
7903 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
7907 "Display routes matching the communities\n"
7908 "community number\n"
7909 "Do not send outside local AS (well-known community)\n"
7910 "Do not advertise to any peer (well-known community)\n"
7911 "Do not export to next AS (well-known community)\n")
7913 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
7917 ALIAS (show_ipv6_mbgp_community
,
7918 show_ipv6_mbgp_community2_cmd
,
7919 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7923 "Display routes matching the communities\n"
7924 "community number\n"
7925 "Do not send outside local AS (well-known community)\n"
7926 "Do not advertise to any peer (well-known community)\n"
7927 "Do not export to next AS (well-known community)\n"
7928 "community number\n"
7929 "Do not send outside local AS (well-known community)\n"
7930 "Do not advertise to any peer (well-known community)\n"
7931 "Do not export to next AS (well-known community)\n")
7934 ALIAS (show_ipv6_mbgp_community
,
7935 show_ipv6_mbgp_community3_cmd
,
7936 "show ipv6 mbgp 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)",
7940 "Display routes matching the communities\n"
7941 "community number\n"
7942 "Do not send outside local AS (well-known community)\n"
7943 "Do not advertise to any peer (well-known community)\n"
7944 "Do not export to next AS (well-known community)\n"
7945 "community number\n"
7946 "Do not send outside local AS (well-known community)\n"
7947 "Do not advertise to any peer (well-known community)\n"
7948 "Do not export to next AS (well-known community)\n"
7949 "community number\n"
7950 "Do not send outside local AS (well-known community)\n"
7951 "Do not advertise to any peer (well-known community)\n"
7952 "Do not export to next AS (well-known community)\n")
7955 ALIAS (show_ipv6_mbgp_community
,
7956 show_ipv6_mbgp_community4_cmd
,
7957 "show ipv6 mbgp 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)",
7961 "Display routes matching the communities\n"
7962 "community number\n"
7963 "Do not send outside local AS (well-known community)\n"
7964 "Do not advertise to any peer (well-known community)\n"
7965 "Do not export to next AS (well-known community)\n"
7966 "community number\n"
7967 "Do not send outside local AS (well-known community)\n"
7968 "Do not advertise to any peer (well-known community)\n"
7969 "Do not export to next AS (well-known community)\n"
7970 "community number\n"
7971 "Do not send outside local AS (well-known community)\n"
7972 "Do not advertise to any peer (well-known community)\n"
7973 "Do not export to next AS (well-known community)\n"
7974 "community number\n"
7975 "Do not send outside local AS (well-known community)\n"
7976 "Do not advertise to any peer (well-known community)\n"
7977 "Do not export to next AS (well-known community)\n")
7980 DEFUN (show_ipv6_mbgp_community_exact
,
7981 show_ipv6_mbgp_community_exact_cmd
,
7982 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7986 "Display routes matching the communities\n"
7987 "community number\n"
7988 "Do not send outside local AS (well-known community)\n"
7989 "Do not advertise to any peer (well-known community)\n"
7990 "Do not export to next AS (well-known community)\n"
7991 "Exact match of the communities")
7993 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
7997 ALIAS (show_ipv6_mbgp_community_exact
,
7998 show_ipv6_mbgp_community2_exact_cmd
,
7999 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8003 "Display routes matching the communities\n"
8004 "community number\n"
8005 "Do not send outside local AS (well-known community)\n"
8006 "Do not advertise to any peer (well-known community)\n"
8007 "Do not export to next AS (well-known community)\n"
8008 "community number\n"
8009 "Do not send outside local AS (well-known community)\n"
8010 "Do not advertise to any peer (well-known community)\n"
8011 "Do not export to next AS (well-known community)\n"
8012 "Exact match of the communities")
8015 ALIAS (show_ipv6_mbgp_community_exact
,
8016 show_ipv6_mbgp_community3_exact_cmd
,
8017 "show ipv6 mbgp 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) exact-match",
8021 "Display routes matching the communities\n"
8022 "community number\n"
8023 "Do not send outside local AS (well-known community)\n"
8024 "Do not advertise to any peer (well-known community)\n"
8025 "Do not export to next AS (well-known community)\n"
8026 "community number\n"
8027 "Do not send outside local AS (well-known community)\n"
8028 "Do not advertise to any peer (well-known community)\n"
8029 "Do not export to next AS (well-known community)\n"
8030 "community number\n"
8031 "Do not send outside local AS (well-known community)\n"
8032 "Do not advertise to any peer (well-known community)\n"
8033 "Do not export to next AS (well-known community)\n"
8034 "Exact match of the communities")
8037 ALIAS (show_ipv6_mbgp_community_exact
,
8038 show_ipv6_mbgp_community4_exact_cmd
,
8039 "show ipv6 mbgp 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",
8043 "Display routes matching the communities\n"
8044 "community number\n"
8045 "Do not send outside local AS (well-known community)\n"
8046 "Do not advertise to any peer (well-known community)\n"
8047 "Do not export to next AS (well-known community)\n"
8048 "community number\n"
8049 "Do not send outside local AS (well-known community)\n"
8050 "Do not advertise to any peer (well-known community)\n"
8051 "Do not export to next AS (well-known community)\n"
8052 "community number\n"
8053 "Do not send outside local AS (well-known community)\n"
8054 "Do not advertise to any peer (well-known community)\n"
8055 "Do not export to next AS (well-known community)\n"
8056 "community number\n"
8057 "Do not send outside local AS (well-known community)\n"
8058 "Do not advertise to any peer (well-known community)\n"
8059 "Do not export to next AS (well-known community)\n"
8060 "Exact match of the communities")
8061 #endif /* HAVE_IPV6 */
8064 bgp_show_community_list (struct vty
*vty
, const char *com
, int exact
,
8065 u_int16_t afi
, u_char safi
)
8067 struct community_list
*list
;
8069 list
= community_list_lookup (bgp_clist
, com
, COMMUNITY_LIST_MASTER
);
8072 vty_out (vty
, "%% %s is not a valid community-list name%s", com
,
8077 return bgp_show (vty
, NULL
, afi
, safi
,
8078 (exact
? bgp_show_type_community_list_exact
:
8079 bgp_show_type_community_list
), list
);
8082 DEFUN (show_ip_bgp_community_list
,
8083 show_ip_bgp_community_list_cmd
,
8084 "show ip bgp community-list (<1-500>|WORD)",
8088 "Display routes matching the community-list\n"
8089 "community-list number\n"
8090 "community-list name\n")
8092 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP
, SAFI_UNICAST
);
8095 DEFUN (show_ip_bgp_ipv4_community_list
,
8096 show_ip_bgp_ipv4_community_list_cmd
,
8097 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
8102 "Address Family modifier\n"
8103 "Address Family modifier\n"
8104 "Display routes matching the community-list\n"
8105 "community-list number\n"
8106 "community-list name\n")
8108 if (strncmp (argv
[0], "m", 1) == 0)
8109 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_MULTICAST
);
8111 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_UNICAST
);
8114 DEFUN (show_ip_bgp_community_list_exact
,
8115 show_ip_bgp_community_list_exact_cmd
,
8116 "show ip bgp community-list (<1-500>|WORD) exact-match",
8120 "Display routes matching the community-list\n"
8121 "community-list number\n"
8122 "community-list name\n"
8123 "Exact match of the communities\n")
8125 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP
, SAFI_UNICAST
);
8128 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
8129 show_ip_bgp_ipv4_community_list_exact_cmd
,
8130 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
8135 "Address Family modifier\n"
8136 "Address Family modifier\n"
8137 "Display routes matching the community-list\n"
8138 "community-list number\n"
8139 "community-list name\n"
8140 "Exact match of the communities\n")
8142 if (strncmp (argv
[0], "m", 1) == 0)
8143 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_MULTICAST
);
8145 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_UNICAST
);
8149 DEFUN (show_bgp_community_list
,
8150 show_bgp_community_list_cmd
,
8151 "show bgp community-list (<1-500>|WORD)",
8154 "Display routes matching the community-list\n"
8155 "community-list number\n"
8156 "community-list name\n")
8158 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
8161 ALIAS (show_bgp_community_list
,
8162 show_bgp_ipv6_community_list_cmd
,
8163 "show bgp ipv6 community-list (<1-500>|WORD)",
8167 "Display routes matching the community-list\n"
8168 "community-list number\n"
8169 "community-list name\n")
8172 DEFUN (show_ipv6_bgp_community_list
,
8173 show_ipv6_bgp_community_list_cmd
,
8174 "show ipv6 bgp community-list WORD",
8178 "Display routes matching the community-list\n"
8179 "community-list name\n")
8181 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
8185 DEFUN (show_ipv6_mbgp_community_list
,
8186 show_ipv6_mbgp_community_list_cmd
,
8187 "show ipv6 mbgp community-list WORD",
8191 "Display routes matching the community-list\n"
8192 "community-list name\n")
8194 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_MULTICAST
);
8197 DEFUN (show_bgp_community_list_exact
,
8198 show_bgp_community_list_exact_cmd
,
8199 "show bgp community-list (<1-500>|WORD) exact-match",
8202 "Display routes matching the community-list\n"
8203 "community-list number\n"
8204 "community-list name\n"
8205 "Exact match of the communities\n")
8207 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
8210 ALIAS (show_bgp_community_list_exact
,
8211 show_bgp_ipv6_community_list_exact_cmd
,
8212 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
8216 "Display routes matching the community-list\n"
8217 "community-list number\n"
8218 "community-list name\n"
8219 "Exact match of the communities\n")
8222 DEFUN (show_ipv6_bgp_community_list_exact
,
8223 show_ipv6_bgp_community_list_exact_cmd
,
8224 "show ipv6 bgp community-list WORD exact-match",
8228 "Display routes matching the community-list\n"
8229 "community-list name\n"
8230 "Exact match of the communities\n")
8232 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
8236 DEFUN (show_ipv6_mbgp_community_list_exact
,
8237 show_ipv6_mbgp_community_list_exact_cmd
,
8238 "show ipv6 mbgp community-list WORD exact-match",
8242 "Display routes matching the community-list\n"
8243 "community-list name\n"
8244 "Exact match of the communities\n")
8246 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_MULTICAST
);
8248 #endif /* HAVE_IPV6 */
8251 bgp_show_prefix_longer (struct vty
*vty
, const char *prefix
, afi_t afi
,
8252 safi_t safi
, enum bgp_show_type type
)
8259 ret
= str2prefix (prefix
, p
);
8262 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
8266 ret
= bgp_show (vty
, NULL
, afi
, safi
, type
, p
);
8271 DEFUN (show_ip_bgp_prefix_longer
,
8272 show_ip_bgp_prefix_longer_cmd
,
8273 "show ip bgp A.B.C.D/M longer-prefixes",
8277 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8278 "Display route and more specific routes\n")
8280 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8281 bgp_show_type_prefix_longer
);
8284 DEFUN (show_ip_bgp_flap_prefix_longer
,
8285 show_ip_bgp_flap_prefix_longer_cmd
,
8286 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
8290 "Display flap statistics of routes\n"
8291 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8292 "Display route and more specific routes\n")
8294 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8295 bgp_show_type_flap_prefix_longer
);
8298 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
8299 show_ip_bgp_ipv4_prefix_longer_cmd
,
8300 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
8305 "Address Family modifier\n"
8306 "Address Family modifier\n"
8307 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8308 "Display route and more specific routes\n")
8310 if (strncmp (argv
[0], "m", 1) == 0)
8311 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
8312 bgp_show_type_prefix_longer
);
8314 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
8315 bgp_show_type_prefix_longer
);
8318 DEFUN (show_ip_bgp_flap_address
,
8319 show_ip_bgp_flap_address_cmd
,
8320 "show ip bgp flap-statistics A.B.C.D",
8324 "Display flap statistics of routes\n"
8325 "Network in the BGP routing table to display\n")
8327 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8328 bgp_show_type_flap_address
);
8331 DEFUN (show_ip_bgp_flap_prefix
,
8332 show_ip_bgp_flap_prefix_cmd
,
8333 "show ip bgp flap-statistics A.B.C.D/M",
8337 "Display flap statistics of routes\n"
8338 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8340 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8341 bgp_show_type_flap_prefix
);
8344 DEFUN (show_bgp_prefix_longer
,
8345 show_bgp_prefix_longer_cmd
,
8346 "show bgp X:X::X:X/M longer-prefixes",
8349 "IPv6 prefix <network>/<length>\n"
8350 "Display route and more specific routes\n")
8352 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8353 bgp_show_type_prefix_longer
);
8356 ALIAS (show_bgp_prefix_longer
,
8357 show_bgp_ipv6_prefix_longer_cmd
,
8358 "show bgp ipv6 X:X::X:X/M longer-prefixes",
8362 "IPv6 prefix <network>/<length>\n"
8363 "Display route and more specific routes\n")
8366 DEFUN (show_ipv6_bgp_prefix_longer
,
8367 show_ipv6_bgp_prefix_longer_cmd
,
8368 "show ipv6 bgp X:X::X:X/M longer-prefixes",
8372 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8373 "Display route and more specific routes\n")
8375 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8376 bgp_show_type_prefix_longer
);
8380 DEFUN (show_ipv6_mbgp_prefix_longer
,
8381 show_ipv6_mbgp_prefix_longer_cmd
,
8382 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
8386 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8387 "Display route and more specific routes\n")
8389 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
8390 bgp_show_type_prefix_longer
);
8392 #endif /* HAVE_IPV6 */
8394 static struct peer
*
8395 peer_lookup_in_view (struct vty
*vty
, const char *view_name
,
8403 /* BGP structure lookup. */
8406 bgp
= bgp_lookup_by_name (view_name
);
8409 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
8415 bgp
= bgp_get_default ();
8418 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
8423 /* Get peer sockunion. */
8424 ret
= str2sockunion (ip_str
, &su
);
8427 vty_out (vty
, "Malformed address: %s%s", ip_str
, VTY_NEWLINE
);
8431 /* Peer structure lookup. */
8432 peer
= peer_lookup (bgp
, &su
);
8435 vty_out (vty
, "No such neighbor%s", VTY_NEWLINE
);
8444 BGP_STATS_MAXBITLEN
= 0,
8448 BGP_STATS_UNAGGREGATEABLE
,
8449 BGP_STATS_MAX_AGGREGATEABLE
,
8450 BGP_STATS_AGGREGATES
,
8452 BGP_STATS_ASPATH_COUNT
,
8453 BGP_STATS_ASPATH_MAXHOPS
,
8454 BGP_STATS_ASPATH_TOTHOPS
,
8455 BGP_STATS_ASPATH_MAXSIZE
,
8456 BGP_STATS_ASPATH_TOTSIZE
,
8457 BGP_STATS_ASN_HIGHEST
,
8461 static const char *table_stats_strs
[] =
8463 [BGP_STATS_PREFIXES
] = "Total Prefixes",
8464 [BGP_STATS_TOTPLEN
] = "Average prefix length",
8465 [BGP_STATS_RIB
] = "Total Advertisements",
8466 [BGP_STATS_UNAGGREGATEABLE
] = "Unaggregateable prefixes",
8467 [BGP_STATS_MAX_AGGREGATEABLE
] = "Maximum aggregateable prefixes",
8468 [BGP_STATS_AGGREGATES
] = "BGP Aggregate advertisements",
8469 [BGP_STATS_SPACE
] = "Address space advertised",
8470 [BGP_STATS_ASPATH_COUNT
] = "Advertisements with paths",
8471 [BGP_STATS_ASPATH_MAXHOPS
] = "Longest AS-Path (hops)",
8472 [BGP_STATS_ASPATH_MAXSIZE
] = "Largest AS-Path (bytes)",
8473 [BGP_STATS_ASPATH_TOTHOPS
] = "Average AS-Path length (hops)",
8474 [BGP_STATS_ASPATH_TOTSIZE
] = "Average AS-Path size (bytes)",
8475 [BGP_STATS_ASN_HIGHEST
] = "Highest public ASN",
8476 [BGP_STATS_MAX
] = NULL
,
8479 struct bgp_table_stats
8481 struct bgp_table
*table
;
8482 unsigned long long counts
[BGP_STATS_MAX
];
8486 #define TALLY_SIGFIG 100000
8487 static unsigned long
8488 ravg_tally (unsigned long count
, unsigned long oldavg
, unsigned long newval
)
8490 unsigned long newtot
= (count
-1) * oldavg
+ (newval
* TALLY_SIGFIG
);
8491 unsigned long res
= (newtot
* TALLY_SIGFIG
) / count
;
8492 unsigned long ret
= newtot
/ count
;
8494 if ((res
% TALLY_SIGFIG
) > (TALLY_SIGFIG
/2))
8502 bgp_table_stats_walker (struct thread
*t
)
8504 struct bgp_node
*rn
;
8505 struct bgp_node
*top
;
8506 struct bgp_table_stats
*ts
= THREAD_ARG (t
);
8507 unsigned int space
= 0;
8509 if (!(top
= bgp_table_top (ts
->table
)))
8512 switch (top
->p
.family
)
8515 space
= IPV4_MAX_BITLEN
;
8518 space
= IPV6_MAX_BITLEN
;
8522 ts
->counts
[BGP_STATS_MAXBITLEN
] = space
;
8524 for (rn
= top
; rn
; rn
= bgp_route_next (rn
))
8526 struct bgp_info
*ri
;
8527 struct bgp_node
*prn
= rn
->parent
;
8528 unsigned int rinum
= 0;
8536 ts
->counts
[BGP_STATS_PREFIXES
]++;
8537 ts
->counts
[BGP_STATS_TOTPLEN
] += rn
->p
.prefixlen
;
8540 ts
->counts
[BGP_STATS_AVGPLEN
]
8541 = ravg_tally (ts
->counts
[BGP_STATS_PREFIXES
],
8542 ts
->counts
[BGP_STATS_AVGPLEN
],
8546 /* check if the prefix is included by any other announcements */
8547 while (prn
&& !prn
->info
)
8550 if (prn
== NULL
|| prn
== top
)
8552 ts
->counts
[BGP_STATS_UNAGGREGATEABLE
]++;
8553 /* announced address space */
8555 ts
->counts
[BGP_STATS_SPACE
] += 1 << (space
- rn
->p
.prefixlen
);
8558 ts
->counts
[BGP_STATS_MAX_AGGREGATEABLE
]++;
8560 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
8563 ts
->counts
[BGP_STATS_RIB
]++;
8566 (CHECK_FLAG (ri
->attr
->flag
,
8567 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
))))
8568 ts
->counts
[BGP_STATS_AGGREGATES
]++;
8571 if (ri
->attr
&& ri
->attr
->aspath
)
8573 unsigned int hops
= aspath_count_hops (ri
->attr
->aspath
);
8574 unsigned int size
= aspath_size (ri
->attr
->aspath
);
8575 as_t highest
= aspath_highest (ri
->attr
->aspath
);
8577 ts
->counts
[BGP_STATS_ASPATH_COUNT
]++;
8579 if (hops
> ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
])
8580 ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
] = hops
;
8582 if (size
> ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
])
8583 ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
] = size
;
8585 ts
->counts
[BGP_STATS_ASPATH_TOTHOPS
] += hops
;
8586 ts
->counts
[BGP_STATS_ASPATH_TOTSIZE
] += size
;
8588 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
]
8589 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
8590 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
],
8592 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
]
8593 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
8594 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
],
8597 if (highest
> ts
->counts
[BGP_STATS_ASN_HIGHEST
])
8598 ts
->counts
[BGP_STATS_ASN_HIGHEST
] = highest
;
8606 bgp_table_stats (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
)
8608 struct bgp_table_stats ts
;
8611 if (!bgp
->rib
[afi
][safi
])
8613 vty_out (vty
, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE
);
8617 memset (&ts
, 0, sizeof (ts
));
8618 ts
.table
= bgp
->rib
[afi
][safi
];
8619 thread_execute (bm
->master
, bgp_table_stats_walker
, &ts
, 0);
8621 vty_out (vty
, "BGP %s RIB statistics%s%s",
8622 afi_safi_print (afi
, safi
), VTY_NEWLINE
, VTY_NEWLINE
);
8624 for (i
= 0; i
< BGP_STATS_MAX
; i
++)
8626 if (!table_stats_strs
[i
])
8632 case BGP_STATS_ASPATH_AVGHOPS
:
8633 case BGP_STATS_ASPATH_AVGSIZE
:
8634 case BGP_STATS_AVGPLEN
:
8635 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
8636 vty_out (vty
, "%12.2f",
8637 (float)ts
.counts
[i
] / (float)TALLY_SIGFIG
);
8640 case BGP_STATS_ASPATH_TOTHOPS
:
8641 case BGP_STATS_ASPATH_TOTSIZE
:
8642 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
8643 vty_out (vty
, "%12.2f",
8645 (float)ts
.counts
[i
] /
8646 (float)ts
.counts
[BGP_STATS_ASPATH_COUNT
]
8649 case BGP_STATS_TOTPLEN
:
8650 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
8651 vty_out (vty
, "%12.2f",
8653 (float)ts
.counts
[i
] /
8654 (float)ts
.counts
[BGP_STATS_PREFIXES
]
8657 case BGP_STATS_SPACE
:
8658 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
8659 vty_out (vty
, "%12llu%s", ts
.counts
[i
], VTY_NEWLINE
);
8660 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 9)
8662 vty_out (vty
, "%30s: ", "\% announced ");
8663 vty_out (vty
, "%12.2f%s",
8664 100 * (float)ts
.counts
[BGP_STATS_SPACE
] /
8665 (float)((uint64_t)1UL << ts
.counts
[BGP_STATS_MAXBITLEN
]),
8667 vty_out (vty
, "%30s: ", "/8 equivalent ");
8668 vty_out (vty
, "%12.2f%s",
8669 (float)ts
.counts
[BGP_STATS_SPACE
] /
8670 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 8)),
8672 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 25)
8674 vty_out (vty
, "%30s: ", "/24 equivalent ");
8675 vty_out (vty
, "%12.2f",
8676 (float)ts
.counts
[BGP_STATS_SPACE
] /
8677 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 24)));
8680 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
8681 vty_out (vty
, "%12llu", ts
.counts
[i
]);
8684 vty_out (vty
, "%s", VTY_NEWLINE
);
8690 bgp_table_stats_vty (struct vty
*vty
, const char *name
,
8691 const char *afi_str
, const char *safi_str
)
8698 bgp
= bgp_lookup_by_name (name
);
8700 bgp
= bgp_get_default ();
8704 vty_out (vty
, "%% No such BGP instance exist%s", VTY_NEWLINE
);
8707 if (strncmp (afi_str
, "ipv", 3) == 0)
8709 if (strncmp (afi_str
, "ipv4", 4) == 0)
8711 else if (strncmp (afi_str
, "ipv6", 4) == 0)
8715 vty_out (vty
, "%% Invalid address family %s%s",
8716 afi_str
, VTY_NEWLINE
);
8719 if (strncmp (safi_str
, "m", 1) == 0)
8720 safi
= SAFI_MULTICAST
;
8721 else if (strncmp (safi_str
, "u", 1) == 0)
8722 safi
= SAFI_UNICAST
;
8723 else if (strncmp (safi_str
, "vpnv4", 5) == 0)
8724 safi
= BGP_SAFI_VPNV4
;
8725 else if (strncmp (safi_str
, "vpnv6", 6) == 0)
8726 safi
= BGP_SAFI_VPNV6
;
8729 vty_out (vty
, "%% Invalid subsequent address family %s%s",
8730 safi_str
, VTY_NEWLINE
);
8736 vty_out (vty
, "%% Invalid address family %s%s",
8737 afi_str
, VTY_NEWLINE
);
8741 if ((afi
== AFI_IP
&& safi
== BGP_SAFI_VPNV6
)
8742 || (afi
== AFI_IP6
&& safi
== BGP_SAFI_VPNV4
))
8744 vty_out (vty
, "%% Invalid subsequent address family %s for %s%s",
8745 afi_str
, safi_str
, VTY_NEWLINE
);
8748 return bgp_table_stats (vty
, bgp
, afi
, safi
);
8751 DEFUN (show_bgp_statistics
,
8752 show_bgp_statistics_cmd
,
8753 "show bgp (ipv4|ipv6) (unicast|multicast) statistics",
8758 "Address Family modifier\n"
8759 "Address Family modifier\n"
8760 "BGP RIB advertisement statistics\n")
8762 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
8765 ALIAS (show_bgp_statistics
,
8766 show_bgp_statistics_vpnv4_cmd
,
8767 "show bgp (ipv4) (vpnv4) statistics",
8771 "Address Family modifier\n"
8772 "BGP RIB advertisement statistics\n")
8774 DEFUN (show_bgp_statistics_view
,
8775 show_bgp_statistics_view_cmd
,
8776 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics",
8782 "Address Family modifier\n"
8783 "Address Family modifier\n"
8784 "BGP RIB advertisement statistics\n")
8786 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
8789 ALIAS (show_bgp_statistics_view
,
8790 show_bgp_statistics_view_vpnv4_cmd
,
8791 "show bgp view WORD (ipv4) (vpnv4) statistics",
8796 "Address Family modifier\n"
8797 "BGP RIB advertisement statistics\n")
8809 PCOUNT_PFCNT
, /* the figure we display to users */
8813 static const char *pcount_strs
[] =
8815 [PCOUNT_ADJ_IN
] = "Adj-in",
8816 [PCOUNT_DAMPED
] = "Damped",
8817 [PCOUNT_REMOVED
] = "Removed",
8818 [PCOUNT_HISTORY
] = "History",
8819 [PCOUNT_STALE
] = "Stale",
8820 [PCOUNT_VALID
] = "Valid",
8821 [PCOUNT_ALL
] = "All RIB",
8822 [PCOUNT_COUNTED
] = "PfxCt counted",
8823 [PCOUNT_PFCNT
] = "Useable",
8824 [PCOUNT_MAX
] = NULL
,
8829 unsigned int count
[PCOUNT_MAX
];
8830 const struct peer
*peer
;
8831 const struct bgp_table
*table
;
8835 bgp_peer_count_walker (struct thread
*t
)
8837 struct bgp_node
*rn
;
8838 struct peer_pcounts
*pc
= THREAD_ARG (t
);
8839 const struct peer
*peer
= pc
->peer
;
8841 for (rn
= bgp_table_top (pc
->table
); rn
; rn
= bgp_route_next (rn
))
8843 struct bgp_adj_in
*ain
;
8844 struct bgp_info
*ri
;
8846 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
8847 if (ain
->peer
== peer
)
8848 pc
->count
[PCOUNT_ADJ_IN
]++;
8850 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
8852 char buf
[SU_ADDRSTRLEN
];
8854 if (ri
->peer
!= peer
)
8857 pc
->count
[PCOUNT_ALL
]++;
8859 if (CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
))
8860 pc
->count
[PCOUNT_DAMPED
]++;
8861 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
8862 pc
->count
[PCOUNT_HISTORY
]++;
8863 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
8864 pc
->count
[PCOUNT_REMOVED
]++;
8865 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
8866 pc
->count
[PCOUNT_STALE
]++;
8867 if (CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
))
8868 pc
->count
[PCOUNT_VALID
]++;
8869 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
8870 pc
->count
[PCOUNT_PFCNT
]++;
8872 if (CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
8874 pc
->count
[PCOUNT_COUNTED
]++;
8875 if (CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
8876 plog_warn (peer
->log
,
8877 "%s [pcount] %s/%d is counted but flags 0x%x",
8879 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
8880 buf
, SU_ADDRSTRLEN
),
8886 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
8887 plog_warn (peer
->log
,
8888 "%s [pcount] %s/%d not counted but flags 0x%x",
8890 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
8891 buf
, SU_ADDRSTRLEN
),
8901 bgp_peer_counts (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
)
8903 struct peer_pcounts pcounts
= { .peer
= peer
};
8906 if (!peer
|| !peer
->bgp
|| !peer
->afc
[afi
][safi
]
8907 || !peer
->bgp
->rib
[afi
][safi
])
8909 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
8913 memset (&pcounts
, 0, sizeof(pcounts
));
8914 pcounts
.peer
= peer
;
8915 pcounts
.table
= peer
->bgp
->rib
[afi
][safi
];
8917 /* in-place call via thread subsystem so as to record execution time
8918 * stats for the thread-walk (i.e. ensure this can't be blamed on
8919 * on just vty_read()).
8921 thread_execute (bm
->master
, bgp_peer_count_walker
, &pcounts
, 0);
8923 vty_out (vty
, "Prefix counts for %s, %s%s",
8924 peer
->host
, afi_safi_print (afi
, safi
), VTY_NEWLINE
);
8925 vty_out (vty
, "PfxCt: %ld%s", peer
->pcount
[afi
][safi
], VTY_NEWLINE
);
8926 vty_out (vty
, "%sCounts from RIB table walk:%s%s",
8927 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
8929 for (i
= 0; i
< PCOUNT_MAX
; i
++)
8930 vty_out (vty
, "%20s: %-10d%s",
8931 pcount_strs
[i
], pcounts
.count
[i
], VTY_NEWLINE
);
8933 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
8935 vty_out (vty
, "%s [pcount] PfxCt drift!%s",
8936 peer
->host
, VTY_NEWLINE
);
8937 vty_out (vty
, "Please report this bug, with the above command output%s",
8944 DEFUN (show_ip_bgp_neighbor_prefix_counts
,
8945 show_ip_bgp_neighbor_prefix_counts_cmd
,
8946 "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts",
8950 "Detailed information on TCP and BGP neighbor connections\n"
8951 "Neighbor to display information about\n"
8952 "Neighbor to display information about\n"
8953 "Display detailed prefix count information\n")
8957 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
8961 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
);
8964 DEFUN (show_bgp_ipv6_neighbor_prefix_counts
,
8965 show_bgp_ipv6_neighbor_prefix_counts_cmd
,
8966 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts",
8970 "Detailed information on TCP and BGP neighbor connections\n"
8971 "Neighbor to display information about\n"
8972 "Neighbor to display information about\n"
8973 "Display detailed prefix count information\n")
8977 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
8981 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
);
8984 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts
,
8985 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
,
8986 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
8991 "Address Family modifier\n"
8992 "Address Family modifier\n"
8993 "Detailed information on TCP and BGP neighbor connections\n"
8994 "Neighbor to display information about\n"
8995 "Neighbor to display information about\n"
8996 "Display detailed prefix count information\n")
9000 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9004 if (strncmp (argv
[0], "m", 1) == 0)
9005 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MULTICAST
);
9007 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
);
9010 DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts
,
9011 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
,
9012 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9017 "Address Family modifier\n"
9018 "Address Family modifier\n"
9019 "Detailed information on TCP and BGP neighbor connections\n"
9020 "Neighbor to display information about\n"
9021 "Neighbor to display information about\n"
9022 "Display detailed prefix count information\n")
9026 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9030 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MPLS_VPN
);
9035 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
9038 struct bgp_table
*table
;
9039 struct bgp_adj_in
*ain
;
9040 struct bgp_adj_out
*adj
;
9041 unsigned long output_count
;
9042 struct bgp_node
*rn
;
9052 table
= bgp
->rib
[afi
][safi
];
9056 if (! in
&& CHECK_FLAG (peer
->af_sflags
[afi
][safi
],
9057 PEER_STATUS_DEFAULT_ORIGINATE
))
9059 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9060 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9061 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9063 vty_out (vty
, "Originating default network 0.0.0.0%s%s",
9064 VTY_NEWLINE
, VTY_NEWLINE
);
9068 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
9071 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
9072 if (ain
->peer
== peer
)
9076 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9077 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9078 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9083 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
9088 route_vty_out_tmp (vty
, &rn
->p
, ain
->attr
, safi
);
9095 for (adj
= rn
->adj_out
; adj
; adj
= adj
->next
)
9096 if (adj
->peer
== peer
)
9100 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9101 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9102 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9107 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
9112 route_vty_out_tmp (vty
, &rn
->p
, adj
->attr
, safi
);
9118 if (output_count
!= 0)
9119 vty_out (vty
, "%sTotal number of prefixes %ld%s",
9120 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
9124 peer_adj_routes (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
, int in
)
9126 if (! peer
|| ! peer
->afc
[afi
][safi
])
9128 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
9132 if (in
&& ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
9134 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s",
9139 show_adj_route (vty
, peer
, afi
, safi
, in
);
9144 DEFUN (show_ip_bgp_neighbor_advertised_route
,
9145 show_ip_bgp_neighbor_advertised_route_cmd
,
9146 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9150 "Detailed information on TCP and BGP neighbor connections\n"
9151 "Neighbor to display information about\n"
9152 "Neighbor to display information about\n"
9153 "Display the routes advertised to a BGP neighbor\n")
9157 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9161 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0);
9164 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
9165 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
9166 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9171 "Address Family modifier\n"
9172 "Address Family modifier\n"
9173 "Detailed information on TCP and BGP neighbor connections\n"
9174 "Neighbor to display information about\n"
9175 "Neighbor to display information about\n"
9176 "Display the routes advertised to a BGP neighbor\n")
9180 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9184 if (strncmp (argv
[0], "m", 1) == 0)
9185 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 0);
9187 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0);
9191 DEFUN (show_bgp_view_neighbor_advertised_route
,
9192 show_bgp_view_neighbor_advertised_route_cmd
,
9193 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9198 "Detailed information on TCP and BGP neighbor connections\n"
9199 "Neighbor to display information about\n"
9200 "Neighbor to display information about\n"
9201 "Display the routes advertised to a BGP neighbor\n")
9206 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9208 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9213 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0);
9216 ALIAS (show_bgp_view_neighbor_advertised_route
,
9217 show_bgp_view_ipv6_neighbor_advertised_route_cmd
,
9218 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9224 "Detailed information on TCP and BGP neighbor connections\n"
9225 "Neighbor to display information about\n"
9226 "Neighbor to display information about\n"
9227 "Display the routes advertised to a BGP neighbor\n")
9229 DEFUN (show_bgp_view_neighbor_received_routes
,
9230 show_bgp_view_neighbor_received_routes_cmd
,
9231 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
9236 "Detailed information on TCP and BGP neighbor connections\n"
9237 "Neighbor to display information about\n"
9238 "Neighbor to display information about\n"
9239 "Display the received routes from neighbor\n")
9244 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9246 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9251 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1);
9254 ALIAS (show_bgp_view_neighbor_received_routes
,
9255 show_bgp_view_ipv6_neighbor_received_routes_cmd
,
9256 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
9262 "Detailed information on TCP and BGP neighbor connections\n"
9263 "Neighbor to display information about\n"
9264 "Neighbor to display information about\n"
9265 "Display the received routes from neighbor\n")
9267 ALIAS (show_bgp_view_neighbor_advertised_route
,
9268 show_bgp_neighbor_advertised_route_cmd
,
9269 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9272 "Detailed information on TCP and BGP neighbor connections\n"
9273 "Neighbor to display information about\n"
9274 "Neighbor to display information about\n"
9275 "Display the routes advertised to a BGP neighbor\n")
9277 ALIAS (show_bgp_view_neighbor_advertised_route
,
9278 show_bgp_ipv6_neighbor_advertised_route_cmd
,
9279 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9283 "Detailed information on TCP and BGP neighbor connections\n"
9284 "Neighbor to display information about\n"
9285 "Neighbor to display information about\n"
9286 "Display the routes advertised to a BGP neighbor\n")
9289 ALIAS (show_bgp_view_neighbor_advertised_route
,
9290 ipv6_bgp_neighbor_advertised_route_cmd
,
9291 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9295 "Detailed information on TCP and BGP neighbor connections\n"
9296 "Neighbor to display information about\n"
9297 "Neighbor to display information about\n"
9298 "Display the routes advertised to a BGP neighbor\n")
9301 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
9302 ipv6_mbgp_neighbor_advertised_route_cmd
,
9303 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9307 "Detailed information on TCP and BGP neighbor connections\n"
9308 "Neighbor to display information about\n"
9309 "Neighbor to display information about\n"
9310 "Display the routes advertised to a BGP neighbor\n")
9314 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9318 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 0);
9320 #endif /* HAVE_IPV6 */
9322 DEFUN (show_ip_bgp_neighbor_received_routes
,
9323 show_ip_bgp_neighbor_received_routes_cmd
,
9324 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
9328 "Detailed information on TCP and BGP neighbor connections\n"
9329 "Neighbor to display information about\n"
9330 "Neighbor to display information about\n"
9331 "Display the received routes from neighbor\n")
9335 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9339 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1);
9342 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
9343 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
9344 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
9349 "Address Family modifier\n"
9350 "Address Family modifier\n"
9351 "Detailed information on TCP and BGP neighbor connections\n"
9352 "Neighbor to display information about\n"
9353 "Neighbor to display information about\n"
9354 "Display the received routes from neighbor\n")
9358 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9362 if (strncmp (argv
[0], "m", 1) == 0)
9363 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 1);
9365 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1);
9368 DEFUN (show_ip_bgp_neighbor_received_prefix_filter
,
9369 show_ip_bgp_neighbor_received_prefix_filter_cmd
,
9370 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9374 "Detailed information on TCP and BGP neighbor connections\n"
9375 "Neighbor to display information about\n"
9376 "Neighbor to display information about\n"
9377 "Display information received from a BGP neighbor\n"
9378 "Display the prefixlist filter\n")
9381 union sockunion
*su
;
9385 su
= sockunion_str2su (argv
[0]);
9389 peer
= peer_lookup (NULL
, su
);
9393 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
9394 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
9397 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
9398 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
9404 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter
,
9405 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
,
9406 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9411 "Address Family modifier\n"
9412 "Address Family modifier\n"
9413 "Detailed information on TCP and BGP neighbor connections\n"
9414 "Neighbor to display information about\n"
9415 "Neighbor to display information about\n"
9416 "Display information received from a BGP neighbor\n"
9417 "Display the prefixlist filter\n")
9420 union sockunion
*su
;
9424 su
= sockunion_str2su (argv
[1]);
9428 peer
= peer_lookup (NULL
, su
);
9432 if (strncmp (argv
[0], "m", 1) == 0)
9434 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_MULTICAST
);
9435 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
9438 vty_out (vty
, "Address family: IPv4 Multicast%s", VTY_NEWLINE
);
9439 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
9444 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
9445 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
9448 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
9449 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
9458 ALIAS (show_bgp_view_neighbor_received_routes
,
9459 show_bgp_neighbor_received_routes_cmd
,
9460 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
9463 "Detailed information on TCP and BGP neighbor connections\n"
9464 "Neighbor to display information about\n"
9465 "Neighbor to display information about\n"
9466 "Display the received routes from neighbor\n")
9468 ALIAS (show_bgp_view_neighbor_received_routes
,
9469 show_bgp_ipv6_neighbor_received_routes_cmd
,
9470 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
9474 "Detailed information on TCP and BGP neighbor connections\n"
9475 "Neighbor to display information about\n"
9476 "Neighbor to display information about\n"
9477 "Display the received routes from neighbor\n")
9479 DEFUN (show_bgp_neighbor_received_prefix_filter
,
9480 show_bgp_neighbor_received_prefix_filter_cmd
,
9481 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9484 "Detailed information on TCP and BGP neighbor connections\n"
9485 "Neighbor to display information about\n"
9486 "Neighbor to display information about\n"
9487 "Display information received from a BGP neighbor\n"
9488 "Display the prefixlist filter\n")
9491 union sockunion
*su
;
9495 su
= sockunion_str2su (argv
[0]);
9499 peer
= peer_lookup (NULL
, su
);
9503 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
9504 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
);
9507 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
9508 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
);
9514 ALIAS (show_bgp_neighbor_received_prefix_filter
,
9515 show_bgp_ipv6_neighbor_received_prefix_filter_cmd
,
9516 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9520 "Detailed information on TCP and BGP neighbor connections\n"
9521 "Neighbor to display information about\n"
9522 "Neighbor to display information about\n"
9523 "Display information received from a BGP neighbor\n"
9524 "Display the prefixlist filter\n")
9527 ALIAS (show_bgp_view_neighbor_received_routes
,
9528 ipv6_bgp_neighbor_received_routes_cmd
,
9529 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
9533 "Detailed information on TCP and BGP neighbor connections\n"
9534 "Neighbor to display information about\n"
9535 "Neighbor to display information about\n"
9536 "Display the received routes from neighbor\n")
9539 DEFUN (ipv6_mbgp_neighbor_received_routes
,
9540 ipv6_mbgp_neighbor_received_routes_cmd
,
9541 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
9545 "Detailed information on TCP and BGP neighbor connections\n"
9546 "Neighbor to display information about\n"
9547 "Neighbor to display information about\n"
9548 "Display the received routes from neighbor\n")
9552 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9556 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 1);
9559 DEFUN (show_bgp_view_neighbor_received_prefix_filter
,
9560 show_bgp_view_neighbor_received_prefix_filter_cmd
,
9561 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9566 "Detailed information on TCP and BGP neighbor connections\n"
9567 "Neighbor to display information about\n"
9568 "Neighbor to display information about\n"
9569 "Display information received from a BGP neighbor\n"
9570 "Display the prefixlist filter\n")
9573 union sockunion
*su
;
9578 /* BGP structure lookup. */
9579 bgp
= bgp_lookup_by_name (argv
[0]);
9582 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
9586 su
= sockunion_str2su (argv
[1]);
9590 peer
= peer_lookup (bgp
, su
);
9594 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
9595 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
);
9598 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
9599 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
);
9605 ALIAS (show_bgp_view_neighbor_received_prefix_filter
,
9606 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
,
9607 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9613 "Detailed information on TCP and BGP neighbor connections\n"
9614 "Neighbor to display information about\n"
9615 "Neighbor to display information about\n"
9616 "Display information received from a BGP neighbor\n"
9617 "Display the prefixlist filter\n")
9618 #endif /* HAVE_IPV6 */
9621 bgp_show_neighbor_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
,
9622 safi_t safi
, enum bgp_show_type type
)
9624 if (! peer
|| ! peer
->afc
[afi
][safi
])
9626 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
9630 return bgp_show (vty
, peer
->bgp
, afi
, safi
, type
, &peer
->su
);
9633 DEFUN (show_ip_bgp_neighbor_routes
,
9634 show_ip_bgp_neighbor_routes_cmd
,
9635 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
9639 "Detailed information on TCP and BGP neighbor connections\n"
9640 "Neighbor to display information about\n"
9641 "Neighbor to display information about\n"
9642 "Display routes learned from neighbor\n")
9646 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9650 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
9651 bgp_show_type_neighbor
);
9654 DEFUN (show_ip_bgp_neighbor_flap
,
9655 show_ip_bgp_neighbor_flap_cmd
,
9656 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
9660 "Detailed information on TCP and BGP neighbor connections\n"
9661 "Neighbor to display information about\n"
9662 "Neighbor to display information about\n"
9663 "Display flap statistics of the routes learned from neighbor\n")
9667 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9671 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
9672 bgp_show_type_flap_neighbor
);
9675 DEFUN (show_ip_bgp_neighbor_damp
,
9676 show_ip_bgp_neighbor_damp_cmd
,
9677 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
9681 "Detailed information on TCP and BGP neighbor connections\n"
9682 "Neighbor to display information about\n"
9683 "Neighbor to display information about\n"
9684 "Display the dampened routes received from neighbor\n")
9688 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9692 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
9693 bgp_show_type_damp_neighbor
);
9696 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
9697 show_ip_bgp_ipv4_neighbor_routes_cmd
,
9698 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
9703 "Address Family modifier\n"
9704 "Address Family modifier\n"
9705 "Detailed information on TCP and BGP neighbor connections\n"
9706 "Neighbor to display information about\n"
9707 "Neighbor to display information about\n"
9708 "Display routes learned from neighbor\n")
9712 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9716 if (strncmp (argv
[0], "m", 1) == 0)
9717 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_MULTICAST
,
9718 bgp_show_type_neighbor
);
9720 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
9721 bgp_show_type_neighbor
);
9724 DEFUN (show_ip_bgp_view_rsclient
,
9725 show_ip_bgp_view_rsclient_cmd
,
9726 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
9732 "Information about Route Server Client\n"
9735 struct bgp_table
*table
;
9739 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9741 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9746 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
9748 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
9753 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
9754 PEER_FLAG_RSERVER_CLIENT
))
9756 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
9761 table
= peer
->rib
[AFI_IP
][SAFI_UNICAST
];
9763 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
9766 ALIAS (show_ip_bgp_view_rsclient
,
9767 show_ip_bgp_rsclient_cmd
,
9768 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
9772 "Information about Route Server Client\n"
9775 DEFUN (show_ip_bgp_view_rsclient_route
,
9776 show_ip_bgp_view_rsclient_route_cmd
,
9777 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
9783 "Information about Route Server Client\n"
9785 "Network in the BGP routing table to display\n")
9790 /* BGP structure lookup. */
9793 bgp
= bgp_lookup_by_name (argv
[0]);
9796 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
9802 bgp
= bgp_get_default ();
9805 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
9811 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9813 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9818 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
9820 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
9825 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
9826 PEER_FLAG_RSERVER_CLIENT
))
9828 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
9833 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][SAFI_UNICAST
],
9834 (argc
== 3) ? argv
[2] : argv
[1],
9835 AFI_IP
, SAFI_UNICAST
, NULL
, 0);
9838 ALIAS (show_ip_bgp_view_rsclient_route
,
9839 show_ip_bgp_rsclient_route_cmd
,
9840 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
9844 "Information about Route Server Client\n"
9846 "Network in the BGP routing table to display\n")
9848 DEFUN (show_ip_bgp_view_rsclient_prefix
,
9849 show_ip_bgp_view_rsclient_prefix_cmd
,
9850 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
9856 "Information about Route Server Client\n"
9858 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
9863 /* BGP structure lookup. */
9866 bgp
= bgp_lookup_by_name (argv
[0]);
9869 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
9875 bgp
= bgp_get_default ();
9878 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
9884 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9886 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9891 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
9893 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
9898 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
9899 PEER_FLAG_RSERVER_CLIENT
))
9901 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
9906 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][SAFI_UNICAST
],
9907 (argc
== 3) ? argv
[2] : argv
[1],
9908 AFI_IP
, SAFI_UNICAST
, NULL
, 1);
9911 ALIAS (show_ip_bgp_view_rsclient_prefix
,
9912 show_ip_bgp_rsclient_prefix_cmd
,
9913 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
9917 "Information about Route Server Client\n"
9919 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
9923 DEFUN (show_bgp_view_neighbor_routes
,
9924 show_bgp_view_neighbor_routes_cmd
,
9925 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
9930 "Detailed information on TCP and BGP neighbor connections\n"
9931 "Neighbor to display information about\n"
9932 "Neighbor to display information about\n"
9933 "Display routes learned from neighbor\n")
9938 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9940 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9945 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
9946 bgp_show_type_neighbor
);
9949 ALIAS (show_bgp_view_neighbor_routes
,
9950 show_bgp_view_ipv6_neighbor_routes_cmd
,
9951 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
9957 "Detailed information on TCP and BGP neighbor connections\n"
9958 "Neighbor to display information about\n"
9959 "Neighbor to display information about\n"
9960 "Display routes learned from neighbor\n")
9962 DEFUN (show_bgp_view_neighbor_damp
,
9963 show_bgp_view_neighbor_damp_cmd
,
9964 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
9969 "Detailed information on TCP and BGP neighbor connections\n"
9970 "Neighbor to display information about\n"
9971 "Neighbor to display information about\n"
9972 "Display the dampened routes received from neighbor\n")
9977 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9979 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9984 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
9985 bgp_show_type_damp_neighbor
);
9988 ALIAS (show_bgp_view_neighbor_damp
,
9989 show_bgp_view_ipv6_neighbor_damp_cmd
,
9990 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
9996 "Detailed information on TCP and BGP neighbor connections\n"
9997 "Neighbor to display information about\n"
9998 "Neighbor to display information about\n"
9999 "Display the dampened routes received from neighbor\n")
10001 DEFUN (show_bgp_view_neighbor_flap
,
10002 show_bgp_view_neighbor_flap_cmd
,
10003 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10008 "Detailed information on TCP and BGP neighbor connections\n"
10009 "Neighbor to display information about\n"
10010 "Neighbor to display information about\n"
10011 "Display flap statistics of the routes learned from neighbor\n")
10016 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10018 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10021 return CMD_WARNING
;
10023 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
10024 bgp_show_type_flap_neighbor
);
10027 ALIAS (show_bgp_view_neighbor_flap
,
10028 show_bgp_view_ipv6_neighbor_flap_cmd
,
10029 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10035 "Detailed information on TCP and BGP neighbor connections\n"
10036 "Neighbor to display information about\n"
10037 "Neighbor to display information about\n"
10038 "Display flap statistics of the routes learned from neighbor\n")
10040 ALIAS (show_bgp_view_neighbor_routes
,
10041 show_bgp_neighbor_routes_cmd
,
10042 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
10045 "Detailed information on TCP and BGP neighbor connections\n"
10046 "Neighbor to display information about\n"
10047 "Neighbor to display information about\n"
10048 "Display routes learned from neighbor\n")
10051 ALIAS (show_bgp_view_neighbor_routes
,
10052 show_bgp_ipv6_neighbor_routes_cmd
,
10053 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
10057 "Detailed information on TCP and BGP neighbor connections\n"
10058 "Neighbor to display information about\n"
10059 "Neighbor to display information about\n"
10060 "Display routes learned from neighbor\n")
10063 ALIAS (show_bgp_view_neighbor_routes
,
10064 ipv6_bgp_neighbor_routes_cmd
,
10065 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
10069 "Detailed information on TCP and BGP neighbor connections\n"
10070 "Neighbor to display information about\n"
10071 "Neighbor to display information about\n"
10072 "Display routes learned from neighbor\n")
10075 DEFUN (ipv6_mbgp_neighbor_routes
,
10076 ipv6_mbgp_neighbor_routes_cmd
,
10077 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
10081 "Detailed information on TCP and BGP neighbor connections\n"
10082 "Neighbor to display information about\n"
10083 "Neighbor to display information about\n"
10084 "Display routes learned from neighbor\n")
10088 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10090 return CMD_WARNING
;
10092 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
,
10093 bgp_show_type_neighbor
);
10096 ALIAS (show_bgp_view_neighbor_flap
,
10097 show_bgp_neighbor_flap_cmd
,
10098 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10101 "Detailed information on TCP and BGP neighbor connections\n"
10102 "Neighbor to display information about\n"
10103 "Neighbor to display information about\n"
10104 "Display flap statistics of the routes learned from neighbor\n")
10106 ALIAS (show_bgp_view_neighbor_flap
,
10107 show_bgp_ipv6_neighbor_flap_cmd
,
10108 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10112 "Detailed information on TCP and BGP neighbor connections\n"
10113 "Neighbor to display information about\n"
10114 "Neighbor to display information about\n"
10115 "Display flap statistics of the routes learned from neighbor\n")
10117 ALIAS (show_bgp_view_neighbor_damp
,
10118 show_bgp_neighbor_damp_cmd
,
10119 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10122 "Detailed information on TCP and BGP neighbor connections\n"
10123 "Neighbor to display information about\n"
10124 "Neighbor to display information about\n"
10125 "Display the dampened routes received from neighbor\n")
10127 ALIAS (show_bgp_view_neighbor_damp
,
10128 show_bgp_ipv6_neighbor_damp_cmd
,
10129 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10133 "Detailed information on TCP and BGP neighbor connections\n"
10134 "Neighbor to display information about\n"
10135 "Neighbor to display information about\n"
10136 "Display the dampened routes received from neighbor\n")
10138 DEFUN (show_bgp_view_rsclient
,
10139 show_bgp_view_rsclient_cmd
,
10140 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
10145 "Information about Route Server Client\n"
10148 struct bgp_table
*table
;
10152 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10154 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10157 return CMD_WARNING
;
10159 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
10161 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10163 return CMD_WARNING
;
10166 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
10167 PEER_FLAG_RSERVER_CLIENT
))
10169 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10171 return CMD_WARNING
;
10174 table
= peer
->rib
[AFI_IP6
][SAFI_UNICAST
];
10176 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
10179 ALIAS (show_bgp_view_rsclient
,
10180 show_bgp_rsclient_cmd
,
10181 "show bgp rsclient (A.B.C.D|X:X::X:X)",
10184 "Information about Route Server Client\n"
10187 DEFUN (show_bgp_view_rsclient_route
,
10188 show_bgp_view_rsclient_route_cmd
,
10189 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
10194 "Information about Route Server Client\n"
10196 "Network in the BGP routing table to display\n")
10201 /* BGP structure lookup. */
10204 bgp
= bgp_lookup_by_name (argv
[0]);
10207 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10208 return CMD_WARNING
;
10213 bgp
= bgp_get_default ();
10216 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10217 return CMD_WARNING
;
10222 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10224 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10227 return CMD_WARNING
;
10229 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
10231 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10233 return CMD_WARNING
;
10236 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
10237 PEER_FLAG_RSERVER_CLIENT
))
10239 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10241 return CMD_WARNING
;
10244 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][SAFI_UNICAST
],
10245 (argc
== 3) ? argv
[2] : argv
[1],
10246 AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
10249 ALIAS (show_bgp_view_rsclient_route
,
10250 show_bgp_rsclient_route_cmd
,
10251 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
10254 "Information about Route Server Client\n"
10256 "Network in the BGP routing table to display\n")
10258 DEFUN (show_bgp_view_rsclient_prefix
,
10259 show_bgp_view_rsclient_prefix_cmd
,
10260 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
10265 "Information about Route Server Client\n"
10267 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
10272 /* BGP structure lookup. */
10275 bgp
= bgp_lookup_by_name (argv
[0]);
10278 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10279 return CMD_WARNING
;
10284 bgp
= bgp_get_default ();
10287 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10288 return CMD_WARNING
;
10293 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10295 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10298 return CMD_WARNING
;
10300 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
10302 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10304 return CMD_WARNING
;
10307 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
10308 PEER_FLAG_RSERVER_CLIENT
))
10310 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10312 return CMD_WARNING
;
10315 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][SAFI_UNICAST
],
10316 (argc
== 3) ? argv
[2] : argv
[1],
10317 AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
10320 ALIAS (show_bgp_view_rsclient_prefix
,
10321 show_bgp_rsclient_prefix_cmd
,
10322 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
10325 "Information about Route Server Client\n"
10327 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
10329 #endif /* HAVE_IPV6 */
10331 struct bgp_table
*bgp_distance_table
;
10333 struct bgp_distance
10335 /* Distance value for the IP source prefix. */
10338 /* Name of the access-list to be matched. */
10342 static struct bgp_distance
*
10343 bgp_distance_new ()
10345 struct bgp_distance
*new;
10346 new = XMALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
10347 memset (new, 0, sizeof (struct bgp_distance
));
10352 bgp_distance_free (struct bgp_distance
*bdistance
)
10354 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
10358 bgp_distance_set (struct vty
*vty
, const char *distance_str
,
10359 const char *ip_str
, const char *access_list_str
)
10362 struct prefix_ipv4 p
;
10364 struct bgp_node
*rn
;
10365 struct bgp_distance
*bdistance
;
10367 ret
= str2prefix_ipv4 (ip_str
, &p
);
10370 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
10371 return CMD_WARNING
;
10374 distance
= atoi (distance_str
);
10376 /* Get BGP distance node. */
10377 rn
= bgp_node_get (bgp_distance_table
, (struct prefix
*) &p
);
10380 bdistance
= rn
->info
;
10381 bgp_unlock_node (rn
);
10385 bdistance
= bgp_distance_new ();
10386 rn
->info
= bdistance
;
10389 /* Set distance value. */
10390 bdistance
->distance
= distance
;
10392 /* Reset access-list configuration. */
10393 if (bdistance
->access_list
)
10395 free (bdistance
->access_list
);
10396 bdistance
->access_list
= NULL
;
10398 if (access_list_str
)
10399 bdistance
->access_list
= strdup (access_list_str
);
10401 return CMD_SUCCESS
;
10405 bgp_distance_unset (struct vty
*vty
, const char *distance_str
,
10406 const char *ip_str
, const char *access_list_str
)
10409 struct prefix_ipv4 p
;
10411 struct bgp_node
*rn
;
10412 struct bgp_distance
*bdistance
;
10414 ret
= str2prefix_ipv4 (ip_str
, &p
);
10417 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
10418 return CMD_WARNING
;
10421 distance
= atoi (distance_str
);
10423 rn
= bgp_node_lookup (bgp_distance_table
, (struct prefix
*)&p
);
10426 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
10427 return CMD_WARNING
;
10430 bdistance
= rn
->info
;
10432 if (bdistance
->access_list
)
10433 free (bdistance
->access_list
);
10434 bgp_distance_free (bdistance
);
10437 bgp_unlock_node (rn
);
10438 bgp_unlock_node (rn
);
10440 return CMD_SUCCESS
;
10444 bgp_distance_reset ()
10446 struct bgp_node
*rn
;
10447 struct bgp_distance
*bdistance
;
10449 for (rn
= bgp_table_top (bgp_distance_table
); rn
; rn
= bgp_route_next (rn
))
10450 if ((bdistance
= rn
->info
) != NULL
)
10452 if (bdistance
->access_list
)
10453 free (bdistance
->access_list
);
10454 bgp_distance_free (bdistance
);
10456 bgp_unlock_node (rn
);
10460 /* Apply BGP information to distance method. */
10462 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, struct bgp
*bgp
)
10464 struct bgp_node
*rn
;
10465 struct prefix_ipv4 q
;
10467 struct bgp_distance
*bdistance
;
10468 struct access_list
*alist
;
10469 struct bgp_static
*bgp_static
;
10474 if (p
->family
!= AF_INET
)
10477 peer
= rinfo
->peer
;
10479 if (peer
->su
.sa
.sa_family
!= AF_INET
)
10482 memset (&q
, 0, sizeof (struct prefix_ipv4
));
10483 q
.family
= AF_INET
;
10484 q
.prefix
= peer
->su
.sin
.sin_addr
;
10485 q
.prefixlen
= IPV4_MAX_BITLEN
;
10487 /* Check source address. */
10488 rn
= bgp_node_match (bgp_distance_table
, (struct prefix
*) &q
);
10491 bdistance
= rn
->info
;
10492 bgp_unlock_node (rn
);
10494 if (bdistance
->access_list
)
10496 alist
= access_list_lookup (AFI_IP
, bdistance
->access_list
);
10497 if (alist
&& access_list_apply (alist
, p
) == FILTER_PERMIT
)
10498 return bdistance
->distance
;
10501 return bdistance
->distance
;
10504 /* Backdoor check. */
10505 rn
= bgp_node_lookup (bgp
->route
[AFI_IP
][SAFI_UNICAST
], p
);
10508 bgp_static
= rn
->info
;
10509 bgp_unlock_node (rn
);
10511 if (bgp_static
->backdoor
)
10513 if (bgp
->distance_local
)
10514 return bgp
->distance_local
;
10516 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
10520 if (peer_sort (peer
) == BGP_PEER_EBGP
)
10522 if (bgp
->distance_ebgp
)
10523 return bgp
->distance_ebgp
;
10524 return ZEBRA_EBGP_DISTANCE_DEFAULT
;
10528 if (bgp
->distance_ibgp
)
10529 return bgp
->distance_ibgp
;
10530 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
10534 DEFUN (bgp_distance
,
10536 "distance bgp <1-255> <1-255> <1-255>",
10537 "Define an administrative distance\n"
10539 "Distance for routes external to the AS\n"
10540 "Distance for routes internal to the AS\n"
10541 "Distance for local routes\n")
10547 bgp
->distance_ebgp
= atoi (argv
[0]);
10548 bgp
->distance_ibgp
= atoi (argv
[1]);
10549 bgp
->distance_local
= atoi (argv
[2]);
10550 return CMD_SUCCESS
;
10553 DEFUN (no_bgp_distance
,
10554 no_bgp_distance_cmd
,
10555 "no distance bgp <1-255> <1-255> <1-255>",
10557 "Define an administrative distance\n"
10559 "Distance for routes external to the AS\n"
10560 "Distance for routes internal to the AS\n"
10561 "Distance for local routes\n")
10567 bgp
->distance_ebgp
= 0;
10568 bgp
->distance_ibgp
= 0;
10569 bgp
->distance_local
= 0;
10570 return CMD_SUCCESS
;
10573 ALIAS (no_bgp_distance
,
10574 no_bgp_distance2_cmd
,
10577 "Define an administrative distance\n"
10580 DEFUN (bgp_distance_source
,
10581 bgp_distance_source_cmd
,
10582 "distance <1-255> A.B.C.D/M",
10583 "Define an administrative distance\n"
10584 "Administrative distance\n"
10585 "IP source prefix\n")
10587 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
10588 return CMD_SUCCESS
;
10591 DEFUN (no_bgp_distance_source
,
10592 no_bgp_distance_source_cmd
,
10593 "no distance <1-255> A.B.C.D/M",
10595 "Define an administrative distance\n"
10596 "Administrative distance\n"
10597 "IP source prefix\n")
10599 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
10600 return CMD_SUCCESS
;
10603 DEFUN (bgp_distance_source_access_list
,
10604 bgp_distance_source_access_list_cmd
,
10605 "distance <1-255> A.B.C.D/M WORD",
10606 "Define an administrative distance\n"
10607 "Administrative distance\n"
10608 "IP source prefix\n"
10609 "Access list name\n")
10611 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
10612 return CMD_SUCCESS
;
10615 DEFUN (no_bgp_distance_source_access_list
,
10616 no_bgp_distance_source_access_list_cmd
,
10617 "no distance <1-255> A.B.C.D/M WORD",
10619 "Define an administrative distance\n"
10620 "Administrative distance\n"
10621 "IP source prefix\n"
10622 "Access list name\n")
10624 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
10625 return CMD_SUCCESS
;
10628 DEFUN (bgp_damp_set
,
10630 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
10631 "BGP Specific commands\n"
10632 "Enable route-flap dampening\n"
10633 "Half-life time for the penalty\n"
10634 "Value to start reusing a route\n"
10635 "Value to start suppressing a route\n"
10636 "Maximum duration to suppress a stable route\n")
10639 int half
= DEFAULT_HALF_LIFE
* 60;
10640 int reuse
= DEFAULT_REUSE
;
10641 int suppress
= DEFAULT_SUPPRESS
;
10642 int max
= 4 * half
;
10646 half
= atoi (argv
[0]) * 60;
10647 reuse
= atoi (argv
[1]);
10648 suppress
= atoi (argv
[2]);
10649 max
= atoi (argv
[3]) * 60;
10651 else if (argc
== 1)
10653 half
= atoi (argv
[0]) * 60;
10658 return bgp_damp_enable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
),
10659 half
, reuse
, suppress
, max
);
10662 ALIAS (bgp_damp_set
,
10664 "bgp dampening <1-45>",
10665 "BGP Specific commands\n"
10666 "Enable route-flap dampening\n"
10667 "Half-life time for the penalty\n")
10669 ALIAS (bgp_damp_set
,
10672 "BGP Specific commands\n"
10673 "Enable route-flap dampening\n")
10675 DEFUN (bgp_damp_unset
,
10676 bgp_damp_unset_cmd
,
10677 "no bgp dampening",
10679 "BGP Specific commands\n"
10680 "Enable route-flap dampening\n")
10685 return bgp_damp_disable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
));
10688 ALIAS (bgp_damp_unset
,
10689 bgp_damp_unset2_cmd
,
10690 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
10692 "BGP Specific commands\n"
10693 "Enable route-flap dampening\n"
10694 "Half-life time for the penalty\n"
10695 "Value to start reusing a route\n"
10696 "Value to start suppressing a route\n"
10697 "Maximum duration to suppress a stable route\n")
10699 DEFUN (show_ip_bgp_dampened_paths
,
10700 show_ip_bgp_dampened_paths_cmd
,
10701 "show ip bgp dampened-paths",
10705 "Display paths suppressed due to dampening\n")
10707 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_dampend_paths
,
10711 DEFUN (show_ip_bgp_flap_statistics
,
10712 show_ip_bgp_flap_statistics_cmd
,
10713 "show ip bgp flap-statistics",
10717 "Display flap statistics of routes\n")
10719 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
10720 bgp_show_type_flap_statistics
, NULL
);
10723 /* Display specified route of BGP table. */
10725 bgp_clear_damp_route (struct vty
*vty
, const char *view_name
,
10726 const char *ip_str
, afi_t afi
, safi_t safi
,
10727 struct prefix_rd
*prd
, int prefix_check
)
10730 struct prefix match
;
10731 struct bgp_node
*rn
;
10732 struct bgp_node
*rm
;
10733 struct bgp_info
*ri
;
10734 struct bgp_info
*ri_temp
;
10736 struct bgp_table
*table
;
10738 /* BGP structure lookup. */
10741 bgp
= bgp_lookup_by_name (view_name
);
10744 vty_out (vty
, "%% Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
10745 return CMD_WARNING
;
10750 bgp
= bgp_get_default ();
10753 vty_out (vty
, "%% No BGP process is configured%s", VTY_NEWLINE
);
10754 return CMD_WARNING
;
10758 /* Check IP address argument. */
10759 ret
= str2prefix (ip_str
, &match
);
10762 vty_out (vty
, "%% address is malformed%s", VTY_NEWLINE
);
10763 return CMD_WARNING
;
10766 match
.family
= afi2family (afi
);
10768 if (safi
== SAFI_MPLS_VPN
)
10770 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][SAFI_MPLS_VPN
]); rn
; rn
= bgp_route_next (rn
))
10772 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
10775 if ((table
= rn
->info
) != NULL
)
10776 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
10777 if (! prefix_check
|| rm
->p
.prefixlen
== match
.prefixlen
)
10784 ri_temp
= ri
->next
;
10785 bgp_damp_info_free (ri
->damp_info
, 1);
10796 if ((rn
= bgp_node_match (bgp
->rib
[afi
][safi
], &match
)) != NULL
)
10797 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
10804 ri_temp
= ri
->next
;
10805 bgp_damp_info_free (ri
->damp_info
, 1);
10814 return CMD_SUCCESS
;
10817 DEFUN (clear_ip_bgp_dampening
,
10818 clear_ip_bgp_dampening_cmd
,
10819 "clear ip bgp dampening",
10823 "Clear route flap dampening information\n")
10825 bgp_damp_info_clean ();
10826 return CMD_SUCCESS
;
10829 DEFUN (clear_ip_bgp_dampening_prefix
,
10830 clear_ip_bgp_dampening_prefix_cmd
,
10831 "clear ip bgp dampening A.B.C.D/M",
10835 "Clear route flap dampening information\n"
10836 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10838 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
10839 SAFI_UNICAST
, NULL
, 1);
10842 DEFUN (clear_ip_bgp_dampening_address
,
10843 clear_ip_bgp_dampening_address_cmd
,
10844 "clear ip bgp dampening A.B.C.D",
10848 "Clear route flap dampening information\n"
10849 "Network to clear damping information\n")
10851 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
10852 SAFI_UNICAST
, NULL
, 0);
10855 DEFUN (clear_ip_bgp_dampening_address_mask
,
10856 clear_ip_bgp_dampening_address_mask_cmd
,
10857 "clear ip bgp dampening A.B.C.D A.B.C.D",
10861 "Clear route flap dampening information\n"
10862 "Network to clear damping information\n"
10866 char prefix_str
[BUFSIZ
];
10868 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
10871 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
10872 return CMD_WARNING
;
10875 return bgp_clear_damp_route (vty
, NULL
, prefix_str
, AFI_IP
,
10876 SAFI_UNICAST
, NULL
, 0);
10880 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
10881 afi_t afi
, safi_t safi
, int *write
)
10883 struct bgp_node
*prn
;
10884 struct bgp_node
*rn
;
10885 struct bgp_table
*table
;
10887 struct prefix_rd
*prd
;
10888 struct bgp_static
*bgp_static
;
10890 char buf
[SU_ADDRSTRLEN
];
10891 char rdbuf
[RD_ADDRSTRLEN
];
10893 /* Network configuration. */
10894 for (prn
= bgp_table_top (bgp
->route
[afi
][safi
]); prn
; prn
= bgp_route_next (prn
))
10895 if ((table
= prn
->info
) != NULL
)
10896 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
10897 if ((bgp_static
= rn
->info
) != NULL
)
10900 prd
= (struct prefix_rd
*) &prn
->p
;
10902 /* "address-family" display. */
10903 bgp_config_write_family_header (vty
, afi
, safi
, write
);
10905 /* "network" configuration display. */
10906 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
10907 label
= decode_label (bgp_static
->tag
);
10909 vty_out (vty
, " network %s/%d rd %s tag %d",
10910 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
10913 vty_out (vty
, "%s", VTY_NEWLINE
);
10918 /* Configuration of static route announcement and aggregate
10921 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
10922 afi_t afi
, safi_t safi
, int *write
)
10924 struct bgp_node
*rn
;
10926 struct bgp_static
*bgp_static
;
10927 struct bgp_aggregate
*bgp_aggregate
;
10928 char buf
[SU_ADDRSTRLEN
];
10930 if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
10931 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
10933 /* Network configuration. */
10934 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
10935 if ((bgp_static
= rn
->info
) != NULL
)
10939 /* "address-family" display. */
10940 bgp_config_write_family_header (vty
, afi
, safi
, write
);
10942 /* "network" configuration display. */
10943 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
10945 u_int32_t destination
;
10946 struct in_addr netmask
;
10948 destination
= ntohl (p
->u
.prefix4
.s_addr
);
10949 masklen2ip (p
->prefixlen
, &netmask
);
10950 vty_out (vty
, " network %s",
10951 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
));
10953 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
10954 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
10955 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
10956 || p
->u
.prefix4
.s_addr
== 0)
10958 /* Natural mask is not display. */
10961 vty_out (vty
, " mask %s", inet_ntoa (netmask
));
10965 vty_out (vty
, " network %s/%d",
10966 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
10970 if (bgp_static
->rmap
.name
)
10971 vty_out (vty
, " route-map %s", bgp_static
->rmap
.name
);
10972 else if (bgp_static
->backdoor
)
10973 vty_out (vty
, " backdoor");
10975 vty_out (vty
, "%s", VTY_NEWLINE
);
10978 /* Aggregate-address configuration. */
10979 for (rn
= bgp_table_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
10980 if ((bgp_aggregate
= rn
->info
) != NULL
)
10984 /* "address-family" display. */
10985 bgp_config_write_family_header (vty
, afi
, safi
, write
);
10987 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
10989 struct in_addr netmask
;
10991 masklen2ip (p
->prefixlen
, &netmask
);
10992 vty_out (vty
, " aggregate-address %s %s",
10993 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
10994 inet_ntoa (netmask
));
10998 vty_out (vty
, " aggregate-address %s/%d",
10999 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
11003 if (bgp_aggregate
->as_set
)
11004 vty_out (vty
, " as-set");
11006 if (bgp_aggregate
->summary_only
)
11007 vty_out (vty
, " summary-only");
11009 vty_out (vty
, "%s", VTY_NEWLINE
);
11016 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
)
11018 struct bgp_node
*rn
;
11019 struct bgp_distance
*bdistance
;
11021 /* Distance configuration. */
11022 if (bgp
->distance_ebgp
11023 && bgp
->distance_ibgp
11024 && bgp
->distance_local
11025 && (bgp
->distance_ebgp
!= ZEBRA_EBGP_DISTANCE_DEFAULT
11026 || bgp
->distance_ibgp
!= ZEBRA_IBGP_DISTANCE_DEFAULT
11027 || bgp
->distance_local
!= ZEBRA_IBGP_DISTANCE_DEFAULT
))
11028 vty_out (vty
, " distance bgp %d %d %d%s",
11029 bgp
->distance_ebgp
, bgp
->distance_ibgp
, bgp
->distance_local
,
11032 for (rn
= bgp_table_top (bgp_distance_table
); rn
; rn
= bgp_route_next (rn
))
11033 if ((bdistance
= rn
->info
) != NULL
)
11035 vty_out (vty
, " distance %d %s/%d %s%s", bdistance
->distance
,
11036 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
11037 bdistance
->access_list
? bdistance
->access_list
: "",
11044 /* Allocate routing table structure and install commands. */
11048 /* Init BGP distance table. */
11049 bgp_distance_table
= bgp_table_init (AFI_IP
, SAFI_UNICAST
);
11051 /* IPv4 BGP commands. */
11052 install_element (BGP_NODE
, &bgp_network_cmd
);
11053 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
11054 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
11055 install_element (BGP_NODE
, &bgp_network_route_map_cmd
);
11056 install_element (BGP_NODE
, &bgp_network_mask_route_map_cmd
);
11057 install_element (BGP_NODE
, &bgp_network_mask_natural_route_map_cmd
);
11058 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
11059 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
11060 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
11061 install_element (BGP_NODE
, &no_bgp_network_cmd
);
11062 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
11063 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
11064 install_element (BGP_NODE
, &no_bgp_network_route_map_cmd
);
11065 install_element (BGP_NODE
, &no_bgp_network_mask_route_map_cmd
);
11066 install_element (BGP_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
11067 install_element (BGP_NODE
, &no_bgp_network_backdoor_cmd
);
11068 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_cmd
);
11069 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_cmd
);
11071 install_element (BGP_NODE
, &aggregate_address_cmd
);
11072 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
11073 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
11074 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
11075 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
11076 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
11077 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
11078 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
11079 install_element (BGP_NODE
, &aggregate_address_summary_as_set_cmd
);
11080 install_element (BGP_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
11081 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
11082 install_element (BGP_NODE
, &no_aggregate_address_summary_only_cmd
);
11083 install_element (BGP_NODE
, &no_aggregate_address_as_set_cmd
);
11084 install_element (BGP_NODE
, &no_aggregate_address_as_set_summary_cmd
);
11085 install_element (BGP_NODE
, &no_aggregate_address_summary_as_set_cmd
);
11086 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
11087 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
11088 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_cmd
);
11089 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
11090 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
11092 /* IPv4 unicast configuration. */
11093 install_element (BGP_IPV4_NODE
, &bgp_network_cmd
);
11094 install_element (BGP_IPV4_NODE
, &bgp_network_mask_cmd
);
11095 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_cmd
);
11096 install_element (BGP_IPV4_NODE
, &bgp_network_route_map_cmd
);
11097 install_element (BGP_IPV4_NODE
, &bgp_network_mask_route_map_cmd
);
11098 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_route_map_cmd
);
11099 install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
11100 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_cmd
);
11101 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_cmd
);
11102 install_element (BGP_IPV4_NODE
, &no_bgp_network_route_map_cmd
);
11103 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_route_map_cmd
);
11104 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
11105 install_element (BGP_IPV4_NODE
, &aggregate_address_cmd
);
11106 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_cmd
);
11107 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_only_cmd
);
11108 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_only_cmd
);
11109 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_cmd
);
11110 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_cmd
);
11111 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_summary_cmd
);
11112 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
11113 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_as_set_cmd
);
11114 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
11115 install_element (BGP_IPV4_NODE
, &no_aggregate_address_cmd
);
11116 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_only_cmd
);
11117 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_cmd
);
11118 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_summary_cmd
);
11119 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_as_set_cmd
);
11120 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_cmd
);
11121 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
11122 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_cmd
);
11123 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
11124 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
11126 /* IPv4 multicast configuration. */
11127 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
11128 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
11129 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
11130 install_element (BGP_IPV4M_NODE
, &bgp_network_route_map_cmd
);
11131 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_route_map_cmd
);
11132 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_route_map_cmd
);
11133 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
11134 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
11135 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
11136 install_element (BGP_IPV4M_NODE
, &no_bgp_network_route_map_cmd
);
11137 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_route_map_cmd
);
11138 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
11139 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
11140 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
11141 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
11142 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
11143 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
11144 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
11145 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
11146 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
11147 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_as_set_cmd
);
11148 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
11149 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
11150 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_only_cmd
);
11151 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_cmd
);
11152 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_summary_cmd
);
11153 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_as_set_cmd
);
11154 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
11155 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
11156 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_cmd
);
11157 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
11158 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
11160 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
11161 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
11162 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
11163 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
11164 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
11165 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
11166 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
11167 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
11168 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
11169 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
11170 install_element (VIEW_NODE
, &show_ip_bgp_view_cmd
);
11171 install_element (VIEW_NODE
, &show_ip_bgp_view_route_cmd
);
11172 install_element (VIEW_NODE
, &show_ip_bgp_view_prefix_cmd
);
11173 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
11174 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
11175 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
11176 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
11177 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
11178 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
11179 install_element (VIEW_NODE
, &show_ip_bgp_route_map_cmd
);
11180 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
11181 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
11182 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
11183 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
11184 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
11185 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
11186 install_element (VIEW_NODE
, &show_ip_bgp_community2_cmd
);
11187 install_element (VIEW_NODE
, &show_ip_bgp_community3_cmd
);
11188 install_element (VIEW_NODE
, &show_ip_bgp_community4_cmd
);
11189 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
11190 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
11191 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
11192 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
11193 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
11194 install_element (VIEW_NODE
, &show_ip_bgp_community2_exact_cmd
);
11195 install_element (VIEW_NODE
, &show_ip_bgp_community3_exact_cmd
);
11196 install_element (VIEW_NODE
, &show_ip_bgp_community4_exact_cmd
);
11197 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
11198 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
11199 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
11200 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
11201 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
11202 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
11203 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
11204 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
11205 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
11206 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
11207 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
11208 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
11209 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
11210 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
11211 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
11212 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
11213 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
11214 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
11215 install_element (VIEW_NODE
, &show_ip_bgp_dampened_paths_cmd
);
11216 install_element (VIEW_NODE
, &show_ip_bgp_flap_statistics_cmd
);
11217 install_element (VIEW_NODE
, &show_ip_bgp_flap_address_cmd
);
11218 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_cmd
);
11219 install_element (VIEW_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
11220 install_element (VIEW_NODE
, &show_ip_bgp_flap_regexp_cmd
);
11221 install_element (VIEW_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
11222 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
11223 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
11224 install_element (VIEW_NODE
, &show_ip_bgp_flap_route_map_cmd
);
11225 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
11226 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
11227 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_cmd
);
11228 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_route_cmd
);
11229 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
11230 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_cmd
);
11231 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
11232 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
11234 install_element (ENABLE_NODE
, &show_ip_bgp_cmd
);
11235 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cmd
);
11236 install_element (ENABLE_NODE
, &show_ip_bgp_route_cmd
);
11237 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_cmd
);
11238 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
11239 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
11240 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_cmd
);
11241 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
11242 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
11243 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
11244 install_element (ENABLE_NODE
, &show_ip_bgp_view_cmd
);
11245 install_element (ENABLE_NODE
, &show_ip_bgp_view_route_cmd
);
11246 install_element (ENABLE_NODE
, &show_ip_bgp_view_prefix_cmd
);
11247 install_element (ENABLE_NODE
, &show_ip_bgp_regexp_cmd
);
11248 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
11249 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_list_cmd
);
11250 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
11251 install_element (ENABLE_NODE
, &show_ip_bgp_filter_list_cmd
);
11252 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
11253 install_element (ENABLE_NODE
, &show_ip_bgp_route_map_cmd
);
11254 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
11255 install_element (ENABLE_NODE
, &show_ip_bgp_cidr_only_cmd
);
11256 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
11257 install_element (ENABLE_NODE
, &show_ip_bgp_community_all_cmd
);
11258 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
11259 install_element (ENABLE_NODE
, &show_ip_bgp_community_cmd
);
11260 install_element (ENABLE_NODE
, &show_ip_bgp_community2_cmd
);
11261 install_element (ENABLE_NODE
, &show_ip_bgp_community3_cmd
);
11262 install_element (ENABLE_NODE
, &show_ip_bgp_community4_cmd
);
11263 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_cmd
);
11264 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
11265 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
11266 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
11267 install_element (ENABLE_NODE
, &show_ip_bgp_community_exact_cmd
);
11268 install_element (ENABLE_NODE
, &show_ip_bgp_community2_exact_cmd
);
11269 install_element (ENABLE_NODE
, &show_ip_bgp_community3_exact_cmd
);
11270 install_element (ENABLE_NODE
, &show_ip_bgp_community4_exact_cmd
);
11271 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
11272 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
11273 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
11274 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
11275 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_cmd
);
11276 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
11277 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_exact_cmd
);
11278 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
11279 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_longer_cmd
);
11280 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
11281 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
11282 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
11283 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
11284 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
11285 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
11286 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
11287 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
11288 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
11289 install_element (ENABLE_NODE
, &show_ip_bgp_dampened_paths_cmd
);
11290 install_element (ENABLE_NODE
, &show_ip_bgp_flap_statistics_cmd
);
11291 install_element (ENABLE_NODE
, &show_ip_bgp_flap_address_cmd
);
11292 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_cmd
);
11293 install_element (ENABLE_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
11294 install_element (ENABLE_NODE
, &show_ip_bgp_flap_regexp_cmd
);
11295 install_element (ENABLE_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
11296 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
11297 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
11298 install_element (ENABLE_NODE
, &show_ip_bgp_flap_route_map_cmd
);
11299 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
11300 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
11301 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_cmd
);
11302 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_route_cmd
);
11303 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
11304 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_cmd
);
11305 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
11306 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
11308 /* BGP dampening clear commands */
11309 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_cmd
);
11310 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_prefix_cmd
);
11311 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_cmd
);
11312 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_mask_cmd
);
11315 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_prefix_counts_cmd
);
11316 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
);
11317 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
);
11319 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_prefix_counts_cmd
);
11321 /* New config IPv6 BGP commands. */
11322 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
11323 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_route_map_cmd
);
11324 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
11325 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_route_map_cmd
);
11327 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
11328 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
11329 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
11330 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
11332 /* Old config IPv6 BGP commands. */
11333 install_element (BGP_NODE
, &old_ipv6_bgp_network_cmd
);
11334 install_element (BGP_NODE
, &old_no_ipv6_bgp_network_cmd
);
11336 install_element (BGP_NODE
, &old_ipv6_aggregate_address_cmd
);
11337 install_element (BGP_NODE
, &old_ipv6_aggregate_address_summary_only_cmd
);
11338 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_cmd
);
11339 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_summary_only_cmd
);
11341 install_element (VIEW_NODE
, &show_bgp_cmd
);
11342 install_element (VIEW_NODE
, &show_bgp_ipv6_cmd
);
11343 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
11344 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
11345 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
11346 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
11347 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
11348 install_element (VIEW_NODE
, &show_bgp_ipv6_regexp_cmd
);
11349 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
11350 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
11351 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
11352 install_element (VIEW_NODE
, &show_bgp_ipv6_filter_list_cmd
);
11353 install_element (VIEW_NODE
, &show_bgp_route_map_cmd
);
11354 install_element (VIEW_NODE
, &show_bgp_ipv6_route_map_cmd
);
11355 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
11356 install_element (VIEW_NODE
, &show_bgp_ipv6_community_all_cmd
);
11357 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
11358 install_element (VIEW_NODE
, &show_bgp_ipv6_community_cmd
);
11359 install_element (VIEW_NODE
, &show_bgp_community2_cmd
);
11360 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_cmd
);
11361 install_element (VIEW_NODE
, &show_bgp_community3_cmd
);
11362 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_cmd
);
11363 install_element (VIEW_NODE
, &show_bgp_community4_cmd
);
11364 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_cmd
);
11365 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
11366 install_element (VIEW_NODE
, &show_bgp_ipv6_community_exact_cmd
);
11367 install_element (VIEW_NODE
, &show_bgp_community2_exact_cmd
);
11368 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
11369 install_element (VIEW_NODE
, &show_bgp_community3_exact_cmd
);
11370 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
11371 install_element (VIEW_NODE
, &show_bgp_community4_exact_cmd
);
11372 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
11373 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
11374 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_cmd
);
11375 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
11376 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
11377 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
11378 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
11379 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
11380 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
11381 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
11382 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
11383 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
11384 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
11385 install_element (VIEW_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
11386 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
11387 install_element (VIEW_NODE
, &show_bgp_neighbor_flap_cmd
);
11388 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
11389 install_element (VIEW_NODE
, &show_bgp_neighbor_damp_cmd
);
11390 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
11391 install_element (VIEW_NODE
, &show_bgp_rsclient_cmd
);
11392 install_element (VIEW_NODE
, &show_bgp_rsclient_route_cmd
);
11393 install_element (VIEW_NODE
, &show_bgp_rsclient_prefix_cmd
);
11394 install_element (VIEW_NODE
, &show_bgp_view_cmd
);
11395 install_element (VIEW_NODE
, &show_bgp_view_ipv6_cmd
);
11396 install_element (VIEW_NODE
, &show_bgp_view_route_cmd
);
11397 install_element (VIEW_NODE
, &show_bgp_view_ipv6_route_cmd
);
11398 install_element (VIEW_NODE
, &show_bgp_view_prefix_cmd
);
11399 install_element (VIEW_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
11400 install_element (VIEW_NODE
, &show_bgp_view_neighbor_advertised_route_cmd
);
11401 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_advertised_route_cmd
);
11402 install_element (VIEW_NODE
, &show_bgp_view_neighbor_received_routes_cmd
);
11403 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_received_routes_cmd
);
11404 install_element (VIEW_NODE
, &show_bgp_view_neighbor_routes_cmd
);
11405 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_routes_cmd
);
11406 install_element (VIEW_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
11407 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
11408 install_element (VIEW_NODE
, &show_bgp_view_neighbor_flap_cmd
);
11409 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_flap_cmd
);
11410 install_element (VIEW_NODE
, &show_bgp_view_neighbor_damp_cmd
);
11411 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_damp_cmd
);
11412 install_element (VIEW_NODE
, &show_bgp_view_rsclient_cmd
);
11413 install_element (VIEW_NODE
, &show_bgp_view_rsclient_route_cmd
);
11414 install_element (VIEW_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
11416 install_element (ENABLE_NODE
, &show_bgp_cmd
);
11417 install_element (ENABLE_NODE
, &show_bgp_ipv6_cmd
);
11418 install_element (ENABLE_NODE
, &show_bgp_route_cmd
);
11419 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_cmd
);
11420 install_element (ENABLE_NODE
, &show_bgp_prefix_cmd
);
11421 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_cmd
);
11422 install_element (ENABLE_NODE
, &show_bgp_regexp_cmd
);
11423 install_element (ENABLE_NODE
, &show_bgp_ipv6_regexp_cmd
);
11424 install_element (ENABLE_NODE
, &show_bgp_prefix_list_cmd
);
11425 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
11426 install_element (ENABLE_NODE
, &show_bgp_filter_list_cmd
);
11427 install_element (ENABLE_NODE
, &show_bgp_ipv6_filter_list_cmd
);
11428 install_element (ENABLE_NODE
, &show_bgp_route_map_cmd
);
11429 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_map_cmd
);
11430 install_element (ENABLE_NODE
, &show_bgp_community_all_cmd
);
11431 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_all_cmd
);
11432 install_element (ENABLE_NODE
, &show_bgp_community_cmd
);
11433 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_cmd
);
11434 install_element (ENABLE_NODE
, &show_bgp_community2_cmd
);
11435 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_cmd
);
11436 install_element (ENABLE_NODE
, &show_bgp_community3_cmd
);
11437 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_cmd
);
11438 install_element (ENABLE_NODE
, &show_bgp_community4_cmd
);
11439 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_cmd
);
11440 install_element (ENABLE_NODE
, &show_bgp_community_exact_cmd
);
11441 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_exact_cmd
);
11442 install_element (ENABLE_NODE
, &show_bgp_community2_exact_cmd
);
11443 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
11444 install_element (ENABLE_NODE
, &show_bgp_community3_exact_cmd
);
11445 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
11446 install_element (ENABLE_NODE
, &show_bgp_community4_exact_cmd
);
11447 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
11448 install_element (ENABLE_NODE
, &show_bgp_community_list_cmd
);
11449 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_cmd
);
11450 install_element (ENABLE_NODE
, &show_bgp_community_list_exact_cmd
);
11451 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
11452 install_element (ENABLE_NODE
, &show_bgp_prefix_longer_cmd
);
11453 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
11454 install_element (ENABLE_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
11455 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
11456 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_routes_cmd
);
11457 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
11458 install_element (ENABLE_NODE
, &show_bgp_neighbor_routes_cmd
);
11459 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
11460 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
11461 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
11462 install_element (ENABLE_NODE
, &show_bgp_neighbor_flap_cmd
);
11463 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
11464 install_element (ENABLE_NODE
, &show_bgp_neighbor_damp_cmd
);
11465 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
11466 install_element (ENABLE_NODE
, &show_bgp_rsclient_cmd
);
11467 install_element (ENABLE_NODE
, &show_bgp_rsclient_route_cmd
);
11468 install_element (ENABLE_NODE
, &show_bgp_rsclient_prefix_cmd
);
11469 install_element (ENABLE_NODE
, &show_bgp_view_cmd
);
11470 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_cmd
);
11471 install_element (ENABLE_NODE
, &show_bgp_view_route_cmd
);
11472 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_route_cmd
);
11473 install_element (ENABLE_NODE
, &show_bgp_view_prefix_cmd
);
11474 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
11475 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_advertised_route_cmd
);
11476 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_advertised_route_cmd
);
11477 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_received_routes_cmd
);
11478 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_received_routes_cmd
);
11479 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_routes_cmd
);
11480 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_routes_cmd
);
11481 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
11482 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
11483 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_flap_cmd
);
11484 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_flap_cmd
);
11485 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_damp_cmd
);
11486 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_damp_cmd
);
11487 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_cmd
);
11488 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_route_cmd
);
11489 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
11492 install_element (ENABLE_NODE
, &show_bgp_statistics_cmd
);
11493 install_element (ENABLE_NODE
, &show_bgp_statistics_vpnv4_cmd
);
11494 install_element (ENABLE_NODE
, &show_bgp_statistics_view_cmd
);
11495 install_element (ENABLE_NODE
, &show_bgp_statistics_view_vpnv4_cmd
);
11498 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
11499 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
11500 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
11501 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
11502 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
11503 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
11504 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
11505 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
11506 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_cmd
);
11507 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_cmd
);
11508 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_cmd
);
11509 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
11510 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
11511 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
11512 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
11513 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
11514 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
11515 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
11516 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
11517 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
11518 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
11519 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
11520 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
11521 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
11522 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
11523 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
11524 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_cmd
);
11525 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_cmd
);
11526 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_cmd
);
11527 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
11528 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
11529 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
11530 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
11531 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
11532 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
11533 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
11536 install_element (ENABLE_NODE
, &show_ipv6_bgp_cmd
);
11537 install_element (ENABLE_NODE
, &show_ipv6_bgp_route_cmd
);
11538 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_cmd
);
11539 install_element (ENABLE_NODE
, &show_ipv6_bgp_regexp_cmd
);
11540 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
11541 install_element (ENABLE_NODE
, &show_ipv6_bgp_filter_list_cmd
);
11542 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_all_cmd
);
11543 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_cmd
);
11544 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_cmd
);
11545 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_cmd
);
11546 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_cmd
);
11547 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_exact_cmd
);
11548 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
11549 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
11550 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
11551 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_cmd
);
11552 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
11553 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
11554 install_element (ENABLE_NODE
, &show_ipv6_mbgp_cmd
);
11555 install_element (ENABLE_NODE
, &show_ipv6_mbgp_route_cmd
);
11556 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_cmd
);
11557 install_element (ENABLE_NODE
, &show_ipv6_mbgp_regexp_cmd
);
11558 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
11559 install_element (ENABLE_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
11560 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_all_cmd
);
11561 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_cmd
);
11562 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_cmd
);
11563 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_cmd
);
11564 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_cmd
);
11565 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
11566 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
11567 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
11568 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
11569 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_cmd
);
11570 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
11571 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
11574 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
11575 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
11576 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
11577 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
11580 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
11581 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
11582 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
11583 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
11586 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
11587 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
11588 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
11589 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
11590 #endif /* HAVE_IPV6 */
11592 install_element (BGP_NODE
, &bgp_distance_cmd
);
11593 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
11594 install_element (BGP_NODE
, &no_bgp_distance2_cmd
);
11595 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
11596 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
11597 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
11598 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
11600 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
11601 install_element (BGP_NODE
, &bgp_damp_set2_cmd
);
11602 install_element (BGP_NODE
, &bgp_damp_set3_cmd
);
11603 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
11604 install_element (BGP_NODE
, &bgp_damp_unset2_cmd
);
11605 install_element (BGP_IPV4_NODE
, &bgp_damp_set_cmd
);
11606 install_element (BGP_IPV4_NODE
, &bgp_damp_set2_cmd
);
11607 install_element (BGP_IPV4_NODE
, &bgp_damp_set3_cmd
);
11608 install_element (BGP_IPV4_NODE
, &bgp_damp_unset_cmd
);
11609 install_element (BGP_IPV4_NODE
, &bgp_damp_unset2_cmd
);