1 /* BGP routing information
2 Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro
4 This file is part of GNU Zebra.
6 GNU Zebra is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 GNU Zebra is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Zebra; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
33 #include "sockunion.h"
36 #include "workqueue.h"
38 #include "bgpd/bgpd.h"
39 #include "bgpd/bgp_table.h"
40 #include "bgpd/bgp_route.h"
41 #include "bgpd/bgp_attr.h"
42 #include "bgpd/bgp_debug.h"
43 #include "bgpd/bgp_aspath.h"
44 #include "bgpd/bgp_regex.h"
45 #include "bgpd/bgp_community.h"
46 #include "bgpd/bgp_ecommunity.h"
47 #include "bgpd/bgp_clist.h"
48 #include "bgpd/bgp_packet.h"
49 #include "bgpd/bgp_filter.h"
50 #include "bgpd/bgp_fsm.h"
51 #include "bgpd/bgp_mplsvpn.h"
52 #include "bgpd/bgp_nexthop.h"
53 #include "bgpd/bgp_damp.h"
54 #include "bgpd/bgp_advertise.h"
55 #include "bgpd/bgp_zebra.h"
56 #include "bgpd/bgp_vty.h"
58 /* Extern from bgp_dump.c */
59 extern char *bgp_origin_str
[];
60 extern char *bgp_origin_long_str
[];
62 static struct bgp_node
*
63 bgp_afi_node_get (struct bgp_table
*table
, afi_t afi
, safi_t safi
, struct prefix
*p
,
64 struct prefix_rd
*prd
)
67 struct bgp_node
*prn
= NULL
;
73 if (safi
== SAFI_MPLS_VPN
)
75 prn
= bgp_node_get (table
, (struct prefix
*) prd
);
77 if (prn
->info
== NULL
)
78 prn
->info
= bgp_table_init (afi
, safi
);
80 bgp_unlock_node (prn
);
84 rn
= bgp_node_get (table
, p
);
86 if (safi
== SAFI_MPLS_VPN
)
92 /* Allocate new bgp info structure. */
93 static struct bgp_info
*
98 new = XMALLOC (MTYPE_BGP_ROUTE
, sizeof (struct bgp_info
));
99 memset (new, 0, sizeof (struct bgp_info
));
104 /* Free bgp route information. */
106 bgp_info_free (struct bgp_info
*binfo
)
109 bgp_attr_unintern (binfo
->attr
);
111 if (binfo
->damp_info
)
112 bgp_damp_info_free (binfo
->damp_info
, 0);
114 peer_unlock (binfo
->peer
); /* bgp_info peer reference */
116 XFREE (MTYPE_BGP_ROUTE
, binfo
);
120 bgp_info_lock (struct bgp_info
*binfo
)
127 bgp_info_unlock (struct bgp_info
*binfo
)
129 assert (binfo
&& binfo
->lock
> 0);
132 if (binfo
->lock
== 0)
135 zlog_debug ("%s: unlocked and freeing", __func__
);
136 zlog_backtrace (LOG_DEBUG
);
138 bgp_info_free (binfo
);
143 if (binfo
->lock
== 1)
145 zlog_debug ("%s: unlocked to 1", __func__
);
146 zlog_backtrace (LOG_DEBUG
);
154 bgp_info_add (struct bgp_node
*rn
, struct bgp_info
*ri
)
156 struct bgp_info
*top
;
168 peer_lock (ri
->peer
); /* bgp_info peer reference */
171 /* Do the actual removal of info from RIB, for use by bgp_process
172 completion callback *only* */
174 bgp_info_reap (struct bgp_node
*rn
, struct bgp_info
*ri
)
177 ri
->next
->prev
= ri
->prev
;
179 ri
->prev
->next
= ri
->next
;
183 bgp_info_unlock (ri
);
184 bgp_unlock_node (rn
);
188 bgp_info_delete (struct bgp_node
*rn
, struct bgp_info
*ri
)
190 bgp_info_set_flag (rn
, ri
, BGP_INFO_REMOVED
);
191 /* set of previous already took care of pcount */
192 UNSET_FLAG (ri
->flags
, BGP_INFO_VALID
);
195 /* Adjust pcount as required */
197 bgp_pcount_adjust (struct bgp_node
*rn
, struct bgp_info
*ri
)
199 /* Ignore 'pcount' for RS-client tables */
200 if (rn
->table
->type
!= BGP_TABLE_MAIN
201 || ri
->peer
== ri
->peer
->bgp
->peer_self
)
204 if (BGP_INFO_HOLDDOWN (ri
)
205 && CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
208 UNSET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
210 /* slight hack, but more robust against errors. */
211 if (ri
->peer
->pcount
[rn
->table
->afi
][rn
->table
->safi
])
212 ri
->peer
->pcount
[rn
->table
->afi
][rn
->table
->safi
]--;
215 zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s",
216 __func__
, ri
->peer
->host
);
217 zlog_backtrace (LOG_WARNING
);
218 zlog_warn ("%s: Please report to Quagga bugzilla", __func__
);
221 else if (!BGP_INFO_HOLDDOWN (ri
)
222 && !CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
224 SET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
225 ri
->peer
->pcount
[rn
->table
->afi
][rn
->table
->safi
]++;
230 /* Set/unset bgp_info flags, adjusting any other state as needed.
231 * This is here primarily to keep prefix-count in check.
234 bgp_info_set_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
236 SET_FLAG (ri
->flags
, flag
);
238 /* early bath if we know it's not a flag that changes useability state */
239 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_UNUSEABLE
))
242 bgp_pcount_adjust (rn
, ri
);
246 bgp_info_unset_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
248 UNSET_FLAG (ri
->flags
, flag
);
250 /* early bath if we know it's not a flag that changes useability state */
251 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_UNUSEABLE
))
254 bgp_pcount_adjust (rn
, ri
);
257 /* Get MED value. If MED value is missing and "bgp bestpath
258 missing-as-worst" is specified, treat it as the worst value. */
260 bgp_med_value (struct attr
*attr
, struct bgp
*bgp
)
262 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
266 if (bgp_flag_check (bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
273 /* Compare two bgp route entity. br is preferable then return 1. */
275 bgp_info_cmp (struct bgp
*bgp
, struct bgp_info
*new, struct bgp_info
*exist
)
278 u_int32_t exist_pref
;
281 struct in_addr new_id
;
282 struct in_addr exist_id
;
285 int internal_as_route
= 0;
286 int confed_as_route
= 0;
295 /* 1. Weight check. */
296 if (new->attr
->weight
> exist
->attr
->weight
)
298 if (new->attr
->weight
< exist
->attr
->weight
)
301 /* 2. Local preference check. */
302 if (new->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
303 new_pref
= new->attr
->local_pref
;
305 new_pref
= bgp
->default_local_pref
;
307 if (exist
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
308 exist_pref
= exist
->attr
->local_pref
;
310 exist_pref
= bgp
->default_local_pref
;
312 if (new_pref
> exist_pref
)
314 if (new_pref
< exist_pref
)
317 /* 3. Local route check. */
318 if (new->sub_type
== BGP_ROUTE_STATIC
)
320 if (exist
->sub_type
== BGP_ROUTE_STATIC
)
323 if (new->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
325 if (exist
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
328 if (new->sub_type
== BGP_ROUTE_AGGREGATE
)
330 if (exist
->sub_type
== BGP_ROUTE_AGGREGATE
)
333 /* 4. AS path length check. */
334 if (! bgp_flag_check (bgp
, BGP_FLAG_ASPATH_IGNORE
))
336 int exist_hops
= aspath_count_hops (exist
->attr
->aspath
);
337 int exist_confeds
= aspath_count_confeds (exist
->attr
->aspath
);
339 if (bgp_flag_check (bgp
, BGP_FLAG_ASPATH_CONFED
))
343 aspath_hops
= aspath_count_hops (new->attr
->aspath
);
344 aspath_hops
+= aspath_count_confeds (new->attr
->aspath
);
346 if ( aspath_hops
< (exist_hops
+ exist_confeds
))
348 if ( aspath_hops
> (exist_hops
+ exist_confeds
))
353 int newhops
= aspath_count_hops (new->attr
->aspath
);
355 if (newhops
< exist_hops
)
357 if (newhops
> exist_hops
)
362 /* 5. Origin check. */
363 if (new->attr
->origin
< exist
->attr
->origin
)
365 if (new->attr
->origin
> exist
->attr
->origin
)
369 internal_as_route
= (aspath_count_hops (new->attr
->aspath
) == 0
370 && aspath_count_hops (exist
->attr
->aspath
) == 0);
371 confed_as_route
= (aspath_count_confeds (new->attr
->aspath
) > 0
372 && aspath_count_confeds (exist
->attr
->aspath
) > 0
373 && aspath_count_hops (new->attr
->aspath
) == 0
374 && aspath_count_hops (exist
->attr
->aspath
) == 0);
376 if (bgp_flag_check (bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
)
377 || (bgp_flag_check (bgp
, BGP_FLAG_MED_CONFED
)
379 || aspath_cmp_left (new->attr
->aspath
, exist
->attr
->aspath
)
380 || aspath_cmp_left_confed (new->attr
->aspath
, exist
->attr
->aspath
)
381 || internal_as_route
)
383 new_med
= bgp_med_value (new->attr
, bgp
);
384 exist_med
= bgp_med_value (exist
->attr
, bgp
);
386 if (new_med
< exist_med
)
388 if (new_med
> exist_med
)
392 /* 7. Peer type check. */
393 if (peer_sort (new->peer
) == BGP_PEER_EBGP
394 && peer_sort (exist
->peer
) == BGP_PEER_IBGP
)
396 if (peer_sort (new->peer
) == BGP_PEER_EBGP
397 && peer_sort (exist
->peer
) == BGP_PEER_CONFED
)
399 if (peer_sort (new->peer
) == BGP_PEER_IBGP
400 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
402 if (peer_sort (new->peer
) == BGP_PEER_CONFED
403 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
406 /* 8. IGP metric check. */
407 if (new->igpmetric
< exist
->igpmetric
)
409 if (new->igpmetric
> exist
->igpmetric
)
412 /* 9. Maximum path check. */
414 /* 10. If both paths are external, prefer the path that was received
415 first (the oldest one). This step minimizes route-flap, since a
416 newer path won't displace an older one, even if it was the
417 preferred route based on the additional decision criteria below. */
418 if (! bgp_flag_check (bgp
, BGP_FLAG_COMPARE_ROUTER_ID
)
419 && peer_sort (new->peer
) == BGP_PEER_EBGP
420 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
422 if (CHECK_FLAG (new->flags
, BGP_INFO_SELECTED
))
424 if (CHECK_FLAG (exist
->flags
, BGP_INFO_SELECTED
))
428 /* 11. Rourter-ID comparision. */
429 if (new->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
430 new_id
.s_addr
= new->attr
->originator_id
.s_addr
;
432 new_id
.s_addr
= new->peer
->remote_id
.s_addr
;
433 if (exist
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
434 exist_id
.s_addr
= exist
->attr
->originator_id
.s_addr
;
436 exist_id
.s_addr
= exist
->peer
->remote_id
.s_addr
;
438 if (ntohl (new_id
.s_addr
) < ntohl (exist_id
.s_addr
))
440 if (ntohl (new_id
.s_addr
) > ntohl (exist_id
.s_addr
))
443 /* 12. Cluster length comparision. */
444 if (new->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
445 new_cluster
= new->attr
->cluster
->length
;
448 if (exist
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
449 exist_cluster
= exist
->attr
->cluster
->length
;
453 if (new_cluster
< exist_cluster
)
455 if (new_cluster
> exist_cluster
)
458 /* 13. Neighbor address comparision. */
459 ret
= sockunion_cmp (new->peer
->su_remote
, exist
->peer
->su_remote
);
469 static enum filter_type
470 bgp_input_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
471 afi_t afi
, safi_t safi
)
473 struct bgp_filter
*filter
;
475 filter
= &peer
->filter
[afi
][safi
];
477 if (DISTRIBUTE_IN_NAME (filter
))
478 if (access_list_apply (DISTRIBUTE_IN (filter
), p
) == FILTER_DENY
)
481 if (PREFIX_LIST_IN_NAME (filter
))
482 if (prefix_list_apply (PREFIX_LIST_IN (filter
), p
) == PREFIX_DENY
)
485 if (FILTER_LIST_IN_NAME (filter
))
486 if (as_list_apply (FILTER_LIST_IN (filter
), attr
->aspath
)== AS_FILTER_DENY
)
489 return FILTER_PERMIT
;
492 static enum filter_type
493 bgp_output_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
494 afi_t afi
, safi_t safi
)
496 struct bgp_filter
*filter
;
498 filter
= &peer
->filter
[afi
][safi
];
500 if (DISTRIBUTE_OUT_NAME (filter
))
501 if (access_list_apply (DISTRIBUTE_OUT (filter
), p
) == FILTER_DENY
)
504 if (PREFIX_LIST_OUT_NAME (filter
))
505 if (prefix_list_apply (PREFIX_LIST_OUT (filter
), p
) == PREFIX_DENY
)
508 if (FILTER_LIST_OUT_NAME (filter
))
509 if (as_list_apply (FILTER_LIST_OUT (filter
), attr
->aspath
) == AS_FILTER_DENY
)
512 return FILTER_PERMIT
;
515 /* If community attribute includes no_export then return 1. */
517 bgp_community_filter (struct peer
*peer
, struct attr
*attr
)
521 /* NO_ADVERTISE check. */
522 if (community_include (attr
->community
, COMMUNITY_NO_ADVERTISE
))
525 /* NO_EXPORT check. */
526 if (peer_sort (peer
) == BGP_PEER_EBGP
&&
527 community_include (attr
->community
, COMMUNITY_NO_EXPORT
))
530 /* NO_EXPORT_SUBCONFED check. */
531 if (peer_sort (peer
) == BGP_PEER_EBGP
532 || peer_sort (peer
) == BGP_PEER_CONFED
)
533 if (community_include (attr
->community
, COMMUNITY_NO_EXPORT_SUBCONFED
))
539 /* Route reflection loop check. */
541 bgp_cluster_filter (struct peer
*peer
, struct attr
*attr
)
543 struct in_addr cluster_id
;
547 if (peer
->bgp
->config
& BGP_CONFIG_CLUSTER_ID
)
548 cluster_id
= peer
->bgp
->cluster_id
;
550 cluster_id
= peer
->bgp
->router_id
;
552 if (cluster_loop_check (attr
->cluster
, cluster_id
))
559 bgp_input_modifier (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
560 afi_t afi
, safi_t safi
)
562 struct bgp_filter
*filter
;
563 struct bgp_info info
;
564 route_map_result_t ret
;
566 filter
= &peer
->filter
[afi
][safi
];
568 /* Apply default weight value. */
569 attr
->weight
= peer
->weight
;
571 /* Route map apply. */
572 if (ROUTE_MAP_IN_NAME (filter
))
574 /* Duplicate current value to new strucutre for modification. */
578 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IN
);
580 /* Apply BGP route map to the attribute. */
581 ret
= route_map_apply (ROUTE_MAP_IN (filter
), p
, RMAP_BGP
, &info
);
585 if (ret
== RMAP_DENYMATCH
)
587 /* Free newly generated AS path and community by route-map. */
588 bgp_attr_flush (attr
);
596 bgp_export_modifier (struct peer
*rsclient
, struct peer
*peer
,
597 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
599 struct bgp_filter
*filter
;
600 struct bgp_info info
;
601 route_map_result_t ret
;
603 filter
= &peer
->filter
[afi
][safi
];
605 /* Route map apply. */
606 if (ROUTE_MAP_EXPORT_NAME (filter
))
608 /* Duplicate current value to new strucutre for modification. */
609 info
.peer
= rsclient
;
612 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_EXPORT
);
614 /* Apply BGP route map to the attribute. */
615 ret
= route_map_apply (ROUTE_MAP_EXPORT (filter
), p
, RMAP_BGP
, &info
);
617 rsclient
->rmap_type
= 0;
619 if (ret
== RMAP_DENYMATCH
)
621 /* Free newly generated AS path and community by route-map. */
622 bgp_attr_flush (attr
);
630 bgp_import_modifier (struct peer
*rsclient
, struct peer
*peer
,
631 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
633 struct bgp_filter
*filter
;
634 struct bgp_info info
;
635 route_map_result_t ret
;
637 filter
= &rsclient
->filter
[afi
][safi
];
639 /* Apply default weight value. */
640 attr
->weight
= peer
->weight
;
642 /* Route map apply. */
643 if (ROUTE_MAP_IMPORT_NAME (filter
))
645 /* Duplicate current value to new strucutre for modification. */
649 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
);
651 /* Apply BGP route map to the attribute. */
652 ret
= route_map_apply (ROUTE_MAP_IMPORT (filter
), p
, RMAP_BGP
, &info
);
656 if (ret
== RMAP_DENYMATCH
)
658 /* Free newly generated AS path and community by route-map. */
659 bgp_attr_flush (attr
);
667 bgp_announce_check (struct bgp_info
*ri
, struct peer
*peer
, struct prefix
*p
,
668 struct attr
*attr
, afi_t afi
, safi_t safi
)
671 char buf
[SU_ADDRSTRLEN
];
672 struct bgp_filter
*filter
;
679 filter
= &peer
->filter
[afi
][safi
];
682 #ifdef DISABLE_BGP_ANNOUNCE
686 /* Do not send announces to RS-clients from the 'normal' bgp_table. */
687 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
690 /* Do not send back route to sender. */
694 /* If peer's id and route's nexthop are same. draft-ietf-idr-bgp4-23 5.1.3 */
695 if (p
->family
== AF_INET
696 && IPV4_ADDR_SAME(&peer
->remote_id
, &ri
->attr
->nexthop
))
699 if (p
->family
== AF_INET6
700 && IPV6_ADDR_SAME(&peer
->remote_id
, &ri
->attr
->nexthop
))
704 /* Aggregate-address suppress check. */
706 if (! UNSUPPRESS_MAP_NAME (filter
))
709 /* Default route check. */
710 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
))
712 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
)
715 else if (p
->family
== AF_INET6
&& p
->prefixlen
== 0)
717 #endif /* HAVE_IPV6 */
720 /* Transparency check. */
721 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
)
722 && CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
727 /* If community is not disabled check the no-export and local. */
728 if (! transparent
&& bgp_community_filter (peer
, ri
->attr
))
731 /* If the attribute has originator-id and it is same as remote
733 if (ri
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
))
735 if (IPV4_ADDR_SAME (&peer
->remote_id
, &ri
->attr
->originator_id
))
737 if (BGP_DEBUG (filter
, FILTER
))
738 zlog (peer
->log
, LOG_DEBUG
,
739 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
741 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
747 /* ORF prefix-list filter check */
748 if (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_RM_ADV
)
749 && (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_RCV
)
750 || CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)))
751 if (peer
->orf_plist
[afi
][safi
])
753 if (prefix_list_apply (peer
->orf_plist
[afi
][safi
], p
) == PREFIX_DENY
)
757 /* Output filter check. */
758 if (bgp_output_filter (peer
, p
, ri
->attr
, afi
, safi
) == FILTER_DENY
)
760 if (BGP_DEBUG (filter
, FILTER
))
761 zlog (peer
->log
, LOG_DEBUG
,
762 "%s [Update:SEND] %s/%d is filtered",
764 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
769 #ifdef BGP_SEND_ASPATH_CHECK
770 /* AS path loop check. */
771 if (aspath_loop_check (ri
->attr
->aspath
, peer
->as
))
773 if (BGP_DEBUG (filter
, FILTER
))
774 zlog (peer
->log
, LOG_DEBUG
,
775 "%s [Update:SEND] suppress announcement to peer AS %d is AS path.",
776 peer
->host
, peer
->as
);
779 #endif /* BGP_SEND_ASPATH_CHECK */
781 /* If we're a CONFED we need to loop check the CONFED ID too */
782 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
784 if (aspath_loop_check(ri
->attr
->aspath
, bgp
->confed_id
))
786 if (BGP_DEBUG (filter
, FILTER
))
787 zlog (peer
->log
, LOG_DEBUG
,
788 "%s [Update:SEND] suppress announcement to peer AS %d is AS path.",
795 /* Route-Reflect check. */
796 if (peer_sort (from
) == BGP_PEER_IBGP
&& peer_sort (peer
) == BGP_PEER_IBGP
)
801 /* IBGP reflection check. */
804 /* A route from a Client peer. */
805 if (CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
807 /* Reflect to all the Non-Client peers and also to the
808 Client peers other than the originator. Originator check
809 is already done. So there is noting to do. */
810 /* no bgp client-to-client reflection check. */
811 if (bgp_flag_check (bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
812 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
817 /* A route from a Non-client peer. Reflect to all other
819 if (! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
824 /* For modify attribute, copy it to temporary structure. */
827 /* If local-preference is not set. */
828 if ((peer_sort (peer
) == BGP_PEER_IBGP
829 || peer_sort (peer
) == BGP_PEER_CONFED
)
830 && (! (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))))
832 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
);
833 attr
->local_pref
= bgp
->default_local_pref
;
836 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
837 if (peer_sort (peer
) == BGP_PEER_EBGP
838 && attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
840 if (ri
->peer
!= bgp
->peer_self
&& ! transparent
841 && ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
842 attr
->flag
&= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
));
846 if (transparent
|| reflect
847 || (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_UNCHANGED
)
848 && ((p
->family
== AF_INET
&& attr
->nexthop
.s_addr
)
850 || (p
->family
== AF_INET6
&&
851 ! IN6_IS_ADDR_UNSPECIFIED(&attr
->mp_nexthop_global
))
852 #endif /* HAVE_IPV6 */
855 /* NEXT-HOP Unchanged. */
857 else if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
858 || (p
->family
== AF_INET
&& attr
->nexthop
.s_addr
== 0)
860 || (p
->family
== AF_INET6
&&
861 IN6_IS_ADDR_UNSPECIFIED(&attr
->mp_nexthop_global
))
862 #endif /* HAVE_IPV6 */
863 || (peer_sort (peer
) == BGP_PEER_EBGP
864 && bgp_multiaccess_check_v4 (attr
->nexthop
, peer
->host
) == 0))
866 /* Set IPv4 nexthop. */
867 if (p
->family
== AF_INET
)
869 if (safi
== SAFI_MPLS_VPN
)
870 memcpy (&attr
->mp_nexthop_global_in
, &peer
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
872 memcpy (&attr
->nexthop
, &peer
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
875 /* Set IPv6 nexthop. */
876 if (p
->family
== AF_INET6
)
878 /* IPv6 global nexthop must be included. */
879 memcpy (&attr
->mp_nexthop_global
, &peer
->nexthop
.v6_global
,
881 attr
->mp_nexthop_len
= 16;
883 #endif /* HAVE_IPV6 */
887 if (p
->family
== AF_INET6
)
889 /* Left nexthop_local unchanged if so configured. */
890 if ( CHECK_FLAG (peer
->af_flags
[afi
][safi
],
891 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) )
893 if ( IN6_IS_ADDR_LINKLOCAL (&attr
->mp_nexthop_local
) )
894 attr
->mp_nexthop_len
=32;
896 attr
->mp_nexthop_len
=16;
899 /* Default nexthop_local treatment for non-RS-Clients */
902 /* Link-local address should not be transit to different peer. */
903 attr
->mp_nexthop_len
= 16;
905 /* Set link-local address for shared network peer. */
906 if (peer
->shared_network
907 && ! IN6_IS_ADDR_UNSPECIFIED (&peer
->nexthop
.v6_local
))
909 memcpy (&attr
->mp_nexthop_local
, &peer
->nexthop
.v6_local
,
911 attr
->mp_nexthop_len
= 32;
914 /* If bgpd act as BGP-4+ route-reflector, do not send link-local
917 attr
->mp_nexthop_len
= 16;
919 /* If BGP-4+ link-local nexthop is not link-local nexthop. */
920 if (! IN6_IS_ADDR_LINKLOCAL (&peer
->nexthop
.v6_local
))
921 attr
->mp_nexthop_len
= 16;
925 #endif /* HAVE_IPV6 */
927 /* If this is EBGP peer and remove-private-AS is set. */
928 if (peer_sort (peer
) == BGP_PEER_EBGP
929 && peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)
930 && aspath_private_as_check (attr
->aspath
))
931 attr
->aspath
= aspath_empty_get ();
933 /* Route map & unsuppress-map apply. */
934 if (ROUTE_MAP_OUT_NAME (filter
)
937 struct bgp_info info
;
938 struct attr dummy_attr
;
943 /* The route reflector is not allowed to modify the attributes
944 of the reflected IBGP routes. */
945 if (peer_sort (from
) == BGP_PEER_IBGP
946 && peer_sort (peer
) == BGP_PEER_IBGP
)
949 info
.attr
= &dummy_attr
;
952 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
);
955 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
957 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
961 if (ret
== RMAP_DENYMATCH
)
963 bgp_attr_flush (attr
);
971 bgp_announce_check_rsclient (struct bgp_info
*ri
, struct peer
*rsclient
,
972 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
975 char buf
[SU_ADDRSTRLEN
];
976 struct bgp_filter
*filter
;
977 struct bgp_info info
;
982 filter
= &rsclient
->filter
[afi
][safi
];
985 #ifdef DISABLE_BGP_ANNOUNCE
989 /* Do not send back route to sender. */
990 if (from
== rsclient
)
993 /* Aggregate-address suppress check. */
995 if (! UNSUPPRESS_MAP_NAME (filter
))
998 /* Default route check. */
999 if (CHECK_FLAG (rsclient
->af_sflags
[afi
][safi
],
1000 PEER_STATUS_DEFAULT_ORIGINATE
))
1002 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
)
1005 else if (p
->family
== AF_INET6
&& p
->prefixlen
== 0)
1007 #endif /* HAVE_IPV6 */
1010 /* If the attribute has originator-id and it is same as remote
1012 if (ri
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
))
1014 if (IPV4_ADDR_SAME (&rsclient
->remote_id
, &ri
->attr
->originator_id
))
1016 if (BGP_DEBUG (filter
, FILTER
))
1017 zlog (rsclient
->log
, LOG_DEBUG
,
1018 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
1020 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1026 /* ORF prefix-list filter check */
1027 if (CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_RM_ADV
)
1028 && (CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_RCV
)
1029 || CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)))
1030 if (rsclient
->orf_plist
[afi
][safi
])
1032 if (prefix_list_apply (rsclient
->orf_plist
[afi
][safi
], p
) == PREFIX_DENY
)
1036 /* Output filter check. */
1037 if (bgp_output_filter (rsclient
, p
, ri
->attr
, afi
, safi
) == FILTER_DENY
)
1039 if (BGP_DEBUG (filter
, FILTER
))
1040 zlog (rsclient
->log
, LOG_DEBUG
,
1041 "%s [Update:SEND] %s/%d is filtered",
1043 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1048 #ifdef BGP_SEND_ASPATH_CHECK
1049 /* AS path loop check. */
1050 if (aspath_loop_check (ri
->attr
->aspath
, rsclient
->as
))
1052 if (BGP_DEBUG (filter
, FILTER
))
1053 zlog (rsclient
->log
, LOG_DEBUG
,
1054 "%s [Update:SEND] suppress announcement to peer AS %d is AS path.",
1055 rsclient
->host
, rsclient
->as
);
1058 #endif /* BGP_SEND_ASPATH_CHECK */
1060 /* For modify attribute, copy it to temporary structure. */
1064 if ((p
->family
== AF_INET
&& attr
->nexthop
.s_addr
== 0)
1066 || (p
->family
== AF_INET6
&&
1067 IN6_IS_ADDR_UNSPECIFIED(&attr
->mp_nexthop_global
))
1068 #endif /* HAVE_IPV6 */
1071 /* Set IPv4 nexthop. */
1072 if (p
->family
== AF_INET
)
1074 if (safi
== SAFI_MPLS_VPN
)
1075 memcpy (&attr
->mp_nexthop_global_in
, &rsclient
->nexthop
.v4
,
1078 memcpy (&attr
->nexthop
, &rsclient
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
1081 /* Set IPv6 nexthop. */
1082 if (p
->family
== AF_INET6
)
1084 /* IPv6 global nexthop must be included. */
1085 memcpy (&attr
->mp_nexthop_global
, &rsclient
->nexthop
.v6_global
,
1088 attr
->mp_nexthop_len
= 16;
1090 #endif /* HAVE_IPV6 */
1094 if (p
->family
== AF_INET6
)
1096 /* Left nexthop_local unchanged if so configured. */
1097 if ( CHECK_FLAG (rsclient
->af_flags
[afi
][safi
],
1098 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) )
1100 if ( IN6_IS_ADDR_LINKLOCAL (&attr
->mp_nexthop_local
) )
1101 attr
->mp_nexthop_len
=32;
1103 attr
->mp_nexthop_len
=16;
1106 /* Default nexthop_local treatment for RS-Clients */
1109 /* Announcer and RS-Client are both in the same network */
1110 if (rsclient
->shared_network
&& from
->shared_network
&&
1111 (rsclient
->ifindex
== from
->ifindex
))
1113 if ( IN6_IS_ADDR_LINKLOCAL (&attr
->mp_nexthop_local
) )
1114 attr
->mp_nexthop_len
=32;
1116 attr
->mp_nexthop_len
=16;
1119 /* Set link-local address for shared network peer. */
1120 else if (rsclient
->shared_network
1121 && IN6_IS_ADDR_LINKLOCAL (&rsclient
->nexthop
.v6_local
))
1123 memcpy (&attr
->mp_nexthop_local
, &rsclient
->nexthop
.v6_local
,
1125 attr
->mp_nexthop_len
= 32;
1129 attr
->mp_nexthop_len
= 16;
1133 #endif /* HAVE_IPV6 */
1136 /* If this is EBGP peer and remove-private-AS is set. */
1137 if (peer_sort (rsclient
) == BGP_PEER_EBGP
1138 && peer_af_flag_check (rsclient
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)
1139 && aspath_private_as_check (attr
->aspath
))
1140 attr
->aspath
= aspath_empty_get ();
1142 /* Route map & unsuppress-map apply. */
1143 if (ROUTE_MAP_OUT_NAME (filter
) || ri
->suppress
)
1145 info
.peer
= rsclient
;
1148 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1151 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
1153 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
1155 rsclient
->rmap_type
= 0;
1157 if (ret
== RMAP_DENYMATCH
)
1159 bgp_attr_flush (attr
);
1167 struct bgp_info_pair
1169 struct bgp_info
*old
;
1170 struct bgp_info
*new;
1174 bgp_best_selection (struct bgp
*bgp
, struct bgp_node
*rn
, struct bgp_info_pair
*result
)
1176 struct bgp_info
*new_select
;
1177 struct bgp_info
*old_select
;
1178 struct bgp_info
*ri
;
1179 struct bgp_info
*ri1
;
1180 struct bgp_info
*ri2
;
1181 struct bgp_info
*nextri
= NULL
;
1183 /* bgp deterministic-med */
1185 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
))
1186 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1188 if (CHECK_FLAG (ri1
->flags
, BGP_INFO_DMED_CHECK
))
1190 if (BGP_INFO_HOLDDOWN (ri1
))
1195 for (ri2
= ri1
->next
; ri2
; ri2
= ri2
->next
)
1197 if (CHECK_FLAG (ri2
->flags
, BGP_INFO_DMED_CHECK
))
1199 if (BGP_INFO_HOLDDOWN (ri2
))
1202 if (aspath_cmp_left (ri1
->attr
->aspath
, ri2
->attr
->aspath
)
1203 || aspath_cmp_left_confed (ri1
->attr
->aspath
,
1206 if (bgp_info_cmp (bgp
, ri2
, new_select
))
1208 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1212 bgp_info_set_flag (rn
, ri2
, BGP_INFO_DMED_CHECK
);
1215 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_CHECK
);
1216 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1219 /* Check old selected route and new selected route. */
1222 for (ri
= rn
->info
; (ri
!= NULL
) && (nextri
= ri
->next
, 1); ri
= nextri
)
1224 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1227 if (BGP_INFO_HOLDDOWN (ri
))
1229 /* reap REMOVED routes, if needs be
1230 * selected route must stay for a while longer though
1232 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
1233 && (ri
!= old_select
))
1234 bgp_info_reap (rn
, ri
);
1239 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
)
1240 && (! CHECK_FLAG (ri
->flags
, BGP_INFO_DMED_SELECTED
)))
1242 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1245 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1246 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_SELECTED
);
1248 if (bgp_info_cmp (bgp
, ri
, new_select
))
1252 result
->old
= old_select
;
1253 result
->new = new_select
;
1259 bgp_process_announce_selected (struct peer
*peer
, struct bgp_info
*selected
,
1260 struct bgp_node
*rn
, struct attr
*attr
, afi_t afi
, safi_t safi
)
1266 /* Announce route to Established peer. */
1267 if (peer
->status
!= Established
)
1270 /* Address family configuration check. */
1271 if (! peer
->afc_nego
[afi
][safi
])
1274 /* First update is deferred until ORF or ROUTE-REFRESH is received */
1275 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
],
1276 PEER_STATUS_ORF_WAIT_REFRESH
))
1279 switch (rn
->table
->type
)
1281 case BGP_TABLE_MAIN
:
1282 /* Announcement to peer->conf. If the route is filtered,
1284 if (selected
&& bgp_announce_check (selected
, peer
, p
, attr
, afi
, safi
))
1285 bgp_adj_out_set (rn
, peer
, p
, attr
, afi
, safi
, selected
);
1287 bgp_adj_out_unset (rn
, peer
, p
, afi
, safi
);
1289 case BGP_TABLE_RSCLIENT
:
1290 /* Announcement to peer->conf. If the route is filtered,
1292 if (selected
&& bgp_announce_check_rsclient
1293 (selected
, peer
, p
, attr
, afi
, safi
))
1294 bgp_adj_out_set (rn
, peer
, p
, attr
, afi
, safi
, selected
);
1296 bgp_adj_out_unset (rn
, peer
, p
, afi
, safi
);
1302 struct bgp_process_queue
1305 struct bgp_node
*rn
;
1310 static wq_item_status
1311 bgp_process_rsclient (struct work_queue
*wq
, void *data
)
1313 struct bgp_process_queue
*pq
= data
;
1314 struct bgp
*bgp
= pq
->bgp
;
1315 struct bgp_node
*rn
= pq
->rn
;
1316 afi_t afi
= pq
->afi
;
1317 safi_t safi
= pq
->safi
;
1318 struct bgp_info
*new_select
;
1319 struct bgp_info
*old_select
;
1320 struct bgp_info_pair old_and_new
;
1322 struct listnode
*node
, *nnode
;
1323 struct peer
*rsclient
= rn
->table
->owner
;
1325 /* Best path selection. */
1326 bgp_best_selection (bgp
, rn
, &old_and_new
);
1327 new_select
= old_and_new
.new;
1328 old_select
= old_and_new
.old
;
1330 if (CHECK_FLAG (rsclient
->sflags
, PEER_STATUS_GROUP
))
1332 for (ALL_LIST_ELEMENTS (rsclient
->group
->peer
, node
, nnode
, rsclient
))
1334 /* Nothing to do. */
1335 if (old_select
&& old_select
== new_select
)
1336 if (!CHECK_FLAG (old_select
->flags
, BGP_INFO_ATTR_CHANGED
))
1340 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1343 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1344 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1347 bgp_process_announce_selected (rsclient
, new_select
, rn
, &attr
,
1354 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1357 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1358 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1360 bgp_process_announce_selected (rsclient
, new_select
, rn
,
1364 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
1365 bgp_info_reap (rn
, old_select
);
1367 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1371 static wq_item_status
1372 bgp_process_main (struct work_queue
*wq
, void *data
)
1374 struct bgp_process_queue
*pq
= data
;
1375 struct bgp
*bgp
= pq
->bgp
;
1376 struct bgp_node
*rn
= pq
->rn
;
1377 afi_t afi
= pq
->afi
;
1378 safi_t safi
= pq
->safi
;
1379 struct prefix
*p
= &rn
->p
;
1380 struct bgp_info
*new_select
;
1381 struct bgp_info
*old_select
;
1382 struct bgp_info_pair old_and_new
;
1383 struct listnode
*node
, *nnode
;
1387 /* Best path selection. */
1388 bgp_best_selection (bgp
, rn
, &old_and_new
);
1389 old_select
= old_and_new
.old
;
1390 new_select
= old_and_new
.new;
1392 /* Nothing to do. */
1393 if (old_select
&& old_select
== new_select
)
1395 if (! CHECK_FLAG (old_select
->flags
, BGP_INFO_ATTR_CHANGED
))
1397 if (CHECK_FLAG (old_select
->flags
, BGP_INFO_IGP_CHANGED
))
1398 bgp_zebra_announce (p
, old_select
, bgp
);
1400 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1406 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1409 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1410 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1414 /* Check each BGP peer. */
1415 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
1417 bgp_process_announce_selected (peer
, new_select
, rn
, &attr
, afi
, safi
);
1421 if (safi
== SAFI_UNICAST
&& ! bgp
->name
&&
1422 ! bgp_option_check (BGP_OPT_NO_FIB
))
1425 && new_select
->type
== ZEBRA_ROUTE_BGP
1426 && new_select
->sub_type
== BGP_ROUTE_NORMAL
)
1427 bgp_zebra_announce (p
, new_select
, bgp
);
1430 /* Withdraw the route from the kernel. */
1432 && old_select
->type
== ZEBRA_ROUTE_BGP
1433 && old_select
->sub_type
== BGP_ROUTE_NORMAL
)
1434 bgp_zebra_withdraw (p
, old_select
);
1438 /* Reap old select bgp_info, it it has been removed */
1439 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
1440 bgp_info_reap (rn
, old_select
);
1442 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1447 bgp_processq_del (struct work_queue
*wq
, void *data
)
1449 struct bgp_process_queue
*pq
= data
;
1451 bgp_unlock_node (pq
->rn
);
1452 XFREE (MTYPE_BGP_PROCESS_QUEUE
, pq
);
1456 bgp_process_queue_init (void)
1458 bm
->process_main_queue
1459 = work_queue_new (bm
->master
, "process_main_queue");
1460 bm
->process_rsclient_queue
1461 = work_queue_new (bm
->master
, "process_rsclient_queue");
1463 if ( !(bm
->process_main_queue
&& bm
->process_rsclient_queue
) )
1465 zlog_err ("%s: Failed to allocate work queue", __func__
);
1469 bm
->process_main_queue
->spec
.workfunc
= &bgp_process_main
;
1470 bm
->process_rsclient_queue
->spec
.workfunc
= &bgp_process_rsclient
;
1471 bm
->process_main_queue
->spec
.del_item_data
= &bgp_processq_del
;
1472 bm
->process_rsclient_queue
->spec
.del_item_data
1473 = bm
->process_main_queue
->spec
.del_item_data
;
1474 bm
->process_main_queue
->spec
.max_retries
1475 = bm
->process_main_queue
->spec
.max_retries
= 0;
1476 bm
->process_rsclient_queue
->spec
.hold
1477 = bm
->process_main_queue
->spec
.hold
= 500;
1481 bgp_process (struct bgp
*bgp
, struct bgp_node
*rn
, afi_t afi
, safi_t safi
)
1483 struct bgp_process_queue
*pqnode
;
1485 /* already scheduled for processing? */
1486 if (CHECK_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
))
1489 if ( (bm
->process_main_queue
== NULL
) ||
1490 (bm
->process_rsclient_queue
== NULL
) )
1491 bgp_process_queue_init ();
1493 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
1494 sizeof (struct bgp_process_queue
));
1498 pqnode
->rn
= bgp_lock_node (rn
); /* unlocked by bgp_processq_del */
1501 pqnode
->safi
= safi
;
1503 switch (rn
->table
->type
)
1505 case BGP_TABLE_MAIN
:
1506 work_queue_add (bm
->process_main_queue
, pqnode
);
1508 case BGP_TABLE_RSCLIENT
:
1509 work_queue_add (bm
->process_rsclient_queue
, pqnode
);
1517 bgp_maximum_prefix_restart_timer (struct thread
*thread
)
1521 peer
= THREAD_ARG (thread
);
1522 peer
->t_pmax_restart
= NULL
;
1524 if (BGP_DEBUG (events
, EVENTS
))
1525 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
1534 bgp_maximum_prefix_overflow (struct peer
*peer
, afi_t afi
,
1535 safi_t safi
, int always
)
1537 if (!CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
))
1540 if (peer
->pcount
[afi
][safi
] > peer
->pmax
[afi
][safi
])
1542 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
)
1546 zlog (peer
->log
, LOG_INFO
,
1547 "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
1548 "limit %ld", afi_safi_print (afi
, safi
), peer
->host
,
1549 peer
->pcount
[afi
][safi
], peer
->pmax
[afi
][safi
]);
1550 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
1552 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_WARNING
))
1558 if (safi
== SAFI_MPLS_VPN
)
1559 safi
= BGP_SAFI_VPNV4
;
1561 ndata
[0] = (afi
>> 8);
1564 ndata
[3] = (peer
->pmax
[afi
][safi
] >> 24);
1565 ndata
[4] = (peer
->pmax
[afi
][safi
] >> 16);
1566 ndata
[5] = (peer
->pmax
[afi
][safi
] >> 8);
1567 ndata
[6] = (peer
->pmax
[afi
][safi
]);
1569 SET_FLAG (peer
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
);
1570 bgp_notify_send_with_data (peer
, BGP_NOTIFY_CEASE
,
1571 BGP_NOTIFY_CEASE_MAX_PREFIX
, ndata
, 7);
1574 /* restart timer start */
1575 if (peer
->pmax_restart
[afi
][safi
])
1577 peer
->v_pmax_restart
= peer
->pmax_restart
[afi
][safi
] * 60;
1579 if (BGP_DEBUG (events
, EVENTS
))
1580 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
1581 peer
->host
, peer
->v_pmax_restart
);
1583 BGP_TIMER_ON (peer
->t_pmax_restart
, bgp_maximum_prefix_restart_timer
,
1584 peer
->v_pmax_restart
);
1590 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
1592 if (peer
->pcount
[afi
][safi
] > (peer
->pmax
[afi
][safi
] * peer
->pmax_threshold
[afi
][safi
] / 100))
1594 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
)
1598 zlog (peer
->log
, LOG_INFO
,
1599 "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
1600 afi_safi_print (afi
, safi
), peer
->host
, peer
->pcount
[afi
][safi
],
1601 peer
->pmax
[afi
][safi
]);
1602 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
1605 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
1609 /* Unconditionally remove the route from the RIB, without taking
1610 * damping into consideration (eg, because the session went down)
1613 bgp_rib_remove (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
1614 afi_t afi
, safi_t safi
)
1616 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
1618 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
1619 bgp_info_delete (rn
, ri
); /* keep historical info */
1621 bgp_process (peer
->bgp
, rn
, afi
, safi
);
1625 bgp_rib_withdraw (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
1626 afi_t afi
, safi_t safi
)
1628 int status
= BGP_DAMP_NONE
;
1630 /* apply dampening, if result is suppressed, we'll be retaining
1631 * the bgp_info in the RIB for historical reference.
1633 if (CHECK_FLAG (peer
->bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
1634 && peer_sort (peer
) == BGP_PEER_EBGP
)
1635 if ( (status
= bgp_damp_withdraw (ri
, rn
, afi
, safi
, 0))
1636 == BGP_DAMP_SUPPRESSED
)
1638 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
1642 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
1646 bgp_update_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
,
1647 struct attr
*attr
, struct peer
*peer
, struct prefix
*p
, int type
,
1648 int sub_type
, struct prefix_rd
*prd
, u_char
*tag
)
1650 struct bgp_node
*rn
;
1652 struct attr new_attr
;
1653 struct attr
*attr_new
;
1654 struct attr
*attr_new2
;
1655 struct bgp_info
*ri
;
1656 struct bgp_info
*new;
1658 char buf
[SU_ADDRSTRLEN
];
1660 /* Do not insert announces from a rsclient into its own 'bgp_table'. */
1661 if (peer
== rsclient
)
1665 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
1667 /* Check previously received route. */
1668 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1669 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
1672 /* AS path loop check. */
1673 if (aspath_loop_check (attr
->aspath
, rsclient
->as
) > peer
->allowas_in
[afi
][safi
])
1675 reason
= "as-path contains our own AS;";
1679 /* Route reflector originator ID check. */
1680 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
1681 && IPV4_ADDR_SAME (&rsclient
->remote_id
, &attr
->originator_id
))
1683 reason
= "originator is us;";
1689 /* Apply export policy. */
1690 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
) &&
1691 bgp_export_modifier (rsclient
, peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
1693 reason
= "export-policy;";
1697 attr_new2
= bgp_attr_intern (&new_attr
);
1699 /* Apply import policy. */
1700 if (bgp_import_modifier (rsclient
, peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
1702 bgp_attr_unintern (attr_new2
);
1704 reason
= "import-policy;";
1708 attr_new
= bgp_attr_intern (&new_attr
);
1709 bgp_attr_unintern (attr_new2
);
1711 /* IPv4 unicast next hop check. */
1712 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
1714 /* Next hop must not be 0.0.0.0 nor Class E address. */
1715 if (new_attr
.nexthop
.s_addr
== 0
1716 || ntohl (new_attr
.nexthop
.s_addr
) >= 0xe0000000)
1718 bgp_attr_unintern (attr_new
);
1720 reason
= "martian next-hop;";
1725 /* If the update is implicit withdraw. */
1728 ri
->uptime
= time (NULL
);
1730 /* Same attribute comes in. */
1731 if (attrhash_cmp (ri
->attr
, attr_new
))
1734 bgp_info_unset_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
1736 if (BGP_DEBUG (update
, UPDATE_IN
))
1737 zlog (peer
->log
, LOG_DEBUG
,
1738 "%s rcvd %s/%d for RS-client %s...duplicate ignored",
1740 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1741 p
->prefixlen
, rsclient
->host
);
1743 bgp_unlock_node (rn
);
1744 bgp_attr_unintern (attr_new
);
1749 /* Received Logging. */
1750 if (BGP_DEBUG (update
, UPDATE_IN
))
1751 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d for RS-client %s",
1753 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1754 p
->prefixlen
, rsclient
->host
);
1756 /* The attribute is changed. */
1757 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
1759 /* Update to new attribute. */
1760 bgp_attr_unintern (ri
->attr
);
1761 ri
->attr
= attr_new
;
1763 /* Update MPLS tag. */
1764 if (safi
== SAFI_MPLS_VPN
)
1765 memcpy (ri
->tag
, tag
, 3);
1767 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
1769 /* Process change. */
1770 bgp_process (bgp
, rn
, afi
, safi
);
1771 bgp_unlock_node (rn
);
1776 /* Received Logging. */
1777 if (BGP_DEBUG (update
, UPDATE_IN
))
1779 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d for RS-client %s",
1781 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1782 p
->prefixlen
, rsclient
->host
);
1785 /* Make new BGP info. */
1786 new = bgp_info_new ();
1788 new->sub_type
= sub_type
;
1790 new->attr
= attr_new
;
1791 new->uptime
= time (NULL
);
1793 /* Update MPLS tag. */
1794 if (safi
== SAFI_MPLS_VPN
)
1795 memcpy (new->tag
, tag
, 3);
1797 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
1799 /* Register new BGP information. */
1800 bgp_info_add (rn
, new);
1802 /* route_node_get lock */
1803 bgp_unlock_node (rn
);
1805 /* Process change. */
1806 bgp_process (bgp
, rn
, afi
, safi
);
1812 /* This BGP update is filtered. Log the reason then update BGP entry. */
1813 if (BGP_DEBUG (update
, UPDATE_IN
))
1814 zlog (peer
->log
, LOG_DEBUG
,
1815 "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s",
1817 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1818 p
->prefixlen
, rsclient
->host
, reason
);
1821 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
1823 bgp_unlock_node (rn
);
1829 bgp_withdraw_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
,
1830 struct peer
*peer
, struct prefix
*p
, int type
, int sub_type
,
1831 struct prefix_rd
*prd
, u_char
*tag
)
1833 struct bgp_node
*rn
;
1834 struct bgp_info
*ri
;
1835 char buf
[SU_ADDRSTRLEN
];
1837 if (rsclient
== peer
)
1840 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
1842 /* Lookup withdrawn route. */
1843 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1844 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
1847 /* Withdraw specified route from routing table. */
1848 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
1849 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
1850 else if (BGP_DEBUG (update
, UPDATE_IN
))
1851 zlog (peer
->log
, LOG_DEBUG
,
1852 "%s Can't find the route %s/%d", peer
->host
,
1853 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1856 /* Unlock bgp_node_get() lock. */
1857 bgp_unlock_node (rn
);
1861 bgp_update_main (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
1862 afi_t afi
, safi_t safi
, int type
, int sub_type
,
1863 struct prefix_rd
*prd
, u_char
*tag
, int soft_reconfig
)
1866 int aspath_loop_count
= 0;
1867 struct bgp_node
*rn
;
1869 struct attr new_attr
;
1870 struct attr
*attr_new
;
1871 struct bgp_info
*ri
;
1872 struct bgp_info
*new;
1874 char buf
[SU_ADDRSTRLEN
];
1877 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
1879 /* When peer's soft reconfiguration enabled. Record input packet in
1881 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
1882 && peer
!= bgp
->peer_self
&& ! soft_reconfig
)
1883 bgp_adj_in_set (rn
, peer
, attr
);
1885 /* Check previously received route. */
1886 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1887 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
1890 /* AS path local-as loop check. */
1891 if (peer
->change_local_as
)
1893 if (! CHECK_FLAG (peer
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
1894 aspath_loop_count
= 1;
1896 if (aspath_loop_check (attr
->aspath
, peer
->change_local_as
) > aspath_loop_count
)
1898 reason
= "as-path contains our own AS;";
1903 /* AS path loop check. */
1904 if (aspath_loop_check (attr
->aspath
, bgp
->as
) > peer
->allowas_in
[afi
][safi
]
1905 || (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
1906 && aspath_loop_check(attr
->aspath
, bgp
->confed_id
)
1907 > peer
->allowas_in
[afi
][safi
]))
1909 reason
= "as-path contains our own AS;";
1913 /* Route reflector originator ID check. */
1914 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
1915 && IPV4_ADDR_SAME (&bgp
->router_id
, &attr
->originator_id
))
1917 reason
= "originator is us;";
1921 /* Route reflector cluster ID check. */
1922 if (bgp_cluster_filter (peer
, attr
))
1924 reason
= "reflected from the same cluster;";
1928 /* Apply incoming filter. */
1929 if (bgp_input_filter (peer
, p
, attr
, afi
, safi
) == FILTER_DENY
)
1935 /* Apply incoming route-map. */
1938 if (bgp_input_modifier (peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
1940 reason
= "route-map;";
1944 /* IPv4 unicast next hop check. */
1945 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
1947 /* If the peer is EBGP and nexthop is not on connected route,
1949 if (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
== 1
1950 && ! bgp_nexthop_check_ebgp (afi
, &new_attr
)
1951 && ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
1953 reason
= "non-connected next-hop;";
1957 /* Next hop must not be 0.0.0.0 nor Class E address. Next hop
1958 must not be my own address. */
1959 if (bgp_nexthop_self (afi
, &new_attr
)
1960 || new_attr
.nexthop
.s_addr
== 0
1961 || ntohl (new_attr
.nexthop
.s_addr
) >= 0xe0000000)
1963 reason
= "martian next-hop;";
1968 attr_new
= bgp_attr_intern (&new_attr
);
1970 /* If the update is implicit withdraw. */
1973 ri
->uptime
= time (NULL
);
1975 /* Same attribute comes in. */
1976 if (attrhash_cmp (ri
->attr
, attr_new
))
1978 bgp_info_unset_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
1980 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
1981 && peer_sort (peer
) == BGP_PEER_EBGP
1982 && CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
1984 if (BGP_DEBUG (update
, UPDATE_IN
))
1985 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
1987 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1990 if (bgp_damp_update (ri
, rn
, afi
, safi
) != BGP_DAMP_SUPPRESSED
)
1992 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
1993 bgp_process (bgp
, rn
, afi
, safi
);
1998 if (BGP_DEBUG (update
, UPDATE_IN
))
1999 zlog (peer
->log
, LOG_DEBUG
,
2000 "%s rcvd %s/%d...duplicate ignored",
2002 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2005 /* graceful restart STALE flag unset. */
2006 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2008 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2009 bgp_process (bgp
, rn
, afi
, safi
);
2013 bgp_unlock_node (rn
);
2014 bgp_attr_unintern (attr_new
);
2018 /* Received Logging. */
2019 if (BGP_DEBUG (update
, UPDATE_IN
))
2020 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2022 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2025 /* graceful restart STALE flag unset. */
2026 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2027 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2029 /* The attribute is changed. */
2030 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2032 /* implicit withdraw, decrement aggregate and pcount here.
2033 * only if update is accepted, they'll increment below.
2035 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
2037 /* Update bgp route dampening information. */
2038 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2039 && peer_sort (peer
) == BGP_PEER_EBGP
)
2041 /* This is implicit withdraw so we should update dampening
2043 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2044 bgp_damp_withdraw (ri
, rn
, afi
, safi
, 1);
2047 /* Update to new attribute. */
2048 bgp_attr_unintern (ri
->attr
);
2049 ri
->attr
= attr_new
;
2051 /* Update MPLS tag. */
2052 if (safi
== SAFI_MPLS_VPN
)
2053 memcpy (ri
->tag
, tag
, 3);
2055 /* Update bgp route dampening information. */
2056 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2057 && peer_sort (peer
) == BGP_PEER_EBGP
)
2059 /* Now we do normal update dampening. */
2060 ret
= bgp_damp_update (ri
, rn
, afi
, safi
);
2061 if (ret
== BGP_DAMP_SUPPRESSED
)
2063 bgp_unlock_node (rn
);
2068 /* Nexthop reachability check. */
2069 if ((afi
== AFI_IP
|| afi
== AFI_IP6
)
2070 && safi
== SAFI_UNICAST
2071 && (peer_sort (peer
) == BGP_PEER_IBGP
2072 || (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)
2073 || CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)))
2075 if (bgp_nexthop_lookup (afi
, peer
, ri
, NULL
, NULL
))
2076 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2078 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
2081 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2083 /* Process change. */
2084 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2086 bgp_process (bgp
, rn
, afi
, safi
);
2087 bgp_unlock_node (rn
);
2091 /* Received Logging. */
2092 if (BGP_DEBUG (update
, UPDATE_IN
))
2094 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2096 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2100 /* Make new BGP info. */
2101 new = bgp_info_new ();
2103 new->sub_type
= sub_type
;
2105 new->attr
= attr_new
;
2106 new->uptime
= time (NULL
);
2108 /* Update MPLS tag. */
2109 if (safi
== SAFI_MPLS_VPN
)
2110 memcpy (new->tag
, tag
, 3);
2112 /* Nexthop reachability check. */
2113 if ((afi
== AFI_IP
|| afi
== AFI_IP6
)
2114 && safi
== SAFI_UNICAST
2115 && (peer_sort (peer
) == BGP_PEER_IBGP
2116 || (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)
2117 || CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)))
2119 if (bgp_nexthop_lookup (afi
, peer
, new, NULL
, NULL
))
2120 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2122 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
2125 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2127 /* Increment prefix */
2128 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
2130 /* Register new BGP information. */
2131 bgp_info_add (rn
, new);
2133 /* route_node_get lock */
2134 bgp_unlock_node (rn
);
2136 /* If maximum prefix count is configured and current prefix
2138 if (bgp_maximum_prefix_overflow (peer
, afi
, safi
, 0))
2141 /* Process change. */
2142 bgp_process (bgp
, rn
, afi
, safi
);
2146 /* This BGP update is filtered. Log the reason then update BGP
2149 if (BGP_DEBUG (update
, UPDATE_IN
))
2150 zlog (peer
->log
, LOG_DEBUG
,
2151 "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
2153 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2154 p
->prefixlen
, reason
);
2157 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2159 bgp_unlock_node (rn
);
2165 bgp_update (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
2166 afi_t afi
, safi_t safi
, int type
, int sub_type
,
2167 struct prefix_rd
*prd
, u_char
*tag
, int soft_reconfig
)
2169 struct peer
*rsclient
;
2170 struct listnode
*node
, *nnode
;
2174 ret
= bgp_update_main (peer
, p
, attr
, afi
, safi
, type
, sub_type
, prd
, tag
,
2179 /* Process the update for each RS-client. */
2180 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
2182 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2183 bgp_update_rsclient (rsclient
, afi
, safi
, attr
, peer
, p
, type
,
2184 sub_type
, prd
, tag
);
2191 bgp_withdraw (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
2192 afi_t afi
, safi_t safi
, int type
, int sub_type
,
2193 struct prefix_rd
*prd
, u_char
*tag
)
2196 char buf
[SU_ADDRSTRLEN
];
2197 struct bgp_node
*rn
;
2198 struct bgp_info
*ri
;
2199 struct peer
*rsclient
;
2200 struct listnode
*node
, *nnode
;
2204 /* Process the withdraw for each RS-client. */
2205 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
2207 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2208 bgp_withdraw_rsclient (rsclient
, afi
, safi
, peer
, p
, type
, sub_type
, prd
, tag
);
2212 if (BGP_DEBUG (update
, UPDATE_IN
))
2213 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd UPDATE about %s/%d -- withdrawn",
2215 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2219 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2221 /* If peer is soft reconfiguration enabled. Record input packet for
2222 further calculation. */
2223 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2224 && peer
!= bgp
->peer_self
)
2225 bgp_adj_in_unset (rn
, peer
);
2227 /* Lookup withdrawn route. */
2228 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2229 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
2232 /* Withdraw specified route from routing table. */
2233 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2234 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
2235 else if (BGP_DEBUG (update
, UPDATE_IN
))
2236 zlog (peer
->log
, LOG_DEBUG
,
2237 "%s Can't find the route %s/%d", peer
->host
,
2238 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2241 /* Unlock bgp_node_get() lock. */
2242 bgp_unlock_node (rn
);
2248 bgp_default_originate (struct peer
*peer
, afi_t afi
, safi_t safi
, int withdraw
)
2252 struct aspath
*aspath
;
2254 struct bgp_info binfo
;
2256 int ret
= RMAP_DENYMATCH
;
2259 from
= bgp
->peer_self
;
2261 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
2262 aspath
= attr
.aspath
;
2263 attr
.local_pref
= bgp
->default_local_pref
;
2264 memcpy (&attr
.nexthop
, &peer
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
2267 str2prefix ("0.0.0.0/0", &p
);
2269 else if (afi
== AFI_IP6
)
2271 str2prefix ("::/0", &p
);
2273 /* IPv6 global nexthop must be included. */
2274 memcpy (&attr
.mp_nexthop_global
, &peer
->nexthop
.v6_global
,
2276 attr
.mp_nexthop_len
= 16;
2278 /* If the peer is on shared nextwork and we have link-local
2280 if (peer
->shared_network
2281 && !IN6_IS_ADDR_UNSPECIFIED (&peer
->nexthop
.v6_local
))
2283 memcpy (&attr
.mp_nexthop_local
, &peer
->nexthop
.v6_local
,
2285 attr
.mp_nexthop_len
= 32;
2288 #endif /* HAVE_IPV6 */
2292 if (peer
->default_rmap
[afi
][safi
].name
)
2294 binfo
.peer
= bgp
->peer_self
;
2297 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_DEFAULT
);
2299 ret
= route_map_apply (peer
->default_rmap
[afi
][safi
].map
, &p
,
2302 bgp
->peer_self
->rmap_type
= 0;
2304 if (ret
== RMAP_DENYMATCH
)
2306 bgp_attr_flush (&attr
);
2313 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
))
2314 bgp_default_withdraw_send (peer
, afi
, safi
);
2315 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
);
2319 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
);
2320 bgp_default_update_send (peer
, &attr
, afi
, safi
, from
);
2323 aspath_unintern (aspath
);
2327 bgp_announce_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2328 struct bgp_table
*table
, int rsclient
)
2330 struct bgp_node
*rn
;
2331 struct bgp_info
*ri
;
2335 table
= (rsclient
) ? peer
->rib
[afi
][safi
] : peer
->bgp
->rib
[afi
][safi
];
2337 if (safi
!= SAFI_MPLS_VPN
2338 && CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_DEFAULT_ORIGINATE
))
2339 bgp_default_originate (peer
, afi
, safi
, 0);
2341 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next(rn
))
2342 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2343 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
) && ri
->peer
!= peer
)
2346 (bgp_announce_check_rsclient (ri
, peer
, &rn
->p
, &attr
, afi
, safi
))
2347 : (bgp_announce_check (ri
, peer
, &rn
->p
, &attr
, afi
, safi
)))
2348 bgp_adj_out_set (rn
, peer
, &rn
->p
, &attr
, afi
, safi
, ri
);
2350 bgp_adj_out_unset (rn
, peer
, &rn
->p
, afi
, safi
);
2355 bgp_announce_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2357 struct bgp_node
*rn
;
2358 struct bgp_table
*table
;
2360 if (peer
->status
!= Established
)
2363 if (! peer
->afc_nego
[afi
][safi
])
2366 /* First update is deferred until ORF or ROUTE-REFRESH is received */
2367 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_ORF_WAIT_REFRESH
))
2370 if (safi
!= SAFI_MPLS_VPN
)
2371 bgp_announce_table (peer
, afi
, safi
, NULL
, 0);
2373 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2374 rn
= bgp_route_next(rn
))
2375 if ((table
= (rn
->info
)) != NULL
)
2376 bgp_announce_table (peer
, afi
, safi
, table
, 0);
2378 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2379 bgp_announce_table (peer
, afi
, safi
, NULL
, 1);
2383 bgp_announce_route_all (struct peer
*peer
)
2388 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2389 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2390 bgp_announce_route (peer
, afi
, safi
);
2394 bgp_soft_reconfig_table_rsclient (struct peer
*rsclient
, afi_t afi
,
2395 safi_t safi
, struct bgp_table
*table
)
2397 struct bgp_node
*rn
;
2398 struct bgp_adj_in
*ain
;
2401 table
= rsclient
->bgp
->rib
[afi
][safi
];
2403 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2404 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2406 bgp_update_rsclient (rsclient
, afi
, safi
, ain
->attr
, ain
->peer
,
2407 &rn
->p
, ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
2412 bgp_soft_reconfig_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
)
2414 struct bgp_table
*table
;
2415 struct bgp_node
*rn
;
2417 if (safi
!= SAFI_MPLS_VPN
)
2418 bgp_soft_reconfig_table_rsclient (rsclient
, afi
, safi
, NULL
);
2421 for (rn
= bgp_table_top (rsclient
->bgp
->rib
[afi
][safi
]); rn
;
2422 rn
= bgp_route_next (rn
))
2423 if ((table
= rn
->info
) != NULL
)
2424 bgp_soft_reconfig_table_rsclient (rsclient
, afi
, safi
, table
);
2428 bgp_soft_reconfig_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2429 struct bgp_table
*table
)
2432 struct bgp_node
*rn
;
2433 struct bgp_adj_in
*ain
;
2436 table
= peer
->bgp
->rib
[afi
][safi
];
2438 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2439 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2441 if (ain
->peer
== peer
)
2443 ret
= bgp_update (peer
, &rn
->p
, ain
->attr
, afi
, safi
,
2444 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
,
2448 bgp_unlock_node (rn
);
2457 bgp_soft_reconfig_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2459 struct bgp_node
*rn
;
2460 struct bgp_table
*table
;
2462 if (peer
->status
!= Established
)
2465 if (safi
!= SAFI_MPLS_VPN
)
2466 bgp_soft_reconfig_table (peer
, afi
, safi
, NULL
);
2468 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2469 rn
= bgp_route_next (rn
))
2470 if ((table
= rn
->info
) != NULL
)
2471 bgp_soft_reconfig_table (peer
, afi
, safi
, table
);
2474 static wq_item_status
2475 bgp_clear_route_node (struct work_queue
*wq
, void *data
)
2477 struct bgp_node
*rn
= data
;
2478 struct peer
*peer
= wq
->spec
.data
;
2479 struct bgp_adj_in
*ain
;
2480 struct bgp_adj_out
*aout
;
2481 struct bgp_info
*ri
;
2482 afi_t afi
= rn
->table
->afi
;
2483 safi_t safi
= rn
->table
->safi
;
2485 assert (rn
&& peer
);
2487 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2488 if (ri
->peer
== peer
)
2490 /* graceful restart STALE flag set. */
2491 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_NSF_WAIT
)
2492 && peer
->nsf
[afi
][safi
]
2493 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
)
2494 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
2495 bgp_info_set_flag (rn
, ri
, BGP_INFO_STALE
);
2497 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2500 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2501 if (ain
->peer
== peer
)
2503 bgp_adj_in_remove (rn
, ain
);
2504 bgp_unlock_node (rn
);
2507 for (aout
= rn
->adj_out
; aout
; aout
= aout
->next
)
2508 if (aout
->peer
== peer
)
2510 bgp_adj_out_remove (rn
, aout
, peer
, afi
, safi
);
2511 bgp_unlock_node (rn
);
2518 bgp_clear_node_queue_del (struct work_queue
*wq
, void *data
)
2520 struct bgp_node
*rn
= data
;
2522 bgp_unlock_node (rn
);
2526 bgp_clear_node_complete (struct work_queue
*wq
)
2528 struct peer
*peer
= wq
->spec
.data
;
2530 UNSET_FLAG (peer
->sflags
, PEER_STATUS_CLEARING
);
2531 peer_unlock (peer
); /* bgp_clear_node_complete */
2533 /* Tickle FSM to start moving again */
2534 BGP_EVENT_ADD (peer
, BGP_Start
);
2538 bgp_clear_node_queue_init (struct peer
*peer
)
2540 #define CLEAR_QUEUE_NAME_LEN 26 /* "clear 2001:123:123:123::1" */
2541 char wname
[CLEAR_QUEUE_NAME_LEN
];
2543 snprintf (wname
, CLEAR_QUEUE_NAME_LEN
, "clear %s", peer
->host
);
2544 #undef CLEAR_QUEUE_NAME_LEN
2546 if ( (peer
->clear_node_queue
= work_queue_new (bm
->master
, wname
)) == NULL
)
2548 zlog_err ("%s: Failed to allocate work queue", __func__
);
2551 peer
->clear_node_queue
->spec
.hold
= 10;
2552 peer
->clear_node_queue
->spec
.workfunc
= &bgp_clear_route_node
;
2553 peer
->clear_node_queue
->spec
.del_item_data
= &bgp_clear_node_queue_del
;
2554 peer
->clear_node_queue
->spec
.completion_func
= &bgp_clear_node_complete
;
2555 peer
->clear_node_queue
->spec
.max_retries
= 0;
2557 /* we only 'lock' this peer reference when the queue is actually active */
2558 peer
->clear_node_queue
->spec
.data
= peer
;
2562 bgp_clear_route_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2563 struct bgp_table
*table
, struct peer
*rsclient
)
2565 struct bgp_node
*rn
;
2568 table
= (rsclient
) ? rsclient
->rib
[afi
][safi
] : peer
->bgp
->rib
[afi
][safi
];
2570 /* If still no table => afi/safi isn't configured at all or smth. */
2574 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2576 if (rn
->info
== NULL
)
2579 bgp_lock_node (rn
); /* unlocked: bgp_clear_node_queue_del */
2580 work_queue_add (peer
->clear_node_queue
, rn
);
2586 bgp_clear_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2588 struct bgp_node
*rn
;
2589 struct bgp_table
*table
;
2590 struct peer
*rsclient
;
2591 struct listnode
*node
, *nnode
;
2593 if (peer
->clear_node_queue
== NULL
)
2594 bgp_clear_node_queue_init (peer
);
2596 /* bgp_fsm.c will not bring CLEARING sessions out of Idle this
2597 * protects against peers which flap faster than we can we clear,
2598 * which could lead to:
2600 * a) race with routes from the new session being installed before
2601 * clear_route_node visits the node (to delete the route of that
2603 * b) resource exhaustion, clear_route_node likely leads to an entry
2604 * on the process_main queue. Fast-flapping could cause that queue
2607 if (!CHECK_FLAG (peer
->sflags
, PEER_STATUS_CLEARING
))
2609 SET_FLAG (peer
->sflags
, PEER_STATUS_CLEARING
);
2610 peer_lock (peer
); /* bgp_clear_node_complete */
2613 if (safi
!= SAFI_MPLS_VPN
)
2614 bgp_clear_route_table (peer
, afi
, safi
, NULL
, NULL
);
2616 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2617 rn
= bgp_route_next (rn
))
2618 if ((table
= rn
->info
) != NULL
)
2619 bgp_clear_route_table (peer
, afi
, safi
, table
, NULL
);
2621 for (ALL_LIST_ELEMENTS (peer
->bgp
->rsclient
, node
, nnode
, rsclient
))
2623 if (CHECK_FLAG(rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2624 bgp_clear_route_table (peer
, afi
, safi
, NULL
, rsclient
);
2627 /* If no routes were cleared, nothing was added to workqueue, run the
2628 * completion function now.
2630 if (!peer
->clear_node_queue
->thread
)
2631 bgp_clear_node_complete (peer
->clear_node_queue
);
2635 bgp_clear_route_all (struct peer
*peer
)
2640 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2641 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2642 bgp_clear_route (peer
, afi
, safi
);
2646 bgp_clear_adj_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2648 struct bgp_table
*table
;
2649 struct bgp_node
*rn
;
2650 struct bgp_adj_in
*ain
;
2652 table
= peer
->bgp
->rib
[afi
][safi
];
2654 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2655 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2656 if (ain
->peer
== peer
)
2658 bgp_adj_in_remove (rn
, ain
);
2659 bgp_unlock_node (rn
);
2665 bgp_clear_stale_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2667 struct bgp_node
*rn
;
2668 struct bgp_info
*ri
;
2669 struct bgp_table
*table
;
2671 table
= peer
->bgp
->rib
[afi
][safi
];
2673 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2675 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2676 if (ri
->peer
== peer
)
2678 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2679 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2685 /* Delete all kernel routes. */
2687 bgp_cleanup_routes ()
2690 struct listnode
*node
, *nnode
;
2691 struct bgp_node
*rn
;
2692 struct bgp_table
*table
;
2693 struct bgp_info
*ri
;
2695 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
2697 table
= bgp
->rib
[AFI_IP
][SAFI_UNICAST
];
2699 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2700 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2701 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
2702 && ri
->type
== ZEBRA_ROUTE_BGP
2703 && ri
->sub_type
== BGP_ROUTE_NORMAL
)
2704 bgp_zebra_withdraw (&rn
->p
, ri
);
2706 table
= bgp
->rib
[AFI_IP6
][SAFI_UNICAST
];
2708 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2709 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2710 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
2711 && ri
->type
== ZEBRA_ROUTE_BGP
2712 && ri
->sub_type
== BGP_ROUTE_NORMAL
)
2713 bgp_zebra_withdraw (&rn
->p
, ri
);
2721 bgp_zclient_reset ();
2722 access_list_reset ();
2723 prefix_list_reset ();
2726 /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
2729 bgp_nlri_parse (struct peer
*peer
, struct attr
*attr
, struct bgp_nlri
*packet
)
2737 /* Check peer status. */
2738 if (peer
->status
!= Established
)
2742 lim
= pnt
+ packet
->length
;
2744 for (; pnt
< lim
; pnt
+= psize
)
2746 /* Clear prefix structure. */
2747 memset (&p
, 0, sizeof (struct prefix
));
2749 /* Fetch prefix length. */
2750 p
.prefixlen
= *pnt
++;
2751 p
.family
= afi2family (packet
->afi
);
2753 /* Already checked in nlri_sanity_check(). We do double check
2755 if ((packet
->afi
== AFI_IP
&& p
.prefixlen
> 32)
2756 || (packet
->afi
== AFI_IP6
&& p
.prefixlen
> 128))
2759 /* Packet size overflow check. */
2760 psize
= PSIZE (p
.prefixlen
);
2762 /* When packet overflow occur return immediately. */
2763 if (pnt
+ psize
> lim
)
2766 /* Fetch prefix from NLRI packet. */
2767 memcpy (&p
.u
.prefix
, pnt
, psize
);
2769 /* Check address. */
2770 if (packet
->afi
== AFI_IP
&& packet
->safi
== SAFI_UNICAST
)
2772 if (IN_CLASSD (ntohl (p
.u
.prefix4
.s_addr
)))
2775 * From draft-ietf-idr-bgp4-22, Section 6.3:
2776 * If a BGP router receives an UPDATE message with a
2777 * semantically incorrect NLRI field, in which a prefix is
2778 * semantically incorrect (eg. an unexpected multicast IP
2779 * address), it should ignore the prefix.
2781 zlog (peer
->log
, LOG_ERR
,
2782 "IPv4 unicast NLRI is multicast address %s",
2783 inet_ntoa (p
.u
.prefix4
));
2790 /* Check address. */
2791 if (packet
->afi
== AFI_IP6
&& packet
->safi
== SAFI_UNICAST
)
2793 if (IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
2797 zlog (peer
->log
, LOG_WARNING
,
2798 "IPv6 link-local NLRI received %s ignore this NLRI",
2799 inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
2804 #endif /* HAVE_IPV6 */
2806 /* Normal process. */
2808 ret
= bgp_update (peer
, &p
, attr
, packet
->afi
, packet
->safi
,
2809 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
2811 ret
= bgp_withdraw (peer
, &p
, attr
, packet
->afi
, packet
->safi
,
2812 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
2814 /* Address family configuration mismatch or maximum-prefix count
2820 /* Packet length consistency check. */
2827 /* NLRI encode syntax check routine. */
2829 bgp_nlri_sanity_check (struct peer
*peer
, int afi
, u_char
*pnt
,
2838 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
2839 syntactic validity. If the field is syntactically incorrect,
2840 then the Error Subcode is set to Invalid Network Field. */
2846 /* Prefix length check. */
2847 if ((afi
== AFI_IP
&& prefixlen
> 32)
2848 || (afi
== AFI_IP6
&& prefixlen
> 128))
2850 plog_err (peer
->log
,
2851 "%s [Error] Update packet error (wrong prefix length %d)",
2852 peer
->host
, prefixlen
);
2853 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
2854 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
2858 /* Packet size overflow check. */
2859 psize
= PSIZE (prefixlen
);
2861 if (pnt
+ psize
> end
)
2863 plog_err (peer
->log
,
2864 "%s [Error] Update packet error"
2865 " (prefix data overflow prefix size is %d)",
2867 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
2868 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
2875 /* Packet length consistency check. */
2878 plog_err (peer
->log
,
2879 "%s [Error] Update packet error"
2880 " (prefix length mismatch with total length)",
2882 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
2883 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
2889 static struct bgp_static
*
2892 struct bgp_static
*new;
2893 new = XMALLOC (MTYPE_BGP_STATIC
, sizeof (struct bgp_static
));
2894 memset (new, 0, sizeof (struct bgp_static
));
2899 bgp_static_free (struct bgp_static
*bgp_static
)
2901 if (bgp_static
->rmap
.name
)
2902 free (bgp_static
->rmap
.name
);
2903 XFREE (MTYPE_BGP_STATIC
, bgp_static
);
2907 bgp_static_withdraw_rsclient (struct bgp
*bgp
, struct peer
*rsclient
,
2908 struct prefix
*p
, afi_t afi
, safi_t safi
)
2910 struct bgp_node
*rn
;
2911 struct bgp_info
*ri
;
2913 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
2915 /* Check selected route and self inserted route. */
2916 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2917 if (ri
->peer
== bgp
->peer_self
2918 && ri
->type
== ZEBRA_ROUTE_BGP
2919 && ri
->sub_type
== BGP_ROUTE_STATIC
)
2922 /* Withdraw static BGP route from routing table. */
2925 bgp_info_delete (rn
, ri
);
2926 bgp_process (bgp
, rn
, afi
, safi
);
2929 /* Unlock bgp_node_lookup. */
2930 bgp_unlock_node (rn
);
2934 bgp_static_update_rsclient (struct peer
*rsclient
, struct prefix
*p
,
2935 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
2937 struct bgp_node
*rn
;
2938 struct bgp_info
*ri
;
2939 struct bgp_info
*new;
2940 struct bgp_info info
;
2941 struct attr new_attr
;
2942 struct attr
*attr_new
;
2946 char buf
[SU_ADDRSTRLEN
];
2948 bgp
= rsclient
->bgp
;
2950 assert (bgp_static
);
2954 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
2956 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
2958 attr
.nexthop
= bgp_static
->igpnexthop
;
2959 attr
.med
= bgp_static
->igpmetric
;
2960 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
2964 /* Apply network route-map for export to this rsclient. */
2965 if (bgp_static
->rmap
.name
)
2967 info
.peer
= rsclient
;
2968 info
.attr
= &new_attr
;
2970 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_EXPORT
);
2971 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
2973 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
2975 rsclient
->rmap_type
= 0;
2977 if (ret
== RMAP_DENYMATCH
)
2979 /* Free uninterned attribute. */
2980 bgp_attr_flush (&new_attr
);
2982 /* Unintern original. */
2983 aspath_unintern (attr
.aspath
);
2984 bgp_static_withdraw_rsclient (bgp
, rsclient
, p
, afi
, safi
);
2988 attr_new
= bgp_attr_intern (&new_attr
);
2991 attr_new
= bgp_attr_intern (&attr
);
2993 new_attr
= *attr_new
;
2995 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
2997 if (bgp_import_modifier (rsclient
, bgp
->peer_self
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
2999 /* This BGP update is filtered. Log the reason then update BGP entry. */
3000 if (BGP_DEBUG (update
, UPDATE_IN
))
3001 zlog (rsclient
->log
, LOG_DEBUG
,
3002 "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
3003 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
3004 p
->prefixlen
, rsclient
->host
);
3006 bgp
->peer_self
->rmap_type
= 0;
3008 bgp_attr_unintern (attr_new
);
3009 aspath_unintern (attr
.aspath
);
3011 bgp_static_withdraw_rsclient (bgp
, rsclient
, p
, afi
, safi
);
3016 bgp
->peer_self
->rmap_type
= 0;
3018 bgp_attr_unintern (attr_new
);
3019 attr_new
= bgp_attr_intern (&new_attr
);
3021 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3022 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3023 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3028 if (attrhash_cmp (ri
->attr
, attr_new
))
3030 bgp_unlock_node (rn
);
3031 bgp_attr_unintern (attr_new
);
3032 aspath_unintern (attr
.aspath
);
3037 /* The attribute is changed. */
3038 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3040 /* Rewrite BGP route information. */
3041 bgp_attr_unintern (ri
->attr
);
3042 ri
->attr
= attr_new
;
3043 ri
->uptime
= time (NULL
);
3045 /* Process change. */
3046 bgp_process (bgp
, rn
, afi
, safi
);
3047 bgp_unlock_node (rn
);
3048 aspath_unintern (attr
.aspath
);
3053 /* Make new BGP info. */
3054 new = bgp_info_new ();
3055 new->type
= ZEBRA_ROUTE_BGP
;
3056 new->sub_type
= BGP_ROUTE_STATIC
;
3057 new->peer
= bgp
->peer_self
;
3058 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3059 new->attr
= attr_new
;
3060 new->uptime
= time (NULL
);
3062 /* Register new BGP information. */
3063 bgp_info_add (rn
, new);
3065 /* route_node_get lock */
3066 bgp_unlock_node (rn
);
3068 /* Process change. */
3069 bgp_process (bgp
, rn
, afi
, safi
);
3071 /* Unintern original. */
3072 aspath_unintern (attr
.aspath
);
3076 bgp_static_update_main (struct bgp
*bgp
, struct prefix
*p
,
3077 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3079 struct bgp_node
*rn
;
3080 struct bgp_info
*ri
;
3081 struct bgp_info
*new;
3082 struct bgp_info info
;
3084 struct attr attr_tmp
;
3085 struct attr
*attr_new
;
3088 assert (bgp_static
);
3092 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3094 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3096 attr
.nexthop
= bgp_static
->igpnexthop
;
3097 attr
.med
= bgp_static
->igpmetric
;
3098 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3100 /* Apply route-map. */
3101 if (bgp_static
->rmap
.name
)
3104 info
.peer
= bgp
->peer_self
;
3105 info
.attr
= &attr_tmp
;
3107 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3109 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3111 bgp
->peer_self
->rmap_type
= 0;
3113 if (ret
== RMAP_DENYMATCH
)
3115 /* Free uninterned attribute. */
3116 bgp_attr_flush (&attr_tmp
);
3118 /* Unintern original. */
3119 aspath_unintern (attr
.aspath
);
3120 bgp_static_withdraw (bgp
, p
, afi
, safi
);
3123 attr_new
= bgp_attr_intern (&attr_tmp
);
3126 attr_new
= bgp_attr_intern (&attr
);
3128 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3129 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3130 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3135 if (attrhash_cmp (ri
->attr
, attr_new
))
3137 bgp_unlock_node (rn
);
3138 bgp_attr_unintern (attr_new
);
3139 aspath_unintern (attr
.aspath
);
3144 /* The attribute is changed. */
3145 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3147 /* Rewrite BGP route information. */
3148 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3149 bgp_attr_unintern (ri
->attr
);
3150 ri
->attr
= attr_new
;
3151 ri
->uptime
= time (NULL
);
3153 /* Process change. */
3154 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3155 bgp_process (bgp
, rn
, afi
, safi
);
3156 bgp_unlock_node (rn
);
3157 aspath_unintern (attr
.aspath
);
3162 /* Make new BGP info. */
3163 new = bgp_info_new ();
3164 new->type
= ZEBRA_ROUTE_BGP
;
3165 new->sub_type
= BGP_ROUTE_STATIC
;
3166 new->peer
= bgp
->peer_self
;
3167 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3168 new->attr
= attr_new
;
3169 new->uptime
= time (NULL
);
3171 /* Aggregate address increment. */
3172 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3174 /* Register new BGP information. */
3175 bgp_info_add (rn
, new);
3177 /* route_node_get lock */
3178 bgp_unlock_node (rn
);
3180 /* Process change. */
3181 bgp_process (bgp
, rn
, afi
, safi
);
3183 /* Unintern original. */
3184 aspath_unintern (attr
.aspath
);
3188 bgp_static_update (struct bgp
*bgp
, struct prefix
*p
,
3189 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3191 struct peer
*rsclient
;
3192 struct listnode
*node
, *nnode
;
3194 bgp_static_update_main (bgp
, p
, bgp_static
, afi
, safi
);
3196 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
3198 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
3199 bgp_static_update_rsclient (rsclient
, p
, bgp_static
, afi
, safi
);
3204 bgp_static_update_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, u_int16_t afi
,
3205 u_char safi
, struct prefix_rd
*prd
, u_char
*tag
)
3207 struct bgp_node
*rn
;
3208 struct bgp_info
*new;
3210 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3212 /* Make new BGP info. */
3213 new = bgp_info_new ();
3214 new->type
= ZEBRA_ROUTE_BGP
;
3215 new->sub_type
= BGP_ROUTE_STATIC
;
3216 new->peer
= bgp
->peer_self
;
3217 new->attr
= bgp_attr_default_intern (BGP_ORIGIN_IGP
);
3218 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3219 new->uptime
= time (NULL
);
3220 memcpy (new->tag
, tag
, 3);
3222 /* Aggregate address increment. */
3223 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3225 /* Register new BGP information. */
3226 bgp_info_add (rn
, new);
3228 /* route_node_get lock */
3229 bgp_unlock_node (rn
);
3231 /* Process change. */
3232 bgp_process (bgp
, rn
, afi
, safi
);
3236 bgp_static_withdraw (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3239 struct bgp_node
*rn
;
3240 struct bgp_info
*ri
;
3242 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3244 /* Check selected route and self inserted route. */
3245 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3246 if (ri
->peer
== bgp
->peer_self
3247 && ri
->type
== ZEBRA_ROUTE_BGP
3248 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3251 /* Withdraw static BGP route from routing table. */
3254 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3255 bgp_info_delete (rn
, ri
);
3256 bgp_process (bgp
, rn
, afi
, safi
);
3259 /* Unlock bgp_node_lookup. */
3260 bgp_unlock_node (rn
);
3264 bgp_check_local_routes_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
)
3266 struct bgp_static
*bgp_static
;
3268 struct bgp_node
*rn
;
3271 bgp
= rsclient
->bgp
;
3273 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3274 if ((bgp_static
= rn
->info
) != NULL
)
3278 bgp_static_update_rsclient (rsclient
, p
, bgp_static
,
3284 bgp_static_withdraw_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, u_int16_t afi
,
3285 u_char safi
, struct prefix_rd
*prd
, u_char
*tag
)
3287 struct bgp_node
*rn
;
3288 struct bgp_info
*ri
;
3290 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3292 /* Check selected route and self inserted route. */
3293 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3294 if (ri
->peer
== bgp
->peer_self
3295 && ri
->type
== ZEBRA_ROUTE_BGP
3296 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3299 /* Withdraw static BGP route from routing table. */
3302 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3303 bgp_info_delete (rn
, ri
);
3304 bgp_process (bgp
, rn
, afi
, safi
);
3307 /* Unlock bgp_node_lookup. */
3308 bgp_unlock_node (rn
);
3311 /* Configure static BGP network. When user don't run zebra, static
3312 route should be installed as valid. */
3314 bgp_static_set (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3315 u_int16_t afi
, u_char safi
, const char *rmap
, int backdoor
)
3319 struct bgp_static
*bgp_static
;
3320 struct bgp_node
*rn
;
3321 int need_update
= 0;
3323 /* Convert IP prefix string to struct prefix. */
3324 ret
= str2prefix (ip_str
, &p
);
3327 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3331 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3333 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3337 #endif /* HAVE_IPV6 */
3341 /* Set BGP static route configuration. */
3342 rn
= bgp_node_get (bgp
->route
[afi
][safi
], &p
);
3346 /* Configuration change. */
3347 bgp_static
= rn
->info
;
3349 /* Check previous routes are installed into BGP. */
3350 if (! bgp_static
->backdoor
&& bgp_static
->valid
)
3353 bgp_static
->backdoor
= backdoor
;
3356 if (bgp_static
->rmap
.name
)
3357 free (bgp_static
->rmap
.name
);
3358 bgp_static
->rmap
.name
= strdup (rmap
);
3359 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3363 if (bgp_static
->rmap
.name
)
3364 free (bgp_static
->rmap
.name
);
3365 bgp_static
->rmap
.name
= NULL
;
3366 bgp_static
->rmap
.map
= NULL
;
3367 bgp_static
->valid
= 0;
3369 bgp_unlock_node (rn
);
3373 /* New configuration. */
3374 bgp_static
= bgp_static_new ();
3375 bgp_static
->backdoor
= backdoor
;
3376 bgp_static
->valid
= 0;
3377 bgp_static
->igpmetric
= 0;
3378 bgp_static
->igpnexthop
.s_addr
= 0;
3381 if (bgp_static
->rmap
.name
)
3382 free (bgp_static
->rmap
.name
);
3383 bgp_static
->rmap
.name
= strdup (rmap
);
3384 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3386 rn
->info
= bgp_static
;
3389 /* If BGP scan is not enabled, we should install this route here. */
3390 if (! bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3392 bgp_static
->valid
= 1;
3395 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3397 if (! bgp_static
->backdoor
)
3398 bgp_static_update (bgp
, &p
, bgp_static
, afi
, safi
);
3404 /* Configure static BGP network. */
3406 bgp_static_unset (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3407 u_int16_t afi
, u_char safi
)
3411 struct bgp_static
*bgp_static
;
3412 struct bgp_node
*rn
;
3414 /* Convert IP prefix string to struct prefix. */
3415 ret
= str2prefix (ip_str
, &p
);
3418 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3422 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3424 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3428 #endif /* HAVE_IPV6 */
3432 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], &p
);
3435 vty_out (vty
, "%% Can't find specified static route configuration.%s",
3440 bgp_static
= rn
->info
;
3442 /* Update BGP RIB. */
3443 if (! bgp_static
->backdoor
)
3444 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3446 /* Clear configuration. */
3447 bgp_static_free (bgp_static
);
3449 bgp_unlock_node (rn
);
3450 bgp_unlock_node (rn
);
3455 /* Called from bgp_delete(). Delete all static routes from the BGP
3458 bgp_static_delete (struct bgp
*bgp
)
3462 struct bgp_node
*rn
;
3463 struct bgp_node
*rm
;
3464 struct bgp_table
*table
;
3465 struct bgp_static
*bgp_static
;
3467 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3468 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3469 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3470 if (rn
->info
!= NULL
)
3472 if (safi
== SAFI_MPLS_VPN
)
3476 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
3478 bgp_static
= rn
->info
;
3479 bgp_static_withdraw_vpnv4 (bgp
, &rm
->p
,
3480 AFI_IP
, SAFI_MPLS_VPN
,
3481 (struct prefix_rd
*)&rn
->p
,
3483 bgp_static_free (bgp_static
);
3485 bgp_unlock_node (rn
);
3490 bgp_static
= rn
->info
;
3491 bgp_static_withdraw (bgp
, &rn
->p
, afi
, safi
);
3492 bgp_static_free (bgp_static
);
3494 bgp_unlock_node (rn
);
3500 bgp_static_set_vpnv4 (struct vty
*vty
, const char *ip_str
, const char *rd_str
,
3501 const char *tag_str
)
3505 struct prefix_rd prd
;
3507 struct bgp_node
*prn
;
3508 struct bgp_node
*rn
;
3509 struct bgp_table
*table
;
3510 struct bgp_static
*bgp_static
;
3515 ret
= str2prefix (ip_str
, &p
);
3518 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3523 ret
= str2prefix_rd (rd_str
, &prd
);
3526 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3530 ret
= str2tag (tag_str
, tag
);
3533 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3537 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3538 (struct prefix
*)&prd
);
3539 if (prn
->info
== NULL
)
3540 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3542 bgp_unlock_node (prn
);
3545 rn
= bgp_node_get (table
, &p
);
3549 vty_out (vty
, "%% Same network configuration exists%s", VTY_NEWLINE
);
3550 bgp_unlock_node (rn
);
3554 /* New configuration. */
3555 bgp_static
= bgp_static_new ();
3556 bgp_static
->valid
= 1;
3557 memcpy (bgp_static
->tag
, tag
, 3);
3558 rn
->info
= bgp_static
;
3560 bgp_static_update_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3566 /* Configure static BGP network. */
3568 bgp_static_unset_vpnv4 (struct vty
*vty
, const char *ip_str
,
3569 const char *rd_str
, const char *tag_str
)
3574 struct prefix_rd prd
;
3575 struct bgp_node
*prn
;
3576 struct bgp_node
*rn
;
3577 struct bgp_table
*table
;
3578 struct bgp_static
*bgp_static
;
3583 /* Convert IP prefix string to struct prefix. */
3584 ret
= str2prefix (ip_str
, &p
);
3587 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3592 ret
= str2prefix_rd (rd_str
, &prd
);
3595 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3599 ret
= str2tag (tag_str
, tag
);
3602 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3606 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3607 (struct prefix
*)&prd
);
3608 if (prn
->info
== NULL
)
3609 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3611 bgp_unlock_node (prn
);
3614 rn
= bgp_node_lookup (table
, &p
);
3618 bgp_static_withdraw_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3620 bgp_static
= rn
->info
;
3621 bgp_static_free (bgp_static
);
3623 bgp_unlock_node (rn
);
3624 bgp_unlock_node (rn
);
3627 vty_out (vty
, "%% Can't find the route%s", VTY_NEWLINE
);
3634 "network A.B.C.D/M",
3635 "Specify a network to announce via BGP\n"
3636 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
3638 return bgp_static_set (vty
, vty
->index
, argv
[0],
3639 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
3642 DEFUN (bgp_network_route_map
,
3643 bgp_network_route_map_cmd
,
3644 "network A.B.C.D/M route-map WORD",
3645 "Specify a network to announce via BGP\n"
3646 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3647 "Route-map to modify the attributes\n"
3648 "Name of the route map\n")
3650 return bgp_static_set (vty
, vty
->index
, argv
[0],
3651 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
3654 DEFUN (bgp_network_backdoor
,
3655 bgp_network_backdoor_cmd
,
3656 "network A.B.C.D/M backdoor",
3657 "Specify a network to announce via BGP\n"
3658 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3659 "Specify a BGP backdoor route\n")
3661 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
3664 DEFUN (bgp_network_mask
,
3665 bgp_network_mask_cmd
,
3666 "network A.B.C.D mask A.B.C.D",
3667 "Specify a network to announce via BGP\n"
3673 char prefix_str
[BUFSIZ
];
3675 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3678 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3682 return bgp_static_set (vty
, vty
->index
, prefix_str
,
3683 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
3686 DEFUN (bgp_network_mask_route_map
,
3687 bgp_network_mask_route_map_cmd
,
3688 "network A.B.C.D mask A.B.C.D route-map WORD",
3689 "Specify a network to announce via BGP\n"
3693 "Route-map to modify the attributes\n"
3694 "Name of the route map\n")
3697 char prefix_str
[BUFSIZ
];
3699 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3702 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3706 return bgp_static_set (vty
, vty
->index
, prefix_str
,
3707 AFI_IP
, bgp_node_safi (vty
), argv
[2], 0);
3710 DEFUN (bgp_network_mask_backdoor
,
3711 bgp_network_mask_backdoor_cmd
,
3712 "network A.B.C.D mask A.B.C.D backdoor",
3713 "Specify a network to announce via BGP\n"
3717 "Specify a BGP backdoor route\n")
3720 char prefix_str
[BUFSIZ
];
3722 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3725 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3729 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
, NULL
, 1);
3732 DEFUN (bgp_network_mask_natural
,
3733 bgp_network_mask_natural_cmd
,
3735 "Specify a network to announce via BGP\n"
3739 char prefix_str
[BUFSIZ
];
3741 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
3744 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3748 return bgp_static_set (vty
, vty
->index
, prefix_str
,
3749 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
3752 DEFUN (bgp_network_mask_natural_route_map
,
3753 bgp_network_mask_natural_route_map_cmd
,
3754 "network A.B.C.D route-map WORD",
3755 "Specify a network to announce via BGP\n"
3757 "Route-map to modify the attributes\n"
3758 "Name of the route map\n")
3761 char prefix_str
[BUFSIZ
];
3763 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
3766 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3770 return bgp_static_set (vty
, vty
->index
, prefix_str
,
3771 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
3774 DEFUN (bgp_network_mask_natural_backdoor
,
3775 bgp_network_mask_natural_backdoor_cmd
,
3776 "network A.B.C.D backdoor",
3777 "Specify a network to announce via BGP\n"
3779 "Specify a BGP backdoor route\n")
3782 char prefix_str
[BUFSIZ
];
3784 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
3787 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3791 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
, NULL
, 1);
3794 DEFUN (no_bgp_network
,
3796 "no network A.B.C.D/M",
3798 "Specify a network to announce via BGP\n"
3799 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
3801 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP
,
3802 bgp_node_safi (vty
));
3805 ALIAS (no_bgp_network
,
3806 no_bgp_network_route_map_cmd
,
3807 "no network A.B.C.D/M route-map WORD",
3809 "Specify a network to announce via BGP\n"
3810 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3811 "Route-map to modify the attributes\n"
3812 "Name of the route map\n")
3814 ALIAS (no_bgp_network
,
3815 no_bgp_network_backdoor_cmd
,
3816 "no network A.B.C.D/M backdoor",
3818 "Specify a network to announce via BGP\n"
3819 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3820 "Specify a BGP backdoor route\n")
3822 DEFUN (no_bgp_network_mask
,
3823 no_bgp_network_mask_cmd
,
3824 "no network A.B.C.D mask A.B.C.D",
3826 "Specify a network to announce via BGP\n"
3832 char prefix_str
[BUFSIZ
];
3834 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3837 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3841 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
3842 bgp_node_safi (vty
));
3845 ALIAS (no_bgp_network_mask
,
3846 no_bgp_network_mask_route_map_cmd
,
3847 "no network A.B.C.D mask A.B.C.D route-map WORD",
3849 "Specify a network to announce via BGP\n"
3853 "Route-map to modify the attributes\n"
3854 "Name of the route map\n")
3856 ALIAS (no_bgp_network_mask
,
3857 no_bgp_network_mask_backdoor_cmd
,
3858 "no network A.B.C.D mask A.B.C.D backdoor",
3860 "Specify a network to announce via BGP\n"
3864 "Specify a BGP backdoor route\n")
3866 DEFUN (no_bgp_network_mask_natural
,
3867 no_bgp_network_mask_natural_cmd
,
3868 "no network A.B.C.D",
3870 "Specify a network to announce via BGP\n"
3874 char prefix_str
[BUFSIZ
];
3876 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
3879 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3883 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
3884 bgp_node_safi (vty
));
3887 ALIAS (no_bgp_network_mask_natural
,
3888 no_bgp_network_mask_natural_route_map_cmd
,
3889 "no network A.B.C.D route-map WORD",
3891 "Specify a network to announce via BGP\n"
3893 "Route-map to modify the attributes\n"
3894 "Name of the route map\n")
3896 ALIAS (no_bgp_network_mask_natural
,
3897 no_bgp_network_mask_natural_backdoor_cmd
,
3898 "no network A.B.C.D backdoor",
3900 "Specify a network to announce via BGP\n"
3902 "Specify a BGP backdoor route\n")
3905 DEFUN (ipv6_bgp_network
,
3906 ipv6_bgp_network_cmd
,
3907 "network X:X::X:X/M",
3908 "Specify a network to announce via BGP\n"
3909 "IPv6 prefix <network>/<length>\n")
3911 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
3914 DEFUN (ipv6_bgp_network_route_map
,
3915 ipv6_bgp_network_route_map_cmd
,
3916 "network X:X::X:X/M route-map WORD",
3917 "Specify a network to announce via BGP\n"
3918 "IPv6 prefix <network>/<length>\n"
3919 "Route-map to modify the attributes\n"
3920 "Name of the route map\n")
3922 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
,
3923 bgp_node_safi (vty
), argv
[1], 0);
3926 DEFUN (no_ipv6_bgp_network
,
3927 no_ipv6_bgp_network_cmd
,
3928 "no network X:X::X:X/M",
3930 "Specify a network to announce via BGP\n"
3931 "IPv6 prefix <network>/<length>\n")
3933 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
3936 ALIAS (no_ipv6_bgp_network
,
3937 no_ipv6_bgp_network_route_map_cmd
,
3938 "no network X:X::X:X/M route-map WORD",
3940 "Specify a network to announce via BGP\n"
3941 "IPv6 prefix <network>/<length>\n"
3942 "Route-map to modify the attributes\n"
3943 "Name of the route map\n")
3945 ALIAS (ipv6_bgp_network
,
3946 old_ipv6_bgp_network_cmd
,
3947 "ipv6 bgp network X:X::X:X/M",
3950 "Specify a network to announce via BGP\n"
3951 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
3953 ALIAS (no_ipv6_bgp_network
,
3954 old_no_ipv6_bgp_network_cmd
,
3955 "no ipv6 bgp network X:X::X:X/M",
3959 "Specify a network to announce via BGP\n"
3960 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
3961 #endif /* HAVE_IPV6 */
3963 /* Aggreagete address:
3965 advertise-map Set condition to advertise attribute
3966 as-set Generate AS set path information
3967 attribute-map Set attributes of aggregate
3968 route-map Set parameters of aggregate
3969 summary-only Filter more specific routes from updates
3970 suppress-map Conditionally filter more specific routes from updates
3973 struct bgp_aggregate
3975 /* Summary-only flag. */
3976 u_char summary_only
;
3978 /* AS set generation. */
3981 /* Route-map for aggregated route. */
3982 struct route_map
*map
;
3984 /* Suppress-count. */
3985 unsigned long count
;
3987 /* SAFI configuration. */
3991 static struct bgp_aggregate
*
3992 bgp_aggregate_new ()
3994 struct bgp_aggregate
*new;
3995 new = XMALLOC (MTYPE_BGP_AGGREGATE
, sizeof (struct bgp_aggregate
));
3996 memset (new, 0, sizeof (struct bgp_aggregate
));
4001 bgp_aggregate_free (struct bgp_aggregate
*aggregate
)
4003 XFREE (MTYPE_BGP_AGGREGATE
, aggregate
);
4007 bgp_aggregate_route (struct bgp
*bgp
, struct prefix
*p
, struct bgp_info
*rinew
,
4008 afi_t afi
, safi_t safi
, struct bgp_info
*del
,
4009 struct bgp_aggregate
*aggregate
)
4011 struct bgp_table
*table
;
4012 struct bgp_node
*top
;
4013 struct bgp_node
*rn
;
4015 struct aspath
*aspath
= NULL
;
4016 struct aspath
*asmerge
= NULL
;
4017 struct community
*community
= NULL
;
4018 struct community
*commerge
= NULL
;
4019 struct in_addr nexthop
;
4021 struct bgp_info
*ri
;
4022 struct bgp_info
*new;
4024 unsigned long match
= 0;
4026 /* Record adding route's nexthop and med. */
4029 nexthop
= rinew
->attr
->nexthop
;
4030 med
= rinew
->attr
->med
;
4033 /* ORIGIN attribute: If at least one route among routes that are
4034 aggregated has ORIGIN with the value INCOMPLETE, then the
4035 aggregated route must have the ORIGIN attribute with the value
4036 INCOMPLETE. Otherwise, if at least one route among routes that
4037 are aggregated has ORIGIN with the value EGP, then the aggregated
4038 route must have the origin attribute with the value EGP. In all
4039 other case the value of the ORIGIN attribute of the aggregated
4040 route is INTERNAL. */
4041 origin
= BGP_ORIGIN_IGP
;
4043 table
= bgp
->rib
[afi
][safi
];
4045 top
= bgp_node_get (table
, p
);
4046 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4047 if (rn
->p
.prefixlen
> p
->prefixlen
)
4051 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4053 if (BGP_INFO_HOLDDOWN (ri
))
4056 if (del
&& ri
== del
)
4059 if (! rinew
&& first
)
4061 nexthop
= ri
->attr
->nexthop
;
4062 med
= ri
->attr
->med
;
4066 #ifdef AGGREGATE_NEXTHOP_CHECK
4067 if (! IPV4_ADDR_SAME (&ri
->attr
->nexthop
, &nexthop
)
4068 || ri
->attr
->med
!= med
)
4071 aspath_free (aspath
);
4073 community_free (community
);
4074 bgp_unlock_node (rn
);
4075 bgp_unlock_node (top
);
4078 #endif /* AGGREGATE_NEXTHOP_CHECK */
4080 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4082 if (aggregate
->summary_only
)
4085 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4091 if (aggregate
->as_set
)
4093 if (origin
< ri
->attr
->origin
)
4094 origin
= ri
->attr
->origin
;
4098 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4099 aspath_free (aspath
);
4103 aspath
= aspath_dup (ri
->attr
->aspath
);
4105 if (ri
->attr
->community
)
4109 commerge
= community_merge (community
,
4110 ri
->attr
->community
);
4111 community
= community_uniq_sort (commerge
);
4112 community_free (commerge
);
4115 community
= community_dup (ri
->attr
->community
);
4121 bgp_process (bgp
, rn
, afi
, safi
);
4123 bgp_unlock_node (top
);
4129 if (aggregate
->summary_only
)
4132 if (aggregate
->as_set
)
4134 if (origin
< rinew
->attr
->origin
)
4135 origin
= rinew
->attr
->origin
;
4139 asmerge
= aspath_aggregate (aspath
, rinew
->attr
->aspath
);
4140 aspath_free (aspath
);
4144 aspath
= aspath_dup (rinew
->attr
->aspath
);
4146 if (rinew
->attr
->community
)
4150 commerge
= community_merge (community
,
4151 rinew
->attr
->community
);
4152 community
= community_uniq_sort (commerge
);
4153 community_free (commerge
);
4156 community
= community_dup (rinew
->attr
->community
);
4161 if (aggregate
->count
> 0)
4163 rn
= bgp_node_get (table
, p
);
4164 new = bgp_info_new ();
4165 new->type
= ZEBRA_ROUTE_BGP
;
4166 new->sub_type
= BGP_ROUTE_AGGREGATE
;
4167 new->peer
= bgp
->peer_self
;
4168 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4169 new->attr
= bgp_attr_aggregate_intern (bgp
, origin
, aspath
, community
, aggregate
->as_set
);
4170 new->uptime
= time (NULL
);
4172 bgp_info_add (rn
, new);
4173 bgp_unlock_node (rn
);
4174 bgp_process (bgp
, rn
, afi
, safi
);
4179 aspath_free (aspath
);
4181 community_free (community
);
4185 void bgp_aggregate_delete (struct bgp
*, struct prefix
*, afi_t
, safi_t
,
4186 struct bgp_aggregate
*);
4189 bgp_aggregate_increment (struct bgp
*bgp
, struct prefix
*p
,
4190 struct bgp_info
*ri
, afi_t afi
, safi_t safi
)
4192 struct bgp_node
*child
;
4193 struct bgp_node
*rn
;
4194 struct bgp_aggregate
*aggregate
;
4196 /* MPLS-VPN aggregation is not yet supported. */
4197 if (safi
== SAFI_MPLS_VPN
)
4200 if (p
->prefixlen
== 0)
4203 if (BGP_INFO_HOLDDOWN (ri
))
4206 child
= bgp_node_get (bgp
->aggregate
[afi
][safi
], p
);
4208 /* Aggregate address configuration check. */
4209 for (rn
= child
; rn
; rn
= rn
->parent
)
4210 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4212 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4213 bgp_aggregate_route (bgp
, &rn
->p
, ri
, afi
, safi
, NULL
, aggregate
);
4215 bgp_unlock_node (child
);
4219 bgp_aggregate_decrement (struct bgp
*bgp
, struct prefix
*p
,
4220 struct bgp_info
*del
, afi_t afi
, safi_t safi
)
4222 struct bgp_node
*child
;
4223 struct bgp_node
*rn
;
4224 struct bgp_aggregate
*aggregate
;
4226 /* MPLS-VPN aggregation is not yet supported. */
4227 if (safi
== SAFI_MPLS_VPN
)
4230 if (p
->prefixlen
== 0)
4233 child
= bgp_node_get (bgp
->aggregate
[afi
][safi
], p
);
4235 /* Aggregate address configuration check. */
4236 for (rn
= child
; rn
; rn
= rn
->parent
)
4237 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4239 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4240 bgp_aggregate_route (bgp
, &rn
->p
, NULL
, afi
, safi
, del
, aggregate
);
4242 bgp_unlock_node (child
);
4246 bgp_aggregate_add (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
, safi_t safi
,
4247 struct bgp_aggregate
*aggregate
)
4249 struct bgp_table
*table
;
4250 struct bgp_node
*top
;
4251 struct bgp_node
*rn
;
4252 struct bgp_info
*new;
4253 struct bgp_info
*ri
;
4254 unsigned long match
;
4255 u_char origin
= BGP_ORIGIN_IGP
;
4256 struct aspath
*aspath
= NULL
;
4257 struct aspath
*asmerge
= NULL
;
4258 struct community
*community
= NULL
;
4259 struct community
*commerge
= NULL
;
4261 table
= bgp
->rib
[afi
][safi
];
4264 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4266 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4269 /* If routes exists below this node, generate aggregate routes. */
4270 top
= bgp_node_get (table
, p
);
4271 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4272 if (rn
->p
.prefixlen
> p
->prefixlen
)
4276 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4278 if (BGP_INFO_HOLDDOWN (ri
))
4281 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4283 /* summary-only aggregate route suppress aggregated
4284 route announcement. */
4285 if (aggregate
->summary_only
)
4288 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4291 /* as-set aggregate route generate origin, as path,
4292 community aggregation. */
4293 if (aggregate
->as_set
)
4295 if (origin
< ri
->attr
->origin
)
4296 origin
= ri
->attr
->origin
;
4300 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4301 aspath_free (aspath
);
4305 aspath
= aspath_dup (ri
->attr
->aspath
);
4307 if (ri
->attr
->community
)
4311 commerge
= community_merge (community
,
4312 ri
->attr
->community
);
4313 community
= community_uniq_sort (commerge
);
4314 community_free (commerge
);
4317 community
= community_dup (ri
->attr
->community
);
4324 /* If this node is suppressed, process the change. */
4326 bgp_process (bgp
, rn
, afi
, safi
);
4328 bgp_unlock_node (top
);
4330 /* Add aggregate route to BGP table. */
4331 if (aggregate
->count
)
4333 rn
= bgp_node_get (table
, p
);
4335 new = bgp_info_new ();
4336 new->type
= ZEBRA_ROUTE_BGP
;
4337 new->sub_type
= BGP_ROUTE_AGGREGATE
;
4338 new->peer
= bgp
->peer_self
;
4339 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4340 new->attr
= bgp_attr_aggregate_intern (bgp
, origin
, aspath
, community
, aggregate
->as_set
);
4341 new->uptime
= time (NULL
);
4343 bgp_info_add (rn
, new);
4344 bgp_unlock_node (rn
);
4346 /* Process change. */
4347 bgp_process (bgp
, rn
, afi
, safi
);
4352 bgp_aggregate_delete (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
4353 safi_t safi
, struct bgp_aggregate
*aggregate
)
4355 struct bgp_table
*table
;
4356 struct bgp_node
*top
;
4357 struct bgp_node
*rn
;
4358 struct bgp_info
*ri
;
4359 unsigned long match
;
4361 table
= bgp
->rib
[afi
][safi
];
4363 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4365 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4368 /* If routes exists below this node, generate aggregate routes. */
4369 top
= bgp_node_get (table
, p
);
4370 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4371 if (rn
->p
.prefixlen
> p
->prefixlen
)
4375 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4377 if (BGP_INFO_HOLDDOWN (ri
))
4380 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4382 if (aggregate
->summary_only
)
4386 if (ri
->suppress
== 0)
4388 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4396 /* If this node is suppressed, process the change. */
4398 bgp_process (bgp
, rn
, afi
, safi
);
4400 bgp_unlock_node (top
);
4402 /* Delete aggregate route from BGP table. */
4403 rn
= bgp_node_get (table
, p
);
4405 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4406 if (ri
->peer
== bgp
->peer_self
4407 && ri
->type
== ZEBRA_ROUTE_BGP
4408 && ri
->sub_type
== BGP_ROUTE_AGGREGATE
)
4411 /* Withdraw static BGP route from routing table. */
4414 bgp_info_delete (rn
, ri
);
4415 bgp_process (bgp
, rn
, afi
, safi
);
4418 /* Unlock bgp_node_lookup. */
4419 bgp_unlock_node (rn
);
4422 /* Aggregate route attribute. */
4423 #define AGGREGATE_SUMMARY_ONLY 1
4424 #define AGGREGATE_AS_SET 1
4427 bgp_aggregate_set (struct vty
*vty
, const char *prefix_str
,
4428 afi_t afi
, safi_t safi
,
4429 u_char summary_only
, u_char as_set
)
4433 struct bgp_node
*rn
;
4435 struct bgp_aggregate
*aggregate
;
4437 /* Convert string to prefix structure. */
4438 ret
= str2prefix (prefix_str
, &p
);
4441 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
4446 /* Get BGP structure. */
4449 /* Old configuration check. */
4450 rn
= bgp_node_get (bgp
->aggregate
[afi
][safi
], &p
);
4454 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
4455 bgp_unlock_node (rn
);
4459 /* Make aggregate address structure. */
4460 aggregate
= bgp_aggregate_new ();
4461 aggregate
->summary_only
= summary_only
;
4462 aggregate
->as_set
= as_set
;
4463 aggregate
->safi
= safi
;
4464 rn
->info
= aggregate
;
4466 /* Aggregate address insert into BGP routing table. */
4467 if (safi
& SAFI_UNICAST
)
4468 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
4469 if (safi
& SAFI_MULTICAST
)
4470 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
4476 bgp_aggregate_unset (struct vty
*vty
, const char *prefix_str
,
4477 afi_t afi
, safi_t safi
)
4481 struct bgp_node
*rn
;
4483 struct bgp_aggregate
*aggregate
;
4485 /* Convert string to prefix structure. */
4486 ret
= str2prefix (prefix_str
, &p
);
4489 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
4494 /* Get BGP structure. */
4497 /* Old configuration check. */
4498 rn
= bgp_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
4501 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
4506 aggregate
= rn
->info
;
4507 if (aggregate
->safi
& SAFI_UNICAST
)
4508 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
4509 if (aggregate
->safi
& SAFI_MULTICAST
)
4510 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
4512 /* Unlock aggregate address configuration. */
4514 bgp_aggregate_free (aggregate
);
4515 bgp_unlock_node (rn
);
4516 bgp_unlock_node (rn
);
4521 DEFUN (aggregate_address
,
4522 aggregate_address_cmd
,
4523 "aggregate-address A.B.C.D/M",
4524 "Configure BGP aggregate entries\n"
4525 "Aggregate prefix\n")
4527 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
), 0, 0);
4530 DEFUN (aggregate_address_mask
,
4531 aggregate_address_mask_cmd
,
4532 "aggregate-address A.B.C.D A.B.C.D",
4533 "Configure BGP aggregate entries\n"
4534 "Aggregate address\n"
4538 char prefix_str
[BUFSIZ
];
4540 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4544 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4548 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
4552 DEFUN (aggregate_address_summary_only
,
4553 aggregate_address_summary_only_cmd
,
4554 "aggregate-address A.B.C.D/M summary-only",
4555 "Configure BGP aggregate entries\n"
4556 "Aggregate prefix\n"
4557 "Filter more specific routes from updates\n")
4559 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
4560 AGGREGATE_SUMMARY_ONLY
, 0);
4563 DEFUN (aggregate_address_mask_summary_only
,
4564 aggregate_address_mask_summary_only_cmd
,
4565 "aggregate-address A.B.C.D A.B.C.D summary-only",
4566 "Configure BGP aggregate entries\n"
4567 "Aggregate address\n"
4569 "Filter more specific routes from updates\n")
4572 char prefix_str
[BUFSIZ
];
4574 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4578 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4582 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
4583 AGGREGATE_SUMMARY_ONLY
, 0);
4586 DEFUN (aggregate_address_as_set
,
4587 aggregate_address_as_set_cmd
,
4588 "aggregate-address A.B.C.D/M as-set",
4589 "Configure BGP aggregate entries\n"
4590 "Aggregate prefix\n"
4591 "Generate AS set path information\n")
4593 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
4594 0, AGGREGATE_AS_SET
);
4597 DEFUN (aggregate_address_mask_as_set
,
4598 aggregate_address_mask_as_set_cmd
,
4599 "aggregate-address A.B.C.D A.B.C.D as-set",
4600 "Configure BGP aggregate entries\n"
4601 "Aggregate address\n"
4603 "Generate AS set path information\n")
4606 char prefix_str
[BUFSIZ
];
4608 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4612 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4616 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
4617 0, AGGREGATE_AS_SET
);
4621 DEFUN (aggregate_address_as_set_summary
,
4622 aggregate_address_as_set_summary_cmd
,
4623 "aggregate-address A.B.C.D/M as-set summary-only",
4624 "Configure BGP aggregate entries\n"
4625 "Aggregate prefix\n"
4626 "Generate AS set path information\n"
4627 "Filter more specific routes from updates\n")
4629 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
4630 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
4633 ALIAS (aggregate_address_as_set_summary
,
4634 aggregate_address_summary_as_set_cmd
,
4635 "aggregate-address A.B.C.D/M summary-only as-set",
4636 "Configure BGP aggregate entries\n"
4637 "Aggregate prefix\n"
4638 "Filter more specific routes from updates\n"
4639 "Generate AS set path information\n")
4641 DEFUN (aggregate_address_mask_as_set_summary
,
4642 aggregate_address_mask_as_set_summary_cmd
,
4643 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
4644 "Configure BGP aggregate entries\n"
4645 "Aggregate address\n"
4647 "Generate AS set path information\n"
4648 "Filter more specific routes from updates\n")
4651 char prefix_str
[BUFSIZ
];
4653 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4657 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4661 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
4662 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
4665 ALIAS (aggregate_address_mask_as_set_summary
,
4666 aggregate_address_mask_summary_as_set_cmd
,
4667 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
4668 "Configure BGP aggregate entries\n"
4669 "Aggregate address\n"
4671 "Filter more specific routes from updates\n"
4672 "Generate AS set path information\n")
4674 DEFUN (no_aggregate_address
,
4675 no_aggregate_address_cmd
,
4676 "no aggregate-address A.B.C.D/M",
4678 "Configure BGP aggregate entries\n"
4679 "Aggregate prefix\n")
4681 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
));
4684 ALIAS (no_aggregate_address
,
4685 no_aggregate_address_summary_only_cmd
,
4686 "no aggregate-address A.B.C.D/M summary-only",
4688 "Configure BGP aggregate entries\n"
4689 "Aggregate prefix\n"
4690 "Filter more specific routes from updates\n")
4692 ALIAS (no_aggregate_address
,
4693 no_aggregate_address_as_set_cmd
,
4694 "no aggregate-address A.B.C.D/M as-set",
4696 "Configure BGP aggregate entries\n"
4697 "Aggregate prefix\n"
4698 "Generate AS set path information\n")
4700 ALIAS (no_aggregate_address
,
4701 no_aggregate_address_as_set_summary_cmd
,
4702 "no aggregate-address A.B.C.D/M as-set summary-only",
4704 "Configure BGP aggregate entries\n"
4705 "Aggregate prefix\n"
4706 "Generate AS set path information\n"
4707 "Filter more specific routes from updates\n")
4709 ALIAS (no_aggregate_address
,
4710 no_aggregate_address_summary_as_set_cmd
,
4711 "no aggregate-address A.B.C.D/M summary-only as-set",
4713 "Configure BGP aggregate entries\n"
4714 "Aggregate prefix\n"
4715 "Filter more specific routes from updates\n"
4716 "Generate AS set path information\n")
4718 DEFUN (no_aggregate_address_mask
,
4719 no_aggregate_address_mask_cmd
,
4720 "no aggregate-address A.B.C.D A.B.C.D",
4722 "Configure BGP aggregate entries\n"
4723 "Aggregate address\n"
4727 char prefix_str
[BUFSIZ
];
4729 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4733 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4737 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
4740 ALIAS (no_aggregate_address_mask
,
4741 no_aggregate_address_mask_summary_only_cmd
,
4742 "no aggregate-address A.B.C.D A.B.C.D summary-only",
4744 "Configure BGP aggregate entries\n"
4745 "Aggregate address\n"
4747 "Filter more specific routes from updates\n")
4749 ALIAS (no_aggregate_address_mask
,
4750 no_aggregate_address_mask_as_set_cmd
,
4751 "no aggregate-address A.B.C.D A.B.C.D as-set",
4753 "Configure BGP aggregate entries\n"
4754 "Aggregate address\n"
4756 "Generate AS set path information\n")
4758 ALIAS (no_aggregate_address_mask
,
4759 no_aggregate_address_mask_as_set_summary_cmd
,
4760 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
4762 "Configure BGP aggregate entries\n"
4763 "Aggregate address\n"
4765 "Generate AS set path information\n"
4766 "Filter more specific routes from updates\n")
4768 ALIAS (no_aggregate_address_mask
,
4769 no_aggregate_address_mask_summary_as_set_cmd
,
4770 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
4772 "Configure BGP aggregate entries\n"
4773 "Aggregate address\n"
4775 "Filter more specific routes from updates\n"
4776 "Generate AS set path information\n")
4779 DEFUN (ipv6_aggregate_address
,
4780 ipv6_aggregate_address_cmd
,
4781 "aggregate-address X:X::X:X/M",
4782 "Configure BGP aggregate entries\n"
4783 "Aggregate prefix\n")
4785 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0, 0);
4788 DEFUN (ipv6_aggregate_address_summary_only
,
4789 ipv6_aggregate_address_summary_only_cmd
,
4790 "aggregate-address X:X::X:X/M summary-only",
4791 "Configure BGP aggregate entries\n"
4792 "Aggregate prefix\n"
4793 "Filter more specific routes from updates\n")
4795 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
4796 AGGREGATE_SUMMARY_ONLY
, 0);
4799 DEFUN (no_ipv6_aggregate_address
,
4800 no_ipv6_aggregate_address_cmd
,
4801 "no aggregate-address X:X::X:X/M",
4803 "Configure BGP aggregate entries\n"
4804 "Aggregate prefix\n")
4806 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
4809 DEFUN (no_ipv6_aggregate_address_summary_only
,
4810 no_ipv6_aggregate_address_summary_only_cmd
,
4811 "no aggregate-address X:X::X:X/M summary-only",
4813 "Configure BGP aggregate entries\n"
4814 "Aggregate prefix\n"
4815 "Filter more specific routes from updates\n")
4817 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
4820 ALIAS (ipv6_aggregate_address
,
4821 old_ipv6_aggregate_address_cmd
,
4822 "ipv6 bgp aggregate-address X:X::X:X/M",
4825 "Configure BGP aggregate entries\n"
4826 "Aggregate prefix\n")
4828 ALIAS (ipv6_aggregate_address_summary_only
,
4829 old_ipv6_aggregate_address_summary_only_cmd
,
4830 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
4833 "Configure BGP aggregate entries\n"
4834 "Aggregate prefix\n"
4835 "Filter more specific routes from updates\n")
4837 ALIAS (no_ipv6_aggregate_address
,
4838 old_no_ipv6_aggregate_address_cmd
,
4839 "no ipv6 bgp aggregate-address X:X::X:X/M",
4843 "Configure BGP aggregate entries\n"
4844 "Aggregate prefix\n")
4846 ALIAS (no_ipv6_aggregate_address_summary_only
,
4847 old_no_ipv6_aggregate_address_summary_only_cmd
,
4848 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
4852 "Configure BGP aggregate entries\n"
4853 "Aggregate prefix\n"
4854 "Filter more specific routes from updates\n")
4855 #endif /* HAVE_IPV6 */
4857 /* Redistribute route treatment. */
4859 bgp_redistribute_add (struct prefix
*p
, struct in_addr
*nexthop
,
4860 u_int32_t metric
, u_char type
)
4863 struct listnode
*node
, *nnode
;
4864 struct bgp_info
*new;
4865 struct bgp_info
*bi
;
4866 struct bgp_info info
;
4867 struct bgp_node
*bn
;
4869 struct attr attr_new
;
4870 struct attr
*new_attr
;
4874 /* Make default attribute. */
4875 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
4877 attr
.nexthop
= *nexthop
;
4880 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
4882 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
4884 afi
= family2afi (p
->family
);
4886 if (bgp
->redist
[afi
][type
])
4888 /* Copy attribute for modification. */
4891 if (bgp
->redist_metric_flag
[afi
][type
])
4892 attr_new
.med
= bgp
->redist_metric
[afi
][type
];
4894 /* Apply route-map. */
4895 if (bgp
->rmap
[afi
][type
].map
)
4897 info
.peer
= bgp
->peer_self
;
4898 info
.attr
= &attr_new
;
4900 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
);
4902 ret
= route_map_apply (bgp
->rmap
[afi
][type
].map
, p
, RMAP_BGP
,
4905 bgp
->peer_self
->rmap_type
= 0;
4907 if (ret
== RMAP_DENYMATCH
)
4909 /* Free uninterned attribute. */
4910 bgp_attr_flush (&attr_new
);
4912 /* Unintern original. */
4913 aspath_unintern (attr
.aspath
);
4914 bgp_redistribute_delete (p
, type
);
4919 bn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
4920 new_attr
= bgp_attr_intern (&attr_new
);
4922 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
4923 if (bi
->peer
== bgp
->peer_self
4924 && bi
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
4929 if (attrhash_cmp (bi
->attr
, new_attr
))
4931 bgp_attr_unintern (new_attr
);
4932 aspath_unintern (attr
.aspath
);
4933 bgp_unlock_node (bn
);
4938 /* The attribute is changed. */
4939 bgp_info_set_flag (bn
, bi
, BGP_INFO_ATTR_CHANGED
);
4941 /* Rewrite BGP route information. */
4942 bgp_aggregate_decrement (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
4943 bgp_attr_unintern (bi
->attr
);
4944 bi
->attr
= new_attr
;
4945 bi
->uptime
= time (NULL
);
4947 /* Process change. */
4948 bgp_aggregate_increment (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
4949 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
4950 bgp_unlock_node (bn
);
4951 aspath_unintern (attr
.aspath
);
4956 new = bgp_info_new ();
4958 new->sub_type
= BGP_ROUTE_REDISTRIBUTE
;
4959 new->peer
= bgp
->peer_self
;
4960 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4961 new->attr
= new_attr
;
4962 new->uptime
= time (NULL
);
4964 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
4965 bgp_info_add (bn
, new);
4966 bgp_unlock_node (bn
);
4967 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
4971 /* Unintern original. */
4972 aspath_unintern (attr
.aspath
);
4976 bgp_redistribute_delete (struct prefix
*p
, u_char type
)
4979 struct listnode
*node
, *nnode
;
4981 struct bgp_node
*rn
;
4982 struct bgp_info
*ri
;
4984 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
4986 afi
= family2afi (p
->family
);
4988 if (bgp
->redist
[afi
][type
])
4990 rn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
4992 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4993 if (ri
->peer
== bgp
->peer_self
4994 && ri
->type
== type
)
4999 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
5000 bgp_info_delete (rn
, ri
);
5001 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5003 bgp_unlock_node (rn
);
5008 /* Withdraw specified route type's route. */
5010 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
)
5012 struct bgp_node
*rn
;
5013 struct bgp_info
*ri
;
5014 struct bgp_table
*table
;
5016 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
5018 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
5020 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5021 if (ri
->peer
== bgp
->peer_self
5022 && ri
->type
== type
)
5027 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
5028 bgp_info_delete (rn
, ri
);
5029 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5034 /* Static function to display route. */
5036 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
5039 u_int32_t destination
;
5042 if (p
->family
== AF_INET
)
5044 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
5045 destination
= ntohl (p
->u
.prefix4
.s_addr
);
5047 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
5048 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
5049 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
5050 || p
->u
.prefix4
.s_addr
== 0)
5052 /* When mask is natural, mask is not displayed. */
5055 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
5058 len
= vty_out (vty
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
5063 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
5065 vty_out (vty
, "%*s", len
, " ");
5068 enum bgp_display_type
5073 /* Print the short form route status for a bgp_info */
5075 route_vty_short_status_out (struct vty
*vty
, struct bgp_info
*binfo
)
5077 /* Route status display. */
5078 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5080 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5082 else if (binfo
->suppress
)
5084 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5090 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5092 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5094 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5099 /* Internal route. */
5100 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
5106 /* called from terminal list command */
5108 route_vty_out (struct vty
*vty
, struct prefix
*p
,
5109 struct bgp_info
*binfo
, int display
, safi_t safi
)
5113 /* short status lead text */
5114 route_vty_short_status_out (vty
, binfo
);
5116 /* print prefix and mask */
5118 route_vty_out_route (p
, vty
);
5120 vty_out (vty
, "%*s", 17, " ");
5122 /* Print attribute */
5126 if (p
->family
== AF_INET
)
5128 if (safi
== SAFI_MPLS_VPN
)
5129 vty_out (vty
, "%-16s", inet_ntoa (attr
->mp_nexthop_global_in
));
5131 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5134 else if (p
->family
== AF_INET6
)
5139 len
= vty_out (vty
, "%s",
5140 inet_ntop (AF_INET6
, &attr
->mp_nexthop_global
, buf
, BUFSIZ
));
5143 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5145 vty_out (vty
, "%*s", len
, " ");
5147 #endif /* HAVE_IPV6 */
5149 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5150 vty_out (vty
, "%10d", attr
->med
);
5154 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5155 vty_out (vty
, "%7d", attr
->local_pref
);
5159 vty_out (vty
, "%7u ",attr
->weight
);
5163 aspath_print_vty (vty
, "%s ", attr
->aspath
);
5166 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5168 vty_out (vty
, "%s", VTY_NEWLINE
);
5171 /* called from terminal list command */
5173 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
,
5174 struct attr
*attr
, safi_t safi
)
5176 /* Route status display. */
5181 /* print prefix and mask */
5182 route_vty_out_route (p
, vty
);
5184 /* Print attribute */
5187 if (p
->family
== AF_INET
)
5189 if (safi
== SAFI_MPLS_VPN
)
5190 vty_out (vty
, "%-16s", inet_ntoa (attr
->mp_nexthop_global_in
));
5192 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5195 else if (p
->family
== AF_INET6
)
5200 len
= vty_out (vty
, "%s",
5201 inet_ntop (AF_INET6
, &attr
->mp_nexthop_global
, buf
, BUFSIZ
));
5204 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5206 vty_out (vty
, "%*s", len
, " ");
5208 #endif /* HAVE_IPV6 */
5210 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5211 vty_out (vty
, "%10d", attr
->med
);
5215 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5216 vty_out (vty
, "%7d", attr
->local_pref
);
5220 vty_out (vty
, "%7d ",attr
->weight
);
5224 aspath_print_vty (vty
, "%s ", attr
->aspath
);
5227 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5230 vty_out (vty
, "%s", VTY_NEWLINE
);
5234 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
5235 struct bgp_info
*binfo
, int display
, safi_t safi
)
5238 u_int32_t label
= 0;
5240 /* short status lead text */
5241 route_vty_short_status_out (vty
, binfo
);
5243 /* print prefix and mask */
5245 route_vty_out_route (p
, vty
);
5247 vty_out (vty
, "%*s", 17, " ");
5249 /* Print attribute */
5253 if (p
->family
== AF_INET
)
5255 if (safi
== SAFI_MPLS_VPN
)
5256 vty_out (vty
, "%-16s", inet_ntoa (attr
->mp_nexthop_global_in
));
5258 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5261 else if (p
->family
== AF_INET6
)
5265 if (attr
->mp_nexthop_len
== 16)
5267 inet_ntop (AF_INET6
, &attr
->mp_nexthop_global
, buf
, BUFSIZ
));
5268 else if (attr
->mp_nexthop_len
== 32)
5269 vty_out (vty
, "%s(%s)",
5270 inet_ntop (AF_INET6
, &attr
->mp_nexthop_global
, buf
, BUFSIZ
),
5271 inet_ntop (AF_INET6
, &attr
->mp_nexthop_local
, buf1
, BUFSIZ
));
5274 #endif /* HAVE_IPV6 */
5277 label
= decode_label (binfo
->tag
);
5279 vty_out (vty
, "notag/%d", label
);
5281 vty_out (vty
, "%s", VTY_NEWLINE
);
5284 /* dampening route */
5286 damp_route_vty_out (struct vty
*vty
, struct prefix
*p
,
5287 struct bgp_info
*binfo
, int display
, safi_t safi
)
5292 /* short status lead text */
5293 route_vty_short_status_out (vty
, binfo
);
5295 /* print prefix and mask */
5297 route_vty_out_route (p
, vty
);
5299 vty_out (vty
, "%*s", 17, " ");
5301 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
5304 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 34, " ");
5306 vty_out (vty
, "%*s", len
, " ");
5308 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
));
5310 /* Print attribute */
5316 aspath_print_vty (vty
, "%s ", attr
->aspath
);
5319 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5321 vty_out (vty
, "%s", VTY_NEWLINE
);
5324 #define BGP_UPTIME_LEN 25
5328 flap_route_vty_out (struct vty
*vty
, struct prefix
*p
,
5329 struct bgp_info
*binfo
, int display
, safi_t safi
)
5332 struct bgp_damp_info
*bdi
;
5333 char timebuf
[BGP_UPTIME_LEN
];
5336 bdi
= binfo
->damp_info
;
5338 /* short status lead text */
5339 route_vty_short_status_out (vty
, binfo
);
5341 /* print prefix and mask */
5343 route_vty_out_route (p
, vty
);
5345 vty_out (vty
, "%*s", 17, " ");
5347 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
5350 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 33, " ");
5352 vty_out (vty
, "%*s", len
, " ");
5354 len
= vty_out (vty
, "%d", bdi
->flap
);
5359 vty_out (vty
, "%*s ", len
, " ");
5361 vty_out (vty
, "%s ", peer_uptime (bdi
->start_time
,
5362 timebuf
, BGP_UPTIME_LEN
));
5364 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
)
5365 && ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5366 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
));
5368 vty_out (vty
, "%*s ", 8, " ");
5370 /* Print attribute */
5376 aspath_print_vty (vty
, "%s ", attr
->aspath
);
5379 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5381 vty_out (vty
, "%s", VTY_NEWLINE
);
5385 route_vty_out_detail (struct vty
*vty
, struct bgp
*bgp
, struct prefix
*p
,
5386 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
)
5388 char buf
[INET6_ADDRSTRLEN
];
5391 int sockunion_vty_out (struct vty
*, union sockunion
*);
5397 /* Line1 display AS-path, Aggregator */
5401 if (aspath_count_hops (attr
->aspath
) == 0)
5402 vty_out (vty
, "Local");
5404 aspath_print_vty (vty
, "%s", attr
->aspath
);
5407 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5408 vty_out (vty
, ", (removed)");
5409 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5410 vty_out (vty
, ", (stale)");
5411 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
5412 vty_out (vty
, ", (aggregated by %d %s)", attr
->aggregator_as
,
5413 inet_ntoa (attr
->aggregator_addr
));
5414 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
5415 vty_out (vty
, ", (Received from a RR-client)");
5416 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
5417 vty_out (vty
, ", (Received from a RS-client)");
5418 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5419 vty_out (vty
, ", (history entry)");
5420 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5421 vty_out (vty
, ", (suppressed due to dampening)");
5422 vty_out (vty
, "%s", VTY_NEWLINE
);
5424 /* Line2 display Next-hop, Neighbor, Router-id */
5425 if (p
->family
== AF_INET
)
5427 vty_out (vty
, " %s", safi
== SAFI_MPLS_VPN
?
5428 inet_ntoa (attr
->mp_nexthop_global_in
) :
5429 inet_ntoa (attr
->nexthop
));
5434 vty_out (vty
, " %s",
5435 inet_ntop (AF_INET6
, &attr
->mp_nexthop_global
,
5436 buf
, INET6_ADDRSTRLEN
));
5438 #endif /* HAVE_IPV6 */
5440 if (binfo
->peer
== bgp
->peer_self
)
5442 vty_out (vty
, " from %s ",
5443 p
->family
== AF_INET
? "0.0.0.0" : "::");
5444 vty_out (vty
, "(%s)", inet_ntoa(bgp
->router_id
));
5448 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
5449 vty_out (vty
, " (inaccessible)");
5450 else if (binfo
->igpmetric
)
5451 vty_out (vty
, " (metric %d)", binfo
->igpmetric
);
5452 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
5453 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
5454 vty_out (vty
, " (%s)", inet_ntoa (attr
->originator_id
));
5456 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
5458 vty_out (vty
, "%s", VTY_NEWLINE
);
5461 /* display nexthop local */
5462 if (attr
->mp_nexthop_len
== 32)
5464 vty_out (vty
, " (%s)%s",
5465 inet_ntop (AF_INET6
, &attr
->mp_nexthop_local
,
5466 buf
, INET6_ADDRSTRLEN
),
5469 #endif /* HAVE_IPV6 */
5471 /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */
5472 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
5474 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
5475 vty_out (vty
, ", metric %d", attr
->med
);
5477 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
5478 vty_out (vty
, ", localpref %d", attr
->local_pref
);
5480 vty_out (vty
, ", localpref %d", bgp
->default_local_pref
);
5482 if (attr
->weight
!= 0)
5483 vty_out (vty
, ", weight %d", attr
->weight
);
5485 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5486 vty_out (vty
, ", valid");
5488 if (binfo
->peer
!= bgp
->peer_self
)
5490 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
5491 vty_out (vty
, ", internal");
5493 vty_out (vty
, ", %s",
5494 (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
) ? "confed-external" : "external"));
5496 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
5497 vty_out (vty
, ", aggregated, local");
5498 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
5499 vty_out (vty
, ", sourced");
5501 vty_out (vty
, ", sourced, local");
5503 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
5504 vty_out (vty
, ", atomic-aggregate");
5506 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5507 vty_out (vty
, ", best");
5509 vty_out (vty
, "%s", VTY_NEWLINE
);
5511 /* Line 4 display Community */
5512 if (attr
->community
)
5513 vty_out (vty
, " Community: %s%s", attr
->community
->str
,
5516 /* Line 5 display Extended-community */
5517 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
5518 vty_out (vty
, " Extended Community: %s%s", attr
->ecommunity
->str
,
5521 /* Line 6 display Originator, Cluster-id */
5522 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
5523 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
5525 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
5526 vty_out (vty
, " Originator: %s", inet_ntoa (attr
->originator_id
));
5528 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
5531 vty_out (vty
, ", Cluster list: ");
5532 for (i
= 0; i
< attr
->cluster
->length
/ 4; i
++)
5533 vty_out (vty
, "%s ", inet_ntoa (attr
->cluster
->list
[i
]));
5535 vty_out (vty
, "%s", VTY_NEWLINE
);
5538 if (binfo
->damp_info
)
5539 bgp_damp_info_vty (vty
, binfo
);
5541 /* Line 7 display Uptime */
5542 vty_out (vty
, " Last update: %s", ctime (&binfo
->uptime
));
5544 vty_out (vty
, "%s", VTY_NEWLINE
);
5547 #define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,%s r RIB-failure, S Stale, R Removed%s"
5548 #define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
5549 #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
5550 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
5551 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
5555 bgp_show_type_normal
,
5556 bgp_show_type_regexp
,
5557 bgp_show_type_prefix_list
,
5558 bgp_show_type_filter_list
,
5559 bgp_show_type_route_map
,
5560 bgp_show_type_neighbor
,
5561 bgp_show_type_cidr_only
,
5562 bgp_show_type_prefix_longer
,
5563 bgp_show_type_community_all
,
5564 bgp_show_type_community
,
5565 bgp_show_type_community_exact
,
5566 bgp_show_type_community_list
,
5567 bgp_show_type_community_list_exact
,
5568 bgp_show_type_flap_statistics
,
5569 bgp_show_type_flap_address
,
5570 bgp_show_type_flap_prefix
,
5571 bgp_show_type_flap_cidr_only
,
5572 bgp_show_type_flap_regexp
,
5573 bgp_show_type_flap_filter_list
,
5574 bgp_show_type_flap_prefix_list
,
5575 bgp_show_type_flap_prefix_longer
,
5576 bgp_show_type_flap_route_map
,
5577 bgp_show_type_flap_neighbor
,
5578 bgp_show_type_dampend_paths
,
5579 bgp_show_type_damp_neighbor
5583 bgp_show_table (struct vty
*vty
, struct bgp_table
*table
, struct in_addr
*router_id
,
5584 enum bgp_show_type type
, void *output_arg
)
5586 struct bgp_info
*ri
;
5587 struct bgp_node
*rn
;
5590 unsigned long output_count
;
5592 /* This is first entry point, so reset total line. */
5595 /* Start processing of routes. */
5596 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
5597 if (rn
->info
!= NULL
)
5601 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5603 if (type
== bgp_show_type_flap_statistics
5604 || type
== bgp_show_type_flap_address
5605 || type
== bgp_show_type_flap_prefix
5606 || type
== bgp_show_type_flap_cidr_only
5607 || type
== bgp_show_type_flap_regexp
5608 || type
== bgp_show_type_flap_filter_list
5609 || type
== bgp_show_type_flap_prefix_list
5610 || type
== bgp_show_type_flap_prefix_longer
5611 || type
== bgp_show_type_flap_route_map
5612 || type
== bgp_show_type_flap_neighbor
5613 || type
== bgp_show_type_dampend_paths
5614 || type
== bgp_show_type_damp_neighbor
)
5616 if (! ri
->damp_info
)
5619 if (type
== bgp_show_type_regexp
5620 || type
== bgp_show_type_flap_regexp
)
5622 regex_t
*regex
= output_arg
;
5624 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
5627 if (type
== bgp_show_type_prefix_list
5628 || type
== bgp_show_type_flap_prefix_list
)
5630 struct prefix_list
*plist
= output_arg
;
5632 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
5635 if (type
== bgp_show_type_filter_list
5636 || type
== bgp_show_type_flap_filter_list
)
5638 struct as_list
*as_list
= output_arg
;
5640 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
5643 if (type
== bgp_show_type_route_map
5644 || type
== bgp_show_type_flap_route_map
)
5646 struct route_map
*rmap
= output_arg
;
5647 struct bgp_info binfo
;
5648 struct attr dummy_attr
;
5651 dummy_attr
= *ri
->attr
;
5652 binfo
.peer
= ri
->peer
;
5653 binfo
.attr
= &dummy_attr
;
5655 ret
= route_map_apply (rmap
, &rn
->p
, RMAP_BGP
, &binfo
);
5657 if (ret
== RMAP_DENYMATCH
)
5660 if (type
== bgp_show_type_neighbor
5661 || type
== bgp_show_type_flap_neighbor
5662 || type
== bgp_show_type_damp_neighbor
)
5664 union sockunion
*su
= output_arg
;
5666 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
5669 if (type
== bgp_show_type_cidr_only
5670 || type
== bgp_show_type_flap_cidr_only
)
5672 u_int32_t destination
;
5674 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
5675 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
5677 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
5679 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
5682 if (type
== bgp_show_type_prefix_longer
5683 || type
== bgp_show_type_flap_prefix_longer
)
5685 struct prefix
*p
= output_arg
;
5687 if (! prefix_match (p
, &rn
->p
))
5690 if (type
== bgp_show_type_community_all
)
5692 if (! ri
->attr
->community
)
5695 if (type
== bgp_show_type_community
)
5697 struct community
*com
= output_arg
;
5699 if (! ri
->attr
->community
||
5700 ! community_match (ri
->attr
->community
, com
))
5703 if (type
== bgp_show_type_community_exact
)
5705 struct community
*com
= output_arg
;
5707 if (! ri
->attr
->community
||
5708 ! community_cmp (ri
->attr
->community
, com
))
5711 if (type
== bgp_show_type_community_list
)
5713 struct community_list
*list
= output_arg
;
5715 if (! community_list_match (ri
->attr
->community
, list
))
5718 if (type
== bgp_show_type_community_list_exact
)
5720 struct community_list
*list
= output_arg
;
5722 if (! community_list_exact_match (ri
->attr
->community
, list
))
5725 if (type
== bgp_show_type_flap_address
5726 || type
== bgp_show_type_flap_prefix
)
5728 struct prefix
*p
= output_arg
;
5730 if (! prefix_match (&rn
->p
, p
))
5733 if (type
== bgp_show_type_flap_prefix
)
5734 if (p
->prefixlen
!= rn
->p
.prefixlen
)
5737 if (type
== bgp_show_type_dampend_paths
5738 || type
== bgp_show_type_damp_neighbor
)
5740 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
)
5741 || CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
5747 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id
), VTY_NEWLINE
);
5748 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
5749 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
5750 if (type
== bgp_show_type_dampend_paths
5751 || type
== bgp_show_type_damp_neighbor
)
5752 vty_out (vty
, BGP_SHOW_DAMP_HEADER
, VTY_NEWLINE
);
5753 else if (type
== bgp_show_type_flap_statistics
5754 || type
== bgp_show_type_flap_address
5755 || type
== bgp_show_type_flap_prefix
5756 || type
== bgp_show_type_flap_cidr_only
5757 || type
== bgp_show_type_flap_regexp
5758 || type
== bgp_show_type_flap_filter_list
5759 || type
== bgp_show_type_flap_prefix_list
5760 || type
== bgp_show_type_flap_prefix_longer
5761 || type
== bgp_show_type_flap_route_map
5762 || type
== bgp_show_type_flap_neighbor
)
5763 vty_out (vty
, BGP_SHOW_FLAP_HEADER
, VTY_NEWLINE
);
5765 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
5769 if (type
== bgp_show_type_dampend_paths
5770 || type
== bgp_show_type_damp_neighbor
)
5771 damp_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
5772 else if (type
== bgp_show_type_flap_statistics
5773 || type
== bgp_show_type_flap_address
5774 || type
== bgp_show_type_flap_prefix
5775 || type
== bgp_show_type_flap_cidr_only
5776 || type
== bgp_show_type_flap_regexp
5777 || type
== bgp_show_type_flap_filter_list
5778 || type
== bgp_show_type_flap_prefix_list
5779 || type
== bgp_show_type_flap_prefix_longer
5780 || type
== bgp_show_type_flap_route_map
5781 || type
== bgp_show_type_flap_neighbor
)
5782 flap_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
5784 route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
5791 /* No route is displayed */
5792 if (output_count
== 0)
5794 if (type
== bgp_show_type_normal
)
5795 vty_out (vty
, "No BGP network exists%s", VTY_NEWLINE
);
5798 vty_out (vty
, "%sTotal number of prefixes %ld%s",
5799 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
5805 bgp_show (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
5806 enum bgp_show_type type
, void *output_arg
)
5808 struct bgp_table
*table
;
5811 bgp
= bgp_get_default ();
5816 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
5821 table
= bgp
->rib
[afi
][safi
];
5823 return bgp_show_table (vty
, table
, &bgp
->router_id
, type
, output_arg
);
5826 /* Header of detailed BGP route information */
5828 route_vty_out_detail_header (struct vty
*vty
, struct bgp
*bgp
,
5829 struct bgp_node
*rn
,
5830 struct prefix_rd
*prd
, afi_t afi
, safi_t safi
)
5832 struct bgp_info
*ri
;
5835 struct listnode
*node
, *nnode
;
5836 char buf1
[INET6_ADDRSTRLEN
];
5837 char buf2
[INET6_ADDRSTRLEN
];
5842 int no_advertise
= 0;
5847 vty_out (vty
, "BGP routing table entry for %s%s%s/%d%s",
5848 (safi
== SAFI_MPLS_VPN
?
5849 prefix_rd2str (prd
, buf1
, RD_ADDRSTRLEN
) : ""),
5850 safi
== SAFI_MPLS_VPN
? ":" : "",
5851 inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
),
5852 p
->prefixlen
, VTY_NEWLINE
);
5854 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5857 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
5862 if (ri
->attr
->community
!= NULL
)
5864 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
5866 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
5868 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
5874 vty_out (vty
, "Paths: (%d available", count
);
5877 vty_out (vty
, ", best #%d", best
);
5878 if (safi
== SAFI_UNICAST
)
5879 vty_out (vty
, ", table Default-IP-Routing-Table");
5882 vty_out (vty
, ", no best path");
5884 vty_out (vty
, ", not advertised to any peer");
5886 vty_out (vty
, ", not advertised to EBGP peer");
5888 vty_out (vty
, ", not advertised outside local AS");
5890 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
5891 vty_out (vty
, ")%s", VTY_NEWLINE
);
5893 /* advertised peer */
5894 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
5896 if (bgp_adj_out_lookup (peer
, p
, afi
, safi
, rn
))
5899 vty_out (vty
, " Advertised to non peer-group peers:%s ", VTY_NEWLINE
);
5900 vty_out (vty
, " %s", sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
5905 vty_out (vty
, " Not advertised to any peer");
5906 vty_out (vty
, "%s", VTY_NEWLINE
);
5909 /* Display specified route of BGP table. */
5911 bgp_show_route_in_table (struct vty
*vty
, struct bgp
*bgp
,
5912 struct bgp_table
*rib
, const char *ip_str
,
5913 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
5919 struct prefix match
;
5920 struct bgp_node
*rn
;
5921 struct bgp_node
*rm
;
5922 struct bgp_info
*ri
;
5923 struct bgp_table
*table
;
5925 /* Check IP address argument. */
5926 ret
= str2prefix (ip_str
, &match
);
5929 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
5933 match
.family
= afi2family (afi
);
5935 if (safi
== SAFI_MPLS_VPN
)
5937 for (rn
= bgp_table_top (rib
); rn
; rn
= bgp_route_next (rn
))
5939 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
5942 if ((table
= rn
->info
) != NULL
)
5946 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
5948 if (prefix_check
&& rm
->p
.prefixlen
!= match
.prefixlen
)
5951 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
5955 route_vty_out_detail_header (vty
, bgp
, rm
, (struct prefix_rd
*)&rn
->p
,
5956 AFI_IP
, SAFI_MPLS_VPN
);
5961 route_vty_out_detail (vty
, bgp
, &rm
->p
, ri
, AFI_IP
, SAFI_MPLS_VPN
);
5971 if ((rn
= bgp_node_match (rib
, &match
)) != NULL
)
5973 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
5975 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5979 route_vty_out_detail_header (vty
, bgp
, rn
, NULL
, afi
, safi
);
5983 route_vty_out_detail (vty
, bgp
, &rn
->p
, ri
, afi
, safi
);
5991 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
5998 /* Display specified route of Main RIB */
6000 bgp_show_route (struct vty
*vty
, const char *view_name
, const char *ip_str
,
6001 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
6006 /* BGP structure lookup. */
6009 bgp
= bgp_lookup_by_name (view_name
);
6012 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
6018 bgp
= bgp_get_default ();
6021 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
6026 return bgp_show_route_in_table (vty
, bgp
, bgp
->rib
[afi
][safi
], ip_str
,
6027 afi
, safi
, prd
, prefix_check
);
6030 /* BGP route print out function. */
6038 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6041 DEFUN (show_ip_bgp_ipv4
,
6042 show_ip_bgp_ipv4_cmd
,
6043 "show ip bgp ipv4 (unicast|multicast)",
6048 "Address Family modifier\n"
6049 "Address Family modifier\n")
6051 if (strncmp (argv
[0], "m", 1) == 0)
6052 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
, bgp_show_type_normal
,
6055 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6058 DEFUN (show_ip_bgp_route
,
6059 show_ip_bgp_route_cmd
,
6060 "show ip bgp A.B.C.D",
6064 "Network in the BGP routing table to display\n")
6066 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6069 DEFUN (show_ip_bgp_ipv4_route
,
6070 show_ip_bgp_ipv4_route_cmd
,
6071 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
6076 "Address Family modifier\n"
6077 "Address Family modifier\n"
6078 "Network in the BGP routing table to display\n")
6080 if (strncmp (argv
[0], "m", 1) == 0)
6081 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0);
6083 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6086 DEFUN (show_ip_bgp_vpnv4_all_route
,
6087 show_ip_bgp_vpnv4_all_route_cmd
,
6088 "show ip bgp vpnv4 all A.B.C.D",
6092 "Display VPNv4 NLRI specific information\n"
6093 "Display information about all VPNv4 NLRIs\n"
6094 "Network in the BGP routing table to display\n")
6096 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 0);
6099 DEFUN (show_ip_bgp_vpnv4_rd_route
,
6100 show_ip_bgp_vpnv4_rd_route_cmd
,
6101 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
6105 "Display VPNv4 NLRI specific information\n"
6106 "Display information for a route distinguisher\n"
6107 "VPN Route Distinguisher\n"
6108 "Network in the BGP routing table to display\n")
6111 struct prefix_rd prd
;
6113 ret
= str2prefix_rd (argv
[0], &prd
);
6116 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
6119 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0);
6122 DEFUN (show_ip_bgp_prefix
,
6123 show_ip_bgp_prefix_cmd
,
6124 "show ip bgp A.B.C.D/M",
6128 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6130 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6133 DEFUN (show_ip_bgp_ipv4_prefix
,
6134 show_ip_bgp_ipv4_prefix_cmd
,
6135 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
6140 "Address Family modifier\n"
6141 "Address Family modifier\n"
6142 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6144 if (strncmp (argv
[0], "m", 1) == 0)
6145 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1);
6147 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6150 DEFUN (show_ip_bgp_vpnv4_all_prefix
,
6151 show_ip_bgp_vpnv4_all_prefix_cmd
,
6152 "show ip bgp vpnv4 all A.B.C.D/M",
6156 "Display VPNv4 NLRI specific information\n"
6157 "Display information about all VPNv4 NLRIs\n"
6158 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6160 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 1);
6163 DEFUN (show_ip_bgp_vpnv4_rd_prefix
,
6164 show_ip_bgp_vpnv4_rd_prefix_cmd
,
6165 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
6169 "Display VPNv4 NLRI specific information\n"
6170 "Display information for a route distinguisher\n"
6171 "VPN Route Distinguisher\n"
6172 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6175 struct prefix_rd prd
;
6177 ret
= str2prefix_rd (argv
[0], &prd
);
6180 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
6183 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 1);
6186 DEFUN (show_ip_bgp_view
,
6187 show_ip_bgp_view_cmd
,
6188 "show ip bgp view WORD",
6197 /* BGP structure lookup. */
6198 bgp
= bgp_lookup_by_name (argv
[0]);
6201 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
6205 return bgp_show (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6208 DEFUN (show_ip_bgp_view_route
,
6209 show_ip_bgp_view_route_cmd
,
6210 "show ip bgp view WORD A.B.C.D",
6216 "Network in the BGP routing table to display\n")
6218 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6221 DEFUN (show_ip_bgp_view_prefix
,
6222 show_ip_bgp_view_prefix_cmd
,
6223 "show ip bgp view WORD A.B.C.D/M",
6229 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6231 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6241 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
6253 DEFUN (show_ipv6_bgp
,
6260 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
6264 DEFUN (show_bgp_route
,
6266 "show bgp X:X::X:X",
6269 "Network in the BGP routing table to display\n")
6271 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6274 ALIAS (show_bgp_route
,
6275 show_bgp_ipv6_route_cmd
,
6276 "show bgp ipv6 X:X::X:X",
6280 "Network in the BGP routing table to display\n")
6283 DEFUN (show_ipv6_bgp_route
,
6284 show_ipv6_bgp_route_cmd
,
6285 "show ipv6 bgp X:X::X:X",
6289 "Network in the BGP routing table to display\n")
6291 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6294 DEFUN (show_bgp_prefix
,
6295 show_bgp_prefix_cmd
,
6296 "show bgp X:X::X:X/M",
6299 "IPv6 prefix <network>/<length>\n")
6301 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6304 ALIAS (show_bgp_prefix
,
6305 show_bgp_ipv6_prefix_cmd
,
6306 "show bgp ipv6 X:X::X:X/M",
6310 "IPv6 prefix <network>/<length>\n")
6313 DEFUN (show_ipv6_bgp_prefix
,
6314 show_ipv6_bgp_prefix_cmd
,
6315 "show ipv6 bgp X:X::X:X/M",
6319 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6321 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6324 DEFUN (show_bgp_view
,
6326 "show bgp view WORD",
6334 /* BGP structure lookup. */
6335 bgp
= bgp_lookup_by_name (argv
[0]);
6338 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
6342 return bgp_show (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6345 ALIAS (show_bgp_view
,
6346 show_bgp_view_ipv6_cmd
,
6347 "show bgp view WORD ipv6",
6354 DEFUN (show_bgp_view_route
,
6355 show_bgp_view_route_cmd
,
6356 "show bgp view WORD X:X::X:X",
6361 "Network in the BGP routing table to display\n")
6363 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6366 ALIAS (show_bgp_view_route
,
6367 show_bgp_view_ipv6_route_cmd
,
6368 "show bgp view WORD ipv6 X:X::X:X",
6374 "Network in the BGP routing table to display\n")
6376 DEFUN (show_bgp_view_prefix
,
6377 show_bgp_view_prefix_cmd
,
6378 "show bgp view WORD X:X::X:X/M",
6383 "IPv6 prefix <network>/<length>\n")
6385 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6388 ALIAS (show_bgp_view_prefix
,
6389 show_bgp_view_ipv6_prefix_cmd
,
6390 "show bgp view WORD ipv6 X:X::X:X/M",
6396 "IPv6 prefix <network>/<length>\n")
6399 DEFUN (show_ipv6_mbgp
,
6406 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
6411 DEFUN (show_ipv6_mbgp_route
,
6412 show_ipv6_mbgp_route_cmd
,
6413 "show ipv6 mbgp X:X::X:X",
6417 "Network in the MBGP routing table to display\n")
6419 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0);
6423 DEFUN (show_ipv6_mbgp_prefix
,
6424 show_ipv6_mbgp_prefix_cmd
,
6425 "show ipv6 mbgp X:X::X:X/M",
6429 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6431 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1);
6437 bgp_show_regexp (struct vty
*vty
, int argc
, const char **argv
, afi_t afi
,
6438 safi_t safi
, enum bgp_show_type type
)
6448 b
= buffer_new (1024);
6449 for (i
= 0; i
< argc
; i
++)
6452 buffer_putc (b
, ' ');
6455 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
6460 buffer_putstr (b
, argv
[i
]);
6462 buffer_putc (b
, '\0');
6464 regstr
= buffer_getstr (b
);
6467 regex
= bgp_regcomp (regstr
);
6468 XFREE(MTYPE_TMP
, regstr
);
6471 vty_out (vty
, "Can't compile regexp %s%s", argv
[0],
6476 rc
= bgp_show (vty
, NULL
, afi
, safi
, type
, regex
);
6477 bgp_regex_free (regex
);
6481 DEFUN (show_ip_bgp_regexp
,
6482 show_ip_bgp_regexp_cmd
,
6483 "show ip bgp regexp .LINE",
6487 "Display routes matching the AS path regular expression\n"
6488 "A regular-expression to match the BGP AS paths\n")
6490 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
6491 bgp_show_type_regexp
);
6494 DEFUN (show_ip_bgp_flap_regexp
,
6495 show_ip_bgp_flap_regexp_cmd
,
6496 "show ip bgp flap-statistics regexp .LINE",
6500 "Display flap statistics of routes\n"
6501 "Display routes matching the AS path regular expression\n"
6502 "A regular-expression to match the BGP AS paths\n")
6504 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
6505 bgp_show_type_flap_regexp
);
6508 DEFUN (show_ip_bgp_ipv4_regexp
,
6509 show_ip_bgp_ipv4_regexp_cmd
,
6510 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
6515 "Address Family modifier\n"
6516 "Address Family modifier\n"
6517 "Display routes matching the AS path regular expression\n"
6518 "A regular-expression to match the BGP AS paths\n")
6520 if (strncmp (argv
[0], "m", 1) == 0)
6521 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_MULTICAST
,
6522 bgp_show_type_regexp
);
6524 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
6525 bgp_show_type_regexp
);
6529 DEFUN (show_bgp_regexp
,
6530 show_bgp_regexp_cmd
,
6531 "show bgp regexp .LINE",
6534 "Display routes matching the AS path regular expression\n"
6535 "A regular-expression to match the BGP AS paths\n")
6537 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
6538 bgp_show_type_regexp
);
6541 ALIAS (show_bgp_regexp
,
6542 show_bgp_ipv6_regexp_cmd
,
6543 "show bgp ipv6 regexp .LINE",
6547 "Display routes matching the AS path regular expression\n"
6548 "A regular-expression to match the BGP AS paths\n")
6551 DEFUN (show_ipv6_bgp_regexp
,
6552 show_ipv6_bgp_regexp_cmd
,
6553 "show ipv6 bgp regexp .LINE",
6557 "Display routes matching the AS path regular expression\n"
6558 "A regular-expression to match the BGP AS paths\n")
6560 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
6561 bgp_show_type_regexp
);
6565 DEFUN (show_ipv6_mbgp_regexp
,
6566 show_ipv6_mbgp_regexp_cmd
,
6567 "show ipv6 mbgp regexp .LINE",
6571 "Display routes matching the AS path regular expression\n"
6572 "A regular-expression to match the MBGP AS paths\n")
6574 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
,
6575 bgp_show_type_regexp
);
6577 #endif /* HAVE_IPV6 */
6580 bgp_show_prefix_list (struct vty
*vty
, const char *prefix_list_str
, afi_t afi
,
6581 safi_t safi
, enum bgp_show_type type
)
6583 struct prefix_list
*plist
;
6585 plist
= prefix_list_lookup (afi
, prefix_list_str
);
6588 vty_out (vty
, "%% %s is not a valid prefix-list name%s",
6589 prefix_list_str
, VTY_NEWLINE
);
6593 return bgp_show (vty
, NULL
, afi
, safi
, type
, plist
);
6596 DEFUN (show_ip_bgp_prefix_list
,
6597 show_ip_bgp_prefix_list_cmd
,
6598 "show ip bgp prefix-list WORD",
6602 "Display routes conforming to the prefix-list\n"
6603 "IP prefix-list name\n")
6605 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
6606 bgp_show_type_prefix_list
);
6609 DEFUN (show_ip_bgp_flap_prefix_list
,
6610 show_ip_bgp_flap_prefix_list_cmd
,
6611 "show ip bgp flap-statistics prefix-list WORD",
6615 "Display flap statistics of routes\n"
6616 "Display routes conforming to the prefix-list\n"
6617 "IP prefix-list name\n")
6619 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
6620 bgp_show_type_flap_prefix_list
);
6623 DEFUN (show_ip_bgp_ipv4_prefix_list
,
6624 show_ip_bgp_ipv4_prefix_list_cmd
,
6625 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
6630 "Address Family modifier\n"
6631 "Address Family modifier\n"
6632 "Display routes conforming to the prefix-list\n"
6633 "IP prefix-list name\n")
6635 if (strncmp (argv
[0], "m", 1) == 0)
6636 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
6637 bgp_show_type_prefix_list
);
6639 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
6640 bgp_show_type_prefix_list
);
6644 DEFUN (show_bgp_prefix_list
,
6645 show_bgp_prefix_list_cmd
,
6646 "show bgp prefix-list WORD",
6649 "Display routes conforming to the prefix-list\n"
6650 "IPv6 prefix-list name\n")
6652 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
6653 bgp_show_type_prefix_list
);
6656 ALIAS (show_bgp_prefix_list
,
6657 show_bgp_ipv6_prefix_list_cmd
,
6658 "show bgp ipv6 prefix-list WORD",
6662 "Display routes conforming to the prefix-list\n"
6663 "IPv6 prefix-list name\n")
6666 DEFUN (show_ipv6_bgp_prefix_list
,
6667 show_ipv6_bgp_prefix_list_cmd
,
6668 "show ipv6 bgp prefix-list WORD",
6672 "Display routes matching the prefix-list\n"
6673 "IPv6 prefix-list name\n")
6675 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
6676 bgp_show_type_prefix_list
);
6680 DEFUN (show_ipv6_mbgp_prefix_list
,
6681 show_ipv6_mbgp_prefix_list_cmd
,
6682 "show ipv6 mbgp prefix-list WORD",
6686 "Display routes matching the prefix-list\n"
6687 "IPv6 prefix-list name\n")
6689 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
6690 bgp_show_type_prefix_list
);
6692 #endif /* HAVE_IPV6 */
6695 bgp_show_filter_list (struct vty
*vty
, const char *filter
, afi_t afi
,
6696 safi_t safi
, enum bgp_show_type type
)
6698 struct as_list
*as_list
;
6700 as_list
= as_list_lookup (filter
);
6701 if (as_list
== NULL
)
6703 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
6707 return bgp_show (vty
, NULL
, afi
, safi
, type
, as_list
);
6710 DEFUN (show_ip_bgp_filter_list
,
6711 show_ip_bgp_filter_list_cmd
,
6712 "show ip bgp filter-list WORD",
6716 "Display routes conforming to the filter-list\n"
6717 "Regular expression access list name\n")
6719 return bgp_show_filter_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
6720 bgp_show_type_filter_list
);
6723 DEFUN (show_ip_bgp_flap_filter_list
,
6724 show_ip_bgp_flap_filter_list_cmd
,
6725 "show ip bgp flap-statistics filter-list WORD",
6729 "Display flap statistics of routes\n"
6730 "Display routes conforming to the filter-list\n"
6731 "Regular expression access list name\n")
6733 return bgp_show_filter_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
6734 bgp_show_type_flap_filter_list
);
6737 DEFUN (show_ip_bgp_ipv4_filter_list
,
6738 show_ip_bgp_ipv4_filter_list_cmd
,
6739 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
6744 "Address Family modifier\n"
6745 "Address Family modifier\n"
6746 "Display routes conforming to the filter-list\n"
6747 "Regular expression access list name\n")
6749 if (strncmp (argv
[0], "m", 1) == 0)
6750 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
6751 bgp_show_type_filter_list
);
6753 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
6754 bgp_show_type_filter_list
);
6758 DEFUN (show_bgp_filter_list
,
6759 show_bgp_filter_list_cmd
,
6760 "show bgp filter-list WORD",
6763 "Display routes conforming to the filter-list\n"
6764 "Regular expression access list name\n")
6766 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
6767 bgp_show_type_filter_list
);
6770 ALIAS (show_bgp_filter_list
,
6771 show_bgp_ipv6_filter_list_cmd
,
6772 "show bgp ipv6 filter-list WORD",
6776 "Display routes conforming to the filter-list\n"
6777 "Regular expression access list name\n")
6780 DEFUN (show_ipv6_bgp_filter_list
,
6781 show_ipv6_bgp_filter_list_cmd
,
6782 "show ipv6 bgp filter-list WORD",
6786 "Display routes conforming to the filter-list\n"
6787 "Regular expression access list name\n")
6789 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
6790 bgp_show_type_filter_list
);
6794 DEFUN (show_ipv6_mbgp_filter_list
,
6795 show_ipv6_mbgp_filter_list_cmd
,
6796 "show ipv6 mbgp filter-list WORD",
6800 "Display routes conforming to the filter-list\n"
6801 "Regular expression access list name\n")
6803 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
6804 bgp_show_type_filter_list
);
6806 #endif /* HAVE_IPV6 */
6809 bgp_show_route_map (struct vty
*vty
, const char *rmap_str
, afi_t afi
,
6810 safi_t safi
, enum bgp_show_type type
)
6812 struct route_map
*rmap
;
6814 rmap
= route_map_lookup_by_name (rmap_str
);
6817 vty_out (vty
, "%% %s is not a valid route-map name%s",
6818 rmap_str
, VTY_NEWLINE
);
6822 return bgp_show (vty
, NULL
, afi
, safi
, type
, rmap
);
6825 DEFUN (show_ip_bgp_route_map
,
6826 show_ip_bgp_route_map_cmd
,
6827 "show ip bgp route-map WORD",
6831 "Display routes matching the route-map\n"
6832 "A route-map to match on\n")
6834 return bgp_show_route_map (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
6835 bgp_show_type_route_map
);
6838 DEFUN (show_ip_bgp_flap_route_map
,
6839 show_ip_bgp_flap_route_map_cmd
,
6840 "show ip bgp flap-statistics route-map WORD",
6844 "Display flap statistics of routes\n"
6845 "Display routes matching the route-map\n"
6846 "A route-map to match on\n")
6848 return bgp_show_route_map (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
6849 bgp_show_type_flap_route_map
);
6852 DEFUN (show_ip_bgp_ipv4_route_map
,
6853 show_ip_bgp_ipv4_route_map_cmd
,
6854 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
6859 "Address Family modifier\n"
6860 "Address Family modifier\n"
6861 "Display routes matching the route-map\n"
6862 "A route-map to match on\n")
6864 if (strncmp (argv
[0], "m", 1) == 0)
6865 return bgp_show_route_map (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
6866 bgp_show_type_route_map
);
6868 return bgp_show_route_map (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
6869 bgp_show_type_route_map
);
6872 DEFUN (show_bgp_route_map
,
6873 show_bgp_route_map_cmd
,
6874 "show bgp route-map WORD",
6877 "Display routes matching the route-map\n"
6878 "A route-map to match on\n")
6880 return bgp_show_route_map (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
6881 bgp_show_type_route_map
);
6884 ALIAS (show_bgp_route_map
,
6885 show_bgp_ipv6_route_map_cmd
,
6886 "show bgp ipv6 route-map WORD",
6890 "Display routes matching the route-map\n"
6891 "A route-map to match on\n")
6893 DEFUN (show_ip_bgp_cidr_only
,
6894 show_ip_bgp_cidr_only_cmd
,
6895 "show ip bgp cidr-only",
6899 "Display only routes with non-natural netmasks\n")
6901 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
6902 bgp_show_type_cidr_only
, NULL
);
6905 DEFUN (show_ip_bgp_flap_cidr_only
,
6906 show_ip_bgp_flap_cidr_only_cmd
,
6907 "show ip bgp flap-statistics cidr-only",
6911 "Display flap statistics of routes\n"
6912 "Display only routes with non-natural netmasks\n")
6914 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
6915 bgp_show_type_flap_cidr_only
, NULL
);
6918 DEFUN (show_ip_bgp_ipv4_cidr_only
,
6919 show_ip_bgp_ipv4_cidr_only_cmd
,
6920 "show ip bgp ipv4 (unicast|multicast) cidr-only",
6925 "Address Family modifier\n"
6926 "Address Family modifier\n"
6927 "Display only routes with non-natural netmasks\n")
6929 if (strncmp (argv
[0], "m", 1) == 0)
6930 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
6931 bgp_show_type_cidr_only
, NULL
);
6933 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
6934 bgp_show_type_cidr_only
, NULL
);
6937 DEFUN (show_ip_bgp_community_all
,
6938 show_ip_bgp_community_all_cmd
,
6939 "show ip bgp community",
6943 "Display routes matching the communities\n")
6945 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
6946 bgp_show_type_community_all
, NULL
);
6949 DEFUN (show_ip_bgp_ipv4_community_all
,
6950 show_ip_bgp_ipv4_community_all_cmd
,
6951 "show ip bgp ipv4 (unicast|multicast) community",
6956 "Address Family modifier\n"
6957 "Address Family modifier\n"
6958 "Display routes matching the communities\n")
6960 if (strncmp (argv
[0], "m", 1) == 0)
6961 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
6962 bgp_show_type_community_all
, NULL
);
6964 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
6965 bgp_show_type_community_all
, NULL
);
6969 DEFUN (show_bgp_community_all
,
6970 show_bgp_community_all_cmd
,
6971 "show bgp community",
6974 "Display routes matching the communities\n")
6976 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
6977 bgp_show_type_community_all
, NULL
);
6980 ALIAS (show_bgp_community_all
,
6981 show_bgp_ipv6_community_all_cmd
,
6982 "show bgp ipv6 community",
6986 "Display routes matching the communities\n")
6989 DEFUN (show_ipv6_bgp_community_all
,
6990 show_ipv6_bgp_community_all_cmd
,
6991 "show ipv6 bgp community",
6995 "Display routes matching the communities\n")
6997 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
6998 bgp_show_type_community_all
, NULL
);
7002 DEFUN (show_ipv6_mbgp_community_all
,
7003 show_ipv6_mbgp_community_all_cmd
,
7004 "show ipv6 mbgp community",
7008 "Display routes matching the communities\n")
7010 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
7011 bgp_show_type_community_all
, NULL
);
7013 #endif /* HAVE_IPV6 */
7016 bgp_show_community (struct vty
*vty
, int argc
, const char **argv
, int exact
,
7017 u_int16_t afi
, u_char safi
)
7019 struct community
*com
;
7025 b
= buffer_new (1024);
7026 for (i
= 0; i
< argc
; i
++)
7029 buffer_putc (b
, ' ');
7032 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
7037 buffer_putstr (b
, argv
[i
]);
7039 buffer_putc (b
, '\0');
7041 str
= buffer_getstr (b
);
7044 com
= community_str2com (str
);
7045 XFREE (MTYPE_TMP
, str
);
7048 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
7052 return bgp_show (vty
, NULL
, afi
, safi
,
7053 (exact
? bgp_show_type_community_exact
:
7054 bgp_show_type_community
), com
);
7057 DEFUN (show_ip_bgp_community
,
7058 show_ip_bgp_community_cmd
,
7059 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
7063 "Display routes matching the communities\n"
7064 "community number\n"
7065 "Do not send outside local AS (well-known community)\n"
7066 "Do not advertise to any peer (well-known community)\n"
7067 "Do not export to next AS (well-known community)\n")
7069 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
7072 ALIAS (show_ip_bgp_community
,
7073 show_ip_bgp_community2_cmd
,
7074 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7078 "Display routes matching the communities\n"
7079 "community number\n"
7080 "Do not send outside local AS (well-known community)\n"
7081 "Do not advertise to any peer (well-known community)\n"
7082 "Do not export to next AS (well-known community)\n"
7083 "community number\n"
7084 "Do not send outside local AS (well-known community)\n"
7085 "Do not advertise to any peer (well-known community)\n"
7086 "Do not export to next AS (well-known community)\n")
7088 ALIAS (show_ip_bgp_community
,
7089 show_ip_bgp_community3_cmd
,
7090 "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)",
7094 "Display routes matching the communities\n"
7095 "community number\n"
7096 "Do not send outside local AS (well-known community)\n"
7097 "Do not advertise to any peer (well-known community)\n"
7098 "Do not export to next AS (well-known community)\n"
7099 "community number\n"
7100 "Do not send outside local AS (well-known community)\n"
7101 "Do not advertise to any peer (well-known community)\n"
7102 "Do not export to next AS (well-known community)\n"
7103 "community number\n"
7104 "Do not send outside local AS (well-known community)\n"
7105 "Do not advertise to any peer (well-known community)\n"
7106 "Do not export to next AS (well-known community)\n")
7108 ALIAS (show_ip_bgp_community
,
7109 show_ip_bgp_community4_cmd
,
7110 "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)",
7114 "Display routes matching the communities\n"
7115 "community number\n"
7116 "Do not send outside local AS (well-known community)\n"
7117 "Do not advertise to any peer (well-known community)\n"
7118 "Do not export to next AS (well-known community)\n"
7119 "community number\n"
7120 "Do not send outside local AS (well-known community)\n"
7121 "Do not advertise to any peer (well-known community)\n"
7122 "Do not export to next AS (well-known community)\n"
7123 "community number\n"
7124 "Do not send outside local AS (well-known community)\n"
7125 "Do not advertise to any peer (well-known community)\n"
7126 "Do not export to next AS (well-known community)\n"
7127 "community number\n"
7128 "Do not send outside local AS (well-known community)\n"
7129 "Do not advertise to any peer (well-known community)\n"
7130 "Do not export to next AS (well-known community)\n")
7132 DEFUN (show_ip_bgp_ipv4_community
,
7133 show_ip_bgp_ipv4_community_cmd
,
7134 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
7139 "Address Family modifier\n"
7140 "Address Family modifier\n"
7141 "Display routes matching the communities\n"
7142 "community number\n"
7143 "Do not send outside local AS (well-known community)\n"
7144 "Do not advertise to any peer (well-known community)\n"
7145 "Do not export to next AS (well-known community)\n")
7147 if (strncmp (argv
[0], "m", 1) == 0)
7148 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_MULTICAST
);
7150 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
7153 ALIAS (show_ip_bgp_ipv4_community
,
7154 show_ip_bgp_ipv4_community2_cmd
,
7155 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7160 "Address Family modifier\n"
7161 "Address Family modifier\n"
7162 "Display routes matching the communities\n"
7163 "community number\n"
7164 "Do not send outside local AS (well-known community)\n"
7165 "Do not advertise to any peer (well-known community)\n"
7166 "Do not export to next AS (well-known community)\n"
7167 "community number\n"
7168 "Do not send outside local AS (well-known community)\n"
7169 "Do not advertise to any peer (well-known community)\n"
7170 "Do not export to next AS (well-known community)\n")
7172 ALIAS (show_ip_bgp_ipv4_community
,
7173 show_ip_bgp_ipv4_community3_cmd
,
7174 "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)",
7179 "Address Family modifier\n"
7180 "Address Family modifier\n"
7181 "Display routes matching the communities\n"
7182 "community number\n"
7183 "Do not send outside local AS (well-known community)\n"
7184 "Do not advertise to any peer (well-known community)\n"
7185 "Do not export to next AS (well-known community)\n"
7186 "community number\n"
7187 "Do not send outside local AS (well-known community)\n"
7188 "Do not advertise to any peer (well-known community)\n"
7189 "Do not export to next AS (well-known community)\n"
7190 "community number\n"
7191 "Do not send outside local AS (well-known community)\n"
7192 "Do not advertise to any peer (well-known community)\n"
7193 "Do not export to next AS (well-known community)\n")
7195 ALIAS (show_ip_bgp_ipv4_community
,
7196 show_ip_bgp_ipv4_community4_cmd
,
7197 "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)",
7202 "Address Family modifier\n"
7203 "Address Family modifier\n"
7204 "Display routes matching the communities\n"
7205 "community number\n"
7206 "Do not send outside local AS (well-known community)\n"
7207 "Do not advertise to any peer (well-known community)\n"
7208 "Do not export to next AS (well-known community)\n"
7209 "community number\n"
7210 "Do not send outside local AS (well-known community)\n"
7211 "Do not advertise to any peer (well-known community)\n"
7212 "Do not export to next AS (well-known community)\n"
7213 "community number\n"
7214 "Do not send outside local AS (well-known community)\n"
7215 "Do not advertise to any peer (well-known community)\n"
7216 "Do not export to next AS (well-known community)\n"
7217 "community number\n"
7218 "Do not send outside local AS (well-known community)\n"
7219 "Do not advertise to any peer (well-known community)\n"
7220 "Do not export to next AS (well-known community)\n")
7222 DEFUN (show_ip_bgp_community_exact
,
7223 show_ip_bgp_community_exact_cmd
,
7224 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7228 "Display routes matching the communities\n"
7229 "community number\n"
7230 "Do not send outside local AS (well-known community)\n"
7231 "Do not advertise to any peer (well-known community)\n"
7232 "Do not export to next AS (well-known community)\n"
7233 "Exact match of the communities")
7235 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
7238 ALIAS (show_ip_bgp_community_exact
,
7239 show_ip_bgp_community2_exact_cmd
,
7240 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7244 "Display routes matching the communities\n"
7245 "community number\n"
7246 "Do not send outside local AS (well-known community)\n"
7247 "Do not advertise to any peer (well-known community)\n"
7248 "Do not export to next AS (well-known community)\n"
7249 "community number\n"
7250 "Do not send outside local AS (well-known community)\n"
7251 "Do not advertise to any peer (well-known community)\n"
7252 "Do not export to next AS (well-known community)\n"
7253 "Exact match of the communities")
7255 ALIAS (show_ip_bgp_community_exact
,
7256 show_ip_bgp_community3_exact_cmd
,
7257 "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",
7261 "Display routes matching the communities\n"
7262 "community number\n"
7263 "Do not send outside local AS (well-known community)\n"
7264 "Do not advertise to any peer (well-known community)\n"
7265 "Do not export to next AS (well-known community)\n"
7266 "community number\n"
7267 "Do not send outside local AS (well-known community)\n"
7268 "Do not advertise to any peer (well-known community)\n"
7269 "Do not export to next AS (well-known community)\n"
7270 "community number\n"
7271 "Do not send outside local AS (well-known community)\n"
7272 "Do not advertise to any peer (well-known community)\n"
7273 "Do not export to next AS (well-known community)\n"
7274 "Exact match of the communities")
7276 ALIAS (show_ip_bgp_community_exact
,
7277 show_ip_bgp_community4_exact_cmd
,
7278 "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",
7282 "Display routes matching the communities\n"
7283 "community number\n"
7284 "Do not send outside local AS (well-known community)\n"
7285 "Do not advertise to any peer (well-known community)\n"
7286 "Do not export to next AS (well-known community)\n"
7287 "community number\n"
7288 "Do not send outside local AS (well-known community)\n"
7289 "Do not advertise to any peer (well-known community)\n"
7290 "Do not export to next AS (well-known community)\n"
7291 "community number\n"
7292 "Do not send outside local AS (well-known community)\n"
7293 "Do not advertise to any peer (well-known community)\n"
7294 "Do not export to next AS (well-known community)\n"
7295 "community number\n"
7296 "Do not send outside local AS (well-known community)\n"
7297 "Do not advertise to any peer (well-known community)\n"
7298 "Do not export to next AS (well-known community)\n"
7299 "Exact match of the communities")
7301 DEFUN (show_ip_bgp_ipv4_community_exact
,
7302 show_ip_bgp_ipv4_community_exact_cmd
,
7303 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7308 "Address Family modifier\n"
7309 "Address Family modifier\n"
7310 "Display routes matching the communities\n"
7311 "community number\n"
7312 "Do not send outside local AS (well-known community)\n"
7313 "Do not advertise to any peer (well-known community)\n"
7314 "Do not export to next AS (well-known community)\n"
7315 "Exact match of the communities")
7317 if (strncmp (argv
[0], "m", 1) == 0)
7318 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_MULTICAST
);
7320 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
7323 ALIAS (show_ip_bgp_ipv4_community_exact
,
7324 show_ip_bgp_ipv4_community2_exact_cmd
,
7325 "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",
7330 "Address Family modifier\n"
7331 "Address Family modifier\n"
7332 "Display routes matching the communities\n"
7333 "community number\n"
7334 "Do not send outside local AS (well-known community)\n"
7335 "Do not advertise to any peer (well-known community)\n"
7336 "Do not export to next AS (well-known community)\n"
7337 "community number\n"
7338 "Do not send outside local AS (well-known community)\n"
7339 "Do not advertise to any peer (well-known community)\n"
7340 "Do not export to next AS (well-known community)\n"
7341 "Exact match of the communities")
7343 ALIAS (show_ip_bgp_ipv4_community_exact
,
7344 show_ip_bgp_ipv4_community3_exact_cmd
,
7345 "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",
7350 "Address Family modifier\n"
7351 "Address Family modifier\n"
7352 "Display routes matching the communities\n"
7353 "community number\n"
7354 "Do not send outside local AS (well-known community)\n"
7355 "Do not advertise to any peer (well-known community)\n"
7356 "Do not export to next AS (well-known community)\n"
7357 "community number\n"
7358 "Do not send outside local AS (well-known community)\n"
7359 "Do not advertise to any peer (well-known community)\n"
7360 "Do not export to next AS (well-known community)\n"
7361 "community number\n"
7362 "Do not send outside local AS (well-known community)\n"
7363 "Do not advertise to any peer (well-known community)\n"
7364 "Do not export to next AS (well-known community)\n"
7365 "Exact match of the communities")
7367 ALIAS (show_ip_bgp_ipv4_community_exact
,
7368 show_ip_bgp_ipv4_community4_exact_cmd
,
7369 "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",
7374 "Address Family modifier\n"
7375 "Address Family modifier\n"
7376 "Display routes matching the communities\n"
7377 "community number\n"
7378 "Do not send outside local AS (well-known community)\n"
7379 "Do not advertise to any peer (well-known community)\n"
7380 "Do not export to next AS (well-known community)\n"
7381 "community number\n"
7382 "Do not send outside local AS (well-known community)\n"
7383 "Do not advertise to any peer (well-known community)\n"
7384 "Do not export to next AS (well-known community)\n"
7385 "community number\n"
7386 "Do not send outside local AS (well-known community)\n"
7387 "Do not advertise to any peer (well-known community)\n"
7388 "Do not export to next AS (well-known community)\n"
7389 "community number\n"
7390 "Do not send outside local AS (well-known community)\n"
7391 "Do not advertise to any peer (well-known community)\n"
7392 "Do not export to next AS (well-known community)\n"
7393 "Exact match of the communities")
7396 DEFUN (show_bgp_community
,
7397 show_bgp_community_cmd
,
7398 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
7401 "Display routes matching the communities\n"
7402 "community number\n"
7403 "Do not send outside local AS (well-known community)\n"
7404 "Do not advertise to any peer (well-known community)\n"
7405 "Do not export to next AS (well-known community)\n")
7407 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
7410 ALIAS (show_bgp_community
,
7411 show_bgp_ipv6_community_cmd
,
7412 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
7416 "Display routes matching the communities\n"
7417 "community number\n"
7418 "Do not send outside local AS (well-known community)\n"
7419 "Do not advertise to any peer (well-known community)\n"
7420 "Do not export to next AS (well-known community)\n")
7422 ALIAS (show_bgp_community
,
7423 show_bgp_community2_cmd
,
7424 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7427 "Display routes matching the communities\n"
7428 "community number\n"
7429 "Do not send outside local AS (well-known community)\n"
7430 "Do not advertise to any peer (well-known community)\n"
7431 "Do not export to next AS (well-known community)\n"
7432 "community number\n"
7433 "Do not send outside local AS (well-known community)\n"
7434 "Do not advertise to any peer (well-known community)\n"
7435 "Do not export to next AS (well-known community)\n")
7437 ALIAS (show_bgp_community
,
7438 show_bgp_ipv6_community2_cmd
,
7439 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7443 "Display routes matching the communities\n"
7444 "community number\n"
7445 "Do not send outside local AS (well-known community)\n"
7446 "Do not advertise to any peer (well-known community)\n"
7447 "Do not export to next AS (well-known community)\n"
7448 "community number\n"
7449 "Do not send outside local AS (well-known community)\n"
7450 "Do not advertise to any peer (well-known community)\n"
7451 "Do not export to next AS (well-known community)\n")
7453 ALIAS (show_bgp_community
,
7454 show_bgp_community3_cmd
,
7455 "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)",
7458 "Display routes matching the communities\n"
7459 "community number\n"
7460 "Do not send outside local AS (well-known community)\n"
7461 "Do not advertise to any peer (well-known community)\n"
7462 "Do not export to next AS (well-known community)\n"
7463 "community number\n"
7464 "Do not send outside local AS (well-known community)\n"
7465 "Do not advertise to any peer (well-known community)\n"
7466 "Do not export to next AS (well-known community)\n"
7467 "community number\n"
7468 "Do not send outside local AS (well-known community)\n"
7469 "Do not advertise to any peer (well-known community)\n"
7470 "Do not export to next AS (well-known community)\n")
7472 ALIAS (show_bgp_community
,
7473 show_bgp_ipv6_community3_cmd
,
7474 "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)",
7478 "Display routes matching the communities\n"
7479 "community number\n"
7480 "Do not send outside local AS (well-known community)\n"
7481 "Do not advertise to any peer (well-known community)\n"
7482 "Do not export to next AS (well-known community)\n"
7483 "community number\n"
7484 "Do not send outside local AS (well-known community)\n"
7485 "Do not advertise to any peer (well-known community)\n"
7486 "Do not export to next AS (well-known community)\n"
7487 "community number\n"
7488 "Do not send outside local AS (well-known community)\n"
7489 "Do not advertise to any peer (well-known community)\n"
7490 "Do not export to next AS (well-known community)\n")
7492 ALIAS (show_bgp_community
,
7493 show_bgp_community4_cmd
,
7494 "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)",
7497 "Display routes matching the communities\n"
7498 "community number\n"
7499 "Do not send outside local AS (well-known community)\n"
7500 "Do not advertise to any peer (well-known community)\n"
7501 "Do not export to next AS (well-known community)\n"
7502 "community number\n"
7503 "Do not send outside local AS (well-known community)\n"
7504 "Do not advertise to any peer (well-known community)\n"
7505 "Do not export to next AS (well-known community)\n"
7506 "community number\n"
7507 "Do not send outside local AS (well-known community)\n"
7508 "Do not advertise to any peer (well-known community)\n"
7509 "Do not export to next AS (well-known community)\n"
7510 "community number\n"
7511 "Do not send outside local AS (well-known community)\n"
7512 "Do not advertise to any peer (well-known community)\n"
7513 "Do not export to next AS (well-known community)\n")
7515 ALIAS (show_bgp_community
,
7516 show_bgp_ipv6_community4_cmd
,
7517 "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)",
7521 "Display routes matching the communities\n"
7522 "community number\n"
7523 "Do not send outside local AS (well-known community)\n"
7524 "Do not advertise to any peer (well-known community)\n"
7525 "Do not export to next AS (well-known community)\n"
7526 "community number\n"
7527 "Do not send outside local AS (well-known community)\n"
7528 "Do not advertise to any peer (well-known community)\n"
7529 "Do not export to next AS (well-known community)\n"
7530 "community number\n"
7531 "Do not send outside local AS (well-known community)\n"
7532 "Do not advertise to any peer (well-known community)\n"
7533 "Do not export to next AS (well-known community)\n"
7534 "community number\n"
7535 "Do not send outside local AS (well-known community)\n"
7536 "Do not advertise to any peer (well-known community)\n"
7537 "Do not export to next AS (well-known community)\n")
7540 DEFUN (show_ipv6_bgp_community
,
7541 show_ipv6_bgp_community_cmd
,
7542 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
7546 "Display routes matching the communities\n"
7547 "community number\n"
7548 "Do not send outside local AS (well-known community)\n"
7549 "Do not advertise to any peer (well-known community)\n"
7550 "Do not export to next AS (well-known community)\n")
7552 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
7556 ALIAS (show_ipv6_bgp_community
,
7557 show_ipv6_bgp_community2_cmd
,
7558 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7562 "Display routes matching the communities\n"
7563 "community number\n"
7564 "Do not send outside local AS (well-known community)\n"
7565 "Do not advertise to any peer (well-known community)\n"
7566 "Do not export to next AS (well-known community)\n"
7567 "community number\n"
7568 "Do not send outside local AS (well-known community)\n"
7569 "Do not advertise to any peer (well-known community)\n"
7570 "Do not export to next AS (well-known community)\n")
7573 ALIAS (show_ipv6_bgp_community
,
7574 show_ipv6_bgp_community3_cmd
,
7575 "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)",
7579 "Display routes matching the communities\n"
7580 "community number\n"
7581 "Do not send outside local AS (well-known community)\n"
7582 "Do not advertise to any peer (well-known community)\n"
7583 "Do not export to next AS (well-known community)\n"
7584 "community number\n"
7585 "Do not send outside local AS (well-known community)\n"
7586 "Do not advertise to any peer (well-known community)\n"
7587 "Do not export to next AS (well-known community)\n"
7588 "community number\n"
7589 "Do not send outside local AS (well-known community)\n"
7590 "Do not advertise to any peer (well-known community)\n"
7591 "Do not export to next AS (well-known community)\n")
7594 ALIAS (show_ipv6_bgp_community
,
7595 show_ipv6_bgp_community4_cmd
,
7596 "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)",
7600 "Display routes matching the communities\n"
7601 "community number\n"
7602 "Do not send outside local AS (well-known community)\n"
7603 "Do not advertise to any peer (well-known community)\n"
7604 "Do not export to next AS (well-known community)\n"
7605 "community number\n"
7606 "Do not send outside local AS (well-known community)\n"
7607 "Do not advertise to any peer (well-known community)\n"
7608 "Do not export to next AS (well-known community)\n"
7609 "community number\n"
7610 "Do not send outside local AS (well-known community)\n"
7611 "Do not advertise to any peer (well-known community)\n"
7612 "Do not export to next AS (well-known community)\n"
7613 "community number\n"
7614 "Do not send outside local AS (well-known community)\n"
7615 "Do not advertise to any peer (well-known community)\n"
7616 "Do not export to next AS (well-known community)\n")
7618 DEFUN (show_bgp_community_exact
,
7619 show_bgp_community_exact_cmd
,
7620 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7623 "Display routes matching the communities\n"
7624 "community number\n"
7625 "Do not send outside local AS (well-known community)\n"
7626 "Do not advertise to any peer (well-known community)\n"
7627 "Do not export to next AS (well-known community)\n"
7628 "Exact match of the communities")
7630 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
7633 ALIAS (show_bgp_community_exact
,
7634 show_bgp_ipv6_community_exact_cmd
,
7635 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7639 "Display routes matching the communities\n"
7640 "community number\n"
7641 "Do not send outside local AS (well-known community)\n"
7642 "Do not advertise to any peer (well-known community)\n"
7643 "Do not export to next AS (well-known community)\n"
7644 "Exact match of the communities")
7646 ALIAS (show_bgp_community_exact
,
7647 show_bgp_community2_exact_cmd
,
7648 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7651 "Display routes matching the communities\n"
7652 "community number\n"
7653 "Do not send outside local AS (well-known community)\n"
7654 "Do not advertise to any peer (well-known community)\n"
7655 "Do not export to next AS (well-known community)\n"
7656 "community number\n"
7657 "Do not send outside local AS (well-known community)\n"
7658 "Do not advertise to any peer (well-known community)\n"
7659 "Do not export to next AS (well-known community)\n"
7660 "Exact match of the communities")
7662 ALIAS (show_bgp_community_exact
,
7663 show_bgp_ipv6_community2_exact_cmd
,
7664 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7668 "Display routes matching the communities\n"
7669 "community number\n"
7670 "Do not send outside local AS (well-known community)\n"
7671 "Do not advertise to any peer (well-known community)\n"
7672 "Do not export to next AS (well-known community)\n"
7673 "community number\n"
7674 "Do not send outside local AS (well-known community)\n"
7675 "Do not advertise to any peer (well-known community)\n"
7676 "Do not export to next AS (well-known community)\n"
7677 "Exact match of the communities")
7679 ALIAS (show_bgp_community_exact
,
7680 show_bgp_community3_exact_cmd
,
7681 "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",
7684 "Display routes matching the communities\n"
7685 "community number\n"
7686 "Do not send outside local AS (well-known community)\n"
7687 "Do not advertise to any peer (well-known community)\n"
7688 "Do not export to next AS (well-known community)\n"
7689 "community number\n"
7690 "Do not send outside local AS (well-known community)\n"
7691 "Do not advertise to any peer (well-known community)\n"
7692 "Do not export to next AS (well-known community)\n"
7693 "community number\n"
7694 "Do not send outside local AS (well-known community)\n"
7695 "Do not advertise to any peer (well-known community)\n"
7696 "Do not export to next AS (well-known community)\n"
7697 "Exact match of the communities")
7699 ALIAS (show_bgp_community_exact
,
7700 show_bgp_ipv6_community3_exact_cmd
,
7701 "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",
7705 "Display routes matching the communities\n"
7706 "community number\n"
7707 "Do not send outside local AS (well-known community)\n"
7708 "Do not advertise to any peer (well-known community)\n"
7709 "Do not export to next AS (well-known community)\n"
7710 "community number\n"
7711 "Do not send outside local AS (well-known community)\n"
7712 "Do not advertise to any peer (well-known community)\n"
7713 "Do not export to next AS (well-known community)\n"
7714 "community number\n"
7715 "Do not send outside local AS (well-known community)\n"
7716 "Do not advertise to any peer (well-known community)\n"
7717 "Do not export to next AS (well-known community)\n"
7718 "Exact match of the communities")
7720 ALIAS (show_bgp_community_exact
,
7721 show_bgp_community4_exact_cmd
,
7722 "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",
7725 "Display routes matching the communities\n"
7726 "community number\n"
7727 "Do not send outside local AS (well-known community)\n"
7728 "Do not advertise to any peer (well-known community)\n"
7729 "Do not export to next AS (well-known community)\n"
7730 "community number\n"
7731 "Do not send outside local AS (well-known community)\n"
7732 "Do not advertise to any peer (well-known community)\n"
7733 "Do not export to next AS (well-known community)\n"
7734 "community number\n"
7735 "Do not send outside local AS (well-known community)\n"
7736 "Do not advertise to any peer (well-known community)\n"
7737 "Do not export to next AS (well-known community)\n"
7738 "community number\n"
7739 "Do not send outside local AS (well-known community)\n"
7740 "Do not advertise to any peer (well-known community)\n"
7741 "Do not export to next AS (well-known community)\n"
7742 "Exact match of the communities")
7744 ALIAS (show_bgp_community_exact
,
7745 show_bgp_ipv6_community4_exact_cmd
,
7746 "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",
7750 "Display routes matching the communities\n"
7751 "community number\n"
7752 "Do not send outside local AS (well-known community)\n"
7753 "Do not advertise to any peer (well-known community)\n"
7754 "Do not export to next AS (well-known community)\n"
7755 "community number\n"
7756 "Do not send outside local AS (well-known community)\n"
7757 "Do not advertise to any peer (well-known community)\n"
7758 "Do not export to next AS (well-known community)\n"
7759 "community number\n"
7760 "Do not send outside local AS (well-known community)\n"
7761 "Do not advertise to any peer (well-known community)\n"
7762 "Do not export to next AS (well-known community)\n"
7763 "community number\n"
7764 "Do not send outside local AS (well-known community)\n"
7765 "Do not advertise to any peer (well-known community)\n"
7766 "Do not export to next AS (well-known community)\n"
7767 "Exact match of the communities")
7770 DEFUN (show_ipv6_bgp_community_exact
,
7771 show_ipv6_bgp_community_exact_cmd
,
7772 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7776 "Display routes matching the communities\n"
7777 "community number\n"
7778 "Do not send outside local AS (well-known community)\n"
7779 "Do not advertise to any peer (well-known community)\n"
7780 "Do not export to next AS (well-known community)\n"
7781 "Exact match of the communities")
7783 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
7787 ALIAS (show_ipv6_bgp_community_exact
,
7788 show_ipv6_bgp_community2_exact_cmd
,
7789 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7793 "Display routes matching the communities\n"
7794 "community number\n"
7795 "Do not send outside local AS (well-known community)\n"
7796 "Do not advertise to any peer (well-known community)\n"
7797 "Do not export to next AS (well-known community)\n"
7798 "community number\n"
7799 "Do not send outside local AS (well-known community)\n"
7800 "Do not advertise to any peer (well-known community)\n"
7801 "Do not export to next AS (well-known community)\n"
7802 "Exact match of the communities")
7805 ALIAS (show_ipv6_bgp_community_exact
,
7806 show_ipv6_bgp_community3_exact_cmd
,
7807 "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",
7811 "Display routes matching the communities\n"
7812 "community number\n"
7813 "Do not send outside local AS (well-known community)\n"
7814 "Do not advertise to any peer (well-known community)\n"
7815 "Do not export to next AS (well-known community)\n"
7816 "community number\n"
7817 "Do not send outside local AS (well-known community)\n"
7818 "Do not advertise to any peer (well-known community)\n"
7819 "Do not export to next AS (well-known community)\n"
7820 "community number\n"
7821 "Do not send outside local AS (well-known community)\n"
7822 "Do not advertise to any peer (well-known community)\n"
7823 "Do not export to next AS (well-known community)\n"
7824 "Exact match of the communities")
7827 ALIAS (show_ipv6_bgp_community_exact
,
7828 show_ipv6_bgp_community4_exact_cmd
,
7829 "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",
7833 "Display routes matching the communities\n"
7834 "community number\n"
7835 "Do not send outside local AS (well-known community)\n"
7836 "Do not advertise to any peer (well-known community)\n"
7837 "Do not export to next AS (well-known community)\n"
7838 "community number\n"
7839 "Do not send outside local AS (well-known community)\n"
7840 "Do not advertise to any peer (well-known community)\n"
7841 "Do not export to next AS (well-known community)\n"
7842 "community number\n"
7843 "Do not send outside local AS (well-known community)\n"
7844 "Do not advertise to any peer (well-known community)\n"
7845 "Do not export to next AS (well-known community)\n"
7846 "community number\n"
7847 "Do not send outside local AS (well-known community)\n"
7848 "Do not advertise to any peer (well-known community)\n"
7849 "Do not export to next AS (well-known community)\n"
7850 "Exact match of the communities")
7853 DEFUN (show_ipv6_mbgp_community
,
7854 show_ipv6_mbgp_community_cmd
,
7855 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
7859 "Display routes matching the communities\n"
7860 "community number\n"
7861 "Do not send outside local AS (well-known community)\n"
7862 "Do not advertise to any peer (well-known community)\n"
7863 "Do not export to next AS (well-known community)\n")
7865 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
7869 ALIAS (show_ipv6_mbgp_community
,
7870 show_ipv6_mbgp_community2_cmd
,
7871 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7875 "Display routes matching the communities\n"
7876 "community number\n"
7877 "Do not send outside local AS (well-known community)\n"
7878 "Do not advertise to any peer (well-known community)\n"
7879 "Do not export to next AS (well-known community)\n"
7880 "community number\n"
7881 "Do not send outside local AS (well-known community)\n"
7882 "Do not advertise to any peer (well-known community)\n"
7883 "Do not export to next AS (well-known community)\n")
7886 ALIAS (show_ipv6_mbgp_community
,
7887 show_ipv6_mbgp_community3_cmd
,
7888 "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)",
7892 "Display routes matching the communities\n"
7893 "community number\n"
7894 "Do not send outside local AS (well-known community)\n"
7895 "Do not advertise to any peer (well-known community)\n"
7896 "Do not export to next AS (well-known community)\n"
7897 "community number\n"
7898 "Do not send outside local AS (well-known community)\n"
7899 "Do not advertise to any peer (well-known community)\n"
7900 "Do not export to next AS (well-known community)\n"
7901 "community number\n"
7902 "Do not send outside local AS (well-known community)\n"
7903 "Do not advertise to any peer (well-known community)\n"
7904 "Do not export to next AS (well-known community)\n")
7907 ALIAS (show_ipv6_mbgp_community
,
7908 show_ipv6_mbgp_community4_cmd
,
7909 "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)",
7913 "Display routes matching the communities\n"
7914 "community number\n"
7915 "Do not send outside local AS (well-known community)\n"
7916 "Do not advertise to any peer (well-known community)\n"
7917 "Do not export to next AS (well-known community)\n"
7918 "community number\n"
7919 "Do not send outside local AS (well-known community)\n"
7920 "Do not advertise to any peer (well-known community)\n"
7921 "Do not export to next AS (well-known community)\n"
7922 "community number\n"
7923 "Do not send outside local AS (well-known community)\n"
7924 "Do not advertise to any peer (well-known community)\n"
7925 "Do not export to next AS (well-known community)\n"
7926 "community number\n"
7927 "Do not send outside local AS (well-known community)\n"
7928 "Do not advertise to any peer (well-known community)\n"
7929 "Do not export to next AS (well-known community)\n")
7932 DEFUN (show_ipv6_mbgp_community_exact
,
7933 show_ipv6_mbgp_community_exact_cmd
,
7934 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7938 "Display routes matching the communities\n"
7939 "community number\n"
7940 "Do not send outside local AS (well-known community)\n"
7941 "Do not advertise to any peer (well-known community)\n"
7942 "Do not export to next AS (well-known community)\n"
7943 "Exact match of the communities")
7945 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
7949 ALIAS (show_ipv6_mbgp_community_exact
,
7950 show_ipv6_mbgp_community2_exact_cmd
,
7951 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7955 "Display routes matching the communities\n"
7956 "community number\n"
7957 "Do not send outside local AS (well-known community)\n"
7958 "Do not advertise to any peer (well-known community)\n"
7959 "Do not export to next AS (well-known community)\n"
7960 "community number\n"
7961 "Do not send outside local AS (well-known community)\n"
7962 "Do not advertise to any peer (well-known community)\n"
7963 "Do not export to next AS (well-known community)\n"
7964 "Exact match of the communities")
7967 ALIAS (show_ipv6_mbgp_community_exact
,
7968 show_ipv6_mbgp_community3_exact_cmd
,
7969 "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",
7973 "Display routes matching the communities\n"
7974 "community number\n"
7975 "Do not send outside local AS (well-known community)\n"
7976 "Do not advertise to any peer (well-known community)\n"
7977 "Do not export to next AS (well-known community)\n"
7978 "community number\n"
7979 "Do not send outside local AS (well-known community)\n"
7980 "Do not advertise to any peer (well-known community)\n"
7981 "Do not export to next AS (well-known community)\n"
7982 "community number\n"
7983 "Do not send outside local AS (well-known community)\n"
7984 "Do not advertise to any peer (well-known community)\n"
7985 "Do not export to next AS (well-known community)\n"
7986 "Exact match of the communities")
7989 ALIAS (show_ipv6_mbgp_community_exact
,
7990 show_ipv6_mbgp_community4_exact_cmd
,
7991 "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",
7995 "Display routes matching the communities\n"
7996 "community number\n"
7997 "Do not send outside local AS (well-known community)\n"
7998 "Do not advertise to any peer (well-known community)\n"
7999 "Do not export to next AS (well-known community)\n"
8000 "community number\n"
8001 "Do not send outside local AS (well-known community)\n"
8002 "Do not advertise to any peer (well-known community)\n"
8003 "Do not export to next AS (well-known community)\n"
8004 "community number\n"
8005 "Do not send outside local AS (well-known community)\n"
8006 "Do not advertise to any peer (well-known community)\n"
8007 "Do not export to next AS (well-known community)\n"
8008 "community number\n"
8009 "Do not send outside local AS (well-known community)\n"
8010 "Do not advertise to any peer (well-known community)\n"
8011 "Do not export to next AS (well-known community)\n"
8012 "Exact match of the communities")
8013 #endif /* HAVE_IPV6 */
8016 bgp_show_community_list (struct vty
*vty
, const char *com
, int exact
,
8017 u_int16_t afi
, u_char safi
)
8019 struct community_list
*list
;
8021 list
= community_list_lookup (bgp_clist
, com
, COMMUNITY_LIST_MASTER
);
8024 vty_out (vty
, "%% %s is not a valid community-list name%s", com
,
8029 return bgp_show (vty
, NULL
, afi
, safi
,
8030 (exact
? bgp_show_type_community_list_exact
:
8031 bgp_show_type_community_list
), list
);
8034 DEFUN (show_ip_bgp_community_list
,
8035 show_ip_bgp_community_list_cmd
,
8036 "show ip bgp community-list (<1-500>|WORD)",
8040 "Display routes matching the community-list\n"
8041 "community-list number\n"
8042 "community-list name\n")
8044 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP
, SAFI_UNICAST
);
8047 DEFUN (show_ip_bgp_ipv4_community_list
,
8048 show_ip_bgp_ipv4_community_list_cmd
,
8049 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
8054 "Address Family modifier\n"
8055 "Address Family modifier\n"
8056 "Display routes matching the community-list\n"
8057 "community-list number\n"
8058 "community-list name\n")
8060 if (strncmp (argv
[0], "m", 1) == 0)
8061 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_MULTICAST
);
8063 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_UNICAST
);
8066 DEFUN (show_ip_bgp_community_list_exact
,
8067 show_ip_bgp_community_list_exact_cmd
,
8068 "show ip bgp community-list (<1-500>|WORD) exact-match",
8072 "Display routes matching the community-list\n"
8073 "community-list number\n"
8074 "community-list name\n"
8075 "Exact match of the communities\n")
8077 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP
, SAFI_UNICAST
);
8080 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
8081 show_ip_bgp_ipv4_community_list_exact_cmd
,
8082 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
8087 "Address Family modifier\n"
8088 "Address Family modifier\n"
8089 "Display routes matching the community-list\n"
8090 "community-list number\n"
8091 "community-list name\n"
8092 "Exact match of the communities\n")
8094 if (strncmp (argv
[0], "m", 1) == 0)
8095 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_MULTICAST
);
8097 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_UNICAST
);
8101 DEFUN (show_bgp_community_list
,
8102 show_bgp_community_list_cmd
,
8103 "show bgp community-list (<1-500>|WORD)",
8106 "Display routes matching the community-list\n"
8107 "community-list number\n"
8108 "community-list name\n")
8110 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
8113 ALIAS (show_bgp_community_list
,
8114 show_bgp_ipv6_community_list_cmd
,
8115 "show bgp ipv6 community-list (<1-500>|WORD)",
8119 "Display routes matching the community-list\n"
8120 "community-list number\n"
8121 "community-list name\n")
8124 DEFUN (show_ipv6_bgp_community_list
,
8125 show_ipv6_bgp_community_list_cmd
,
8126 "show ipv6 bgp community-list WORD",
8130 "Display routes matching the community-list\n"
8131 "community-list name\n")
8133 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
8137 DEFUN (show_ipv6_mbgp_community_list
,
8138 show_ipv6_mbgp_community_list_cmd
,
8139 "show ipv6 mbgp community-list WORD",
8143 "Display routes matching the community-list\n"
8144 "community-list name\n")
8146 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_MULTICAST
);
8149 DEFUN (show_bgp_community_list_exact
,
8150 show_bgp_community_list_exact_cmd
,
8151 "show bgp community-list (<1-500>|WORD) exact-match",
8154 "Display routes matching the community-list\n"
8155 "community-list number\n"
8156 "community-list name\n"
8157 "Exact match of the communities\n")
8159 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
8162 ALIAS (show_bgp_community_list_exact
,
8163 show_bgp_ipv6_community_list_exact_cmd
,
8164 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
8168 "Display routes matching the community-list\n"
8169 "community-list number\n"
8170 "community-list name\n"
8171 "Exact match of the communities\n")
8174 DEFUN (show_ipv6_bgp_community_list_exact
,
8175 show_ipv6_bgp_community_list_exact_cmd
,
8176 "show ipv6 bgp community-list WORD exact-match",
8180 "Display routes matching the community-list\n"
8181 "community-list name\n"
8182 "Exact match of the communities\n")
8184 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
8188 DEFUN (show_ipv6_mbgp_community_list_exact
,
8189 show_ipv6_mbgp_community_list_exact_cmd
,
8190 "show ipv6 mbgp community-list WORD exact-match",
8194 "Display routes matching the community-list\n"
8195 "community-list name\n"
8196 "Exact match of the communities\n")
8198 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_MULTICAST
);
8200 #endif /* HAVE_IPV6 */
8203 bgp_show_prefix_longer (struct vty
*vty
, const char *prefix
, afi_t afi
,
8204 safi_t safi
, enum bgp_show_type type
)
8211 ret
= str2prefix (prefix
, p
);
8214 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
8218 ret
= bgp_show (vty
, NULL
, afi
, safi
, type
, p
);
8223 DEFUN (show_ip_bgp_prefix_longer
,
8224 show_ip_bgp_prefix_longer_cmd
,
8225 "show ip bgp A.B.C.D/M longer-prefixes",
8229 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8230 "Display route and more specific routes\n")
8232 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8233 bgp_show_type_prefix_longer
);
8236 DEFUN (show_ip_bgp_flap_prefix_longer
,
8237 show_ip_bgp_flap_prefix_longer_cmd
,
8238 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
8242 "Display flap statistics of routes\n"
8243 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8244 "Display route and more specific routes\n")
8246 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8247 bgp_show_type_flap_prefix_longer
);
8250 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
8251 show_ip_bgp_ipv4_prefix_longer_cmd
,
8252 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
8257 "Address Family modifier\n"
8258 "Address Family modifier\n"
8259 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8260 "Display route and more specific routes\n")
8262 if (strncmp (argv
[0], "m", 1) == 0)
8263 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
8264 bgp_show_type_prefix_longer
);
8266 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
8267 bgp_show_type_prefix_longer
);
8270 DEFUN (show_ip_bgp_flap_address
,
8271 show_ip_bgp_flap_address_cmd
,
8272 "show ip bgp flap-statistics A.B.C.D",
8276 "Display flap statistics of routes\n"
8277 "Network in the BGP routing table to display\n")
8279 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8280 bgp_show_type_flap_address
);
8283 DEFUN (show_ip_bgp_flap_prefix
,
8284 show_ip_bgp_flap_prefix_cmd
,
8285 "show ip bgp flap-statistics A.B.C.D/M",
8289 "Display flap statistics of routes\n"
8290 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8292 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8293 bgp_show_type_flap_prefix
);
8296 DEFUN (show_bgp_prefix_longer
,
8297 show_bgp_prefix_longer_cmd
,
8298 "show bgp X:X::X:X/M longer-prefixes",
8301 "IPv6 prefix <network>/<length>\n"
8302 "Display route and more specific routes\n")
8304 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8305 bgp_show_type_prefix_longer
);
8308 ALIAS (show_bgp_prefix_longer
,
8309 show_bgp_ipv6_prefix_longer_cmd
,
8310 "show bgp ipv6 X:X::X:X/M longer-prefixes",
8314 "IPv6 prefix <network>/<length>\n"
8315 "Display route and more specific routes\n")
8318 DEFUN (show_ipv6_bgp_prefix_longer
,
8319 show_ipv6_bgp_prefix_longer_cmd
,
8320 "show ipv6 bgp X:X::X:X/M longer-prefixes",
8324 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8325 "Display route and more specific routes\n")
8327 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8328 bgp_show_type_prefix_longer
);
8332 DEFUN (show_ipv6_mbgp_prefix_longer
,
8333 show_ipv6_mbgp_prefix_longer_cmd
,
8334 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
8338 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8339 "Display route and more specific routes\n")
8341 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
8342 bgp_show_type_prefix_longer
);
8344 #endif /* HAVE_IPV6 */
8346 static struct peer
*
8347 peer_lookup_in_view (struct vty
*vty
, const char *view_name
,
8355 /* BGP structure lookup. */
8358 bgp
= bgp_lookup_by_name (view_name
);
8361 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
8367 bgp
= bgp_get_default ();
8370 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
8375 /* Get peer sockunion. */
8376 ret
= str2sockunion (ip_str
, &su
);
8379 vty_out (vty
, "Malformed address: %s%s", ip_str
, VTY_NEWLINE
);
8383 /* Peer structure lookup. */
8384 peer
= peer_lookup (bgp
, &su
);
8387 vty_out (vty
, "No such neighbor%s", VTY_NEWLINE
);
8404 PCOUNT_PFCNT
, /* the figure we display to users */
8408 static const char *pcount_strs
[] =
8410 [PCOUNT_ADJ_IN
] = "Adj-in",
8411 [PCOUNT_DAMPED
] = "Damped",
8412 [PCOUNT_REMOVED
] = "Removed",
8413 [PCOUNT_HISTORY
] = "History",
8414 [PCOUNT_STALE
] = "Stale",
8415 [PCOUNT_VALID
] = "Valid",
8416 [PCOUNT_ALL
] = "All RIB",
8417 [PCOUNT_COUNTED
] = "PfxCt counted",
8418 [PCOUNT_PFCNT
] = "Useable",
8419 [PCOUNT_MAX
] = NULL
,
8423 bgp_peer_counts (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
)
8425 struct bgp_node
*rn
;
8426 struct bgp_info
*ri
;
8427 unsigned int pcounts
[PCOUNT_MAX
], i
;
8429 if (!peer
|| !peer
->bgp
|| !peer
->afc
[afi
][safi
]
8430 || !peer
->bgp
->rib
[afi
][safi
])
8432 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
8436 memset (&pcounts
, 0, sizeof(pcounts
));
8438 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
8439 rn
= bgp_route_next (rn
))
8441 struct bgp_adj_in
*ain
;
8443 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
8444 if (ain
->peer
== peer
)
8445 pcounts
[PCOUNT_ADJ_IN
]++;
8447 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
8449 char buf
[SU_ADDRSTRLEN
];
8451 if (ri
->peer
!= peer
)
8454 pcounts
[PCOUNT_ALL
]++;
8456 if (CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
))
8457 pcounts
[PCOUNT_DAMPED
]++;
8458 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
8459 pcounts
[PCOUNT_HISTORY
]++;
8460 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
8461 pcounts
[PCOUNT_REMOVED
]++;
8462 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
8463 pcounts
[PCOUNT_STALE
]++;
8464 if (CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
))
8465 pcounts
[PCOUNT_VALID
]++;
8466 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
8467 pcounts
[PCOUNT_PFCNT
]++;
8469 if (CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
8471 pcounts
[PCOUNT_COUNTED
]++;
8472 if (CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
8473 plog_warn (peer
->log
,
8474 "%s [pcount] %s/%d is counted but flags 0x%x",
8476 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
8477 buf
, SU_ADDRSTRLEN
),
8483 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
8484 plog_warn (peer
->log
,
8485 "%s [pcount] %s/%d not counted but flags 0x%x",
8487 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
8488 buf
, SU_ADDRSTRLEN
),
8495 vty_out (vty
, "Prefix counts for %s, %s%s",
8496 peer
->host
, afi_safi_print (afi
, safi
), VTY_NEWLINE
);
8497 vty_out (vty
, "PfxCt: %ld%s", peer
->pcount
[afi
][safi
], VTY_NEWLINE
);
8498 vty_out (vty
, "%sCounts from RIB table walk:%s%s",
8499 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
8501 for (i
= 0; i
< PCOUNT_MAX
; i
++)
8502 vty_out (vty
, "%20s: %-10d%s", pcount_strs
[i
], pcounts
[i
], VTY_NEWLINE
);
8504 if (pcounts
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
8506 vty_out (vty
, "%s [pcount] PfxCt drift!%s",
8507 peer
->host
, VTY_NEWLINE
);
8508 vty_out (vty
, "Please report this bug, with the above command output%s",
8515 DEFUN (show_ip_bgp_neighbor_prefix_counts
,
8516 show_ip_bgp_neighbor_prefix_counts_cmd
,
8517 "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts",
8521 "Detailed information on TCP and BGP neighbor connections\n"
8522 "Neighbor to display information about\n"
8523 "Neighbor to display information about\n"
8524 "Display detailed prefix count information\n")
8528 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
8532 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
);
8535 DEFUN (show_bgp_ipv6_neighbor_prefix_counts
,
8536 show_bgp_ipv6_neighbor_prefix_counts_cmd
,
8537 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts",
8541 "Detailed information on TCP and BGP neighbor connections\n"
8542 "Neighbor to display information about\n"
8543 "Neighbor to display information about\n"
8544 "Display detailed prefix count information\n")
8548 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
8552 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
);
8555 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts
,
8556 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
,
8557 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
8562 "Address Family modifier\n"
8563 "Address Family modifier\n"
8564 "Detailed information on TCP and BGP neighbor connections\n"
8565 "Neighbor to display information about\n"
8566 "Neighbor to display information about\n"
8567 "Display detailed prefix count information\n")
8571 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
8575 if (strncmp (argv
[0], "m", 1) == 0)
8576 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MULTICAST
);
8578 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
);
8581 DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts
,
8582 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
,
8583 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
8588 "Address Family modifier\n"
8589 "Address Family modifier\n"
8590 "Detailed information on TCP and BGP neighbor connections\n"
8591 "Neighbor to display information about\n"
8592 "Neighbor to display information about\n"
8593 "Display detailed prefix count information\n")
8597 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
8601 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MPLS_VPN
);
8606 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
8609 struct bgp_table
*table
;
8610 struct bgp_adj_in
*ain
;
8611 struct bgp_adj_out
*adj
;
8612 unsigned long output_count
;
8613 struct bgp_node
*rn
;
8623 table
= bgp
->rib
[afi
][safi
];
8627 if (! in
&& CHECK_FLAG (peer
->af_sflags
[afi
][safi
],
8628 PEER_STATUS_DEFAULT_ORIGINATE
))
8630 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
8631 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
8632 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
8634 vty_out (vty
, "Originating default network 0.0.0.0%s%s",
8635 VTY_NEWLINE
, VTY_NEWLINE
);
8639 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
8642 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
8643 if (ain
->peer
== peer
)
8647 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
8648 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
8649 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
8654 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
8659 route_vty_out_tmp (vty
, &rn
->p
, ain
->attr
, safi
);
8666 for (adj
= rn
->adj_out
; adj
; adj
= adj
->next
)
8667 if (adj
->peer
== peer
)
8671 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
8672 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
8673 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
8678 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
8683 route_vty_out_tmp (vty
, &rn
->p
, adj
->attr
, safi
);
8689 if (output_count
!= 0)
8690 vty_out (vty
, "%sTotal number of prefixes %ld%s",
8691 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
8695 peer_adj_routes (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
, int in
)
8697 if (! peer
|| ! peer
->afc
[afi
][safi
])
8699 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
8703 if (in
&& ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8705 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s",
8710 show_adj_route (vty
, peer
, afi
, safi
, in
);
8715 DEFUN (show_ip_bgp_neighbor_advertised_route
,
8716 show_ip_bgp_neighbor_advertised_route_cmd
,
8717 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8721 "Detailed information on TCP and BGP neighbor connections\n"
8722 "Neighbor to display information about\n"
8723 "Neighbor to display information about\n"
8724 "Display the routes advertised to a BGP neighbor\n")
8728 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
8732 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0);
8735 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
8736 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
8737 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8742 "Address Family modifier\n"
8743 "Address Family modifier\n"
8744 "Detailed information on TCP and BGP neighbor connections\n"
8745 "Neighbor to display information about\n"
8746 "Neighbor to display information about\n"
8747 "Display the routes advertised to a BGP neighbor\n")
8751 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
8755 if (strncmp (argv
[0], "m", 1) == 0)
8756 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 0);
8758 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0);
8762 DEFUN (show_bgp_view_neighbor_advertised_route
,
8763 show_bgp_view_neighbor_advertised_route_cmd
,
8764 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8769 "Detailed information on TCP and BGP neighbor connections\n"
8770 "Neighbor to display information about\n"
8771 "Neighbor to display information about\n"
8772 "Display the routes advertised to a BGP neighbor\n")
8777 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
8779 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
8784 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0);
8787 ALIAS (show_bgp_view_neighbor_advertised_route
,
8788 show_bgp_view_ipv6_neighbor_advertised_route_cmd
,
8789 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8795 "Detailed information on TCP and BGP neighbor connections\n"
8796 "Neighbor to display information about\n"
8797 "Neighbor to display information about\n"
8798 "Display the routes advertised to a BGP neighbor\n")
8800 DEFUN (show_bgp_view_neighbor_received_routes
,
8801 show_bgp_view_neighbor_received_routes_cmd
,
8802 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
8807 "Detailed information on TCP and BGP neighbor connections\n"
8808 "Neighbor to display information about\n"
8809 "Neighbor to display information about\n"
8810 "Display the received routes from neighbor\n")
8815 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
8817 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
8822 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1);
8825 ALIAS (show_bgp_view_neighbor_received_routes
,
8826 show_bgp_view_ipv6_neighbor_received_routes_cmd
,
8827 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
8833 "Detailed information on TCP and BGP neighbor connections\n"
8834 "Neighbor to display information about\n"
8835 "Neighbor to display information about\n"
8836 "Display the received routes from neighbor\n")
8838 ALIAS (show_bgp_view_neighbor_advertised_route
,
8839 show_bgp_neighbor_advertised_route_cmd
,
8840 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8843 "Detailed information on TCP and BGP neighbor connections\n"
8844 "Neighbor to display information about\n"
8845 "Neighbor to display information about\n"
8846 "Display the routes advertised to a BGP neighbor\n")
8848 ALIAS (show_bgp_view_neighbor_advertised_route
,
8849 show_bgp_ipv6_neighbor_advertised_route_cmd
,
8850 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8854 "Detailed information on TCP and BGP neighbor connections\n"
8855 "Neighbor to display information about\n"
8856 "Neighbor to display information about\n"
8857 "Display the routes advertised to a BGP neighbor\n")
8860 ALIAS (show_bgp_view_neighbor_advertised_route
,
8861 ipv6_bgp_neighbor_advertised_route_cmd
,
8862 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8866 "Detailed information on TCP and BGP neighbor connections\n"
8867 "Neighbor to display information about\n"
8868 "Neighbor to display information about\n"
8869 "Display the routes advertised to a BGP neighbor\n")
8872 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
8873 ipv6_mbgp_neighbor_advertised_route_cmd
,
8874 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8878 "Detailed information on TCP and BGP neighbor connections\n"
8879 "Neighbor to display information about\n"
8880 "Neighbor to display information about\n"
8881 "Display the routes advertised to a BGP neighbor\n")
8885 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
8889 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 0);
8891 #endif /* HAVE_IPV6 */
8893 DEFUN (show_ip_bgp_neighbor_received_routes
,
8894 show_ip_bgp_neighbor_received_routes_cmd
,
8895 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
8899 "Detailed information on TCP and BGP neighbor connections\n"
8900 "Neighbor to display information about\n"
8901 "Neighbor to display information about\n"
8902 "Display the received routes from neighbor\n")
8906 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
8910 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1);
8913 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
8914 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
8915 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
8920 "Address Family modifier\n"
8921 "Address Family modifier\n"
8922 "Detailed information on TCP and BGP neighbor connections\n"
8923 "Neighbor to display information about\n"
8924 "Neighbor to display information about\n"
8925 "Display the received routes from neighbor\n")
8929 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
8933 if (strncmp (argv
[0], "m", 1) == 0)
8934 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 1);
8936 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1);
8939 DEFUN (show_ip_bgp_neighbor_received_prefix_filter
,
8940 show_ip_bgp_neighbor_received_prefix_filter_cmd
,
8941 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
8945 "Detailed information on TCP and BGP neighbor connections\n"
8946 "Neighbor to display information about\n"
8947 "Neighbor to display information about\n"
8948 "Display information received from a BGP neighbor\n"
8949 "Display the prefixlist filter\n")
8952 union sockunion
*su
;
8956 su
= sockunion_str2su (argv
[0]);
8960 peer
= peer_lookup (NULL
, su
);
8964 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
8965 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
8968 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
8969 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
8975 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter
,
8976 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
,
8977 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
8982 "Address Family modifier\n"
8983 "Address Family modifier\n"
8984 "Detailed information on TCP and BGP neighbor connections\n"
8985 "Neighbor to display information about\n"
8986 "Neighbor to display information about\n"
8987 "Display information received from a BGP neighbor\n"
8988 "Display the prefixlist filter\n")
8991 union sockunion
*su
;
8995 su
= sockunion_str2su (argv
[1]);
8999 peer
= peer_lookup (NULL
, su
);
9003 if (strncmp (argv
[0], "m", 1) == 0)
9005 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_MULTICAST
);
9006 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
9009 vty_out (vty
, "Address family: IPv4 Multicast%s", VTY_NEWLINE
);
9010 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
9015 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
9016 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
9019 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
9020 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
9029 ALIAS (show_bgp_view_neighbor_received_routes
,
9030 show_bgp_neighbor_received_routes_cmd
,
9031 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
9034 "Detailed information on TCP and BGP neighbor connections\n"
9035 "Neighbor to display information about\n"
9036 "Neighbor to display information about\n"
9037 "Display the received routes from neighbor\n")
9039 ALIAS (show_bgp_view_neighbor_received_routes
,
9040 show_bgp_ipv6_neighbor_received_routes_cmd
,
9041 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
9045 "Detailed information on TCP and BGP neighbor connections\n"
9046 "Neighbor to display information about\n"
9047 "Neighbor to display information about\n"
9048 "Display the received routes from neighbor\n")
9050 DEFUN (show_bgp_neighbor_received_prefix_filter
,
9051 show_bgp_neighbor_received_prefix_filter_cmd
,
9052 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9055 "Detailed information on TCP and BGP neighbor connections\n"
9056 "Neighbor to display information about\n"
9057 "Neighbor to display information about\n"
9058 "Display information received from a BGP neighbor\n"
9059 "Display the prefixlist filter\n")
9062 union sockunion
*su
;
9066 su
= sockunion_str2su (argv
[0]);
9070 peer
= peer_lookup (NULL
, su
);
9074 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
9075 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
);
9078 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
9079 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
);
9085 ALIAS (show_bgp_neighbor_received_prefix_filter
,
9086 show_bgp_ipv6_neighbor_received_prefix_filter_cmd
,
9087 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9091 "Detailed information on TCP and BGP neighbor connections\n"
9092 "Neighbor to display information about\n"
9093 "Neighbor to display information about\n"
9094 "Display information received from a BGP neighbor\n"
9095 "Display the prefixlist filter\n")
9098 ALIAS (show_bgp_view_neighbor_received_routes
,
9099 ipv6_bgp_neighbor_received_routes_cmd
,
9100 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
9104 "Detailed information on TCP and BGP neighbor connections\n"
9105 "Neighbor to display information about\n"
9106 "Neighbor to display information about\n"
9107 "Display the received routes from neighbor\n")
9110 DEFUN (ipv6_mbgp_neighbor_received_routes
,
9111 ipv6_mbgp_neighbor_received_routes_cmd
,
9112 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
9116 "Detailed information on TCP and BGP neighbor connections\n"
9117 "Neighbor to display information about\n"
9118 "Neighbor to display information about\n"
9119 "Display the received routes from neighbor\n")
9123 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9127 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 1);
9130 DEFUN (show_bgp_view_neighbor_received_prefix_filter
,
9131 show_bgp_view_neighbor_received_prefix_filter_cmd
,
9132 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9137 "Detailed information on TCP and BGP neighbor connections\n"
9138 "Neighbor to display information about\n"
9139 "Neighbor to display information about\n"
9140 "Display information received from a BGP neighbor\n"
9141 "Display the prefixlist filter\n")
9144 union sockunion
*su
;
9149 /* BGP structure lookup. */
9150 bgp
= bgp_lookup_by_name (argv
[0]);
9153 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
9157 su
= sockunion_str2su (argv
[1]);
9161 peer
= peer_lookup (bgp
, su
);
9165 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
9166 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
);
9169 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
9170 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
);
9176 ALIAS (show_bgp_view_neighbor_received_prefix_filter
,
9177 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
,
9178 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9184 "Detailed information on TCP and BGP neighbor connections\n"
9185 "Neighbor to display information about\n"
9186 "Neighbor to display information about\n"
9187 "Display information received from a BGP neighbor\n"
9188 "Display the prefixlist filter\n")
9189 #endif /* HAVE_IPV6 */
9192 bgp_show_neighbor_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
,
9193 safi_t safi
, enum bgp_show_type type
)
9195 if (! peer
|| ! peer
->afc
[afi
][safi
])
9197 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
9201 return bgp_show (vty
, peer
->bgp
, afi
, safi
, type
, &peer
->su
);
9204 DEFUN (show_ip_bgp_neighbor_routes
,
9205 show_ip_bgp_neighbor_routes_cmd
,
9206 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
9210 "Detailed information on TCP and BGP neighbor connections\n"
9211 "Neighbor to display information about\n"
9212 "Neighbor to display information about\n"
9213 "Display routes learned from neighbor\n")
9217 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9221 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
9222 bgp_show_type_neighbor
);
9225 DEFUN (show_ip_bgp_neighbor_flap
,
9226 show_ip_bgp_neighbor_flap_cmd
,
9227 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
9231 "Detailed information on TCP and BGP neighbor connections\n"
9232 "Neighbor to display information about\n"
9233 "Neighbor to display information about\n"
9234 "Display flap statistics of the routes learned from neighbor\n")
9238 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9242 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
9243 bgp_show_type_flap_neighbor
);
9246 DEFUN (show_ip_bgp_neighbor_damp
,
9247 show_ip_bgp_neighbor_damp_cmd
,
9248 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
9252 "Detailed information on TCP and BGP neighbor connections\n"
9253 "Neighbor to display information about\n"
9254 "Neighbor to display information about\n"
9255 "Display the dampened routes received from neighbor\n")
9259 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9263 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
9264 bgp_show_type_damp_neighbor
);
9267 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
9268 show_ip_bgp_ipv4_neighbor_routes_cmd
,
9269 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
9274 "Address Family modifier\n"
9275 "Address Family modifier\n"
9276 "Detailed information on TCP and BGP neighbor connections\n"
9277 "Neighbor to display information about\n"
9278 "Neighbor to display information about\n"
9279 "Display routes learned from neighbor\n")
9283 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9287 if (strncmp (argv
[0], "m", 1) == 0)
9288 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_MULTICAST
,
9289 bgp_show_type_neighbor
);
9291 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
9292 bgp_show_type_neighbor
);
9295 DEFUN (show_ip_bgp_view_rsclient
,
9296 show_ip_bgp_view_rsclient_cmd
,
9297 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
9303 "Information about Route Server Client\n"
9306 struct bgp_table
*table
;
9310 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9312 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9317 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
9319 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
9324 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
9325 PEER_FLAG_RSERVER_CLIENT
))
9327 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
9332 table
= peer
->rib
[AFI_IP
][SAFI_UNICAST
];
9334 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
9337 ALIAS (show_ip_bgp_view_rsclient
,
9338 show_ip_bgp_rsclient_cmd
,
9339 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
9343 "Information about Route Server Client\n"
9346 DEFUN (show_ip_bgp_view_rsclient_route
,
9347 show_ip_bgp_view_rsclient_route_cmd
,
9348 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
9354 "Information about Route Server Client\n"
9356 "Network in the BGP routing table to display\n")
9361 /* BGP structure lookup. */
9364 bgp
= bgp_lookup_by_name (argv
[0]);
9367 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
9373 bgp
= bgp_get_default ();
9376 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
9382 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9384 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9389 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
9391 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
9396 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
9397 PEER_FLAG_RSERVER_CLIENT
))
9399 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
9404 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][SAFI_UNICAST
],
9405 (argc
== 3) ? argv
[2] : argv
[1],
9406 AFI_IP
, SAFI_UNICAST
, NULL
, 0);
9409 ALIAS (show_ip_bgp_view_rsclient_route
,
9410 show_ip_bgp_rsclient_route_cmd
,
9411 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
9415 "Information about Route Server Client\n"
9417 "Network in the BGP routing table to display\n")
9419 DEFUN (show_ip_bgp_view_rsclient_prefix
,
9420 show_ip_bgp_view_rsclient_prefix_cmd
,
9421 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
9427 "Information about Route Server Client\n"
9429 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
9434 /* BGP structure lookup. */
9437 bgp
= bgp_lookup_by_name (argv
[0]);
9440 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
9446 bgp
= bgp_get_default ();
9449 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
9455 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9457 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9462 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
9464 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
9469 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
9470 PEER_FLAG_RSERVER_CLIENT
))
9472 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
9477 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][SAFI_UNICAST
],
9478 (argc
== 3) ? argv
[2] : argv
[1],
9479 AFI_IP
, SAFI_UNICAST
, NULL
, 1);
9482 ALIAS (show_ip_bgp_view_rsclient_prefix
,
9483 show_ip_bgp_rsclient_prefix_cmd
,
9484 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
9488 "Information about Route Server Client\n"
9490 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
9494 DEFUN (show_bgp_view_neighbor_routes
,
9495 show_bgp_view_neighbor_routes_cmd
,
9496 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
9501 "Detailed information on TCP and BGP neighbor connections\n"
9502 "Neighbor to display information about\n"
9503 "Neighbor to display information about\n"
9504 "Display routes learned from neighbor\n")
9509 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9511 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9516 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
9517 bgp_show_type_neighbor
);
9520 ALIAS (show_bgp_view_neighbor_routes
,
9521 show_bgp_view_ipv6_neighbor_routes_cmd
,
9522 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
9528 "Detailed information on TCP and BGP neighbor connections\n"
9529 "Neighbor to display information about\n"
9530 "Neighbor to display information about\n"
9531 "Display routes learned from neighbor\n")
9533 DEFUN (show_bgp_view_neighbor_damp
,
9534 show_bgp_view_neighbor_damp_cmd
,
9535 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
9540 "Detailed information on TCP and BGP neighbor connections\n"
9541 "Neighbor to display information about\n"
9542 "Neighbor to display information about\n"
9543 "Display the dampened routes received from neighbor\n")
9548 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9550 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9555 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
9556 bgp_show_type_damp_neighbor
);
9559 ALIAS (show_bgp_view_neighbor_damp
,
9560 show_bgp_view_ipv6_neighbor_damp_cmd
,
9561 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
9567 "Detailed information on TCP and BGP neighbor connections\n"
9568 "Neighbor to display information about\n"
9569 "Neighbor to display information about\n"
9570 "Display the dampened routes received from neighbor\n")
9572 DEFUN (show_bgp_view_neighbor_flap
,
9573 show_bgp_view_neighbor_flap_cmd
,
9574 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
9579 "Detailed information on TCP and BGP neighbor connections\n"
9580 "Neighbor to display information about\n"
9581 "Neighbor to display information about\n"
9582 "Display flap statistics of the routes learned from neighbor\n")
9587 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9589 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9594 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
9595 bgp_show_type_flap_neighbor
);
9598 ALIAS (show_bgp_view_neighbor_flap
,
9599 show_bgp_view_ipv6_neighbor_flap_cmd
,
9600 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
9606 "Detailed information on TCP and BGP neighbor connections\n"
9607 "Neighbor to display information about\n"
9608 "Neighbor to display information about\n"
9609 "Display flap statistics of the routes learned from neighbor\n")
9611 ALIAS (show_bgp_view_neighbor_routes
,
9612 show_bgp_neighbor_routes_cmd
,
9613 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
9616 "Detailed information on TCP and BGP neighbor connections\n"
9617 "Neighbor to display information about\n"
9618 "Neighbor to display information about\n"
9619 "Display routes learned from neighbor\n")
9622 ALIAS (show_bgp_view_neighbor_routes
,
9623 show_bgp_ipv6_neighbor_routes_cmd
,
9624 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
9628 "Detailed information on TCP and BGP neighbor connections\n"
9629 "Neighbor to display information about\n"
9630 "Neighbor to display information about\n"
9631 "Display routes learned from neighbor\n")
9634 ALIAS (show_bgp_view_neighbor_routes
,
9635 ipv6_bgp_neighbor_routes_cmd
,
9636 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
9640 "Detailed information on TCP and BGP neighbor connections\n"
9641 "Neighbor to display information about\n"
9642 "Neighbor to display information about\n"
9643 "Display routes learned from neighbor\n")
9646 DEFUN (ipv6_mbgp_neighbor_routes
,
9647 ipv6_mbgp_neighbor_routes_cmd
,
9648 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
9652 "Detailed information on TCP and BGP neighbor connections\n"
9653 "Neighbor to display information about\n"
9654 "Neighbor to display information about\n"
9655 "Display routes learned from neighbor\n")
9659 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9663 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
,
9664 bgp_show_type_neighbor
);
9667 ALIAS (show_bgp_view_neighbor_flap
,
9668 show_bgp_neighbor_flap_cmd
,
9669 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
9672 "Detailed information on TCP and BGP neighbor connections\n"
9673 "Neighbor to display information about\n"
9674 "Neighbor to display information about\n"
9675 "Display flap statistics of the routes learned from neighbor\n")
9677 ALIAS (show_bgp_view_neighbor_flap
,
9678 show_bgp_ipv6_neighbor_flap_cmd
,
9679 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
9683 "Detailed information on TCP and BGP neighbor connections\n"
9684 "Neighbor to display information about\n"
9685 "Neighbor to display information about\n"
9686 "Display flap statistics of the routes learned from neighbor\n")
9688 ALIAS (show_bgp_view_neighbor_damp
,
9689 show_bgp_neighbor_damp_cmd
,
9690 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
9693 "Detailed information on TCP and BGP neighbor connections\n"
9694 "Neighbor to display information about\n"
9695 "Neighbor to display information about\n"
9696 "Display the dampened routes received from neighbor\n")
9698 ALIAS (show_bgp_view_neighbor_damp
,
9699 show_bgp_ipv6_neighbor_damp_cmd
,
9700 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
9704 "Detailed information on TCP and BGP neighbor connections\n"
9705 "Neighbor to display information about\n"
9706 "Neighbor to display information about\n"
9707 "Display the dampened routes received from neighbor\n")
9709 DEFUN (show_bgp_view_rsclient
,
9710 show_bgp_view_rsclient_cmd
,
9711 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
9716 "Information about Route Server Client\n"
9719 struct bgp_table
*table
;
9723 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9725 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9730 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
9732 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
9737 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
9738 PEER_FLAG_RSERVER_CLIENT
))
9740 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
9745 table
= peer
->rib
[AFI_IP6
][SAFI_UNICAST
];
9747 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
9750 ALIAS (show_bgp_view_rsclient
,
9751 show_bgp_rsclient_cmd
,
9752 "show bgp rsclient (A.B.C.D|X:X::X:X)",
9755 "Information about Route Server Client\n"
9758 DEFUN (show_bgp_view_rsclient_route
,
9759 show_bgp_view_rsclient_route_cmd
,
9760 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
9765 "Information about Route Server Client\n"
9767 "Network in the BGP routing table to display\n")
9772 /* BGP structure lookup. */
9775 bgp
= bgp_lookup_by_name (argv
[0]);
9778 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
9784 bgp
= bgp_get_default ();
9787 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
9793 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9795 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9800 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
9802 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
9807 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
9808 PEER_FLAG_RSERVER_CLIENT
))
9810 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
9815 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][SAFI_UNICAST
],
9816 (argc
== 3) ? argv
[2] : argv
[1],
9817 AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
9820 ALIAS (show_bgp_view_rsclient_route
,
9821 show_bgp_rsclient_route_cmd
,
9822 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
9825 "Information about Route Server Client\n"
9827 "Network in the BGP routing table to display\n")
9829 DEFUN (show_bgp_view_rsclient_prefix
,
9830 show_bgp_view_rsclient_prefix_cmd
,
9831 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
9836 "Information about Route Server Client\n"
9838 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
9843 /* BGP structure lookup. */
9846 bgp
= bgp_lookup_by_name (argv
[0]);
9849 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
9855 bgp
= bgp_get_default ();
9858 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
9864 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9866 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9871 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
9873 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
9878 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
9879 PEER_FLAG_RSERVER_CLIENT
))
9881 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
9886 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][SAFI_UNICAST
],
9887 (argc
== 3) ? argv
[2] : argv
[1],
9888 AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
9891 ALIAS (show_bgp_view_rsclient_prefix
,
9892 show_bgp_rsclient_prefix_cmd
,
9893 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
9896 "Information about Route Server Client\n"
9898 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
9900 #endif /* HAVE_IPV6 */
9902 struct bgp_table
*bgp_distance_table
;
9906 /* Distance value for the IP source prefix. */
9909 /* Name of the access-list to be matched. */
9913 static struct bgp_distance
*
9916 struct bgp_distance
*new;
9917 new = XMALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
9918 memset (new, 0, sizeof (struct bgp_distance
));
9923 bgp_distance_free (struct bgp_distance
*bdistance
)
9925 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
9929 bgp_distance_set (struct vty
*vty
, const char *distance_str
,
9930 const char *ip_str
, const char *access_list_str
)
9933 struct prefix_ipv4 p
;
9935 struct bgp_node
*rn
;
9936 struct bgp_distance
*bdistance
;
9938 ret
= str2prefix_ipv4 (ip_str
, &p
);
9941 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
9945 distance
= atoi (distance_str
);
9947 /* Get BGP distance node. */
9948 rn
= bgp_node_get (bgp_distance_table
, (struct prefix
*) &p
);
9951 bdistance
= rn
->info
;
9952 bgp_unlock_node (rn
);
9956 bdistance
= bgp_distance_new ();
9957 rn
->info
= bdistance
;
9960 /* Set distance value. */
9961 bdistance
->distance
= distance
;
9963 /* Reset access-list configuration. */
9964 if (bdistance
->access_list
)
9966 free (bdistance
->access_list
);
9967 bdistance
->access_list
= NULL
;
9969 if (access_list_str
)
9970 bdistance
->access_list
= strdup (access_list_str
);
9976 bgp_distance_unset (struct vty
*vty
, const char *distance_str
,
9977 const char *ip_str
, const char *access_list_str
)
9980 struct prefix_ipv4 p
;
9982 struct bgp_node
*rn
;
9983 struct bgp_distance
*bdistance
;
9985 ret
= str2prefix_ipv4 (ip_str
, &p
);
9988 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
9992 distance
= atoi (distance_str
);
9994 rn
= bgp_node_lookup (bgp_distance_table
, (struct prefix
*)&p
);
9997 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
10001 bdistance
= rn
->info
;
10003 if (bdistance
->access_list
)
10004 free (bdistance
->access_list
);
10005 bgp_distance_free (bdistance
);
10008 bgp_unlock_node (rn
);
10009 bgp_unlock_node (rn
);
10011 return CMD_SUCCESS
;
10015 bgp_distance_reset ()
10017 struct bgp_node
*rn
;
10018 struct bgp_distance
*bdistance
;
10020 for (rn
= bgp_table_top (bgp_distance_table
); rn
; rn
= bgp_route_next (rn
))
10021 if ((bdistance
= rn
->info
) != NULL
)
10023 if (bdistance
->access_list
)
10024 free (bdistance
->access_list
);
10025 bgp_distance_free (bdistance
);
10027 bgp_unlock_node (rn
);
10031 /* Apply BGP information to distance method. */
10033 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, struct bgp
*bgp
)
10035 struct bgp_node
*rn
;
10036 struct prefix_ipv4 q
;
10038 struct bgp_distance
*bdistance
;
10039 struct access_list
*alist
;
10040 struct bgp_static
*bgp_static
;
10045 if (p
->family
!= AF_INET
)
10048 peer
= rinfo
->peer
;
10050 if (peer
->su
.sa
.sa_family
!= AF_INET
)
10053 memset (&q
, 0, sizeof (struct prefix_ipv4
));
10054 q
.family
= AF_INET
;
10055 q
.prefix
= peer
->su
.sin
.sin_addr
;
10056 q
.prefixlen
= IPV4_MAX_BITLEN
;
10058 /* Check source address. */
10059 rn
= bgp_node_match (bgp_distance_table
, (struct prefix
*) &q
);
10062 bdistance
= rn
->info
;
10063 bgp_unlock_node (rn
);
10065 if (bdistance
->access_list
)
10067 alist
= access_list_lookup (AFI_IP
, bdistance
->access_list
);
10068 if (alist
&& access_list_apply (alist
, p
) == FILTER_PERMIT
)
10069 return bdistance
->distance
;
10072 return bdistance
->distance
;
10075 /* Backdoor check. */
10076 rn
= bgp_node_lookup (bgp
->route
[AFI_IP
][SAFI_UNICAST
], p
);
10079 bgp_static
= rn
->info
;
10080 bgp_unlock_node (rn
);
10082 if (bgp_static
->backdoor
)
10084 if (bgp
->distance_local
)
10085 return bgp
->distance_local
;
10087 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
10091 if (peer_sort (peer
) == BGP_PEER_EBGP
)
10093 if (bgp
->distance_ebgp
)
10094 return bgp
->distance_ebgp
;
10095 return ZEBRA_EBGP_DISTANCE_DEFAULT
;
10099 if (bgp
->distance_ibgp
)
10100 return bgp
->distance_ibgp
;
10101 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
10105 DEFUN (bgp_distance
,
10107 "distance bgp <1-255> <1-255> <1-255>",
10108 "Define an administrative distance\n"
10110 "Distance for routes external to the AS\n"
10111 "Distance for routes internal to the AS\n"
10112 "Distance for local routes\n")
10118 bgp
->distance_ebgp
= atoi (argv
[0]);
10119 bgp
->distance_ibgp
= atoi (argv
[1]);
10120 bgp
->distance_local
= atoi (argv
[2]);
10121 return CMD_SUCCESS
;
10124 DEFUN (no_bgp_distance
,
10125 no_bgp_distance_cmd
,
10126 "no distance bgp <1-255> <1-255> <1-255>",
10128 "Define an administrative distance\n"
10130 "Distance for routes external to the AS\n"
10131 "Distance for routes internal to the AS\n"
10132 "Distance for local routes\n")
10138 bgp
->distance_ebgp
= 0;
10139 bgp
->distance_ibgp
= 0;
10140 bgp
->distance_local
= 0;
10141 return CMD_SUCCESS
;
10144 ALIAS (no_bgp_distance
,
10145 no_bgp_distance2_cmd
,
10148 "Define an administrative distance\n"
10151 DEFUN (bgp_distance_source
,
10152 bgp_distance_source_cmd
,
10153 "distance <1-255> A.B.C.D/M",
10154 "Define an administrative distance\n"
10155 "Administrative distance\n"
10156 "IP source prefix\n")
10158 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
10159 return CMD_SUCCESS
;
10162 DEFUN (no_bgp_distance_source
,
10163 no_bgp_distance_source_cmd
,
10164 "no distance <1-255> A.B.C.D/M",
10166 "Define an administrative distance\n"
10167 "Administrative distance\n"
10168 "IP source prefix\n")
10170 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
10171 return CMD_SUCCESS
;
10174 DEFUN (bgp_distance_source_access_list
,
10175 bgp_distance_source_access_list_cmd
,
10176 "distance <1-255> A.B.C.D/M WORD",
10177 "Define an administrative distance\n"
10178 "Administrative distance\n"
10179 "IP source prefix\n"
10180 "Access list name\n")
10182 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
10183 return CMD_SUCCESS
;
10186 DEFUN (no_bgp_distance_source_access_list
,
10187 no_bgp_distance_source_access_list_cmd
,
10188 "no distance <1-255> A.B.C.D/M WORD",
10190 "Define an administrative distance\n"
10191 "Administrative distance\n"
10192 "IP source prefix\n"
10193 "Access list name\n")
10195 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
10196 return CMD_SUCCESS
;
10199 DEFUN (bgp_damp_set
,
10201 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
10202 "BGP Specific commands\n"
10203 "Enable route-flap dampening\n"
10204 "Half-life time for the penalty\n"
10205 "Value to start reusing a route\n"
10206 "Value to start suppressing a route\n"
10207 "Maximum duration to suppress a stable route\n")
10210 int half
= DEFAULT_HALF_LIFE
* 60;
10211 int reuse
= DEFAULT_REUSE
;
10212 int suppress
= DEFAULT_SUPPRESS
;
10213 int max
= 4 * half
;
10217 half
= atoi (argv
[0]) * 60;
10218 reuse
= atoi (argv
[1]);
10219 suppress
= atoi (argv
[2]);
10220 max
= atoi (argv
[3]) * 60;
10222 else if (argc
== 1)
10224 half
= atoi (argv
[0]) * 60;
10229 return bgp_damp_enable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
),
10230 half
, reuse
, suppress
, max
);
10233 ALIAS (bgp_damp_set
,
10235 "bgp dampening <1-45>",
10236 "BGP Specific commands\n"
10237 "Enable route-flap dampening\n"
10238 "Half-life time for the penalty\n")
10240 ALIAS (bgp_damp_set
,
10243 "BGP Specific commands\n"
10244 "Enable route-flap dampening\n")
10246 DEFUN (bgp_damp_unset
,
10247 bgp_damp_unset_cmd
,
10248 "no bgp dampening",
10250 "BGP Specific commands\n"
10251 "Enable route-flap dampening\n")
10256 return bgp_damp_disable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
));
10259 ALIAS (bgp_damp_unset
,
10260 bgp_damp_unset2_cmd
,
10261 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
10263 "BGP Specific commands\n"
10264 "Enable route-flap dampening\n"
10265 "Half-life time for the penalty\n"
10266 "Value to start reusing a route\n"
10267 "Value to start suppressing a route\n"
10268 "Maximum duration to suppress a stable route\n")
10270 DEFUN (show_ip_bgp_dampened_paths
,
10271 show_ip_bgp_dampened_paths_cmd
,
10272 "show ip bgp dampened-paths",
10276 "Display paths suppressed due to dampening\n")
10278 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_dampend_paths
,
10282 DEFUN (show_ip_bgp_flap_statistics
,
10283 show_ip_bgp_flap_statistics_cmd
,
10284 "show ip bgp flap-statistics",
10288 "Display flap statistics of routes\n")
10290 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
10291 bgp_show_type_flap_statistics
, NULL
);
10294 /* Display specified route of BGP table. */
10296 bgp_clear_damp_route (struct vty
*vty
, const char *view_name
,
10297 const char *ip_str
, afi_t afi
, safi_t safi
,
10298 struct prefix_rd
*prd
, int prefix_check
)
10301 struct prefix match
;
10302 struct bgp_node
*rn
;
10303 struct bgp_node
*rm
;
10304 struct bgp_info
*ri
;
10305 struct bgp_info
*ri_temp
;
10307 struct bgp_table
*table
;
10309 /* BGP structure lookup. */
10312 bgp
= bgp_lookup_by_name (view_name
);
10315 vty_out (vty
, "%% Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
10316 return CMD_WARNING
;
10321 bgp
= bgp_get_default ();
10324 vty_out (vty
, "%% No BGP process is configured%s", VTY_NEWLINE
);
10325 return CMD_WARNING
;
10329 /* Check IP address argument. */
10330 ret
= str2prefix (ip_str
, &match
);
10333 vty_out (vty
, "%% address is malformed%s", VTY_NEWLINE
);
10334 return CMD_WARNING
;
10337 match
.family
= afi2family (afi
);
10339 if (safi
== SAFI_MPLS_VPN
)
10341 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][SAFI_MPLS_VPN
]); rn
; rn
= bgp_route_next (rn
))
10343 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
10346 if ((table
= rn
->info
) != NULL
)
10347 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
10348 if (! prefix_check
|| rm
->p
.prefixlen
== match
.prefixlen
)
10355 ri_temp
= ri
->next
;
10356 bgp_damp_info_free (ri
->damp_info
, 1);
10367 if ((rn
= bgp_node_match (bgp
->rib
[afi
][safi
], &match
)) != NULL
)
10368 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
10375 ri_temp
= ri
->next
;
10376 bgp_damp_info_free (ri
->damp_info
, 1);
10385 return CMD_SUCCESS
;
10388 DEFUN (clear_ip_bgp_dampening
,
10389 clear_ip_bgp_dampening_cmd
,
10390 "clear ip bgp dampening",
10394 "Clear route flap dampening information\n")
10396 bgp_damp_info_clean ();
10397 return CMD_SUCCESS
;
10400 DEFUN (clear_ip_bgp_dampening_prefix
,
10401 clear_ip_bgp_dampening_prefix_cmd
,
10402 "clear ip bgp dampening A.B.C.D/M",
10406 "Clear route flap dampening information\n"
10407 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10409 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
10410 SAFI_UNICAST
, NULL
, 1);
10413 DEFUN (clear_ip_bgp_dampening_address
,
10414 clear_ip_bgp_dampening_address_cmd
,
10415 "clear ip bgp dampening A.B.C.D",
10419 "Clear route flap dampening information\n"
10420 "Network to clear damping information\n")
10422 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
10423 SAFI_UNICAST
, NULL
, 0);
10426 DEFUN (clear_ip_bgp_dampening_address_mask
,
10427 clear_ip_bgp_dampening_address_mask_cmd
,
10428 "clear ip bgp dampening A.B.C.D A.B.C.D",
10432 "Clear route flap dampening information\n"
10433 "Network to clear damping information\n"
10437 char prefix_str
[BUFSIZ
];
10439 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
10442 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
10443 return CMD_WARNING
;
10446 return bgp_clear_damp_route (vty
, NULL
, prefix_str
, AFI_IP
,
10447 SAFI_UNICAST
, NULL
, 0);
10451 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
10452 afi_t afi
, safi_t safi
, int *write
)
10454 struct bgp_node
*prn
;
10455 struct bgp_node
*rn
;
10456 struct bgp_table
*table
;
10458 struct prefix_rd
*prd
;
10459 struct bgp_static
*bgp_static
;
10461 char buf
[SU_ADDRSTRLEN
];
10462 char rdbuf
[RD_ADDRSTRLEN
];
10464 /* Network configuration. */
10465 for (prn
= bgp_table_top (bgp
->route
[afi
][safi
]); prn
; prn
= bgp_route_next (prn
))
10466 if ((table
= prn
->info
) != NULL
)
10467 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
10468 if ((bgp_static
= rn
->info
) != NULL
)
10471 prd
= (struct prefix_rd
*) &prn
->p
;
10473 /* "address-family" display. */
10474 bgp_config_write_family_header (vty
, afi
, safi
, write
);
10476 /* "network" configuration display. */
10477 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
10478 label
= decode_label (bgp_static
->tag
);
10480 vty_out (vty
, " network %s/%d rd %s tag %d",
10481 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
10484 vty_out (vty
, "%s", VTY_NEWLINE
);
10489 /* Configuration of static route announcement and aggregate
10492 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
10493 afi_t afi
, safi_t safi
, int *write
)
10495 struct bgp_node
*rn
;
10497 struct bgp_static
*bgp_static
;
10498 struct bgp_aggregate
*bgp_aggregate
;
10499 char buf
[SU_ADDRSTRLEN
];
10501 if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
10502 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
10504 /* Network configuration. */
10505 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
10506 if ((bgp_static
= rn
->info
) != NULL
)
10510 /* "address-family" display. */
10511 bgp_config_write_family_header (vty
, afi
, safi
, write
);
10513 /* "network" configuration display. */
10514 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
10516 u_int32_t destination
;
10517 struct in_addr netmask
;
10519 destination
= ntohl (p
->u
.prefix4
.s_addr
);
10520 masklen2ip (p
->prefixlen
, &netmask
);
10521 vty_out (vty
, " network %s",
10522 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
));
10524 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
10525 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
10526 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
10527 || p
->u
.prefix4
.s_addr
== 0)
10529 /* Natural mask is not display. */
10532 vty_out (vty
, " mask %s", inet_ntoa (netmask
));
10536 vty_out (vty
, " network %s/%d",
10537 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
10541 if (bgp_static
->rmap
.name
)
10542 vty_out (vty
, " route-map %s", bgp_static
->rmap
.name
);
10543 else if (bgp_static
->backdoor
)
10544 vty_out (vty
, " backdoor");
10546 vty_out (vty
, "%s", VTY_NEWLINE
);
10549 /* Aggregate-address configuration. */
10550 for (rn
= bgp_table_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
10551 if ((bgp_aggregate
= rn
->info
) != NULL
)
10555 /* "address-family" display. */
10556 bgp_config_write_family_header (vty
, afi
, safi
, write
);
10558 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
10560 struct in_addr netmask
;
10562 masklen2ip (p
->prefixlen
, &netmask
);
10563 vty_out (vty
, " aggregate-address %s %s",
10564 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
10565 inet_ntoa (netmask
));
10569 vty_out (vty
, " aggregate-address %s/%d",
10570 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
10574 if (bgp_aggregate
->as_set
)
10575 vty_out (vty
, " as-set");
10577 if (bgp_aggregate
->summary_only
)
10578 vty_out (vty
, " summary-only");
10580 vty_out (vty
, "%s", VTY_NEWLINE
);
10587 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
)
10589 struct bgp_node
*rn
;
10590 struct bgp_distance
*bdistance
;
10592 /* Distance configuration. */
10593 if (bgp
->distance_ebgp
10594 && bgp
->distance_ibgp
10595 && bgp
->distance_local
10596 && (bgp
->distance_ebgp
!= ZEBRA_EBGP_DISTANCE_DEFAULT
10597 || bgp
->distance_ibgp
!= ZEBRA_IBGP_DISTANCE_DEFAULT
10598 || bgp
->distance_local
!= ZEBRA_IBGP_DISTANCE_DEFAULT
))
10599 vty_out (vty
, " distance bgp %d %d %d%s",
10600 bgp
->distance_ebgp
, bgp
->distance_ibgp
, bgp
->distance_local
,
10603 for (rn
= bgp_table_top (bgp_distance_table
); rn
; rn
= bgp_route_next (rn
))
10604 if ((bdistance
= rn
->info
) != NULL
)
10606 vty_out (vty
, " distance %d %s/%d %s%s", bdistance
->distance
,
10607 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
10608 bdistance
->access_list
? bdistance
->access_list
: "",
10615 /* Allocate routing table structure and install commands. */
10619 /* Init BGP distance table. */
10620 bgp_distance_table
= bgp_table_init (AFI_IP
, SAFI_UNICAST
);
10622 /* IPv4 BGP commands. */
10623 install_element (BGP_NODE
, &bgp_network_cmd
);
10624 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
10625 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
10626 install_element (BGP_NODE
, &bgp_network_route_map_cmd
);
10627 install_element (BGP_NODE
, &bgp_network_mask_route_map_cmd
);
10628 install_element (BGP_NODE
, &bgp_network_mask_natural_route_map_cmd
);
10629 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
10630 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
10631 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
10632 install_element (BGP_NODE
, &no_bgp_network_cmd
);
10633 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
10634 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
10635 install_element (BGP_NODE
, &no_bgp_network_route_map_cmd
);
10636 install_element (BGP_NODE
, &no_bgp_network_mask_route_map_cmd
);
10637 install_element (BGP_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
10638 install_element (BGP_NODE
, &no_bgp_network_backdoor_cmd
);
10639 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_cmd
);
10640 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_cmd
);
10642 install_element (BGP_NODE
, &aggregate_address_cmd
);
10643 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
10644 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
10645 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
10646 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
10647 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
10648 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
10649 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
10650 install_element (BGP_NODE
, &aggregate_address_summary_as_set_cmd
);
10651 install_element (BGP_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
10652 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
10653 install_element (BGP_NODE
, &no_aggregate_address_summary_only_cmd
);
10654 install_element (BGP_NODE
, &no_aggregate_address_as_set_cmd
);
10655 install_element (BGP_NODE
, &no_aggregate_address_as_set_summary_cmd
);
10656 install_element (BGP_NODE
, &no_aggregate_address_summary_as_set_cmd
);
10657 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
10658 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
10659 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_cmd
);
10660 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
10661 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
10663 /* IPv4 unicast configuration. */
10664 install_element (BGP_IPV4_NODE
, &bgp_network_cmd
);
10665 install_element (BGP_IPV4_NODE
, &bgp_network_mask_cmd
);
10666 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_cmd
);
10667 install_element (BGP_IPV4_NODE
, &bgp_network_route_map_cmd
);
10668 install_element (BGP_IPV4_NODE
, &bgp_network_mask_route_map_cmd
);
10669 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_route_map_cmd
);
10670 install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
10671 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_cmd
);
10672 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_cmd
);
10673 install_element (BGP_IPV4_NODE
, &no_bgp_network_route_map_cmd
);
10674 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_route_map_cmd
);
10675 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
10676 install_element (BGP_IPV4_NODE
, &aggregate_address_cmd
);
10677 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_cmd
);
10678 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_only_cmd
);
10679 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_only_cmd
);
10680 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_cmd
);
10681 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_cmd
);
10682 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_summary_cmd
);
10683 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
10684 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_as_set_cmd
);
10685 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
10686 install_element (BGP_IPV4_NODE
, &no_aggregate_address_cmd
);
10687 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_only_cmd
);
10688 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_cmd
);
10689 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_summary_cmd
);
10690 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_as_set_cmd
);
10691 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_cmd
);
10692 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
10693 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_cmd
);
10694 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
10695 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
10697 /* IPv4 multicast configuration. */
10698 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
10699 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
10700 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
10701 install_element (BGP_IPV4M_NODE
, &bgp_network_route_map_cmd
);
10702 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_route_map_cmd
);
10703 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_route_map_cmd
);
10704 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
10705 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
10706 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
10707 install_element (BGP_IPV4M_NODE
, &no_bgp_network_route_map_cmd
);
10708 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_route_map_cmd
);
10709 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
10710 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
10711 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
10712 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
10713 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
10714 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
10715 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
10716 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
10717 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
10718 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_as_set_cmd
);
10719 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
10720 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
10721 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_only_cmd
);
10722 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_cmd
);
10723 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_summary_cmd
);
10724 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_as_set_cmd
);
10725 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
10726 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
10727 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_cmd
);
10728 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
10729 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
10731 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
10732 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
10733 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
10734 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
10735 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
10736 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
10737 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
10738 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
10739 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
10740 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
10741 install_element (VIEW_NODE
, &show_ip_bgp_view_cmd
);
10742 install_element (VIEW_NODE
, &show_ip_bgp_view_route_cmd
);
10743 install_element (VIEW_NODE
, &show_ip_bgp_view_prefix_cmd
);
10744 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
10745 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
10746 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
10747 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
10748 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
10749 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
10750 install_element (VIEW_NODE
, &show_ip_bgp_route_map_cmd
);
10751 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
10752 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
10753 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
10754 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
10755 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
10756 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
10757 install_element (VIEW_NODE
, &show_ip_bgp_community2_cmd
);
10758 install_element (VIEW_NODE
, &show_ip_bgp_community3_cmd
);
10759 install_element (VIEW_NODE
, &show_ip_bgp_community4_cmd
);
10760 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
10761 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
10762 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
10763 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
10764 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
10765 install_element (VIEW_NODE
, &show_ip_bgp_community2_exact_cmd
);
10766 install_element (VIEW_NODE
, &show_ip_bgp_community3_exact_cmd
);
10767 install_element (VIEW_NODE
, &show_ip_bgp_community4_exact_cmd
);
10768 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
10769 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
10770 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
10771 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
10772 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
10773 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
10774 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
10775 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
10776 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
10777 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
10778 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
10779 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
10780 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
10781 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
10782 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
10783 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
10784 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
10785 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
10786 install_element (VIEW_NODE
, &show_ip_bgp_dampened_paths_cmd
);
10787 install_element (VIEW_NODE
, &show_ip_bgp_flap_statistics_cmd
);
10788 install_element (VIEW_NODE
, &show_ip_bgp_flap_address_cmd
);
10789 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_cmd
);
10790 install_element (VIEW_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
10791 install_element (VIEW_NODE
, &show_ip_bgp_flap_regexp_cmd
);
10792 install_element (VIEW_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
10793 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
10794 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
10795 install_element (VIEW_NODE
, &show_ip_bgp_flap_route_map_cmd
);
10796 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
10797 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
10798 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_cmd
);
10799 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_route_cmd
);
10800 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
10801 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_cmd
);
10802 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
10803 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
10805 install_element (ENABLE_NODE
, &show_ip_bgp_cmd
);
10806 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cmd
);
10807 install_element (ENABLE_NODE
, &show_ip_bgp_route_cmd
);
10808 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_cmd
);
10809 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
10810 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
10811 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_cmd
);
10812 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
10813 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
10814 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
10815 install_element (ENABLE_NODE
, &show_ip_bgp_view_cmd
);
10816 install_element (ENABLE_NODE
, &show_ip_bgp_view_route_cmd
);
10817 install_element (ENABLE_NODE
, &show_ip_bgp_view_prefix_cmd
);
10818 install_element (ENABLE_NODE
, &show_ip_bgp_regexp_cmd
);
10819 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
10820 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_list_cmd
);
10821 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
10822 install_element (ENABLE_NODE
, &show_ip_bgp_filter_list_cmd
);
10823 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
10824 install_element (ENABLE_NODE
, &show_ip_bgp_route_map_cmd
);
10825 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
10826 install_element (ENABLE_NODE
, &show_ip_bgp_cidr_only_cmd
);
10827 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
10828 install_element (ENABLE_NODE
, &show_ip_bgp_community_all_cmd
);
10829 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
10830 install_element (ENABLE_NODE
, &show_ip_bgp_community_cmd
);
10831 install_element (ENABLE_NODE
, &show_ip_bgp_community2_cmd
);
10832 install_element (ENABLE_NODE
, &show_ip_bgp_community3_cmd
);
10833 install_element (ENABLE_NODE
, &show_ip_bgp_community4_cmd
);
10834 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_cmd
);
10835 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
10836 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
10837 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
10838 install_element (ENABLE_NODE
, &show_ip_bgp_community_exact_cmd
);
10839 install_element (ENABLE_NODE
, &show_ip_bgp_community2_exact_cmd
);
10840 install_element (ENABLE_NODE
, &show_ip_bgp_community3_exact_cmd
);
10841 install_element (ENABLE_NODE
, &show_ip_bgp_community4_exact_cmd
);
10842 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
10843 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
10844 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
10845 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
10846 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_cmd
);
10847 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
10848 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_exact_cmd
);
10849 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
10850 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_longer_cmd
);
10851 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
10852 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
10853 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
10854 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
10855 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
10856 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
10857 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
10858 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
10859 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
10860 install_element (ENABLE_NODE
, &show_ip_bgp_dampened_paths_cmd
);
10861 install_element (ENABLE_NODE
, &show_ip_bgp_flap_statistics_cmd
);
10862 install_element (ENABLE_NODE
, &show_ip_bgp_flap_address_cmd
);
10863 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_cmd
);
10864 install_element (ENABLE_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
10865 install_element (ENABLE_NODE
, &show_ip_bgp_flap_regexp_cmd
);
10866 install_element (ENABLE_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
10867 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
10868 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
10869 install_element (ENABLE_NODE
, &show_ip_bgp_flap_route_map_cmd
);
10870 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
10871 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
10872 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_cmd
);
10873 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_route_cmd
);
10874 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
10875 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_cmd
);
10876 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
10877 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
10879 /* BGP dampening clear commands */
10880 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_cmd
);
10881 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_prefix_cmd
);
10882 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_cmd
);
10883 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_mask_cmd
);
10886 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_prefix_counts_cmd
);
10887 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
);
10888 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
);
10890 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_prefix_counts_cmd
);
10892 /* New config IPv6 BGP commands. */
10893 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
10894 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_route_map_cmd
);
10895 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
10896 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_route_map_cmd
);
10898 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
10899 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
10900 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
10901 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
10903 /* Old config IPv6 BGP commands. */
10904 install_element (BGP_NODE
, &old_ipv6_bgp_network_cmd
);
10905 install_element (BGP_NODE
, &old_no_ipv6_bgp_network_cmd
);
10907 install_element (BGP_NODE
, &old_ipv6_aggregate_address_cmd
);
10908 install_element (BGP_NODE
, &old_ipv6_aggregate_address_summary_only_cmd
);
10909 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_cmd
);
10910 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_summary_only_cmd
);
10912 install_element (VIEW_NODE
, &show_bgp_cmd
);
10913 install_element (VIEW_NODE
, &show_bgp_ipv6_cmd
);
10914 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
10915 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
10916 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
10917 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
10918 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
10919 install_element (VIEW_NODE
, &show_bgp_ipv6_regexp_cmd
);
10920 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
10921 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
10922 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
10923 install_element (VIEW_NODE
, &show_bgp_ipv6_filter_list_cmd
);
10924 install_element (VIEW_NODE
, &show_bgp_route_map_cmd
);
10925 install_element (VIEW_NODE
, &show_bgp_ipv6_route_map_cmd
);
10926 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
10927 install_element (VIEW_NODE
, &show_bgp_ipv6_community_all_cmd
);
10928 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
10929 install_element (VIEW_NODE
, &show_bgp_ipv6_community_cmd
);
10930 install_element (VIEW_NODE
, &show_bgp_community2_cmd
);
10931 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_cmd
);
10932 install_element (VIEW_NODE
, &show_bgp_community3_cmd
);
10933 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_cmd
);
10934 install_element (VIEW_NODE
, &show_bgp_community4_cmd
);
10935 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_cmd
);
10936 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
10937 install_element (VIEW_NODE
, &show_bgp_ipv6_community_exact_cmd
);
10938 install_element (VIEW_NODE
, &show_bgp_community2_exact_cmd
);
10939 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
10940 install_element (VIEW_NODE
, &show_bgp_community3_exact_cmd
);
10941 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
10942 install_element (VIEW_NODE
, &show_bgp_community4_exact_cmd
);
10943 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
10944 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
10945 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_cmd
);
10946 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
10947 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
10948 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
10949 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
10950 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
10951 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
10952 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
10953 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
10954 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
10955 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
10956 install_element (VIEW_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
10957 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
10958 install_element (VIEW_NODE
, &show_bgp_neighbor_flap_cmd
);
10959 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
10960 install_element (VIEW_NODE
, &show_bgp_neighbor_damp_cmd
);
10961 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
10962 install_element (VIEW_NODE
, &show_bgp_rsclient_cmd
);
10963 install_element (VIEW_NODE
, &show_bgp_rsclient_route_cmd
);
10964 install_element (VIEW_NODE
, &show_bgp_rsclient_prefix_cmd
);
10965 install_element (VIEW_NODE
, &show_bgp_view_cmd
);
10966 install_element (VIEW_NODE
, &show_bgp_view_ipv6_cmd
);
10967 install_element (VIEW_NODE
, &show_bgp_view_route_cmd
);
10968 install_element (VIEW_NODE
, &show_bgp_view_ipv6_route_cmd
);
10969 install_element (VIEW_NODE
, &show_bgp_view_prefix_cmd
);
10970 install_element (VIEW_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
10971 install_element (VIEW_NODE
, &show_bgp_view_neighbor_advertised_route_cmd
);
10972 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_advertised_route_cmd
);
10973 install_element (VIEW_NODE
, &show_bgp_view_neighbor_received_routes_cmd
);
10974 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_received_routes_cmd
);
10975 install_element (VIEW_NODE
, &show_bgp_view_neighbor_routes_cmd
);
10976 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_routes_cmd
);
10977 install_element (VIEW_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
10978 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
10979 install_element (VIEW_NODE
, &show_bgp_view_neighbor_flap_cmd
);
10980 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_flap_cmd
);
10981 install_element (VIEW_NODE
, &show_bgp_view_neighbor_damp_cmd
);
10982 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_damp_cmd
);
10983 install_element (VIEW_NODE
, &show_bgp_view_rsclient_cmd
);
10984 install_element (VIEW_NODE
, &show_bgp_view_rsclient_route_cmd
);
10985 install_element (VIEW_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
10987 install_element (ENABLE_NODE
, &show_bgp_cmd
);
10988 install_element (ENABLE_NODE
, &show_bgp_ipv6_cmd
);
10989 install_element (ENABLE_NODE
, &show_bgp_route_cmd
);
10990 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_cmd
);
10991 install_element (ENABLE_NODE
, &show_bgp_prefix_cmd
);
10992 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_cmd
);
10993 install_element (ENABLE_NODE
, &show_bgp_regexp_cmd
);
10994 install_element (ENABLE_NODE
, &show_bgp_ipv6_regexp_cmd
);
10995 install_element (ENABLE_NODE
, &show_bgp_prefix_list_cmd
);
10996 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
10997 install_element (ENABLE_NODE
, &show_bgp_filter_list_cmd
);
10998 install_element (ENABLE_NODE
, &show_bgp_ipv6_filter_list_cmd
);
10999 install_element (ENABLE_NODE
, &show_bgp_route_map_cmd
);
11000 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_map_cmd
);
11001 install_element (ENABLE_NODE
, &show_bgp_community_all_cmd
);
11002 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_all_cmd
);
11003 install_element (ENABLE_NODE
, &show_bgp_community_cmd
);
11004 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_cmd
);
11005 install_element (ENABLE_NODE
, &show_bgp_community2_cmd
);
11006 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_cmd
);
11007 install_element (ENABLE_NODE
, &show_bgp_community3_cmd
);
11008 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_cmd
);
11009 install_element (ENABLE_NODE
, &show_bgp_community4_cmd
);
11010 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_cmd
);
11011 install_element (ENABLE_NODE
, &show_bgp_community_exact_cmd
);
11012 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_exact_cmd
);
11013 install_element (ENABLE_NODE
, &show_bgp_community2_exact_cmd
);
11014 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
11015 install_element (ENABLE_NODE
, &show_bgp_community3_exact_cmd
);
11016 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
11017 install_element (ENABLE_NODE
, &show_bgp_community4_exact_cmd
);
11018 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
11019 install_element (ENABLE_NODE
, &show_bgp_community_list_cmd
);
11020 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_cmd
);
11021 install_element (ENABLE_NODE
, &show_bgp_community_list_exact_cmd
);
11022 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
11023 install_element (ENABLE_NODE
, &show_bgp_prefix_longer_cmd
);
11024 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
11025 install_element (ENABLE_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
11026 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
11027 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_routes_cmd
);
11028 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
11029 install_element (ENABLE_NODE
, &show_bgp_neighbor_routes_cmd
);
11030 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
11031 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
11032 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
11033 install_element (ENABLE_NODE
, &show_bgp_neighbor_flap_cmd
);
11034 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
11035 install_element (ENABLE_NODE
, &show_bgp_neighbor_damp_cmd
);
11036 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
11037 install_element (ENABLE_NODE
, &show_bgp_rsclient_cmd
);
11038 install_element (ENABLE_NODE
, &show_bgp_rsclient_route_cmd
);
11039 install_element (ENABLE_NODE
, &show_bgp_rsclient_prefix_cmd
);
11040 install_element (ENABLE_NODE
, &show_bgp_view_cmd
);
11041 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_cmd
);
11042 install_element (ENABLE_NODE
, &show_bgp_view_route_cmd
);
11043 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_route_cmd
);
11044 install_element (ENABLE_NODE
, &show_bgp_view_prefix_cmd
);
11045 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
11046 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_advertised_route_cmd
);
11047 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_advertised_route_cmd
);
11048 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_received_routes_cmd
);
11049 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_received_routes_cmd
);
11050 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_routes_cmd
);
11051 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_routes_cmd
);
11052 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
11053 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
11054 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_flap_cmd
);
11055 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_flap_cmd
);
11056 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_damp_cmd
);
11057 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_damp_cmd
);
11058 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_cmd
);
11059 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_route_cmd
);
11060 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
11063 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
11064 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
11065 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
11066 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
11067 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
11068 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
11069 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
11070 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
11071 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_cmd
);
11072 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_cmd
);
11073 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_cmd
);
11074 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
11075 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
11076 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
11077 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
11078 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
11079 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
11080 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
11081 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
11082 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
11083 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
11084 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
11085 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
11086 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
11087 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
11088 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
11089 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_cmd
);
11090 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_cmd
);
11091 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_cmd
);
11092 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
11093 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
11094 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
11095 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
11096 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
11097 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
11098 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
11101 install_element (ENABLE_NODE
, &show_ipv6_bgp_cmd
);
11102 install_element (ENABLE_NODE
, &show_ipv6_bgp_route_cmd
);
11103 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_cmd
);
11104 install_element (ENABLE_NODE
, &show_ipv6_bgp_regexp_cmd
);
11105 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
11106 install_element (ENABLE_NODE
, &show_ipv6_bgp_filter_list_cmd
);
11107 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_all_cmd
);
11108 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_cmd
);
11109 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_cmd
);
11110 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_cmd
);
11111 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_cmd
);
11112 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_exact_cmd
);
11113 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
11114 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
11115 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
11116 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_cmd
);
11117 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
11118 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
11119 install_element (ENABLE_NODE
, &show_ipv6_mbgp_cmd
);
11120 install_element (ENABLE_NODE
, &show_ipv6_mbgp_route_cmd
);
11121 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_cmd
);
11122 install_element (ENABLE_NODE
, &show_ipv6_mbgp_regexp_cmd
);
11123 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
11124 install_element (ENABLE_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
11125 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_all_cmd
);
11126 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_cmd
);
11127 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_cmd
);
11128 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_cmd
);
11129 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_cmd
);
11130 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
11131 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
11132 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
11133 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
11134 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_cmd
);
11135 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
11136 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
11139 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
11140 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
11141 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
11142 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
11145 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
11146 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
11147 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
11148 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
11151 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
11152 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
11153 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
11154 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
11155 #endif /* HAVE_IPV6 */
11157 install_element (BGP_NODE
, &bgp_distance_cmd
);
11158 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
11159 install_element (BGP_NODE
, &no_bgp_distance2_cmd
);
11160 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
11161 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
11162 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
11163 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
11165 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
11166 install_element (BGP_NODE
, &bgp_damp_set2_cmd
);
11167 install_element (BGP_NODE
, &bgp_damp_set3_cmd
);
11168 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
11169 install_element (BGP_NODE
, &bgp_damp_unset2_cmd
);
11170 install_element (BGP_IPV4_NODE
, &bgp_damp_set_cmd
);
11171 install_element (BGP_IPV4_NODE
, &bgp_damp_set2_cmd
);
11172 install_element (BGP_IPV4_NODE
, &bgp_damp_set3_cmd
);
11173 install_element (BGP_IPV4_NODE
, &bgp_damp_unset_cmd
);
11174 install_element (BGP_IPV4_NODE
, &bgp_damp_unset2_cmd
);