1 /* BGP routing information
2 Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro
3 Copyright (C) 2016 Job Snijders <job@instituut.net>
5 This file is part of GNU Zebra.
7 GNU Zebra is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
12 GNU Zebra is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Zebra; see the file COPYING. If not, write to the Free
19 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
34 #include "sockunion.h"
37 #include "workqueue.h"
39 #include "bgpd/bgpd.h"
40 #include "bgpd/bgp_table.h"
41 #include "bgpd/bgp_route.h"
42 #include "bgpd/bgp_attr.h"
43 #include "bgpd/bgp_debug.h"
44 #include "bgpd/bgp_aspath.h"
45 #include "bgpd/bgp_regex.h"
46 #include "bgpd/bgp_community.h"
47 #include "bgpd/bgp_ecommunity.h"
48 #include "bgpd/bgp_lcommunity.h"
49 #include "bgpd/bgp_clist.h"
50 #include "bgpd/bgp_packet.h"
51 #include "bgpd/bgp_filter.h"
52 #include "bgpd/bgp_fsm.h"
53 #include "bgpd/bgp_mplsvpn.h"
54 #include "bgpd/bgp_nexthop.h"
55 #include "bgpd/bgp_damp.h"
56 #include "bgpd/bgp_advertise.h"
57 #include "bgpd/bgp_zebra.h"
58 #include "bgpd/bgp_vty.h"
59 #include "bgpd/bgp_mpath.h"
60 #include "bgpd/bgp_nht.h"
62 /* Extern from bgp_dump.c */
63 extern const char *bgp_origin_str[];
64 extern const char *bgp_origin_long_str[];
66 static struct bgp_node *
67 bgp_afi_node_get (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p,
68 struct prefix_rd *prd)
71 struct bgp_node *prn = NULL;
77 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
79 prn = bgp_node_get (table, (struct prefix *) prd);
81 if (prn->info == NULL)
82 prn->info = bgp_table_init (afi, safi);
84 bgp_unlock_node (prn);
88 rn = bgp_node_get (table, p);
90 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
96 /* Allocate bgp_info_extra */
97 static struct bgp_info_extra *
98 bgp_info_extra_new (void)
100 struct bgp_info_extra *new;
101 new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA, sizeof (struct bgp_info_extra));
106 bgp_info_extra_free (struct bgp_info_extra **extra)
110 if ((*extra)->damp_info)
111 bgp_damp_info_free ((*extra)->damp_info, 0);
113 (*extra)->damp_info = NULL;
115 XFREE (MTYPE_BGP_ROUTE_EXTRA, *extra);
121 /* Get bgp_info extra information for the given bgp_info, lazy allocated
124 struct bgp_info_extra *
125 bgp_info_extra_get (struct bgp_info *ri)
128 ri->extra = bgp_info_extra_new();
132 /* Free bgp route information. */
134 bgp_info_free (struct bgp_info *binfo)
137 bgp_attr_unintern (&binfo->attr);
139 bgp_unlink_nexthop (binfo);
140 bgp_info_extra_free (&binfo->extra);
141 bgp_info_mpath_free (&binfo->mpath);
143 peer_unlock (binfo->peer); /* bgp_info peer reference */
145 XFREE (MTYPE_BGP_ROUTE, binfo);
149 bgp_info_lock (struct bgp_info *binfo)
156 bgp_info_unlock (struct bgp_info *binfo)
158 assert (binfo && binfo->lock > 0);
161 if (binfo->lock == 0)
164 zlog_debug ("%s: unlocked and freeing", __func__);
165 zlog_backtrace (LOG_DEBUG);
167 bgp_info_free (binfo);
172 if (binfo->lock == 1)
174 zlog_debug ("%s: unlocked to 1", __func__);
175 zlog_backtrace (LOG_DEBUG);
183 bgp_info_add (struct bgp_node *rn, struct bgp_info *ri)
185 struct bgp_info *top;
197 peer_lock (ri->peer); /* bgp_info peer reference */
200 /* Do the actual removal of info from RIB, for use by bgp_process
201 completion callback *only* */
203 bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri)
206 ri->next->prev = ri->prev;
208 ri->prev->next = ri->next;
212 bgp_info_mpath_dequeue (ri);
213 bgp_info_unlock (ri);
214 bgp_unlock_node (rn);
218 bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri)
220 bgp_info_set_flag (rn, ri, BGP_INFO_REMOVED);
221 /* set of previous already took care of pcount */
222 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
225 /* undo the effects of a previous call to bgp_info_delete; typically
226 called when a route is deleted and then quickly re-added before the
227 deletion has been processed */
229 bgp_info_restore (struct bgp_node *rn, struct bgp_info *ri)
231 bgp_info_unset_flag (rn, ri, BGP_INFO_REMOVED);
232 /* unset of previous already took care of pcount */
233 SET_FLAG (ri->flags, BGP_INFO_VALID);
236 /* Adjust pcount as required */
238 bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri)
240 struct bgp_table *table;
242 assert (rn && bgp_node_table (rn));
243 assert (ri && ri->peer && ri->peer->bgp);
245 table = bgp_node_table (rn);
247 /* Ignore 'pcount' for RS-client tables */
248 if (table->type != BGP_TABLE_MAIN
249 || ri->peer == ri->peer->bgp->peer_self)
252 if (!BGP_INFO_COUNTABLE (ri)
253 && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
256 UNSET_FLAG (ri->flags, BGP_INFO_COUNTED);
258 /* slight hack, but more robust against errors. */
259 if (ri->peer->pcount[table->afi][table->safi])
260 ri->peer->pcount[table->afi][table->safi]--;
263 zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s",
264 __func__, ri->peer->host);
265 zlog_backtrace (LOG_WARNING);
266 zlog_warn ("%s: Please report to Quagga bugzilla", __func__);
269 else if (BGP_INFO_COUNTABLE (ri)
270 && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
272 SET_FLAG (ri->flags, BGP_INFO_COUNTED);
273 ri->peer->pcount[table->afi][table->safi]++;
278 /* Set/unset bgp_info flags, adjusting any other state as needed.
279 * This is here primarily to keep prefix-count in check.
282 bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag)
284 SET_FLAG (ri->flags, flag);
286 /* early bath if we know it's not a flag that changes countability state */
287 if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_HISTORY|BGP_INFO_REMOVED))
290 bgp_pcount_adjust (rn, ri);
294 bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag)
296 UNSET_FLAG (ri->flags, flag);
298 /* early bath if we know it's not a flag that changes countability state */
299 if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_HISTORY|BGP_INFO_REMOVED))
302 bgp_pcount_adjust (rn, ri);
305 /* Get MED value. If MED value is missing and "bgp bestpath
306 missing-as-worst" is specified, treat it as the worst value. */
308 bgp_med_value (struct attr *attr, struct bgp *bgp)
310 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
314 if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST))
321 /* Compare two bgp route entity. Return -1 if new is preferred, 1 if exist
322 * is preferred, or 0 if they are the same (usually will only occur if
323 * multipath is enabled */
325 bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
326 afi_t afi, safi_t safi)
328 struct attr *newattr, *existattr;
329 struct attr_extra *newattre, *existattre;
330 bgp_peer_sort_t new_sort;
331 bgp_peer_sort_t exist_sort;
333 u_int32_t exist_pref;
336 u_int32_t new_weight;
337 u_int32_t exist_weight;
338 uint32_t newm, existm;
339 struct in_addr new_id;
340 struct in_addr exist_id;
343 int internal_as_route;
354 existattr = exist->attr;
355 newattre = newattr->extra;
356 existattre = existattr->extra;
358 /* 1. Weight check. */
359 new_weight = exist_weight = 0;
362 new_weight = newattre->weight;
364 exist_weight = existattre->weight;
366 if (new_weight > exist_weight)
368 if (new_weight < exist_weight)
371 /* 2. Local preference check. */
372 new_pref = exist_pref = bgp->default_local_pref;
374 if (newattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
375 new_pref = newattr->local_pref;
376 if (existattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
377 exist_pref = existattr->local_pref;
379 if (new_pref > exist_pref)
381 if (new_pref < exist_pref)
384 /* 3. Local route check. We prefer:
386 * - BGP_ROUTE_AGGREGATE
387 * - BGP_ROUTE_REDISTRIBUTE
389 if (! (new->sub_type == BGP_ROUTE_NORMAL))
391 if (! (exist->sub_type == BGP_ROUTE_NORMAL))
394 /* 4. AS path length check. */
395 if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE))
397 int exist_hops = aspath_count_hops (existattr->aspath);
398 int exist_confeds = aspath_count_confeds (existattr->aspath);
400 if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED))
404 aspath_hops = aspath_count_hops (newattr->aspath);
405 aspath_hops += aspath_count_confeds (newattr->aspath);
407 if ( aspath_hops < (exist_hops + exist_confeds))
409 if ( aspath_hops > (exist_hops + exist_confeds))
414 int newhops = aspath_count_hops (newattr->aspath);
416 if (newhops < exist_hops)
418 if (newhops > exist_hops)
423 /* 5. Origin check. */
424 if (newattr->origin < existattr->origin)
426 if (newattr->origin > existattr->origin)
430 internal_as_route = (aspath_count_hops (newattr->aspath) == 0
431 && aspath_count_hops (existattr->aspath) == 0);
432 confed_as_route = (aspath_count_confeds (newattr->aspath) > 0
433 && aspath_count_confeds (existattr->aspath) > 0
434 && aspath_count_hops (newattr->aspath) == 0
435 && aspath_count_hops (existattr->aspath) == 0);
437 if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED)
438 || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED)
440 || aspath_cmp_left (newattr->aspath, existattr->aspath)
441 || aspath_cmp_left_confed (newattr->aspath, existattr->aspath)
442 || internal_as_route)
444 new_med = bgp_med_value (new->attr, bgp);
445 exist_med = bgp_med_value (exist->attr, bgp);
447 if (new_med < exist_med)
449 if (new_med > exist_med)
453 /* 7. Peer type check. */
454 new_sort = new->peer->sort;
455 exist_sort = exist->peer->sort;
457 if (new_sort == BGP_PEER_EBGP
458 && (exist_sort == BGP_PEER_IBGP || exist_sort == BGP_PEER_CONFED))
460 if (exist_sort == BGP_PEER_EBGP
461 && (new_sort == BGP_PEER_IBGP || new_sort == BGP_PEER_CONFED))
464 /* 8. IGP metric check. */
468 newm = new->extra->igpmetric;
470 existm = exist->extra->igpmetric;
477 /* 9. Maximum path check. */
478 if (bgp_mpath_is_configured (bgp, afi, safi))
480 if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX))
483 * For the two paths, all comparison steps till IGP metric
484 * have succeeded - including AS_PATH hop count. Since 'bgp
485 * bestpath as-path multipath-relax' knob is on, we don't need
486 * an exact match of AS_PATH. Thus, mark the paths are equal.
487 * That will trigger both these paths to get into the multipath
492 else if (new->peer->sort == BGP_PEER_IBGP)
494 if (aspath_cmp (new->attr->aspath, exist->attr->aspath))
497 else if (new->peer->as == exist->peer->as)
501 /* 10. If both paths are external, prefer the path that was received
502 first (the oldest one). This step minimizes route-flap, since a
503 newer path won't displace an older one, even if it was the
504 preferred route based on the additional decision criteria below. */
505 if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID)
506 && new_sort == BGP_PEER_EBGP
507 && exist_sort == BGP_PEER_EBGP)
509 if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED))
511 if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED))
515 /* 11. Router-ID comparision. */
516 /* If one of the paths is "stale", the corresponding peer router-id will
517 * be 0 and would always win over the other path. If originator id is
518 * used for the comparision, it will decide which path is better.
520 if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
521 new_id.s_addr = newattre->originator_id.s_addr;
523 new_id.s_addr = new->peer->remote_id.s_addr;
524 if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
525 exist_id.s_addr = existattre->originator_id.s_addr;
527 exist_id.s_addr = exist->peer->remote_id.s_addr;
529 if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr))
531 if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr))
534 /* 12. Cluster length comparision. */
535 new_cluster = exist_cluster = 0;
537 if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
538 new_cluster = newattre->cluster->length;
539 if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
540 exist_cluster = existattre->cluster->length;
542 if (new_cluster < exist_cluster)
544 if (new_cluster > exist_cluster)
547 /* 13. Neighbor address comparision. */
548 /* Do this only if neither path is "stale" as stale paths do not have
549 * valid peer information (as the connection may or may not be up).
551 if (CHECK_FLAG (exist->flags, BGP_INFO_STALE))
553 if (CHECK_FLAG (new->flags, BGP_INFO_STALE))
555 /* locally configured routes to advertise do not have su_remote */
556 if (new->peer->su_remote == NULL)
558 if (exist->peer->su_remote == NULL)
561 ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote);
571 static enum filter_type
572 bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr,
573 afi_t afi, safi_t safi)
575 struct bgp_filter *filter;
577 filter = &peer->filter[afi][safi];
579 #define FILTER_EXIST_WARN(F,f,filter) \
580 if (BGP_DEBUG (update, UPDATE_IN) \
581 && !(F ## _IN (filter))) \
582 plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \
583 peer->host, #f, F ## _IN_NAME(filter));
585 if (DISTRIBUTE_IN_NAME (filter)) {
586 FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter);
588 if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY)
592 if (PREFIX_LIST_IN_NAME (filter)) {
593 FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter);
595 if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY)
599 if (FILTER_LIST_IN_NAME (filter)) {
600 FILTER_EXIST_WARN(FILTER_LIST, as, filter);
602 if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY)
606 return FILTER_PERMIT;
607 #undef FILTER_EXIST_WARN
610 static enum filter_type
611 bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr,
612 afi_t afi, safi_t safi)
614 struct bgp_filter *filter;
616 filter = &peer->filter[afi][safi];
618 #define FILTER_EXIST_WARN(F,f,filter) \
619 if (BGP_DEBUG (update, UPDATE_OUT) \
620 && !(F ## _OUT (filter))) \
621 plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \
622 peer->host, #f, F ## _OUT_NAME(filter));
624 if (DISTRIBUTE_OUT_NAME (filter)) {
625 FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter);
627 if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY)
631 if (PREFIX_LIST_OUT_NAME (filter)) {
632 FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter);
634 if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY)
638 if (FILTER_LIST_OUT_NAME (filter)) {
639 FILTER_EXIST_WARN(FILTER_LIST, as, filter);
641 if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY)
645 return FILTER_PERMIT;
646 #undef FILTER_EXIST_WARN
649 /* If community attribute includes no_export then return 1. */
651 bgp_community_filter (struct peer *peer, struct attr *attr)
655 /* NO_ADVERTISE check. */
656 if (community_include (attr->community, COMMUNITY_NO_ADVERTISE))
659 /* NO_EXPORT check. */
660 if (peer->sort == BGP_PEER_EBGP &&
661 community_include (attr->community, COMMUNITY_NO_EXPORT))
664 /* NO_EXPORT_SUBCONFED check. */
665 if (peer->sort == BGP_PEER_EBGP
666 || peer->sort == BGP_PEER_CONFED)
667 if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED))
673 /* Route reflection loop check. */
675 bgp_cluster_filter (struct peer *peer, struct attr *attr)
677 struct in_addr cluster_id;
679 if (attr->extra && attr->extra->cluster)
681 if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID)
682 cluster_id = peer->bgp->cluster_id;
684 cluster_id = peer->bgp->router_id;
686 if (cluster_loop_check (attr->extra->cluster, cluster_id))
693 bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr,
694 afi_t afi, safi_t safi)
696 struct bgp_filter *filter;
697 struct bgp_info info;
698 route_map_result_t ret;
700 filter = &peer->filter[afi][safi];
702 /* Apply default weight value. */
704 (bgp_attr_extra_get (attr))->weight = peer->weight;
706 /* Route map apply. */
707 if (ROUTE_MAP_IN_NAME (filter))
709 /* Duplicate current value to new strucutre for modification. */
713 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN);
715 /* Apply BGP route map to the attribute. */
716 ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info);
720 if (ret == RMAP_DENYMATCH)
721 /* caller has multiple error paths with bgp_attr_flush() */
728 bgp_export_modifier (struct peer *rsclient, struct peer *peer,
729 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
731 struct bgp_filter *filter;
732 struct bgp_info info;
733 route_map_result_t ret;
735 filter = &peer->filter[afi][safi];
737 /* Route map apply. */
738 if (ROUTE_MAP_EXPORT_NAME (filter))
740 /* Duplicate current value to new strucutre for modification. */
741 info.peer = rsclient;
744 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT);
746 /* Apply BGP route map to the attribute. */
747 ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info);
749 rsclient->rmap_type = 0;
751 if (ret == RMAP_DENYMATCH)
753 /* Free newly generated AS path and community by route-map. */
754 bgp_attr_flush (attr);
762 bgp_import_modifier (struct peer *rsclient, struct peer *peer,
763 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
765 struct bgp_filter *filter;
766 struct bgp_info info;
767 route_map_result_t ret;
769 filter = &rsclient->filter[afi][safi];
771 /* Apply default weight value. */
773 (bgp_attr_extra_get (attr))->weight = peer->weight;
775 /* Route map apply. */
776 if (ROUTE_MAP_IMPORT_NAME (filter))
778 /* Duplicate current value to new strucutre for modification. */
782 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT);
784 /* Apply BGP route map to the attribute. */
785 ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info);
789 if (ret == RMAP_DENYMATCH)
791 /* Free newly generated AS path and community by route-map. */
792 bgp_attr_flush (attr);
800 bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p,
801 struct attr *attr, afi_t afi, safi_t safi)
804 char buf[SU_ADDRSTRLEN];
805 struct bgp_filter *filter;
813 filter = &peer->filter[afi][safi];
815 riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr;
817 if (DISABLE_BGP_ANNOUNCE)
820 /* Do not send announces to RS-clients from the 'normal' bgp_table. */
821 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
824 /* Do not send back route to sender. */
828 /* Aggregate-address suppress check. */
829 if (ri->extra && ri->extra->suppress)
830 if (! UNSUPPRESS_MAP_NAME (filter))
833 /* Default route check. */
834 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
836 if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY)
838 else if (p->family == AF_INET6 && p->prefixlen == 0)
842 /* Transparency check. */
843 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)
844 && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
849 /* If community is not disabled check the no-export and local. */
850 if (! transparent && bgp_community_filter (peer, riattr))
853 /* If the attribute has originator-id and it is same as remote
855 if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))
857 if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id))
859 if (BGP_DEBUG (filter, FILTER))
860 zlog (peer->log, LOG_DEBUG,
861 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
863 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
869 /* ORF prefix-list filter check */
870 if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
871 && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
872 || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)))
873 if (peer->orf_plist[afi][safi])
875 if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY)
879 /* Output filter check. */
880 if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY)
882 if (BGP_DEBUG (filter, FILTER))
883 zlog (peer->log, LOG_DEBUG,
884 "%s [Update:SEND] %s/%d is filtered",
886 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
891 #ifdef BGP_SEND_ASPATH_CHECK
892 /* AS path loop check. */
893 if (aspath_loop_check (riattr->aspath, peer->as))
895 if (BGP_DEBUG (filter, FILTER))
896 zlog (peer->log, LOG_DEBUG,
897 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
898 peer->host, peer->as);
902 /* If we're a CONFED we need to loop check the CONFED ID too */
903 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
905 if (aspath_loop_check(riattr->aspath, bgp->confed_id))
907 if (BGP_DEBUG (filter, FILTER))
908 zlog (peer->log, LOG_DEBUG,
909 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
915 #endif /* BGP_SEND_ASPATH_CHECK */
917 /* Route-Reflect check. */
918 if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP)
923 /* IBGP reflection check. */
926 /* A route from a Client peer. */
927 if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
929 /* Reflect to all the Non-Client peers and also to the
930 Client peers other than the originator. Originator check
931 is already done. So there is noting to do. */
932 /* no bgp client-to-client reflection check. */
933 if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT))
934 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
939 /* A route from a Non-client peer. Reflect to all other
941 if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
946 /* For modify attribute, copy it to temporary structure. */
947 bgp_attr_dup (attr, riattr);
949 /* If local-preference is not set. */
950 if ((peer->sort == BGP_PEER_IBGP
951 || peer->sort == BGP_PEER_CONFED)
952 && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))))
954 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF);
955 attr->local_pref = bgp->default_local_pref;
958 /* If originator-id is not set and the route is to be reflected,
959 set the originator id */
960 if (peer && from && peer->sort == BGP_PEER_IBGP &&
961 from->sort == BGP_PEER_IBGP &&
962 (! (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))))
964 attr->extra = bgp_attr_extra_get(attr);
965 IPV4_ADDR_COPY(&(attr->extra->originator_id), &(from->remote_id));
966 SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID);
969 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
970 if (peer->sort == BGP_PEER_EBGP
971 && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
973 if (ri->peer != bgp->peer_self && ! transparent
974 && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
975 attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC));
979 #define NEXTHOP_IS_V4 (\
980 (safi != SAFI_ENCAP && p->family == AF_INET) || \
981 (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 4))
983 #define NEXTHOP_IS_V6 (\
984 (safi != SAFI_ENCAP && p->family == AF_INET6) || \
985 (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 16))
989 || (reflect && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF_ALL))
990 || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)
991 && ((NEXTHOP_IS_V4 && attr->nexthop.s_addr)
993 ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
996 /* NEXT-HOP Unchanged. */
998 else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF)
999 || (NEXTHOP_IS_V4 && attr->nexthop.s_addr == 0)
1000 || (NEXTHOP_IS_V6 &&
1001 IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
1002 || (peer->sort == BGP_PEER_EBGP
1003 && (bgp_multiaccess_check_v4 (attr->nexthop, peer) == 0)))
1005 /* Set IPv4 nexthop. */
1008 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
1009 memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4,
1012 memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
1014 /* Set IPv6 nexthop. */
1017 /* IPv6 global nexthop must be included. */
1018 memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global,
1020 attr->extra->mp_nexthop_len = 16;
1024 if (p->family == AF_INET6 && safi != SAFI_ENCAP)
1026 /* Left nexthop_local unchanged if so configured. */
1027 if ( CHECK_FLAG (peer->af_flags[afi][safi],
1028 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) )
1030 if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) )
1031 attr->extra->mp_nexthop_len=32;
1033 attr->extra->mp_nexthop_len=16;
1036 /* Default nexthop_local treatment for non-RS-Clients */
1039 /* Link-local address should not be transit to different peer. */
1040 attr->extra->mp_nexthop_len = 16;
1042 /* Set link-local address for shared network peer. */
1043 if (peer->shared_network
1044 && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
1046 memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local,
1048 attr->extra->mp_nexthop_len = 32;
1051 /* If bgpd act as BGP-4+ route-reflector, do not send link-local
1054 attr->extra->mp_nexthop_len = 16;
1056 /* If BGP-4+ link-local nexthop is not link-local nexthop. */
1057 if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local))
1058 attr->extra->mp_nexthop_len = 16;
1063 /* If this is EBGP peer and remove-private-AS is set. */
1064 if (peer->sort == BGP_PEER_EBGP
1065 && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)
1066 && aspath_private_as_check (attr->aspath))
1067 attr->aspath = aspath_empty_get ();
1069 /* Route map & unsuppress-map apply. */
1070 if (ROUTE_MAP_OUT_NAME (filter)
1071 || (ri->extra && ri->extra->suppress) )
1073 struct bgp_info info;
1074 struct attr dummy_attr;
1075 struct attr_extra dummy_extra;
1077 dummy_attr.extra = &dummy_extra;
1082 /* The route reflector is not allowed to modify the attributes
1083 of the reflected IBGP routes, unless configured to allow it */
1084 if ((from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP) &&
1085 !bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY))
1087 bgp_attr_dup (&dummy_attr, attr);
1088 info.attr = &dummy_attr;
1091 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT);
1093 if (ri->extra && ri->extra->suppress)
1094 ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info);
1096 ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info);
1098 peer->rmap_type = 0;
1100 if (ret == RMAP_DENYMATCH)
1102 bgp_attr_flush (attr);
1110 bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient,
1111 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
1114 char buf[SU_ADDRSTRLEN];
1115 struct bgp_filter *filter;
1116 struct bgp_info info;
1118 struct attr *riattr;
1121 filter = &rsclient->filter[afi][safi];
1122 riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr;
1124 if (DISABLE_BGP_ANNOUNCE)
1127 /* Do not send back route to sender. */
1128 if (from == rsclient)
1131 /* Aggregate-address suppress check. */
1132 if (ri->extra && ri->extra->suppress)
1133 if (! UNSUPPRESS_MAP_NAME (filter))
1136 /* Default route check. */
1137 if (CHECK_FLAG (rsclient->af_sflags[afi][safi],
1138 PEER_STATUS_DEFAULT_ORIGINATE))
1140 if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY)
1142 else if (p->family == AF_INET6 && p->prefixlen == 0)
1146 /* If the attribute has originator-id and it is same as remote
1148 if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))
1150 if (IPV4_ADDR_SAME (&rsclient->remote_id,
1151 &riattr->extra->originator_id))
1153 if (BGP_DEBUG (filter, FILTER))
1154 zlog (rsclient->log, LOG_DEBUG,
1155 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
1157 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1163 /* ORF prefix-list filter check */
1164 if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
1165 && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
1166 || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)))
1167 if (rsclient->orf_plist[afi][safi])
1169 if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY)
1173 /* Output filter check. */
1174 if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY)
1176 if (BGP_DEBUG (filter, FILTER))
1177 zlog (rsclient->log, LOG_DEBUG,
1178 "%s [Update:SEND] %s/%d is filtered",
1180 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1185 #ifdef BGP_SEND_ASPATH_CHECK
1186 /* AS path loop check. */
1187 if (aspath_loop_check (riattr->aspath, rsclient->as))
1189 if (BGP_DEBUG (filter, FILTER))
1190 zlog (rsclient->log, LOG_DEBUG,
1191 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
1192 rsclient->host, rsclient->as);
1195 #endif /* BGP_SEND_ASPATH_CHECK */
1197 /* For modify attribute, copy it to temporary structure. */
1198 bgp_attr_dup (attr, riattr);
1201 if ((p->family == AF_INET && attr->nexthop.s_addr == 0)
1202 || (p->family == AF_INET6 &&
1203 IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
1206 /* Set IPv4 nexthop. */
1207 if (p->family == AF_INET)
1209 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
1210 memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4,
1213 memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN);
1215 /* Set IPv6 nexthop. */
1216 if (p->family == AF_INET6)
1218 /* IPv6 global nexthop must be included. */
1219 memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global,
1221 attr->extra->mp_nexthop_len = 16;
1225 if (p->family == AF_INET6)
1227 struct attr_extra *attre = attr->extra;
1229 /* Left nexthop_local unchanged if so configured. */
1230 if ( CHECK_FLAG (rsclient->af_flags[afi][safi],
1231 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) )
1233 if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) )
1234 attre->mp_nexthop_len=32;
1236 attre->mp_nexthop_len=16;
1239 /* Default nexthop_local treatment for RS-Clients */
1242 /* Announcer and RS-Client are both in the same network */
1243 if (rsclient->shared_network && from->shared_network &&
1244 (rsclient->ifindex == from->ifindex))
1246 if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) )
1247 attre->mp_nexthop_len=32;
1249 attre->mp_nexthop_len=16;
1252 /* Set link-local address for shared network peer. */
1253 else if (rsclient->shared_network
1254 && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local))
1256 memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local,
1258 attre->mp_nexthop_len = 32;
1262 attre->mp_nexthop_len = 16;
1267 /* If this is EBGP peer and remove-private-AS is set. */
1268 if (rsclient->sort == BGP_PEER_EBGP
1269 && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)
1270 && aspath_private_as_check (attr->aspath))
1271 attr->aspath = aspath_empty_get ();
1273 /* Route map & unsuppress-map apply. */
1274 if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) )
1276 info.peer = rsclient;
1279 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT);
1281 if (ri->extra && ri->extra->suppress)
1282 ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info);
1284 ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info);
1286 rsclient->rmap_type = 0;
1288 if (ret == RMAP_DENYMATCH)
1290 bgp_attr_flush (attr);
1298 struct bgp_info_pair
1300 struct bgp_info *old;
1301 struct bgp_info *new;
1305 bgp_best_selection (struct bgp *bgp, struct bgp_node *rn,
1306 struct bgp_info_pair *result,
1307 afi_t afi, safi_t safi)
1309 struct bgp_info *new_select;
1310 struct bgp_info *old_select;
1311 struct bgp_info *ri;
1312 struct bgp_info *ri1;
1313 struct bgp_info *ri2;
1314 struct bgp_info *nextri = NULL;
1315 int cmpret, do_mpath;
1316 struct list mp_list;
1318 result->old = result->new = NULL;
1320 if (rn->info == NULL)
1322 char buf[PREFIX_STRLEN];
1323 zlog_warn ("%s: Called for route_node %s with no routing entries!",
1325 prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf)));
1329 bgp_mp_list_init (&mp_list);
1330 do_mpath = bgp_mpath_is_configured (bgp, afi, safi);
1332 /* bgp deterministic-med */
1334 if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
1335 for (ri1 = rn->info; ri1; ri1 = ri1->next)
1337 if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK))
1339 if (BGP_INFO_HOLDDOWN (ri1))
1341 if (ri1->peer && ri1->peer != bgp->peer_self)
1342 if (ri1->peer->status != Established)
1347 bgp_mp_list_add (&mp_list, ri1);
1348 old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL;
1350 for (ri2 = ri1->next; ri2; ri2 = ri2->next)
1352 if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK))
1354 if (BGP_INFO_HOLDDOWN (ri2))
1357 ri2->peer != bgp->peer_self &&
1358 !CHECK_FLAG (ri2->peer->sflags, PEER_STATUS_NSF_WAIT))
1359 if (ri2->peer->status != Established)
1362 if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath)
1363 || aspath_cmp_left_confed (ri1->attr->aspath,
1366 if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED))
1368 if ((cmpret = bgp_info_cmp (bgp, ri2, new_select, afi, safi))
1371 bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED);
1378 bgp_mp_list_clear (&mp_list);
1380 if (cmpret == 0 || cmpret == -1)
1381 bgp_mp_list_add (&mp_list, ri2);
1384 bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK);
1387 bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK);
1388 bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED);
1390 bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi);
1391 bgp_mp_list_clear (&mp_list);
1394 /* Check old selected route and new selected route. */
1397 for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri)
1399 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
1402 if (BGP_INFO_HOLDDOWN (ri))
1404 /* reap REMOVED routes, if needs be
1405 * selected route must stay for a while longer though
1407 if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)
1408 && (ri != old_select))
1409 bgp_info_reap (rn, ri);
1415 ri->peer != bgp->peer_self &&
1416 !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT))
1417 if (ri->peer->status != Established)
1420 if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)
1421 && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED)))
1423 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK);
1426 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK);
1427 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED);
1429 if ((cmpret = bgp_info_cmp (bgp, ri, new_select, afi, safi)) == -1)
1431 if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
1432 bgp_mp_dmed_deselect (new_select);
1436 else if (cmpret == 1 && do_mpath
1437 && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
1438 bgp_mp_dmed_deselect (ri);
1443 bgp_mp_list_clear (&mp_list);
1445 if (cmpret == 0 || cmpret == -1)
1446 bgp_mp_list_add (&mp_list, ri);
1450 if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
1451 bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi);
1453 bgp_info_mpath_aggregate_update (new_select, old_select);
1454 bgp_mp_list_clear (&mp_list);
1456 result->old = old_select;
1457 result->new = new_select;
1463 bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected,
1464 struct bgp_node *rn, afi_t afi, safi_t safi)
1468 struct attr_extra extra;
1470 memset (&attr, 0, sizeof(struct attr));
1471 memset (&extra, 0, sizeof(struct attr_extra));
1475 /* Announce route to Established peer. */
1476 if (peer->status != Established)
1479 /* Address family configuration check. */
1480 if (! peer->afc_nego[afi][safi])
1483 /* First update is deferred until ORF or ROUTE-REFRESH is received */
1484 if (CHECK_FLAG (peer->af_sflags[afi][safi],
1485 PEER_STATUS_ORF_WAIT_REFRESH))
1488 /* It's initialized in bgp_announce_[check|check_rsclient]() */
1489 attr.extra = &extra;
1491 switch (bgp_node_table (rn)->type)
1493 case BGP_TABLE_MAIN:
1494 /* Announcement to peer->conf. If the route is filtered,
1496 if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi))
1497 bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected);
1499 bgp_adj_out_unset (rn, peer, p, afi, safi);
1501 case BGP_TABLE_RSCLIENT:
1502 /* Announcement to peer->conf. If the route is filtered,
1505 bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi))
1506 bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected);
1508 bgp_adj_out_unset (rn, peer, p, afi, safi);
1512 bgp_attr_flush (&attr);
1516 struct bgp_process_queue
1519 struct bgp_node *rn;
1524 static wq_item_status
1525 bgp_process_rsclient (struct work_queue *wq, void *data)
1527 struct bgp_process_queue *pq = data;
1528 struct bgp *bgp = pq->bgp;
1529 struct bgp_node *rn = pq->rn;
1530 afi_t afi = pq->afi;
1531 safi_t safi = pq->safi;
1532 struct bgp_info *new_select;
1533 struct bgp_info *old_select;
1534 struct bgp_info_pair old_and_new;
1535 struct listnode *node, *nnode;
1536 struct peer *rsclient = bgp_node_table (rn)->owner;
1538 /* Best path selection. */
1539 bgp_best_selection (bgp, rn, &old_and_new, afi, safi);
1540 new_select = old_and_new.new;
1541 old_select = old_and_new.old;
1543 if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP))
1545 if (rsclient->group)
1546 for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient))
1548 /* Nothing to do. */
1549 if (old_select && old_select == new_select)
1550 if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
1554 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
1557 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1558 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
1559 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
1562 bgp_process_announce_selected (rsclient, new_select, rn,
1569 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
1572 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1573 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
1574 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
1576 bgp_process_announce_selected (rsclient, new_select, rn, afi, safi);
1579 if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED))
1580 bgp_info_reap (rn, old_select);
1582 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1586 static wq_item_status
1587 bgp_process_main (struct work_queue *wq, void *data)
1589 struct bgp_process_queue *pq = data;
1590 struct bgp *bgp = pq->bgp;
1591 struct bgp_node *rn = pq->rn;
1592 afi_t afi = pq->afi;
1593 safi_t safi = pq->safi;
1594 struct prefix *p = &rn->p;
1595 struct bgp_info *new_select;
1596 struct bgp_info *old_select;
1597 struct bgp_info_pair old_and_new;
1598 struct listnode *node, *nnode;
1601 /* Best path selection. */
1602 bgp_best_selection (bgp, rn, &old_and_new, afi, safi);
1603 old_select = old_and_new.old;
1604 new_select = old_and_new.new;
1606 /* Nothing to do. */
1607 if (old_select && old_select == new_select
1608 && !CHECK_FLAG(rn->flags, BGP_NODE_USER_CLEAR))
1610 if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
1612 if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) ||
1613 CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG))
1614 bgp_zebra_announce (p, old_select, bgp, safi);
1616 UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG);
1617 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1622 /* If the user did "clear ip bgp prefix x.x.x.x" this flag will be set */
1623 UNSET_FLAG(rn->flags, BGP_NODE_USER_CLEAR);
1626 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
1629 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1630 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
1631 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
1635 /* Check each BGP peer. */
1636 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
1638 bgp_process_announce_selected (peer, new_select, rn, afi, safi);
1642 if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name &&
1643 ! bgp_option_check (BGP_OPT_NO_FIB)))
1646 && new_select->type == ZEBRA_ROUTE_BGP
1647 && new_select->sub_type == BGP_ROUTE_NORMAL)
1648 bgp_zebra_announce (p, new_select, bgp, safi);
1651 /* Withdraw the route from the kernel. */
1653 && old_select->type == ZEBRA_ROUTE_BGP
1654 && old_select->sub_type == BGP_ROUTE_NORMAL)
1655 bgp_zebra_withdraw (p, old_select, safi);
1659 /* Reap old select bgp_info, if it has been removed */
1660 if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED))
1661 bgp_info_reap (rn, old_select);
1663 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1668 bgp_processq_del (struct work_queue *wq, void *data)
1670 struct bgp_process_queue *pq = data;
1671 struct bgp_table *table = bgp_node_table (pq->rn);
1673 bgp_unlock (pq->bgp);
1674 bgp_unlock_node (pq->rn);
1675 bgp_table_unlock (table);
1676 XFREE (MTYPE_BGP_PROCESS_QUEUE, pq);
1680 bgp_process_queue_init (void)
1682 bm->process_main_queue
1683 = work_queue_new (bm->master, "process_main_queue");
1684 bm->process_rsclient_queue
1685 = work_queue_new (bm->master, "process_rsclient_queue");
1687 if ( !(bm->process_main_queue && bm->process_rsclient_queue) )
1689 zlog_err ("%s: Failed to allocate work queue", __func__);
1693 bm->process_main_queue->spec.workfunc = &bgp_process_main;
1694 bm->process_main_queue->spec.del_item_data = &bgp_processq_del;
1695 bm->process_main_queue->spec.max_retries = 0;
1696 bm->process_main_queue->spec.hold = 50;
1698 bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient;
1699 bm->process_rsclient_queue->spec.del_item_data = &bgp_processq_del;
1700 bm->process_rsclient_queue->spec.max_retries = 0;
1701 bm->process_rsclient_queue->spec.hold = 50;
1705 bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi)
1707 struct bgp_process_queue *pqnode;
1709 /* already scheduled for processing? */
1710 if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED))
1713 if (rn->info == NULL)
1715 /* XXX: Perhaps remove before next release, after we've flushed out
1718 assert (rn->info != NULL);
1719 char buf[PREFIX_STRLEN];
1720 zlog_warn ("%s: Called for route_node %s with no routing entries!",
1722 prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf)));
1726 if ( (bm->process_main_queue == NULL) ||
1727 (bm->process_rsclient_queue == NULL) )
1728 bgp_process_queue_init ();
1730 pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE,
1731 sizeof (struct bgp_process_queue));
1735 /* all unlocked in bgp_processq_del */
1736 bgp_table_lock (bgp_node_table (rn));
1737 pqnode->rn = bgp_lock_node (rn);
1741 pqnode->safi = safi;
1743 switch (bgp_node_table (rn)->type)
1745 case BGP_TABLE_MAIN:
1746 work_queue_add (bm->process_main_queue, pqnode);
1748 case BGP_TABLE_RSCLIENT:
1749 work_queue_add (bm->process_rsclient_queue, pqnode);
1753 SET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1758 bgp_maximum_prefix_restart_timer (struct thread *thread)
1762 peer = THREAD_ARG (thread);
1763 peer->t_pmax_restart = NULL;
1765 if (BGP_DEBUG (events, EVENTS))
1766 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
1775 bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi,
1776 safi_t safi, int always)
1778 if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
1781 if (peer->pcount[afi][safi] > peer->pmax[afi][safi])
1783 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT)
1787 zlog (peer->log, LOG_INFO,
1788 "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
1789 "limit %ld", afi_safi_print (afi, safi), peer->host,
1790 peer->pcount[afi][safi], peer->pmax[afi][safi]);
1791 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT);
1793 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING))
1799 if (safi == SAFI_MPLS_VPN)
1800 safi = SAFI_MPLS_LABELED_VPN;
1802 ndata[0] = (afi >> 8);
1805 ndata[3] = (peer->pmax[afi][safi] >> 24);
1806 ndata[4] = (peer->pmax[afi][safi] >> 16);
1807 ndata[5] = (peer->pmax[afi][safi] >> 8);
1808 ndata[6] = (peer->pmax[afi][safi]);
1810 SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW);
1811 bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE,
1812 BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7);
1815 /* restart timer start */
1816 if (peer->pmax_restart[afi][safi])
1818 peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60;
1820 if (BGP_DEBUG (events, EVENTS))
1821 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
1822 peer->host, peer->v_pmax_restart);
1824 BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer,
1825 peer->v_pmax_restart);
1831 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT);
1833 if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100))
1835 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD)
1839 zlog (peer->log, LOG_INFO,
1840 "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
1841 afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi],
1842 peer->pmax[afi][safi]);
1843 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD);
1846 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD);
1850 /* Unconditionally remove the route from the RIB, without taking
1851 * damping into consideration (eg, because the session went down)
1854 bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
1855 afi_t afi, safi_t safi)
1857 bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
1859 if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
1860 bgp_info_delete (rn, ri); /* keep historical info */
1862 bgp_process (peer->bgp, rn, afi, safi);
1866 bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
1867 afi_t afi, safi_t safi, struct prefix_rd *prd)
1869 int status = BGP_DAMP_NONE;
1871 /* apply dampening, if result is suppressed, we'll be retaining
1872 * the bgp_info in the RIB for historical reference.
1874 if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
1875 && peer->sort == BGP_PEER_EBGP)
1876 if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0))
1877 == BGP_DAMP_SUPPRESSED)
1879 bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
1883 bgp_rib_remove (rn, ri, peer, afi, safi);
1886 static struct bgp_info *
1887 info_make (int type, int sub_type, struct peer *peer, struct attr *attr,
1888 struct bgp_node *rn)
1890 struct bgp_info *new;
1892 /* Make new BGP info. */
1893 new = XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info));
1895 new->sub_type = sub_type;
1898 new->uptime = bgp_clock ();
1904 bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
1905 struct attr *attr, struct peer *peer, struct prefix *p, int type,
1906 int sub_type, struct prefix_rd *prd, u_char *tag)
1908 struct bgp_node *rn;
1910 struct attr new_attr;
1911 struct attr_extra new_extra;
1912 struct attr *attr_new;
1913 struct attr *attr_new2;
1914 struct bgp_info *ri;
1915 struct bgp_info *new;
1917 char buf[SU_ADDRSTRLEN];
1919 /* Do not insert announces from a rsclient into its own 'bgp_table'. */
1920 if (peer == rsclient)
1924 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd);
1926 /* Check previously received route. */
1927 for (ri = rn->info; ri; ri = ri->next)
1928 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
1931 /* AS path loop check. */
1932 if (aspath_loop_check (attr->aspath, rsclient->as) > rsclient->allowas_in[afi][safi])
1934 reason = "as-path contains our own AS;";
1938 /* Route reflector originator ID check. */
1939 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
1940 && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id))
1942 reason = "originator is us;";
1946 new_attr.extra = &new_extra;
1947 bgp_attr_dup (&new_attr, attr);
1949 /* Apply export policy. */
1950 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) &&
1951 bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY)
1953 reason = "export-policy;";
1957 attr_new2 = bgp_attr_intern (&new_attr);
1959 /* Apply import policy. */
1960 if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY)
1962 bgp_attr_unintern (&attr_new2);
1964 reason = "import-policy;";
1968 attr_new = bgp_attr_intern (&new_attr);
1969 bgp_attr_unintern (&attr_new2);
1971 /* IPv4 unicast next hop check. */
1972 if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST))
1974 /* Next hop must not be 0.0.0.0 nor Class D/E address. */
1975 if (new_attr.nexthop.s_addr == 0
1976 || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)))
1978 bgp_attr_unintern (&attr_new);
1980 reason = "martian next-hop;";
1985 /* If the update is implicit withdraw. */
1988 ri->uptime = bgp_clock ();
1990 /* Same attribute comes in. */
1991 if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)
1992 && attrhash_cmp (ri->attr, attr_new))
1996 if (BGP_DEBUG (update, UPDATE_IN))
1997 zlog (peer->log, LOG_DEBUG,
1998 "%s rcvd %s/%d for RS-client %s...duplicate ignored",
2000 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2001 p->prefixlen, rsclient->host);
2003 bgp_unlock_node (rn);
2004 bgp_attr_unintern (&attr_new);
2005 bgp_attr_flush(&new_attr);
2009 /* Withdraw/Announce before we fully processed the withdraw */
2010 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
2011 bgp_info_restore (rn, ri);
2013 /* Received Logging. */
2014 if (BGP_DEBUG (update, UPDATE_IN))
2015 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
2017 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2018 p->prefixlen, rsclient->host);
2020 /* The attribute is changed. */
2021 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
2023 /* Update to new attribute. */
2024 bgp_attr_unintern (&ri->attr);
2025 ri->attr = attr_new;
2027 /* Update MPLS tag. */
2028 if (safi == SAFI_MPLS_VPN)
2029 memcpy ((bgp_info_extra_get (ri))->tag, tag, 3);
2031 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
2033 /* Process change. */
2034 bgp_process (bgp, rn, afi, safi);
2035 bgp_unlock_node (rn);
2040 /* Received Logging. */
2041 if (BGP_DEBUG (update, UPDATE_IN))
2043 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
2045 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2046 p->prefixlen, rsclient->host);
2049 new = info_make(type, sub_type, peer, attr_new, rn);
2051 /* Update MPLS tag. */
2052 if (safi == SAFI_MPLS_VPN)
2053 memcpy ((bgp_info_extra_get (new))->tag, tag, 3);
2055 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
2057 /* Register new BGP information. */
2058 bgp_info_add (rn, new);
2060 /* route_node_get lock */
2061 bgp_unlock_node (rn);
2063 /* Process change. */
2064 bgp_process (bgp, rn, afi, safi);
2070 /* This BGP update is filtered. Log the reason then update BGP entry. */
2071 if (BGP_DEBUG (update, UPDATE_IN))
2072 zlog (peer->log, LOG_DEBUG,
2073 "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s",
2075 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2076 p->prefixlen, rsclient->host, reason);
2079 bgp_rib_remove (rn, ri, peer, afi, safi);
2081 bgp_unlock_node (rn);
2087 bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
2088 struct peer *peer, struct prefix *p, int type, int sub_type,
2089 struct prefix_rd *prd, u_char *tag)
2091 struct bgp_node *rn;
2092 struct bgp_info *ri;
2093 char buf[SU_ADDRSTRLEN];
2095 if (rsclient == peer)
2098 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd);
2100 /* Lookup withdrawn route. */
2101 for (ri = rn->info; ri; ri = ri->next)
2102 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2105 /* Withdraw specified route from routing table. */
2106 if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
2107 bgp_rib_withdraw (rn, ri, peer, afi, safi, prd);
2108 else if (BGP_DEBUG (update, UPDATE_IN))
2109 zlog (peer->log, LOG_DEBUG,
2110 "%s Can't find the route %s/%d", peer->host,
2111 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2114 /* Unlock bgp_node_get() lock. */
2115 bgp_unlock_node (rn);
2119 bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr,
2120 afi_t afi, safi_t safi, int type, int sub_type,
2121 struct prefix_rd *prd, u_char *tag, int soft_reconfig)
2124 int aspath_loop_count = 0;
2125 struct bgp_node *rn;
2127 struct attr new_attr;
2128 struct attr_extra new_extra;
2129 struct attr *attr_new;
2130 struct bgp_info *ri;
2131 struct bgp_info *new;
2133 char buf[SU_ADDRSTRLEN];
2136 memset (&new_attr, 0, sizeof(struct attr));
2137 memset (&new_extra, 0, sizeof(struct attr_extra));
2140 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
2142 /* When peer's soft reconfiguration enabled. Record input packet in
2144 if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
2145 && peer != bgp->peer_self)
2146 bgp_adj_in_set (rn, peer, attr);
2148 /* Check previously received route. */
2149 for (ri = rn->info; ri; ri = ri->next)
2150 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2153 /* AS path local-as loop check. */
2154 if (peer->change_local_as)
2156 if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND))
2157 aspath_loop_count = 1;
2159 if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count)
2161 reason = "as-path contains our own AS;";
2166 /* AS path loop check. */
2167 if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi]
2168 || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)
2169 && aspath_loop_check(attr->aspath, bgp->confed_id)
2170 > peer->allowas_in[afi][safi]))
2172 reason = "as-path contains our own AS;";
2176 /* Route reflector originator ID check. */
2177 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
2178 && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id))
2180 reason = "originator is us;";
2184 /* Route reflector cluster ID check. */
2185 if (bgp_cluster_filter (peer, attr))
2187 reason = "reflected from the same cluster;";
2191 /* Apply incoming filter. */
2192 if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY)
2198 new_attr.extra = &new_extra;
2199 bgp_attr_dup (&new_attr, attr);
2201 /* Apply incoming route-map.
2202 * NB: new_attr may now contain newly allocated values from route-map "set"
2203 * commands, so we need bgp_attr_flush in the error paths, until we intern
2204 * the attr (which takes over the memory references) */
2205 if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY)
2207 reason = "route-map;";
2208 bgp_attr_flush (&new_attr);
2212 /* IPv4 unicast next hop check. */
2213 if (afi == AFI_IP && safi == SAFI_UNICAST)
2215 /* Next hop must not be 0.0.0.0 nor Class D/E address. Next hop
2216 must not be my own address. */
2217 if (new_attr.nexthop.s_addr == 0
2218 || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))
2219 || bgp_nexthop_self (&new_attr))
2221 reason = "martian next-hop;";
2222 bgp_attr_flush (&new_attr);
2227 attr_new = bgp_attr_intern (&new_attr);
2229 /* If the update is implicit withdraw. */
2232 ri->uptime = bgp_clock ();
2234 /* Same attribute comes in. */
2235 if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)
2236 && attrhash_cmp (ri->attr, attr_new))
2238 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
2239 && peer->sort == BGP_PEER_EBGP
2240 && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
2242 if (BGP_DEBUG (update, UPDATE_IN))
2243 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
2245 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2248 if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED)
2250 bgp_aggregate_increment (bgp, p, ri, afi, safi);
2251 bgp_process (bgp, rn, afi, safi);
2254 else /* Duplicate - odd */
2256 if (BGP_DEBUG (update, UPDATE_IN))
2257 zlog (peer->log, LOG_DEBUG,
2258 "%s rcvd %s/%d...duplicate ignored",
2260 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2263 /* graceful restart STALE flag unset. */
2264 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
2266 bgp_info_unset_flag (rn, ri, BGP_INFO_STALE);
2267 bgp_process (bgp, rn, afi, safi);
2271 bgp_unlock_node (rn);
2272 bgp_attr_unintern (&attr_new);
2273 bgp_attr_flush (&new_attr);
2278 /* Withdraw/Announce before we fully processed the withdraw */
2279 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
2281 if (BGP_DEBUG (update, UPDATE_IN))
2282 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing",
2284 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2286 bgp_info_restore (rn, ri);
2289 /* Received Logging. */
2290 if (BGP_DEBUG (update, UPDATE_IN))
2291 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
2293 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2296 /* graceful restart STALE flag unset. */
2297 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
2298 bgp_info_unset_flag (rn, ri, BGP_INFO_STALE);
2300 /* The attribute is changed. */
2301 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
2303 /* implicit withdraw, decrement aggregate and pcount here.
2304 * only if update is accepted, they'll increment below.
2306 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
2308 /* Update bgp route dampening information. */
2309 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
2310 && peer->sort == BGP_PEER_EBGP)
2312 /* This is implicit withdraw so we should update dampening
2314 if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
2315 bgp_damp_withdraw (ri, rn, afi, safi, 1);
2318 /* Update to new attribute. */
2319 bgp_attr_unintern (&ri->attr);
2320 ri->attr = attr_new;
2322 /* Update MPLS tag. */
2323 if (safi == SAFI_MPLS_VPN)
2324 memcpy ((bgp_info_extra_get (ri))->tag, tag, 3);
2326 bgp_attr_flush (&new_attr);
2328 /* Update bgp route dampening information. */
2329 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
2330 && peer->sort == BGP_PEER_EBGP)
2332 /* Now we do normal update dampening. */
2333 ret = bgp_damp_update (ri, rn, afi, safi);
2334 if (ret == BGP_DAMP_SUPPRESSED)
2336 bgp_unlock_node (rn);
2341 /* Nexthop reachability check. */
2342 if ((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)
2344 if (peer->sort == BGP_PEER_EBGP && peer_ttl (peer) == 1 &&
2345 ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
2350 if (bgp_ensure_nexthop (ri, NULL, connected))
2351 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
2354 if (BGP_DEBUG(nht, NHT))
2356 char buf1[INET6_ADDRSTRLEN];
2357 inet_ntop(AF_INET, (const void *)&attr_new->nexthop, buf1, INET6_ADDRSTRLEN);
2358 zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
2360 bgp_info_unset_flag (rn, ri, BGP_INFO_VALID);
2364 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
2366 bgp_attr_flush (&new_attr);
2368 /* Process change. */
2369 bgp_aggregate_increment (bgp, p, ri, afi, safi);
2371 bgp_process (bgp, rn, afi, safi);
2372 bgp_unlock_node (rn);
2377 /* Received Logging. */
2378 if (BGP_DEBUG (update, UPDATE_IN))
2380 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
2382 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2386 /* Make new BGP info. */
2387 new = info_make(type, sub_type, peer, attr_new, rn);
2389 /* Update MPLS tag. */
2390 if (safi == SAFI_MPLS_VPN)
2391 memcpy ((bgp_info_extra_get (new))->tag, tag, 3);
2393 /* Nexthop reachability check. */
2394 if ((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)
2396 if (peer->sort == BGP_PEER_EBGP && peer_ttl (peer) == 1 &&
2397 ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
2402 if (bgp_ensure_nexthop (new, NULL, connected))
2403 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
2406 if (BGP_DEBUG(nht, NHT))
2408 char buf1[INET6_ADDRSTRLEN];
2409 inet_ntop(AF_INET, (const void *)&attr_new->nexthop, buf1, INET6_ADDRSTRLEN);
2410 zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
2412 bgp_info_unset_flag (rn, new, BGP_INFO_VALID);
2416 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
2418 /* Increment prefix */
2419 bgp_aggregate_increment (bgp, p, new, afi, safi);
2421 /* Register new BGP information. */
2422 bgp_info_add (rn, new);
2424 /* route_node_get lock */
2425 bgp_unlock_node (rn);
2427 bgp_attr_flush (&new_attr);
2429 /* If maximum prefix count is configured and current prefix
2431 if (bgp_maximum_prefix_overflow (peer, afi, safi, 0))
2434 /* Process change. */
2435 bgp_process (bgp, rn, afi, safi);
2439 /* This BGP update is filtered. Log the reason then update BGP
2442 if (BGP_DEBUG (update, UPDATE_IN))
2443 zlog (peer->log, LOG_DEBUG,
2444 "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
2446 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2447 p->prefixlen, reason);
2450 bgp_rib_remove (rn, ri, peer, afi, safi);
2452 bgp_unlock_node (rn);
2453 bgp_attr_flush (&new_attr);
2459 bgp_update (struct peer *peer, struct prefix *p, struct attr *attr,
2460 afi_t afi, safi_t safi, int type, int sub_type,
2461 struct prefix_rd *prd, u_char *tag, int soft_reconfig)
2463 struct peer *rsclient;
2464 struct listnode *node, *nnode;
2468 ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag,
2473 /* Process the update for each RS-client. */
2474 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
2476 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2477 bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type,
2478 sub_type, prd, tag);
2485 bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr,
2486 afi_t afi, safi_t safi, int type, int sub_type,
2487 struct prefix_rd *prd, u_char *tag)
2490 char buf[SU_ADDRSTRLEN];
2491 struct bgp_node *rn;
2492 struct bgp_info *ri;
2493 struct peer *rsclient;
2494 struct listnode *node, *nnode;
2499 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
2501 /* Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all
2502 * routes that are filtered. This tanks out Quagga RS pretty badly due to
2503 * the iteration over all RS clients.
2504 * Since we need to remove the entry from adj_in anyway, do that first and
2505 * if there was no entry, we don't need to do anything more. */
2506 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
2507 && peer != bgp->peer_self)
2508 if (!bgp_adj_in_unset (rn, peer))
2510 if (BGP_DEBUG (update, UPDATE_IN))
2511 zlog (peer->log, LOG_DEBUG, "%s withdrawing route %s/%d "
2512 "not in adj-in", peer->host,
2513 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2515 bgp_unlock_node (rn);
2519 /* Process the withdraw for each RS-client. */
2520 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
2522 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2523 bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag);
2527 if (BGP_DEBUG (update, UPDATE_IN))
2528 zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn",
2530 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2533 /* Lookup withdrawn route. */
2534 for (ri = rn->info; ri; ri = ri->next)
2535 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2538 /* Withdraw specified route from routing table. */
2539 if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
2540 bgp_rib_withdraw (rn, ri, peer, afi, safi, prd);
2541 else if (BGP_DEBUG (update, UPDATE_IN))
2542 zlog (peer->log, LOG_DEBUG,
2543 "%s Can't find the route %s/%d", peer->host,
2544 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2547 /* Unlock bgp_node_get() lock. */
2548 bgp_unlock_node (rn);
2554 bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw)
2558 struct aspath *aspath;
2561 struct bgp_node *rn;
2562 struct bgp_info *ri;
2563 int ret = RMAP_DENYMATCH;
2565 if (!(afi == AFI_IP || afi == AFI_IP6))
2569 from = bgp->peer_self;
2571 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
2572 aspath = attr.aspath;
2573 attr.local_pref = bgp->default_local_pref;
2574 memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
2577 str2prefix ("0.0.0.0/0", &p);
2578 else if (afi == AFI_IP6)
2580 struct attr_extra *ae = attr.extra;
2582 str2prefix ("::/0", &p);
2584 /* IPv6 global nexthop must be included. */
2585 memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global,
2587 ae->mp_nexthop_len = 16;
2589 /* If the peer is on shared nextwork and we have link-local
2591 if (peer->shared_network
2592 && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
2594 memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local,
2596 ae->mp_nexthop_len = 32;
2600 if (peer->default_rmap[afi][safi].name)
2602 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT);
2603 for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; rn = bgp_route_next(rn))
2605 for (ri = rn->info; ri; ri = ri->next)
2607 struct attr dummy_attr;
2608 struct attr_extra dummy_extra;
2609 struct bgp_info info;
2611 /* Provide dummy so the route-map can't modify the attributes */
2612 dummy_attr.extra = &dummy_extra;
2613 bgp_attr_dup(&dummy_attr, ri->attr);
2614 info.peer = ri->peer;
2615 info.attr = &dummy_attr;
2617 ret = route_map_apply(peer->default_rmap[afi][safi].map, &rn->p,
2620 /* The route map might have set attributes. If we don't flush them
2621 * here, they will be leaked. */
2622 bgp_attr_flush(&dummy_attr);
2623 if (ret != RMAP_DENYMATCH)
2626 if (ret != RMAP_DENYMATCH)
2629 bgp->peer_self->rmap_type = 0;
2631 if (ret == RMAP_DENYMATCH)
2637 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
2638 bgp_default_withdraw_send (peer, afi, safi);
2639 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
2643 if (! CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
2645 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
2646 bgp_default_update_send (peer, &attr, afi, safi, from);
2650 bgp_attr_extra_free (&attr);
2651 aspath_unintern (&aspath);
2655 bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi,
2656 struct bgp_table *table, int rsclient)
2658 struct bgp_node *rn;
2659 struct bgp_info *ri;
2661 struct attr_extra extra;
2663 memset(&extra, 0, sizeof(extra));
2666 table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi];
2668 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)
2669 && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
2670 bgp_default_originate (peer, afi, safi, 0);
2672 /* It's initialized in bgp_announce_[check|check_rsclient]() */
2673 attr.extra = &extra;
2675 for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn))
2676 for (ri = rn->info; ri; ri = ri->next)
2677 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer)
2680 (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi))
2681 : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi)))
2682 bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri);
2684 bgp_adj_out_unset (rn, peer, &rn->p, afi, safi);
2687 bgp_attr_flush_encap(&attr);
2691 bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi)
2693 struct bgp_node *rn;
2694 struct bgp_table *table;
2696 if (peer->status != Established)
2699 if (! peer->afc_nego[afi][safi])
2702 /* First update is deferred until ORF or ROUTE-REFRESH is received */
2703 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
2706 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
2707 bgp_announce_table (peer, afi, safi, NULL, 0);
2709 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2710 rn = bgp_route_next(rn))
2711 if ((table = (rn->info)) != NULL)
2712 bgp_announce_table (peer, afi, safi, table, 0);
2714 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2715 bgp_announce_table (peer, afi, safi, NULL, 1);
2719 bgp_announce_route_all (struct peer *peer)
2724 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2725 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
2726 bgp_announce_route (peer, afi, safi);
2730 bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi,
2731 safi_t safi, struct bgp_table *table, struct prefix_rd *prd)
2733 struct bgp_node *rn;
2734 struct bgp_adj_in *ain;
2737 table = rsclient->bgp->rib[afi][safi];
2739 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2740 for (ain = rn->adj_in; ain; ain = ain->next)
2742 struct bgp_info *ri = rn->info;
2743 u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL;
2745 bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer,
2746 &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, tag);
2751 bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
2753 struct bgp_table *table;
2754 struct bgp_node *rn;
2756 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
2757 bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL);
2760 for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn;
2761 rn = bgp_route_next (rn))
2762 if ((table = rn->info) != NULL)
2764 struct prefix_rd prd;
2765 prd.family = AF_UNSPEC;
2767 memcpy(&prd.val, rn->p.u.val, 8);
2769 bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd);
2774 bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi,
2775 struct bgp_table *table, struct prefix_rd *prd)
2778 struct bgp_node *rn;
2779 struct bgp_adj_in *ain;
2782 table = peer->bgp->rib[afi][safi];
2784 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2785 for (ain = rn->adj_in; ain; ain = ain->next)
2787 if (ain->peer == peer)
2789 struct bgp_info *ri = rn->info;
2790 u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL;
2792 ret = bgp_update (peer, &rn->p, ain->attr, afi, safi,
2793 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
2798 bgp_unlock_node (rn);
2807 bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi)
2809 struct bgp_node *rn;
2810 struct bgp_table *table;
2812 if (peer->status != Established)
2815 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
2816 bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL);
2818 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2819 rn = bgp_route_next (rn))
2820 if ((table = rn->info) != NULL)
2822 struct prefix_rd prd;
2823 prd.family = AF_UNSPEC;
2825 memcpy(&prd.val, rn->p.u.val, 8);
2827 bgp_soft_reconfig_table (peer, afi, safi, table, &prd);
2832 struct bgp_clear_node_queue
2834 struct bgp_node *rn;
2835 enum bgp_clear_route_type purpose;
2838 static wq_item_status
2839 bgp_clear_route_node (struct work_queue *wq, void *data)
2841 struct bgp_clear_node_queue *cnq = data;
2842 struct bgp_node *rn = cnq->rn;
2843 struct peer *peer = wq->spec.data;
2844 struct bgp_info *ri;
2845 afi_t afi = bgp_node_table (rn)->afi;
2846 safi_t safi = bgp_node_table (rn)->safi;
2848 assert (rn && peer);
2850 for (ri = rn->info; ri; ri = ri->next)
2851 if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
2853 /* graceful restart STALE flag set. */
2854 if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT)
2855 && peer->nsf[afi][safi]
2856 && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE)
2857 && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
2858 bgp_info_set_flag (rn, ri, BGP_INFO_STALE);
2860 bgp_rib_remove (rn, ri, peer, afi, safi);
2867 bgp_clear_node_queue_del (struct work_queue *wq, void *data)
2869 struct bgp_clear_node_queue *cnq = data;
2870 struct bgp_node *rn = cnq->rn;
2871 struct bgp_table *table = bgp_node_table (rn);
2873 bgp_unlock_node (rn);
2874 bgp_table_unlock (table);
2875 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq);
2879 bgp_clear_node_complete (struct work_queue *wq)
2881 struct peer *peer = wq->spec.data;
2883 /* Tickle FSM to start moving again */
2884 BGP_EVENT_ADD (peer, Clearing_Completed);
2886 peer_unlock (peer); /* bgp_clear_route */
2890 bgp_clear_node_queue_init (struct peer *peer)
2892 char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
2894 snprintf (wname, sizeof(wname), "clear %s", peer->host);
2895 #undef CLEAR_QUEUE_NAME_LEN
2897 if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL)
2899 zlog_err ("%s: Failed to allocate work queue", __func__);
2902 peer->clear_node_queue->spec.hold = 10;
2903 peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node;
2904 peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del;
2905 peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete;
2906 peer->clear_node_queue->spec.max_retries = 0;
2908 /* we only 'lock' this peer reference when the queue is actually active */
2909 peer->clear_node_queue->spec.data = peer;
2913 bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi,
2914 struct bgp_table *table, struct peer *rsclient,
2915 enum bgp_clear_route_type purpose)
2917 struct bgp_node *rn;
2921 table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi];
2923 /* If still no table => afi/safi isn't configured at all or smth. */
2927 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2929 struct bgp_info *ri;
2930 struct bgp_adj_in *ain;
2931 struct bgp_adj_out *aout;
2933 /* XXX:TODO: This is suboptimal, every non-empty route_node is
2934 * queued for every clearing peer, regardless of whether it is
2935 * relevant to the peer at hand.
2937 * Overview: There are 3 different indices which need to be
2938 * scrubbed, potentially, when a peer is removed:
2940 * 1 peer's routes visible via the RIB (ie accepted routes)
2941 * 2 peer's routes visible by the (optional) peer's adj-in index
2942 * 3 other routes visible by the peer's adj-out index
2944 * 3 there is no hurry in scrubbing, once the struct peer is
2945 * removed from bgp->peer, we could just GC such deleted peer's
2946 * adj-outs at our leisure.
2948 * 1 and 2 must be 'scrubbed' in some way, at least made
2949 * invisible via RIB index before peer session is allowed to be
2950 * brought back up. So one needs to know when such a 'search' is
2955 * - there'd be a single global queue or a single RIB walker
2956 * - rather than tracking which route_nodes still need to be
2957 * examined on a peer basis, we'd track which peers still
2960 * Given that our per-peer prefix-counts now should be reliable,
2961 * this may actually be achievable. It doesn't seem to be a huge
2962 * problem at this time,
2964 for (ain = rn->adj_in; ain; ain = ain->next)
2965 if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
2967 bgp_adj_in_remove (rn, ain);
2968 bgp_unlock_node (rn);
2971 for (aout = rn->adj_out; aout; aout = aout->next)
2972 if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
2974 bgp_adj_out_remove (rn, aout, peer, afi, safi);
2975 bgp_unlock_node (rn);
2979 for (ri = rn->info; ri; ri = ri->next)
2980 if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
2982 struct bgp_clear_node_queue *cnq;
2984 /* both unlocked in bgp_clear_node_queue_del */
2985 bgp_table_lock (bgp_node_table (rn));
2987 cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE,
2988 sizeof (struct bgp_clear_node_queue));
2990 cnq->purpose = purpose;
2991 work_queue_add (peer->clear_node_queue, cnq);
2999 bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi,
3000 enum bgp_clear_route_type purpose)
3002 struct bgp_node *rn;
3003 struct bgp_table *table;
3004 struct peer *rsclient;
3005 struct listnode *node, *nnode;
3007 if (peer->clear_node_queue == NULL)
3008 bgp_clear_node_queue_init (peer);
3010 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
3011 * Idle until it receives a Clearing_Completed event. This protects
3012 * against peers which flap faster than we can we clear, which could
3015 * a) race with routes from the new session being installed before
3016 * clear_route_node visits the node (to delete the route of that
3018 * b) resource exhaustion, clear_route_node likely leads to an entry
3019 * on the process_main queue. Fast-flapping could cause that queue
3023 /* lock peer in assumption that clear-node-queue will get nodes; if so,
3024 * the unlock will happen upon work-queue completion; other wise, the
3025 * unlock happens at the end of this function.
3027 if (!peer->clear_node_queue->thread)
3028 peer_lock (peer); /* bgp_clear_node_complete */
3031 case BGP_CLEAR_ROUTE_NORMAL:
3032 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
3033 bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose);
3035 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
3036 rn = bgp_route_next (rn))
3037 if ((table = rn->info) != NULL)
3038 bgp_clear_route_table (peer, afi, safi, table, NULL, purpose);
3040 for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient))
3041 if (CHECK_FLAG(rsclient->af_flags[afi][safi],
3042 PEER_FLAG_RSERVER_CLIENT))
3043 bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose);
3046 case BGP_CLEAR_ROUTE_MY_RSCLIENT:
3048 * gpz 091009: TBD why don't we have special handling for
3049 * SAFI_MPLS_VPN here in the original quagga code?
3050 * (and, by extension, for SAFI_ENCAP)
3052 bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose);
3060 /* unlock if no nodes got added to the clear-node-queue. */
3061 if (!peer->clear_node_queue->thread)
3067 bgp_clear_route_all (struct peer *peer)
3072 for (afi = AFI_IP; afi < AFI_MAX; afi++)
3073 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
3074 bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL);
3078 * Finish freeing things when exiting
3081 bgp_drain_workqueue_immediate (struct work_queue *wq)
3089 * no thread implies no queued items
3091 assert(!wq->items->count);
3095 while (wq->items->count)
3098 thread_cancel(wq->thread);
3099 work_queue_run(wq->thread);
3104 * Special function to process clear node queue when bgpd is exiting
3105 * and the thread scheduler is no longer running.
3108 bgp_peer_clear_node_queue_drain_immediate(struct peer *peer)
3113 bgp_drain_workqueue_immediate(peer->clear_node_queue);
3117 * The work queues are not specific to a BGP instance, but the
3118 * items in them refer to BGP instances, so this should be called
3119 * before each BGP instance is deleted.
3122 bgp_process_queues_drain_immediate(void)
3124 bgp_drain_workqueue_immediate(bm->process_main_queue);
3125 bgp_drain_workqueue_immediate(bm->process_rsclient_queue);
3129 bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi)
3131 struct bgp_table *table;
3132 struct bgp_node *rn;
3133 struct bgp_adj_in *ain;
3135 table = peer->bgp->rib[afi][safi];
3137 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3138 for (ain = rn->adj_in; ain ; ain = ain->next)
3139 if (ain->peer == peer)
3141 bgp_adj_in_remove (rn, ain);
3142 bgp_unlock_node (rn);
3148 bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi)
3150 struct bgp_node *rn;
3151 struct bgp_info *ri;
3152 struct bgp_table *table;
3154 table = peer->bgp->rib[afi][safi];
3156 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3158 for (ri = rn->info; ri; ri = ri->next)
3159 if (ri->peer == peer)
3161 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
3162 bgp_rib_remove (rn, ri, peer, afi, safi);
3169 bgp_cleanup_table(struct bgp_table *table, safi_t safi)
3171 struct bgp_node *rn;
3172 struct bgp_info *ri;
3173 struct bgp_info *next;
3175 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3176 for (ri = rn->info; ri; ri = next)
3179 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)
3180 && ri->type == ZEBRA_ROUTE_BGP
3181 && ri->sub_type == BGP_ROUTE_NORMAL)
3182 bgp_zebra_withdraw (&rn->p, ri, safi);
3186 /* Delete all kernel routes. */
3188 bgp_cleanup_routes (void)
3191 struct listnode *node, *nnode;
3194 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
3196 for (afi = AFI_IP; afi < AFI_MAX; ++afi)
3198 struct bgp_node *rn;
3200 bgp_cleanup_table(bgp->rib[afi][SAFI_UNICAST], SAFI_UNICAST);
3203 * VPN and ENCAP tables are two-level (RD is top level)
3205 for (rn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn;
3206 rn = bgp_route_next (rn))
3210 bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_MPLS_VPN);
3211 bgp_table_finish ((struct bgp_table **)&(rn->info));
3213 bgp_unlock_node(rn);
3217 for (rn = bgp_table_top(bgp->rib[afi][SAFI_ENCAP]); rn;
3218 rn = bgp_route_next (rn))
3222 bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_ENCAP);
3223 bgp_table_finish ((struct bgp_table **)&(rn->info));
3225 bgp_unlock_node(rn);
3236 bgp_zclient_reset ();
3237 access_list_reset ();
3238 prefix_list_reset ();
3241 /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3244 bgp_nlri_parse_ip (struct peer *peer, struct attr *attr,
3245 struct bgp_nlri *packet)
3253 /* Check peer status. */
3254 if (peer->status != Established)
3258 lim = pnt + packet->length;
3260 /* RFC4771 6.3 The NLRI field in the UPDATE message is checked for
3261 syntactic validity. If the field is syntactically incorrect,
3262 then the Error Subcode is set to Invalid Network Field. */
3263 for (; pnt < lim; pnt += psize)
3265 /* Clear prefix structure. */
3266 memset (&p, 0, sizeof (struct prefix));
3268 /* Fetch prefix length. */
3269 p.prefixlen = *pnt++;
3270 /* afi/safi validity already verified by caller, bgp_update_receive */
3271 p.family = afi2family (packet->afi);
3273 /* Prefix length check. */
3274 if (p.prefixlen > prefix_blen (&p) * 8)
3276 plog_err (peer->log,
3277 "%s [Error] Update packet error"
3278 " (wrong prefix length %u for afi %u)",
3279 peer->host, p.prefixlen, packet->afi);
3283 /* Packet size overflow check. */
3284 psize = PSIZE (p.prefixlen);
3286 /* When packet overflow occur return immediately. */
3287 if (pnt + psize > lim)
3289 plog_err (peer->log,
3290 "%s [Error] Update packet error"
3291 " (prefix length %u overflows packet)",
3292 peer->host, p.prefixlen);
3296 /* Defensive coding, double-check the psize fits in a struct prefix */
3297 if (psize > (ssize_t) sizeof(p.u))
3299 plog_err (peer->log,
3300 "%s [Error] Update packet error"
3301 " (prefix length %u too large for prefix storage %zu!?!!",
3302 peer->host, p.prefixlen, sizeof(p.u));
3306 /* Fetch prefix from NLRI packet. */
3307 memcpy (&p.u.prefix, pnt, psize);
3309 /* Check address. */
3310 if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST)
3312 if (IN_CLASSD (ntohl (p.u.prefix4.s_addr)))
3315 * From RFC4271 Section 6.3:
3317 * If a prefix in the NLRI field is semantically incorrect
3318 * (e.g., an unexpected multicast IP address), an error SHOULD
3319 * be logged locally, and the prefix SHOULD be ignored.
3321 zlog (peer->log, LOG_ERR,
3322 "%s: IPv4 unicast NLRI is multicast address %s, ignoring",
3323 peer->host, inet_ntoa (p.u.prefix4));
3328 /* Check address. */
3329 if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST)
3331 if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
3335 zlog (peer->log, LOG_ERR,
3336 "%s: IPv6 unicast NLRI is link-local address %s, ignoring",
3338 inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
3341 if (IN6_IS_ADDR_MULTICAST (&p.u.prefix6))
3345 zlog (peer->log, LOG_ERR,
3346 "%s: IPv6 unicast NLRI is multicast address %s, ignoring",
3348 inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
3353 /* Normal process. */
3355 ret = bgp_update (peer, &p, attr, packet->afi, packet->safi,
3356 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0);
3358 ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi,
3359 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL);
3361 /* Address family configuration mismatch or maximum-prefix count
3367 /* Packet length consistency check. */
3370 plog_err (peer->log,
3371 "%s [Error] Update packet error"
3372 " (prefix length mismatch with total length)",
3380 static struct bgp_static *
3381 bgp_static_new (void)
3383 return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static));
3387 bgp_static_free (struct bgp_static *bgp_static)
3389 if (bgp_static->rmap.name)
3390 free (bgp_static->rmap.name);
3391 XFREE (MTYPE_BGP_STATIC, bgp_static);
3395 bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient,
3396 struct prefix *p, afi_t afi, safi_t safi)
3398 struct bgp_node *rn;
3399 struct bgp_info *ri;
3401 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
3403 /* Check selected route and self inserted route. */
3404 for (ri = rn->info; ri; ri = ri->next)
3405 if (ri->peer == bgp->peer_self
3406 && ri->type == ZEBRA_ROUTE_BGP
3407 && ri->sub_type == BGP_ROUTE_STATIC)
3410 /* Withdraw static BGP route from routing table. */
3413 bgp_info_delete (rn, ri);
3414 bgp_process (bgp, rn, afi, safi);
3417 /* Unlock bgp_node_lookup. */
3418 bgp_unlock_node (rn);
3422 bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p,
3423 struct bgp_static *bgp_static,
3424 afi_t afi, safi_t safi)
3426 struct bgp_node *rn;
3427 struct bgp_info *ri;
3428 struct bgp_info *new;
3429 struct bgp_info info;
3430 struct attr *attr_new;
3432 struct attr new_attr;
3433 struct attr_extra new_extra;
3436 char buf[SU_ADDRSTRLEN];
3438 bgp = rsclient->bgp;
3440 assert (bgp_static);
3444 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
3446 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
3448 attr.nexthop = bgp_static->igpnexthop;
3449 attr.med = bgp_static->igpmetric;
3450 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
3452 if (bgp_static->atomic)
3453 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
3455 /* Apply network route-map for export to this rsclient. */
3456 if (bgp_static->rmap.name)
3458 struct attr attr_tmp = attr;
3459 info.peer = rsclient;
3460 info.attr = &attr_tmp;
3462 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT);
3463 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK);
3465 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
3467 rsclient->rmap_type = 0;
3469 if (ret == RMAP_DENYMATCH)
3471 /* Free uninterned attribute. */
3472 bgp_attr_flush (&attr_tmp);
3474 /* Unintern original. */
3475 aspath_unintern (&attr.aspath);
3476 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
3477 bgp_attr_extra_free (&attr);
3481 attr_new = bgp_attr_intern (&attr_tmp);
3484 attr_new = bgp_attr_intern (&attr);
3486 new_attr.extra = &new_extra;
3487 bgp_attr_dup(&new_attr, attr_new);
3489 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3491 if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi)
3494 /* This BGP update is filtered. Log the reason then update BGP entry. */
3495 if (BGP_DEBUG (update, UPDATE_IN))
3496 zlog (rsclient->log, LOG_DEBUG,
3497 "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
3498 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
3499 p->prefixlen, rsclient->host);
3501 bgp->peer_self->rmap_type = 0;
3503 bgp_attr_unintern (&attr_new);
3504 aspath_unintern (&attr.aspath);
3505 bgp_attr_extra_free (&attr);
3507 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
3512 bgp->peer_self->rmap_type = 0;
3514 bgp_attr_unintern (&attr_new);
3515 attr_new = bgp_attr_intern (&new_attr);
3517 for (ri = rn->info; ri; ri = ri->next)
3518 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3519 && ri->sub_type == BGP_ROUTE_STATIC)
3524 if (attrhash_cmp (ri->attr, attr_new) &&
3525 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3527 bgp_unlock_node (rn);
3528 bgp_attr_unintern (&attr_new);
3529 aspath_unintern (&attr.aspath);
3530 bgp_attr_extra_free (&attr);
3535 /* The attribute is changed. */
3536 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
3538 /* Rewrite BGP route information. */
3539 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3540 bgp_info_restore(rn, ri);
3541 bgp_attr_unintern (&ri->attr);
3542 ri->attr = attr_new;
3543 ri->uptime = bgp_clock ();
3545 /* Nexthop reachability check. */
3546 if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
3548 if (bgp_ensure_nexthop (ri, NULL, 0))
3549 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
3552 if (BGP_DEBUG(nht, NHT))
3554 char buf1[INET6_ADDRSTRLEN];
3555 inet_ntop(AF_INET, (const void *)&attr_new->nexthop,
3556 buf1, INET6_ADDRSTRLEN);
3557 zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
3559 bgp_info_unset_flag (rn, ri, BGP_INFO_VALID);
3562 /* Process change. */
3563 bgp_process (bgp, rn, afi, safi);
3564 bgp_unlock_node (rn);
3565 aspath_unintern (&attr.aspath);
3566 bgp_attr_extra_free (&attr);
3571 /* Make new BGP info. */
3572 new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self,
3574 /* Nexthop reachability check. */
3575 if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
3577 if (bgp_ensure_nexthop (new, NULL, 0))
3578 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
3581 if (BGP_DEBUG(nht, NHT))
3583 char buf1[INET6_ADDRSTRLEN];
3584 inet_ntop(AF_INET, (const void *)&attr_new->nexthop,
3585 buf1, INET6_ADDRSTRLEN);
3586 zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
3588 bgp_info_unset_flag (rn, new, BGP_INFO_VALID);
3592 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
3594 /* Register new BGP information. */
3595 bgp_info_add (rn, new);
3597 /* route_node_get lock */
3598 bgp_unlock_node (rn);
3600 /* Process change. */
3601 bgp_process (bgp, rn, afi, safi);
3603 /* Unintern original. */
3604 aspath_unintern (&attr.aspath);
3605 bgp_attr_extra_free (&attr);
3609 bgp_static_update_main (struct bgp *bgp, struct prefix *p,
3610 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3612 struct bgp_node *rn;
3613 struct bgp_info *ri;
3614 struct bgp_info *new;
3615 struct bgp_info info;
3617 struct attr *attr_new;
3620 assert (bgp_static);
3624 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL);
3626 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
3628 attr.nexthop = bgp_static->igpnexthop;
3629 attr.med = bgp_static->igpmetric;
3630 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
3632 if (bgp_static->atomic)
3633 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
3635 /* Apply route-map. */
3636 if (bgp_static->rmap.name)
3638 struct attr attr_tmp = attr;
3639 info.peer = bgp->peer_self;
3640 info.attr = &attr_tmp;
3642 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3644 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
3646 bgp->peer_self->rmap_type = 0;
3648 if (ret == RMAP_DENYMATCH)
3650 /* Free uninterned attribute. */
3651 bgp_attr_flush (&attr_tmp);
3653 /* Unintern original. */
3654 aspath_unintern (&attr.aspath);
3655 bgp_attr_extra_free (&attr);
3656 bgp_static_withdraw (bgp, p, afi, safi);
3659 attr_new = bgp_attr_intern (&attr_tmp);
3662 attr_new = bgp_attr_intern (&attr);
3664 for (ri = rn->info; ri; ri = ri->next)
3665 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3666 && ri->sub_type == BGP_ROUTE_STATIC)
3671 if (attrhash_cmp (ri->attr, attr_new) &&
3672 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3674 bgp_unlock_node (rn);
3675 bgp_attr_unintern (&attr_new);
3676 aspath_unintern (&attr.aspath);
3677 bgp_attr_extra_free (&attr);
3682 /* The attribute is changed. */
3683 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
3685 /* Rewrite BGP route information. */
3686 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3687 bgp_info_restore(rn, ri);
3689 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
3690 bgp_attr_unintern (&ri->attr);
3691 ri->attr = attr_new;
3692 ri->uptime = bgp_clock ();
3694 /* Nexthop reachability check. */
3695 if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
3697 if (bgp_ensure_nexthop (ri, NULL, 0))
3698 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
3701 if (BGP_DEBUG(nht, NHT))
3703 char buf1[INET6_ADDRSTRLEN];
3704 inet_ntop(AF_INET, (const void *)&attr_new->nexthop,
3705 buf1, INET6_ADDRSTRLEN);
3706 zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
3708 bgp_info_unset_flag (rn, ri, BGP_INFO_VALID);
3711 /* Process change. */
3712 bgp_aggregate_increment (bgp, p, ri, afi, safi);
3713 bgp_process (bgp, rn, afi, safi);
3714 bgp_unlock_node (rn);
3715 aspath_unintern (&attr.aspath);
3716 bgp_attr_extra_free (&attr);
3721 /* Make new BGP info. */
3722 new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self, attr_new,
3724 /* Nexthop reachability check. */
3725 if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
3727 if (bgp_ensure_nexthop (new, NULL, 0))
3728 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
3731 if (BGP_DEBUG(nht, NHT))
3733 char buf1[INET6_ADDRSTRLEN];
3734 inet_ntop(AF_INET, (const void *)&attr_new->nexthop, buf1,
3736 zlog_debug("%s(%s): NH unresolved", __FUNCTION__, buf1);
3738 bgp_info_unset_flag (rn, new, BGP_INFO_VALID);
3742 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
3744 /* Aggregate address increment. */
3745 bgp_aggregate_increment (bgp, p, new, afi, safi);
3747 /* Register new BGP information. */
3748 bgp_info_add (rn, new);
3750 /* route_node_get lock */
3751 bgp_unlock_node (rn);
3753 /* Process change. */
3754 bgp_process (bgp, rn, afi, safi);
3756 /* Unintern original. */
3757 aspath_unintern (&attr.aspath);
3758 bgp_attr_extra_free (&attr);
3762 bgp_static_update (struct bgp *bgp, struct prefix *p,
3763 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3765 struct peer *rsclient;
3766 struct listnode *node, *nnode;
3768 bgp_static_update_main (bgp, p, bgp_static, afi, safi);
3770 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
3772 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
3773 bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi);
3778 bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi,
3781 struct bgp_node *rn;
3782 struct bgp_info *ri;
3784 /* Make new BGP info. */
3785 rn = bgp_node_get (bgp->rib[afi][safi], p);
3787 /* Check selected route and self inserted route. */
3788 for (ri = rn->info; ri; ri = ri->next)
3789 if (ri->peer == bgp->peer_self
3790 && ri->type == ZEBRA_ROUTE_BGP
3791 && ri->sub_type == BGP_ROUTE_STATIC)
3794 /* Withdraw static BGP route from routing table. */
3797 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
3798 bgp_unlink_nexthop(ri);
3799 bgp_info_delete (rn, ri);
3800 bgp_process (bgp, rn, afi, safi);
3803 /* Unlock bgp_node_lookup. */
3804 bgp_unlock_node (rn);
3808 bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
3810 struct bgp_static *bgp_static;
3812 struct bgp_node *rn;
3815 bgp = rsclient->bgp;
3817 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
3818 if ((bgp_static = rn->info) != NULL)
3822 bgp_static_update_rsclient (rsclient, p, bgp_static,
3828 * Used for SAFI_MPLS_VPN and SAFI_ENCAP
3831 bgp_static_withdraw_safi (struct bgp *bgp, struct prefix *p, afi_t afi,
3832 safi_t safi, struct prefix_rd *prd, u_char *tag)
3834 struct bgp_node *rn;
3835 struct bgp_info *ri;
3837 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
3839 /* Check selected route and self inserted route. */
3840 for (ri = rn->info; ri; ri = ri->next)
3841 if (ri->peer == bgp->peer_self
3842 && ri->type == ZEBRA_ROUTE_BGP
3843 && ri->sub_type == BGP_ROUTE_STATIC)
3846 /* Withdraw static BGP route from routing table. */
3849 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
3850 bgp_info_delete (rn, ri);
3851 bgp_process (bgp, rn, afi, safi);
3854 /* Unlock bgp_node_lookup. */
3855 bgp_unlock_node (rn);
3859 bgp_static_update_safi (struct bgp *bgp, struct prefix *p,
3860 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3862 struct bgp_node *rn;
3863 struct bgp_info *new;
3864 struct attr *attr_new;
3865 struct attr attr = { 0 };
3866 struct bgp_info *ri;
3868 assert (bgp_static);
3870 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, &bgp_static->prd);
3872 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
3874 attr.nexthop = bgp_static->igpnexthop;
3875 attr.med = bgp_static->igpmetric;
3876 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
3878 /* Apply route-map. */
3879 if (bgp_static->rmap.name)
3881 struct attr attr_tmp = attr;
3882 struct bgp_info info;
3885 info.peer = bgp->peer_self;
3886 info.attr = &attr_tmp;
3888 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3890 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
3892 bgp->peer_self->rmap_type = 0;
3894 if (ret == RMAP_DENYMATCH)
3896 /* Free uninterned attribute. */
3897 bgp_attr_flush (&attr_tmp);
3899 /* Unintern original. */
3900 aspath_unintern (&attr.aspath);
3901 bgp_attr_extra_free (&attr);
3902 bgp_static_withdraw_safi (bgp, p, afi, safi, &bgp_static->prd,
3907 attr_new = bgp_attr_intern (&attr_tmp);
3911 attr_new = bgp_attr_intern (&attr);
3914 for (ri = rn->info; ri; ri = ri->next)
3915 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3916 && ri->sub_type == BGP_ROUTE_STATIC)
3921 if (attrhash_cmp (ri->attr, attr_new) &&
3922 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3924 bgp_unlock_node (rn);
3925 bgp_attr_unintern (&attr_new);
3926 aspath_unintern (&attr.aspath);
3927 bgp_attr_extra_free (&attr);
3932 /* The attribute is changed. */
3933 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
3935 /* Rewrite BGP route information. */
3936 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3937 bgp_info_restore(rn, ri);
3939 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
3940 bgp_attr_unintern (&ri->attr);
3941 ri->attr = attr_new;
3942 ri->uptime = bgp_clock ();
3944 /* Process change. */
3945 bgp_aggregate_increment (bgp, p, ri, afi, safi);
3946 bgp_process (bgp, rn, afi, safi);
3947 bgp_unlock_node (rn);
3948 aspath_unintern (&attr.aspath);
3949 bgp_attr_extra_free (&attr);
3955 /* Make new BGP info. */
3956 new = info_make (ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, bgp->peer_self,
3958 SET_FLAG (new->flags, BGP_INFO_VALID);
3959 new->extra = bgp_info_extra_new();
3960 memcpy (new->extra->tag, bgp_static->tag, 3);
3962 /* Aggregate address increment. */
3963 bgp_aggregate_increment (bgp, p, new, afi, safi);
3965 /* Register new BGP information. */
3966 bgp_info_add (rn, new);
3968 /* route_node_get lock */
3969 bgp_unlock_node (rn);
3971 /* Process change. */
3972 bgp_process (bgp, rn, afi, safi);
3974 /* Unintern original. */
3975 aspath_unintern (&attr.aspath);
3976 bgp_attr_extra_free (&attr);
3979 /* Configure static BGP network. When user don't run zebra, static
3980 route should be installed as valid. */
3982 bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str,
3983 afi_t afi, safi_t safi, const char *rmap, int backdoor)
3987 struct bgp_static *bgp_static;
3988 struct bgp_node *rn;
3989 u_char need_update = 0;
3991 /* Convert IP prefix string to struct prefix. */
3992 ret = str2prefix (ip_str, &p);
3995 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
3998 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
4000 vty_out (vty, "%% Malformed prefix (link-local address)%s",
4007 /* Set BGP static route configuration. */
4008 rn = bgp_node_get (bgp->route[afi][safi], &p);
4012 /* Configuration change. */
4013 bgp_static = rn->info;
4015 /* Check previous routes are installed into BGP. */
4016 if (bgp_static->valid && bgp_static->backdoor != backdoor)
4019 bgp_static->backdoor = backdoor;
4023 if (bgp_static->rmap.name)
4024 free (bgp_static->rmap.name);
4025 bgp_static->rmap.name = strdup (rmap);
4026 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
4030 if (bgp_static->rmap.name)
4031 free (bgp_static->rmap.name);
4032 bgp_static->rmap.name = NULL;
4033 bgp_static->rmap.map = NULL;
4034 bgp_static->valid = 0;
4036 bgp_unlock_node (rn);
4040 /* New configuration. */
4041 bgp_static = bgp_static_new ();
4042 bgp_static->backdoor = backdoor;
4043 bgp_static->valid = 0;
4044 bgp_static->igpmetric = 0;
4045 bgp_static->igpnexthop.s_addr = 0;
4049 if (bgp_static->rmap.name)
4050 free (bgp_static->rmap.name);
4051 bgp_static->rmap.name = strdup (rmap);
4052 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
4054 rn->info = bgp_static;
4057 bgp_static->valid = 1;
4059 bgp_static_withdraw (bgp, &p, afi, safi);
4061 if (! bgp_static->backdoor)
4062 bgp_static_update (bgp, &p, bgp_static, afi, safi);
4067 /* Configure static BGP network. */
4069 bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str,
4070 afi_t afi, safi_t safi)
4074 struct bgp_static *bgp_static;
4075 struct bgp_node *rn;
4077 /* Convert IP prefix string to struct prefix. */
4078 ret = str2prefix (ip_str, &p);
4081 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4084 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
4086 vty_out (vty, "%% Malformed prefix (link-local address)%s",
4093 rn = bgp_node_lookup (bgp->route[afi][safi], &p);
4096 vty_out (vty, "%% Can't find specified static route configuration.%s",
4101 bgp_static = rn->info;
4103 /* Update BGP RIB. */
4104 if (! bgp_static->backdoor)
4105 bgp_static_withdraw (bgp, &p, afi, safi);
4107 /* Clear configuration. */
4108 bgp_static_free (bgp_static);
4110 bgp_unlock_node (rn);
4111 bgp_unlock_node (rn);
4116 /* Called from bgp_delete(). Delete all static routes from the BGP
4119 bgp_static_delete (struct bgp *bgp)
4123 struct bgp_node *rn;
4124 struct bgp_node *rm;
4125 struct bgp_table *table;
4126 struct bgp_static *bgp_static;
4128 for (afi = AFI_IP; afi < AFI_MAX; afi++)
4129 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
4130 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
4131 if (rn->info != NULL)
4133 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
4137 for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
4139 bgp_static = rn->info;
4140 bgp_static_withdraw_safi (bgp, &rm->p,
4142 (struct prefix_rd *)&rn->p,
4144 bgp_static_free (bgp_static);
4146 bgp_unlock_node (rn);
4151 bgp_static = rn->info;
4152 bgp_static_withdraw (bgp, &rn->p, afi, safi);
4153 bgp_static_free (bgp_static);
4155 bgp_unlock_node (rn);
4162 * Currently this is used to set static routes for VPN and ENCAP.
4163 * I think it can probably be factored with bgp_static_set.
4166 bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str,
4167 const char *rd_str, const char *tag_str,
4168 const char *rmap_str)
4172 struct prefix_rd prd;
4174 struct bgp_node *prn;
4175 struct bgp_node *rn;
4176 struct bgp_table *table;
4177 struct bgp_static *bgp_static;
4182 ret = str2prefix (ip_str, &p);
4185 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4190 ret = str2prefix_rd (rd_str, &prd);
4193 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
4197 ret = str2tag (tag_str, tag);
4200 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
4204 prn = bgp_node_get (bgp->route[AFI_IP][safi],
4205 (struct prefix *)&prd);
4206 if (prn->info == NULL)
4207 prn->info = bgp_table_init (AFI_IP, safi);
4209 bgp_unlock_node (prn);
4212 rn = bgp_node_get (table, &p);
4216 vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE);
4217 bgp_unlock_node (rn);
4221 /* New configuration. */
4222 bgp_static = bgp_static_new ();
4223 bgp_static->backdoor = 0;
4224 bgp_static->valid = 0;
4225 bgp_static->igpmetric = 0;
4226 bgp_static->igpnexthop.s_addr = 0;
4227 memcpy(bgp_static->tag, tag, 3);
4228 bgp_static->prd = prd;
4232 if (bgp_static->rmap.name)
4233 free (bgp_static->rmap.name);
4234 bgp_static->rmap.name = strdup (rmap_str);
4235 bgp_static->rmap.map = route_map_lookup_by_name (rmap_str);
4237 rn->info = bgp_static;
4239 bgp_static->valid = 1;
4240 bgp_static_update_safi (bgp, &p, bgp_static, AFI_IP, safi);
4246 /* Configure static BGP network. */
4248 bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str,
4249 const char *rd_str, const char *tag_str)
4254 struct prefix_rd prd;
4255 struct bgp_node *prn;
4256 struct bgp_node *rn;
4257 struct bgp_table *table;
4258 struct bgp_static *bgp_static;
4263 /* Convert IP prefix string to struct prefix. */
4264 ret = str2prefix (ip_str, &p);
4267 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4272 ret = str2prefix_rd (rd_str, &prd);
4275 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
4279 ret = str2tag (tag_str, tag);
4282 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
4286 prn = bgp_node_get (bgp->route[AFI_IP][safi],
4287 (struct prefix *)&prd);
4288 if (prn->info == NULL)
4289 prn->info = bgp_table_init (AFI_IP, safi);
4291 bgp_unlock_node (prn);
4294 rn = bgp_node_lookup (table, &p);
4298 bgp_static_withdraw_safi (bgp, &p, AFI_IP, safi, &prd, tag);
4300 bgp_static = rn->info;
4301 bgp_static_free (bgp_static);
4303 bgp_unlock_node (rn);
4304 bgp_unlock_node (rn);
4307 vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE);
4314 "network A.B.C.D/M",
4315 "Specify a network to announce via BGP\n"
4316 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4318 return bgp_static_set (vty, vty->index, argv[0],
4319 AFI_IP, bgp_node_safi (vty), NULL, 0);
4322 DEFUN (bgp_network_route_map,
4323 bgp_network_route_map_cmd,
4324 "network A.B.C.D/M route-map WORD",
4325 "Specify a network to announce via BGP\n"
4326 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4327 "Route-map to modify the attributes\n"
4328 "Name of the route map\n")
4330 return bgp_static_set (vty, vty->index, argv[0],
4331 AFI_IP, bgp_node_safi (vty), argv[1], 0);
4334 DEFUN (bgp_network_backdoor,
4335 bgp_network_backdoor_cmd,
4336 "network A.B.C.D/M backdoor",
4337 "Specify a network to announce via BGP\n"
4338 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4339 "Specify a BGP backdoor route\n")
4341 return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST,
4345 DEFUN (bgp_network_mask,
4346 bgp_network_mask_cmd,
4347 "network A.B.C.D mask A.B.C.D",
4348 "Specify a network to announce via BGP\n"
4354 char prefix_str[BUFSIZ];
4356 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4359 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4363 return bgp_static_set (vty, vty->index, prefix_str,
4364 AFI_IP, bgp_node_safi (vty), NULL, 0);
4367 DEFUN (bgp_network_mask_route_map,
4368 bgp_network_mask_route_map_cmd,
4369 "network A.B.C.D mask A.B.C.D route-map WORD",
4370 "Specify a network to announce via BGP\n"
4374 "Route-map to modify the attributes\n"
4375 "Name of the route map\n")
4378 char prefix_str[BUFSIZ];
4380 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4383 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4387 return bgp_static_set (vty, vty->index, prefix_str,
4388 AFI_IP, bgp_node_safi (vty), argv[2], 0);
4391 DEFUN (bgp_network_mask_backdoor,
4392 bgp_network_mask_backdoor_cmd,
4393 "network A.B.C.D mask A.B.C.D backdoor",
4394 "Specify a network to announce via BGP\n"
4398 "Specify a BGP backdoor route\n")
4401 char prefix_str[BUFSIZ];
4403 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4406 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4410 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
4414 DEFUN (bgp_network_mask_natural,
4415 bgp_network_mask_natural_cmd,
4417 "Specify a network to announce via BGP\n"
4421 char prefix_str[BUFSIZ];
4423 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4426 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4430 return bgp_static_set (vty, vty->index, prefix_str,
4431 AFI_IP, bgp_node_safi (vty), NULL, 0);
4434 DEFUN (bgp_network_mask_natural_route_map,
4435 bgp_network_mask_natural_route_map_cmd,
4436 "network A.B.C.D route-map WORD",
4437 "Specify a network to announce via BGP\n"
4439 "Route-map to modify the attributes\n"
4440 "Name of the route map\n")
4443 char prefix_str[BUFSIZ];
4445 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4448 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4452 return bgp_static_set (vty, vty->index, prefix_str,
4453 AFI_IP, bgp_node_safi (vty), argv[1], 0);
4456 DEFUN (bgp_network_mask_natural_backdoor,
4457 bgp_network_mask_natural_backdoor_cmd,
4458 "network A.B.C.D backdoor",
4459 "Specify a network to announce via BGP\n"
4461 "Specify a BGP backdoor route\n")
4464 char prefix_str[BUFSIZ];
4466 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4469 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4473 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
4477 DEFUN (no_bgp_network,
4479 "no network A.B.C.D/M",
4481 "Specify a network to announce via BGP\n"
4482 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4484 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP,
4485 bgp_node_safi (vty));
4488 ALIAS (no_bgp_network,
4489 no_bgp_network_route_map_cmd,
4490 "no network A.B.C.D/M route-map WORD",
4492 "Specify a network to announce via BGP\n"
4493 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4494 "Route-map to modify the attributes\n"
4495 "Name of the route map\n")
4497 ALIAS (no_bgp_network,
4498 no_bgp_network_backdoor_cmd,
4499 "no network A.B.C.D/M backdoor",
4501 "Specify a network to announce via BGP\n"
4502 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4503 "Specify a BGP backdoor route\n")
4505 DEFUN (no_bgp_network_mask,
4506 no_bgp_network_mask_cmd,
4507 "no network A.B.C.D mask A.B.C.D",
4509 "Specify a network to announce via BGP\n"
4515 char prefix_str[BUFSIZ];
4517 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4520 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4524 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
4525 bgp_node_safi (vty));
4528 ALIAS (no_bgp_network_mask,
4529 no_bgp_network_mask_route_map_cmd,
4530 "no network A.B.C.D mask A.B.C.D route-map WORD",
4532 "Specify a network to announce via BGP\n"
4536 "Route-map to modify the attributes\n"
4537 "Name of the route map\n")
4539 ALIAS (no_bgp_network_mask,
4540 no_bgp_network_mask_backdoor_cmd,
4541 "no network A.B.C.D mask A.B.C.D backdoor",
4543 "Specify a network to announce via BGP\n"
4547 "Specify a BGP backdoor route\n")
4549 DEFUN (no_bgp_network_mask_natural,
4550 no_bgp_network_mask_natural_cmd,
4551 "no network A.B.C.D",
4553 "Specify a network to announce via BGP\n"
4557 char prefix_str[BUFSIZ];
4559 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4562 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4566 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
4567 bgp_node_safi (vty));
4570 ALIAS (no_bgp_network_mask_natural,
4571 no_bgp_network_mask_natural_route_map_cmd,
4572 "no network A.B.C.D route-map WORD",
4574 "Specify a network to announce via BGP\n"
4576 "Route-map to modify the attributes\n"
4577 "Name of the route map\n")
4579 ALIAS (no_bgp_network_mask_natural,
4580 no_bgp_network_mask_natural_backdoor_cmd,
4581 "no network A.B.C.D backdoor",
4583 "Specify a network to announce via BGP\n"
4585 "Specify a BGP backdoor route\n")
4587 DEFUN (ipv6_bgp_network,
4588 ipv6_bgp_network_cmd,
4589 "network X:X::X:X/M",
4590 "Specify a network to announce via BGP\n"
4591 "IPv6 prefix <network>/<length>\n")
4593 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty),
4597 DEFUN (ipv6_bgp_network_route_map,
4598 ipv6_bgp_network_route_map_cmd,
4599 "network X:X::X:X/M route-map WORD",
4600 "Specify a network to announce via BGP\n"
4601 "IPv6 prefix <network>/<length>\n"
4602 "Route-map to modify the attributes\n"
4603 "Name of the route map\n")
4605 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6,
4606 bgp_node_safi (vty), argv[1], 0);
4609 DEFUN (no_ipv6_bgp_network,
4610 no_ipv6_bgp_network_cmd,
4611 "no network X:X::X:X/M",
4613 "Specify a network to announce via BGP\n"
4614 "IPv6 prefix <network>/<length>\n")
4616 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty));
4619 ALIAS (no_ipv6_bgp_network,
4620 no_ipv6_bgp_network_route_map_cmd,
4621 "no network X:X::X:X/M route-map WORD",
4623 "Specify a network to announce via BGP\n"
4624 "IPv6 prefix <network>/<length>\n"
4625 "Route-map to modify the attributes\n"
4626 "Name of the route map\n")
4628 ALIAS (ipv6_bgp_network,
4629 old_ipv6_bgp_network_cmd,
4630 "ipv6 bgp network X:X::X:X/M",
4633 "Specify a network to announce via BGP\n"
4634 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4636 ALIAS (no_ipv6_bgp_network,
4637 old_no_ipv6_bgp_network_cmd,
4638 "no ipv6 bgp network X:X::X:X/M",
4642 "Specify a network to announce via BGP\n"
4643 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4645 /* stubs for removed AS-Pathlimit commands, kept for config compatibility */
4646 ALIAS_DEPRECATED (bgp_network,
4647 bgp_network_ttl_cmd,
4648 "network A.B.C.D/M pathlimit <0-255>",
4649 "Specify a network to announce via BGP\n"
4650 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4651 "AS-Path hopcount limit attribute\n"
4652 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4653 ALIAS_DEPRECATED (bgp_network_backdoor,
4654 bgp_network_backdoor_ttl_cmd,
4655 "network A.B.C.D/M backdoor pathlimit <0-255>",
4656 "Specify a network to announce via BGP\n"
4657 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4658 "Specify a BGP backdoor route\n"
4659 "AS-Path hopcount limit attribute\n"
4660 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4661 ALIAS_DEPRECATED (bgp_network_mask,
4662 bgp_network_mask_ttl_cmd,
4663 "network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4664 "Specify a network to announce via BGP\n"
4668 "AS-Path hopcount limit attribute\n"
4669 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4670 ALIAS_DEPRECATED (bgp_network_mask_backdoor,
4671 bgp_network_mask_backdoor_ttl_cmd,
4672 "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4673 "Specify a network to announce via BGP\n"
4677 "Specify a BGP backdoor route\n"
4678 "AS-Path hopcount limit attribute\n"
4679 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4680 ALIAS_DEPRECATED (bgp_network_mask_natural,
4681 bgp_network_mask_natural_ttl_cmd,
4682 "network A.B.C.D pathlimit <0-255>",
4683 "Specify a network to announce via BGP\n"
4685 "AS-Path hopcount limit attribute\n"
4686 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4687 ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor,
4688 bgp_network_mask_natural_backdoor_ttl_cmd,
4689 "network A.B.C.D backdoor pathlimit <1-255>",
4690 "Specify a network to announce via BGP\n"
4692 "Specify a BGP backdoor route\n"
4693 "AS-Path hopcount limit attribute\n"
4694 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4695 ALIAS_DEPRECATED (no_bgp_network,
4696 no_bgp_network_ttl_cmd,
4697 "no network A.B.C.D/M pathlimit <0-255>",
4699 "Specify a network to announce via BGP\n"
4700 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4701 "AS-Path hopcount limit attribute\n"
4702 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4703 ALIAS_DEPRECATED (no_bgp_network,
4704 no_bgp_network_backdoor_ttl_cmd,
4705 "no network A.B.C.D/M backdoor pathlimit <0-255>",
4707 "Specify a network to announce via BGP\n"
4708 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4709 "Specify a BGP backdoor route\n"
4710 "AS-Path hopcount limit attribute\n"
4711 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4712 ALIAS_DEPRECATED (no_bgp_network,
4713 no_bgp_network_mask_ttl_cmd,
4714 "no network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4716 "Specify a network to announce via BGP\n"
4720 "AS-Path hopcount limit attribute\n"
4721 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4722 ALIAS_DEPRECATED (no_bgp_network_mask,
4723 no_bgp_network_mask_backdoor_ttl_cmd,
4724 "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4726 "Specify a network to announce via BGP\n"
4730 "Specify a BGP backdoor route\n"
4731 "AS-Path hopcount limit attribute\n"
4732 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4733 ALIAS_DEPRECATED (no_bgp_network_mask_natural,
4734 no_bgp_network_mask_natural_ttl_cmd,
4735 "no network A.B.C.D pathlimit <0-255>",
4737 "Specify a network to announce via BGP\n"
4739 "AS-Path hopcount limit attribute\n"
4740 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4741 ALIAS_DEPRECATED (no_bgp_network_mask_natural,
4742 no_bgp_network_mask_natural_backdoor_ttl_cmd,
4743 "no network A.B.C.D backdoor pathlimit <0-255>",
4745 "Specify a network to announce via BGP\n"
4747 "Specify a BGP backdoor route\n"
4748 "AS-Path hopcount limit attribute\n"
4749 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4750 ALIAS_DEPRECATED (ipv6_bgp_network,
4751 ipv6_bgp_network_ttl_cmd,
4752 "network X:X::X:X/M pathlimit <0-255>",
4753 "Specify a network to announce via BGP\n"
4754 "IPv6 prefix <network>/<length>\n"
4755 "AS-Path hopcount limit attribute\n"
4756 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4757 ALIAS_DEPRECATED (no_ipv6_bgp_network,
4758 no_ipv6_bgp_network_ttl_cmd,
4759 "no network X:X::X:X/M pathlimit <0-255>",
4761 "Specify a network to announce via BGP\n"
4762 "IPv6 prefix <network>/<length>\n"
4763 "AS-Path hopcount limit attribute\n"
4764 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4766 /* Aggreagete address:
4768 advertise-map Set condition to advertise attribute
4769 as-set Generate AS set path information
4770 attribute-map Set attributes of aggregate
4771 route-map Set parameters of aggregate
4772 summary-only Filter more specific routes from updates
4773 suppress-map Conditionally filter more specific routes from updates
4776 struct bgp_aggregate
4778 /* Summary-only flag. */
4779 u_char summary_only;
4781 /* AS set generation. */
4784 /* Route-map for aggregated route. */
4785 struct route_map *map;
4787 /* Suppress-count. */
4788 unsigned long count;
4790 /* SAFI configuration. */
4794 static struct bgp_aggregate *
4795 bgp_aggregate_new (void)
4797 return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate));
4801 bgp_aggregate_free (struct bgp_aggregate *aggregate)
4803 XFREE (MTYPE_BGP_AGGREGATE, aggregate);
4806 /* Update an aggregate as routes are added/removed from the BGP table */
4808 bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew,
4809 afi_t afi, safi_t safi, struct bgp_info *del,
4810 struct bgp_aggregate *aggregate)
4812 struct bgp_table *table;
4813 struct bgp_node *top;
4814 struct bgp_node *rn;
4816 struct aspath *aspath = NULL;
4817 struct aspath *asmerge = NULL;
4818 struct community *community = NULL;
4819 struct community *commerge = NULL;
4820 struct bgp_info *ri;
4821 struct bgp_info *new;
4823 unsigned long match = 0;
4824 u_char atomic_aggregate = 0;
4826 /* ORIGIN attribute: If at least one route among routes that are
4827 aggregated has ORIGIN with the value INCOMPLETE, then the
4828 aggregated route must have the ORIGIN attribute with the value
4829 INCOMPLETE. Otherwise, if at least one route among routes that
4830 are aggregated has ORIGIN with the value EGP, then the aggregated
4831 route must have the origin attribute with the value EGP. In all
4832 other case the value of the ORIGIN attribute of the aggregated
4833 route is INTERNAL. */
4834 origin = BGP_ORIGIN_IGP;
4836 table = bgp->rib[afi][safi];
4838 top = bgp_node_get (table, p);
4839 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
4840 if (rn->p.prefixlen > p->prefixlen)
4844 for (ri = rn->info; ri; ri = ri->next)
4846 if (BGP_INFO_HOLDDOWN (ri))
4849 if (del && ri == del)
4852 if (! rinew && first)
4855 #ifdef AGGREGATE_NEXTHOP_CHECK
4856 if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop)
4857 || ri->attr->med != med)
4860 aspath_free (aspath);
4862 community_free (community);
4863 bgp_unlock_node (rn);
4864 bgp_unlock_node (top);
4867 #endif /* AGGREGATE_NEXTHOP_CHECK */
4869 if (ri->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
4870 atomic_aggregate = 1;
4872 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
4874 if (aggregate->summary_only)
4876 (bgp_info_extra_get (ri))->suppress++;
4877 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
4883 if (origin < ri->attr->origin)
4884 origin = ri->attr->origin;
4886 if (aggregate->as_set)
4890 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
4891 aspath_free (aspath);
4895 aspath = aspath_dup (ri->attr->aspath);
4897 if (ri->attr->community)
4901 commerge = community_merge (community,
4902 ri->attr->community);
4903 community = community_uniq_sort (commerge);
4904 community_free (commerge);
4907 community = community_dup (ri->attr->community);
4913 bgp_process (bgp, rn, afi, safi);
4915 bgp_unlock_node (top);
4921 if (aggregate->summary_only)
4922 (bgp_info_extra_get (rinew))->suppress++;
4924 if (origin < rinew->attr->origin)
4925 origin = rinew->attr->origin;
4927 if (aggregate->as_set)
4931 asmerge = aspath_aggregate (aspath, rinew->attr->aspath);
4932 aspath_free (aspath);
4936 aspath = aspath_dup (rinew->attr->aspath);
4938 if (rinew->attr->community)
4942 commerge = community_merge (community,
4943 rinew->attr->community);
4944 community = community_uniq_sort (commerge);
4945 community_free (commerge);
4948 community = community_dup (rinew->attr->community);
4953 if (aggregate->count > 0)
4955 rn = bgp_node_get (table, p);
4956 new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, bgp->peer_self,
4957 bgp_attr_aggregate_intern(bgp, origin, aspath, community,
4959 atomic_aggregate), rn);
4960 SET_FLAG (new->flags, BGP_INFO_VALID);
4962 bgp_info_add (rn, new);
4963 bgp_unlock_node (rn);
4964 bgp_process (bgp, rn, afi, safi);
4969 aspath_free (aspath);
4971 community_free (community);
4975 void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t,
4976 struct bgp_aggregate *);
4979 bgp_aggregate_increment (struct bgp *bgp, struct prefix *p,
4980 struct bgp_info *ri, afi_t afi, safi_t safi)
4982 struct bgp_node *child;
4983 struct bgp_node *rn;
4984 struct bgp_aggregate *aggregate;
4985 struct bgp_table *table;
4987 /* MPLS-VPN aggregation is not yet supported. */
4988 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
4991 table = bgp->aggregate[afi][safi];
4993 /* No aggregates configured. */
4994 if (bgp_table_top_nolock (table) == NULL)
4997 if (p->prefixlen == 0)
5000 if (BGP_INFO_HOLDDOWN (ri))
5003 child = bgp_node_get (table, p);
5005 /* Aggregate address configuration check. */
5006 for (rn = child; rn; rn = bgp_node_parent_nolock (rn))
5007 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
5009 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
5010 bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate);
5012 bgp_unlock_node (child);
5016 bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p,
5017 struct bgp_info *del, afi_t afi, safi_t safi)
5019 struct bgp_node *child;
5020 struct bgp_node *rn;
5021 struct bgp_aggregate *aggregate;
5022 struct bgp_table *table;
5024 /* MPLS-VPN aggregation is not yet supported. */
5025 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
5028 table = bgp->aggregate[afi][safi];
5030 /* No aggregates configured. */
5031 if (bgp_table_top_nolock (table) == NULL)
5034 if (p->prefixlen == 0)
5037 child = bgp_node_get (table, p);
5039 /* Aggregate address configuration check. */
5040 for (rn = child; rn; rn = bgp_node_parent_nolock (rn))
5041 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
5043 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
5044 bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate);
5046 bgp_unlock_node (child);
5049 /* Called via bgp_aggregate_set when the user configures aggregate-address */
5051 bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi,
5052 struct bgp_aggregate *aggregate)
5054 struct bgp_table *table;
5055 struct bgp_node *top;
5056 struct bgp_node *rn;
5057 struct bgp_info *new;
5058 struct bgp_info *ri;
5059 unsigned long match;
5060 u_char origin = BGP_ORIGIN_IGP;
5061 struct aspath *aspath = NULL;
5062 struct aspath *asmerge = NULL;
5063 struct community *community = NULL;
5064 struct community *commerge = NULL;
5065 u_char atomic_aggregate = 0;
5067 table = bgp->rib[afi][safi];
5070 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
5072 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
5075 /* If routes exists below this node, generate aggregate routes. */
5076 top = bgp_node_get (table, p);
5077 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
5078 if (rn->p.prefixlen > p->prefixlen)
5082 for (ri = rn->info; ri; ri = ri->next)
5084 if (BGP_INFO_HOLDDOWN (ri))
5087 if (ri->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
5088 atomic_aggregate = 1;
5090 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
5092 /* summary-only aggregate route suppress aggregated
5093 route announcement. */
5094 if (aggregate->summary_only)
5096 (bgp_info_extra_get (ri))->suppress++;
5097 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
5101 /* If at least one route among routes that are aggregated has
5102 * ORIGIN with the value INCOMPLETE, then the aggregated route
5103 * MUST have the ORIGIN attribute with the value INCOMPLETE.
5104 * Otherwise, if at least one route among routes that are
5105 * aggregated has ORIGIN with the value EGP, then the aggregated
5106 * route MUST have the ORIGIN attribute with the value EGP.
5108 if (origin < ri->attr->origin)
5109 origin = ri->attr->origin;
5111 /* as-set aggregate route generate origin, as path,
5112 community aggregation. */
5113 if (aggregate->as_set)
5117 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
5118 aspath_free (aspath);
5122 aspath = aspath_dup (ri->attr->aspath);
5124 if (ri->attr->community)
5128 commerge = community_merge (community,
5129 ri->attr->community);
5130 community = community_uniq_sort (commerge);
5131 community_free (commerge);
5134 community = community_dup (ri->attr->community);
5141 /* If this node is suppressed, process the change. */
5143 bgp_process (bgp, rn, afi, safi);
5145 bgp_unlock_node (top);
5147 /* Add aggregate route to BGP table. */
5148 if (aggregate->count)
5150 rn = bgp_node_get (table, p);
5151 new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, bgp->peer_self,
5152 bgp_attr_aggregate_intern(bgp, origin, aspath, community,
5154 atomic_aggregate), rn);
5155 SET_FLAG (new->flags, BGP_INFO_VALID);
5157 bgp_info_add (rn, new);
5158 bgp_unlock_node (rn);
5160 /* Process change. */
5161 bgp_process (bgp, rn, afi, safi);
5166 aspath_free (aspath);
5168 community_free (community);
5173 bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi,
5174 safi_t safi, struct bgp_aggregate *aggregate)
5176 struct bgp_table *table;
5177 struct bgp_node *top;
5178 struct bgp_node *rn;
5179 struct bgp_info *ri;
5180 unsigned long match;
5182 table = bgp->rib[afi][safi];
5184 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
5186 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
5189 /* If routes exists below this node, generate aggregate routes. */
5190 top = bgp_node_get (table, p);
5191 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
5192 if (rn->p.prefixlen > p->prefixlen)
5196 for (ri = rn->info; ri; ri = ri->next)
5198 if (BGP_INFO_HOLDDOWN (ri))
5201 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
5203 if (aggregate->summary_only && ri->extra)
5205 ri->extra->suppress--;
5207 if (ri->extra->suppress == 0)
5209 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
5217 /* If this node was suppressed, process the change. */
5219 bgp_process (bgp, rn, afi, safi);
5221 bgp_unlock_node (top);
5223 /* Delete aggregate route from BGP table. */
5224 rn = bgp_node_get (table, p);
5226 for (ri = rn->info; ri; ri = ri->next)
5227 if (ri->peer == bgp->peer_self
5228 && ri->type == ZEBRA_ROUTE_BGP
5229 && ri->sub_type == BGP_ROUTE_AGGREGATE)
5232 /* Withdraw static BGP route from routing table. */
5235 bgp_info_delete (rn, ri);
5236 bgp_process (bgp, rn, afi, safi);
5239 /* Unlock bgp_node_lookup. */
5240 bgp_unlock_node (rn);
5243 /* Aggregate route attribute. */
5244 #define AGGREGATE_SUMMARY_ONLY 1
5245 #define AGGREGATE_AS_SET 1
5248 bgp_aggregate_unset (struct vty *vty, const char *prefix_str,
5249 afi_t afi, safi_t safi)
5253 struct bgp_node *rn;
5255 struct bgp_aggregate *aggregate;
5257 /* Convert string to prefix structure. */
5258 ret = str2prefix (prefix_str, &p);
5261 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
5266 /* Get BGP structure. */
5269 /* Old configuration check. */
5270 rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p);
5273 vty_out (vty, "%% There is no aggregate-address configuration.%s",
5278 aggregate = rn->info;
5279 if (aggregate->safi & SAFI_UNICAST)
5280 bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate);
5281 if (aggregate->safi & SAFI_MULTICAST)
5282 bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate);
5284 /* Unlock aggregate address configuration. */
5286 bgp_aggregate_free (aggregate);
5287 bgp_unlock_node (rn);
5288 bgp_unlock_node (rn);
5294 bgp_aggregate_set (struct vty *vty, const char *prefix_str,
5295 afi_t afi, safi_t safi,
5296 u_char summary_only, u_char as_set)
5300 struct bgp_node *rn;
5302 struct bgp_aggregate *aggregate;
5304 /* Convert string to prefix structure. */
5305 ret = str2prefix (prefix_str, &p);
5308 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
5313 /* Get BGP structure. */
5316 /* Old configuration check. */
5317 rn = bgp_node_get (bgp->aggregate[afi][safi], &p);
5321 vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE);
5322 /* try to remove the old entry */
5323 ret = bgp_aggregate_unset (vty, prefix_str, afi, safi);
5326 vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE);
5327 bgp_unlock_node (rn);
5332 /* Make aggregate address structure. */
5333 aggregate = bgp_aggregate_new ();
5334 aggregate->summary_only = summary_only;
5335 aggregate->as_set = as_set;
5336 aggregate->safi = safi;
5337 rn->info = aggregate;
5339 /* Aggregate address insert into BGP routing table. */
5340 if (safi & SAFI_UNICAST)
5341 bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate);
5342 if (safi & SAFI_MULTICAST)
5343 bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate);
5348 DEFUN (aggregate_address,
5349 aggregate_address_cmd,
5350 "aggregate-address A.B.C.D/M",
5351 "Configure BGP aggregate entries\n"
5352 "Aggregate prefix\n")
5354 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0);
5357 DEFUN (aggregate_address_mask,
5358 aggregate_address_mask_cmd,
5359 "aggregate-address A.B.C.D A.B.C.D",
5360 "Configure BGP aggregate entries\n"
5361 "Aggregate address\n"
5365 char prefix_str[BUFSIZ];
5367 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5371 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5375 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5379 DEFUN (aggregate_address_summary_only,
5380 aggregate_address_summary_only_cmd,
5381 "aggregate-address A.B.C.D/M summary-only",
5382 "Configure BGP aggregate entries\n"
5383 "Aggregate prefix\n"
5384 "Filter more specific routes from updates\n")
5386 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5387 AGGREGATE_SUMMARY_ONLY, 0);
5390 DEFUN (aggregate_address_mask_summary_only,
5391 aggregate_address_mask_summary_only_cmd,
5392 "aggregate-address A.B.C.D A.B.C.D summary-only",
5393 "Configure BGP aggregate entries\n"
5394 "Aggregate address\n"
5396 "Filter more specific routes from updates\n")
5399 char prefix_str[BUFSIZ];
5401 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5405 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5409 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5410 AGGREGATE_SUMMARY_ONLY, 0);
5413 DEFUN (aggregate_address_as_set,
5414 aggregate_address_as_set_cmd,
5415 "aggregate-address A.B.C.D/M as-set",
5416 "Configure BGP aggregate entries\n"
5417 "Aggregate prefix\n"
5418 "Generate AS set path information\n")
5420 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5421 0, AGGREGATE_AS_SET);
5424 DEFUN (aggregate_address_mask_as_set,
5425 aggregate_address_mask_as_set_cmd,
5426 "aggregate-address A.B.C.D A.B.C.D as-set",
5427 "Configure BGP aggregate entries\n"
5428 "Aggregate address\n"
5430 "Generate AS set path information\n")
5433 char prefix_str[BUFSIZ];
5435 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5439 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5443 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5444 0, AGGREGATE_AS_SET);
5448 DEFUN (aggregate_address_as_set_summary,
5449 aggregate_address_as_set_summary_cmd,
5450 "aggregate-address A.B.C.D/M as-set summary-only",
5451 "Configure BGP aggregate entries\n"
5452 "Aggregate prefix\n"
5453 "Generate AS set path information\n"
5454 "Filter more specific routes from updates\n")
5456 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5457 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
5460 ALIAS (aggregate_address_as_set_summary,
5461 aggregate_address_summary_as_set_cmd,
5462 "aggregate-address A.B.C.D/M summary-only as-set",
5463 "Configure BGP aggregate entries\n"
5464 "Aggregate prefix\n"
5465 "Filter more specific routes from updates\n"
5466 "Generate AS set path information\n")
5468 DEFUN (aggregate_address_mask_as_set_summary,
5469 aggregate_address_mask_as_set_summary_cmd,
5470 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5471 "Configure BGP aggregate entries\n"
5472 "Aggregate address\n"
5474 "Generate AS set path information\n"
5475 "Filter more specific routes from updates\n")
5478 char prefix_str[BUFSIZ];
5480 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5484 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5488 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5489 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
5492 ALIAS (aggregate_address_mask_as_set_summary,
5493 aggregate_address_mask_summary_as_set_cmd,
5494 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5495 "Configure BGP aggregate entries\n"
5496 "Aggregate address\n"
5498 "Filter more specific routes from updates\n"
5499 "Generate AS set path information\n")
5501 DEFUN (no_aggregate_address,
5502 no_aggregate_address_cmd,
5503 "no aggregate-address A.B.C.D/M",
5505 "Configure BGP aggregate entries\n"
5506 "Aggregate prefix\n")
5508 return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty));
5511 ALIAS (no_aggregate_address,
5512 no_aggregate_address_summary_only_cmd,
5513 "no aggregate-address A.B.C.D/M summary-only",
5515 "Configure BGP aggregate entries\n"
5516 "Aggregate prefix\n"
5517 "Filter more specific routes from updates\n")
5519 ALIAS (no_aggregate_address,
5520 no_aggregate_address_as_set_cmd,
5521 "no aggregate-address A.B.C.D/M as-set",
5523 "Configure BGP aggregate entries\n"
5524 "Aggregate prefix\n"
5525 "Generate AS set path information\n")
5527 ALIAS (no_aggregate_address,
5528 no_aggregate_address_as_set_summary_cmd,
5529 "no aggregate-address A.B.C.D/M as-set summary-only",
5531 "Configure BGP aggregate entries\n"
5532 "Aggregate prefix\n"
5533 "Generate AS set path information\n"
5534 "Filter more specific routes from updates\n")
5536 ALIAS (no_aggregate_address,
5537 no_aggregate_address_summary_as_set_cmd,
5538 "no aggregate-address A.B.C.D/M summary-only as-set",
5540 "Configure BGP aggregate entries\n"
5541 "Aggregate prefix\n"
5542 "Filter more specific routes from updates\n"
5543 "Generate AS set path information\n")
5545 DEFUN (no_aggregate_address_mask,
5546 no_aggregate_address_mask_cmd,
5547 "no aggregate-address A.B.C.D A.B.C.D",
5549 "Configure BGP aggregate entries\n"
5550 "Aggregate address\n"
5554 char prefix_str[BUFSIZ];
5556 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5560 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5564 return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty));
5567 ALIAS (no_aggregate_address_mask,
5568 no_aggregate_address_mask_summary_only_cmd,
5569 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5571 "Configure BGP aggregate entries\n"
5572 "Aggregate address\n"
5574 "Filter more specific routes from updates\n")
5576 ALIAS (no_aggregate_address_mask,
5577 no_aggregate_address_mask_as_set_cmd,
5578 "no aggregate-address A.B.C.D A.B.C.D as-set",
5580 "Configure BGP aggregate entries\n"
5581 "Aggregate address\n"
5583 "Generate AS set path information\n")
5585 ALIAS (no_aggregate_address_mask,
5586 no_aggregate_address_mask_as_set_summary_cmd,
5587 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5589 "Configure BGP aggregate entries\n"
5590 "Aggregate address\n"
5592 "Generate AS set path information\n"
5593 "Filter more specific routes from updates\n")
5595 ALIAS (no_aggregate_address_mask,
5596 no_aggregate_address_mask_summary_as_set_cmd,
5597 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5599 "Configure BGP aggregate entries\n"
5600 "Aggregate address\n"
5602 "Filter more specific routes from updates\n"
5603 "Generate AS set path information\n")
5605 DEFUN (ipv6_aggregate_address,
5606 ipv6_aggregate_address_cmd,
5607 "aggregate-address X:X::X:X/M",
5608 "Configure BGP aggregate entries\n"
5609 "Aggregate prefix\n")
5611 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0);
5614 DEFUN (ipv6_aggregate_address_summary_only,
5615 ipv6_aggregate_address_summary_only_cmd,
5616 "aggregate-address X:X::X:X/M summary-only",
5617 "Configure BGP aggregate entries\n"
5618 "Aggregate prefix\n"
5619 "Filter more specific routes from updates\n")
5621 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST,
5622 AGGREGATE_SUMMARY_ONLY, 0);
5625 DEFUN (no_ipv6_aggregate_address,
5626 no_ipv6_aggregate_address_cmd,
5627 "no aggregate-address X:X::X:X/M",
5629 "Configure BGP aggregate entries\n"
5630 "Aggregate prefix\n")
5632 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
5635 DEFUN (no_ipv6_aggregate_address_summary_only,
5636 no_ipv6_aggregate_address_summary_only_cmd,
5637 "no aggregate-address X:X::X:X/M summary-only",
5639 "Configure BGP aggregate entries\n"
5640 "Aggregate prefix\n"
5641 "Filter more specific routes from updates\n")
5643 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
5646 ALIAS (ipv6_aggregate_address,
5647 old_ipv6_aggregate_address_cmd,
5648 "ipv6 bgp aggregate-address X:X::X:X/M",
5651 "Configure BGP aggregate entries\n"
5652 "Aggregate prefix\n")
5654 ALIAS (ipv6_aggregate_address_summary_only,
5655 old_ipv6_aggregate_address_summary_only_cmd,
5656 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5659 "Configure BGP aggregate entries\n"
5660 "Aggregate prefix\n"
5661 "Filter more specific routes from updates\n")
5663 ALIAS (no_ipv6_aggregate_address,
5664 old_no_ipv6_aggregate_address_cmd,
5665 "no ipv6 bgp aggregate-address X:X::X:X/M",
5669 "Configure BGP aggregate entries\n"
5670 "Aggregate prefix\n")
5672 ALIAS (no_ipv6_aggregate_address_summary_only,
5673 old_no_ipv6_aggregate_address_summary_only_cmd,
5674 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5678 "Configure BGP aggregate entries\n"
5679 "Aggregate prefix\n"
5680 "Filter more specific routes from updates\n")
5682 /* Redistribute route treatment. */
5684 bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop,
5685 const struct in6_addr *nexthop6,
5686 u_int32_t metric, u_char type, route_tag_t tag)
5689 struct listnode *node, *nnode;
5690 struct bgp_info *new;
5691 struct bgp_info *bi;
5692 struct bgp_info info;
5693 struct bgp_node *bn;
5695 struct attr *new_attr;
5699 /* Make default attribute. */
5700 bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE);
5702 attr.nexthop = *nexthop;
5706 struct attr_extra *extra = bgp_attr_extra_get(&attr);
5707 extra->mp_nexthop_global = *nexthop6;
5708 extra->mp_nexthop_len = 16;
5712 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
5713 attr.extra->tag = tag;
5715 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
5717 afi = family2afi (p->family);
5719 if (bgp->redist[afi][type])
5721 struct attr attr_new;
5722 struct attr_extra extra_new;
5724 /* Copy attribute for modification. */
5725 attr_new.extra = &extra_new;
5726 bgp_attr_dup (&attr_new, &attr);
5728 if (bgp->redist_metric_flag[afi][type])
5729 attr_new.med = bgp->redist_metric[afi][type];
5731 /* Apply route-map. */
5732 if (bgp->rmap[afi][type].name)
5734 info.peer = bgp->peer_self;
5735 info.attr = &attr_new;
5737 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE);
5739 ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP,
5742 bgp->peer_self->rmap_type = 0;
5744 if (ret == RMAP_DENYMATCH)
5746 /* Free uninterned attribute. */
5747 bgp_attr_flush (&attr_new);
5749 /* Unintern original. */
5750 aspath_unintern (&attr.aspath);
5751 bgp_attr_extra_free (&attr);
5752 bgp_redistribute_delete (p, type);
5757 bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST],
5758 afi, SAFI_UNICAST, p, NULL);
5760 new_attr = bgp_attr_intern (&attr_new);
5762 for (bi = bn->info; bi; bi = bi->next)
5763 if (bi->peer == bgp->peer_self
5764 && bi->sub_type == BGP_ROUTE_REDISTRIBUTE)
5769 if (attrhash_cmp (bi->attr, new_attr) &&
5770 !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED))
5772 bgp_attr_unintern (&new_attr);
5773 aspath_unintern (&attr.aspath);
5774 bgp_attr_extra_free (&attr);
5775 bgp_unlock_node (bn);
5780 /* The attribute is changed. */
5781 bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED);
5783 /* Rewrite BGP route information. */
5784 if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED))
5785 bgp_info_restore(bn, bi);
5787 bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST);
5788 bgp_attr_unintern (&bi->attr);
5789 bi->attr = new_attr;
5790 bi->uptime = bgp_clock ();
5792 /* Process change. */
5793 bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST);
5794 bgp_process (bgp, bn, afi, SAFI_UNICAST);
5795 bgp_unlock_node (bn);
5796 aspath_unintern (&attr.aspath);
5797 bgp_attr_extra_free (&attr);
5802 new = info_make(type, BGP_ROUTE_REDISTRIBUTE, bgp->peer_self,
5804 SET_FLAG (new->flags, BGP_INFO_VALID);
5806 bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST);
5807 bgp_info_add (bn, new);
5808 bgp_unlock_node (bn);
5809 bgp_process (bgp, bn, afi, SAFI_UNICAST);
5813 /* Unintern original. */
5814 aspath_unintern (&attr.aspath);
5815 bgp_attr_extra_free (&attr);
5819 bgp_redistribute_delete (struct prefix *p, u_char type)
5822 struct listnode *node, *nnode;
5824 struct bgp_node *rn;
5825 struct bgp_info *ri;
5827 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
5829 afi = family2afi (p->family);
5831 if (bgp->redist[afi][type])
5833 rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL);
5835 for (ri = rn->info; ri; ri = ri->next)
5836 if (ri->peer == bgp->peer_self
5837 && ri->type == type)
5842 bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST);
5843 bgp_info_delete (rn, ri);
5844 bgp_process (bgp, rn, afi, SAFI_UNICAST);
5846 bgp_unlock_node (rn);
5851 /* Withdraw specified route type's route. */
5853 bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type)
5855 struct bgp_node *rn;
5856 struct bgp_info *ri;
5857 struct bgp_table *table;
5859 table = bgp->rib[afi][SAFI_UNICAST];
5861 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
5863 for (ri = rn->info; ri; ri = ri->next)
5864 if (ri->peer == bgp->peer_self
5865 && ri->type == type)
5870 bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST);
5871 bgp_info_delete (rn, ri);
5872 bgp_process (bgp, rn, afi, SAFI_UNICAST);
5877 /* Static function to display route. */
5879 route_vty_out_route (struct prefix *p, struct vty *vty)
5882 u_int32_t destination;
5885 if (p->family == AF_INET)
5887 len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ));
5888 destination = ntohl (p->u.prefix4.s_addr);
5890 if ((IN_CLASSC (destination) && p->prefixlen == 24)
5891 || (IN_CLASSB (destination) && p->prefixlen == 16)
5892 || (IN_CLASSA (destination) && p->prefixlen == 8)
5893 || p->u.prefix4.s_addr == 0)
5895 /* When mask is natural, mask is not displayed. */
5898 len += vty_out (vty, "/%d", p->prefixlen);
5901 len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
5906 vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " ");
5908 vty_out (vty, "%*s", len, " ");
5911 enum bgp_display_type
5916 /* Print the short form route status for a bgp_info */
5918 route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo)
5920 /* Route status display. */
5921 if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED))
5923 else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
5925 else if (binfo->extra && binfo->extra->suppress)
5927 else if (CHECK_FLAG (binfo->flags, BGP_INFO_VALID) &&
5928 ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5934 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5936 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
5938 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
5940 else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH))
5945 /* Internal route. */
5946 if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as))
5952 /* called from terminal list command */
5957 struct bgp_info *binfo,
5963 /* short status lead text */
5964 route_vty_short_status_out (vty, binfo);
5966 /* print prefix and mask */
5968 route_vty_out_route (p, vty);
5970 vty_out (vty, "%*s", 17, " ");
5972 /* Print attribute */
5982 * For ENCAP routes, nexthop address family is not
5983 * neccessarily the same as the prefix address family.
5984 * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field
5986 if ((safi == SAFI_ENCAP) || (safi == SAFI_MPLS_VPN)) {
5989 int af = NEXTHOP_FAMILY(attr->extra->mp_nexthop_len);
5993 vty_out (vty, "%s", inet_ntop(af,
5994 &attr->extra->mp_nexthop_global_in, buf, BUFSIZ));
5997 vty_out (vty, "%s", inet_ntop(af,
5998 &attr->extra->mp_nexthop_global, buf, BUFSIZ));
6008 if (p->family == AF_INET)
6010 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6012 else if (p->family == AF_INET6)
6017 len = vty_out (vty, "%s",
6018 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6022 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
6024 vty_out (vty, "%*s", len, " ");
6037 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
6038 vty_out (vty, "%10u", attr->med);
6042 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
6043 vty_out (vty, "%7u", attr->local_pref);
6047 vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
6051 aspath_print_vty (vty, "%s", attr->aspath, " ");
6054 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
6056 vty_out (vty, "%s", VTY_NEWLINE);
6059 /* called from terminal list command */
6061 route_vty_out_tmp (struct vty *vty, struct prefix *p,
6062 struct attr *attr, safi_t safi)
6064 /* Route status display. */
6069 /* print prefix and mask */
6070 route_vty_out_route (p, vty);
6072 /* Print attribute */
6075 if (p->family == AF_INET)
6077 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
6078 vty_out (vty, "%-16s",
6079 inet_ntoa (attr->extra->mp_nexthop_global_in));
6081 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6083 else if (p->family == AF_INET6)
6088 assert (attr->extra);
6090 len = vty_out (vty, "%s",
6091 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6095 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
6097 vty_out (vty, "%*s", len, " ");
6100 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
6101 vty_out (vty, "%10u ", attr->med);
6105 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
6106 vty_out (vty, "%7u ", attr->local_pref);
6110 vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
6114 aspath_print_vty (vty, "%s", attr->aspath, " ");
6117 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
6120 vty_out (vty, "%s", VTY_NEWLINE);
6124 route_vty_out_tag (struct vty *vty, struct prefix *p,
6125 struct bgp_info *binfo, int display, safi_t safi)
6128 u_int32_t label = 0;
6133 /* short status lead text */
6134 route_vty_short_status_out (vty, binfo);
6136 /* print prefix and mask */
6138 route_vty_out_route (p, vty);
6140 vty_out (vty, "%*s", 17, " ");
6142 /* Print attribute */
6146 if (p->family == AF_INET)
6148 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
6149 vty_out (vty, "%-16s",
6150 inet_ntoa (attr->extra->mp_nexthop_global_in));
6152 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6154 else if (p->family == AF_INET6)
6156 assert (attr->extra);
6159 if (attr->extra->mp_nexthop_len == 16)
6161 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6163 else if (attr->extra->mp_nexthop_len == 32)
6164 vty_out (vty, "%s(%s)",
6165 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6167 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
6173 label = decode_label (binfo->extra->tag);
6175 vty_out (vty, "notag/%d", label);
6177 vty_out (vty, "%s", VTY_NEWLINE);
6180 /* dampening route */
6182 damp_route_vty_out (struct vty *vty, struct prefix *p,
6183 struct bgp_info *binfo, int display, safi_t safi)
6187 char timebuf[BGP_UPTIME_LEN];
6189 /* short status lead text */
6190 route_vty_short_status_out (vty, binfo);
6192 /* print prefix and mask */
6194 route_vty_out_route (p, vty);
6196 vty_out (vty, "%*s", 17, " ");
6198 len = vty_out (vty, "%s", binfo->peer->host);
6201 vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " ");
6203 vty_out (vty, "%*s", len, " ");
6205 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
6207 /* Print attribute */
6213 aspath_print_vty (vty, "%s", attr->aspath, " ");
6216 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
6218 vty_out (vty, "%s", VTY_NEWLINE);
6223 flap_route_vty_out (struct vty *vty, struct prefix *p,
6224 struct bgp_info *binfo, int display, safi_t safi)
6227 struct bgp_damp_info *bdi;
6228 char timebuf[BGP_UPTIME_LEN];
6234 bdi = binfo->extra->damp_info;
6236 /* short status lead text */
6237 route_vty_short_status_out (vty, binfo);
6239 /* print prefix and mask */
6241 route_vty_out_route (p, vty);
6243 vty_out (vty, "%*s", 17, " ");
6245 len = vty_out (vty, "%s", binfo->peer->host);
6248 vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " ");
6250 vty_out (vty, "%*s", len, " ");
6252 len = vty_out (vty, "%d", bdi->flap);
6257 vty_out (vty, "%*s ", len, " ");
6259 vty_out (vty, "%s ", peer_uptime (bdi->start_time,
6260 timebuf, BGP_UPTIME_LEN));
6262 if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)
6263 && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
6264 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
6266 vty_out (vty, "%*s ", 8, " ");
6268 /* Print attribute */
6274 aspath_print_vty (vty, "%s", attr->aspath, " ");
6277 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
6279 vty_out (vty, "%s", VTY_NEWLINE);
6283 route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
6284 struct bgp_info *binfo, afi_t afi, safi_t safi)
6286 char buf[INET6_ADDRSTRLEN];
6289 int sockunion_vty_out (struct vty *, union sockunion *);
6290 #ifdef HAVE_CLOCK_MONOTONIC
6298 /* Line1 display AS-path, Aggregator */
6302 if (aspath_count_hops (attr->aspath) == 0)
6303 vty_out (vty, "Local");
6305 aspath_print_vty (vty, "%s", attr->aspath, "");
6308 if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED))
6309 vty_out (vty, ", (removed)");
6310 if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
6311 vty_out (vty, ", (stale)");
6312 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
6313 vty_out (vty, ", (aggregated by %u %s)",
6314 attr->extra->aggregator_as,
6315 inet_ntoa (attr->extra->aggregator_addr));
6316 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
6317 vty_out (vty, ", (Received from a RR-client)");
6318 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
6319 vty_out (vty, ", (Received from a RS-client)");
6320 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
6321 vty_out (vty, ", (history entry)");
6322 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
6323 vty_out (vty, ", (suppressed due to dampening)");
6324 vty_out (vty, "%s", VTY_NEWLINE);
6326 /* Line2 display Next-hop, Neighbor, Router-id */
6327 if (p->family == AF_INET)
6329 vty_out (vty, " %s", ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) ?
6330 inet_ntoa (attr->extra->mp_nexthop_global_in) :
6331 inet_ntoa (attr->nexthop));
6335 assert (attr->extra);
6336 vty_out (vty, " %s",
6337 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6338 buf, INET6_ADDRSTRLEN));
6341 if (binfo->peer == bgp->peer_self)
6343 vty_out (vty, " from %s ",
6344 p->family == AF_INET ? "0.0.0.0" : "::");
6345 vty_out (vty, "(%s)", inet_ntoa(bgp->router_id));
6349 if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID))
6350 vty_out (vty, " (inaccessible)");
6351 else if (binfo->extra && binfo->extra->igpmetric)
6352 vty_out (vty, " (metric %u)", binfo->extra->igpmetric);
6353 if (!sockunion2str (&binfo->peer->su, buf, sizeof(buf))) {
6357 vty_out (vty, " from %s", buf);
6358 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
6359 vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id));
6361 vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ));
6363 vty_out (vty, "%s", VTY_NEWLINE);
6365 /* display nexthop local */
6366 if (attr->extra && attr->extra->mp_nexthop_len == 32)
6368 vty_out (vty, " (%s)%s",
6369 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
6370 buf, INET6_ADDRSTRLEN),
6374 /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */
6375 vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]);
6377 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
6378 vty_out (vty, ", metric %u", attr->med);
6380 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
6381 vty_out (vty, ", localpref %u", attr->local_pref);
6383 vty_out (vty, ", localpref %u", bgp->default_local_pref);
6385 if (attr->extra && attr->extra->weight != 0)
6386 vty_out (vty, ", weight %u", attr->extra->weight);
6388 if (attr->extra && attr->extra->tag != 0)
6389 vty_out (vty, ", tag %d", attr->extra->tag);
6391 if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID))
6392 vty_out (vty, ", invalid");
6393 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
6394 vty_out (vty, ", valid");
6396 if (binfo->peer != bgp->peer_self)
6398 if (binfo->peer->as == binfo->peer->local_as)
6399 vty_out (vty, ", internal");
6401 vty_out (vty, ", %s",
6402 (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external"));
6404 else if (binfo->sub_type == BGP_ROUTE_AGGREGATE)
6405 vty_out (vty, ", aggregated, local");
6406 else if (binfo->type != ZEBRA_ROUTE_BGP)
6407 vty_out (vty, ", sourced");
6409 vty_out (vty, ", sourced, local");
6411 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
6412 vty_out (vty, ", atomic-aggregate");
6414 if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) ||
6415 (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) &&
6416 bgp_info_mpath_count (binfo)))
6417 vty_out (vty, ", multipath");
6419 if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
6420 vty_out (vty, ", best");
6422 vty_out (vty, "%s", VTY_NEWLINE);
6424 /* Line 4 display Community */
6425 if (attr->community)
6426 vty_out (vty, " Community: %s%s", attr->community->str,
6429 /* Line 5 display Extended-community */
6430 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))
6431 vty_out (vty, " Extended Community: %s%s",
6432 attr->extra->ecommunity->str, VTY_NEWLINE);
6434 /* Line 6 display Large community */
6435 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES))
6436 vty_out (vty, " Large Community: %s%s",
6437 attr->extra->lcommunity->str, VTY_NEWLINE);
6439 /* Line 7 display Originator, Cluster-id */
6440 if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) ||
6441 (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)))
6443 assert (attr->extra);
6444 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
6445 vty_out (vty, " Originator: %s",
6446 inet_ntoa (attr->extra->originator_id));
6448 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
6451 vty_out (vty, ", Cluster list: ");
6452 for (i = 0; i < attr->extra->cluster->length / 4; i++)
6453 vty_out (vty, "%s ",
6454 inet_ntoa (attr->extra->cluster->list[i]));
6456 vty_out (vty, "%s", VTY_NEWLINE);
6459 if (binfo->extra && binfo->extra->damp_info)
6460 bgp_damp_info_vty (vty, binfo);
6462 /* Line 8 display Uptime */
6463 #ifdef HAVE_CLOCK_MONOTONIC
6464 tbuf = time(NULL) - (bgp_clock() - binfo->uptime);
6465 vty_out (vty, " Last update: %s", ctime(&tbuf));
6467 vty_out (vty, " Last update: %s", ctime(&binfo->uptime));
6468 #endif /* HAVE_CLOCK_MONOTONIC */
6470 vty_out (vty, "%s", VTY_NEWLINE);
6473 #define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\
6474 "h history, * valid, > best, = multipath,%s"\
6475 " i internal, r RIB-failure, S Stale, R Removed%s"
6476 #define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
6477 #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
6478 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
6479 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
6483 bgp_show_type_normal,
6484 bgp_show_type_regexp,
6485 bgp_show_type_prefix_list,
6486 bgp_show_type_filter_list,
6487 bgp_show_type_route_map,
6488 bgp_show_type_neighbor,
6489 bgp_show_type_cidr_only,
6490 bgp_show_type_prefix_longer,
6491 bgp_show_type_community_all,
6492 bgp_show_type_community,
6493 bgp_show_type_community_exact,
6494 bgp_show_type_community_list,
6495 bgp_show_type_community_list_exact,
6496 bgp_show_type_lcommunity_all,
6497 bgp_show_type_lcommunity,
6498 bgp_show_type_lcommunity_list,
6499 bgp_show_type_flap_statistics,
6500 bgp_show_type_flap_address,
6501 bgp_show_type_flap_prefix,
6502 bgp_show_type_flap_cidr_only,
6503 bgp_show_type_flap_regexp,
6504 bgp_show_type_flap_filter_list,
6505 bgp_show_type_flap_prefix_list,
6506 bgp_show_type_flap_prefix_longer,
6507 bgp_show_type_flap_route_map,
6508 bgp_show_type_flap_neighbor,
6509 bgp_show_type_dampend_paths,
6510 bgp_show_type_damp_neighbor
6514 bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router_id,
6515 enum bgp_show_type type, void *output_arg)
6517 struct bgp_info *ri;
6518 struct bgp_node *rn;
6521 unsigned long output_count;
6522 unsigned long total_count;
6524 /* This is first entry point, so reset total line. */
6528 /* Start processing of routes. */
6529 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
6530 if (rn->info != NULL)
6534 for (ri = rn->info; ri; ri = ri->next)
6537 if (type == bgp_show_type_flap_statistics
6538 || type == bgp_show_type_flap_address
6539 || type == bgp_show_type_flap_prefix
6540 || type == bgp_show_type_flap_cidr_only
6541 || type == bgp_show_type_flap_regexp
6542 || type == bgp_show_type_flap_filter_list
6543 || type == bgp_show_type_flap_prefix_list
6544 || type == bgp_show_type_flap_prefix_longer
6545 || type == bgp_show_type_flap_route_map
6546 || type == bgp_show_type_flap_neighbor
6547 || type == bgp_show_type_dampend_paths
6548 || type == bgp_show_type_damp_neighbor)
6550 if (!(ri->extra && ri->extra->damp_info))
6553 if (type == bgp_show_type_regexp
6554 || type == bgp_show_type_flap_regexp)
6556 regex_t *regex = output_arg;
6558 if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH)
6561 if (type == bgp_show_type_prefix_list
6562 || type == bgp_show_type_flap_prefix_list)
6564 struct prefix_list *plist = output_arg;
6566 if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT)
6569 if (type == bgp_show_type_filter_list
6570 || type == bgp_show_type_flap_filter_list)
6572 struct as_list *as_list = output_arg;
6574 if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT)
6577 if (type == bgp_show_type_route_map
6578 || type == bgp_show_type_flap_route_map)
6580 struct route_map *rmap = output_arg;
6581 struct bgp_info binfo;
6582 struct attr dummy_attr;
6583 struct attr_extra dummy_extra;
6586 dummy_attr.extra = &dummy_extra;
6587 bgp_attr_dup (&dummy_attr, ri->attr);
6589 binfo.peer = ri->peer;
6590 binfo.attr = &dummy_attr;
6592 ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo);
6593 if (ret == RMAP_DENYMATCH)
6596 if (type == bgp_show_type_neighbor
6597 || type == bgp_show_type_flap_neighbor
6598 || type == bgp_show_type_damp_neighbor)
6600 union sockunion *su = output_arg;
6602 if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su))
6605 if (type == bgp_show_type_cidr_only
6606 || type == bgp_show_type_flap_cidr_only)
6608 u_int32_t destination;
6610 destination = ntohl (rn->p.u.prefix4.s_addr);
6611 if (IN_CLASSC (destination) && rn->p.prefixlen == 24)
6613 if (IN_CLASSB (destination) && rn->p.prefixlen == 16)
6615 if (IN_CLASSA (destination) && rn->p.prefixlen == 8)
6618 if (type == bgp_show_type_prefix_longer
6619 || type == bgp_show_type_flap_prefix_longer)
6621 struct prefix *p = output_arg;
6623 if (! prefix_match (p, &rn->p))
6626 if (type == bgp_show_type_community_all)
6628 if (! ri->attr->community)
6631 if (type == bgp_show_type_community)
6633 struct community *com = output_arg;
6635 if (! ri->attr->community ||
6636 ! community_match (ri->attr->community, com))
6639 if (type == bgp_show_type_community_exact)
6641 struct community *com = output_arg;
6643 if (! ri->attr->community ||
6644 ! community_cmp (ri->attr->community, com))
6647 if (type == bgp_show_type_community_list)
6649 struct community_list *list = output_arg;
6651 if (! community_list_match (ri->attr->community, list))
6654 if (type == bgp_show_type_community_list_exact)
6656 struct community_list *list = output_arg;
6658 if (! community_list_exact_match (ri->attr->community, list))
6661 if (type == bgp_show_type_community_all)
6663 if (! ri->attr->community)
6666 if (type == bgp_show_type_lcommunity)
6668 struct lcommunity *lcom = output_arg;
6670 if (! ri->attr->extra || ! ri->attr->extra->lcommunity ||
6671 ! lcommunity_match (ri->attr->extra->lcommunity, lcom))
6674 if (type == bgp_show_type_lcommunity_list)
6676 struct community_list *list = output_arg;
6678 if (! ri->attr->extra ||
6679 ! lcommunity_list_match (ri->attr->extra->lcommunity, list))
6682 if (type == bgp_show_type_lcommunity_all)
6684 if (! ri->attr->extra || ! ri->attr->extra->lcommunity)
6687 if (type == bgp_show_type_flap_address
6688 || type == bgp_show_type_flap_prefix)
6690 struct prefix *p = output_arg;
6692 if (! prefix_match (&rn->p, p))
6695 if (type == bgp_show_type_flap_prefix)
6696 if (p->prefixlen != rn->p.prefixlen)
6699 if (type == bgp_show_type_dampend_paths
6700 || type == bgp_show_type_damp_neighbor)
6702 if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)
6703 || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
6709 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE);
6710 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
6711 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
6712 if (type == bgp_show_type_dampend_paths
6713 || type == bgp_show_type_damp_neighbor)
6714 vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE);
6715 else if (type == bgp_show_type_flap_statistics
6716 || type == bgp_show_type_flap_address
6717 || type == bgp_show_type_flap_prefix
6718 || type == bgp_show_type_flap_cidr_only
6719 || type == bgp_show_type_flap_regexp
6720 || type == bgp_show_type_flap_filter_list
6721 || type == bgp_show_type_flap_prefix_list
6722 || type == bgp_show_type_flap_prefix_longer
6723 || type == bgp_show_type_flap_route_map
6724 || type == bgp_show_type_flap_neighbor)
6725 vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE);
6727 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
6731 if (type == bgp_show_type_dampend_paths
6732 || type == bgp_show_type_damp_neighbor)
6733 damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
6734 else if (type == bgp_show_type_flap_statistics
6735 || type == bgp_show_type_flap_address
6736 || type == bgp_show_type_flap_prefix
6737 || type == bgp_show_type_flap_cidr_only
6738 || type == bgp_show_type_flap_regexp
6739 || type == bgp_show_type_flap_filter_list
6740 || type == bgp_show_type_flap_prefix_list
6741 || type == bgp_show_type_flap_prefix_longer
6742 || type == bgp_show_type_flap_route_map
6743 || type == bgp_show_type_flap_neighbor)
6744 flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
6746 route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
6753 /* No route is displayed */
6754 if (output_count == 0)
6756 if (type == bgp_show_type_normal)
6757 vty_out (vty, "No BGP prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE);
6760 vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s",
6761 VTY_NEWLINE, output_count, total_count, VTY_NEWLINE);
6767 bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
6768 enum bgp_show_type type, void *output_arg)
6770 struct bgp_table *table;
6773 bgp = bgp_get_default ();
6778 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
6783 table = bgp->rib[afi][safi];
6785 return bgp_show_table (vty, table, &bgp->router_id, type, output_arg);
6788 /* Header of detailed BGP route information */
6790 route_vty_out_detail_header (struct vty *vty, struct bgp *bgp,
6791 struct bgp_node *rn,
6792 struct prefix_rd *prd, afi_t afi, safi_t safi)
6794 struct bgp_info *ri;
6797 struct listnode *node, *nnode;
6798 char buf1[INET6_ADDRSTRLEN];
6799 char buf2[INET6_ADDRSTRLEN];
6804 int no_advertise = 0;
6807 int printrd = ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP));
6810 vty_out (vty, "BGP routing table entry for %s%s%s/%d%s",
6811 (printrd ? prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""),
6813 inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN),
6814 p->prefixlen, VTY_NEWLINE);
6816 for (ri = rn->info; ri; ri = ri->next)
6819 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
6822 if (ri->extra && ri->extra->suppress)
6824 if (ri->attr->community != NULL)
6826 if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE))
6828 if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT))
6830 if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS))
6836 vty_out (vty, "Paths: (%d available", count);
6839 vty_out (vty, ", best #%d", best);
6840 if (safi == SAFI_UNICAST)
6841 vty_out (vty, ", table Default-IP-Routing-Table");
6844 vty_out (vty, ", no best path");
6846 vty_out (vty, ", not advertised to any peer");
6848 vty_out (vty, ", not advertised to EBGP peer");
6850 vty_out (vty, ", not advertised outside local AS");
6852 vty_out (vty, ", Advertisements suppressed by an aggregate.");
6853 vty_out (vty, ")%s", VTY_NEWLINE);
6855 /* advertised peer */
6856 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
6858 if (bgp_adj_out_lookup (peer, p, afi, safi, rn))
6861 vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE);
6862 vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN));
6867 vty_out (vty, " Not advertised to any peer");
6868 vty_out (vty, "%s", VTY_NEWLINE);
6871 /* Display specified route of BGP table. */
6873 bgp_show_route_in_table (struct vty *vty, struct bgp *bgp,
6874 struct bgp_table *rib, const char *ip_str,
6875 afi_t afi, safi_t safi, struct prefix_rd *prd,
6876 int prefix_check, enum bgp_path_type pathtype)
6881 struct prefix match;
6882 struct bgp_node *rn;
6883 struct bgp_node *rm;
6884 struct bgp_info *ri;
6885 struct bgp_table *table;
6887 memset (&match, 0, sizeof (struct prefix)); /* keep valgrind happy */
6888 /* Check IP address argument. */
6889 ret = str2prefix (ip_str, &match);
6892 vty_out (vty, "address is malformed%s", VTY_NEWLINE);
6896 match.family = afi2family (afi);
6898 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
6900 for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn))
6902 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
6905 if ((table = rn->info) != NULL)
6909 if ((rm = bgp_node_match (table, &match)) != NULL)
6911 if (prefix_check && rm->p.prefixlen != match.prefixlen)
6913 bgp_unlock_node (rm);
6917 for (ri = rm->info; ri; ri = ri->next)
6921 route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p,
6928 if (pathtype == BGP_PATH_ALL ||
6929 (pathtype == BGP_PATH_BESTPATH && CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) ||
6930 (pathtype == BGP_PATH_MULTIPATH &&
6931 (CHECK_FLAG (ri->flags, BGP_INFO_MULTIPATH) || CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))))
6932 route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, safi);
6935 bgp_unlock_node (rm);
6944 if ((rn = bgp_node_match (rib, &match)) != NULL)
6946 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
6948 for (ri = rn->info; ri; ri = ri->next)
6952 route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi);
6957 if (pathtype == BGP_PATH_ALL ||
6958 (pathtype == BGP_PATH_BESTPATH && CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)) ||
6959 (pathtype == BGP_PATH_MULTIPATH &&
6960 (CHECK_FLAG (ri->flags, BGP_INFO_MULTIPATH) || CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))))
6961 route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi);
6965 bgp_unlock_node (rn);
6971 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
6978 /* Display specified route of Main RIB */
6980 bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str,
6981 afi_t afi, safi_t safi, struct prefix_rd *prd,
6982 int prefix_check, enum bgp_path_type pathtype)
6986 /* BGP structure lookup. */
6989 bgp = bgp_lookup_by_name (view_name);
6992 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
6998 bgp = bgp_get_default ();
7001 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
7006 return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str,
7007 afi, safi, prd, prefix_check, pathtype);
7010 /* BGP route print out function. */
7018 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
7021 DEFUN (show_ip_bgp_ipv4,
7022 show_ip_bgp_ipv4_cmd,
7023 "show ip bgp ipv4 (unicast|multicast)",
7028 "Address Family modifier\n"
7029 "Address Family modifier\n")
7031 if (strncmp (argv[0], "m", 1) == 0)
7032 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
7035 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
7038 DEFUN (show_ip_bgp_route,
7039 show_ip_bgp_route_cmd,
7040 "show ip bgp A.B.C.D",
7044 "Network in the BGP routing table to display\n")
7046 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
7049 DEFUN (show_ip_bgp_route_pathtype,
7050 show_ip_bgp_route_pathtype_cmd,
7051 "show ip bgp A.B.C.D (bestpath|multipath)",
7055 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7056 "Display only the bestpath\n"
7057 "Display only multipaths\n")
7059 if (strncmp (argv[1], "b", 1) == 0)
7060 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH);
7062 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH);
7065 DEFUN (show_bgp_ipv4_safi_route_pathtype,
7066 show_bgp_ipv4_safi_route_pathtype_cmd,
7067 "show bgp ipv4 (unicast|multicast) A.B.C.D (bestpath|multipath)",
7071 "Address Family modifier\n"
7072 "Address Family modifier\n"
7073 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7074 "Display only the bestpath\n"
7075 "Display only multipaths\n")
7077 if (strncmp (argv[0], "m", 1) == 0)
7078 if (strncmp (argv[2], "b", 1) == 0)
7079 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH);
7081 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH);
7083 if (strncmp (argv[2], "b", 1) == 0)
7084 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH);
7086 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH);
7089 DEFUN (show_ip_bgp_ipv4_route,
7090 show_ip_bgp_ipv4_route_cmd,
7091 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
7096 "Address Family modifier\n"
7097 "Address Family modifier\n"
7098 "Network in the BGP routing table to display\n")
7100 if (strncmp (argv[0], "m", 1) == 0)
7101 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL);
7103 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
7106 DEFUN (show_ip_bgp_vpnv4_all_route,
7107 show_ip_bgp_vpnv4_all_route_cmd,
7108 "show ip bgp vpnv4 all A.B.C.D",
7112 "Display VPNv4 NLRI specific information\n"
7113 "Display information about all VPNv4 NLRIs\n"
7114 "Network in the BGP routing table to display\n")
7116 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL);
7120 DEFUN (show_ip_bgp_vpnv4_rd_route,
7121 show_ip_bgp_vpnv4_rd_route_cmd,
7122 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
7126 "Display VPNv4 NLRI specific information\n"
7127 "Display information for a route distinguisher\n"
7128 "VPN Route Distinguisher\n"
7129 "Network in the BGP routing table to display\n")
7132 struct prefix_rd prd;
7134 ret = str2prefix_rd (argv[0], &prd);
7137 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7140 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL);
7143 DEFUN (show_ip_bgp_prefix,
7144 show_ip_bgp_prefix_cmd,
7145 "show ip bgp A.B.C.D/M",
7149 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7151 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
7154 DEFUN (show_ip_bgp_prefix_pathtype,
7155 show_ip_bgp_prefix_pathtype_cmd,
7156 "show ip bgp A.B.C.D/M (bestpath|multipath)",
7160 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7161 "Display only the bestpath\n"
7162 "Display only multipaths\n")
7164 if (strncmp (argv[1], "b", 1) == 0)
7165 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH);
7167 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH);
7170 DEFUN (show_ip_bgp_ipv4_prefix,
7171 show_ip_bgp_ipv4_prefix_cmd,
7172 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
7177 "Address Family modifier\n"
7178 "Address Family modifier\n"
7179 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7181 if (strncmp (argv[0], "m", 1) == 0)
7182 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL);
7184 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
7187 DEFUN (show_ip_bgp_ipv4_prefix_pathtype,
7188 show_ip_bgp_ipv4_prefix_pathtype_cmd,
7189 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath)",
7194 "Address Family modifier\n"
7195 "Address Family modifier\n"
7196 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7197 "Display only the bestpath\n"
7198 "Display only multipaths\n")
7200 if (strncmp (argv[0], "m", 1) == 0)
7201 if (strncmp (argv[2], "b", 1) == 0)
7202 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH);
7204 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH);
7206 if (strncmp (argv[2], "b", 1) == 0)
7207 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH);
7209 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH);
7212 ALIAS (show_ip_bgp_ipv4_prefix_pathtype,
7213 show_bgp_ipv4_safi_prefix_pathtype_cmd,
7214 "show bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath)",
7218 "Address Family modifier\n"
7219 "Address Family modifier\n"
7220 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7221 "Display only the bestpath\n"
7222 "Display only multipaths\n")
7224 DEFUN (show_ip_bgp_vpnv4_all_prefix,
7225 show_ip_bgp_vpnv4_all_prefix_cmd,
7226 "show ip bgp vpnv4 all A.B.C.D/M",
7230 "Display VPNv4 NLRI specific information\n"
7231 "Display information about all VPNv4 NLRIs\n"
7232 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7234 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL);
7237 DEFUN (show_ip_bgp_vpnv4_rd_prefix,
7238 show_ip_bgp_vpnv4_rd_prefix_cmd,
7239 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
7243 "Display VPNv4 NLRI specific information\n"
7244 "Display information for a route distinguisher\n"
7245 "VPN Route Distinguisher\n"
7246 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7249 struct prefix_rd prd;
7251 ret = str2prefix_rd (argv[0], &prd);
7254 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7257 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1, BGP_PATH_ALL);
7260 DEFUN (show_ip_bgp_view,
7261 show_ip_bgp_view_cmd,
7262 "show ip bgp view WORD",
7271 /* BGP structure lookup. */
7272 bgp = bgp_lookup_by_name (argv[0]);
7275 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7279 return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
7282 DEFUN (show_ip_bgp_view_route,
7283 show_ip_bgp_view_route_cmd,
7284 "show ip bgp view WORD A.B.C.D",
7290 "Network in the BGP routing table to display\n")
7292 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
7295 DEFUN (show_ip_bgp_view_prefix,
7296 show_ip_bgp_view_prefix_cmd,
7297 "show ip bgp view WORD A.B.C.D/M",
7303 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7305 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
7314 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
7326 DEFUN (show_ipv6_bgp,
7333 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
7337 DEFUN (show_bgp_route,
7339 "show bgp X:X::X:X",
7342 "Network in the BGP routing table to display\n")
7344 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
7347 DEFUN (show_bgp_ipv4_safi,
7348 show_bgp_ipv4_safi_cmd,
7349 "show bgp ipv4 (unicast|multicast)",
7353 "Address Family modifier\n"
7354 "Address Family modifier\n")
7356 if (strncmp (argv[0], "m", 1) == 0)
7357 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
7360 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
7363 DEFUN (show_bgp_ipv4_safi_route,
7364 show_bgp_ipv4_safi_route_cmd,
7365 "show bgp ipv4 (unicast|multicast) A.B.C.D",
7369 "Address Family modifier\n"
7370 "Address Family modifier\n"
7371 "Network in the BGP routing table to display\n")
7373 if (strncmp (argv[0], "m", 1) == 0)
7374 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL);
7376 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
7379 DEFUN (show_bgp_route_pathtype,
7380 show_bgp_route_pathtype_cmd,
7381 "show bgp X:X::X:X (bestpath|multipath)",
7384 "Network in the BGP routing table to display\n"
7385 "Display only the bestpath\n"
7386 "Display only multipaths\n")
7388 if (strncmp (argv[1], "b", 1) == 0)
7389 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH);
7391 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH);
7394 ALIAS (show_bgp_route_pathtype,
7395 show_bgp_ipv6_route_pathtype_cmd,
7396 "show bgp ipv6 X:X::X:X (bestpath|multipath)",
7400 "Network in the BGP routing table to display\n"
7401 "Display only the bestpath\n"
7402 "Display only multipaths\n")
7404 DEFUN (show_bgp_ipv6_safi_route_pathtype,
7405 show_bgp_ipv6_safi_route_pathtype_cmd,
7406 "show bgp ipv6 (unicast|multicast) X:X::X:X (bestpath|multipath)",
7410 "Address Family modifier\n"
7411 "Address Family modifier\n"
7412 "Network in the BGP routing table to display\n"
7413 "Display only the bestpath\n"
7414 "Display only multipaths\n")
7416 if (strncmp (argv[0], "m", 1) == 0)
7417 if (strncmp (argv[2], "b", 1) == 0)
7418 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH);
7420 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH);
7422 if (strncmp (argv[2], "b", 1) == 0)
7423 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH);
7425 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH);
7428 DEFUN (show_bgp_ipv4_vpn_route,
7429 show_bgp_ipv4_vpn_route_cmd,
7430 "show bgp ipv4 vpn A.B.C.D",
7434 "Display VPN NLRI specific information\n"
7435 "Network in the BGP routing table to display\n")
7437 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL);
7440 DEFUN (show_bgp_ipv6_vpn_route,
7441 show_bgp_ipv6_vpn_route_cmd,
7442 "show bgp ipv6 vpn X:X::X:X",
7446 "Display VPN NLRI specific information\n"
7447 "Network in the BGP routing table to display\n")
7449 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL);
7452 DEFUN (show_bgp_ipv4_vpn_rd_route,
7453 show_bgp_ipv4_vpn_rd_route_cmd,
7454 "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D",
7458 "Display VPN NLRI specific information\n"
7459 "Display information for a route distinguisher\n"
7460 "VPN Route Distinguisher\n"
7461 "Network in the BGP routing table to display\n")
7464 struct prefix_rd prd;
7466 ret = str2prefix_rd (argv[0], &prd);
7469 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7472 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL);
7475 DEFUN (show_bgp_ipv6_vpn_rd_route,
7476 show_bgp_ipv6_vpn_rd_route_cmd,
7477 "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn X:X::X:X",
7481 "Display VPN NLRI specific information\n"
7482 "Display information for a route distinguisher\n"
7483 "VPN Route Distinguisher\n"
7484 "Network in the BGP routing table to display\n")
7487 struct prefix_rd prd;
7489 ret = str2prefix_rd (argv[0], &prd);
7492 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7495 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL);
7498 DEFUN (show_bgp_prefix_pathtype,
7499 show_bgp_prefix_pathtype_cmd,
7500 "show bgp X:X::X:X/M (bestpath|multipath)",
7503 "IPv6 prefix <network>/<length>\n"
7504 "Display only the bestpath\n"
7505 "Display only multipaths\n")
7507 if (strncmp (argv[1], "b", 1) == 0)
7508 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH);
7510 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH);
7513 ALIAS (show_bgp_prefix_pathtype,
7514 show_bgp_ipv6_prefix_pathtype_cmd,
7515 "show bgp ipv6 X:X::X:X/M (bestpath|multipath)",
7519 "IPv6 prefix <network>/<length>\n"
7520 "Display only the bestpath\n"
7521 "Display only multipaths\n")
7523 DEFUN (show_bgp_ipv6_safi_prefix_pathtype,
7524 show_bgp_ipv6_safi_prefix_pathtype_cmd,
7525 "show bgp ipv6 (unicast|multicast) X:X::X:X/M (bestpath|multipath)",
7529 "Address Family modifier\n"
7530 "Address Family modifier\n"
7531 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
7532 "Display only the bestpath\n"
7533 "Display only multipaths\n")
7535 if (strncmp (argv[0], "m", 1) == 0)
7536 if (strncmp (argv[2], "b", 1) == 0)
7537 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH);
7539 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH);
7541 if (strncmp (argv[2], "b", 1) == 0)
7542 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH);
7544 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH);
7547 DEFUN (show_bgp_ipv4_encap_route,
7548 show_bgp_ipv4_encap_route_cmd,
7549 "show bgp ipv4 encap A.B.C.D",
7553 "Display ENCAP NLRI specific information\n"
7554 "Network in the BGP routing table to display\n")
7556 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 0, BGP_PATH_ALL);
7559 DEFUN (show_bgp_ipv6_encap_route,
7560 show_bgp_ipv6_encap_route_cmd,
7561 "show bgp ipv6 encap X:X::X:X",
7565 "Display ENCAP NLRI specific information\n"
7566 "Network in the BGP routing table to display\n")
7568 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 0, BGP_PATH_ALL);
7571 DEFUN (show_bgp_ipv4_safi_rd_route,
7572 show_bgp_ipv4_safi_rd_route_cmd,
7573 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D",
7577 "Address Family Modifier\n"
7578 "Address Family Modifier\n"
7579 "Display information for a route distinguisher\n"
7580 "ENCAP Route Distinguisher\n"
7581 "Network in the BGP routing table to display\n")
7584 struct prefix_rd prd;
7587 if (bgp_parse_safi(argv[0], &safi)) {
7588 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7591 ret = str2prefix_rd (argv[1], &prd);
7594 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7597 return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 0, BGP_PATH_ALL);
7600 DEFUN (show_bgp_ipv6_safi_rd_route,
7601 show_bgp_ipv6_safi_rd_route_cmd,
7602 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X",
7606 "Address Family Modifier\n"
7607 "Address Family Modifier\n"
7608 "Display information for a route distinguisher\n"
7609 "ENCAP Route Distinguisher\n"
7610 "Network in the BGP routing table to display\n")
7613 struct prefix_rd prd;
7616 if (bgp_parse_safi(argv[0], &safi)) {
7617 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7620 ret = str2prefix_rd (argv[1], &prd);
7623 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7626 return bgp_show_route (vty, NULL, argv[2], AFI_IP6, SAFI_ENCAP, &prd, 0, BGP_PATH_ALL);
7629 DEFUN (show_bgp_ipv4_prefix,
7630 show_bgp_ipv4_prefix_cmd,
7631 "show bgp ipv4 A.B.C.D/M",
7635 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7637 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
7640 DEFUN (show_bgp_ipv4_safi_prefix,
7641 show_bgp_ipv4_safi_prefix_cmd,
7642 "show bgp ipv4 (unicast|multicast) A.B.C.D/M",
7646 "Address Family modifier\n"
7647 "Address Family modifier\n"
7648 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7650 if (strncmp (argv[0], "m", 1) == 0)
7651 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL);
7653 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
7656 DEFUN (show_bgp_ipv4_vpn_prefix,
7657 show_bgp_ipv4_vpn_prefix_cmd,
7658 "show bgp ipv4 vpn A.B.C.D/M",
7662 "Display VPN NLRI specific information\n"
7663 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7665 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL);
7668 DEFUN (show_bgp_ipv6_vpn_prefix,
7669 show_bgp_ipv6_vpn_prefix_cmd,
7670 "show bgp ipv6 vpn X:X::X:X/M",
7674 "Display VPN NLRI specific information\n"
7675 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7677 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL);
7680 DEFUN (show_bgp_ipv4_encap_prefix,
7681 show_bgp_ipv4_encap_prefix_cmd,
7682 "show bgp ipv4 encap A.B.C.D/M",
7686 "Display ENCAP NLRI specific information\n"
7687 "Display information about ENCAP NLRIs\n"
7688 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7690 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 1, BGP_PATH_ALL);
7693 DEFUN (show_bgp_ipv6_encap_prefix,
7694 show_bgp_ipv6_encap_prefix_cmd,
7695 "show bgp ipv6 encap X:X::X:X/M",
7699 "Display ENCAP NLRI specific information\n"
7700 "Display information about ENCAP NLRIs\n"
7701 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7703 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 1, BGP_PATH_ALL);
7706 DEFUN (show_bgp_ipv4_safi_rd_prefix,
7707 show_bgp_ipv4_safi_rd_prefix_cmd,
7708 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/M",
7712 "Address Family Modifier\n"
7713 "Address Family Modifier\n"
7714 "Display information for a route distinguisher\n"
7715 "ENCAP Route Distinguisher\n"
7716 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7719 struct prefix_rd prd;
7722 if (bgp_parse_safi(argv[0], &safi)) {
7723 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7727 ret = str2prefix_rd (argv[1], &prd);
7730 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7733 return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 1, BGP_PATH_ALL);
7736 DEFUN (show_bgp_ipv6_safi_rd_prefix,
7737 show_bgp_ipv6_safi_rd_prefix_cmd,
7738 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/M",
7742 "Address Family Modifier\n"
7743 "Address Family Modifier\n"
7744 "Display information for a route distinguisher\n"
7745 "ENCAP Route Distinguisher\n"
7746 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7749 struct prefix_rd prd;
7752 if (bgp_parse_safi(argv[0], &safi)) {
7753 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7757 ret = str2prefix_rd (argv[1], &prd);
7760 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7763 return bgp_show_route (vty, NULL, argv[2], AFI_IP6, safi, &prd, 1, BGP_PATH_ALL);
7766 DEFUN (show_bgp_afi_safi_view,
7767 show_bgp_afi_safi_view_cmd,
7768 "show bgp view WORD (ipv4|ipv6) (encap|mulicast|unicast|vpn)",
7775 "Address Family Modifier\n"
7776 "Address Family Modifier\n"
7777 "Address Family Modifier\n"
7778 "Address Family Modifier\n"
7785 if (bgp_parse_afi(argv[1], &afi)) {
7786 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7789 if (bgp_parse_safi(argv[2], &safi)) {
7790 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7794 /* BGP structure lookup. */
7795 bgp = bgp_lookup_by_name (argv[0]);
7798 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7802 return bgp_show (vty, bgp, afi, safi, bgp_show_type_normal, NULL);
7805 DEFUN (show_bgp_view_afi_safi_route,
7806 show_bgp_view_afi_safi_route_cmd,
7807 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D",
7814 "Address Family Modifier\n"
7815 "Address Family Modifier\n"
7816 "Address Family Modifier\n"
7817 "Address Family Modifier\n"
7818 "Network in the BGP routing table to display\n")
7823 if (bgp_parse_afi(argv[1], &afi)) {
7824 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7827 if (bgp_parse_safi(argv[2], &safi)) {
7828 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7831 return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 0, BGP_PATH_ALL);
7834 DEFUN (show_bgp_view_afi_safi_prefix,
7835 show_bgp_view_afi_safi_prefix_cmd,
7836 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D/M",
7843 "Address Family Modifier\n"
7844 "Address Family Modifier\n"
7845 "Address Family Modifier\n"
7846 "Address Family Modifier\n"
7847 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7852 if (bgp_parse_afi(argv[1], &afi)) {
7853 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7856 if (bgp_parse_safi(argv[2], &safi)) {
7857 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7860 return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 1, BGP_PATH_ALL);
7864 DEFUN (show_bgp_afi,
7866 "show bgp (ipv4|ipv6)",
7874 if (bgp_parse_afi(argv[0], &afi)) {
7875 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7878 return bgp_show (vty, NULL, afi, SAFI_UNICAST, bgp_show_type_normal,
7882 DEFUN (show_bgp_ipv6_safi,
7883 show_bgp_ipv6_safi_cmd,
7884 "show bgp ipv6 (unicast|multicast)",
7888 "Address Family modifier\n"
7889 "Address Family modifier\n")
7891 if (strncmp (argv[0], "m", 1) == 0)
7892 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
7895 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
7898 DEFUN (show_bgp_ipv6_route,
7899 show_bgp_ipv6_route_cmd,
7900 "show bgp ipv6 X:X::X:X",
7904 "Network in the BGP routing table to display\n")
7906 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
7909 DEFUN (show_bgp_ipv6_safi_route,
7910 show_bgp_ipv6_safi_route_cmd,
7911 "show bgp ipv6 (unicast|multicast) X:X::X:X",
7915 "Address Family modifier\n"
7916 "Address Family modifier\n"
7917 "Network in the BGP routing table to display\n")
7919 if (strncmp (argv[0], "m", 1) == 0)
7920 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL);
7922 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
7926 DEFUN (show_ipv6_bgp_route,
7927 show_ipv6_bgp_route_cmd,
7928 "show ipv6 bgp X:X::X:X",
7932 "Network in the BGP routing table to display\n")
7934 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
7937 DEFUN (show_bgp_prefix,
7938 show_bgp_prefix_cmd,
7939 "show bgp X:X::X:X/M",
7942 "IPv6 prefix <network>/<length>\n")
7944 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
7949 DEFUN (show_bgp_ipv6_prefix,
7950 show_bgp_ipv6_prefix_cmd,
7951 "show bgp ipv6 X:X::X:X/M",
7955 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7957 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
7959 DEFUN (show_bgp_ipv6_safi_prefix,
7960 show_bgp_ipv6_safi_prefix_cmd,
7961 "show bgp ipv6 (unicast|multicast) X:X::X:X/M",
7965 "Address Family modifier\n"
7966 "Address Family modifier\n"
7967 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7969 if (strncmp (argv[0], "m", 1) == 0)
7970 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL);
7972 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
7976 DEFUN (show_ipv6_bgp_prefix,
7977 show_ipv6_bgp_prefix_cmd,
7978 "show ipv6 bgp X:X::X:X/M",
7982 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7984 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
7987 DEFUN (show_bgp_view,
7989 "show bgp view WORD",
7997 /* BGP structure lookup. */
7998 bgp = bgp_lookup_by_name (argv[0]);
8001 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
8005 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
8008 DEFUN (show_bgp_view_ipv6,
8009 show_bgp_view_ipv6_cmd,
8010 "show bgp view WORD ipv6",
8019 /* BGP structure lookup. */
8020 bgp = bgp_lookup_by_name (argv[0]);
8023 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
8027 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
8030 DEFUN (show_bgp_view_route,
8031 show_bgp_view_route_cmd,
8032 "show bgp view WORD X:X::X:X",
8037 "Network in the BGP routing table to display\n")
8039 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
8042 DEFUN (show_bgp_view_ipv6_route,
8043 show_bgp_view_ipv6_route_cmd,
8044 "show bgp view WORD ipv6 X:X::X:X",
8050 "Network in the BGP routing table to display\n")
8052 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
8056 DEFUN (show_ipv6_mbgp,
8063 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
8068 DEFUN (show_ipv6_mbgp_route,
8069 show_ipv6_mbgp_route_cmd,
8070 "show ipv6 mbgp X:X::X:X",
8074 "Network in the MBGP routing table to display\n")
8076 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL);
8080 DEFUN (show_ipv6_mbgp_prefix,
8081 show_ipv6_mbgp_prefix_cmd,
8082 "show ipv6 mbgp X:X::X:X/M",
8086 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
8088 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL);
8091 DEFUN (show_bgp_view_prefix,
8092 show_bgp_view_prefix_cmd,
8093 "show bgp view WORD X:X::X:X/M",
8098 "IPv6 prefix <network>/<length>\n")
8100 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
8103 DEFUN (show_bgp_view_ipv6_prefix,
8104 show_bgp_view_ipv6_prefix_cmd,
8105 "show bgp view WORD ipv6 X:X::X:X/M",
8111 "IPv6 prefix <network>/<length>\n")
8113 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
8117 bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi,
8118 safi_t safi, enum bgp_show_type type)
8128 b = buffer_new (1024);
8129 for (i = 0; i < argc; i++)
8132 buffer_putc (b, ' ');
8135 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
8140 buffer_putstr (b, argv[i]);
8142 buffer_putc (b, '\0');
8144 regstr = buffer_getstr (b);
8147 regex = bgp_regcomp (regstr);
8148 XFREE(MTYPE_TMP, regstr);
8151 vty_out (vty, "Can't compile regexp %s%s", argv[0],
8156 rc = bgp_show (vty, NULL, afi, safi, type, regex);
8157 bgp_regex_free (regex);
8162 DEFUN (show_ip_bgp_regexp,
8163 show_ip_bgp_regexp_cmd,
8164 "show ip bgp regexp .LINE",
8168 "Display routes matching the AS path regular expression\n"
8169 "A regular-expression to match the BGP AS paths\n")
8171 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
8172 bgp_show_type_regexp);
8175 DEFUN (show_ip_bgp_flap_regexp,
8176 show_ip_bgp_flap_regexp_cmd,
8177 "show ip bgp flap-statistics regexp .LINE",
8181 "Display flap statistics of routes\n"
8182 "Display routes matching the AS path regular expression\n"
8183 "A regular-expression to match the BGP AS paths\n")
8185 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
8186 bgp_show_type_flap_regexp);
8189 ALIAS (show_ip_bgp_flap_regexp,
8190 show_ip_bgp_damp_flap_regexp_cmd,
8191 "show ip bgp dampening flap-statistics regexp .LINE",
8195 "Display detailed information about dampening\n"
8196 "Display flap statistics of routes\n"
8197 "Display routes matching the AS path regular expression\n"
8198 "A regular-expression to match the BGP AS paths\n")
8200 DEFUN (show_ip_bgp_ipv4_regexp,
8201 show_ip_bgp_ipv4_regexp_cmd,
8202 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
8207 "Address Family modifier\n"
8208 "Address Family modifier\n"
8209 "Display routes matching the AS path regular expression\n"
8210 "A regular-expression to match the BGP AS paths\n")
8212 if (strncmp (argv[0], "m", 1) == 0)
8213 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST,
8214 bgp_show_type_regexp);
8216 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
8217 bgp_show_type_regexp);
8220 DEFUN (show_bgp_regexp,
8221 show_bgp_regexp_cmd,
8222 "show bgp regexp .LINE",
8225 "Display routes matching the AS path regular expression\n"
8226 "A regular-expression to match the BGP AS paths\n")
8228 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
8229 bgp_show_type_regexp);
8233 DEFUN (show_ipv6_bgp_regexp,
8234 show_ipv6_bgp_regexp_cmd,
8235 "show ipv6 bgp regexp .LINE",
8239 "Display routes matching the AS path regular expression\n"
8240 "A regular-expression to match the BGP AS paths\n")
8242 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
8243 bgp_show_type_regexp);
8247 DEFUN (show_ipv6_mbgp_regexp,
8248 show_ipv6_mbgp_regexp_cmd,
8249 "show ipv6 mbgp regexp .LINE",
8253 "Display routes matching the AS path regular expression\n"
8254 "A regular-expression to match the MBGP AS paths\n")
8256 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST,
8257 bgp_show_type_regexp);
8260 DEFUN (show_bgp_ipv4_safi_flap_regexp,
8261 show_bgp_ipv4_safi_flap_regexp_cmd,
8262 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE",
8266 "Address Family Modifier\n"
8267 "Address Family Modifier\n"
8268 "Address Family Modifier\n"
8269 "Address Family Modifier\n"
8270 "Display flap statistics of routes\n"
8271 "Display routes matching the AS path regular expression\n"
8272 "A regular-expression to match the BGP AS paths\n")
8276 if (bgp_parse_safi(argv[0], &safi)) {
8277 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
8280 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi,
8281 bgp_show_type_flap_regexp);
8284 ALIAS (show_bgp_ipv4_safi_flap_regexp,
8285 show_bgp_ipv4_safi_damp_flap_regexp_cmd,
8286 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE",
8290 "Address Family Modifier\n"
8291 "Address Family Modifier\n"
8292 "Address Family Modifier\n"
8293 "Address Family Modifier\n"
8294 "Display detailed information about dampening\n"
8295 "Display flap statistics of routes\n"
8296 "Display routes matching the AS path regular expression\n"
8297 "A regular-expression to match the BGP AS paths\n")
8299 DEFUN (show_bgp_ipv6_safi_flap_regexp,
8300 show_bgp_ipv6_safi_flap_regexp_cmd,
8301 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE",
8305 "Address Family Modifier\n"
8306 "Address Family Modifier\n"
8307 "Address Family Modifier\n"
8308 "Address Family Modifier\n"
8309 "Display flap statistics of routes\n"
8310 "Display routes matching the AS path regular expression\n"
8311 "A regular-expression to match the BGP AS paths\n")
8315 if (bgp_parse_safi(argv[0], &safi)) {
8316 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
8319 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi,
8320 bgp_show_type_flap_regexp);
8323 ALIAS (show_bgp_ipv6_safi_flap_regexp,
8324 show_bgp_ipv6_safi_damp_flap_regexp_cmd,
8325 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE",
8329 "Address Family Modifier\n"
8330 "Address Family Modifier\n"
8331 "Address Family Modifier\n"
8332 "Address Family Modifier\n"
8333 "Display detailed information about dampening\n"
8334 "Display flap statistics of routes\n"
8335 "Display routes matching the AS path regular expression\n"
8336 "A regular-expression to match the BGP AS paths\n")
8338 DEFUN (show_bgp_ipv4_safi_regexp,
8339 show_bgp_ipv4_safi_regexp_cmd,
8340 "show bgp ipv4 (encap|multicast|unicast|vpn) regexp .LINE",
8344 "Address Family modifier\n"
8345 "Address Family modifier\n"
8346 "Address Family modifier\n"
8347 "Address Family modifier\n"
8348 "Display routes matching the AS path regular expression\n"
8349 "A regular-expression to match the BGP AS paths\n")
8352 if (bgp_parse_safi(argv[0], &safi)) {
8353 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8357 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi,
8358 bgp_show_type_regexp);
8361 DEFUN (show_bgp_ipv6_safi_regexp,
8362 show_bgp_ipv6_safi_regexp_cmd,
8363 "show bgp ipv6 (encap|multicast|unicast|vpn) regexp .LINE",
8367 "Address Family modifier\n"
8368 "Address Family modifier\n"
8369 "Address Family modifier\n"
8370 "Address Family modifier\n"
8371 "Display routes matching the AS path regular expression\n"
8372 "A regular-expression to match the BGP AS paths\n")
8375 if (bgp_parse_safi(argv[0], &safi)) {
8376 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8380 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi,
8381 bgp_show_type_regexp);
8384 DEFUN (show_bgp_ipv6_regexp,
8385 show_bgp_ipv6_regexp_cmd,
8386 "show bgp ipv6 regexp .LINE",
8390 "Display routes matching the AS path regular expression\n"
8391 "A regular-expression to match the BGP AS paths\n")
8393 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
8394 bgp_show_type_regexp);
8398 bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi,
8399 safi_t safi, enum bgp_show_type type)
8401 struct prefix_list *plist;
8403 plist = prefix_list_lookup (afi, prefix_list_str);
8406 vty_out (vty, "%% %s is not a valid prefix-list name%s",
8407 prefix_list_str, VTY_NEWLINE);
8411 return bgp_show (vty, NULL, afi, safi, type, plist);
8413 DEFUN (show_ip_bgp_prefix_list,
8414 show_ip_bgp_prefix_list_cmd,
8415 "show ip bgp prefix-list WORD",
8419 "Display routes conforming to the prefix-list\n"
8420 "IP prefix-list name\n")
8422 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8423 bgp_show_type_prefix_list);
8426 DEFUN (show_ip_bgp_flap_prefix_list,
8427 show_ip_bgp_flap_prefix_list_cmd,
8428 "show ip bgp flap-statistics prefix-list WORD",
8432 "Display flap statistics of routes\n"
8433 "Display routes conforming to the prefix-list\n"
8434 "IP prefix-list name\n")
8436 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8437 bgp_show_type_flap_prefix_list);
8440 ALIAS (show_ip_bgp_flap_prefix_list,
8441 show_ip_bgp_damp_flap_prefix_list_cmd,
8442 "show ip bgp dampening flap-statistics prefix-list WORD",
8446 "Display detailed information about dampening\n"
8447 "Display flap statistics of routes\n"
8448 "Display routes conforming to the prefix-list\n"
8449 "IP prefix-list name\n")
8451 DEFUN (show_ip_bgp_ipv4_prefix_list,
8452 show_ip_bgp_ipv4_prefix_list_cmd,
8453 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
8458 "Address Family modifier\n"
8459 "Address Family modifier\n"
8460 "Display routes conforming to the prefix-list\n"
8461 "IP prefix-list name\n")
8463 if (strncmp (argv[0], "m", 1) == 0)
8464 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8465 bgp_show_type_prefix_list);
8467 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
8468 bgp_show_type_prefix_list);
8471 DEFUN (show_bgp_prefix_list,
8472 show_bgp_prefix_list_cmd,
8473 "show bgp prefix-list WORD",
8476 "Display routes conforming to the prefix-list\n"
8477 "IPv6 prefix-list name\n")
8479 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8480 bgp_show_type_prefix_list);
8483 ALIAS (show_bgp_prefix_list,
8484 show_bgp_ipv6_prefix_list_cmd,
8485 "show bgp ipv6 prefix-list WORD",
8489 "Display routes conforming to the prefix-list\n"
8490 "IPv6 prefix-list name\n")
8493 DEFUN (show_ipv6_bgp_prefix_list,
8494 show_ipv6_bgp_prefix_list_cmd,
8495 "show ipv6 bgp prefix-list WORD",
8499 "Display routes matching the prefix-list\n"
8500 "IPv6 prefix-list name\n")
8502 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8503 bgp_show_type_prefix_list);
8507 DEFUN (show_ipv6_mbgp_prefix_list,
8508 show_ipv6_mbgp_prefix_list_cmd,
8509 "show ipv6 mbgp prefix-list WORD",
8513 "Display routes matching the prefix-list\n"
8514 "IPv6 prefix-list name\n")
8516 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
8517 bgp_show_type_prefix_list);
8520 DEFUN (show_bgp_ipv4_prefix_list,
8521 show_bgp_ipv4_prefix_list_cmd,
8522 "show bgp ipv4 prefix-list WORD",
8526 "Display routes conforming to the prefix-list\n"
8527 "IP prefix-list name\n")
8529 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8530 bgp_show_type_prefix_list);
8533 DEFUN (show_bgp_ipv4_safi_flap_prefix_list,
8534 show_bgp_ipv4_safi_flap_prefix_list_cmd,
8535 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD",
8539 "Address Family Modifier\n"
8540 "Address Family Modifier\n"
8541 "Address Family Modifier\n"
8542 "Address Family Modifier\n"
8543 "Display flap statistics of routes\n"
8544 "Display routes conforming to the prefix-list\n"
8545 "IP prefix-list name\n")
8548 if (bgp_parse_safi(argv[0], &safi)) {
8549 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8552 return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi,
8553 bgp_show_type_flap_prefix_list);
8556 ALIAS (show_bgp_ipv4_safi_flap_prefix_list,
8557 show_bgp_ipv4_safi_damp_flap_prefix_list_cmd,
8558 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD",
8562 "Address Family Modifier\n"
8563 "Address Family Modifier\n"
8564 "Address Family Modifier\n"
8565 "Address Family Modifier\n"
8566 "Display detailed information about dampening\n"
8567 "Display flap statistics of routes\n"
8568 "Display routes conforming to the prefix-list\n"
8569 "IP prefix-list name\n")
8571 DEFUN (show_bgp_ipv6_safi_flap_prefix_list,
8572 show_bgp_ipv6_safi_flap_prefix_list_cmd,
8573 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD",
8577 "Address Family Modifier\n"
8578 "Address Family Modifier\n"
8579 "Address Family Modifier\n"
8580 "Address Family Modifier\n"
8581 "Display flap statistics of routes\n"
8582 "Display routes conforming to the prefix-list\n"
8583 "IP prefix-list name\n")
8586 if (bgp_parse_safi(argv[0], &safi)) {
8587 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8590 return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi,
8591 bgp_show_type_flap_prefix_list);
8593 ALIAS (show_bgp_ipv6_safi_flap_prefix_list,
8594 show_bgp_ipv6_safi_damp_flap_prefix_list_cmd,
8595 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD",
8599 "Address Family Modifier\n"
8600 "Address Family Modifier\n"
8601 "Address Family Modifier\n"
8602 "Address Family Modifier\n"
8603 "Display detailed information about dampening\n"
8604 "Display flap statistics of routes\n"
8605 "Display routes conforming to the prefix-list\n"
8606 "IP prefix-list name\n")
8608 DEFUN (show_bgp_ipv4_safi_prefix_list,
8609 show_bgp_ipv4_safi_prefix_list_cmd,
8610 "show bgp ipv4 (encap|multicast|unicast|vpn) prefix-list WORD",
8614 "Address Family modifier\n"
8615 "Address Family modifier\n"
8616 "Address Family modifier\n"
8617 "Address Family modifier\n"
8618 "Display routes conforming to the prefix-list\n"
8619 "IP prefix-list name\n")
8622 if (bgp_parse_safi(argv[0], &safi)) {
8623 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8626 return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi,
8627 bgp_show_type_prefix_list);
8630 DEFUN (show_bgp_ipv6_safi_prefix_list,
8631 show_bgp_ipv6_safi_prefix_list_cmd,
8632 "show bgp ipv6 (encap|multicast|unicast|vpn) prefix-list WORD",
8636 "Address Family modifier\n"
8637 "Address Family modifier\n"
8638 "Address Family modifier\n"
8639 "Address Family modifier\n"
8640 "Display routes conforming to the prefix-list\n"
8641 "IP prefix-list name\n")
8644 if (bgp_parse_safi(argv[0], &safi)) {
8645 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8648 return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi,
8649 bgp_show_type_prefix_list);
8653 bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi,
8654 safi_t safi, enum bgp_show_type type)
8656 struct as_list *as_list;
8658 as_list = as_list_lookup (filter);
8659 if (as_list == NULL)
8661 vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE);
8665 return bgp_show (vty, NULL, afi, safi, type, as_list);
8668 DEFUN (show_ip_bgp_filter_list,
8669 show_ip_bgp_filter_list_cmd,
8670 "show ip bgp filter-list WORD",
8674 "Display routes conforming to the filter-list\n"
8675 "Regular expression access list name\n")
8677 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8678 bgp_show_type_filter_list);
8681 DEFUN (show_ip_bgp_flap_filter_list,
8682 show_ip_bgp_flap_filter_list_cmd,
8683 "show ip bgp flap-statistics filter-list WORD",
8687 "Display flap statistics of routes\n"
8688 "Display routes conforming to the filter-list\n"
8689 "Regular expression access list name\n")
8691 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8692 bgp_show_type_flap_filter_list);
8695 ALIAS (show_ip_bgp_flap_filter_list,
8696 show_ip_bgp_damp_flap_filter_list_cmd,
8697 "show ip bgp dampening flap-statistics filter-list WORD",
8701 "Display detailed information about dampening\n"
8702 "Display flap statistics of routes\n"
8703 "Display routes conforming to the filter-list\n"
8704 "Regular expression access list name\n")
8706 DEFUN (show_ip_bgp_ipv4_filter_list,
8707 show_ip_bgp_ipv4_filter_list_cmd,
8708 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
8713 "Address Family modifier\n"
8714 "Address Family modifier\n"
8715 "Display routes conforming to the filter-list\n"
8716 "Regular expression access list name\n")
8718 if (strncmp (argv[0], "m", 1) == 0)
8719 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8720 bgp_show_type_filter_list);
8722 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
8723 bgp_show_type_filter_list);
8726 DEFUN (show_bgp_filter_list,
8727 show_bgp_filter_list_cmd,
8728 "show bgp filter-list WORD",
8731 "Display routes conforming to the filter-list\n"
8732 "Regular expression access list name\n")
8734 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8735 bgp_show_type_filter_list);
8739 DEFUN (show_ipv6_bgp_filter_list,
8740 show_ipv6_bgp_filter_list_cmd,
8741 "show ipv6 bgp filter-list WORD",
8745 "Display routes conforming to the filter-list\n"
8746 "Regular expression access list name\n")
8748 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8749 bgp_show_type_filter_list);
8753 DEFUN (show_ipv6_mbgp_filter_list,
8754 show_ipv6_mbgp_filter_list_cmd,
8755 "show ipv6 mbgp filter-list WORD",
8759 "Display routes conforming to the filter-list\n"
8760 "Regular expression access list name\n")
8762 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
8763 bgp_show_type_filter_list);
8766 DEFUN (show_ip_bgp_dampening_info,
8767 show_ip_bgp_dampening_params_cmd,
8768 "show ip bgp dampening parameters",
8772 "Display detailed information about dampening\n"
8773 "Display detail of configured dampening parameters\n")
8775 return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST);
8778 DEFUN (show_bgp_ipv4_filter_list,
8779 show_bgp_ipv4_filter_list_cmd,
8780 "show bgp ipv4 filter-list WORD",
8784 "Display routes conforming to the filter-list\n"
8785 "Regular expression access list name\n")
8787 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8788 bgp_show_type_filter_list);
8791 DEFUN (show_bgp_ipv4_safi_flap_filter_list,
8792 show_bgp_ipv4_safi_flap_filter_list_cmd,
8793 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD",
8797 "Address Family modifier\n"
8798 "Address Family modifier\n"
8799 "Address Family modifier\n"
8800 "Address Family modifier\n"
8801 "Display flap statistics of routes\n"
8802 "Display routes conforming to the filter-list\n"
8803 "Regular expression access list name\n")
8807 if (bgp_parse_safi(argv[0], &safi)) {
8808 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8811 return bgp_show_filter_list (vty, argv[1], AFI_IP, safi,
8812 bgp_show_type_flap_filter_list);
8815 ALIAS (show_bgp_ipv4_safi_flap_filter_list,
8816 show_bgp_ipv4_safi_damp_flap_filter_list_cmd,
8817 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD",
8821 "Address Family modifier\n"
8822 "Address Family modifier\n"
8823 "Address Family modifier\n"
8824 "Address Family modifier\n"
8825 "Display detailed information about dampening\n"
8826 "Display flap statistics of routes\n"
8827 "Display routes conforming to the filter-list\n"
8828 "Regular expression access list name\n")
8830 DEFUN (show_bgp_ipv6_safi_flap_filter_list,
8831 show_bgp_ipv6_safi_flap_filter_list_cmd,
8832 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD",
8836 "Address Family modifier\n"
8837 "Address Family modifier\n"
8838 "Address Family modifier\n"
8839 "Address Family modifier\n"
8840 "Display flap statistics of routes\n"
8841 "Display routes conforming to the filter-list\n"
8842 "Regular expression access list name\n")
8846 if (bgp_parse_safi(argv[0], &safi)) {
8847 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8850 return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi,
8851 bgp_show_type_flap_filter_list);
8853 ALIAS (show_bgp_ipv6_safi_flap_filter_list,
8854 show_bgp_ipv6_safi_damp_flap_filter_list_cmd,
8855 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD",
8859 "Address Family modifier\n"
8860 "Address Family modifier\n"
8861 "Address Family modifier\n"
8862 "Address Family modifier\n"
8863 "Display detailed information about dampening\n"
8864 "Display flap statistics of routes\n"
8865 "Display routes conforming to the filter-list\n"
8866 "Regular expression access list name\n")
8868 DEFUN (show_bgp_ipv4_safi_filter_list,
8869 show_bgp_ipv4_safi_filter_list_cmd,
8870 "show bgp ipv4 (encap|multicast|unicast|vpn) filter-list WORD",
8873 "Address Family modifier\n"
8874 "Address Family modifier\n"
8875 "Address Family modifier\n"
8876 "Address Family modifier\n"
8877 "Display routes conforming to the filter-list\n"
8878 "Regular expression access list name\n")
8882 if (bgp_parse_safi(argv[0], &safi)) {
8883 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8886 return bgp_show_filter_list (vty, argv[1], AFI_IP, safi,
8887 bgp_show_type_filter_list);
8890 DEFUN (show_bgp_ipv6_safi_filter_list,
8891 show_bgp_ipv6_safi_filter_list_cmd,
8892 "show bgp ipv6 (encap|multicast|unicast|vpn) filter-list WORD",
8895 "Address Family modifier\n"
8896 "Address Family modifier\n"
8897 "Address Family modifier\n"
8898 "Address Family modifier\n"
8899 "Display routes conforming to the filter-list\n"
8900 "Regular expression access list name\n")
8904 if (bgp_parse_safi(argv[0], &safi)) {
8905 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8908 return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi,
8909 bgp_show_type_filter_list);
8912 DEFUN (show_bgp_ipv6_filter_list,
8913 show_bgp_ipv6_filter_list_cmd,
8914 "show bgp ipv6 filter-list WORD",
8918 "Display routes conforming to the filter-list\n"
8919 "Regular expression access list name\n")
8921 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8922 bgp_show_type_filter_list);
8926 DEFUN (show_ip_bgp_ipv4_dampening_parameters,
8927 show_ip_bgp_ipv4_dampening_parameters_cmd,
8928 "show ip bgp ipv4 (unicast|multicast) dampening parameters",
8933 "Address Family modifier\n"
8934 "Address Family modifier\n"
8935 "Display detailed information about dampening\n"
8936 "Display detail of configured dampening parameters\n")
8938 if (strncmp(argv[0], "m", 1) == 0)
8939 return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_MULTICAST);
8941 return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST);
8945 DEFUN (show_ip_bgp_ipv4_dampening_flap_stats,
8946 show_ip_bgp_ipv4_dampening_flap_stats_cmd,
8947 "show ip bgp ipv4 (unicast|multicast) dampening flap-statistics",
8952 "Address Family modifier\n"
8953 "Address Family modifier\n"
8954 "Display detailed information about dampening\n"
8955 "Display flap statistics of routes\n")
8957 if (strncmp(argv[0], "m", 1) == 0)
8958 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8959 bgp_show_type_flap_statistics, NULL);
8961 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8962 bgp_show_type_flap_statistics, NULL);
8965 DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths,
8966 show_ip_bgp_ipv4_dampening_dampd_paths_cmd,
8967 "show ip bgp ipv4 (unicast|multicast) dampening dampened-paths",
8972 "Address Family modifier\n"
8973 "Address Family modifier\n"
8974 "Display detailed information about dampening\n"
8975 "Display paths suppressed due to dampening\n")
8977 if (strncmp(argv[0], "m", 1) == 0)
8978 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8979 bgp_show_type_dampend_paths, NULL);
8981 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8982 bgp_show_type_dampend_paths, NULL);
8986 bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi,
8987 safi_t safi, enum bgp_show_type type)
8989 struct route_map *rmap;
8991 rmap = route_map_lookup_by_name (rmap_str);
8994 vty_out (vty, "%% %s is not a valid route-map name%s",
8995 rmap_str, VTY_NEWLINE);
8999 return bgp_show (vty, NULL, afi, safi, type, rmap);
9002 DEFUN (show_ip_bgp_route_map,
9003 show_ip_bgp_route_map_cmd,
9004 "show ip bgp route-map WORD",
9008 "Display routes matching the route-map\n"
9009 "A route-map to match on\n")
9011 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
9012 bgp_show_type_route_map);
9015 DEFUN (show_ip_bgp_flap_route_map,
9016 show_ip_bgp_flap_route_map_cmd,
9017 "show ip bgp flap-statistics route-map WORD",
9021 "Display flap statistics of routes\n"
9022 "Display routes matching the route-map\n"
9023 "A route-map to match on\n")
9025 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
9026 bgp_show_type_flap_route_map);
9029 ALIAS (show_ip_bgp_flap_route_map,
9030 show_ip_bgp_damp_flap_route_map_cmd,
9031 "show ip bgp dampening flap-statistics route-map WORD",
9035 "Display detailed information about dampening\n"
9036 "Display flap statistics of routes\n"
9037 "Display routes matching the route-map\n"
9038 "A route-map to match on\n")
9040 DEFUN (show_ip_bgp_ipv4_route_map,
9041 show_ip_bgp_ipv4_route_map_cmd,
9042 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
9047 "Address Family modifier\n"
9048 "Address Family modifier\n"
9049 "Display routes matching the route-map\n"
9050 "A route-map to match on\n")
9052 if (strncmp (argv[0], "m", 1) == 0)
9053 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST,
9054 bgp_show_type_route_map);
9056 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST,
9057 bgp_show_type_route_map);
9060 DEFUN (show_bgp_route_map,
9061 show_bgp_route_map_cmd,
9062 "show bgp route-map WORD",
9065 "Display routes matching the route-map\n"
9066 "A route-map to match on\n")
9068 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
9069 bgp_show_type_route_map);
9072 DEFUN (show_ip_bgp_cidr_only,
9073 show_ip_bgp_cidr_only_cmd,
9074 "show ip bgp cidr-only",
9078 "Display only routes with non-natural netmasks\n")
9080 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9081 bgp_show_type_cidr_only, NULL);
9084 DEFUN (show_ip_bgp_flap_cidr_only,
9085 show_ip_bgp_flap_cidr_only_cmd,
9086 "show ip bgp flap-statistics cidr-only",
9090 "Display flap statistics of routes\n"
9091 "Display only routes with non-natural netmasks\n")
9093 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9094 bgp_show_type_flap_cidr_only, NULL);
9097 ALIAS (show_ip_bgp_flap_cidr_only,
9098 show_ip_bgp_damp_flap_cidr_only_cmd,
9099 "show ip bgp dampening flap-statistics cidr-only",
9103 "Display detailed information about dampening\n"
9104 "Display flap statistics of routes\n"
9105 "Display only routes with non-natural netmasks\n")
9107 DEFUN (show_ip_bgp_ipv4_cidr_only,
9108 show_ip_bgp_ipv4_cidr_only_cmd,
9109 "show ip bgp ipv4 (unicast|multicast) cidr-only",
9114 "Address Family modifier\n"
9115 "Address Family modifier\n"
9116 "Display only routes with non-natural netmasks\n")
9118 if (strncmp (argv[0], "m", 1) == 0)
9119 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
9120 bgp_show_type_cidr_only, NULL);
9122 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9123 bgp_show_type_cidr_only, NULL);
9126 DEFUN (show_ip_bgp_community_all,
9127 show_ip_bgp_community_all_cmd,
9128 "show ip bgp community",
9132 "Display routes matching the communities\n")
9134 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9135 bgp_show_type_community_all, NULL);
9138 DEFUN (show_ip_bgp_ipv4_community_all,
9139 show_ip_bgp_ipv4_community_all_cmd,
9140 "show ip bgp ipv4 (unicast|multicast) community",
9145 "Address Family modifier\n"
9146 "Address Family modifier\n"
9147 "Display routes matching the communities\n")
9149 if (strncmp (argv[0], "m", 1) == 0)
9150 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
9151 bgp_show_type_community_all, NULL);
9153 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9154 bgp_show_type_community_all, NULL);
9157 DEFUN (show_bgp_community_all,
9158 show_bgp_community_all_cmd,
9159 "show bgp community",
9162 "Display routes matching the communities\n")
9164 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
9165 bgp_show_type_community_all, NULL);
9168 ALIAS (show_bgp_community_all,
9169 show_bgp_ipv6_community_all_cmd,
9170 "show bgp ipv6 community",
9174 "Display routes matching the communities\n")
9177 DEFUN (show_ipv6_bgp_community_all,
9178 show_ipv6_bgp_community_all_cmd,
9179 "show ipv6 bgp community",
9183 "Display routes matching the communities\n")
9185 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
9186 bgp_show_type_community_all, NULL);
9190 DEFUN (show_ipv6_mbgp_community_all,
9191 show_ipv6_mbgp_community_all_cmd,
9192 "show ipv6 mbgp community",
9196 "Display routes matching the communities\n")
9198 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST,
9199 bgp_show_type_community_all, NULL);
9202 /* large-community */
9203 DEFUN (show_ip_bgp_lcommunity_all,
9204 show_ip_bgp_lcommunity_all_cmd,
9205 "show ip bgp large-community",
9209 "Display routes matching the large-communities\n")
9211 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9212 bgp_show_type_lcommunity_all, NULL);
9215 DEFUN (show_ip_bgp_ipv4_lcommunity_all,
9216 show_ip_bgp_ipv4_lcommunity_all_cmd,
9217 "show ip bgp ipv4 (unicast|multicast) large-community",
9222 "Address Family modifier\n"
9223 "Address Family modifier\n"
9224 "Display routes matching the large-communities\n")
9226 if (strncmp (argv[0], "m", 1) == 0)
9227 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
9228 bgp_show_type_lcommunity_all, NULL);
9230 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9231 bgp_show_type_lcommunity_all, NULL);
9234 DEFUN (show_bgp_lcommunity_all,
9235 show_bgp_lcommunity_all_cmd,
9236 "show bgp large-community",
9239 "Display routes matching the large-communities\n")
9241 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
9242 bgp_show_type_lcommunity_all, NULL);
9245 ALIAS (show_bgp_lcommunity_all,
9246 show_bgp_ipv6_lcommunity_all_cmd,
9247 "show bgp ipv6 large-community",
9251 "Display routes matching the large-communities\n")
9254 DEFUN (show_ipv6_bgp_lcommunity_all,
9255 show_ipv6_bgp_lcommunity_all_cmd,
9256 "show ipv6 bgp large-community",
9260 "Display routes matching the large-communities\n")
9262 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
9263 bgp_show_type_lcommunity_all, NULL);
9267 DEFUN (show_ipv6_mbgp_lcommunity_all,
9268 show_ipv6_mbgp_lcommunity_all_cmd,
9269 "show ipv6 mbgp large-community",
9273 "Display routes matching the large-communities\n")
9275 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST,
9276 bgp_show_type_lcommunity_all, NULL);
9280 DEFUN (show_bgp_ipv4_route_map,
9281 show_bgp_ipv4_route_map_cmd,
9282 "show bgp ipv4 route-map WORD",
9286 "Display routes matching the route-map\n"
9287 "A route-map to match on\n")
9289 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
9290 bgp_show_type_route_map);
9293 DEFUN (show_bgp_ipv4_safi_flap_route_map,
9294 show_bgp_ipv4_safi_flap_route_map_cmd,
9295 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics route-map WORD",
9299 "Address Family Modifier\n"
9300 "Address Family Modifier\n"
9301 "Address Family Modifier\n"
9302 "Address Family Modifier\n"
9303 "Display flap statistics of routes\n"
9304 "Display routes matching the route-map\n"
9305 "A route-map to match on\n")
9308 if (bgp_parse_safi(argv[0], &safi)) {
9309 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9312 return bgp_show_route_map (vty, argv[1], AFI_IP, safi,
9313 bgp_show_type_flap_route_map);
9316 ALIAS (show_bgp_ipv4_safi_flap_route_map,
9317 show_bgp_ipv4_safi_damp_flap_route_map_cmd,
9318 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD",
9322 "Address Family Modifier\n"
9323 "Address Family Modifier\n"
9324 "Address Family Modifier\n"
9325 "Address Family Modifier\n"
9326 "Display detailed information about dampening\n"
9327 "Display flap statistics of routes\n"
9328 "Display routes matching the route-map\n"
9329 "A route-map to match on\n")
9331 DEFUN (show_bgp_ipv6_safi_flap_route_map,
9332 show_bgp_ipv6_safi_flap_route_map_cmd,
9333 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics route-map WORD",
9337 "Address Family Modifier\n"
9338 "Address Family Modifier\n"
9339 "Address Family Modifier\n"
9340 "Address Family Modifier\n"
9341 "Display flap statistics of routes\n"
9342 "Display routes matching the route-map\n"
9343 "A route-map to match on\n")
9346 if (bgp_parse_safi(argv[0], &safi)) {
9347 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9350 return bgp_show_route_map (vty, argv[1], AFI_IP6, safi,
9351 bgp_show_type_flap_route_map);
9353 ALIAS (show_bgp_ipv6_safi_flap_route_map,
9354 show_bgp_ipv6_safi_damp_flap_route_map_cmd,
9355 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD",
9359 "Address Family Modifier\n"
9360 "Address Family Modifier\n"
9361 "Address Family Modifier\n"
9362 "Address Family Modifier\n"
9363 "Display detailed information about dampening\n"
9364 "Display flap statistics of routes\n"
9365 "Display routes matching the route-map\n"
9366 "A route-map to match on\n")
9368 DEFUN (show_bgp_ipv4_safi_route_map,
9369 show_bgp_ipv4_safi_route_map_cmd,
9370 "show bgp ipv4 (encap|multicast|unicast|vpn) route-map WORD",
9374 "Address Family modifier\n"
9375 "Address Family modifier\n"
9376 "Address Family modifier\n"
9377 "Address Family modifier\n"
9378 "Display routes matching the route-map\n"
9379 "A route-map to match on\n")
9382 if (bgp_parse_safi(argv[0], &safi)) {
9383 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9386 return bgp_show_route_map (vty, argv[1], AFI_IP, safi,
9387 bgp_show_type_route_map);
9390 DEFUN (show_bgp_ipv6_safi_route_map,
9391 show_bgp_ipv6_safi_route_map_cmd,
9392 "show bgp ipv6 (encap|multicast|unicast|vpn) route-map WORD",
9396 "Address Family modifier\n"
9397 "Address Family modifier\n"
9398 "Address Family modifier\n"
9399 "Address Family modifier\n"
9400 "Display routes matching the route-map\n"
9401 "A route-map to match on\n")
9404 if (bgp_parse_safi(argv[0], &safi)) {
9405 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9408 return bgp_show_route_map (vty, argv[1], AFI_IP6, safi,
9409 bgp_show_type_route_map);
9412 DEFUN (show_bgp_ipv6_route_map,
9413 show_bgp_ipv6_route_map_cmd,
9414 "show bgp ipv6 route-map WORD",
9418 "Display routes matching the route-map\n"
9419 "A route-map to match on\n")
9421 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
9422 bgp_show_type_route_map);
9425 DEFUN (show_bgp_ipv4_cidr_only,
9426 show_bgp_ipv4_cidr_only_cmd,
9427 "show bgp ipv4 cidr-only",
9431 "Display only routes with non-natural netmasks\n")
9433 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9434 bgp_show_type_cidr_only, NULL);
9437 DEFUN (show_bgp_ipv4_safi_flap_cidr_only,
9438 show_bgp_ipv4_safi_flap_cidr_only_cmd,
9439 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics cidr-only",
9443 "Address Family Modifier\n"
9444 "Address Family Modifier\n"
9445 "Address Family Modifier\n"
9446 "Address Family Modifier\n"
9447 "Display flap statistics of routes\n"
9448 "Display only routes with non-natural netmasks\n")
9452 if (bgp_parse_safi(argv[0], &safi)) {
9453 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9456 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_cidr_only, NULL);
9459 ALIAS (show_bgp_ipv4_safi_flap_cidr_only,
9460 show_bgp_ipv4_safi_damp_flap_cidr_only_cmd,
9461 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics cidr-only",
9465 "Address Family Modifier\n"
9466 "Address Family Modifier\n"
9467 "Address Family Modifier\n"
9468 "Address Family Modifier\n"
9469 "Display detailed information about dampening\n"
9470 "Display flap statistics of routes\n"
9471 "Display only routes with non-natural netmasks\n")
9473 DEFUN (show_bgp_ipv4_safi_cidr_only,
9474 show_bgp_ipv4_safi_cidr_only_cmd,
9475 "show bgp ipv4 (unicast|multicast) cidr-only",
9479 "Address Family modifier\n"
9480 "Address Family modifier\n"
9481 "Display only routes with non-natural netmasks\n")
9483 if (strncmp (argv[0], "m", 1) == 0)
9484 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
9485 bgp_show_type_cidr_only, NULL);
9487 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9488 bgp_show_type_cidr_only, NULL);
9492 DEFUN (show_bgp_afi_safi_community_all,
9493 show_bgp_afi_safi_community_all_cmd,
9494 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) community",
9499 "Address Family modifier\n"
9500 "Address Family modifier\n"
9501 "Address Family modifier\n"
9502 "Address Family modifier\n"
9503 "Display routes matching the communities\n")
9508 if (bgp_parse_afi(argv[0], &afi)) {
9509 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
9512 if (bgp_parse_safi(argv[1], &safi)) {
9513 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
9517 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL);
9519 DEFUN (show_bgp_afi_community_all,
9520 show_bgp_afi_community_all_cmd,
9521 "show bgp (ipv4|ipv6) community",
9526 "Display routes matching the communities\n")
9529 safi_t safi = SAFI_UNICAST;
9531 if (bgp_parse_afi(argv[0], &afi)) {
9532 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
9535 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL);
9539 bgp_show_community (struct vty *vty, const char *view_name, int argc,
9540 const char **argv, int exact, afi_t afi, safi_t safi)
9542 struct community *com;
9549 /* BGP structure lookup */
9552 bgp = bgp_lookup_by_name (view_name);
9555 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
9561 bgp = bgp_get_default ();
9564 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
9569 b = buffer_new (1024);
9570 for (i = 0; i < argc; i++)
9573 buffer_putc (b, ' ');
9576 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
9581 buffer_putstr (b, argv[i]);
9583 buffer_putc (b, '\0');
9585 str = buffer_getstr (b);
9588 com = community_str2com (str);
9589 XFREE (MTYPE_TMP, str);
9592 vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE);
9596 rv = bgp_show (vty, bgp, afi, safi,
9597 (exact ? bgp_show_type_community_exact :
9598 bgp_show_type_community), com);
9599 community_free(com);
9603 DEFUN (show_ip_bgp_community,
9604 show_ip_bgp_community_cmd,
9605 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
9609 "Display routes matching the communities\n"
9610 "community number\n"
9611 "Do not send outside local AS (well-known community)\n"
9612 "Do not advertise to any peer (well-known community)\n"
9613 "Do not export to next AS (well-known community)\n")
9615 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
9618 ALIAS (show_ip_bgp_community,
9619 show_ip_bgp_community2_cmd,
9620 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9624 "Display routes matching the communities\n"
9625 "community number\n"
9626 "Do not send outside local AS (well-known community)\n"
9627 "Do not advertise to any peer (well-known community)\n"
9628 "Do not export to next AS (well-known community)\n"
9629 "community number\n"
9630 "Do not send outside local AS (well-known community)\n"
9631 "Do not advertise to any peer (well-known community)\n"
9632 "Do not export to next AS (well-known community)\n")
9634 ALIAS (show_ip_bgp_community,
9635 show_ip_bgp_community3_cmd,
9636 "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)",
9640 "Display routes matching the communities\n"
9641 "community number\n"
9642 "Do not send outside local AS (well-known community)\n"
9643 "Do not advertise to any peer (well-known community)\n"
9644 "Do not export to next AS (well-known community)\n"
9645 "community number\n"
9646 "Do not send outside local AS (well-known community)\n"
9647 "Do not advertise to any peer (well-known community)\n"
9648 "Do not export to next AS (well-known community)\n"
9649 "community number\n"
9650 "Do not send outside local AS (well-known community)\n"
9651 "Do not advertise to any peer (well-known community)\n"
9652 "Do not export to next AS (well-known community)\n")
9654 ALIAS (show_ip_bgp_community,
9655 show_ip_bgp_community4_cmd,
9656 "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)",
9660 "Display routes matching the communities\n"
9661 "community number\n"
9662 "Do not send outside local AS (well-known community)\n"
9663 "Do not advertise to any peer (well-known community)\n"
9664 "Do not export to next AS (well-known community)\n"
9665 "community number\n"
9666 "Do not send outside local AS (well-known community)\n"
9667 "Do not advertise to any peer (well-known community)\n"
9668 "Do not export to next AS (well-known community)\n"
9669 "community number\n"
9670 "Do not send outside local AS (well-known community)\n"
9671 "Do not advertise to any peer (well-known community)\n"
9672 "Do not export to next AS (well-known community)\n"
9673 "community number\n"
9674 "Do not send outside local AS (well-known community)\n"
9675 "Do not advertise to any peer (well-known community)\n"
9676 "Do not export to next AS (well-known community)\n")
9678 DEFUN (show_ip_bgp_ipv4_community,
9679 show_ip_bgp_ipv4_community_cmd,
9680 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
9685 "Address Family modifier\n"
9686 "Address Family modifier\n"
9687 "Display routes matching the communities\n"
9688 "community number\n"
9689 "Do not send outside local AS (well-known community)\n"
9690 "Do not advertise to any peer (well-known community)\n"
9691 "Do not export to next AS (well-known community)\n")
9693 if (strncmp (argv[0], "m", 1) == 0)
9694 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
9696 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
9699 ALIAS (show_ip_bgp_ipv4_community,
9700 show_ip_bgp_ipv4_community2_cmd,
9701 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9706 "Address Family modifier\n"
9707 "Address Family modifier\n"
9708 "Display routes matching the communities\n"
9709 "community number\n"
9710 "Do not send outside local AS (well-known community)\n"
9711 "Do not advertise to any peer (well-known community)\n"
9712 "Do not export to next AS (well-known community)\n"
9713 "community number\n"
9714 "Do not send outside local AS (well-known community)\n"
9715 "Do not advertise to any peer (well-known community)\n"
9716 "Do not export to next AS (well-known community)\n")
9718 ALIAS (show_ip_bgp_ipv4_community,
9719 show_ip_bgp_ipv4_community3_cmd,
9720 "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)",
9725 "Address Family modifier\n"
9726 "Address Family modifier\n"
9727 "Display routes matching the communities\n"
9728 "community number\n"
9729 "Do not send outside local AS (well-known community)\n"
9730 "Do not advertise to any peer (well-known community)\n"
9731 "Do not export to next AS (well-known community)\n"
9732 "community number\n"
9733 "Do not send outside local AS (well-known community)\n"
9734 "Do not advertise to any peer (well-known community)\n"
9735 "Do not export to next AS (well-known community)\n"
9736 "community number\n"
9737 "Do not send outside local AS (well-known community)\n"
9738 "Do not advertise to any peer (well-known community)\n"
9739 "Do not export to next AS (well-known community)\n")
9741 ALIAS (show_ip_bgp_ipv4_community,
9742 show_ip_bgp_ipv4_community4_cmd,
9743 "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)",
9748 "Address Family modifier\n"
9749 "Address Family modifier\n"
9750 "Display routes matching the communities\n"
9751 "community number\n"
9752 "Do not send outside local AS (well-known community)\n"
9753 "Do not advertise to any peer (well-known community)\n"
9754 "Do not export to next AS (well-known community)\n"
9755 "community number\n"
9756 "Do not send outside local AS (well-known community)\n"
9757 "Do not advertise to any peer (well-known community)\n"
9758 "Do not export to next AS (well-known community)\n"
9759 "community number\n"
9760 "Do not send outside local AS (well-known community)\n"
9761 "Do not advertise to any peer (well-known community)\n"
9762 "Do not export to next AS (well-known community)\n"
9763 "community number\n"
9764 "Do not send outside local AS (well-known community)\n"
9765 "Do not advertise to any peer (well-known community)\n"
9766 "Do not export to next AS (well-known community)\n")
9768 DEFUN (show_ip_bgp_community_exact,
9769 show_ip_bgp_community_exact_cmd,
9770 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9774 "Display routes matching the communities\n"
9775 "community number\n"
9776 "Do not send outside local AS (well-known community)\n"
9777 "Do not advertise to any peer (well-known community)\n"
9778 "Do not export to next AS (well-known community)\n"
9779 "Exact match of the communities")
9781 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
9784 ALIAS (show_ip_bgp_community_exact,
9785 show_ip_bgp_community2_exact_cmd,
9786 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9790 "Display routes matching the communities\n"
9791 "community number\n"
9792 "Do not send outside local AS (well-known community)\n"
9793 "Do not advertise to any peer (well-known community)\n"
9794 "Do not export to next AS (well-known community)\n"
9795 "community number\n"
9796 "Do not send outside local AS (well-known community)\n"
9797 "Do not advertise to any peer (well-known community)\n"
9798 "Do not export to next AS (well-known community)\n"
9799 "Exact match of the communities")
9801 ALIAS (show_ip_bgp_community_exact,
9802 show_ip_bgp_community3_exact_cmd,
9803 "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",
9807 "Display routes matching the communities\n"
9808 "community number\n"
9809 "Do not send outside local AS (well-known community)\n"
9810 "Do not advertise to any peer (well-known community)\n"
9811 "Do not export to next AS (well-known community)\n"
9812 "community number\n"
9813 "Do not send outside local AS (well-known community)\n"
9814 "Do not advertise to any peer (well-known community)\n"
9815 "Do not export to next AS (well-known community)\n"
9816 "community number\n"
9817 "Do not send outside local AS (well-known community)\n"
9818 "Do not advertise to any peer (well-known community)\n"
9819 "Do not export to next AS (well-known community)\n"
9820 "Exact match of the communities")
9822 ALIAS (show_ip_bgp_community_exact,
9823 show_ip_bgp_community4_exact_cmd,
9824 "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",
9828 "Display routes matching the communities\n"
9829 "community number\n"
9830 "Do not send outside local AS (well-known community)\n"
9831 "Do not advertise to any peer (well-known community)\n"
9832 "Do not export to next AS (well-known community)\n"
9833 "community number\n"
9834 "Do not send outside local AS (well-known community)\n"
9835 "Do not advertise to any peer (well-known community)\n"
9836 "Do not export to next AS (well-known community)\n"
9837 "community number\n"
9838 "Do not send outside local AS (well-known community)\n"
9839 "Do not advertise to any peer (well-known community)\n"
9840 "Do not export to next AS (well-known community)\n"
9841 "community number\n"
9842 "Do not send outside local AS (well-known community)\n"
9843 "Do not advertise to any peer (well-known community)\n"
9844 "Do not export to next AS (well-known community)\n"
9845 "Exact match of the communities")
9847 DEFUN (show_ip_bgp_ipv4_community_exact,
9848 show_ip_bgp_ipv4_community_exact_cmd,
9849 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9854 "Address Family modifier\n"
9855 "Address Family modifier\n"
9856 "Display routes matching the communities\n"
9857 "community number\n"
9858 "Do not send outside local AS (well-known community)\n"
9859 "Do not advertise to any peer (well-known community)\n"
9860 "Do not export to next AS (well-known community)\n"
9861 "Exact match of the communities")
9863 if (strncmp (argv[0], "m", 1) == 0)
9864 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
9866 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
9869 ALIAS (show_ip_bgp_ipv4_community_exact,
9870 show_ip_bgp_ipv4_community2_exact_cmd,
9871 "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",
9876 "Address Family modifier\n"
9877 "Address Family modifier\n"
9878 "Display routes matching the communities\n"
9879 "community number\n"
9880 "Do not send outside local AS (well-known community)\n"
9881 "Do not advertise to any peer (well-known community)\n"
9882 "Do not export to next AS (well-known community)\n"
9883 "community number\n"
9884 "Do not send outside local AS (well-known community)\n"
9885 "Do not advertise to any peer (well-known community)\n"
9886 "Do not export to next AS (well-known community)\n"
9887 "Exact match of the communities")
9889 ALIAS (show_ip_bgp_ipv4_community_exact,
9890 show_ip_bgp_ipv4_community3_exact_cmd,
9891 "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",
9896 "Address Family modifier\n"
9897 "Address Family modifier\n"
9898 "Display routes matching the communities\n"
9899 "community number\n"
9900 "Do not send outside local AS (well-known community)\n"
9901 "Do not advertise to any peer (well-known community)\n"
9902 "Do not export to next AS (well-known community)\n"
9903 "community number\n"
9904 "Do not send outside local AS (well-known community)\n"
9905 "Do not advertise to any peer (well-known community)\n"
9906 "Do not export to next AS (well-known community)\n"
9907 "community number\n"
9908 "Do not send outside local AS (well-known community)\n"
9909 "Do not advertise to any peer (well-known community)\n"
9910 "Do not export to next AS (well-known community)\n"
9911 "Exact match of the communities")
9913 ALIAS (show_ip_bgp_ipv4_community_exact,
9914 show_ip_bgp_ipv4_community4_exact_cmd,
9915 "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",
9920 "Address Family modifier\n"
9921 "Address Family modifier\n"
9922 "Display routes matching the communities\n"
9923 "community number\n"
9924 "Do not send outside local AS (well-known community)\n"
9925 "Do not advertise to any peer (well-known community)\n"
9926 "Do not export to next AS (well-known community)\n"
9927 "community number\n"
9928 "Do not send outside local AS (well-known community)\n"
9929 "Do not advertise to any peer (well-known community)\n"
9930 "Do not export to next AS (well-known community)\n"
9931 "community number\n"
9932 "Do not send outside local AS (well-known community)\n"
9933 "Do not advertise to any peer (well-known community)\n"
9934 "Do not export to next AS (well-known community)\n"
9935 "community number\n"
9936 "Do not send outside local AS (well-known community)\n"
9937 "Do not advertise to any peer (well-known community)\n"
9938 "Do not export to next AS (well-known community)\n"
9939 "Exact match of the communities")
9941 DEFUN (show_bgp_community,
9942 show_bgp_community_cmd,
9943 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
9946 "Display routes matching the communities\n"
9947 "community number\n"
9948 "Do not send outside local AS (well-known community)\n"
9949 "Do not advertise to any peer (well-known community)\n"
9950 "Do not export to next AS (well-known community)\n")
9952 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
9955 ALIAS (show_bgp_community,
9956 show_bgp_ipv6_community_cmd,
9957 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
9961 "Display routes matching the communities\n"
9962 "community number\n"
9963 "Do not send outside local AS (well-known community)\n"
9964 "Do not advertise to any peer (well-known community)\n"
9965 "Do not export to next AS (well-known community)\n")
9967 ALIAS (show_bgp_community,
9968 show_bgp_community2_cmd,
9969 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9972 "Display routes matching the communities\n"
9973 "community number\n"
9974 "Do not send outside local AS (well-known community)\n"
9975 "Do not advertise to any peer (well-known community)\n"
9976 "Do not export to next AS (well-known community)\n"
9977 "community number\n"
9978 "Do not send outside local AS (well-known community)\n"
9979 "Do not advertise to any peer (well-known community)\n"
9980 "Do not export to next AS (well-known community)\n")
9982 ALIAS (show_bgp_community,
9983 show_bgp_ipv6_community2_cmd,
9984 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9988 "Display routes matching the communities\n"
9989 "community number\n"
9990 "Do not send outside local AS (well-known community)\n"
9991 "Do not advertise to any peer (well-known community)\n"
9992 "Do not export to next AS (well-known community)\n"
9993 "community number\n"
9994 "Do not send outside local AS (well-known community)\n"
9995 "Do not advertise to any peer (well-known community)\n"
9996 "Do not export to next AS (well-known community)\n")
9998 ALIAS (show_bgp_community,
9999 show_bgp_community3_cmd,
10000 "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)",
10003 "Display routes matching the communities\n"
10004 "community number\n"
10005 "Do not send outside local AS (well-known community)\n"
10006 "Do not advertise to any peer (well-known community)\n"
10007 "Do not export to next AS (well-known community)\n"
10008 "community number\n"
10009 "Do not send outside local AS (well-known community)\n"
10010 "Do not advertise to any peer (well-known community)\n"
10011 "Do not export to next AS (well-known community)\n"
10012 "community number\n"
10013 "Do not send outside local AS (well-known community)\n"
10014 "Do not advertise to any peer (well-known community)\n"
10015 "Do not export to next AS (well-known community)\n")
10017 ALIAS (show_bgp_community,
10018 show_bgp_ipv6_community3_cmd,
10019 "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)",
10023 "Display routes matching the communities\n"
10024 "community number\n"
10025 "Do not send outside local AS (well-known community)\n"
10026 "Do not advertise to any peer (well-known community)\n"
10027 "Do not export to next AS (well-known community)\n"
10028 "community number\n"
10029 "Do not send outside local AS (well-known community)\n"
10030 "Do not advertise to any peer (well-known community)\n"
10031 "Do not export to next AS (well-known community)\n"
10032 "community number\n"
10033 "Do not send outside local AS (well-known community)\n"
10034 "Do not advertise to any peer (well-known community)\n"
10035 "Do not export to next AS (well-known community)\n")
10037 ALIAS (show_bgp_community,
10038 show_bgp_community4_cmd,
10039 "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)",
10042 "Display routes matching the communities\n"
10043 "community number\n"
10044 "Do not send outside local AS (well-known community)\n"
10045 "Do not advertise to any peer (well-known community)\n"
10046 "Do not export to next AS (well-known community)\n"
10047 "community number\n"
10048 "Do not send outside local AS (well-known community)\n"
10049 "Do not advertise to any peer (well-known community)\n"
10050 "Do not export to next AS (well-known community)\n"
10051 "community number\n"
10052 "Do not send outside local AS (well-known community)\n"
10053 "Do not advertise to any peer (well-known community)\n"
10054 "Do not export to next AS (well-known community)\n"
10055 "community number\n"
10056 "Do not send outside local AS (well-known community)\n"
10057 "Do not advertise to any peer (well-known community)\n"
10058 "Do not export to next AS (well-known community)\n")
10060 ALIAS (show_bgp_community,
10061 show_bgp_ipv6_community4_cmd,
10062 "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)",
10066 "Display routes matching the communities\n"
10067 "community number\n"
10068 "Do not send outside local AS (well-known community)\n"
10069 "Do not advertise to any peer (well-known community)\n"
10070 "Do not export to next AS (well-known community)\n"
10071 "community number\n"
10072 "Do not send outside local AS (well-known community)\n"
10073 "Do not advertise to any peer (well-known community)\n"
10074 "Do not export to next AS (well-known community)\n"
10075 "community number\n"
10076 "Do not send outside local AS (well-known community)\n"
10077 "Do not advertise to any peer (well-known community)\n"
10078 "Do not export to next AS (well-known community)\n"
10079 "community number\n"
10080 "Do not send outside local AS (well-known community)\n"
10081 "Do not advertise to any peer (well-known community)\n"
10082 "Do not export to next AS (well-known community)\n")
10085 DEFUN (show_ipv6_bgp_community,
10086 show_ipv6_bgp_community_cmd,
10087 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
10091 "Display routes matching the communities\n"
10092 "community number\n"
10093 "Do not send outside local AS (well-known community)\n"
10094 "Do not advertise to any peer (well-known community)\n"
10095 "Do not export to next AS (well-known community)\n")
10097 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
10101 ALIAS (show_ipv6_bgp_community,
10102 show_ipv6_bgp_community2_cmd,
10103 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10107 "Display routes matching the communities\n"
10108 "community number\n"
10109 "Do not send outside local AS (well-known community)\n"
10110 "Do not advertise to any peer (well-known community)\n"
10111 "Do not export to next AS (well-known community)\n"
10112 "community number\n"
10113 "Do not send outside local AS (well-known community)\n"
10114 "Do not advertise to any peer (well-known community)\n"
10115 "Do not export to next AS (well-known community)\n")
10118 ALIAS (show_ipv6_bgp_community,
10119 show_ipv6_bgp_community3_cmd,
10120 "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)",
10124 "Display routes matching the communities\n"
10125 "community number\n"
10126 "Do not send outside local AS (well-known community)\n"
10127 "Do not advertise to any peer (well-known community)\n"
10128 "Do not export to next AS (well-known community)\n"
10129 "community number\n"
10130 "Do not send outside local AS (well-known community)\n"
10131 "Do not advertise to any peer (well-known community)\n"
10132 "Do not export to next AS (well-known community)\n"
10133 "community number\n"
10134 "Do not send outside local AS (well-known community)\n"
10135 "Do not advertise to any peer (well-known community)\n"
10136 "Do not export to next AS (well-known community)\n")
10139 ALIAS (show_ipv6_bgp_community,
10140 show_ipv6_bgp_community4_cmd,
10141 "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)",
10145 "Display routes matching the communities\n"
10146 "community number\n"
10147 "Do not send outside local AS (well-known community)\n"
10148 "Do not advertise to any peer (well-known community)\n"
10149 "Do not export to next AS (well-known community)\n"
10150 "community number\n"
10151 "Do not send outside local AS (well-known community)\n"
10152 "Do not advertise to any peer (well-known community)\n"
10153 "Do not export to next AS (well-known community)\n"
10154 "community number\n"
10155 "Do not send outside local AS (well-known community)\n"
10156 "Do not advertise to any peer (well-known community)\n"
10157 "Do not export to next AS (well-known community)\n"
10158 "community number\n"
10159 "Do not send outside local AS (well-known community)\n"
10160 "Do not advertise to any peer (well-known community)\n"
10161 "Do not export to next AS (well-known community)\n")
10163 DEFUN (show_bgp_community_exact,
10164 show_bgp_community_exact_cmd,
10165 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10168 "Display routes matching the communities\n"
10169 "community number\n"
10170 "Do not send outside local AS (well-known community)\n"
10171 "Do not advertise to any peer (well-known community)\n"
10172 "Do not export to next AS (well-known community)\n"
10173 "Exact match of the communities")
10175 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
10178 ALIAS (show_bgp_community_exact,
10179 show_bgp_ipv6_community_exact_cmd,
10180 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10184 "Display routes matching the communities\n"
10185 "community number\n"
10186 "Do not send outside local AS (well-known community)\n"
10187 "Do not advertise to any peer (well-known community)\n"
10188 "Do not export to next AS (well-known community)\n"
10189 "Exact match of the communities")
10191 ALIAS (show_bgp_community_exact,
10192 show_bgp_community2_exact_cmd,
10193 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10196 "Display routes matching the communities\n"
10197 "community number\n"
10198 "Do not send outside local AS (well-known community)\n"
10199 "Do not advertise to any peer (well-known community)\n"
10200 "Do not export to next AS (well-known community)\n"
10201 "community number\n"
10202 "Do not send outside local AS (well-known community)\n"
10203 "Do not advertise to any peer (well-known community)\n"
10204 "Do not export to next AS (well-known community)\n"
10205 "Exact match of the communities")
10207 ALIAS (show_bgp_community_exact,
10208 show_bgp_ipv6_community2_exact_cmd,
10209 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10213 "Display routes matching the communities\n"
10214 "community number\n"
10215 "Do not send outside local AS (well-known community)\n"
10216 "Do not advertise to any peer (well-known community)\n"
10217 "Do not export to next AS (well-known community)\n"
10218 "community number\n"
10219 "Do not send outside local AS (well-known community)\n"
10220 "Do not advertise to any peer (well-known community)\n"
10221 "Do not export to next AS (well-known community)\n"
10222 "Exact match of the communities")
10224 ALIAS (show_bgp_community_exact,
10225 show_bgp_community3_exact_cmd,
10226 "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",
10229 "Display routes matching the communities\n"
10230 "community number\n"
10231 "Do not send outside local AS (well-known community)\n"
10232 "Do not advertise to any peer (well-known community)\n"
10233 "Do not export to next AS (well-known community)\n"
10234 "community number\n"
10235 "Do not send outside local AS (well-known community)\n"
10236 "Do not advertise to any peer (well-known community)\n"
10237 "Do not export to next AS (well-known community)\n"
10238 "community number\n"
10239 "Do not send outside local AS (well-known community)\n"
10240 "Do not advertise to any peer (well-known community)\n"
10241 "Do not export to next AS (well-known community)\n"
10242 "Exact match of the communities")
10244 ALIAS (show_bgp_community_exact,
10245 show_bgp_ipv6_community3_exact_cmd,
10246 "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",
10250 "Display routes matching the communities\n"
10251 "community number\n"
10252 "Do not send outside local AS (well-known community)\n"
10253 "Do not advertise to any peer (well-known community)\n"
10254 "Do not export to next AS (well-known community)\n"
10255 "community number\n"
10256 "Do not send outside local AS (well-known community)\n"
10257 "Do not advertise to any peer (well-known community)\n"
10258 "Do not export to next AS (well-known community)\n"
10259 "community number\n"
10260 "Do not send outside local AS (well-known community)\n"
10261 "Do not advertise to any peer (well-known community)\n"
10262 "Do not export to next AS (well-known community)\n"
10263 "Exact match of the communities")
10265 ALIAS (show_bgp_community_exact,
10266 show_bgp_community4_exact_cmd,
10267 "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",
10270 "Display routes matching the communities\n"
10271 "community number\n"
10272 "Do not send outside local AS (well-known community)\n"
10273 "Do not advertise to any peer (well-known community)\n"
10274 "Do not export to next AS (well-known community)\n"
10275 "community number\n"
10276 "Do not send outside local AS (well-known community)\n"
10277 "Do not advertise to any peer (well-known community)\n"
10278 "Do not export to next AS (well-known community)\n"
10279 "community number\n"
10280 "Do not send outside local AS (well-known community)\n"
10281 "Do not advertise to any peer (well-known community)\n"
10282 "Do not export to next AS (well-known community)\n"
10283 "community number\n"
10284 "Do not send outside local AS (well-known community)\n"
10285 "Do not advertise to any peer (well-known community)\n"
10286 "Do not export to next AS (well-known community)\n"
10287 "Exact match of the communities")
10289 ALIAS (show_bgp_community_exact,
10290 show_bgp_ipv6_community4_exact_cmd,
10291 "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",
10295 "Display routes matching the communities\n"
10296 "community number\n"
10297 "Do not send outside local AS (well-known community)\n"
10298 "Do not advertise to any peer (well-known community)\n"
10299 "Do not export to next AS (well-known community)\n"
10300 "community number\n"
10301 "Do not send outside local AS (well-known community)\n"
10302 "Do not advertise to any peer (well-known community)\n"
10303 "Do not export to next AS (well-known community)\n"
10304 "community number\n"
10305 "Do not send outside local AS (well-known community)\n"
10306 "Do not advertise to any peer (well-known community)\n"
10307 "Do not export to next AS (well-known community)\n"
10308 "community number\n"
10309 "Do not send outside local AS (well-known community)\n"
10310 "Do not advertise to any peer (well-known community)\n"
10311 "Do not export to next AS (well-known community)\n"
10312 "Exact match of the communities")
10315 DEFUN (show_ipv6_bgp_community_exact,
10316 show_ipv6_bgp_community_exact_cmd,
10317 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10321 "Display routes matching the communities\n"
10322 "community number\n"
10323 "Do not send outside local AS (well-known community)\n"
10324 "Do not advertise to any peer (well-known community)\n"
10325 "Do not export to next AS (well-known community)\n"
10326 "Exact match of the communities")
10328 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
10332 ALIAS (show_ipv6_bgp_community_exact,
10333 show_ipv6_bgp_community2_exact_cmd,
10334 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10338 "Display routes matching the communities\n"
10339 "community number\n"
10340 "Do not send outside local AS (well-known community)\n"
10341 "Do not advertise to any peer (well-known community)\n"
10342 "Do not export to next AS (well-known community)\n"
10343 "community number\n"
10344 "Do not send outside local AS (well-known community)\n"
10345 "Do not advertise to any peer (well-known community)\n"
10346 "Do not export to next AS (well-known community)\n"
10347 "Exact match of the communities")
10350 ALIAS (show_ipv6_bgp_community_exact,
10351 show_ipv6_bgp_community3_exact_cmd,
10352 "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",
10356 "Display routes matching the communities\n"
10357 "community number\n"
10358 "Do not send outside local AS (well-known community)\n"
10359 "Do not advertise to any peer (well-known community)\n"
10360 "Do not export to next AS (well-known community)\n"
10361 "community number\n"
10362 "Do not send outside local AS (well-known community)\n"
10363 "Do not advertise to any peer (well-known community)\n"
10364 "Do not export to next AS (well-known community)\n"
10365 "community number\n"
10366 "Do not send outside local AS (well-known community)\n"
10367 "Do not advertise to any peer (well-known community)\n"
10368 "Do not export to next AS (well-known community)\n"
10369 "Exact match of the communities")
10372 ALIAS (show_ipv6_bgp_community_exact,
10373 show_ipv6_bgp_community4_exact_cmd,
10374 "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",
10378 "Display routes matching the communities\n"
10379 "community number\n"
10380 "Do not send outside local AS (well-known community)\n"
10381 "Do not advertise to any peer (well-known community)\n"
10382 "Do not export to next AS (well-known community)\n"
10383 "community number\n"
10384 "Do not send outside local AS (well-known community)\n"
10385 "Do not advertise to any peer (well-known community)\n"
10386 "Do not export to next AS (well-known community)\n"
10387 "community number\n"
10388 "Do not send outside local AS (well-known community)\n"
10389 "Do not advertise to any peer (well-known community)\n"
10390 "Do not export to next AS (well-known community)\n"
10391 "community number\n"
10392 "Do not send outside local AS (well-known community)\n"
10393 "Do not advertise to any peer (well-known community)\n"
10394 "Do not export to next AS (well-known community)\n"
10395 "Exact match of the communities")
10398 DEFUN (show_ipv6_mbgp_community,
10399 show_ipv6_mbgp_community_cmd,
10400 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
10404 "Display routes matching the communities\n"
10405 "community number\n"
10406 "Do not send outside local AS (well-known community)\n"
10407 "Do not advertise to any peer (well-known community)\n"
10408 "Do not export to next AS (well-known community)\n")
10410 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST);
10414 ALIAS (show_ipv6_mbgp_community,
10415 show_ipv6_mbgp_community2_cmd,
10416 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10420 "Display routes matching the communities\n"
10421 "community number\n"
10422 "Do not send outside local AS (well-known community)\n"
10423 "Do not advertise to any peer (well-known community)\n"
10424 "Do not export to next AS (well-known community)\n"
10425 "community number\n"
10426 "Do not send outside local AS (well-known community)\n"
10427 "Do not advertise to any peer (well-known community)\n"
10428 "Do not export to next AS (well-known community)\n")
10431 ALIAS (show_ipv6_mbgp_community,
10432 show_ipv6_mbgp_community3_cmd,
10433 "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)",
10437 "Display routes matching the communities\n"
10438 "community number\n"
10439 "Do not send outside local AS (well-known community)\n"
10440 "Do not advertise to any peer (well-known community)\n"
10441 "Do not export to next AS (well-known community)\n"
10442 "community number\n"
10443 "Do not send outside local AS (well-known community)\n"
10444 "Do not advertise to any peer (well-known community)\n"
10445 "Do not export to next AS (well-known community)\n"
10446 "community number\n"
10447 "Do not send outside local AS (well-known community)\n"
10448 "Do not advertise to any peer (well-known community)\n"
10449 "Do not export to next AS (well-known community)\n")
10452 ALIAS (show_ipv6_mbgp_community,
10453 show_ipv6_mbgp_community4_cmd,
10454 "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)",
10458 "Display routes matching the communities\n"
10459 "community number\n"
10460 "Do not send outside local AS (well-known community)\n"
10461 "Do not advertise to any peer (well-known community)\n"
10462 "Do not export to next AS (well-known community)\n"
10463 "community number\n"
10464 "Do not send outside local AS (well-known community)\n"
10465 "Do not advertise to any peer (well-known community)\n"
10466 "Do not export to next AS (well-known community)\n"
10467 "community number\n"
10468 "Do not send outside local AS (well-known community)\n"
10469 "Do not advertise to any peer (well-known community)\n"
10470 "Do not export to next AS (well-known community)\n"
10471 "community number\n"
10472 "Do not send outside local AS (well-known community)\n"
10473 "Do not advertise to any peer (well-known community)\n"
10474 "Do not export to next AS (well-known community)\n")
10477 DEFUN (show_ipv6_mbgp_community_exact,
10478 show_ipv6_mbgp_community_exact_cmd,
10479 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10483 "Display routes matching the communities\n"
10484 "community number\n"
10485 "Do not send outside local AS (well-known community)\n"
10486 "Do not advertise to any peer (well-known community)\n"
10487 "Do not export to next AS (well-known community)\n"
10488 "Exact match of the communities")
10490 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST);
10494 ALIAS (show_ipv6_mbgp_community_exact,
10495 show_ipv6_mbgp_community2_exact_cmd,
10496 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10500 "Display routes matching the communities\n"
10501 "community number\n"
10502 "Do not send outside local AS (well-known community)\n"
10503 "Do not advertise to any peer (well-known community)\n"
10504 "Do not export to next AS (well-known community)\n"
10505 "community number\n"
10506 "Do not send outside local AS (well-known community)\n"
10507 "Do not advertise to any peer (well-known community)\n"
10508 "Do not export to next AS (well-known community)\n"
10509 "Exact match of the communities")
10512 ALIAS (show_ipv6_mbgp_community_exact,
10513 show_ipv6_mbgp_community3_exact_cmd,
10514 "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",
10518 "Display routes matching the communities\n"
10519 "community number\n"
10520 "Do not send outside local AS (well-known community)\n"
10521 "Do not advertise to any peer (well-known community)\n"
10522 "Do not export to next AS (well-known community)\n"
10523 "community number\n"
10524 "Do not send outside local AS (well-known community)\n"
10525 "Do not advertise to any peer (well-known community)\n"
10526 "Do not export to next AS (well-known community)\n"
10527 "community number\n"
10528 "Do not send outside local AS (well-known community)\n"
10529 "Do not advertise to any peer (well-known community)\n"
10530 "Do not export to next AS (well-known community)\n"
10531 "Exact match of the communities")
10534 ALIAS (show_ipv6_mbgp_community_exact,
10535 show_ipv6_mbgp_community4_exact_cmd,
10536 "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",
10540 "Display routes matching the communities\n"
10541 "community number\n"
10542 "Do not send outside local AS (well-known community)\n"
10543 "Do not advertise to any peer (well-known community)\n"
10544 "Do not export to next AS (well-known community)\n"
10545 "community number\n"
10546 "Do not send outside local AS (well-known community)\n"
10547 "Do not advertise to any peer (well-known community)\n"
10548 "Do not export to next AS (well-known community)\n"
10549 "community number\n"
10550 "Do not send outside local AS (well-known community)\n"
10551 "Do not advertise to any peer (well-known community)\n"
10552 "Do not export to next AS (well-known community)\n"
10553 "community number\n"
10554 "Do not send outside local AS (well-known community)\n"
10555 "Do not advertise to any peer (well-known community)\n"
10556 "Do not export to next AS (well-known community)\n"
10557 "Exact match of the communities")
10559 DEFUN (show_bgp_ipv4_community,
10560 show_bgp_ipv4_community_cmd,
10561 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export)",
10565 "Display routes matching the communities\n"
10566 "community number\n"
10567 "Do not send outside local AS (well-known community)\n"
10568 "Do not advertise to any peer (well-known community)\n"
10569 "Do not export to next AS (well-known community)\n")
10571 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
10574 ALIAS (show_bgp_ipv4_community,
10575 show_bgp_ipv4_community2_cmd,
10576 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10580 "Display routes matching the communities\n"
10581 "community number\n"
10582 "Do not send outside local AS (well-known community)\n"
10583 "Do not advertise to any peer (well-known community)\n"
10584 "Do not export to next AS (well-known community)\n"
10585 "community number\n"
10586 "Do not send outside local AS (well-known community)\n"
10587 "Do not advertise to any peer (well-known community)\n"
10588 "Do not export to next AS (well-known community)\n")
10590 ALIAS (show_bgp_ipv4_community,
10591 show_bgp_ipv4_community3_cmd,
10592 "show bgp ipv4 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)",
10596 "Display routes matching the communities\n"
10597 "community number\n"
10598 "Do not send outside local AS (well-known community)\n"
10599 "Do not advertise to any peer (well-known community)\n"
10600 "Do not export to next AS (well-known community)\n"
10601 "community number\n"
10602 "Do not send outside local AS (well-known community)\n"
10603 "Do not advertise to any peer (well-known community)\n"
10604 "Do not export to next AS (well-known community)\n"
10605 "community number\n"
10606 "Do not send outside local AS (well-known community)\n"
10607 "Do not advertise to any peer (well-known community)\n"
10608 "Do not export to next AS (well-known community)\n")
10610 ALIAS (show_bgp_ipv4_community,
10611 show_bgp_ipv4_community4_cmd,
10612 "show bgp ipv4 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)",
10616 "Display routes matching the communities\n"
10617 "community number\n"
10618 "Do not send outside local AS (well-known community)\n"
10619 "Do not advertise to any peer (well-known community)\n"
10620 "Do not export to next AS (well-known community)\n"
10621 "community number\n"
10622 "Do not send outside local AS (well-known community)\n"
10623 "Do not advertise to any peer (well-known community)\n"
10624 "Do not export to next AS (well-known community)\n"
10625 "community number\n"
10626 "Do not send outside local AS (well-known community)\n"
10627 "Do not advertise to any peer (well-known community)\n"
10628 "Do not export to next AS (well-known community)\n"
10629 "community number\n"
10630 "Do not send outside local AS (well-known community)\n"
10631 "Do not advertise to any peer (well-known community)\n"
10632 "Do not export to next AS (well-known community)\n")
10634 DEFUN (show_bgp_ipv4_safi_community,
10635 show_bgp_ipv4_safi_community_cmd,
10636 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
10640 "Address Family modifier\n"
10641 "Address Family modifier\n"
10642 "Display routes matching the communities\n"
10643 "community number\n"
10644 "Do not send outside local AS (well-known community)\n"
10645 "Do not advertise to any peer (well-known community)\n"
10646 "Do not export to next AS (well-known community)\n")
10648 if (strncmp (argv[0], "m", 1) == 0)
10649 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
10651 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
10654 ALIAS (show_bgp_ipv4_safi_community,
10655 show_bgp_ipv4_safi_community2_cmd,
10656 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10660 "Address Family modifier\n"
10661 "Address Family modifier\n"
10662 "Display routes matching the communities\n"
10663 "community number\n"
10664 "Do not send outside local AS (well-known community)\n"
10665 "Do not advertise to any peer (well-known community)\n"
10666 "Do not export to next AS (well-known community)\n"
10667 "community number\n"
10668 "Do not send outside local AS (well-known community)\n"
10669 "Do not advertise to any peer (well-known community)\n"
10670 "Do not export to next AS (well-known community)\n")
10672 ALIAS (show_bgp_ipv4_safi_community,
10673 show_bgp_ipv4_safi_community3_cmd,
10674 "show 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)",
10678 "Address Family modifier\n"
10679 "Address Family modifier\n"
10680 "Display routes matching the communities\n"
10681 "community number\n"
10682 "Do not send outside local AS (well-known community)\n"
10683 "Do not advertise to any peer (well-known community)\n"
10684 "Do not export to next AS (well-known community)\n"
10685 "community number\n"
10686 "Do not send outside local AS (well-known community)\n"
10687 "Do not advertise to any peer (well-known community)\n"
10688 "Do not export to next AS (well-known community)\n"
10689 "community number\n"
10690 "Do not send outside local AS (well-known community)\n"
10691 "Do not advertise to any peer (well-known community)\n"
10692 "Do not export to next AS (well-known community)\n")
10694 ALIAS (show_bgp_ipv4_safi_community,
10695 show_bgp_ipv4_safi_community4_cmd,
10696 "show 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)",
10700 "Address Family modifier\n"
10701 "Address Family modifier\n"
10702 "Display routes matching the communities\n"
10703 "community number\n"
10704 "Do not send outside local AS (well-known community)\n"
10705 "Do not advertise to any peer (well-known community)\n"
10706 "Do not export to next AS (well-known community)\n"
10707 "community number\n"
10708 "Do not send outside local AS (well-known community)\n"
10709 "Do not advertise to any peer (well-known community)\n"
10710 "Do not export to next AS (well-known community)\n"
10711 "community number\n"
10712 "Do not send outside local AS (well-known community)\n"
10713 "Do not advertise to any peer (well-known community)\n"
10714 "Do not export to next AS (well-known community)\n"
10715 "community number\n"
10716 "Do not send outside local AS (well-known community)\n"
10717 "Do not advertise to any peer (well-known community)\n"
10718 "Do not export to next AS (well-known community)\n")
10720 DEFUN (show_bgp_view_afi_safi_community_all,
10721 show_bgp_view_afi_safi_community_all_cmd,
10722 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community",
10729 "Address Family modifier\n"
10730 "Address Family modifier\n"
10731 "Display routes matching the communities\n")
10737 /* BGP structure lookup. */
10738 bgp = bgp_lookup_by_name (argv[0]);
10741 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
10742 return CMD_WARNING;
10745 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
10746 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
10747 return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL);
10750 DEFUN (show_bgp_view_afi_safi_community,
10751 show_bgp_view_afi_safi_community_cmd,
10752 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
10759 "Address family modifier\n"
10760 "Address family modifier\n"
10761 "Display routes matching the communities\n"
10762 "community number\n"
10763 "Do not send outside local AS (well-known community)\n"
10764 "Do not advertise to any peer (well-known community)\n"
10765 "Do not export to next AS (well-known community)\n")
10770 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
10771 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
10772 return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi);
10775 ALIAS (show_bgp_view_afi_safi_community,
10776 show_bgp_view_afi_safi_community2_cmd,
10777 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10784 "Address family modifier\n"
10785 "Address family modifier\n"
10786 "Display routes matching the communities\n"
10787 "community number\n"
10788 "Do not send outside local AS (well-known community)\n"
10789 "Do not advertise to any peer (well-known community)\n"
10790 "Do not export to next AS (well-known community)\n"
10791 "community number\n"
10792 "Do not send outside local AS (well-known community)\n"
10793 "Do not advertise to any peer (well-known community)\n"
10794 "Do not export to next AS (well-known community)\n")
10796 ALIAS (show_bgp_view_afi_safi_community,
10797 show_bgp_view_afi_safi_community3_cmd,
10798 "show bgp view WORD (ipv4|ipv6) (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)",
10805 "Address family modifier\n"
10806 "Address family modifier\n"
10807 "Display routes matching the communities\n"
10808 "community number\n"
10809 "Do not send outside local AS (well-known community)\n"
10810 "Do not advertise to any peer (well-known community)\n"
10811 "Do not export to next AS (well-known community)\n"
10812 "community number\n"
10813 "Do not send outside local AS (well-known community)\n"
10814 "Do not advertise to any peer (well-known community)\n"
10815 "Do not export to next AS (well-known community)\n"
10816 "community number\n"
10817 "Do not send outside local AS (well-known community)\n"
10818 "Do not advertise to any peer (well-known community)\n"
10819 "Do not export to next AS (well-known community)\n")
10821 ALIAS (show_bgp_view_afi_safi_community,
10822 show_bgp_view_afi_safi_community4_cmd,
10823 "show bgp view WORD (ipv4|ipv6) (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)",
10830 "Address family modifier\n"
10831 "Address family modifier\n"
10832 "Display routes matching the communities\n"
10833 "community number\n"
10834 "Do not send outside local AS (well-known community)\n"
10835 "Do not advertise to any peer (well-known community)\n"
10836 "Do not export to next AS (well-known community)\n"
10837 "community number\n"
10838 "Do not send outside local AS (well-known community)\n"
10839 "Do not advertise to any peer (well-known community)\n"
10840 "Do not export to next AS (well-known community)\n"
10841 "community number\n"
10842 "Do not send outside local AS (well-known community)\n"
10843 "Do not advertise to any peer (well-known community)\n"
10844 "Do not export to next AS (well-known community)\n"
10845 "community number\n"
10846 "Do not send outside local AS (well-known community)\n"
10847 "Do not advertise to any peer (well-known community)\n"
10848 "Do not export to next AS (well-known community)\n")
10850 DEFUN (show_bgp_ipv4_community_exact,
10851 show_bgp_ipv4_community_exact_cmd,
10852 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10856 "Display routes matching the communities\n"
10857 "community number\n"
10858 "Do not send outside local AS (well-known community)\n"
10859 "Do not advertise to any peer (well-known community)\n"
10860 "Do not export to next AS (well-known community)\n"
10861 "Exact match of the communities")
10863 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
10866 ALIAS (show_bgp_ipv4_community_exact,
10867 show_bgp_ipv4_community2_exact_cmd,
10868 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10872 "Display routes matching the communities\n"
10873 "community number\n"
10874 "Do not send outside local AS (well-known community)\n"
10875 "Do not advertise to any peer (well-known community)\n"
10876 "Do not export to next AS (well-known community)\n"
10877 "community number\n"
10878 "Do not send outside local AS (well-known community)\n"
10879 "Do not advertise to any peer (well-known community)\n"
10880 "Do not export to next AS (well-known community)\n"
10881 "Exact match of the communities")
10883 ALIAS (show_bgp_ipv4_community_exact,
10884 show_bgp_ipv4_community3_exact_cmd,
10885 "show bgp ipv4 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",
10889 "Display routes matching the communities\n"
10890 "community number\n"
10891 "Do not send outside local AS (well-known community)\n"
10892 "Do not advertise to any peer (well-known community)\n"
10893 "Do not export to next AS (well-known community)\n"
10894 "community number\n"
10895 "Do not send outside local AS (well-known community)\n"
10896 "Do not advertise to any peer (well-known community)\n"
10897 "Do not export to next AS (well-known community)\n"
10898 "community number\n"
10899 "Do not send outside local AS (well-known community)\n"
10900 "Do not advertise to any peer (well-known community)\n"
10901 "Do not export to next AS (well-known community)\n"
10902 "Exact match of the communities")
10904 ALIAS (show_bgp_ipv4_community_exact,
10905 show_bgp_ipv4_community4_exact_cmd,
10906 "show bgp ipv4 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",
10910 "Display routes matching the communities\n"
10911 "community number\n"
10912 "Do not send outside local AS (well-known community)\n"
10913 "Do not advertise to any peer (well-known community)\n"
10914 "Do not export to next AS (well-known community)\n"
10915 "community number\n"
10916 "Do not send outside local AS (well-known community)\n"
10917 "Do not advertise to any peer (well-known community)\n"
10918 "Do not export to next AS (well-known community)\n"
10919 "community number\n"
10920 "Do not send outside local AS (well-known community)\n"
10921 "Do not advertise to any peer (well-known community)\n"
10922 "Do not export to next AS (well-known community)\n"
10923 "community number\n"
10924 "Do not send outside local AS (well-known community)\n"
10925 "Do not advertise to any peer (well-known community)\n"
10926 "Do not export to next AS (well-known community)\n"
10927 "Exact match of the communities")
10929 DEFUN (show_bgp_ipv4_safi_community4_exact,
10930 show_bgp_ipv4_safi_community_exact_cmd,
10931 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10935 "Address Family modifier\n"
10936 "Address Family modifier\n"
10937 "Display routes matching the communities\n"
10938 "community number\n"
10939 "Do not send outside local AS (well-known community)\n"
10940 "Do not advertise to any peer (well-known community)\n"
10941 "Do not export to next AS (well-known community)\n"
10942 "Exact match of the communities")
10944 if (strncmp (argv[0], "m", 1) == 0)
10945 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
10947 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
10950 ALIAS (show_bgp_ipv4_safi_community4_exact,
10951 show_bgp_ipv4_safi_community2_exact_cmd,
10952 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10956 "Address Family modifier\n"
10957 "Address Family modifier\n"
10958 "Display routes matching the communities\n"
10959 "community number\n"
10960 "Do not send outside local AS (well-known community)\n"
10961 "Do not advertise to any peer (well-known community)\n"
10962 "Do not export to next AS (well-known community)\n"
10963 "community number\n"
10964 "Do not send outside local AS (well-known community)\n"
10965 "Do not advertise to any peer (well-known community)\n"
10966 "Do not export to next AS (well-known community)\n"
10967 "Exact match of the communities")
10969 ALIAS (show_bgp_ipv4_safi_community4_exact,
10970 show_bgp_ipv4_safi_community3_exact_cmd,
10971 "show 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",
10975 "Address Family modifier\n"
10976 "Address Family modifier\n"
10977 "Display routes matching the communities\n"
10978 "community number\n"
10979 "Do not send outside local AS (well-known community)\n"
10980 "Do not advertise to any peer (well-known community)\n"
10981 "Do not export to next AS (well-known community)\n"
10982 "community number\n"
10983 "Do not send outside local AS (well-known community)\n"
10984 "Do not advertise to any peer (well-known community)\n"
10985 "Do not export to next AS (well-known community)\n"
10986 "community number\n"
10987 "Do not send outside local AS (well-known community)\n"
10988 "Do not advertise to any peer (well-known community)\n"
10989 "Do not export to next AS (well-known community)\n"
10990 "Exact match of the communities")
10992 ALIAS (show_bgp_ipv4_safi_community4_exact,
10993 show_bgp_ipv4_safi_community4_exact_cmd,
10994 "show 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",
10998 "Address Family modifier\n"
10999 "Address Family modifier\n"
11000 "Display routes matching the communities\n"
11001 "community number\n"
11002 "Do not send outside local AS (well-known community)\n"
11003 "Do not advertise to any peer (well-known community)\n"
11004 "Do not export to next AS (well-known community)\n"
11005 "community number\n"
11006 "Do not send outside local AS (well-known community)\n"
11007 "Do not advertise to any peer (well-known community)\n"
11008 "Do not export to next AS (well-known community)\n"
11009 "community number\n"
11010 "Do not send outside local AS (well-known community)\n"
11011 "Do not advertise to any peer (well-known community)\n"
11012 "Do not export to next AS (well-known community)\n"
11013 "community number\n"
11014 "Do not send outside local AS (well-known community)\n"
11015 "Do not advertise to any peer (well-known community)\n"
11016 "Do not export to next AS (well-known community)\n"
11017 "Exact match of the communities")
11019 DEFUN (show_bgp_ipv6_safi_community,
11020 show_bgp_ipv6_safi_community_cmd,
11021 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export)",
11025 "Address family modifier\n"
11026 "Address family modifier\n"
11027 "Address family modifier\n"
11028 "Address family modifier\n"
11029 "Display routes matching the communities\n"
11030 "community number\n"
11031 "Do not send outside local AS (well-known community)\n"
11032 "Do not advertise to any peer (well-known community)\n"
11033 "Do not export to next AS (well-known community)\n")
11037 if (bgp_parse_safi(argv[0], &safi)) {
11038 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11039 return CMD_WARNING;
11041 return bgp_show_community (vty, NULL, argc-1, argv+1, 0, AFI_IP6, safi);
11044 ALIAS (show_bgp_ipv6_safi_community,
11045 show_bgp_ipv6_safi_community2_cmd,
11046 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
11050 "Address family modifier\n"
11051 "Address family modifier\n"
11052 "Address family modifier\n"
11053 "Address family modifier\n"
11054 "Display routes matching the communities\n"
11055 "community number\n"
11056 "Do not send outside local AS (well-known community)\n"
11057 "Do not advertise to any peer (well-known community)\n"
11058 "Do not export to next AS (well-known community)\n"
11059 "community number\n"
11060 "Do not send outside local AS (well-known community)\n"
11061 "Do not advertise to any peer (well-known community)\n"
11062 "Do not export to next AS (well-known community)\n")
11064 ALIAS (show_bgp_ipv6_safi_community,
11065 show_bgp_ipv6_safi_community3_cmd,
11066 "show bgp ipv6 (encap|multicast|unicast|vpn) 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)",
11070 "Address family modifier\n"
11071 "Address family modifier\n"
11072 "Address family modifier\n"
11073 "Address family modifier\n"
11074 "Display routes matching the communities\n"
11075 "community number\n"
11076 "Do not send outside local AS (well-known community)\n"
11077 "Do not advertise to any peer (well-known community)\n"
11078 "Do not export to next AS (well-known community)\n"
11079 "community number\n"
11080 "Do not send outside local AS (well-known community)\n"
11081 "Do not advertise to any peer (well-known community)\n"
11082 "Do not export to next AS (well-known community)\n"
11083 "community number\n"
11084 "Do not send outside local AS (well-known community)\n"
11085 "Do not advertise to any peer (well-known community)\n"
11086 "Do not export to next AS (well-known community)\n")
11088 ALIAS (show_bgp_ipv6_safi_community,
11089 show_bgp_ipv6_safi_community4_cmd,
11090 "show bgp ipv6 (encap|multicast|unicast|vpn) 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)",
11094 "Address family modifier\n"
11095 "Address family modifier\n"
11096 "Address family modifier\n"
11097 "Address family modifier\n"
11098 "Display routes matching the communities\n"
11099 "community number\n"
11100 "Do not send outside local AS (well-known community)\n"
11101 "Do not advertise to any peer (well-known community)\n"
11102 "Do not export to next AS (well-known community)\n"
11103 "community number\n"
11104 "Do not send outside local AS (well-known community)\n"
11105 "Do not advertise to any peer (well-known community)\n"
11106 "Do not export to next AS (well-known community)\n"
11107 "community number\n"
11108 "Do not send outside local AS (well-known community)\n"
11109 "Do not advertise to any peer (well-known community)\n"
11110 "Do not export to next AS (well-known community)\n"
11111 "community number\n"
11112 "Do not send outside local AS (well-known community)\n"
11113 "Do not advertise to any peer (well-known community)\n"
11114 "Do not export to next AS (well-known community)\n")
11117 DEFUN (show_bgp_ipv6_safi_community_exact,
11118 show_bgp_ipv6_safi_community_exact_cmd,
11119 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
11123 "Address family modifier\n"
11124 "Address family modifier\n"
11125 "Address family modifier\n"
11126 "Address family modifier\n"
11127 "Display routes matching the communities\n"
11128 "community number\n"
11129 "Do not send outside local AS (well-known community)\n"
11130 "Do not advertise to any peer (well-known community)\n"
11131 "Do not export to next AS (well-known community)\n"
11132 "Exact match of the communities")
11136 if (bgp_parse_safi(argv[0], &safi)) {
11137 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11138 return CMD_WARNING;
11140 return bgp_show_community (vty, NULL, argc-1, argv+1, 1, AFI_IP6, safi);
11144 ALIAS (show_bgp_community_exact,
11145 show_bgp_ipv6_safi_community2_exact_cmd,
11146 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
11150 "Address family modifier\n"
11151 "Address family modifier\n"
11152 "Address family modifier\n"
11153 "Address family modifier\n"
11154 "Display routes matching the communities\n"
11155 "community number\n"
11156 "Do not send outside local AS (well-known community)\n"
11157 "Do not advertise to any peer (well-known community)\n"
11158 "Do not export to next AS (well-known community)\n"
11159 "community number\n"
11160 "Do not send outside local AS (well-known community)\n"
11161 "Do not advertise to any peer (well-known community)\n"
11162 "Do not export to next AS (well-known community)\n"
11163 "Exact match of the communities")
11165 ALIAS (show_bgp_community_exact,
11166 show_bgp_ipv6_safi_community3_exact_cmd,
11167 "show bgp ipv6 (encap|multicast|unicast|vpn) 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",
11171 "Address family modifier\n"
11172 "Address family modifier\n"
11173 "Address family modifier\n"
11174 "Address family modifier\n"
11175 "Display routes matching the communities\n"
11176 "community number\n"
11177 "Do not send outside local AS (well-known community)\n"
11178 "Do not advertise to any peer (well-known community)\n"
11179 "Do not export to next AS (well-known community)\n"
11180 "community number\n"
11181 "Do not send outside local AS (well-known community)\n"
11182 "Do not advertise to any peer (well-known community)\n"
11183 "Do not export to next AS (well-known community)\n"
11184 "community number\n"
11185 "Do not send outside local AS (well-known community)\n"
11186 "Do not advertise to any peer (well-known community)\n"
11187 "Do not export to next AS (well-known community)\n"
11188 "Exact match of the communities")
11190 ALIAS (show_bgp_community_exact,
11191 show_bgp_ipv6_safi_community4_exact_cmd,
11192 "show bgp ipv6 (encap|multicast|unicast|vpn) 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",
11196 "Address family modifier\n"
11197 "Address family modifier\n"
11198 "Address family modifier\n"
11199 "Address family modifier\n"
11200 "Display routes matching the communities\n"
11201 "community number\n"
11202 "Do not send outside local AS (well-known community)\n"
11203 "Do not advertise to any peer (well-known community)\n"
11204 "Do not export to next AS (well-known community)\n"
11205 "community number\n"
11206 "Do not send outside local AS (well-known community)\n"
11207 "Do not advertise to any peer (well-known community)\n"
11208 "Do not export to next AS (well-known community)\n"
11209 "community number\n"
11210 "Do not send outside local AS (well-known community)\n"
11211 "Do not advertise to any peer (well-known community)\n"
11212 "Do not export to next AS (well-known community)\n"
11213 "community number\n"
11214 "Do not send outside local AS (well-known community)\n"
11215 "Do not advertise to any peer (well-known community)\n"
11216 "Do not export to next AS (well-known community)\n"
11217 "Exact match of the communities")
11220 bgp_show_community_list (struct vty *vty, const char *com, int exact,
11221 afi_t afi, safi_t safi)
11223 struct community_list *list;
11225 list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER);
11228 vty_out (vty, "%% %s is not a valid community-list name%s", com,
11230 return CMD_WARNING;
11233 return bgp_show (vty, NULL, afi, safi,
11234 (exact ? bgp_show_type_community_list_exact :
11235 bgp_show_type_community_list), list);
11238 DEFUN (show_ip_bgp_community_list,
11239 show_ip_bgp_community_list_cmd,
11240 "show ip bgp community-list (<1-500>|WORD)",
11244 "Display routes matching the community-list\n"
11245 "community-list number\n"
11246 "community-list name\n")
11248 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
11251 DEFUN (show_ip_bgp_ipv4_community_list,
11252 show_ip_bgp_ipv4_community_list_cmd,
11253 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
11258 "Address Family modifier\n"
11259 "Address Family modifier\n"
11260 "Display routes matching the community-list\n"
11261 "community-list number\n"
11262 "community-list name\n")
11264 if (strncmp (argv[0], "m", 1) == 0)
11265 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
11267 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
11270 DEFUN (show_ip_bgp_community_list_exact,
11271 show_ip_bgp_community_list_exact_cmd,
11272 "show ip bgp community-list (<1-500>|WORD) exact-match",
11276 "Display routes matching the community-list\n"
11277 "community-list number\n"
11278 "community-list name\n"
11279 "Exact match of the communities\n")
11281 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
11284 DEFUN (show_ip_bgp_ipv4_community_list_exact,
11285 show_ip_bgp_ipv4_community_list_exact_cmd,
11286 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
11291 "Address Family modifier\n"
11292 "Address Family modifier\n"
11293 "Display routes matching the community-list\n"
11294 "community-list number\n"
11295 "community-list name\n"
11296 "Exact match of the communities\n")
11298 if (strncmp (argv[0], "m", 1) == 0)
11299 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
11301 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
11304 DEFUN (show_bgp_community_list,
11305 show_bgp_community_list_cmd,
11306 "show bgp community-list (<1-500>|WORD)",
11309 "Display routes matching the community-list\n"
11310 "community-list number\n"
11311 "community-list name\n")
11313 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
11316 ALIAS (show_bgp_community_list,
11317 show_bgp_ipv6_community_list_cmd,
11318 "show bgp ipv6 community-list (<1-500>|WORD)",
11322 "Display routes matching the community-list\n"
11323 "community-list number\n"
11324 "community-list name\n")
11327 DEFUN (show_ipv6_bgp_community_list,
11328 show_ipv6_bgp_community_list_cmd,
11329 "show ipv6 bgp community-list WORD",
11333 "Display routes matching the community-list\n"
11334 "community-list name\n")
11336 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
11340 DEFUN (show_ipv6_mbgp_community_list,
11341 show_ipv6_mbgp_community_list_cmd,
11342 "show ipv6 mbgp community-list WORD",
11346 "Display routes matching the community-list\n"
11347 "community-list name\n")
11349 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST);
11352 DEFUN (show_bgp_community_list_exact,
11353 show_bgp_community_list_exact_cmd,
11354 "show bgp community-list (<1-500>|WORD) exact-match",
11357 "Display routes matching the community-list\n"
11358 "community-list number\n"
11359 "community-list name\n"
11360 "Exact match of the communities\n")
11362 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
11365 ALIAS (show_bgp_community_list_exact,
11366 show_bgp_ipv6_community_list_exact_cmd,
11367 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
11371 "Display routes matching the community-list\n"
11372 "community-list number\n"
11373 "community-list name\n"
11374 "Exact match of the communities\n")
11377 DEFUN (show_ipv6_bgp_community_list_exact,
11378 show_ipv6_bgp_community_list_exact_cmd,
11379 "show ipv6 bgp community-list WORD exact-match",
11383 "Display routes matching the community-list\n"
11384 "community-list name\n"
11385 "Exact match of the communities\n")
11387 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
11391 DEFUN (show_ipv6_mbgp_community_list_exact,
11392 show_ipv6_mbgp_community_list_exact_cmd,
11393 "show ipv6 mbgp community-list WORD exact-match",
11397 "Display routes matching the community-list\n"
11398 "community-list name\n"
11399 "Exact match of the communities\n")
11401 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST);
11404 DEFUN (show_bgp_ipv4_community_list,
11405 show_bgp_ipv4_community_list_cmd,
11406 "show bgp ipv4 community-list (<1-500>|WORD)",
11410 "Display routes matching the community-list\n"
11411 "community-list number\n"
11412 "community-list name\n")
11414 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
11417 DEFUN (show_bgp_ipv4_safi_community_list,
11418 show_bgp_ipv4_safi_community_list_cmd,
11419 "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
11423 "Address Family modifier\n"
11424 "Address Family modifier\n"
11425 "Display routes matching the community-list\n"
11426 "community-list number\n"
11427 "community-list name\n")
11429 if (strncmp (argv[0], "m", 1) == 0)
11430 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
11432 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
11435 DEFUN (show_bgp_ipv4_community_list_exact,
11436 show_bgp_ipv4_community_list_exact_cmd,
11437 "show bgp ipv4 community-list (<1-500>|WORD) exact-match",
11441 "Display routes matching the community-list\n"
11442 "community-list number\n"
11443 "community-list name\n"
11444 "Exact match of the communities\n")
11446 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
11449 DEFUN (show_bgp_ipv4_safi_community_list_exact,
11450 show_bgp_ipv4_safi_community_list_exact_cmd,
11451 "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
11455 "Address Family modifier\n"
11456 "Address Family modifier\n"
11457 "Display routes matching the community-list\n"
11458 "community-list number\n"
11459 "community-list name\n"
11460 "Exact match of the communities\n")
11462 if (strncmp (argv[0], "m", 1) == 0)
11463 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
11465 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
11468 DEFUN (show_bgp_ipv6_safi_community_list,
11469 show_bgp_ipv6_safi_community_list_cmd,
11470 "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD)",
11474 "Address family modifier\n"
11475 "Address family modifier\n"
11476 "Address family modifier\n"
11477 "Address family modifier\n"
11478 "Display routes matching the community-list\n"
11479 "community-list number\n"
11480 "community-list name\n")
11484 if (bgp_parse_safi(argv[0], &safi)) {
11485 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11486 return CMD_WARNING;
11488 return bgp_show_community_list (vty, argv[1], 0, AFI_IP6, safi);
11491 DEFUN (show_bgp_ipv6_safi_community_list_exact,
11492 show_bgp_ipv6_safi_community_list_exact_cmd,
11493 "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD) exact-match",
11497 "Address family modifier\n"
11498 "Address family modifier\n"
11499 "Address family modifier\n"
11500 "Address family modifier\n"
11501 "Display routes matching the community-list\n"
11502 "community-list number\n"
11503 "community-list name\n"
11504 "Exact match of the communities\n")
11508 if (bgp_parse_safi(argv[0], &safi)) {
11509 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11510 return CMD_WARNING;
11512 return bgp_show_community_list (vty, argv[1], 1, AFI_IP6, safi);
11516 * Large Community show commands.
11519 DEFUN (show_bgp_afi_lcommunity_all,
11520 show_bgp_afi_lcommunity_all_cmd,
11521 "show bgp (ipv4|ipv6) large-community",
11526 "Display routes matching the large-communities\n")
11529 safi_t safi = SAFI_UNICAST;
11531 if (bgp_parse_afi(argv[0], &afi)) {
11532 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
11533 return CMD_WARNING;
11535 return bgp_show (vty, NULL, afi, safi, bgp_show_type_lcommunity_all, NULL);
11539 bgp_show_lcommunity (struct vty *vty, const char *view_name, int argc,
11540 const char **argv, afi_t afi, safi_t safi)
11542 struct lcommunity *lcom;
11549 /* BGP structure lookup */
11552 bgp = bgp_lookup_by_name (view_name);
11555 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
11556 return CMD_WARNING;
11561 bgp = bgp_get_default ();
11564 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
11565 return CMD_WARNING;
11569 b = buffer_new (1024);
11570 for (i = 0; i < argc; i++)
11573 buffer_putc (b, ' ');
11576 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
11581 buffer_putstr (b, argv[i]);
11583 buffer_putc (b, '\0');
11585 str = buffer_getstr (b);
11588 lcom = lcommunity_str2com (str);
11589 XFREE (MTYPE_TMP, str);
11592 vty_out (vty, "%% Large-community malformed: %s", VTY_NEWLINE);
11593 return CMD_WARNING;
11596 return bgp_show (vty, bgp, afi, safi, bgp_show_type_lcommunity, lcom);
11599 DEFUN (show_ip_bgp_lcommunity,
11600 show_ip_bgp_lcommunity_cmd,
11601 "show ip bgp large-community (AA:BB:CC)",
11605 "Display routes matching the large-communities\n"
11606 "large-community number\n")
11608 return bgp_show_lcommunity (vty, NULL, argc, argv, AFI_IP, SAFI_UNICAST);
11611 ALIAS (show_ip_bgp_lcommunity,
11612 show_ip_bgp_lcommunity2_cmd,
11613 "show ip bgp large-community (AA:BB:CC) (AA:BB:CC)",
11617 "Display routes matching the large-communities\n"
11618 "large-community number\n"
11619 "large-community number\n")
11621 ALIAS (show_ip_bgp_lcommunity,
11622 show_ip_bgp_lcommunity3_cmd,
11623 "show ip bgp large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11627 "Display routes matching the large-communities\n"
11628 "largecommunity number\n"
11629 "largecommunity number\n"
11630 "largecommunity number\n")
11632 ALIAS (show_ip_bgp_lcommunity,
11633 show_ip_bgp_lcommunity4_cmd,
11634 "show ip bgp large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11638 "Display routes matching the large-communities\n"
11639 "large-community number\n"
11640 "large-community number\n"
11641 "large-community number\n"
11642 "large-community number\n")
11644 DEFUN (show_ip_bgp_ipv4_lcommunity,
11645 show_ip_bgp_ipv4_lcommunity_cmd,
11646 "show ip bgp ipv4 (unicast|multicast) large-community (AA:BB:CC)",
11651 "Address Family modifier\n"
11652 "Address Family modifier\n"
11653 "Display routes matching the large-communities\n"
11654 "large-community number\n")
11656 if (strncmp (argv[0], "m", 1) == 0)
11657 return bgp_show_lcommunity (vty, NULL, argc, argv, AFI_IP, SAFI_MULTICAST);
11659 return bgp_show_lcommunity (vty, NULL, argc, argv, AFI_IP, SAFI_UNICAST);
11662 ALIAS (show_ip_bgp_ipv4_lcommunity,
11663 show_ip_bgp_ipv4_lcommunity2_cmd,
11664 "show ip bgp ipv4 (unicast|multicast) large-community (AA:BB:CC) (AA:BB:CC)",
11669 "Address Family modifier\n"
11670 "Address Family modifier\n"
11671 "Display routes matching the large-communities\n"
11672 "large-community number\n"
11673 "large-community number\n")
11675 ALIAS (show_ip_bgp_ipv4_lcommunity,
11676 show_ip_bgp_ipv4_lcommunity3_cmd,
11677 "show ip bgp ipv4 (unicast|multicast) large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11682 "Address Family modifier\n"
11683 "Address Family modifier\n"
11684 "Display routes matching the large-communities\n"
11685 "large-community number\n"
11686 "large-community number\n"
11687 "large-community number\n")
11689 ALIAS (show_ip_bgp_ipv4_lcommunity,
11690 show_ip_bgp_ipv4_lcommunity4_cmd,
11691 "show ip bgp ipv4 (unicast|multicast) large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11696 "Address Family modifier\n"
11697 "Address Family modifier\n"
11698 "Display routes matching the large-communities\n"
11699 "large-community number\n"
11700 "large-community number\n"
11701 "large-community number\n"
11702 "large-community number\n")
11704 DEFUN (show_bgp_lcommunity,
11705 show_bgp_lcommunity_cmd,
11706 "show bgp large-community (AA:BB:CC)",
11709 "Display routes matching the large-communities\n"
11710 "large-community number\n")
11712 return bgp_show_lcommunity (vty, NULL, argc, argv, AFI_IP6, SAFI_UNICAST);
11715 ALIAS (show_bgp_lcommunity,
11716 show_bgp_ipv6_lcommunity_cmd,
11717 "show bgp ipv6 large-community (AA:BB:CC)",
11721 "Display routes matching the large-communities\n"
11722 "large-community number\n")
11724 ALIAS (show_bgp_lcommunity,
11725 show_bgp_lcommunity2_cmd,
11726 "show bgp large-community (AA:BB:CC) (AA:BB:CC)",
11729 "Display routes matching the large-communities\n"
11730 "large-community number\n"
11731 "large-community number\n")
11733 ALIAS (show_bgp_lcommunity,
11734 show_bgp_ipv6_lcommunity2_cmd,
11735 "show bgp ipv6 large-community (AA:BB:CC) (AA:BB:CC)",
11739 "Display routes matching the large-communities\n"
11740 "large-community number\n"
11741 "large-community number\n")
11743 ALIAS (show_bgp_lcommunity,
11744 show_bgp_lcommunity3_cmd,
11745 "show bgp large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11748 "Display routes matching the large-communities\n"
11749 "large-community number\n"
11750 "large-community number\n"
11751 "large-community number\n")
11753 ALIAS (show_bgp_lcommunity,
11754 show_bgp_ipv6_lcommunity3_cmd,
11755 "show bgp ipv6 large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11759 "Display routes matching the large-communities\n"
11760 "large-community number\n"
11761 "large-community number\n"
11762 "large-community number\n")
11764 ALIAS (show_bgp_lcommunity,
11765 show_bgp_lcommunity4_cmd,
11766 "show bgp large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11769 "Display routes matching the large-communities\n"
11770 "large-community number\n"
11771 "large-community number\n"
11772 "large-community number\n"
11773 "large-community number\n")
11775 ALIAS (show_bgp_lcommunity,
11776 show_bgp_ipv6_lcommunity4_cmd,
11777 "show bgp ipv6 large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11781 "Display routes matching the large-communities\n"
11782 "large-community number\n"
11783 "large-community number\n"
11784 "large-community number\n"
11785 "large-community number\n")
11788 DEFUN (show_ipv6_bgp_lcommunity,
11789 show_ipv6_bgp_lcommunity_cmd,
11790 "show ipv6 bgp large-community (AA:BB:CC)",
11794 "Display routes matching the large-communities\n"
11795 "large-community number\n")
11797 return bgp_show_lcommunity (vty, NULL, argc, argv, AFI_IP6, SAFI_UNICAST);
11801 ALIAS (show_ipv6_bgp_lcommunity,
11802 show_ipv6_bgp_lcommunity2_cmd,
11803 "show ipv6 bgp large-community (AA:BB:CC) (AA:BB:CC)",
11807 "Display routes matching the large-communities\n"
11808 "large-community number\n"
11809 "large-community number\n")
11812 ALIAS (show_ipv6_bgp_lcommunity,
11813 show_ipv6_bgp_lcommunity3_cmd,
11814 "show ipv6 bgp large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11818 "Display routes matching the large-communities\n"
11819 "large-community number\n"
11820 "large-community number\n"
11821 "large-community number\n")
11824 ALIAS (show_ipv6_bgp_lcommunity,
11825 show_ipv6_bgp_lcommunity4_cmd,
11826 "show ipv6 bgp large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11830 "Display routes matching the large-communities\n"
11831 "large-community number\n"
11832 "large-community number\n"
11833 "large-community number\n"
11834 "large-community number\n")
11837 DEFUN (show_ipv6_mbgp_lcommunity,
11838 show_ipv6_mbgp_lcommunity_cmd,
11839 "show ipv6 mbgp large-community (AA:BB:CC)",
11843 "Display routes matching the large-communities\n"
11844 "large-community number\n")
11846 return bgp_show_lcommunity (vty, NULL, argc, argv, AFI_IP6, SAFI_MULTICAST);
11850 ALIAS (show_ipv6_mbgp_lcommunity,
11851 show_ipv6_mbgp_lcommunity2_cmd,
11852 "show ipv6 mbgp large-community (AA:BB:CC) (AA:BB:CC)",
11856 "Display routes matching the large-communities\n"
11857 "large-community number\n"
11858 "large-community number\n")
11861 ALIAS (show_ipv6_mbgp_lcommunity,
11862 show_ipv6_mbgp_lcommunity3_cmd,
11863 "show ipv6 mbgp large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11867 "Display routes matching the large-communities\n"
11868 "large-community number\n"
11869 "large-community number\n"
11870 "large-community number\n")
11873 ALIAS (show_ipv6_mbgp_lcommunity,
11874 show_ipv6_mbgp_lcommunity4_cmd,
11875 "show ipv6 mbgp laarge-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11879 "Display routes matching the large-communities\n"
11880 "large-community number\n"
11881 "large-community number\n"
11882 "large-community number\n"
11883 "large-community number\n")
11885 DEFUN (show_bgp_ipv4_lcommunity,
11886 show_bgp_ipv4_lcommunity_cmd,
11887 "show bgp ipv4 large-community (AA:BB:CC)",
11891 "Display routes matching the large-communities\n"
11892 "large-community number\n")
11894 return bgp_show_lcommunity (vty, NULL, argc, argv, AFI_IP, SAFI_UNICAST);
11897 ALIAS (show_bgp_ipv4_lcommunity,
11898 show_bgp_ipv4_lcommunity2_cmd,
11899 "show bgp ipv4 large-community (AA:BB:CC) (AA:BB:CC)",
11903 "Display routes matching the large-communities\n"
11904 "large-community number\n"
11905 "large-community number\n")
11907 ALIAS (show_bgp_ipv4_lcommunity,
11908 show_bgp_ipv4_lcommunity3_cmd,
11909 "show bgp ipv4 large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11913 "Display routes matching the large-communities\n"
11914 "large-community number\n"
11915 "large-community number\n"
11916 "large-community number\n")
11918 ALIAS (show_bgp_ipv4_lcommunity,
11919 show_bgp_ipv4_lcommunity4_cmd,
11920 "show bgp ipv4 large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11924 "Display routes matching the large-communities\n"
11925 "large-community number\n"
11926 "large-community number\n"
11927 "large-community number\n"
11928 "large-community number\n")
11930 DEFUN (show_bgp_ipv4_safi_lcommunity,
11931 show_bgp_ipv4_safi_lcommunity_cmd,
11932 "show bgp ipv4 (unicast|multicast) large-community (AA:BB:CC)",
11936 "Address Family modifier\n"
11937 "Address Family modifier\n"
11938 "Display routes matching the large-communities\n"
11939 "large-community number\n")
11941 if (strncmp (argv[0], "m", 1) == 0)
11942 return bgp_show_lcommunity (vty, NULL, argc, argv, AFI_IP, SAFI_MULTICAST);
11944 return bgp_show_lcommunity (vty, NULL, argc, argv, AFI_IP, SAFI_UNICAST);
11947 ALIAS (show_bgp_ipv4_safi_lcommunity,
11948 show_bgp_ipv4_safi_lcommunity2_cmd,
11949 "show bgp ipv4 (unicast|multicast) large-community (AA:BB:CC) (AA:BB:CC)",
11953 "Address Family modifier\n"
11954 "Address Family modifier\n"
11955 "Display routes matching the large-communities\n"
11956 "large-community number\n"
11957 "large-community number\n")
11959 ALIAS (show_bgp_ipv4_safi_lcommunity,
11960 show_bgp_ipv4_safi_lcommunity3_cmd,
11961 "show bgp ipv4 (unicast|multicast) large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11965 "Address Family modifier\n"
11966 "Address Family modifier\n"
11967 "Display routes matching the large-communities\n"
11968 "large-community number\n"
11969 "large-community number\n"
11970 "large-community number\n")
11972 ALIAS (show_bgp_ipv4_safi_lcommunity,
11973 show_bgp_ipv4_safi_lcommunity4_cmd,
11974 "show bgp ipv4 (unicast|multicast) large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
11978 "Address Family modifier\n"
11979 "Address Family modifier\n"
11980 "Display routes matching the large-communities\n"
11981 "large-community number\n"
11982 "large-community number\n"
11983 "large-community number\n"
11984 "large-community number\n")
11986 DEFUN (show_bgp_view_afi_safi_lcommunity_all,
11987 show_bgp_view_afi_safi_lcommunity_all_cmd,
11988 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) large-community",
11995 "Address Family modifier\n"
11996 "Address Family modifier\n"
11997 "Display routes matching the large-communities\n")
12003 /* BGP structure lookup. */
12004 bgp = bgp_lookup_by_name (argv[0]);
12007 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
12008 return CMD_WARNING;
12011 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
12012 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
12013 return bgp_show (vty, bgp, afi, safi, bgp_show_type_lcommunity_all, NULL);
12016 DEFUN (show_bgp_view_afi_safi_lcommunity,
12017 show_bgp_view_afi_safi_lcommunity_cmd,
12018 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) large-community (AA:BB:CC)",
12025 "Address family modifier\n"
12026 "Address family modifier\n"
12027 "Display routes matching the large-communities\n"
12028 "large-community number\n")
12033 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
12034 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
12035 return bgp_show_lcommunity (vty, argv[0], argc-3, &argv[3], afi, safi);
12038 ALIAS (show_bgp_view_afi_safi_lcommunity,
12039 show_bgp_view_afi_safi_lcommunity2_cmd,
12040 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) large-community (AA:BB:CC) (AA:BB:CC)",
12047 "Address family modifier\n"
12048 "Address family modifier\n"
12049 "Display routes matching the large-communities\n"
12050 "large-community number\n"
12051 "large-community number\n")
12053 ALIAS (show_bgp_view_afi_safi_lcommunity,
12054 show_bgp_view_afi_safi_lcommunity3_cmd,
12055 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
12062 "Address family modifier\n"
12063 "Address family modifier\n"
12064 "Display routes matching the large-communities\n"
12065 "large-community number\n"
12066 "large-community number\n"
12067 "large-community number\n")
12069 ALIAS (show_bgp_view_afi_safi_lcommunity,
12070 show_bgp_view_afi_safi_lcommunity4_cmd,
12071 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
12078 "Address family modifier\n"
12079 "Address family modifier\n"
12080 "Display routes matching the large-communities\n"
12081 "large-community number\n"
12082 "large-community number\n"
12083 "large-community number\n"
12084 "large-community number\n")
12086 DEFUN (show_bgp_ipv6_safi_lcommunity,
12087 show_bgp_ipv6_safi_lcommunity_cmd,
12088 "show bgp ipv6 (encap|multicast|unicast|vpn) large-community AA:BB:CC",
12092 "Address family modifier\n"
12093 "Address family modifier\n"
12094 "Address family modifier\n"
12095 "Address family modifier\n"
12096 "Display routes matching the large-communities\n"
12097 "large-community number\n")
12101 if (bgp_parse_safi(argv[0], &safi)) {
12102 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12103 return CMD_WARNING;
12105 return bgp_show_lcommunity (vty, NULL, argc-1, argv+1, AFI_IP6, safi);
12108 ALIAS (show_bgp_ipv6_safi_lcommunity,
12109 show_bgp_ipv6_safi_lcommunity2_cmd,
12110 "show bgp ipv6 (encap|multicast|unicast|vpn) large-community (AA:BB:CC) (AA:BB:CC)",
12114 "Address family modifier\n"
12115 "Address family modifier\n"
12116 "Address family modifier\n"
12117 "Address family modifier\n"
12118 "Display routes matching the large-communities\n"
12119 "large-community number\n"
12120 "large-community number\n")
12122 ALIAS (show_bgp_ipv6_safi_lcommunity,
12123 show_bgp_ipv6_safi_lcommunity3_cmd,
12124 "show bgp ipv6 (encap|multicast|unicast|vpn) large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
12128 "Address family modifier\n"
12129 "Address family modifier\n"
12130 "Address family modifier\n"
12131 "Address family modifier\n"
12132 "Display routes matching the large-communities\n"
12133 "large-community number\n"
12134 "large-community number\n"
12135 "large-community number\n")
12137 ALIAS (show_bgp_ipv6_safi_lcommunity,
12138 show_bgp_ipv6_safi_lcommunity4_cmd,
12139 "show bgp ipv6 (encap|multicast|unicast|vpn) large-community (AA:BB:CC) (AA:BB:CC) (AA:BB:CC) (AA:BB:CC)",
12143 "Address family modifier\n"
12144 "Address family modifier\n"
12145 "Address family modifier\n"
12146 "Address family modifier\n"
12147 "Display routes matching the large-communities\n"
12148 "large-community number\n"
12149 "large-community number\n"
12150 "large-community number\n"
12151 "large-community number\n")
12154 bgp_show_lcommunity_list (struct vty *vty, const char *lcom,
12155 afi_t afi, safi_t safi)
12157 struct community_list *list;
12159 list = community_list_lookup (bgp_clist, lcom, LARGE_COMMUNITY_LIST_MASTER);
12162 vty_out (vty, "%% %s is not a valid large-community-list name%s", lcom,
12164 return CMD_WARNING;
12167 return bgp_show (vty, NULL, afi, safi, bgp_show_type_lcommunity_list, list);
12170 DEFUN (show_ip_bgp_lcommunity_list,
12171 show_ip_bgp_lcommunity_list_cmd,
12172 "show ip bgp large-community-list (<1-500>|WORD)",
12176 "Display routes matching the large-community-list\n"
12177 "large-community-list number\n"
12178 "large-community-list name\n")
12180 return bgp_show_lcommunity_list (vty, argv[0], AFI_IP, SAFI_UNICAST);
12183 DEFUN (show_ip_bgp_ipv4_lcommunity_list,
12184 show_ip_bgp_ipv4_lcommunity_list_cmd,
12185 "show ip bgp ipv4 (unicast|multicast) large-community-list (<1-500>|WORD)",
12190 "Address Family modifier\n"
12191 "Address Family modifier\n"
12192 "Display routes matching the large-community-list\n"
12193 "large-community-list number\n"
12194 "large-community-list name\n")
12196 if (strncmp (argv[0], "m", 1) == 0)
12197 return bgp_show_lcommunity_list (vty, argv[1], AFI_IP, SAFI_MULTICAST);
12199 return bgp_show_lcommunity_list (vty, argv[1], AFI_IP, SAFI_UNICAST);
12202 DEFUN (show_bgp_lcommunity_list,
12203 show_bgp_lcommunity_list_cmd,
12204 "show bgp large-community-list (<1-500>|WORD)",
12207 "Display routes matching the large-community-list\n"
12208 "large-community-list number\n"
12209 "large-community-list name\n")
12211 return bgp_show_lcommunity_list (vty, argv[0], AFI_IP6, SAFI_UNICAST);
12214 ALIAS (show_bgp_lcommunity_list,
12215 show_bgp_ipv6_lcommunity_list_cmd,
12216 "show bgp ipv6 large-community-list (<1-500>|WORD)",
12220 "Display routes matching the large-community-list\n"
12221 "large-community-list number\n"
12222 "large-community-list name\n")
12225 DEFUN (show_ipv6_bgp_lcommunity_list,
12226 show_ipv6_bgp_lcommunity_list_cmd,
12227 "show ipv6 bgp large-community-list WORD",
12231 "Display routes matching the large-community-list\n"
12232 "large-community-list name\n")
12234 return bgp_show_lcommunity_list (vty, argv[0], AFI_IP6, SAFI_UNICAST);
12238 DEFUN (show_ipv6_mbgp_lcommunity_list,
12239 show_ipv6_mbgp_lcommunity_list_cmd,
12240 "show ipv6 mbgp large-community-list WORD",
12244 "Display routes matching the large-community-list\n"
12245 "large-community-list name\n")
12247 return bgp_show_lcommunity_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST);
12250 DEFUN (show_bgp_ipv4_lcommunity_list,
12251 show_bgp_ipv4_lcommunity_list_cmd,
12252 "show bgp ipv4 large-community-list (<1-500>|WORD)",
12256 "Display routes matching the large-community-list\n"
12257 "large-community-list number\n"
12258 "large-community-list name\n")
12260 return bgp_show_lcommunity_list (vty, argv[0], AFI_IP, SAFI_UNICAST);
12263 DEFUN (show_bgp_ipv4_safi_lcommunity_list,
12264 show_bgp_ipv4_safi_lcommunity_list_cmd,
12265 "show bgp ipv4 (unicast|multicast) large-community-list (<1-500>|WORD)",
12269 "Address Family modifier\n"
12270 "Address Family modifier\n"
12271 "Display routes matching the large-community-list\n"
12272 "large-community-list number\n"
12273 "large-community-list name\n")
12275 if (strncmp (argv[0], "m", 1) == 0)
12276 return bgp_show_lcommunity_list (vty, argv[1], AFI_IP, SAFI_MULTICAST);
12278 return bgp_show_lcommunity_list (vty, argv[1], AFI_IP, SAFI_UNICAST);
12281 DEFUN (show_bgp_ipv6_safi_lcommunity_list,
12282 show_bgp_ipv6_safi_lcommunity_list_cmd,
12283 "show bgp ipv6 (encap|multicast|unicast|vpn) large-community-list (<1-500>|WORD)",
12287 "Address family modifier\n"
12288 "Address family modifier\n"
12289 "Address family modifier\n"
12290 "Address family modifier\n"
12291 "Display routes matching the large-community-list\n"
12292 "large-community-list number\n"
12293 "large-community-list name\n")
12297 if (bgp_parse_safi(argv[0], &safi)) {
12298 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12299 return CMD_WARNING;
12301 return bgp_show_lcommunity_list (vty, argv[1], AFI_IP6, safi);
12305 bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi,
12306 safi_t safi, enum bgp_show_type type)
12313 ret = str2prefix (prefix, p);
12316 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
12317 return CMD_WARNING;
12320 ret = bgp_show (vty, NULL, afi, safi, type, p);
12325 DEFUN (show_ip_bgp_prefix_longer,
12326 show_ip_bgp_prefix_longer_cmd,
12327 "show ip bgp A.B.C.D/M longer-prefixes",
12331 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
12332 "Display route and more specific routes\n")
12334 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
12335 bgp_show_type_prefix_longer);
12338 DEFUN (show_ip_bgp_flap_prefix_longer,
12339 show_ip_bgp_flap_prefix_longer_cmd,
12340 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
12344 "Display flap statistics of routes\n"
12345 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
12346 "Display route and more specific routes\n")
12348 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
12349 bgp_show_type_flap_prefix_longer);
12352 ALIAS (show_ip_bgp_flap_prefix_longer,
12353 show_ip_bgp_damp_flap_prefix_longer_cmd,
12354 "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes",
12358 "Display detailed information about dampening\n"
12359 "Display flap statistics of routes\n"
12360 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
12361 "Display route and more specific routes\n")
12363 DEFUN (show_ip_bgp_ipv4_prefix_longer,
12364 show_ip_bgp_ipv4_prefix_longer_cmd,
12365 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
12370 "Address Family modifier\n"
12371 "Address Family modifier\n"
12372 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
12373 "Display route and more specific routes\n")
12375 if (strncmp (argv[0], "m", 1) == 0)
12376 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST,
12377 bgp_show_type_prefix_longer);
12379 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST,
12380 bgp_show_type_prefix_longer);
12383 DEFUN (show_ip_bgp_flap_address,
12384 show_ip_bgp_flap_address_cmd,
12385 "show ip bgp flap-statistics A.B.C.D",
12389 "Display flap statistics of routes\n"
12390 "Network in the BGP routing table to display\n")
12392 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
12393 bgp_show_type_flap_address);
12396 ALIAS (show_ip_bgp_flap_address,
12397 show_ip_bgp_damp_flap_address_cmd,
12398 "show ip bgp dampening flap-statistics A.B.C.D",
12402 "Display detailed information about dampening\n"
12403 "Display flap statistics of routes\n"
12404 "Network in the BGP routing table to display\n")
12406 DEFUN (show_ip_bgp_flap_prefix,
12407 show_ip_bgp_flap_prefix_cmd,
12408 "show ip bgp flap-statistics A.B.C.D/M",
12412 "Display flap statistics of routes\n"
12413 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
12415 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
12416 bgp_show_type_flap_prefix);
12419 ALIAS (show_ip_bgp_flap_prefix,
12420 show_ip_bgp_damp_flap_prefix_cmd,
12421 "show ip bgp dampening flap-statistics A.B.C.D/M",
12425 "Display detailed information about dampening\n"
12426 "Display flap statistics of routes\n"
12427 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
12429 DEFUN (show_bgp_prefix_longer,
12430 show_bgp_prefix_longer_cmd,
12431 "show bgp X:X::X:X/M longer-prefixes",
12434 "IPv6 prefix <network>/<length>\n"
12435 "Display route and more specific routes\n")
12437 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
12438 bgp_show_type_prefix_longer);
12442 DEFUN (show_ipv6_bgp_prefix_longer,
12443 show_ipv6_bgp_prefix_longer_cmd,
12444 "show ipv6 bgp X:X::X:X/M longer-prefixes",
12448 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
12449 "Display route and more specific routes\n")
12451 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
12452 bgp_show_type_prefix_longer);
12456 DEFUN (show_ipv6_mbgp_prefix_longer,
12457 show_ipv6_mbgp_prefix_longer_cmd,
12458 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
12462 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
12463 "Display route and more specific routes\n")
12465 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
12466 bgp_show_type_prefix_longer);
12469 DEFUN (show_bgp_ipv4_prefix_longer,
12470 show_bgp_ipv4_prefix_longer_cmd,
12471 "show bgp ipv4 A.B.C.D/M longer-prefixes",
12475 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
12476 "Display route and more specific routes\n")
12478 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
12479 bgp_show_type_prefix_longer);
12482 DEFUN (show_bgp_ipv4_safi_flap_prefix_longer,
12483 show_bgp_ipv4_safi_flap_prefix_longer_cmd,
12484 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M longer-prefixes",
12488 "Address Family modifier\n"
12489 "Address Family modifier\n"
12490 "Address Family modifier\n"
12491 "Address Family modifier\n"
12492 "Display flap statistics of routes\n"
12493 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
12494 "Display route and more specific routes\n")
12498 if (bgp_parse_safi(argv[0], &safi)) {
12499 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12500 return CMD_WARNING;
12502 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
12503 bgp_show_type_flap_prefix_longer);
12506 ALIAS (show_bgp_ipv4_safi_flap_prefix_longer,
12507 show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd,
12508 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M longer-prefixes",
12512 "Address Family modifier\n"
12513 "Address Family modifier\n"
12514 "Address Family modifier\n"
12515 "Address Family modifier\n"
12516 "Display detailed information about dampening\n"
12517 "Display flap statistics of routes\n"
12518 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
12519 "Display route and more specific routes\n")
12521 DEFUN (show_bgp_ipv6_safi_flap_prefix_longer,
12522 show_bgp_ipv6_safi_flap_prefix_longer_cmd,
12523 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M longer-prefixes",
12527 "Address Family modifier\n"
12528 "Address Family modifier\n"
12529 "Address Family modifier\n"
12530 "Address Family modifier\n"
12531 "Display flap statistics of routes\n"
12532 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
12533 "Display route and more specific routes\n")
12537 if (bgp_parse_safi(argv[0], &safi)) {
12538 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12539 return CMD_WARNING;
12541 return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
12542 bgp_show_type_flap_prefix_longer);
12544 ALIAS (show_bgp_ipv6_safi_flap_prefix_longer,
12545 show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd,
12546 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M longer-prefixes",
12550 "Address Family modifier\n"
12551 "Address Family modifier\n"
12552 "Address Family modifier\n"
12553 "Address Family modifier\n"
12554 "Display detailed information about dampening\n"
12555 "Display flap statistics of routes\n"
12556 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
12557 "Display route and more specific routes\n")
12559 DEFUN (show_bgp_ipv4_safi_prefix_longer,
12560 show_bgp_ipv4_safi_prefix_longer_cmd,
12561 "show bgp ipv4 (encap|multicast|unicast|vpn) A.B.C.D/M longer-prefixes",
12565 "Address Family modifier\n"
12566 "Address Family modifier\n"
12567 "Address Family modifier\n"
12568 "Address Family modifier\n"
12569 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
12570 "Display route and more specific routes\n")
12574 if (bgp_parse_safi(argv[0], &safi)) {
12575 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12576 return CMD_WARNING;
12579 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
12580 bgp_show_type_prefix_longer);
12583 DEFUN (show_bgp_ipv6_safi_prefix_longer,
12584 show_bgp_ipv6_safi_prefix_longer_cmd,
12585 "show bgp ipv6 (encap|multicast|unicast|vpn) X:X::X:X/M longer-prefixes",
12589 "Address Family modifier\n"
12590 "Address Family modifier\n"
12591 "Address Family modifier\n"
12592 "Address Family modifier\n"
12593 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
12594 "Display route and more specific routes\n")
12598 if (bgp_parse_safi(argv[0], &safi)) {
12599 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12600 return CMD_WARNING;
12603 return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
12604 bgp_show_type_prefix_longer);
12607 DEFUN (show_bgp_ipv4_safi_flap_address,
12608 show_bgp_ipv4_safi_flap_address_cmd,
12609 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
12613 "Address Family modifier\n"
12614 "Address Family modifier\n"
12615 "Address Family modifier\n"
12616 "Address Family modifier\n"
12617 "Display flap statistics of routes\n"
12618 "Network in the BGP routing table to display\n")
12622 if (bgp_parse_safi(argv[0], &safi)) {
12623 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12624 return CMD_WARNING;
12626 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
12627 bgp_show_type_flap_address);
12629 ALIAS (show_bgp_ipv4_safi_flap_address,
12630 show_bgp_ipv4_safi_damp_flap_address_cmd,
12631 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
12635 "Address Family modifier\n"
12636 "Address Family modifier\n"
12637 "Address Family modifier\n"
12638 "Address Family modifier\n"
12639 "Display detailed information about dampening\n"
12640 "Display flap statistics of routes\n"
12641 "Network in the BGP routing table to display\n")
12643 DEFUN (show_bgp_ipv6_flap_address,
12644 show_bgp_ipv6_flap_address_cmd,
12645 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
12649 "Address Family modifier\n"
12650 "Address Family modifier\n"
12651 "Address Family modifier\n"
12652 "Address Family modifier\n"
12653 "Display flap statistics of routes\n"
12654 "Network in the BGP routing table to display\n")
12658 if (bgp_parse_safi(argv[0], &safi)) {
12659 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
12660 return CMD_WARNING;
12662 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
12663 bgp_show_type_flap_address);
12665 ALIAS (show_bgp_ipv6_flap_address,
12666 show_bgp_ipv6_damp_flap_address_cmd,
12667 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
12671 "Address Family modifier\n"
12672 "Address Family modifier\n"
12673 "Address Family modifier\n"
12674 "Address Family modifier\n"
12675 "Display detailed information about dampening\n"
12676 "Display flap statistics of routes\n"
12677 "Network in the BGP routing table to display\n")
12679 DEFUN (show_bgp_ipv4_safi_flap_prefix,
12680 show_bgp_ipv4_safi_flap_prefix_cmd,
12681 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M",
12685 "Address Family modifier\n"
12686 "Address Family modifier\n"
12687 "Address Family modifier\n"
12688 "Address Family modifier\n"
12689 "Display flap statistics of routes\n"
12690 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
12694 if (bgp_parse_safi(argv[0], &safi)) {
12695 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
12696 return CMD_WARNING;
12698 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, safi,
12699 bgp_show_type_flap_prefix);
12702 ALIAS (show_bgp_ipv4_safi_flap_prefix,
12703 show_bgp_ipv4_safi_damp_flap_prefix_cmd,
12704 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M",
12708 "Address Family modifier\n"
12709 "Address Family modifier\n"
12710 "Address Family modifier\n"
12711 "Address Family modifier\n"
12712 "Display detailed information about dampening\n"
12713 "Display flap statistics of routes\n"
12714 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
12716 DEFUN (show_bgp_ipv6_safi_flap_prefix,
12717 show_bgp_ipv6_safi_flap_prefix_cmd,
12718 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M",
12722 "Address Family modifier\n"
12723 "Address Family modifier\n"
12724 "Address Family modifier\n"
12725 "Address Family modifier\n"
12726 "Display flap statistics of routes\n"
12727 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
12731 if (bgp_parse_safi(argv[0], &safi)) {
12732 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
12733 return CMD_WARNING;
12735 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, safi,
12736 bgp_show_type_flap_prefix);
12739 ALIAS (show_bgp_ipv6_safi_flap_prefix,
12740 show_bgp_ipv6_safi_damp_flap_prefix_cmd,
12741 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M",
12745 "Address Family modifier\n"
12746 "Address Family modifier\n"
12747 "Address Family modifier\n"
12748 "Address Family modifier\n"
12749 "Display detailed information about dampening\n"
12750 "Display flap statistics of routes\n"
12751 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
12753 DEFUN (show_bgp_ipv6_prefix_longer,
12754 show_bgp_ipv6_prefix_longer_cmd,
12755 "show bgp ipv6 X:X::X:X/M longer-prefixes",
12759 "IPv6 prefix <network>/<length>\n"
12760 "Display route and more specific routes\n")
12762 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
12763 bgp_show_type_prefix_longer);
12766 static struct peer *
12767 peer_lookup_in_view (struct vty *vty, const char *view_name,
12768 const char *ip_str)
12773 union sockunion su;
12775 /* BGP structure lookup. */
12778 bgp = bgp_lookup_by_name (view_name);
12781 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
12787 bgp = bgp_get_default ();
12790 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
12795 /* Get peer sockunion. */
12796 ret = str2sockunion (ip_str, &su);
12799 vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE);
12803 /* Peer structure lookup. */
12804 peer = peer_lookup (bgp, &su);
12807 vty_out (vty, "No such neighbor%s", VTY_NEWLINE);
12816 BGP_STATS_MAXBITLEN = 0,
12818 BGP_STATS_PREFIXES,
12820 BGP_STATS_UNAGGREGATEABLE,
12821 BGP_STATS_MAX_AGGREGATEABLE,
12822 BGP_STATS_AGGREGATES,
12824 BGP_STATS_ASPATH_COUNT,
12825 BGP_STATS_ASPATH_MAXHOPS,
12826 BGP_STATS_ASPATH_TOTHOPS,
12827 BGP_STATS_ASPATH_MAXSIZE,
12828 BGP_STATS_ASPATH_TOTSIZE,
12829 BGP_STATS_ASN_HIGHEST,
12833 static const char *table_stats_strs[] =
12835 [BGP_STATS_PREFIXES] = "Total Prefixes",
12836 [BGP_STATS_TOTPLEN] = "Average prefix length",
12837 [BGP_STATS_RIB] = "Total Advertisements",
12838 [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes",
12839 [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes",
12840 [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements",
12841 [BGP_STATS_SPACE] = "Address space advertised",
12842 [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths",
12843 [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)",
12844 [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)",
12845 [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)",
12846 [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)",
12847 [BGP_STATS_ASN_HIGHEST] = "Highest public ASN",
12848 [BGP_STATS_MAX] = NULL,
12851 struct bgp_table_stats
12853 struct bgp_table *table;
12854 unsigned long long counts[BGP_STATS_MAX];
12858 #define TALLY_SIGFIG 100000
12859 static unsigned long
12860 ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval)
12862 unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG);
12863 unsigned long res = (newtot * TALLY_SIGFIG) / count;
12864 unsigned long ret = newtot / count;
12866 if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2))
12874 bgp_table_stats_walker (struct thread *t)
12876 struct bgp_node *rn;
12877 struct bgp_node *top;
12878 struct bgp_table_stats *ts = THREAD_ARG (t);
12879 unsigned int space = 0;
12881 if (!(top = bgp_table_top (ts->table)))
12884 switch (top->p.family)
12887 space = IPV4_MAX_BITLEN;
12890 space = IPV6_MAX_BITLEN;
12894 ts->counts[BGP_STATS_MAXBITLEN] = space;
12896 for (rn = top; rn; rn = bgp_route_next (rn))
12898 struct bgp_info *ri;
12899 struct bgp_node *prn = bgp_node_parent_nolock (rn);
12900 unsigned int rinum = 0;
12908 ts->counts[BGP_STATS_PREFIXES]++;
12909 ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen;
12912 ts->counts[BGP_STATS_AVGPLEN]
12913 = ravg_tally (ts->counts[BGP_STATS_PREFIXES],
12914 ts->counts[BGP_STATS_AVGPLEN],
12918 /* check if the prefix is included by any other announcements */
12919 while (prn && !prn->info)
12920 prn = bgp_node_parent_nolock (prn);
12922 if (prn == NULL || prn == top)
12924 ts->counts[BGP_STATS_UNAGGREGATEABLE]++;
12925 /* announced address space */
12927 ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen);
12929 else if (prn->info)
12930 ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++;
12932 for (ri = rn->info; ri; ri = ri->next)
12935 ts->counts[BGP_STATS_RIB]++;
12938 (CHECK_FLAG (ri->attr->flag,
12939 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE))))
12940 ts->counts[BGP_STATS_AGGREGATES]++;
12942 /* as-path stats */
12943 if (ri->attr && ri->attr->aspath)
12945 unsigned int hops = aspath_count_hops (ri->attr->aspath);
12946 unsigned int size = aspath_size (ri->attr->aspath);
12947 as_t highest = aspath_highest (ri->attr->aspath);
12949 ts->counts[BGP_STATS_ASPATH_COUNT]++;
12951 if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS])
12952 ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops;
12954 if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE])
12955 ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size;
12957 ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops;
12958 ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size;
12960 ts->counts[BGP_STATS_ASPATH_AVGHOPS]
12961 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
12962 ts->counts[BGP_STATS_ASPATH_AVGHOPS],
12964 ts->counts[BGP_STATS_ASPATH_AVGSIZE]
12965 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
12966 ts->counts[BGP_STATS_ASPATH_AVGSIZE],
12969 if (highest > ts->counts[BGP_STATS_ASN_HIGHEST])
12970 ts->counts[BGP_STATS_ASN_HIGHEST] = highest;
12978 bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi)
12980 struct bgp_table_stats ts;
12983 if (!bgp->rib[afi][safi])
12985 vty_out (vty, "%% No RIB exists for the specified AFI(%d)/SAFI(%d) %s",
12986 afi, safi, VTY_NEWLINE);
12987 return CMD_WARNING;
12990 memset (&ts, 0, sizeof (ts));
12991 ts.table = bgp->rib[afi][safi];
12992 thread_execute (bm->master, bgp_table_stats_walker, &ts, 0);
12994 vty_out (vty, "BGP %s RIB statistics%s%s",
12995 afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE);
12997 for (i = 0; i < BGP_STATS_MAX; i++)
12999 if (!table_stats_strs[i])
13005 case BGP_STATS_ASPATH_AVGHOPS:
13006 case BGP_STATS_ASPATH_AVGSIZE:
13007 case BGP_STATS_AVGPLEN:
13008 vty_out (vty, "%-30s: ", table_stats_strs[i]);
13009 vty_out (vty, "%12.2f",
13010 (float)ts.counts[i] / (float)TALLY_SIGFIG);
13013 case BGP_STATS_ASPATH_TOTHOPS:
13014 case BGP_STATS_ASPATH_TOTSIZE:
13015 vty_out (vty, "%-30s: ", table_stats_strs[i]);
13016 vty_out (vty, "%12.2f",
13018 (float)ts.counts[i] /
13019 (float)ts.counts[BGP_STATS_ASPATH_COUNT]
13022 case BGP_STATS_TOTPLEN:
13023 vty_out (vty, "%-30s: ", table_stats_strs[i]);
13024 vty_out (vty, "%12.2f",
13026 (float)ts.counts[i] /
13027 (float)ts.counts[BGP_STATS_PREFIXES]
13030 case BGP_STATS_SPACE:
13031 vty_out (vty, "%-30s: ", table_stats_strs[i]);
13032 vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE);
13033 if (ts.counts[BGP_STATS_MAXBITLEN] < 9)
13035 vty_out (vty, "%30s: ", "%% announced ");
13036 vty_out (vty, "%12.2f%s",
13037 100 * (float)ts.counts[BGP_STATS_SPACE] /
13038 (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]),
13040 vty_out (vty, "%30s: ", "/8 equivalent ");
13041 vty_out (vty, "%12.2f%s",
13042 (float)ts.counts[BGP_STATS_SPACE] /
13043 (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)),
13045 if (ts.counts[BGP_STATS_MAXBITLEN] < 25)
13047 vty_out (vty, "%30s: ", "/24 equivalent ");
13048 vty_out (vty, "%12.2f",
13049 (float)ts.counts[BGP_STATS_SPACE] /
13050 (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24)));
13053 vty_out (vty, "%-30s: ", table_stats_strs[i]);
13054 vty_out (vty, "%12llu", ts.counts[i]);
13057 vty_out (vty, "%s", VTY_NEWLINE);
13059 return CMD_SUCCESS;
13063 bgp_table_stats_vty (struct vty *vty, const char *name,
13064 const char *afi_str, const char *safi_str)
13071 bgp = bgp_lookup_by_name (name);
13073 bgp = bgp_get_default ();
13077 vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE);
13078 return CMD_WARNING;
13080 if (strncmp (afi_str, "ipv", 3) == 0)
13082 if (strncmp (afi_str, "ipv4", 4) == 0)
13084 else if (strncmp (afi_str, "ipv6", 4) == 0)
13088 vty_out (vty, "%% Invalid address family %s%s",
13089 afi_str, VTY_NEWLINE);
13090 return CMD_WARNING;
13092 switch (safi_str[0]) {
13094 safi = SAFI_MULTICAST;
13097 safi = SAFI_UNICAST;
13100 safi = SAFI_MPLS_VPN;
13106 vty_out (vty, "%% Invalid subsequent address family %s%s",
13107 safi_str, VTY_NEWLINE);
13108 return CMD_WARNING;
13113 vty_out (vty, "%% Invalid address family \"%s\"%s",
13114 afi_str, VTY_NEWLINE);
13115 return CMD_WARNING;
13118 return bgp_table_stats (vty, bgp, afi, safi);
13121 DEFUN (show_bgp_statistics,
13122 show_bgp_statistics_cmd,
13123 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
13128 "Address Family modifier\n"
13129 "Address Family modifier\n"
13130 "Address Family modifier\n"
13131 "Address Family modifier\n"
13132 "BGP RIB advertisement statistics\n")
13134 return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
13137 ALIAS (show_bgp_statistics,
13138 show_bgp_statistics_vpnv4_cmd,
13139 "show bgp (ipv4) (vpnv4) statistics",
13143 "Address Family modifier\n"
13144 "BGP RIB advertisement statistics\n")
13146 DEFUN (show_bgp_statistics_view,
13147 show_bgp_statistics_view_cmd,
13148 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
13154 "Address Family modifier\n"
13155 "Address Family modifier\n"
13156 "Address Family modifier\n"
13157 "Address Family modifier\n"
13158 "BGP RIB advertisement statistics\n")
13160 return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
13163 ALIAS (show_bgp_statistics_view,
13164 show_bgp_statistics_view_vpnv4_cmd,
13165 "show bgp view WORD (ipv4) (vpnv4) statistics",
13170 "Address Family modifier\n"
13171 "BGP RIB advertisement statistics\n")
13183 PCOUNT_PFCNT, /* the figure we display to users */
13187 static const char *pcount_strs[] =
13189 [PCOUNT_ADJ_IN] = "Adj-in",
13190 [PCOUNT_DAMPED] = "Damped",
13191 [PCOUNT_REMOVED] = "Removed",
13192 [PCOUNT_HISTORY] = "History",
13193 [PCOUNT_STALE] = "Stale",
13194 [PCOUNT_VALID] = "Valid",
13195 [PCOUNT_ALL] = "All RIB",
13196 [PCOUNT_COUNTED] = "PfxCt counted",
13197 [PCOUNT_PFCNT] = "Useable",
13198 [PCOUNT_MAX] = NULL,
13201 struct peer_pcounts
13203 unsigned int count[PCOUNT_MAX];
13204 const struct peer *peer;
13205 const struct bgp_table *table;
13209 bgp_peer_count_walker (struct thread *t)
13211 struct bgp_node *rn;
13212 struct peer_pcounts *pc = THREAD_ARG (t);
13213 const struct peer *peer = pc->peer;
13215 for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn))
13217 struct bgp_adj_in *ain;
13218 struct bgp_info *ri;
13220 for (ain = rn->adj_in; ain; ain = ain->next)
13221 if (ain->peer == peer)
13222 pc->count[PCOUNT_ADJ_IN]++;
13224 for (ri = rn->info; ri; ri = ri->next)
13226 char buf[SU_ADDRSTRLEN];
13228 if (ri->peer != peer)
13231 pc->count[PCOUNT_ALL]++;
13233 if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED))
13234 pc->count[PCOUNT_DAMPED]++;
13235 if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
13236 pc->count[PCOUNT_HISTORY]++;
13237 if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED))
13238 pc->count[PCOUNT_REMOVED]++;
13239 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
13240 pc->count[PCOUNT_STALE]++;
13241 if (CHECK_FLAG (ri->flags, BGP_INFO_VALID))
13242 pc->count[PCOUNT_VALID]++;
13243 if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
13244 pc->count[PCOUNT_PFCNT]++;
13246 if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
13248 pc->count[PCOUNT_COUNTED]++;
13249 if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
13250 plog_warn (peer->log,
13251 "%s [pcount] %s/%d is counted but flags 0x%x",
13253 inet_ntop(rn->p.family, &rn->p.u.prefix,
13254 buf, SU_ADDRSTRLEN),
13260 if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
13261 plog_warn (peer->log,
13262 "%s [pcount] %s/%d not counted but flags 0x%x",
13264 inet_ntop(rn->p.family, &rn->p.u.prefix,
13265 buf, SU_ADDRSTRLEN),
13275 bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi)
13277 struct peer_pcounts pcounts = { .peer = peer };
13280 if (!peer || !peer->bgp || !peer->afc[afi][safi]
13281 || !peer->bgp->rib[afi][safi])
13283 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
13284 return CMD_WARNING;
13287 memset (&pcounts, 0, sizeof(pcounts));
13288 pcounts.peer = peer;
13289 pcounts.table = peer->bgp->rib[afi][safi];
13291 /* in-place call via thread subsystem so as to record execution time
13292 * stats for the thread-walk (i.e. ensure this can't be blamed on
13293 * on just vty_read()).
13295 thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0);
13297 vty_out (vty, "Prefix counts for %s, %s%s",
13298 peer->host, afi_safi_print (afi, safi), VTY_NEWLINE);
13299 vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE);
13300 vty_out (vty, "%sCounts from RIB table walk:%s%s",
13301 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
13303 for (i = 0; i < PCOUNT_MAX; i++)
13304 vty_out (vty, "%20s: %-10d%s",
13305 pcount_strs[i], pcounts.count[i], VTY_NEWLINE);
13307 if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi])
13309 vty_out (vty, "%s [pcount] PfxCt drift!%s",
13310 peer->host, VTY_NEWLINE);
13311 vty_out (vty, "Please report this bug, with the above command output%s",
13315 return CMD_SUCCESS;
13318 DEFUN (show_ip_bgp_neighbor_prefix_counts,
13319 show_ip_bgp_neighbor_prefix_counts_cmd,
13320 "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts",
13324 "Detailed information on TCP and BGP neighbor connections\n"
13325 "Neighbor to display information about\n"
13326 "Neighbor to display information about\n"
13327 "Display detailed prefix count information\n")
13331 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13333 return CMD_WARNING;
13335 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
13338 DEFUN (show_bgp_ipv6_neighbor_prefix_counts,
13339 show_bgp_ipv6_neighbor_prefix_counts_cmd,
13340 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts",
13344 "Detailed information on TCP and BGP neighbor connections\n"
13345 "Neighbor to display information about\n"
13346 "Neighbor to display information about\n"
13347 "Display detailed prefix count information\n")
13351 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13353 return CMD_WARNING;
13355 return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST);
13358 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts,
13359 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd,
13360 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
13365 "Address Family modifier\n"
13366 "Address Family modifier\n"
13367 "Detailed information on TCP and BGP neighbor connections\n"
13368 "Neighbor to display information about\n"
13369 "Neighbor to display information about\n"
13370 "Display detailed prefix count information\n")
13374 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13376 return CMD_WARNING;
13378 if (strncmp (argv[0], "m", 1) == 0)
13379 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST);
13381 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
13384 DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts,
13385 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd,
13386 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
13391 "Address Family modifier\n"
13392 "Address Family modifier\n"
13393 "Detailed information on TCP and BGP neighbor connections\n"
13394 "Neighbor to display information about\n"
13395 "Neighbor to display information about\n"
13396 "Display detailed prefix count information\n")
13400 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13402 return CMD_WARNING;
13404 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN);
13407 DEFUN (show_bgp_ipv4_safi_neighbor_prefix_counts,
13408 show_bgp_ipv4_safi_neighbor_prefix_counts_cmd,
13409 "show bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
13413 "Address Family modifier\n"
13414 "Address Family modifier\n"
13415 "Address Family modifier\n"
13416 "Address Family modifier\n"
13417 "Detailed information on TCP and BGP neighbor connections\n"
13418 "Neighbor to display information about\n"
13419 "Neighbor to display information about\n"
13420 "Display detailed prefix count information\n")
13425 if (bgp_parse_safi(argv[0], &safi)) {
13426 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13427 return CMD_WARNING;
13430 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13432 return CMD_WARNING;
13434 return bgp_peer_counts (vty, peer, AFI_IP, safi);
13437 DEFUN (show_bgp_ipv6_safi_neighbor_prefix_counts,
13438 show_bgp_ipv6_safi_neighbor_prefix_counts_cmd,
13439 "show bgp ipv6 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
13443 "Address Family modifier\n"
13444 "Address Family modifier\n"
13445 "Address Family modifier\n"
13446 "Address Family modifier\n"
13447 "Detailed information on TCP and BGP neighbor connections\n"
13448 "Neighbor to display information about\n"
13449 "Neighbor to display information about\n"
13450 "Display detailed prefix count information\n")
13455 if (bgp_parse_safi(argv[0], &safi)) {
13456 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13457 return CMD_WARNING;
13460 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13462 return CMD_WARNING;
13464 return bgp_peer_counts (vty, peer, AFI_IP6, safi);
13467 DEFUN (show_ip_bgp_encap_neighbor_prefix_counts,
13468 show_ip_bgp_encap_neighbor_prefix_counts_cmd,
13469 "show ip bgp encap all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
13474 "Address Family modifier\n"
13475 "Address Family modifier\n"
13476 "Detailed information on TCP and BGP neighbor connections\n"
13477 "Neighbor to display information about\n"
13478 "Neighbor to display information about\n"
13479 "Display detailed prefix count information\n")
13483 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13485 return CMD_WARNING;
13487 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_ENCAP);
13492 show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi,
13495 struct bgp_table *table;
13496 struct bgp_adj_in *ain;
13497 struct bgp_adj_out *adj;
13498 unsigned long output_count;
13499 struct bgp_node *rn;
13509 table = bgp->rib[afi][safi];
13513 if (! in && CHECK_FLAG (peer->af_sflags[afi][safi],
13514 PEER_STATUS_DEFAULT_ORIGINATE))
13516 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE);
13517 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
13518 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
13520 vty_out (vty, "Originating default network 0.0.0.0%s%s",
13521 VTY_NEWLINE, VTY_NEWLINE);
13525 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
13528 for (ain = rn->adj_in; ain; ain = ain->next)
13529 if (ain->peer == peer)
13533 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE);
13534 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
13535 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
13540 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
13545 route_vty_out_tmp (vty, &rn->p, ain->attr, safi);
13552 for (adj = rn->adj_out; adj; adj = adj->next)
13553 if (adj->peer == peer)
13557 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE);
13558 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
13559 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
13564 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
13569 route_vty_out_tmp (vty, &rn->p, adj->attr, safi);
13575 if (output_count != 0)
13576 vty_out (vty, "%sTotal number of prefixes %ld%s",
13577 VTY_NEWLINE, output_count, VTY_NEWLINE);
13581 peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in)
13583 if (! peer || ! peer->afc[afi][safi])
13585 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
13586 return CMD_WARNING;
13589 if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
13591 vty_out (vty, "%% Inbound soft reconfiguration not enabled%s",
13593 return CMD_WARNING;
13596 show_adj_route (vty, peer, afi, safi, in);
13598 return CMD_SUCCESS;
13601 DEFUN (show_ip_bgp_view_neighbor_advertised_route,
13602 show_ip_bgp_view_neighbor_advertised_route_cmd,
13603 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
13609 "Detailed information on TCP and BGP neighbor connections\n"
13610 "Neighbor to display information about\n"
13611 "Neighbor to display information about\n"
13612 "Display the routes advertised to a BGP neighbor\n")
13617 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13619 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13622 return CMD_WARNING;
13624 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
13627 ALIAS (show_ip_bgp_view_neighbor_advertised_route,
13628 show_ip_bgp_neighbor_advertised_route_cmd,
13629 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
13633 "Detailed information on TCP and BGP neighbor connections\n"
13634 "Neighbor to display information about\n"
13635 "Neighbor to display information about\n"
13636 "Display the routes advertised to a BGP neighbor\n")
13638 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route,
13639 show_ip_bgp_ipv4_neighbor_advertised_route_cmd,
13640 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
13645 "Address Family modifier\n"
13646 "Address Family modifier\n"
13647 "Detailed information on TCP and BGP neighbor connections\n"
13648 "Neighbor to display information about\n"
13649 "Neighbor to display information about\n"
13650 "Display the routes advertised to a BGP neighbor\n")
13654 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13656 return CMD_WARNING;
13658 if (strncmp (argv[0], "m", 1) == 0)
13659 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0);
13661 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
13664 DEFUN (show_bgp_view_neighbor_advertised_route,
13665 show_bgp_view_neighbor_advertised_route_cmd,
13666 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
13671 "Detailed information on TCP and BGP neighbor connections\n"
13672 "Neighbor to display information about\n"
13673 "Neighbor to display information about\n"
13674 "Display the routes advertised to a BGP neighbor\n")
13679 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13681 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13684 return CMD_WARNING;
13686 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
13689 DEFUN (show_bgp_view_neighbor_received_routes,
13690 show_bgp_view_neighbor_received_routes_cmd,
13691 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
13696 "Detailed information on TCP and BGP neighbor connections\n"
13697 "Neighbor to display information about\n"
13698 "Neighbor to display information about\n"
13699 "Display the received routes from neighbor\n")
13704 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13706 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13709 return CMD_WARNING;
13711 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
13714 ALIAS (show_bgp_view_neighbor_advertised_route,
13715 show_bgp_neighbor_advertised_route_cmd,
13716 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
13719 "Detailed information on TCP and BGP neighbor connections\n"
13720 "Neighbor to display information about\n"
13721 "Neighbor to display information about\n"
13722 "Display the routes advertised to a BGP neighbor\n")
13724 ALIAS (show_bgp_view_neighbor_advertised_route,
13725 show_bgp_ipv6_neighbor_advertised_route_cmd,
13726 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
13730 "Detailed information on TCP and BGP neighbor connections\n"
13731 "Neighbor to display information about\n"
13732 "Neighbor to display information about\n"
13733 "Display the routes advertised to a BGP neighbor\n")
13736 ALIAS (show_bgp_view_neighbor_advertised_route,
13737 ipv6_bgp_neighbor_advertised_route_cmd,
13738 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
13742 "Detailed information on TCP and BGP neighbor connections\n"
13743 "Neighbor to display information about\n"
13744 "Neighbor to display information about\n"
13745 "Display the routes advertised to a BGP neighbor\n")
13748 DEFUN (ipv6_mbgp_neighbor_advertised_route,
13749 ipv6_mbgp_neighbor_advertised_route_cmd,
13750 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
13754 "Detailed information on TCP and BGP neighbor connections\n"
13755 "Neighbor to display information about\n"
13756 "Neighbor to display information about\n"
13757 "Display the routes advertised to a BGP neighbor\n")
13761 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13763 return CMD_WARNING;
13765 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0);
13768 DEFUN (show_ip_bgp_view_neighbor_received_routes,
13769 show_ip_bgp_view_neighbor_received_routes_cmd,
13770 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
13776 "Detailed information on TCP and BGP neighbor connections\n"
13777 "Neighbor to display information about\n"
13778 "Neighbor to display information about\n"
13779 "Display the received routes from neighbor\n")
13784 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13786 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13789 return CMD_WARNING;
13791 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
13794 ALIAS (show_ip_bgp_view_neighbor_received_routes,
13795 show_ip_bgp_neighbor_received_routes_cmd,
13796 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
13800 "Detailed information on TCP and BGP neighbor connections\n"
13801 "Neighbor to display information about\n"
13802 "Neighbor to display information about\n"
13803 "Display the received routes from neighbor\n")
13805 ALIAS (show_bgp_view_neighbor_received_routes,
13806 show_bgp_ipv6_neighbor_received_routes_cmd,
13807 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
13811 "Detailed information on TCP and BGP neighbor connections\n"
13812 "Neighbor to display information about\n"
13813 "Neighbor to display information about\n"
13814 "Display the received routes from neighbor\n")
13816 DEFUN (show_bgp_neighbor_received_prefix_filter,
13817 show_bgp_neighbor_received_prefix_filter_cmd,
13818 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
13821 "Detailed information on TCP and BGP neighbor connections\n"
13822 "Neighbor to display information about\n"
13823 "Neighbor to display information about\n"
13824 "Display information received from a BGP neighbor\n"
13825 "Display the prefixlist filter\n")
13828 union sockunion su;
13832 ret = str2sockunion (argv[0], &su);
13835 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
13836 return CMD_WARNING;
13839 peer = peer_lookup (NULL, &su);
13841 return CMD_WARNING;
13843 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13844 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13847 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13848 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13851 return CMD_SUCCESS;
13855 ALIAS (show_bgp_view_neighbor_received_routes,
13856 ipv6_bgp_neighbor_received_routes_cmd,
13857 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
13861 "Detailed information on TCP and BGP neighbor connections\n"
13862 "Neighbor to display information about\n"
13863 "Neighbor to display information about\n"
13864 "Display the received routes from neighbor\n")
13867 DEFUN (ipv6_mbgp_neighbor_received_routes,
13868 ipv6_mbgp_neighbor_received_routes_cmd,
13869 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
13873 "Detailed information on TCP and BGP neighbor connections\n"
13874 "Neighbor to display information about\n"
13875 "Neighbor to display information about\n"
13876 "Display the received routes from neighbor\n")
13880 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13882 return CMD_WARNING;
13884 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1);
13887 DEFUN (show_bgp_view_neighbor_received_prefix_filter,
13888 show_bgp_view_neighbor_received_prefix_filter_cmd,
13889 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
13894 "Detailed information on TCP and BGP neighbor connections\n"
13895 "Neighbor to display information about\n"
13896 "Neighbor to display information about\n"
13897 "Display information received from a BGP neighbor\n"
13898 "Display the prefixlist filter\n")
13901 union sockunion su;
13906 /* BGP structure lookup. */
13907 bgp = bgp_lookup_by_name (argv[0]);
13910 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13911 return CMD_WARNING;
13914 ret = str2sockunion (argv[1], &su);
13917 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13918 return CMD_WARNING;
13921 peer = peer_lookup (bgp, &su);
13923 return CMD_WARNING;
13925 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13926 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13929 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13930 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13933 return CMD_SUCCESS;
13937 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes,
13938 show_ip_bgp_ipv4_neighbor_received_routes_cmd,
13939 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
13944 "Address Family modifier\n"
13945 "Address Family modifier\n"
13946 "Detailed information on TCP and BGP neighbor connections\n"
13947 "Neighbor to display information about\n"
13948 "Neighbor to display information about\n"
13949 "Display the received routes from neighbor\n")
13953 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13955 return CMD_WARNING;
13957 if (strncmp (argv[0], "m", 1) == 0)
13958 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1);
13960 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
13963 DEFUN (show_bgp_ipv4_safi_neighbor_advertised_route,
13964 show_bgp_ipv4_safi_neighbor_advertised_route_cmd,
13965 "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
13968 "Address Family modifier\n"
13969 "Address Family modifier\n"
13970 "Detailed information on TCP and BGP neighbor connections\n"
13971 "Neighbor to display information about\n"
13972 "Neighbor to display information about\n"
13973 "Display the routes advertised to a BGP neighbor\n")
13978 if (bgp_parse_safi(argv[0], &safi)) {
13979 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13980 return CMD_WARNING;
13983 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13985 return CMD_WARNING;
13987 return peer_adj_routes (vty, peer, AFI_IP, safi, 0);
13990 DEFUN (show_bgp_ipv6_safi_neighbor_advertised_route,
13991 show_bgp_ipv6_safi_neighbor_advertised_route_cmd,
13992 "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
13995 "Address Family modifier\n"
13996 "Address Family modifier\n"
13997 "Address Family modifier\n"
13998 "Detailed information on TCP and BGP neighbor connections\n"
13999 "Neighbor to display information about\n"
14000 "Neighbor to display information about\n"
14001 "Display the routes advertised to a BGP neighbor\n")
14006 if (bgp_parse_safi(argv[0], &safi)) {
14007 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14008 return CMD_WARNING;
14011 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14013 return CMD_WARNING;
14015 return peer_adj_routes (vty, peer, AFI_IP6, safi, 0);
14018 DEFUN (show_bgp_view_ipv6_neighbor_advertised_route,
14019 show_bgp_view_ipv6_neighbor_advertised_route_cmd,
14020 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
14026 "Detailed information on TCP and BGP neighbor connections\n"
14027 "Neighbor to display information about\n"
14028 "Neighbor to display information about\n"
14029 "Display the routes advertised to a BGP neighbor\n")
14034 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14036 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14039 return CMD_WARNING;
14041 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
14044 DEFUN (show_bgp_view_ipv6_neighbor_received_routes,
14045 show_bgp_view_ipv6_neighbor_received_routes_cmd,
14046 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
14052 "Detailed information on TCP and BGP neighbor connections\n"
14053 "Neighbor to display information about\n"
14054 "Neighbor to display information about\n"
14055 "Display the received routes from neighbor\n")
14060 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14062 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14065 return CMD_WARNING;
14067 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
14070 DEFUN (show_bgp_ipv4_safi_neighbor_received_routes,
14071 show_bgp_ipv4_safi_neighbor_received_routes_cmd,
14072 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received-routes",
14076 "Address Family modifier\n"
14077 "Address Family modifier\n"
14078 "Address Family modifier\n"
14079 "Address Family modifier\n"
14080 "Detailed information on TCP and BGP neighbor connections\n"
14081 "Neighbor to display information about\n"
14082 "Neighbor to display information about\n"
14083 "Display the received routes from neighbor\n")
14088 if (bgp_parse_safi(argv[0], &safi)) {
14089 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14090 return CMD_WARNING;
14093 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14095 return CMD_WARNING;
14097 return peer_adj_routes (vty, peer, AFI_IP, safi, 1);
14100 DEFUN (show_bgp_ipv6_safi_neighbor_received_routes,
14101 show_bgp_ipv6_safi_neighbor_received_routes_cmd,
14102 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received-routes",
14106 "Address Family modifier\n"
14107 "Address Family modifier\n"
14108 "Address Family modifier\n"
14109 "Address Family modifier\n"
14110 "Detailed information on TCP and BGP neighbor connections\n"
14111 "Neighbor to display information about\n"
14112 "Neighbor to display information about\n"
14113 "Display the received routes from neighbor\n")
14118 if (bgp_parse_safi(argv[0], &safi)) {
14119 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14120 return CMD_WARNING;
14123 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14125 return CMD_WARNING;
14127 return peer_adj_routes (vty, peer, AFI_IP6, safi, 1);
14130 DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes,
14131 show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd,
14132 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)",
14139 "Address family modifier\n"
14140 "Address family modifier\n"
14141 "Detailed information on TCP and BGP neighbor connections\n"
14142 "Neighbor to display information about\n"
14143 "Neighbor to display information about\n"
14144 "Display the advertised routes to neighbor\n"
14145 "Display the received routes from neighbor\n")
14152 peer = peer_lookup_in_view (vty, argv[0], argv[3]);
14155 return CMD_WARNING;
14157 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
14158 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14159 in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0;
14161 return peer_adj_routes (vty, peer, afi, safi, in);
14164 DEFUN (show_ip_bgp_neighbor_received_prefix_filter,
14165 show_ip_bgp_neighbor_received_prefix_filter_cmd,
14166 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
14170 "Detailed information on TCP and BGP neighbor connections\n"
14171 "Neighbor to display information about\n"
14172 "Neighbor to display information about\n"
14173 "Display information received from a BGP neighbor\n"
14174 "Display the prefixlist filter\n")
14177 union sockunion su;
14181 ret = str2sockunion (argv[0], &su);
14184 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
14185 return CMD_WARNING;
14188 peer = peer_lookup (NULL, &su);
14190 return CMD_WARNING;
14192 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
14193 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
14196 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
14197 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
14200 return CMD_SUCCESS;
14203 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter,
14204 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd,
14205 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
14210 "Address Family modifier\n"
14211 "Address Family modifier\n"
14212 "Detailed information on TCP and BGP neighbor connections\n"
14213 "Neighbor to display information about\n"
14214 "Neighbor to display information about\n"
14215 "Display information received from a BGP neighbor\n"
14216 "Display the prefixlist filter\n")
14219 union sockunion su;
14223 ret = str2sockunion (argv[1], &su);
14226 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
14227 return CMD_WARNING;
14230 peer = peer_lookup (NULL, &su);
14232 return CMD_WARNING;
14234 if (strncmp (argv[0], "m", 1) == 0)
14236 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST);
14237 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
14240 vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE);
14241 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
14246 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
14247 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
14250 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
14251 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
14255 return CMD_SUCCESS;
14258 ALIAS (show_bgp_view_neighbor_received_routes,
14259 show_bgp_neighbor_received_routes_cmd,
14260 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
14263 "Detailed information on TCP and BGP neighbor connections\n"
14264 "Neighbor to display information about\n"
14265 "Neighbor to display information about\n"
14266 "Display the received routes from neighbor\n")
14268 DEFUN (show_bgp_ipv4_safi_neighbor_received_prefix_filter,
14269 show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd,
14270 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
14274 "Address Family modifier\n"
14275 "Address Family modifier\n"
14276 "Address Family modifier\n"
14277 "Address Family modifier\n"
14278 "Detailed information on TCP and BGP neighbor connections\n"
14279 "Neighbor to display information about\n"
14280 "Neighbor to display information about\n"
14281 "Display information received from a BGP neighbor\n"
14282 "Display the prefixlist filter\n")
14285 union sockunion su;
14290 if (bgp_parse_safi(argv[0], &safi)) {
14291 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14292 return CMD_WARNING;
14295 ret = str2sockunion (argv[1], &su);
14298 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
14299 return CMD_WARNING;
14302 peer = peer_lookup (NULL, &su);
14304 return CMD_WARNING;
14306 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, safi);
14307 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
14309 vty_out (vty, "Address family: IPv4 %s%s", safi2str(safi), VTY_NEWLINE);
14310 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
14313 return CMD_SUCCESS;
14316 DEFUN (show_bgp_ipv6_safi_neighbor_received_prefix_filter,
14317 show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd,
14318 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
14322 "Address Family modifier\n"
14323 "Address Family modifier\n"
14324 "Address Family modifier\n"
14325 "Address Family modifier\n"
14326 "Detailed information on TCP and BGP neighbor connections\n"
14327 "Neighbor to display information about\n"
14328 "Neighbor to display information about\n"
14329 "Display information received from a BGP neighbor\n"
14330 "Display the prefixlist filter\n")
14333 union sockunion su;
14338 if (bgp_parse_safi(argv[0], &safi)) {
14339 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14340 return CMD_WARNING;
14343 ret = str2sockunion (argv[1], &su);
14346 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
14347 return CMD_WARNING;
14350 peer = peer_lookup (NULL, &su);
14352 return CMD_WARNING;
14354 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, safi);
14355 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
14357 vty_out (vty, "Address family: IPv6 %s%s", safi2str(safi), VTY_NEWLINE);
14358 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
14361 return CMD_SUCCESS;
14364 DEFUN (show_bgp_ipv6_neighbor_received_prefix_filter,
14365 show_bgp_ipv6_neighbor_received_prefix_filter_cmd,
14366 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
14370 "Detailed information on TCP and BGP neighbor connections\n"
14371 "Neighbor to display information about\n"
14372 "Neighbor to display information about\n"
14373 "Display information received from a BGP neighbor\n"
14374 "Display the prefixlist filter\n")
14377 union sockunion su;
14381 ret = str2sockunion (argv[0], &su);
14384 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
14385 return CMD_WARNING;
14388 peer = peer_lookup (NULL, &su);
14390 return CMD_WARNING;
14392 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
14393 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
14396 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
14397 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
14400 return CMD_SUCCESS;
14403 DEFUN (show_bgp_view_ipv6_neighbor_received_prefix_filter,
14404 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd,
14405 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
14411 "Detailed information on TCP and BGP neighbor connections\n"
14412 "Neighbor to display information about\n"
14413 "Neighbor to display information about\n"
14414 "Display information received from a BGP neighbor\n"
14415 "Display the prefixlist filter\n")
14418 union sockunion su;
14423 /* BGP structure lookup. */
14424 bgp = bgp_lookup_by_name (argv[0]);
14427 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14428 return CMD_WARNING;
14431 ret = str2sockunion (argv[1], &su);
14434 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
14435 return CMD_WARNING;
14438 peer = peer_lookup (bgp, &su);
14440 return CMD_WARNING;
14442 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
14443 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
14446 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
14447 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
14450 return CMD_SUCCESS;
14454 bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi,
14455 safi_t safi, enum bgp_show_type type)
14457 if (! peer || ! peer->afc[afi][safi])
14459 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
14460 return CMD_WARNING;
14463 return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su);
14465 DEFUN (show_ip_bgp_neighbor_routes,
14466 show_ip_bgp_neighbor_routes_cmd,
14467 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
14471 "Detailed information on TCP and BGP neighbor connections\n"
14472 "Neighbor to display information about\n"
14473 "Neighbor to display information about\n"
14474 "Display routes learned from neighbor\n")
14478 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14480 return CMD_WARNING;
14482 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
14483 bgp_show_type_neighbor);
14486 DEFUN (show_ip_bgp_neighbor_flap,
14487 show_ip_bgp_neighbor_flap_cmd,
14488 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14492 "Detailed information on TCP and BGP neighbor connections\n"
14493 "Neighbor to display information about\n"
14494 "Neighbor to display information about\n"
14495 "Display flap statistics of the routes learned from neighbor\n")
14499 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14501 return CMD_WARNING;
14503 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
14504 bgp_show_type_flap_neighbor);
14507 DEFUN (show_ip_bgp_neighbor_damp,
14508 show_ip_bgp_neighbor_damp_cmd,
14509 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14513 "Detailed information on TCP and BGP neighbor connections\n"
14514 "Neighbor to display information about\n"
14515 "Neighbor to display information about\n"
14516 "Display the dampened routes received from neighbor\n")
14520 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14522 return CMD_WARNING;
14524 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
14525 bgp_show_type_damp_neighbor);
14528 DEFUN (show_ip_bgp_ipv4_neighbor_routes,
14529 show_ip_bgp_ipv4_neighbor_routes_cmd,
14530 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
14535 "Address Family modifier\n"
14536 "Address Family modifier\n"
14537 "Detailed information on TCP and BGP neighbor connections\n"
14538 "Neighbor to display information about\n"
14539 "Neighbor to display information about\n"
14540 "Display routes learned from neighbor\n")
14544 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14546 return CMD_WARNING;
14548 if (strncmp (argv[0], "m", 1) == 0)
14549 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST,
14550 bgp_show_type_neighbor);
14552 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
14553 bgp_show_type_neighbor);
14556 DEFUN (show_ip_bgp_view_rsclient,
14557 show_ip_bgp_view_rsclient_cmd,
14558 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
14564 "Information about Route Server Client\n"
14567 struct bgp_table *table;
14571 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14573 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14576 return CMD_WARNING;
14578 if (! peer->afc[AFI_IP][SAFI_UNICAST])
14580 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14582 return CMD_WARNING;
14585 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
14586 PEER_FLAG_RSERVER_CLIENT))
14588 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14590 return CMD_WARNING;
14593 table = peer->rib[AFI_IP][SAFI_UNICAST];
14595 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14598 ALIAS (show_ip_bgp_view_rsclient,
14599 show_ip_bgp_rsclient_cmd,
14600 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
14604 "Information about Route Server Client\n"
14607 DEFUN (show_bgp_view_ipv4_safi_rsclient,
14608 show_bgp_view_ipv4_safi_rsclient_cmd,
14609 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
14615 "Address Family modifier\n"
14616 "Address Family modifier\n"
14617 "Information about Route Server Client\n"
14620 struct bgp_table *table;
14625 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14626 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14628 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14629 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14633 return CMD_WARNING;
14635 if (! peer->afc[AFI_IP][safi])
14637 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14639 return CMD_WARNING;
14642 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
14643 PEER_FLAG_RSERVER_CLIENT))
14645 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14647 return CMD_WARNING;
14650 table = peer->rib[AFI_IP][safi];
14652 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14655 ALIAS (show_bgp_view_ipv4_safi_rsclient,
14656 show_bgp_ipv4_safi_rsclient_cmd,
14657 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
14661 "Address Family modifier\n"
14662 "Address Family modifier\n"
14663 "Information about Route Server Client\n"
14666 DEFUN (show_ip_bgp_view_rsclient_route,
14667 show_ip_bgp_view_rsclient_route_cmd,
14668 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
14674 "Information about Route Server Client\n"
14676 "Network in the BGP routing table to display\n")
14681 /* BGP structure lookup. */
14684 bgp = bgp_lookup_by_name (argv[0]);
14687 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14688 return CMD_WARNING;
14693 bgp = bgp_get_default ();
14696 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14697 return CMD_WARNING;
14702 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14704 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14707 return CMD_WARNING;
14709 if (! peer->afc[AFI_IP][SAFI_UNICAST])
14711 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14713 return CMD_WARNING;
14716 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
14717 PEER_FLAG_RSERVER_CLIENT))
14719 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14721 return CMD_WARNING;
14724 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
14725 (argc == 3) ? argv[2] : argv[1],
14726 AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
14729 ALIAS (show_ip_bgp_view_rsclient_route,
14730 show_ip_bgp_rsclient_route_cmd,
14731 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
14735 "Information about Route Server Client\n"
14737 "Network in the BGP routing table to display\n")
14739 DEFUN (show_bgp_ipv4_safi_neighbor_flap,
14740 show_bgp_ipv4_safi_neighbor_flap_cmd,
14741 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14744 "Address Family Modifier\n"
14745 "Address Family Modifier\n"
14746 "Address Family Modifier\n"
14747 "Address Family Modifier\n"
14748 "Detailed information on TCP and BGP neighbor connections\n"
14749 "Neighbor to display information about\n"
14750 "Neighbor to display information about\n"
14751 "Display flap statistics of the routes learned from neighbor\n")
14756 if (bgp_parse_safi(argv[0], &safi)) {
14757 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14758 return CMD_WARNING;
14761 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14763 return CMD_WARNING;
14765 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
14766 bgp_show_type_flap_neighbor);
14769 DEFUN (show_bgp_ipv6_safi_neighbor_flap,
14770 show_bgp_ipv6_safi_neighbor_flap_cmd,
14771 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14774 "Address Family Modifier\n"
14775 "Address Family Modifier\n"
14776 "Address Family Modifier\n"
14777 "Address Family Modifier\n"
14778 "Detailed information on TCP and BGP neighbor connections\n"
14779 "Neighbor to display information about\n"
14780 "Neighbor to display information about\n"
14781 "Display flap statistics of the routes learned from neighbor\n")
14786 if (bgp_parse_safi(argv[0], &safi)) {
14787 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14788 return CMD_WARNING;
14791 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14793 return CMD_WARNING;
14795 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
14796 bgp_show_type_flap_neighbor);
14799 DEFUN (show_bgp_ipv4_safi_neighbor_damp,
14800 show_bgp_ipv4_safi_neighbor_damp_cmd,
14801 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14804 "Address Family Modifier\n"
14805 "Address Family Modifier\n"
14806 "Address Family Modifier\n"
14807 "Address Family Modifier\n"
14808 "Detailed information on TCP and BGP neighbor connections\n"
14809 "Neighbor to display information about\n"
14810 "Neighbor to display information about\n"
14811 "Display the dampened routes received from neighbor\n")
14816 if (bgp_parse_safi(argv[0], &safi)) {
14817 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14818 return CMD_WARNING;
14821 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14823 return CMD_WARNING;
14825 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
14826 bgp_show_type_damp_neighbor);
14829 DEFUN (show_bgp_ipv6_safi_neighbor_damp,
14830 show_bgp_ipv6_safi_neighbor_damp_cmd,
14831 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14834 "Address Family Modifier\n"
14835 "Address Family Modifier\n"
14836 "Address Family Modifier\n"
14837 "Address Family Modifier\n"
14838 "Detailed information on TCP and BGP neighbor connections\n"
14839 "Neighbor to display information about\n"
14840 "Neighbor to display information about\n"
14841 "Display the dampened routes received from neighbor\n")
14846 if (bgp_parse_safi(argv[0], &safi)) {
14847 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14848 return CMD_WARNING;
14851 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14853 return CMD_WARNING;
14855 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
14856 bgp_show_type_damp_neighbor);
14859 DEFUN (show_bgp_ipv4_safi_neighbor_routes,
14860 show_bgp_ipv4_safi_neighbor_routes_cmd,
14861 "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
14865 "Address Family modifier\n"
14866 "Address Family modifier\n"
14867 "Detailed information on TCP and BGP neighbor connections\n"
14868 "Neighbor to display information about\n"
14869 "Neighbor to display information about\n"
14870 "Display routes learned from neighbor\n")
14875 if (bgp_parse_safi(argv[0], &safi)) {
14876 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14877 return CMD_WARNING;
14880 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14882 return CMD_WARNING;
14884 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
14885 bgp_show_type_neighbor);
14888 DEFUN (show_bgp_ipv6_safi_neighbor_routes,
14889 show_bgp_ipv6_safi_neighbor_routes_cmd,
14890 "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
14894 "Address Family modifier\n"
14895 "Address Family modifier\n"
14896 "Detailed information on TCP and BGP neighbor connections\n"
14899 "Display routes learned from neighbor\n")
14904 if (bgp_parse_safi(argv[0], &safi)) {
14905 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
14906 return CMD_WARNING;
14909 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14911 return CMD_WARNING;
14913 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
14914 bgp_show_type_neighbor);
14917 DEFUN (show_bgp_view_ipv4_safi_rsclient_route,
14918 show_bgp_view_ipv4_safi_rsclient_route_cmd,
14919 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
14925 "Address Family modifier\n"
14926 "Address Family modifier\n"
14927 "Information about Route Server Client\n"
14929 "Network in the BGP routing table to display\n")
14935 /* BGP structure lookup. */
14938 bgp = bgp_lookup_by_name (argv[0]);
14941 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14942 return CMD_WARNING;
14947 bgp = bgp_get_default ();
14950 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14951 return CMD_WARNING;
14956 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14957 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14959 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14960 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14964 return CMD_WARNING;
14966 if (! peer->afc[AFI_IP][safi])
14968 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14970 return CMD_WARNING;
14973 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
14974 PEER_FLAG_RSERVER_CLIENT))
14976 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14978 return CMD_WARNING;
14981 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
14982 (argc == 4) ? argv[3] : argv[2],
14983 AFI_IP, safi, NULL, 0, BGP_PATH_ALL);
14986 ALIAS (show_bgp_view_ipv4_safi_rsclient_route,
14987 show_bgp_ipv4_safi_rsclient_route_cmd,
14988 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
14992 "Address Family modifier\n"
14993 "Address Family modifier\n"
14994 "Information about Route Server Client\n"
14996 "Network in the BGP routing table to display\n")
14999 DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix,
15000 show_bgp_view_ipv4_safi_rsclient_prefix_cmd,
15001 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
15007 "Address Family modifier\n"
15008 "Address Family modifier\n"
15009 "Information about Route Server Client\n"
15011 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
15017 /* BGP structure lookup. */
15020 bgp = bgp_lookup_by_name (argv[0]);
15023 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
15024 return CMD_WARNING;
15029 bgp = bgp_get_default ();
15032 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
15033 return CMD_WARNING;
15038 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
15039 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
15041 peer = peer_lookup_in_view (vty, NULL, argv[1]);
15042 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
15046 return CMD_WARNING;
15048 if (! peer->afc[AFI_IP][safi])
15050 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15052 return CMD_WARNING;
15055 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
15056 PEER_FLAG_RSERVER_CLIENT))
15058 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15060 return CMD_WARNING;
15063 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
15064 (argc == 4) ? argv[3] : argv[2],
15065 AFI_IP, safi, NULL, 1, BGP_PATH_ALL);
15068 DEFUN (show_ip_bgp_view_rsclient_prefix,
15069 show_ip_bgp_view_rsclient_prefix_cmd,
15070 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
15076 "Information about Route Server Client\n"
15078 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
15083 /* BGP structure lookup. */
15086 bgp = bgp_lookup_by_name (argv[0]);
15089 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
15090 return CMD_WARNING;
15095 bgp = bgp_get_default ();
15098 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
15099 return CMD_WARNING;
15104 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15106 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15109 return CMD_WARNING;
15111 if (! peer->afc[AFI_IP][SAFI_UNICAST])
15113 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15115 return CMD_WARNING;
15118 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
15119 PEER_FLAG_RSERVER_CLIENT))
15121 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15123 return CMD_WARNING;
15126 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
15127 (argc == 3) ? argv[2] : argv[1],
15128 AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
15131 ALIAS (show_ip_bgp_view_rsclient_prefix,
15132 show_ip_bgp_rsclient_prefix_cmd,
15133 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
15137 "Information about Route Server Client\n"
15139 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
15141 ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix,
15142 show_bgp_ipv4_safi_rsclient_prefix_cmd,
15143 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
15147 "Address Family modifier\n"
15148 "Address Family modifier\n"
15149 "Information about Route Server Client\n"
15151 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
15153 DEFUN (show_bgp_view_ipv6_neighbor_routes,
15154 show_bgp_view_ipv6_neighbor_routes_cmd,
15155 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
15161 "Detailed information on TCP and BGP neighbor connections\n"
15162 "Neighbor to display information about\n"
15163 "Neighbor to display information about\n"
15164 "Display routes learned from neighbor\n")
15169 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15171 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15174 return CMD_WARNING;
15176 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
15177 bgp_show_type_neighbor);
15180 DEFUN (show_bgp_view_neighbor_damp,
15181 show_bgp_view_neighbor_damp_cmd,
15182 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
15187 "Detailed information on TCP and BGP neighbor connections\n"
15188 "Neighbor to display information about\n"
15189 "Neighbor to display information about\n"
15190 "Display the dampened routes received from neighbor\n")
15195 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15197 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15200 return CMD_WARNING;
15202 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
15203 bgp_show_type_damp_neighbor);
15206 DEFUN (show_bgp_view_ipv6_neighbor_damp,
15207 show_bgp_view_ipv6_neighbor_damp_cmd,
15208 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
15214 "Detailed information on TCP and BGP neighbor connections\n"
15215 "Neighbor to display information about\n"
15216 "Neighbor to display information about\n"
15217 "Display the dampened routes received from neighbor\n")
15222 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15224 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15227 return CMD_WARNING;
15229 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
15230 bgp_show_type_damp_neighbor);
15233 DEFUN (show_bgp_view_ipv6_neighbor_flap,
15234 show_bgp_view_ipv6_neighbor_flap_cmd,
15235 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
15241 "Detailed information on TCP and BGP neighbor connections\n"
15242 "Neighbor to display information about\n"
15243 "Neighbor to display information about\n"
15244 "Display the dampened routes received from neighbor\n")
15249 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15251 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15254 return CMD_WARNING;
15256 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
15257 bgp_show_type_flap_neighbor);
15260 DEFUN (show_bgp_view_neighbor_flap,
15261 show_bgp_view_neighbor_flap_cmd,
15262 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
15267 "Detailed information on TCP and BGP neighbor connections\n"
15268 "Neighbor to display information about\n"
15269 "Neighbor to display information about\n"
15270 "Display flap statistics of the routes learned from neighbor\n")
15275 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15277 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15280 return CMD_WARNING;
15282 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
15283 bgp_show_type_flap_neighbor);
15286 ALIAS (show_bgp_view_neighbor_flap,
15287 show_bgp_neighbor_flap_cmd,
15288 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
15291 "Detailed information on TCP and BGP neighbor connections\n"
15292 "Neighbor to display information about\n"
15293 "Neighbor to display information about\n"
15294 "Display flap statistics of the routes learned from neighbor\n")
15296 ALIAS (show_bgp_view_neighbor_damp,
15297 show_bgp_neighbor_damp_cmd,
15298 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
15301 "Detailed information on TCP and BGP neighbor connections\n"
15302 "Neighbor to display information about\n"
15303 "Neighbor to display information about\n"
15304 "Display the dampened routes received from neighbor\n")
15306 DEFUN (show_bgp_view_neighbor_routes,
15307 show_bgp_view_neighbor_routes_cmd,
15308 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
15313 "Detailed information on TCP and BGP neighbor connections\n"
15314 "Neighbor to display information about\n"
15315 "Neighbor to display information about\n"
15316 "Display routes learned from neighbor\n")
15321 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15323 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15326 return CMD_WARNING;
15328 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
15329 bgp_show_type_neighbor);
15332 ALIAS (show_bgp_view_neighbor_routes,
15333 show_bgp_neighbor_routes_cmd,
15334 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
15337 "Detailed information on TCP and BGP neighbor connections\n"
15338 "Neighbor to display information about\n"
15339 "Neighbor to display information about\n"
15340 "Display routes learned from neighbor\n")
15342 ALIAS (show_bgp_view_neighbor_routes,
15343 show_bgp_ipv6_neighbor_routes_cmd,
15344 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
15348 "Detailed information on TCP and BGP neighbor connections\n"
15349 "Neighbor to display information about\n"
15350 "Neighbor to display information about\n"
15351 "Display routes learned from neighbor\n")
15354 ALIAS (show_bgp_view_neighbor_routes,
15355 ipv6_bgp_neighbor_routes_cmd,
15356 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
15360 "Detailed information on TCP and BGP neighbor connections\n"
15361 "Neighbor to display information about\n"
15362 "Neighbor to display information about\n"
15363 "Display routes learned from neighbor\n")
15366 DEFUN (ipv6_mbgp_neighbor_routes,
15367 ipv6_mbgp_neighbor_routes_cmd,
15368 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
15372 "Detailed information on TCP and BGP neighbor connections\n"
15373 "Neighbor to display information about\n"
15374 "Neighbor to display information about\n"
15375 "Display routes learned from neighbor\n")
15379 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15381 return CMD_WARNING;
15383 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST,
15384 bgp_show_type_neighbor);
15387 ALIAS (show_bgp_view_neighbor_flap,
15388 show_bgp_ipv6_neighbor_flap_cmd,
15389 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
15393 "Detailed information on TCP and BGP neighbor connections\n"
15394 "Neighbor to display information about\n"
15395 "Neighbor to display information about\n"
15396 "Display flap statistics of the routes learned from neighbor\n")
15398 ALIAS (show_bgp_view_neighbor_damp,
15399 show_bgp_ipv6_neighbor_damp_cmd,
15400 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
15404 "Detailed information on TCP and BGP neighbor connections\n"
15405 "Neighbor to display information about\n"
15406 "Neighbor to display information about\n"
15407 "Display the dampened routes received from neighbor\n")
15409 DEFUN (show_bgp_view_rsclient,
15410 show_bgp_view_rsclient_cmd,
15411 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
15416 "Information about Route Server Client\n"
15419 struct bgp_table *table;
15423 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15425 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15428 return CMD_WARNING;
15430 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
15432 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15434 return CMD_WARNING;
15437 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
15438 PEER_FLAG_RSERVER_CLIENT))
15440 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15442 return CMD_WARNING;
15445 table = peer->rib[AFI_IP6][SAFI_UNICAST];
15447 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
15450 ALIAS (show_bgp_view_rsclient,
15451 show_bgp_rsclient_cmd,
15452 "show bgp rsclient (A.B.C.D|X:X::X:X)",
15455 "Information about Route Server Client\n"
15458 DEFUN (show_bgp_view_ipv4_rsclient,
15459 show_bgp_view_ipv4_rsclient_cmd,
15460 "show bgp view WORD ipv4 rsclient (A.B.C.D|X:X::X:X)",
15466 "Information about Route Server Client\n"
15467 NEIGHBOR_ADDR_STR2)
15469 struct bgp_table *table;
15473 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15475 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15478 return CMD_WARNING;
15480 if (! peer->afc[AFI_IP][SAFI_UNICAST])
15482 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15484 return CMD_WARNING;
15487 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
15488 PEER_FLAG_RSERVER_CLIENT))
15490 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15492 return CMD_WARNING;
15495 table = peer->rib[AFI_IP][SAFI_UNICAST];
15497 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
15499 DEFUN (show_bgp_view_ipv6_rsclient,
15500 show_bgp_view_ipv6_rsclient_cmd,
15501 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X)",
15507 "Information about Route Server Client\n"
15508 NEIGHBOR_ADDR_STR2)
15510 struct bgp_table *table;
15514 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15516 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15519 return CMD_WARNING;
15521 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
15523 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15525 return CMD_WARNING;
15528 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
15529 PEER_FLAG_RSERVER_CLIENT))
15531 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15533 return CMD_WARNING;
15536 table = peer->rib[AFI_IP6][SAFI_UNICAST];
15538 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
15541 ALIAS (show_bgp_view_ipv4_rsclient,
15542 show_bgp_ipv4_rsclient_cmd,
15543 "show bgp ipv4 rsclient (A.B.C.D|X:X::X:X)",
15547 "Information about Route Server Client\n"
15548 NEIGHBOR_ADDR_STR2)
15550 ALIAS (show_bgp_view_ipv6_rsclient,
15551 show_bgp_ipv6_rsclient_cmd,
15552 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X)",
15556 "Information about Route Server Client\n"
15557 NEIGHBOR_ADDR_STR2)
15559 DEFUN (show_bgp_view_ipv6_safi_rsclient,
15560 show_bgp_view_ipv6_safi_rsclient_cmd,
15561 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
15567 "Address Family modifier\n"
15568 "Address Family modifier\n"
15569 "Information about Route Server Client\n"
15572 struct bgp_table *table;
15577 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
15578 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
15580 peer = peer_lookup_in_view (vty, NULL, argv[1]);
15581 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
15585 return CMD_WARNING;
15587 if (! peer->afc[AFI_IP6][safi])
15589 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15591 return CMD_WARNING;
15594 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
15595 PEER_FLAG_RSERVER_CLIENT))
15597 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15599 return CMD_WARNING;
15602 table = peer->rib[AFI_IP6][safi];
15604 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
15607 ALIAS (show_bgp_view_ipv6_safi_rsclient,
15608 show_bgp_ipv6_safi_rsclient_cmd,
15609 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
15613 "Address Family modifier\n"
15614 "Address Family modifier\n"
15615 "Information about Route Server Client\n"
15618 DEFUN (show_bgp_view_rsclient_route,
15619 show_bgp_view_rsclient_route_cmd,
15620 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
15625 "Information about Route Server Client\n"
15627 "Network in the BGP routing table to display\n")
15632 /* BGP structure lookup. */
15635 bgp = bgp_lookup_by_name (argv[0]);
15638 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
15639 return CMD_WARNING;
15644 bgp = bgp_get_default ();
15647 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
15648 return CMD_WARNING;
15653 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15655 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15658 return CMD_WARNING;
15660 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
15662 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15664 return CMD_WARNING;
15667 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
15668 PEER_FLAG_RSERVER_CLIENT))
15670 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15672 return CMD_WARNING;
15675 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
15676 (argc == 3) ? argv[2] : argv[1],
15677 AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
15680 DEFUN (show_bgp_view_ipv6_rsclient_route,
15681 show_bgp_view_ipv6_rsclient_route_cmd,
15682 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
15688 "Information about Route Server Client\n"
15690 "Network in the BGP routing table to display\n")
15695 /* BGP structure lookup. */
15698 bgp = bgp_lookup_by_name (argv[0]);
15701 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
15702 return CMD_WARNING;
15707 bgp = bgp_get_default ();
15710 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
15711 return CMD_WARNING;
15716 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15718 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15721 return CMD_WARNING;
15723 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
15725 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15727 return CMD_WARNING;
15730 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
15731 PEER_FLAG_RSERVER_CLIENT))
15733 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15735 return CMD_WARNING;
15738 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
15739 (argc == 3) ? argv[2] : argv[1],
15740 AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL);
15743 ALIAS (show_bgp_view_ipv6_rsclient_route,
15744 show_bgp_rsclient_route_cmd,
15745 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
15748 "Information about Route Server Client\n"
15750 "Network in the BGP routing table to display\n")
15752 ALIAS (show_bgp_view_ipv6_rsclient_route,
15753 show_bgp_ipv6_rsclient_route_cmd,
15754 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
15758 "Information about Route Server Client\n"
15760 "Network in the BGP routing table to display\n")
15762 DEFUN (show_bgp_view_ipv6_safi_rsclient_route,
15763 show_bgp_view_ipv6_safi_rsclient_route_cmd,
15764 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
15770 "Address Family modifier\n"
15771 "Address Family modifier\n"
15772 "Information about Route Server Client\n"
15774 "Network in the BGP routing table to display\n")
15780 /* BGP structure lookup. */
15783 bgp = bgp_lookup_by_name (argv[0]);
15786 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
15787 return CMD_WARNING;
15792 bgp = bgp_get_default ();
15795 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
15796 return CMD_WARNING;
15801 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
15802 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
15804 peer = peer_lookup_in_view (vty, NULL, argv[1]);
15805 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
15809 return CMD_WARNING;
15811 if (! peer->afc[AFI_IP6][safi])
15813 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15815 return CMD_WARNING;
15818 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
15819 PEER_FLAG_RSERVER_CLIENT))
15821 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15823 return CMD_WARNING;
15826 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
15827 (argc == 4) ? argv[3] : argv[2],
15828 AFI_IP6, safi, NULL, 0, BGP_PATH_ALL);
15831 ALIAS (show_bgp_view_ipv6_safi_rsclient_route,
15832 show_bgp_ipv6_safi_rsclient_route_cmd,
15833 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
15837 "Address Family modifier\n"
15838 "Address Family modifier\n"
15839 "Information about Route Server Client\n"
15841 "Network in the BGP routing table to display\n")
15844 DEFUN (show_bgp_view_rsclient_prefix,
15845 show_bgp_view_rsclient_prefix_cmd,
15846 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
15851 "Information about Route Server Client\n"
15853 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
15858 /* BGP structure lookup. */
15861 bgp = bgp_lookup_by_name (argv[0]);
15864 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
15865 return CMD_WARNING;
15870 bgp = bgp_get_default ();
15873 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
15874 return CMD_WARNING;
15879 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15881 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15884 return CMD_WARNING;
15886 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
15888 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15890 return CMD_WARNING;
15893 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
15894 PEER_FLAG_RSERVER_CLIENT))
15896 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15898 return CMD_WARNING;
15901 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
15902 (argc == 3) ? argv[2] : argv[1],
15903 AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
15906 DEFUN (show_bgp_view_ipv6_rsclient_prefix,
15907 show_bgp_view_ipv6_rsclient_prefix_cmd,
15908 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
15914 "Information about Route Server Client\n"
15916 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
15921 /* BGP structure lookup. */
15924 bgp = bgp_lookup_by_name (argv[0]);
15927 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
15928 return CMD_WARNING;
15933 bgp = bgp_get_default ();
15936 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
15937 return CMD_WARNING;
15942 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
15944 peer = peer_lookup_in_view (vty, NULL, argv[0]);
15947 return CMD_WARNING;
15949 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
15951 vty_out (vty, "%% Activate the neighbor for the address family first%s",
15953 return CMD_WARNING;
15956 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
15957 PEER_FLAG_RSERVER_CLIENT))
15959 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
15961 return CMD_WARNING;
15964 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
15965 (argc == 3) ? argv[2] : argv[1],
15966 AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL);
15969 ALIAS (show_bgp_view_ipv6_rsclient_prefix,
15970 show_bgp_rsclient_prefix_cmd,
15971 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
15974 "Information about Route Server Client\n"
15976 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
15978 ALIAS (show_bgp_view_ipv6_rsclient_prefix,
15979 show_bgp_ipv6_rsclient_prefix_cmd,
15980 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
15983 "Information about Route Server Client\n"
15985 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
15987 DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix,
15988 show_bgp_view_ipv6_safi_rsclient_prefix_cmd,
15989 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
15995 "Address Family modifier\n"
15996 "Address Family modifier\n"
15997 "Information about Route Server Client\n"
15999 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
16005 /* BGP structure lookup. */
16008 bgp = bgp_lookup_by_name (argv[0]);
16011 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
16012 return CMD_WARNING;
16017 bgp = bgp_get_default ();
16020 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
16021 return CMD_WARNING;
16026 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
16027 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
16029 peer = peer_lookup_in_view (vty, NULL, argv[1]);
16030 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
16034 return CMD_WARNING;
16036 if (! peer->afc[AFI_IP6][safi])
16038 vty_out (vty, "%% Activate the neighbor for the address family first%s",
16040 return CMD_WARNING;
16043 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
16044 PEER_FLAG_RSERVER_CLIENT))
16046 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
16048 return CMD_WARNING;
16051 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
16052 (argc == 4) ? argv[3] : argv[2],
16053 AFI_IP6, safi, NULL, 1, BGP_PATH_ALL);
16056 ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix,
16057 show_bgp_ipv6_safi_rsclient_prefix_cmd,
16058 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
16062 "Address Family modifier\n"
16063 "Address Family modifier\n"
16064 "Information about Route Server Client\n"
16066 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
16068 struct bgp_table *bgp_distance_table;
16070 struct bgp_distance
16072 /* Distance value for the IP source prefix. */
16075 /* Name of the access-list to be matched. */
16079 static struct bgp_distance *
16080 bgp_distance_new (void)
16082 return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance));
16086 bgp_distance_free (struct bgp_distance *bdistance)
16088 XFREE (MTYPE_BGP_DISTANCE, bdistance);
16091 /* XXX: Ideally, this should re-announce affected routes to zebra.
16092 * See Bugzilla #949
16095 bgp_distance_set (struct vty *vty, const char *distance_str,
16096 const char *ip_str, const char *access_list_str)
16101 struct bgp_node *rn;
16102 struct bgp_distance *bdistance;
16104 ret = str2prefix (ip_str, &p);
16107 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
16108 return CMD_WARNING;
16111 distance = atoi (distance_str);
16113 /* Get BGP distance node. */
16114 rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p);
16117 bdistance = rn->info;
16118 bgp_unlock_node (rn);
16122 bdistance = bgp_distance_new ();
16123 rn->info = bdistance;
16126 /* Set distance value. */
16127 bdistance->distance = distance;
16129 /* Reset access-list configuration. */
16130 if (bdistance->access_list)
16132 free (bdistance->access_list);
16133 bdistance->access_list = NULL;
16135 if (access_list_str)
16136 bdistance->access_list = strdup (access_list_str);
16138 return CMD_SUCCESS;
16142 bgp_distance_unset (struct vty *vty, const char *distance_str,
16143 const char *ip_str, const char *access_list_str)
16148 struct bgp_node *rn;
16149 struct bgp_distance *bdistance;
16151 ret = str2prefix (ip_str, &p);
16154 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
16155 return CMD_WARNING;
16158 distance = atoi (distance_str);
16160 rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p);
16163 vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE);
16164 return CMD_WARNING;
16167 bdistance = rn->info;
16169 if (bdistance->distance != distance)
16171 vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE);
16172 return CMD_WARNING;
16175 if (bdistance->access_list)
16176 free (bdistance->access_list);
16177 bgp_distance_free (bdistance);
16180 bgp_unlock_node (rn);
16181 bgp_unlock_node (rn);
16183 return CMD_SUCCESS;
16186 /* Apply BGP information to distance method. */
16188 bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp)
16190 struct bgp_node *rn;
16191 struct prefix_ipv4 q;
16193 struct bgp_distance *bdistance;
16194 struct access_list *alist;
16195 struct bgp_static *bgp_static;
16200 if (p->family != AF_INET)
16203 peer = rinfo->peer;
16205 if (peer->su.sa.sa_family != AF_INET)
16208 memset (&q, 0, sizeof (struct prefix_ipv4));
16209 q.family = AF_INET;
16210 q.prefix = peer->su.sin.sin_addr;
16211 q.prefixlen = IPV4_MAX_BITLEN;
16213 /* Check source address. */
16214 rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q);
16217 bdistance = rn->info;
16218 bgp_unlock_node (rn);
16220 if (bdistance->access_list)
16222 alist = access_list_lookup (AFI_IP, bdistance->access_list);
16223 if (alist && access_list_apply (alist, p) == FILTER_PERMIT)
16224 return bdistance->distance;
16227 return bdistance->distance;
16230 /* Backdoor check. */
16231 rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p);
16234 bgp_static = rn->info;
16235 bgp_unlock_node (rn);
16237 if (bgp_static->backdoor)
16239 if (bgp->distance_local)
16240 return bgp->distance_local;
16242 return ZEBRA_IBGP_DISTANCE_DEFAULT;
16246 if (peer->sort == BGP_PEER_EBGP)
16248 if (bgp->distance_ebgp)
16249 return bgp->distance_ebgp;
16250 return ZEBRA_EBGP_DISTANCE_DEFAULT;
16254 if (bgp->distance_ibgp)
16255 return bgp->distance_ibgp;
16256 return ZEBRA_IBGP_DISTANCE_DEFAULT;
16261 /* Apply BGP information to ipv6 distance method. */
16263 ipv6_bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp)
16265 struct bgp_node *rn;
16266 struct prefix_ipv6 q;
16268 struct bgp_distance *bdistance;
16269 struct access_list *alist;
16270 struct bgp_static *bgp_static;
16275 if (p->family != AF_INET6)
16278 peer = rinfo->peer;
16280 if (peer->su.sa.sa_family != AF_INET6)
16283 memset (&q, 0, sizeof (struct prefix_ipv6));
16284 q.family = AF_INET;
16285 q.prefix = peer->su.sin6.sin6_addr;
16286 q.prefixlen = IPV6_MAX_BITLEN;
16288 /* Check source address. */
16289 rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q);
16292 bdistance = rn->info;
16293 bgp_unlock_node (rn);
16295 if (bdistance->access_list)
16297 alist = access_list_lookup (AFI_IP6, bdistance->access_list);
16298 if (alist && access_list_apply (alist, p) == FILTER_PERMIT)
16299 return bdistance->distance;
16302 return bdistance->distance;
16304 /* Backdoor check. */
16305 rn = bgp_node_lookup (bgp->route[AFI_IP6][SAFI_UNICAST], p);
16308 bgp_static = rn->info;
16309 bgp_unlock_node (rn);
16311 if (bgp_static->backdoor)
16313 if (bgp->ipv6_distance_local)
16314 return bgp->ipv6_distance_local;
16316 return ZEBRA_IBGP_DISTANCE_DEFAULT;
16320 if (peer_sort (peer) == BGP_PEER_EBGP)
16322 if (bgp->ipv6_distance_ebgp)
16323 return bgp->ipv6_distance_ebgp;
16324 return ZEBRA_EBGP_DISTANCE_DEFAULT;
16328 if (bgp->ipv6_distance_ibgp)
16329 return bgp->ipv6_distance_ibgp;
16330 return ZEBRA_IBGP_DISTANCE_DEFAULT;
16333 #endif /* HAVE_IPV6 */
16335 DEFUN (bgp_distance,
16337 "distance bgp <1-255> <1-255> <1-255>",
16338 "Define an administrative distance\n"
16340 "Distance for routes external to the AS\n"
16341 "Distance for routes internal to the AS\n"
16342 "Distance for local routes\n")
16348 bgp->distance_ebgp = atoi (argv[0]);
16349 bgp->distance_ibgp = atoi (argv[1]);
16350 bgp->distance_local = atoi (argv[2]);
16351 return CMD_SUCCESS;
16354 DEFUN (no_bgp_distance,
16355 no_bgp_distance_cmd,
16356 "no distance bgp <1-255> <1-255> <1-255>",
16358 "Define an administrative distance\n"
16360 "Distance for routes external to the AS\n"
16361 "Distance for routes internal to the AS\n"
16362 "Distance for local routes\n")
16368 bgp->distance_ebgp= 0;
16369 bgp->distance_ibgp = 0;
16370 bgp->distance_local = 0;
16371 return CMD_SUCCESS;
16374 ALIAS (no_bgp_distance,
16375 no_bgp_distance2_cmd,
16378 "Define an administrative distance\n"
16381 DEFUN (bgp_distance_source,
16382 bgp_distance_source_cmd,
16383 "distance <1-255> A.B.C.D/M",
16384 "Define an administrative distance\n"
16385 "Administrative distance\n"
16386 "IP source prefix\n")
16388 bgp_distance_set (vty, argv[0], argv[1], NULL);
16389 return CMD_SUCCESS;
16392 DEFUN (no_bgp_distance_source,
16393 no_bgp_distance_source_cmd,
16394 "no distance <1-255> A.B.C.D/M",
16396 "Define an administrative distance\n"
16397 "Administrative distance\n"
16398 "IP source prefix\n")
16400 bgp_distance_unset (vty, argv[0], argv[1], NULL);
16401 return CMD_SUCCESS;
16404 DEFUN (bgp_distance_source_access_list,
16405 bgp_distance_source_access_list_cmd,
16406 "distance <1-255> A.B.C.D/M WORD",
16407 "Define an administrative distance\n"
16408 "Administrative distance\n"
16409 "IP source prefix\n"
16410 "Access list name\n")
16412 bgp_distance_set (vty, argv[0], argv[1], argv[2]);
16413 return CMD_SUCCESS;
16416 DEFUN (no_bgp_distance_source_access_list,
16417 no_bgp_distance_source_access_list_cmd,
16418 "no distance <1-255> A.B.C.D/M WORD",
16420 "Define an administrative distance\n"
16421 "Administrative distance\n"
16422 "IP source prefix\n"
16423 "Access list name\n")
16425 bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
16426 return CMD_SUCCESS;
16430 DEFUN (ipv6_bgp_distance,
16431 ipv6_bgp_distance_cmd,
16432 "distance bgp <1-255> <1-255> <1-255>",
16433 "Define an administrative distance\n"
16435 "Distance for routes external to the AS\n"
16436 "Distance for routes internal to the AS\n"
16437 "Distance for local routes\n")
16443 bgp->ipv6_distance_ebgp = atoi (argv[0]);
16444 bgp->ipv6_distance_ibgp = atoi (argv[1]);
16445 bgp->ipv6_distance_local = atoi (argv[2]);
16446 return CMD_SUCCESS;
16449 DEFUN (no_ipv6_bgp_distance,
16450 no_ipv6_bgp_distance_cmd,
16451 "no distance bgp <1-255> <1-255> <1-255>",
16453 "Define an administrative distance\n"
16455 "Distance for routes external to the AS\n"
16456 "Distance for routes internal to the AS\n"
16457 "Distance for local routes\n")
16463 bgp->ipv6_distance_ebgp= 0;
16464 bgp->ipv6_distance_ibgp = 0;
16465 bgp->ipv6_distance_local = 0;
16466 return CMD_SUCCESS;
16469 ALIAS (no_ipv6_bgp_distance,
16470 no_ipv6_bgp_distance2_cmd,
16473 "Define an administrative distance\n"
16476 DEFUN (ipv6_bgp_distance_source,
16477 ipv6_bgp_distance_source_cmd,
16478 "distance <1-255> X:X::X:X/M",
16479 "Define an administrative distance\n"
16480 "Administrative distance\n"
16481 "IP source prefix\n")
16483 bgp_distance_set (vty, argv[0], argv[1], NULL);
16484 return CMD_SUCCESS;
16487 DEFUN (no_ipv6_bgp_distance_source,
16488 no_ipv6_bgp_distance_source_cmd,
16489 "no distance <1-255> X:X::X:X/M",
16491 "Define an administrative distance\n"
16492 "Administrative distance\n"
16493 "IP source prefix\n")
16495 bgp_distance_unset (vty, argv[0], argv[1], NULL);
16496 return CMD_SUCCESS;
16499 DEFUN (ipv6_bgp_distance_source_access_list,
16500 ipv6_bgp_distance_source_access_list_cmd,
16501 "distance <1-255> X:X::X:X/M WORD",
16502 "Define an administrative distance\n"
16503 "Administrative distance\n"
16504 "IP source prefix\n"
16505 "Access list name\n")
16507 bgp_distance_set (vty, argv[0], argv[1], argv[2]);
16508 return CMD_SUCCESS;
16511 DEFUN (no_ipv6_bgp_distance_source_access_list,
16512 no_ipv6_bgp_distance_source_access_list_cmd,
16513 "no distance <1-255> X:X::X:X/M WORD",
16515 "Define an administrative distance\n"
16516 "Administrative distance\n"
16517 "IP source prefix\n"
16518 "Access list name\n")
16520 bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
16521 return CMD_SUCCESS;
16525 DEFUN (bgp_damp_set,
16527 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
16528 "BGP Specific commands\n"
16529 "Enable route-flap dampening\n"
16530 "Half-life time for the penalty\n"
16531 "Value to start reusing a route\n"
16532 "Value to start suppressing a route\n"
16533 "Maximum duration to suppress a stable route\n")
16536 int half = DEFAULT_HALF_LIFE * 60;
16537 int reuse = DEFAULT_REUSE;
16538 int suppress = DEFAULT_SUPPRESS;
16539 int max = 4 * half;
16543 half = atoi (argv[0]) * 60;
16544 reuse = atoi (argv[1]);
16545 suppress = atoi (argv[2]);
16546 max = atoi (argv[3]) * 60;
16548 else if (argc == 1)
16550 half = atoi (argv[0]) * 60;
16556 if (suppress < reuse)
16558 vty_out (vty, "Suppress value cannot be less than reuse value %s",
16563 return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty),
16564 half, reuse, suppress, max);
16567 ALIAS (bgp_damp_set,
16569 "bgp dampening <1-45>",
16570 "BGP Specific commands\n"
16571 "Enable route-flap dampening\n"
16572 "Half-life time for the penalty\n")
16574 ALIAS (bgp_damp_set,
16577 "BGP Specific commands\n"
16578 "Enable route-flap dampening\n")
16580 DEFUN (bgp_damp_unset,
16581 bgp_damp_unset_cmd,
16582 "no bgp dampening",
16584 "BGP Specific commands\n"
16585 "Enable route-flap dampening\n")
16590 return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty));
16593 ALIAS (bgp_damp_unset,
16594 bgp_damp_unset2_cmd,
16595 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
16597 "BGP Specific commands\n"
16598 "Enable route-flap dampening\n"
16599 "Half-life time for the penalty\n"
16600 "Value to start reusing a route\n"
16601 "Value to start suppressing a route\n"
16602 "Maximum duration to suppress a stable route\n")
16604 DEFUN (show_ip_bgp_dampened_paths,
16605 show_ip_bgp_dampened_paths_cmd,
16606 "show ip bgp dampened-paths",
16610 "Display paths suppressed due to dampening\n")
16612 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths,
16616 ALIAS (show_ip_bgp_dampened_paths,
16617 show_ip_bgp_damp_dampened_paths_cmd,
16618 "show ip bgp dampening dampened-paths",
16622 "Display detailed information about dampening\n"
16623 "Display paths suppressed due to dampening\n")
16625 DEFUN (show_ip_bgp_flap_statistics,
16626 show_ip_bgp_flap_statistics_cmd,
16627 "show ip bgp flap-statistics",
16631 "Display flap statistics of routes\n")
16633 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
16634 bgp_show_type_flap_statistics, NULL);
16637 ALIAS (show_ip_bgp_flap_statistics,
16638 show_ip_bgp_damp_flap_statistics_cmd,
16639 "show ip bgp dampening flap-statistics",
16643 "Display detailed information about dampening\n"
16644 "Display flap statistics of routes\n")
16646 DEFUN (show_bgp_ipv4_safi_dampened_paths,
16647 show_bgp_ipv4_safi_dampened_paths_cmd,
16648 "show bgp ipv4 (encap|multicast|unicast|vpn) dampened-paths",
16652 "Address Family modifier\n"
16653 "Address Family modifier\n"
16654 "Address Family modifier\n"
16655 "Address Family modifier\n"
16656 "Display paths suppressed due to dampening\n")
16660 if (bgp_parse_safi(argv[0], &safi)) {
16661 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
16662 return CMD_WARNING;
16665 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_dampend_paths, NULL);
16667 ALIAS (show_bgp_ipv4_safi_dampened_paths,
16668 show_bgp_ipv4_safi_damp_dampened_paths_cmd,
16669 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening dampened-paths",
16673 "Address Family modifier\n"
16674 "Address Family modifier\n"
16675 "Address Family modifier\n"
16676 "Address Family modifier\n"
16677 "Display detailed information about dampening\n"
16678 "Display paths suppressed due to dampening\n")
16680 DEFUN (show_bgp_ipv6_safi_dampened_paths,
16681 show_bgp_ipv6_safi_dampened_paths_cmd,
16682 "show bgp ipv6 (encap|multicast|unicast|vpn) dampened-paths",
16686 "Address Family modifier\n"
16687 "Address Family modifier\n"
16688 "Address Family modifier\n"
16689 "Address Family modifier\n"
16690 "Display paths suppressed due to dampening\n")
16694 if (bgp_parse_safi(argv[0], &safi)) {
16695 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
16696 return CMD_WARNING;
16699 return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_dampend_paths, NULL);
16701 ALIAS (show_bgp_ipv6_safi_dampened_paths,
16702 show_bgp_ipv6_safi_damp_dampened_paths_cmd,
16703 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening dampened-paths",
16707 "Address Family modifier\n"
16708 "Address Family modifier\n"
16709 "Address Family modifier\n"
16710 "Address Family modifier\n"
16711 "Display detailed information about dampening\n"
16712 "Display paths suppressed due to dampening\n")
16714 DEFUN (show_bgp_ipv4_safi_flap_statistics,
16715 show_bgp_ipv4_safi_flap_statistics_cmd,
16716 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics",
16720 "Address Family modifier\n"
16721 "Address Family modifier\n"
16722 "Address Family modifier\n"
16723 "Address Family modifier\n"
16724 "Display flap statistics of routes\n")
16728 if (bgp_parse_safi(argv[0], &safi)) {
16729 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
16730 return CMD_WARNING;
16733 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_statistics, NULL);
16735 ALIAS (show_bgp_ipv4_safi_flap_statistics,
16736 show_bgp_ipv4_safi_damp_flap_statistics_cmd,
16737 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics",
16741 "Address Family modifier\n"
16742 "Address Family modifier\n"
16743 "Address Family modifier\n"
16744 "Address Family modifier\n"
16745 "Display detailed information about dampening\n"
16746 "Display flap statistics of routes\n")
16748 DEFUN (show_bgp_ipv6_safi_flap_statistics,
16749 show_bgp_ipv6_safi_flap_statistics_cmd,
16750 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics",
16754 "Address Family modifier\n"
16755 "Address Family modifier\n"
16756 "Address Family modifier\n"
16757 "Address Family modifier\n"
16758 "Display flap statistics of routes\n")
16762 if (bgp_parse_safi(argv[0], &safi)) {
16763 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
16764 return CMD_WARNING;
16767 return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_flap_statistics, NULL);
16769 ALIAS (show_bgp_ipv6_safi_flap_statistics,
16770 show_bgp_ipv6_safi_damp_flap_statistics_cmd,
16771 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics",
16775 "Address Family modifier\n"
16776 "Address Family modifier\n"
16777 "Address Family modifier\n"
16778 "Address Family modifier\n"
16779 "Display detailed information about dampening\n"
16780 "Display flap statistics of routes\n")
16782 /* Display specified route of BGP table. */
16784 bgp_clear_damp_route (struct vty *vty, const char *view_name,
16785 const char *ip_str, afi_t afi, safi_t safi,
16786 struct prefix_rd *prd, int prefix_check)
16789 struct prefix match;
16790 struct bgp_node *rn;
16791 struct bgp_node *rm;
16792 struct bgp_info *ri;
16793 struct bgp_info *ri_temp;
16795 struct bgp_table *table;
16797 /* BGP structure lookup. */
16800 bgp = bgp_lookup_by_name (view_name);
16803 vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE);
16804 return CMD_WARNING;
16809 bgp = bgp_get_default ();
16812 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
16813 return CMD_WARNING;
16817 /* Check IP address argument. */
16818 ret = str2prefix (ip_str, &match);
16821 vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
16822 return CMD_WARNING;
16825 match.family = afi2family (afi);
16827 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
16829 for (rn = bgp_table_top (bgp->rib[AFI_IP][safi]); rn; rn = bgp_route_next (rn))
16831 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
16834 if ((table = rn->info) != NULL)
16835 if ((rm = bgp_node_match (table, &match)) != NULL)
16837 if (! prefix_check || rm->p.prefixlen == match.prefixlen)
16842 if (ri->extra && ri->extra->damp_info)
16844 ri_temp = ri->next;
16845 bgp_damp_info_free (ri->extra->damp_info, 1);
16853 bgp_unlock_node (rm);
16859 if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL)
16861 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
16866 if (ri->extra && ri->extra->damp_info)
16868 ri_temp = ri->next;
16869 bgp_damp_info_free (ri->extra->damp_info, 1);
16877 bgp_unlock_node (rn);
16881 return CMD_SUCCESS;
16884 DEFUN (clear_ip_bgp_dampening,
16885 clear_ip_bgp_dampening_cmd,
16886 "clear ip bgp dampening",
16890 "Clear route flap dampening information\n")
16892 bgp_damp_info_clean ();
16893 return CMD_SUCCESS;
16896 DEFUN (clear_ip_bgp_dampening_prefix,
16897 clear_ip_bgp_dampening_prefix_cmd,
16898 "clear ip bgp dampening A.B.C.D/M",
16902 "Clear route flap dampening information\n"
16903 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
16905 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
16906 SAFI_UNICAST, NULL, 1);
16909 DEFUN (clear_ip_bgp_dampening_address,
16910 clear_ip_bgp_dampening_address_cmd,
16911 "clear ip bgp dampening A.B.C.D",
16915 "Clear route flap dampening information\n"
16916 "Network to clear damping information\n")
16918 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
16919 SAFI_UNICAST, NULL, 0);
16922 DEFUN (clear_ip_bgp_dampening_address_mask,
16923 clear_ip_bgp_dampening_address_mask_cmd,
16924 "clear ip bgp dampening A.B.C.D A.B.C.D",
16928 "Clear route flap dampening information\n"
16929 "Network to clear damping information\n"
16933 char prefix_str[BUFSIZ];
16935 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
16938 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
16939 return CMD_WARNING;
16942 return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP,
16943 SAFI_UNICAST, NULL, 0);
16946 /* also used for encap safi */
16948 bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp,
16949 afi_t afi, safi_t safi, int *write)
16951 struct bgp_node *prn;
16952 struct bgp_node *rn;
16953 struct bgp_table *table;
16955 struct prefix_rd *prd;
16956 struct bgp_static *bgp_static;
16958 char buf[SU_ADDRSTRLEN];
16959 char rdbuf[RD_ADDRSTRLEN];
16961 /* Network configuration. */
16962 for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn))
16963 if ((table = prn->info) != NULL)
16964 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
16965 if ((bgp_static = rn->info) != NULL)
16968 prd = (struct prefix_rd *) &prn->p;
16970 /* "address-family" display. */
16971 bgp_config_write_family_header (vty, afi, safi, write);
16973 /* "network" configuration display. */
16974 prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN);
16975 label = decode_label (bgp_static->tag);
16977 vty_out (vty, " network %s/%d rd %s tag %d",
16978 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
16981 vty_out (vty, "%s", VTY_NEWLINE);
16986 /* Configuration of static route announcement and aggregate
16989 bgp_config_write_network (struct vty *vty, struct bgp *bgp,
16990 afi_t afi, safi_t safi, int *write)
16992 struct bgp_node *rn;
16994 struct bgp_static *bgp_static;
16995 struct bgp_aggregate *bgp_aggregate;
16996 char buf[SU_ADDRSTRLEN];
16998 if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)))
16999 return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write);
17001 /* Network configuration. */
17002 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
17003 if ((bgp_static = rn->info) != NULL)
17007 /* "address-family" display. */
17008 bgp_config_write_family_header (vty, afi, safi, write);
17010 /* "network" configuration display. */
17011 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
17013 u_int32_t destination;
17014 struct in_addr netmask;
17016 destination = ntohl (p->u.prefix4.s_addr);
17017 masklen2ip (p->prefixlen, &netmask);
17018 vty_out (vty, " network %s",
17019 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN));
17021 if ((IN_CLASSC (destination) && p->prefixlen == 24)
17022 || (IN_CLASSB (destination) && p->prefixlen == 16)
17023 || (IN_CLASSA (destination) && p->prefixlen == 8)
17024 || p->u.prefix4.s_addr == 0)
17026 /* Natural mask is not display. */
17029 vty_out (vty, " mask %s", inet_ntoa (netmask));
17033 vty_out (vty, " network %s/%d",
17034 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
17038 if (bgp_static->rmap.name)
17039 vty_out (vty, " route-map %s", bgp_static->rmap.name);
17042 if (bgp_static->backdoor)
17043 vty_out (vty, " backdoor");
17046 vty_out (vty, "%s", VTY_NEWLINE);
17049 /* Aggregate-address configuration. */
17050 for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn))
17051 if ((bgp_aggregate = rn->info) != NULL)
17055 /* "address-family" display. */
17056 bgp_config_write_family_header (vty, afi, safi, write);
17058 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
17060 struct in_addr netmask;
17062 masklen2ip (p->prefixlen, &netmask);
17063 vty_out (vty, " aggregate-address %s %s",
17064 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
17065 inet_ntoa (netmask));
17069 vty_out (vty, " aggregate-address %s/%d",
17070 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
17074 if (bgp_aggregate->as_set)
17075 vty_out (vty, " as-set");
17077 if (bgp_aggregate->summary_only)
17078 vty_out (vty, " summary-only");
17080 vty_out (vty, "%s", VTY_NEWLINE);
17087 bgp_config_write_distance (struct vty *vty, struct bgp *bgp,
17088 afi_t afi, safi_t safi, int *write)
17090 struct bgp_node *rn;
17091 struct bgp_distance *bdistance;
17093 if (afi == AFI_IP && safi == SAFI_UNICAST)
17095 /* Distance configuration. */
17096 if (bgp->distance_ebgp
17097 && bgp->distance_ibgp
17098 && bgp->distance_local
17099 && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT
17100 || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT
17101 || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT))
17102 vty_out (vty, " distance bgp %d %d %d%s",
17103 bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local,
17106 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
17107 if ((bdistance = rn->info) != NULL)
17109 vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance,
17110 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
17111 bdistance->access_list ? bdistance->access_list : "",
17117 else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
17119 bgp_config_write_family_header (vty, afi, safi, write);
17120 if (bgp->ipv6_distance_ebgp
17121 && bgp->ipv6_distance_ibgp
17122 && bgp->ipv6_distance_local
17123 && (bgp->ipv6_distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT
17124 || bgp->ipv6_distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT
17125 || bgp->ipv6_distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT))
17126 vty_out (vty, " distance bgp %d %d %d%s",
17127 bgp->ipv6_distance_ebgp, bgp->ipv6_distance_ibgp, bgp->ipv6_distance_local,
17130 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
17131 if ((bdistance = rn->info) != NULL)
17133 vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance,
17134 inet6_ntoa (rn->p.u.prefix6), rn->p.prefixlen,
17135 bdistance->access_list ? bdistance->access_list : "",
17139 #endif /* HAVE_IPV6 */
17144 /* Allocate routing table structure and install commands. */
17146 bgp_route_init (void)
17148 /* Init BGP distance table. */
17149 bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST);
17151 /* IPv4 BGP commands. */
17152 install_element (BGP_NODE, &bgp_network_cmd);
17153 install_element (BGP_NODE, &bgp_network_mask_cmd);
17154 install_element (BGP_NODE, &bgp_network_mask_natural_cmd);
17155 install_element (BGP_NODE, &bgp_network_route_map_cmd);
17156 install_element (BGP_NODE, &bgp_network_mask_route_map_cmd);
17157 install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd);
17158 install_element (BGP_NODE, &bgp_network_backdoor_cmd);
17159 install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd);
17160 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd);
17161 install_element (BGP_NODE, &no_bgp_network_cmd);
17162 install_element (BGP_NODE, &no_bgp_network_mask_cmd);
17163 install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd);
17164 install_element (BGP_NODE, &no_bgp_network_route_map_cmd);
17165 install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd);
17166 install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd);
17167 install_element (BGP_NODE, &no_bgp_network_backdoor_cmd);
17168 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd);
17169 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd);
17171 install_element (BGP_NODE, &aggregate_address_cmd);
17172 install_element (BGP_NODE, &aggregate_address_mask_cmd);
17173 install_element (BGP_NODE, &aggregate_address_summary_only_cmd);
17174 install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd);
17175 install_element (BGP_NODE, &aggregate_address_as_set_cmd);
17176 install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd);
17177 install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd);
17178 install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd);
17179 install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd);
17180 install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd);
17181 install_element (BGP_NODE, &no_aggregate_address_cmd);
17182 install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd);
17183 install_element (BGP_NODE, &no_aggregate_address_as_set_cmd);
17184 install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd);
17185 install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd);
17186 install_element (BGP_NODE, &no_aggregate_address_mask_cmd);
17187 install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd);
17188 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd);
17189 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
17190 install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
17192 /* IPv4 unicast configuration. */
17193 install_element (BGP_IPV4_NODE, &bgp_network_cmd);
17194 install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd);
17195 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd);
17196 install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd);
17197 install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd);
17198 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd);
17199 install_element (BGP_IPV4_NODE, &no_bgp_network_cmd);
17200 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd);
17201 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd);
17202 install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd);
17203 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd);
17204 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd);
17206 install_element (BGP_IPV4_NODE, &aggregate_address_cmd);
17207 install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd);
17208 install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd);
17209 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd);
17210 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd);
17211 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd);
17212 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd);
17213 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd);
17214 install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd);
17215 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd);
17216 install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd);
17217 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd);
17218 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd);
17219 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd);
17220 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd);
17221 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd);
17222 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd);
17223 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd);
17224 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
17225 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
17227 /* IPv4 multicast configuration. */
17228 install_element (BGP_IPV4M_NODE, &bgp_network_cmd);
17229 install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd);
17230 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd);
17231 install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd);
17232 install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd);
17233 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd);
17234 install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd);
17235 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd);
17236 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd);
17237 install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd);
17238 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd);
17239 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd);
17240 install_element (BGP_IPV4M_NODE, &aggregate_address_cmd);
17241 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd);
17242 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd);
17243 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd);
17244 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd);
17245 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd);
17246 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd);
17247 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd);
17248 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd);
17249 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd);
17250 install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd);
17251 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd);
17252 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd);
17253 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd);
17254 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd);
17255 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd);
17256 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd);
17257 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd);
17258 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
17259 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
17261 install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd);
17262 install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd);
17263 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd);
17264 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd);
17265 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
17266 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
17267 install_element (VIEW_NODE, &show_bgp_ipv4_encap_route_cmd);
17268 install_element (VIEW_NODE, &show_bgp_ipv6_encap_route_cmd);
17269 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
17270 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
17271 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd);
17272 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd);
17273 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
17274 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
17275 install_element (VIEW_NODE, &show_bgp_ipv4_encap_prefix_cmd);
17276 install_element (VIEW_NODE, &show_bgp_ipv6_encap_prefix_cmd);
17277 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
17278 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
17279 install_element (VIEW_NODE, &show_bgp_afi_safi_view_cmd);
17280 install_element (VIEW_NODE, &show_bgp_view_afi_safi_route_cmd);
17281 install_element (VIEW_NODE, &show_bgp_view_afi_safi_prefix_cmd);
17282 install_element (VIEW_NODE, &show_bgp_ipv4_safi_regexp_cmd);
17283 install_element (VIEW_NODE, &show_bgp_ipv6_safi_regexp_cmd);
17284 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_list_cmd);
17285 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_list_cmd);
17286 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_list_cmd);
17287 install_element (VIEW_NODE, &show_bgp_ipv4_filter_list_cmd);
17288 install_element (VIEW_NODE, &show_bgp_ipv4_safi_filter_list_cmd);
17289 install_element (VIEW_NODE, &show_bgp_ipv6_safi_filter_list_cmd);
17290 install_element (VIEW_NODE, &show_bgp_ipv4_route_map_cmd);
17291 install_element (VIEW_NODE, &show_bgp_ipv4_cidr_only_cmd);
17292 install_element (VIEW_NODE, &show_bgp_ipv4_safi_cidr_only_cmd);
17293 install_element (VIEW_NODE, &show_bgp_ipv4_community_cmd);
17294 install_element (VIEW_NODE, &show_bgp_ipv4_community2_cmd);
17295 install_element (VIEW_NODE, &show_bgp_ipv4_community3_cmd);
17296 install_element (VIEW_NODE, &show_bgp_ipv4_community4_cmd);
17297 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_cmd);
17298 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_cmd);
17299 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_cmd);
17300 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_cmd);
17301 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd);
17302 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd);
17303 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd);
17304 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd);
17305 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd);
17306 install_element (VIEW_NODE, &show_bgp_ipv4_community_exact_cmd);
17307 install_element (VIEW_NODE, &show_bgp_ipv4_community2_exact_cmd);
17308 install_element (VIEW_NODE, &show_bgp_ipv4_community3_exact_cmd);
17309 install_element (VIEW_NODE, &show_bgp_ipv4_community4_exact_cmd);
17310 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
17311 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
17312 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
17313 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
17314 install_element (VIEW_NODE, &show_bgp_ipv4_community_list_cmd);
17315 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_cmd);
17316 install_element (VIEW_NODE, &show_bgp_ipv4_community_list_exact_cmd);
17317 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd);
17319 /* large-communities */
17320 install_element (VIEW_NODE, &show_bgp_ipv4_lcommunity_cmd);
17321 install_element (VIEW_NODE, &show_bgp_ipv4_lcommunity2_cmd);
17322 install_element (VIEW_NODE, &show_bgp_ipv4_lcommunity3_cmd);
17323 install_element (VIEW_NODE, &show_bgp_ipv4_lcommunity4_cmd);
17324 install_element (VIEW_NODE, &show_bgp_ipv4_safi_lcommunity_cmd);
17325 install_element (VIEW_NODE, &show_bgp_ipv4_safi_lcommunity2_cmd);
17326 install_element (VIEW_NODE, &show_bgp_ipv4_safi_lcommunity3_cmd);
17327 install_element (VIEW_NODE, &show_bgp_ipv4_safi_lcommunity4_cmd);
17328 install_element (VIEW_NODE, &show_bgp_view_afi_safi_lcommunity_all_cmd);
17329 install_element (VIEW_NODE, &show_bgp_view_afi_safi_lcommunity_cmd);
17330 install_element (VIEW_NODE, &show_bgp_view_afi_safi_lcommunity2_cmd);
17331 install_element (VIEW_NODE, &show_bgp_view_afi_safi_lcommunity3_cmd);
17332 install_element (VIEW_NODE, &show_bgp_view_afi_safi_lcommunity4_cmd);
17333 install_element (VIEW_NODE, &show_bgp_ipv4_lcommunity_list_cmd);
17334 install_element (VIEW_NODE, &show_bgp_ipv4_safi_lcommunity_list_cmd);
17336 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_longer_cmd);
17337 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd);
17338 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd);
17339 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd);
17340 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd);
17341 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd);
17342 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd);
17343 install_element (VIEW_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd);
17344 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd);
17345 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd);
17346 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd);
17347 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd);
17348 install_element (VIEW_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd);
17349 install_element (VIEW_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd);
17350 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd);
17351 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd);
17352 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd);
17353 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd);
17354 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd);
17355 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd);
17356 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_address_cmd);
17357 install_element (VIEW_NODE, &show_bgp_ipv6_flap_address_cmd);
17358 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd);
17359 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd);
17360 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd);
17361 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd);
17362 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd);
17363 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd);
17364 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd);
17365 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd);
17366 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd);
17367 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd);
17368 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd);
17369 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd);
17370 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd);
17371 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd);
17372 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd);
17373 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd);
17374 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd);
17375 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd);
17376 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd);
17377 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd);
17378 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd);
17379 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd);
17380 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd);
17381 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd);
17382 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd);
17383 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd);
17384 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd);
17385 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd);
17386 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd);
17387 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd);
17388 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd);
17389 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd);
17390 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
17391 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
17392 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd);
17393 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
17394 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
17396 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
17397 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd);
17398 install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
17399 install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
17400 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
17401 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
17402 install_element (RESTRICTED_NODE, &show_bgp_ipv4_prefix_cmd);
17403 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd);
17404 install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
17405 install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
17406 install_element (RESTRICTED_NODE, &show_bgp_ipv4_encap_prefix_cmd);
17407 install_element (RESTRICTED_NODE, &show_bgp_ipv6_encap_prefix_cmd);
17408 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
17409 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
17410 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_route_cmd);
17411 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_prefix_cmd);
17412 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_cmd);
17413 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_cmd);
17414 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_cmd);
17415 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_cmd);
17416 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_cmd);
17417 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_cmd);
17418 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_cmd);
17419 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_cmd);
17420 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd);
17421 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd);
17422 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd);
17423 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd);
17424 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd);
17425 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_exact_cmd);
17426 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_exact_cmd);
17427 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_exact_cmd);
17428 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_exact_cmd);
17429 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
17430 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
17431 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
17432 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
17434 /* large-community */
17435 install_element (RESTRICTED_NODE, &show_bgp_ipv4_lcommunity_cmd);
17436 install_element (RESTRICTED_NODE, &show_bgp_ipv4_lcommunity2_cmd);
17437 install_element (RESTRICTED_NODE, &show_bgp_ipv4_lcommunity3_cmd);
17438 install_element (RESTRICTED_NODE, &show_bgp_ipv4_lcommunity4_cmd);
17439 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_lcommunity_cmd);
17440 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_lcommunity2_cmd);
17441 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_lcommunity3_cmd);
17442 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_lcommunity4_cmd);
17443 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_lcommunity_all_cmd);
17444 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_lcommunity_cmd);
17445 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_lcommunity2_cmd);
17446 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_lcommunity3_cmd);
17447 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_lcommunity4_cmd);
17449 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
17450 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
17451 install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
17452 install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
17454 /* BGP dampening clear commands */
17455 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd);
17456 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd);
17458 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd);
17459 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd);
17461 /* New config IPv6 BGP commands. */
17462 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd);
17463 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd);
17464 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd);
17465 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd);
17467 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd);
17468 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd);
17469 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd);
17470 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd);
17472 install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd);
17473 install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd);
17475 /* Old config IPv6 BGP commands. */
17476 install_element (BGP_NODE, &old_ipv6_bgp_network_cmd);
17477 install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd);
17479 install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd);
17480 install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd);
17481 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd);
17482 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd);
17484 install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd);
17485 install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd);
17486 install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd);
17487 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd);
17488 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd);
17489 install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd);
17490 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd);
17491 install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd);
17492 install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd);
17493 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_cmd);
17494 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_cmd);
17495 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_cmd);
17496 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_cmd);
17497 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
17498 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
17499 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
17500 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
17501 install_element (VIEW_NODE, &show_bgp_community_list_cmd);
17503 /* large-community */
17504 install_element (VIEW_NODE, &show_bgp_ipv6_safi_lcommunity_cmd);
17505 install_element (VIEW_NODE, &show_bgp_ipv6_safi_lcommunity2_cmd);
17506 install_element (VIEW_NODE, &show_bgp_ipv6_safi_lcommunity3_cmd);
17507 install_element (VIEW_NODE, &show_bgp_ipv6_safi_lcommunity4_cmd);
17508 install_element (VIEW_NODE, &show_bgp_lcommunity_list_cmd);
17510 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd);
17511 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
17512 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
17513 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
17514 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
17515 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
17516 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
17517 install_element (VIEW_NODE, &show_bgp_ipv4_rsclient_cmd);
17518 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_cmd);
17519 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd);
17520 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_route_cmd);
17521 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
17522 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
17523 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
17524 install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd);
17525 install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd);
17526 install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd);
17527 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
17528 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
17529 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
17530 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
17531 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
17532 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
17533 install_element (VIEW_NODE, &show_bgp_view_ipv4_rsclient_cmd);
17534 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_cmd);
17535 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd);
17536 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
17537 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
17538 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
17539 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
17542 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
17544 install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd);
17545 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd);
17546 install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd);
17547 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd);
17548 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_cmd);
17549 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_cmd);
17550 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_cmd);
17551 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_cmd);
17552 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
17553 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
17554 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
17555 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
17556 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_lcommunity_cmd);
17557 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_lcommunity2_cmd);
17558 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_lcommunity3_cmd);
17559 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_lcommunity4_cmd);
17560 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_route_cmd);
17561 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
17562 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
17563 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
17564 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd);
17565 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd);
17566 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
17567 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
17568 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
17569 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
17570 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
17573 install_element (ENABLE_NODE, &show_bgp_statistics_cmd);
17574 install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd);
17576 install_element (BGP_NODE, &bgp_distance_cmd);
17577 install_element (BGP_NODE, &no_bgp_distance_cmd);
17578 install_element (BGP_NODE, &no_bgp_distance2_cmd);
17579 install_element (BGP_NODE, &bgp_distance_source_cmd);
17580 install_element (BGP_NODE, &no_bgp_distance_source_cmd);
17581 install_element (BGP_NODE, &bgp_distance_source_access_list_cmd);
17582 install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd);
17584 install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_cmd);
17585 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_cmd);
17586 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance2_cmd);
17587 install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_cmd);
17588 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_cmd);
17589 install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_access_list_cmd);
17590 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_access_list_cmd);
17591 #endif /* HAVE_IPV6 */
17593 install_element (BGP_NODE, &bgp_damp_set_cmd);
17594 install_element (BGP_NODE, &bgp_damp_set2_cmd);
17595 install_element (BGP_NODE, &bgp_damp_set3_cmd);
17596 install_element (BGP_NODE, &bgp_damp_unset_cmd);
17597 install_element (BGP_NODE, &bgp_damp_unset2_cmd);
17598 install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd);
17599 install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd);
17600 install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd);
17601 install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd);
17602 install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd);
17604 /* IPv4 Multicast Mode */
17605 install_element (BGP_IPV4M_NODE, &bgp_damp_set_cmd);
17606 install_element (BGP_IPV4M_NODE, &bgp_damp_set2_cmd);
17607 install_element (BGP_IPV4M_NODE, &bgp_damp_set3_cmd);
17608 install_element (BGP_IPV4M_NODE, &bgp_damp_unset_cmd);
17609 install_element (BGP_IPV4M_NODE, &bgp_damp_unset2_cmd);
17612 /* Deprecated AS-Pathlimit commands */
17613 install_element (BGP_NODE, &bgp_network_ttl_cmd);
17614 install_element (BGP_NODE, &bgp_network_mask_ttl_cmd);
17615 install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd);
17616 install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd);
17617 install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd);
17618 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
17620 install_element (BGP_NODE, &no_bgp_network_ttl_cmd);
17621 install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd);
17622 install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd);
17623 install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd);
17624 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
17625 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
17627 install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd);
17628 install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd);
17629 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd);
17630 install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd);
17631 install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd);
17632 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
17634 install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd);
17635 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd);
17636 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd);
17637 install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd);
17638 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
17639 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
17641 install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd);
17642 install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd);
17643 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd);
17644 install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd);
17645 install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd);
17646 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
17648 install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd);
17649 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd);
17650 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd);
17651 install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd);
17652 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
17653 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
17655 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd);
17656 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd);
17658 /* old style commands */
17659 install_element (VIEW_NODE, &show_ip_bgp_cmd);
17660 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd);
17661 install_element (VIEW_NODE, &show_ip_bgp_route_cmd);
17662 install_element (VIEW_NODE, &show_ip_bgp_route_pathtype_cmd);
17663 install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd);
17664 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd);
17665 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
17666 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
17667 install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd);
17668 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd);
17669 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd);
17670 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd);
17671 install_element (VIEW_NODE, &show_ip_bgp_prefix_pathtype_cmd);
17672 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
17673 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
17674 install_element (VIEW_NODE, &show_ip_bgp_view_cmd);
17675 install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd);
17676 install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd);
17677 install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd);
17678 install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd);
17679 install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd);
17680 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
17681 install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd);
17682 install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
17683 install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd);
17684 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd);
17685 install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd);
17686 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
17687 install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd);
17688 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd);
17689 install_element (VIEW_NODE, &show_ip_bgp_community_cmd);
17690 install_element (VIEW_NODE, &show_ip_bgp_community2_cmd);
17691 install_element (VIEW_NODE, &show_ip_bgp_community3_cmd);
17692 install_element (VIEW_NODE, &show_ip_bgp_community4_cmd);
17693 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd);
17694 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd);
17695 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd);
17696 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd);
17697 install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd);
17698 install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd);
17699 install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd);
17700 install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd);
17701 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
17702 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
17703 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
17704 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
17705 install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd);
17706 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd);
17707 install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd);
17708 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
17709 install_element (VIEW_NODE, &show_ip_bgp_lcommunity_all_cmd);
17710 install_element (VIEW_NODE, &show_ip_bgp_ipv4_lcommunity_all_cmd);
17711 install_element (VIEW_NODE, &show_ip_bgp_lcommunity_cmd);
17712 install_element (VIEW_NODE, &show_ip_bgp_lcommunity2_cmd);
17713 install_element (VIEW_NODE, &show_ip_bgp_lcommunity3_cmd);
17714 install_element (VIEW_NODE, &show_ip_bgp_lcommunity4_cmd);
17715 install_element (VIEW_NODE, &show_ip_bgp_ipv4_lcommunity_cmd);
17716 install_element (VIEW_NODE, &show_ip_bgp_ipv4_lcommunity2_cmd);
17717 install_element (VIEW_NODE, &show_ip_bgp_ipv4_lcommunity3_cmd);
17718 install_element (VIEW_NODE, &show_ip_bgp_ipv4_lcommunity4_cmd);
17719 install_element (VIEW_NODE, &show_ip_bgp_lcommunity_list_cmd);
17720 install_element (VIEW_NODE, &show_ip_bgp_ipv4_lcommunity_list_cmd);
17721 install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd);
17722 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
17723 install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
17724 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
17725 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
17726 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
17727 install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd);
17728 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
17729 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
17730 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
17731 install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd);
17732 install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd);
17733 install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd);
17734 install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd);
17735 install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_flap_stats_cmd);
17736 install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd);
17737 install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd);
17738 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd);
17739 install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd);
17740 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd);
17741 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd);
17742 install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd);
17743 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd);
17744 install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd);
17745 install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd);
17746 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd);
17747 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd);
17748 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd);
17749 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
17750 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd);
17751 install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd);
17752 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd);
17753 install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd);
17754 install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd);
17755 install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd);
17756 install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd);
17757 install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd);
17758 install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd);
17759 install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd);
17760 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd);
17761 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd);
17762 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
17764 install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd);
17765 install_element (RESTRICTED_NODE, &show_ip_bgp_route_pathtype_cmd);
17766 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd);
17767 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd);
17768 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
17769 install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd);
17770 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd);
17771 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd);
17772 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd);
17773 install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_pathtype_cmd);
17774 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
17775 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
17776 install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd);
17777 install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd);
17778 install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd);
17779 install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd);
17780 install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd);
17781 install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd);
17782 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd);
17783 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd);
17784 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd);
17785 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd);
17786 install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd);
17787 install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd);
17788 install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd);
17789 install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd);
17790 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
17791 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
17792 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
17793 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
17794 install_element (RESTRICTED_NODE, &show_ip_bgp_lcommunity_cmd);
17795 install_element (RESTRICTED_NODE, &show_ip_bgp_lcommunity2_cmd);
17796 install_element (RESTRICTED_NODE, &show_ip_bgp_lcommunity3_cmd);
17797 install_element (RESTRICTED_NODE, &show_ip_bgp_lcommunity4_cmd);
17798 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_lcommunity_cmd);
17799 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_lcommunity2_cmd);
17800 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_lcommunity3_cmd);
17801 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_lcommunity4_cmd);
17802 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd);
17803 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd);
17804 install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd);
17805 install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
17807 install_element (VIEW_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd);
17808 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd);
17809 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd);
17811 install_element (VIEW_NODE, &show_bgp_cmd);
17812 install_element (VIEW_NODE, &show_bgp_ipv6_cmd);
17813 install_element (VIEW_NODE, &show_bgp_route_cmd);
17814 install_element (VIEW_NODE, &show_bgp_prefix_cmd);
17815 install_element (VIEW_NODE, &show_bgp_route_pathtype_cmd);
17816 install_element (VIEW_NODE, &show_bgp_ipv6_route_pathtype_cmd);
17817 install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd);
17818 install_element (VIEW_NODE, &show_bgp_prefix_pathtype_cmd);
17819 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_pathtype_cmd);
17820 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd);
17821 install_element (VIEW_NODE, &show_bgp_regexp_cmd);
17822 install_element (VIEW_NODE, &show_bgp_prefix_list_cmd);
17823 install_element (VIEW_NODE, &show_bgp_filter_list_cmd);
17824 install_element (VIEW_NODE, &show_bgp_route_map_cmd);
17825 install_element (VIEW_NODE, &show_bgp_community_all_cmd);
17826 install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd);
17827 install_element (VIEW_NODE, &show_bgp_community_cmd);
17828 install_element (VIEW_NODE, &show_bgp_community2_cmd);
17829 install_element (VIEW_NODE, &show_bgp_community3_cmd);
17830 install_element (VIEW_NODE, &show_bgp_community4_cmd);
17831 install_element (VIEW_NODE, &show_bgp_community_exact_cmd);
17832 install_element (VIEW_NODE, &show_bgp_community2_exact_cmd);
17833 install_element (VIEW_NODE, &show_bgp_community3_exact_cmd);
17834 install_element (VIEW_NODE, &show_bgp_community4_exact_cmd);
17835 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_cmd);
17836 install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd);
17837 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd);
17838 install_element (VIEW_NODE, &show_bgp_lcommunity_all_cmd);
17839 install_element (VIEW_NODE, &show_bgp_ipv6_lcommunity_all_cmd);
17840 install_element (VIEW_NODE, &show_bgp_lcommunity_cmd);
17841 install_element (VIEW_NODE, &show_bgp_lcommunity2_cmd);
17842 install_element (VIEW_NODE, &show_bgp_lcommunity3_cmd);
17843 install_element (VIEW_NODE, &show_bgp_lcommunity4_cmd);
17844 install_element (VIEW_NODE, &show_bgp_ipv6_safi_lcommunity_list_cmd);
17845 install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd);
17846 install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd);
17847 install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd);
17848 install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd);
17849 install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
17850 install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd);
17851 install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd);
17852 install_element (VIEW_NODE, &show_bgp_rsclient_cmd);
17853 install_element (VIEW_NODE, &show_bgp_view_cmd);
17854 install_element (VIEW_NODE, &show_bgp_view_route_cmd);
17855 install_element (VIEW_NODE, &show_bgp_view_prefix_cmd);
17856 install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
17857 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd);
17858 install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd);
17859 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
17860 install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd);
17861 install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd);
17862 install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd);
17864 install_element (RESTRICTED_NODE, &show_bgp_route_cmd);
17865 install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd);
17866 install_element (RESTRICTED_NODE, &show_bgp_route_pathtype_cmd);
17867 install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_pathtype_cmd);
17868 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd);
17869 install_element (RESTRICTED_NODE, &show_bgp_prefix_pathtype_cmd);
17870 install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_pathtype_cmd);
17871 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd);
17872 install_element (RESTRICTED_NODE, &show_bgp_community_cmd);
17873 install_element (RESTRICTED_NODE, &show_bgp_community2_cmd);
17874 install_element (RESTRICTED_NODE, &show_bgp_community3_cmd);
17875 install_element (RESTRICTED_NODE, &show_bgp_community4_cmd);
17876 install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd);
17877 install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd);
17878 install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd);
17879 install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd);
17880 install_element (RESTRICTED_NODE, &show_bgp_lcommunity_cmd);
17881 install_element (RESTRICTED_NODE, &show_bgp_lcommunity2_cmd);
17882 install_element (RESTRICTED_NODE, &show_bgp_lcommunity3_cmd);
17883 install_element (RESTRICTED_NODE, &show_bgp_lcommunity4_cmd);
17884 install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd);
17885 install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd);
17886 install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
17888 install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd);
17889 install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd);
17891 install_element (VIEW_NODE, &show_ipv6_bgp_cmd);
17892 install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd);
17893 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd);
17894 install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd);
17895 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd);
17896 install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd);
17897 install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd);
17898 install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd);
17899 install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd);
17900 install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd);
17901 install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd);
17902 install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd);
17903 install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd);
17904 install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd);
17905 install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd);
17906 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd);
17907 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd);
17908 install_element (VIEW_NODE, &show_ipv6_bgp_lcommunity_all_cmd);
17909 install_element (VIEW_NODE, &show_ipv6_bgp_lcommunity_cmd);
17910 install_element (VIEW_NODE, &show_ipv6_bgp_lcommunity2_cmd);
17911 install_element (VIEW_NODE, &show_ipv6_bgp_lcommunity3_cmd);
17912 install_element (VIEW_NODE, &show_ipv6_bgp_lcommunity4_cmd);
17913 install_element (VIEW_NODE, &show_ipv6_bgp_lcommunity_list_cmd);
17914 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd);
17915 install_element (VIEW_NODE, &show_ipv6_mbgp_cmd);
17916 install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd);
17917 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd);
17918 install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd);
17919 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd);
17920 install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd);
17921 install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd);
17922 install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd);
17923 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd);
17924 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd);
17925 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd);
17926 install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd);
17927 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd);
17928 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd);
17929 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd);
17930 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd);
17931 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
17932 install_element (VIEW_NODE, &show_ipv6_mbgp_lcommunity_all_cmd);
17933 install_element (VIEW_NODE, &show_ipv6_mbgp_lcommunity_cmd);
17934 install_element (VIEW_NODE, &show_ipv6_mbgp_lcommunity2_cmd);
17935 install_element (VIEW_NODE, &show_ipv6_mbgp_lcommunity3_cmd);
17936 install_element (VIEW_NODE, &show_ipv6_mbgp_lcommunity4_cmd);
17937 install_element (VIEW_NODE, &show_ipv6_mbgp_lcommunity_list_cmd);
17938 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
17939 install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
17940 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
17941 install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
17942 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
17943 install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd);
17944 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd);
17945 /* old with name safi collision */
17946 install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd);
17947 install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd);
17948 install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd);
17949 install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd);
17950 install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd);
17951 install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd);
17952 install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd);
17953 install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd);
17954 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd);
17955 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd);
17956 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd);
17957 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd);
17958 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd);
17959 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd);
17960 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd);
17961 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd);
17963 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd);
17964 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd);
17966 install_element (VIEW_NODE, &show_bgp_ipv6_lcommunity_cmd);
17967 install_element (VIEW_NODE, &show_bgp_ipv6_lcommunity2_cmd);
17968 install_element (VIEW_NODE, &show_bgp_ipv6_lcommunity3_cmd);
17969 install_element (VIEW_NODE, &show_bgp_ipv6_lcommunity4_cmd);
17970 install_element (RESTRICTED_NODE, &show_bgp_ipv6_lcommunity_cmd);
17971 install_element (RESTRICTED_NODE, &show_bgp_ipv6_lcommunity2_cmd);
17972 install_element (RESTRICTED_NODE, &show_bgp_ipv6_lcommunity3_cmd);
17973 install_element (RESTRICTED_NODE, &show_bgp_ipv6_lcommunity4_cmd);
17974 install_element (VIEW_NODE, &show_bgp_ipv6_lcommunity_list_cmd);
17976 install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd);
17977 install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd);
17978 install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd);
17979 install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd);
17981 install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd);
17982 install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd);
17983 install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd);
17984 install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd);
17988 bgp_route_finish (void)
17990 bgp_table_unlock (bgp_distance_table);
17991 bgp_distance_table = NULL;