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 const char *bgp_origin_str
[];
60 extern const 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 bgp_info_extra */
93 static struct bgp_info_extra
*
94 bgp_info_extra_new (void)
96 struct bgp_info_extra
*new;
97 new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA
, sizeof (struct bgp_info_extra
));
102 bgp_info_extra_free (struct bgp_info_extra
**extra
)
106 if ((*extra
)->damp_info
)
107 bgp_damp_info_free ((*extra
)->damp_info
, 0);
109 (*extra
)->damp_info
= NULL
;
111 XFREE (MTYPE_BGP_ROUTE_EXTRA
, *extra
);
117 /* Get bgp_info extra information for the given bgp_info, lazy allocated
120 struct bgp_info_extra
*
121 bgp_info_extra_get (struct bgp_info
*ri
)
124 ri
->extra
= bgp_info_extra_new();
128 /* Allocate new bgp info structure. */
129 static struct bgp_info
*
132 return XCALLOC (MTYPE_BGP_ROUTE
, sizeof (struct bgp_info
));
135 /* Free bgp route information. */
137 bgp_info_free (struct bgp_info
*binfo
)
140 bgp_attr_unintern (&binfo
->attr
);
142 bgp_info_extra_free (&binfo
->extra
);
144 peer_unlock (binfo
->peer
); /* bgp_info peer reference */
146 XFREE (MTYPE_BGP_ROUTE
, binfo
);
150 bgp_info_lock (struct bgp_info
*binfo
)
157 bgp_info_unlock (struct bgp_info
*binfo
)
159 assert (binfo
&& binfo
->lock
> 0);
162 if (binfo
->lock
== 0)
165 zlog_debug ("%s: unlocked and freeing", __func__
);
166 zlog_backtrace (LOG_DEBUG
);
168 bgp_info_free (binfo
);
173 if (binfo
->lock
== 1)
175 zlog_debug ("%s: unlocked to 1", __func__
);
176 zlog_backtrace (LOG_DEBUG
);
184 bgp_info_add (struct bgp_node
*rn
, struct bgp_info
*ri
)
186 struct bgp_info
*top
;
198 peer_lock (ri
->peer
); /* bgp_info peer reference */
201 /* Do the actual removal of info from RIB, for use by bgp_process
202 completion callback *only* */
204 bgp_info_reap (struct bgp_node
*rn
, struct bgp_info
*ri
)
207 ri
->next
->prev
= ri
->prev
;
209 ri
->prev
->next
= ri
->next
;
213 bgp_info_unlock (ri
);
214 bgp_unlock_node (rn
);
218 bgp_info_delete (struct bgp_node
*rn
, struct bgp_info
*ri
)
220 bgp_info_set_flag (rn
, ri
, BGP_INFO_REMOVED
);
221 /* set of previous already took care of pcount */
222 UNSET_FLAG (ri
->flags
, BGP_INFO_VALID
);
225 /* undo the effects of a previous call to bgp_info_delete; typically
226 called when a route is deleted and then quickly re-added before the
227 deletion has been processed */
229 bgp_info_restore (struct bgp_node
*rn
, struct bgp_info
*ri
)
231 bgp_info_unset_flag (rn
, ri
, BGP_INFO_REMOVED
);
232 /* unset of previous already took care of pcount */
233 SET_FLAG (ri
->flags
, BGP_INFO_VALID
);
236 /* Adjust pcount as required */
238 bgp_pcount_adjust (struct bgp_node
*rn
, struct bgp_info
*ri
)
240 assert (rn
&& rn
->table
);
241 assert (ri
&& ri
->peer
&& ri
->peer
->bgp
);
243 /* Ignore 'pcount' for RS-client tables */
244 if (rn
->table
->type
!= BGP_TABLE_MAIN
245 || ri
->peer
== ri
->peer
->bgp
->peer_self
)
248 if (BGP_INFO_HOLDDOWN (ri
)
249 && CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
252 UNSET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
254 /* slight hack, but more robust against errors. */
255 if (ri
->peer
->pcount
[rn
->table
->afi
][rn
->table
->safi
])
256 ri
->peer
->pcount
[rn
->table
->afi
][rn
->table
->safi
]--;
259 zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s",
260 __func__
, ri
->peer
->host
);
261 zlog_backtrace (LOG_WARNING
);
262 zlog_warn ("%s: Please report to Quagga bugzilla", __func__
);
265 else if (!BGP_INFO_HOLDDOWN (ri
)
266 && !CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
268 SET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
269 ri
->peer
->pcount
[rn
->table
->afi
][rn
->table
->safi
]++;
274 /* Set/unset bgp_info flags, adjusting any other state as needed.
275 * This is here primarily to keep prefix-count in check.
278 bgp_info_set_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
280 SET_FLAG (ri
->flags
, flag
);
282 /* early bath if we know it's not a flag that changes useability state */
283 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_UNUSEABLE
))
286 bgp_pcount_adjust (rn
, ri
);
290 bgp_info_unset_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
292 UNSET_FLAG (ri
->flags
, flag
);
294 /* early bath if we know it's not a flag that changes useability state */
295 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_UNUSEABLE
))
298 bgp_pcount_adjust (rn
, ri
);
301 /* Get MED value. If MED value is missing and "bgp bestpath
302 missing-as-worst" is specified, treat it as the worst value. */
304 bgp_med_value (struct attr
*attr
, struct bgp
*bgp
)
306 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
310 if (bgp_flag_check (bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
317 /* Compare two bgp route entity. br is preferable then return 1. */
319 bgp_info_cmp (struct bgp
*bgp
, struct bgp_info
*new, struct bgp_info
*exist
)
322 u_int32_t exist_pref
;
325 u_int32_t new_weight
= 0;
326 u_int32_t exist_weight
= 0;
327 struct in_addr new_id
;
328 struct in_addr exist_id
;
331 int internal_as_route
= 0;
332 int confed_as_route
= 0;
341 /* 1. Weight check. */
342 if (new->attr
->extra
)
343 new_weight
= new->attr
->extra
->weight
;
344 if (exist
->attr
->extra
)
345 exist_weight
= exist
->attr
->extra
->weight
;
346 if (new_weight
> exist_weight
)
348 if (new_weight
< exist_weight
)
351 /* 2. Local preference check. */
352 if (new->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
353 new_pref
= new->attr
->local_pref
;
355 new_pref
= bgp
->default_local_pref
;
357 if (exist
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
358 exist_pref
= exist
->attr
->local_pref
;
360 exist_pref
= bgp
->default_local_pref
;
362 if (new_pref
> exist_pref
)
364 if (new_pref
< exist_pref
)
367 /* 3. Local route check. */
368 if (new->sub_type
== BGP_ROUTE_STATIC
)
370 if (exist
->sub_type
== BGP_ROUTE_STATIC
)
373 if (new->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
375 if (exist
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
378 if (new->sub_type
== BGP_ROUTE_AGGREGATE
)
380 if (exist
->sub_type
== BGP_ROUTE_AGGREGATE
)
383 /* 4. AS path length check. */
384 if (! bgp_flag_check (bgp
, BGP_FLAG_ASPATH_IGNORE
))
386 int exist_hops
= aspath_count_hops (exist
->attr
->aspath
);
387 int exist_confeds
= aspath_count_confeds (exist
->attr
->aspath
);
389 if (bgp_flag_check (bgp
, BGP_FLAG_ASPATH_CONFED
))
393 aspath_hops
= aspath_count_hops (new->attr
->aspath
);
394 aspath_hops
+= aspath_count_confeds (new->attr
->aspath
);
396 if ( aspath_hops
< (exist_hops
+ exist_confeds
))
398 if ( aspath_hops
> (exist_hops
+ exist_confeds
))
403 int newhops
= aspath_count_hops (new->attr
->aspath
);
405 if (newhops
< exist_hops
)
407 if (newhops
> exist_hops
)
412 /* 5. Origin check. */
413 if (new->attr
->origin
< exist
->attr
->origin
)
415 if (new->attr
->origin
> exist
->attr
->origin
)
419 internal_as_route
= (aspath_count_hops (new->attr
->aspath
) == 0
420 && aspath_count_hops (exist
->attr
->aspath
) == 0);
421 confed_as_route
= (aspath_count_confeds (new->attr
->aspath
) > 0
422 && aspath_count_confeds (exist
->attr
->aspath
) > 0
423 && aspath_count_hops (new->attr
->aspath
) == 0
424 && aspath_count_hops (exist
->attr
->aspath
) == 0);
426 if (bgp_flag_check (bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
)
427 || (bgp_flag_check (bgp
, BGP_FLAG_MED_CONFED
)
429 || aspath_cmp_left (new->attr
->aspath
, exist
->attr
->aspath
)
430 || aspath_cmp_left_confed (new->attr
->aspath
, exist
->attr
->aspath
)
431 || internal_as_route
)
433 new_med
= bgp_med_value (new->attr
, bgp
);
434 exist_med
= bgp_med_value (exist
->attr
, bgp
);
436 if (new_med
< exist_med
)
438 if (new_med
> exist_med
)
442 /* 7. Peer type check. */
443 if (peer_sort (new->peer
) == BGP_PEER_EBGP
444 && peer_sort (exist
->peer
) == BGP_PEER_IBGP
)
446 if (peer_sort (new->peer
) == BGP_PEER_EBGP
447 && peer_sort (exist
->peer
) == BGP_PEER_CONFED
)
449 if (peer_sort (new->peer
) == BGP_PEER_IBGP
450 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
452 if (peer_sort (new->peer
) == BGP_PEER_CONFED
453 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
456 /* 8. IGP metric check. */
457 if (new->extra
|| exist
->extra
)
459 uint32_t newm
= (new->extra
? new->extra
->igpmetric
: 0);
460 uint32_t existm
= (exist
->extra
? exist
->extra
->igpmetric
: 0);
468 /* 9. Maximum path check. */
470 /* 10. If both paths are external, prefer the path that was received
471 first (the oldest one). This step minimizes route-flap, since a
472 newer path won't displace an older one, even if it was the
473 preferred route based on the additional decision criteria below. */
474 if (! bgp_flag_check (bgp
, BGP_FLAG_COMPARE_ROUTER_ID
)
475 && peer_sort (new->peer
) == BGP_PEER_EBGP
476 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
478 if (CHECK_FLAG (new->flags
, BGP_INFO_SELECTED
))
480 if (CHECK_FLAG (exist
->flags
, BGP_INFO_SELECTED
))
484 /* 11. Rourter-ID comparision. */
485 if (new->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
486 new_id
.s_addr
= new->attr
->extra
->originator_id
.s_addr
;
488 new_id
.s_addr
= new->peer
->remote_id
.s_addr
;
489 if (exist
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
490 exist_id
.s_addr
= exist
->attr
->extra
->originator_id
.s_addr
;
492 exist_id
.s_addr
= exist
->peer
->remote_id
.s_addr
;
494 if (ntohl (new_id
.s_addr
) < ntohl (exist_id
.s_addr
))
496 if (ntohl (new_id
.s_addr
) > ntohl (exist_id
.s_addr
))
499 /* 12. Cluster length comparision. */
500 if (new->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
501 new_cluster
= new->attr
->extra
->cluster
->length
;
504 if (exist
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
505 exist_cluster
= exist
->attr
->extra
->cluster
->length
;
509 if (new_cluster
< exist_cluster
)
511 if (new_cluster
> exist_cluster
)
514 /* 13. Neighbor address comparision. */
515 ret
= sockunion_cmp (new->peer
->su_remote
, exist
->peer
->su_remote
);
525 static enum filter_type
526 bgp_input_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
527 afi_t afi
, safi_t safi
)
529 struct bgp_filter
*filter
;
531 filter
= &peer
->filter
[afi
][safi
];
533 #define FILTER_EXIST_WARN(F,f,filter) \
534 if (BGP_DEBUG (update, UPDATE_IN) \
535 && !(F ## _IN (filter))) \
536 plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \
537 peer->host, #f, F ## _IN_NAME(filter));
539 if (DISTRIBUTE_IN_NAME (filter
)) {
540 FILTER_EXIST_WARN(DISTRIBUTE
, distribute
, filter
);
542 if (access_list_apply (DISTRIBUTE_IN (filter
), p
) == FILTER_DENY
)
546 if (PREFIX_LIST_IN_NAME (filter
)) {
547 FILTER_EXIST_WARN(PREFIX_LIST
, prefix
, filter
);
549 if (prefix_list_apply (PREFIX_LIST_IN (filter
), p
) == PREFIX_DENY
)
553 if (FILTER_LIST_IN_NAME (filter
)) {
554 FILTER_EXIST_WARN(FILTER_LIST
, as
, filter
);
556 if (as_list_apply (FILTER_LIST_IN (filter
), attr
->aspath
)== AS_FILTER_DENY
)
560 return FILTER_PERMIT
;
561 #undef FILTER_EXIST_WARN
564 static enum filter_type
565 bgp_output_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
566 afi_t afi
, safi_t safi
)
568 struct bgp_filter
*filter
;
570 filter
= &peer
->filter
[afi
][safi
];
572 #define FILTER_EXIST_WARN(F,f,filter) \
573 if (BGP_DEBUG (update, UPDATE_OUT) \
574 && !(F ## _OUT (filter))) \
575 plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \
576 peer->host, #f, F ## _OUT_NAME(filter));
578 if (DISTRIBUTE_OUT_NAME (filter
)) {
579 FILTER_EXIST_WARN(DISTRIBUTE
, distribute
, filter
);
581 if (access_list_apply (DISTRIBUTE_OUT (filter
), p
) == FILTER_DENY
)
585 if (PREFIX_LIST_OUT_NAME (filter
)) {
586 FILTER_EXIST_WARN(PREFIX_LIST
, prefix
, filter
);
588 if (prefix_list_apply (PREFIX_LIST_OUT (filter
), p
) == PREFIX_DENY
)
592 if (FILTER_LIST_OUT_NAME (filter
)) {
593 FILTER_EXIST_WARN(FILTER_LIST
, as
, filter
);
595 if (as_list_apply (FILTER_LIST_OUT (filter
), attr
->aspath
) == AS_FILTER_DENY
)
599 return FILTER_PERMIT
;
600 #undef FILTER_EXIST_WARN
603 /* If community attribute includes no_export then return 1. */
605 bgp_community_filter (struct peer
*peer
, struct attr
*attr
)
609 /* NO_ADVERTISE check. */
610 if (community_include (attr
->community
, COMMUNITY_NO_ADVERTISE
))
613 /* NO_EXPORT check. */
614 if (peer_sort (peer
) == BGP_PEER_EBGP
&&
615 community_include (attr
->community
, COMMUNITY_NO_EXPORT
))
618 /* NO_EXPORT_SUBCONFED check. */
619 if (peer_sort (peer
) == BGP_PEER_EBGP
620 || peer_sort (peer
) == BGP_PEER_CONFED
)
621 if (community_include (attr
->community
, COMMUNITY_NO_EXPORT_SUBCONFED
))
627 /* Route reflection loop check. */
629 bgp_cluster_filter (struct peer
*peer
, struct attr
*attr
)
631 struct in_addr cluster_id
;
633 if (attr
->extra
&& attr
->extra
->cluster
)
635 if (peer
->bgp
->config
& BGP_CONFIG_CLUSTER_ID
)
636 cluster_id
= peer
->bgp
->cluster_id
;
638 cluster_id
= peer
->bgp
->router_id
;
640 if (cluster_loop_check (attr
->extra
->cluster
, cluster_id
))
647 bgp_input_modifier (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
648 afi_t afi
, safi_t safi
)
650 struct bgp_filter
*filter
;
651 struct bgp_info info
;
652 route_map_result_t ret
;
654 filter
= &peer
->filter
[afi
][safi
];
656 /* Apply default weight value. */
658 (bgp_attr_extra_get (attr
))->weight
= peer
->weight
;
660 /* Route map apply. */
661 if (ROUTE_MAP_IN_NAME (filter
))
663 /* Duplicate current value to new strucutre for modification. */
667 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IN
);
669 /* Apply BGP route map to the attribute. */
670 ret
= route_map_apply (ROUTE_MAP_IN (filter
), p
, RMAP_BGP
, &info
);
674 if (ret
== RMAP_DENYMATCH
)
676 /* Free newly generated AS path and community by route-map. */
677 bgp_attr_flush (attr
);
685 bgp_export_modifier (struct peer
*rsclient
, struct peer
*peer
,
686 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
688 struct bgp_filter
*filter
;
689 struct bgp_info info
;
690 route_map_result_t ret
;
692 filter
= &peer
->filter
[afi
][safi
];
694 /* Route map apply. */
695 if (ROUTE_MAP_EXPORT_NAME (filter
))
697 /* Duplicate current value to new strucutre for modification. */
698 info
.peer
= rsclient
;
701 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_EXPORT
);
703 /* Apply BGP route map to the attribute. */
704 ret
= route_map_apply (ROUTE_MAP_EXPORT (filter
), p
, RMAP_BGP
, &info
);
706 rsclient
->rmap_type
= 0;
708 if (ret
== RMAP_DENYMATCH
)
710 /* Free newly generated AS path and community by route-map. */
711 bgp_attr_flush (attr
);
719 bgp_import_modifier (struct peer
*rsclient
, struct peer
*peer
,
720 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
722 struct bgp_filter
*filter
;
723 struct bgp_info info
;
724 route_map_result_t ret
;
726 filter
= &rsclient
->filter
[afi
][safi
];
728 /* Apply default weight value. */
730 (bgp_attr_extra_get (attr
))->weight
= peer
->weight
;
732 /* Route map apply. */
733 if (ROUTE_MAP_IMPORT_NAME (filter
))
735 /* Duplicate current value to new strucutre for modification. */
739 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
);
741 /* Apply BGP route map to the attribute. */
742 ret
= route_map_apply (ROUTE_MAP_IMPORT (filter
), p
, RMAP_BGP
, &info
);
746 if (ret
== RMAP_DENYMATCH
)
748 /* Free newly generated AS path and community by route-map. */
749 bgp_attr_flush (attr
);
757 bgp_announce_check (struct bgp_info
*ri
, struct peer
*peer
, struct prefix
*p
,
758 struct attr
*attr
, afi_t afi
, safi_t safi
)
761 char buf
[SU_ADDRSTRLEN
];
762 struct bgp_filter
*filter
;
769 filter
= &peer
->filter
[afi
][safi
];
772 if (DISABLE_BGP_ANNOUNCE
)
775 /* Do not send announces to RS-clients from the 'normal' bgp_table. */
776 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
779 /* Do not send back route to sender. */
783 /* If peer's id and route's nexthop are same. draft-ietf-idr-bgp4-23 5.1.3 */
784 if (p
->family
== AF_INET
785 && IPV4_ADDR_SAME(&peer
->remote_id
, &ri
->attr
->nexthop
))
788 if (p
->family
== AF_INET6
789 && IPV6_ADDR_SAME(&peer
->remote_id
, &ri
->attr
->nexthop
))
793 /* Aggregate-address suppress check. */
794 if (ri
->extra
&& ri
->extra
->suppress
)
795 if (! UNSUPPRESS_MAP_NAME (filter
))
798 /* Default route check. */
799 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
))
801 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
)
804 else if (p
->family
== AF_INET6
&& p
->prefixlen
== 0)
806 #endif /* HAVE_IPV6 */
809 /* Transparency check. */
810 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
)
811 && CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
816 /* If community is not disabled check the no-export and local. */
817 if (! transparent
&& bgp_community_filter (peer
, ri
->attr
))
820 /* If the attribute has originator-id and it is same as remote
822 if (ri
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
))
824 if (IPV4_ADDR_SAME (&peer
->remote_id
, &ri
->attr
->extra
->originator_id
))
826 if (BGP_DEBUG (filter
, FILTER
))
827 zlog (peer
->log
, LOG_DEBUG
,
828 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
830 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
836 /* ORF prefix-list filter check */
837 if (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_RM_ADV
)
838 && (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_RCV
)
839 || CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)))
840 if (peer
->orf_plist
[afi
][safi
])
842 if (prefix_list_apply (peer
->orf_plist
[afi
][safi
], p
) == PREFIX_DENY
)
846 /* Output filter check. */
847 if (bgp_output_filter (peer
, p
, ri
->attr
, afi
, safi
) == FILTER_DENY
)
849 if (BGP_DEBUG (filter
, FILTER
))
850 zlog (peer
->log
, LOG_DEBUG
,
851 "%s [Update:SEND] %s/%d is filtered",
853 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
858 #ifdef BGP_SEND_ASPATH_CHECK
859 /* AS path loop check. */
860 if (aspath_loop_check (ri
->attr
->aspath
, peer
->as
))
862 if (BGP_DEBUG (filter
, FILTER
))
863 zlog (peer
->log
, LOG_DEBUG
,
864 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
865 peer
->host
, peer
->as
);
868 #endif /* BGP_SEND_ASPATH_CHECK */
870 /* If we're a CONFED we need to loop check the CONFED ID too */
871 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
873 if (aspath_loop_check(ri
->attr
->aspath
, bgp
->confed_id
))
875 if (BGP_DEBUG (filter
, FILTER
))
876 zlog (peer
->log
, LOG_DEBUG
,
877 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
884 /* Route-Reflect check. */
885 if (peer_sort (from
) == BGP_PEER_IBGP
&& peer_sort (peer
) == BGP_PEER_IBGP
)
890 /* IBGP reflection check. */
893 /* A route from a Client peer. */
894 if (CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
896 /* Reflect to all the Non-Client peers and also to the
897 Client peers other than the originator. Originator check
898 is already done. So there is noting to do. */
899 /* no bgp client-to-client reflection check. */
900 if (bgp_flag_check (bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
901 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
906 /* A route from a Non-client peer. Reflect to all other
908 if (! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
913 /* For modify attribute, copy it to temporary structure. */
914 bgp_attr_dup (attr
, ri
->attr
);
916 /* If local-preference is not set. */
917 if ((peer_sort (peer
) == BGP_PEER_IBGP
918 || peer_sort (peer
) == BGP_PEER_CONFED
)
919 && (! (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))))
921 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
);
922 attr
->local_pref
= bgp
->default_local_pref
;
925 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
926 if (peer_sort (peer
) == BGP_PEER_EBGP
927 && attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
929 if (ri
->peer
!= bgp
->peer_self
&& ! transparent
930 && ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
931 attr
->flag
&= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
));
935 if (transparent
|| reflect
936 || (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_UNCHANGED
)
937 && ((p
->family
== AF_INET
&& attr
->nexthop
.s_addr
)
939 || (p
->family
== AF_INET6
&&
940 ! IN6_IS_ADDR_UNSPECIFIED(&attr
->extra
->mp_nexthop_global
))
941 #endif /* HAVE_IPV6 */
944 /* NEXT-HOP Unchanged. */
946 else if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
947 || (p
->family
== AF_INET
&& attr
->nexthop
.s_addr
== 0)
949 || (p
->family
== AF_INET6
&&
950 IN6_IS_ADDR_UNSPECIFIED(&attr
->extra
->mp_nexthop_global
))
951 #endif /* HAVE_IPV6 */
952 || (peer_sort (peer
) == BGP_PEER_EBGP
953 && bgp_multiaccess_check_v4 (attr
->nexthop
, peer
->host
) == 0))
955 /* Set IPv4 nexthop. */
956 if (p
->family
== AF_INET
)
958 if (safi
== SAFI_MPLS_VPN
)
959 memcpy (&attr
->extra
->mp_nexthop_global_in
, &peer
->nexthop
.v4
,
962 memcpy (&attr
->nexthop
, &peer
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
965 /* Set IPv6 nexthop. */
966 if (p
->family
== AF_INET6
)
968 /* IPv6 global nexthop must be included. */
969 memcpy (&attr
->extra
->mp_nexthop_global
, &peer
->nexthop
.v6_global
,
971 attr
->extra
->mp_nexthop_len
= 16;
973 #endif /* HAVE_IPV6 */
977 if (p
->family
== AF_INET6
)
979 /* Left nexthop_local unchanged if so configured. */
980 if ( CHECK_FLAG (peer
->af_flags
[afi
][safi
],
981 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) )
983 if ( IN6_IS_ADDR_LINKLOCAL (&attr
->extra
->mp_nexthop_local
) )
984 attr
->extra
->mp_nexthop_len
=32;
986 attr
->extra
->mp_nexthop_len
=16;
989 /* Default nexthop_local treatment for non-RS-Clients */
992 /* Link-local address should not be transit to different peer. */
993 attr
->extra
->mp_nexthop_len
= 16;
995 /* Set link-local address for shared network peer. */
996 if (peer
->shared_network
997 && ! IN6_IS_ADDR_UNSPECIFIED (&peer
->nexthop
.v6_local
))
999 memcpy (&attr
->extra
->mp_nexthop_local
, &peer
->nexthop
.v6_local
,
1001 attr
->extra
->mp_nexthop_len
= 32;
1004 /* If bgpd act as BGP-4+ route-reflector, do not send link-local
1007 attr
->extra
->mp_nexthop_len
= 16;
1009 /* If BGP-4+ link-local nexthop is not link-local nexthop. */
1010 if (! IN6_IS_ADDR_LINKLOCAL (&peer
->nexthop
.v6_local
))
1011 attr
->extra
->mp_nexthop_len
= 16;
1015 #endif /* HAVE_IPV6 */
1017 /* If this is EBGP peer and remove-private-AS is set. */
1018 if (peer_sort (peer
) == BGP_PEER_EBGP
1019 && peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)
1020 && aspath_private_as_check (attr
->aspath
))
1021 attr
->aspath
= aspath_empty_get ();
1023 /* Route map & unsuppress-map apply. */
1024 if (ROUTE_MAP_OUT_NAME (filter
)
1025 || (ri
->extra
&& ri
->extra
->suppress
) )
1027 struct bgp_info info
;
1028 struct attr dummy_attr
= { 0 };
1033 /* The route reflector is not allowed to modify the attributes
1034 of the reflected IBGP routes. */
1035 if (peer_sort (from
) == BGP_PEER_IBGP
1036 && peer_sort (peer
) == BGP_PEER_IBGP
)
1038 bgp_attr_dup (&dummy_attr
, attr
);
1039 info
.attr
= &dummy_attr
;
1042 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1044 if (ri
->extra
&& ri
->extra
->suppress
)
1045 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
1047 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
1049 peer
->rmap_type
= 0;
1051 if (dummy_attr
.extra
)
1052 bgp_attr_extra_free (&dummy_attr
);
1054 if (ret
== RMAP_DENYMATCH
)
1056 bgp_attr_flush (attr
);
1064 bgp_announce_check_rsclient (struct bgp_info
*ri
, struct peer
*rsclient
,
1065 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
1068 char buf
[SU_ADDRSTRLEN
];
1069 struct bgp_filter
*filter
;
1070 struct bgp_info info
;
1075 filter
= &rsclient
->filter
[afi
][safi
];
1076 bgp
= rsclient
->bgp
;
1078 if (DISABLE_BGP_ANNOUNCE
)
1081 /* Do not send back route to sender. */
1082 if (from
== rsclient
)
1085 /* Aggregate-address suppress check. */
1086 if (ri
->extra
&& ri
->extra
->suppress
)
1087 if (! UNSUPPRESS_MAP_NAME (filter
))
1090 /* Default route check. */
1091 if (CHECK_FLAG (rsclient
->af_sflags
[afi
][safi
],
1092 PEER_STATUS_DEFAULT_ORIGINATE
))
1094 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
)
1097 else if (p
->family
== AF_INET6
&& p
->prefixlen
== 0)
1099 #endif /* HAVE_IPV6 */
1102 /* If the attribute has originator-id and it is same as remote
1104 if (ri
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
))
1106 if (IPV4_ADDR_SAME (&rsclient
->remote_id
,
1107 &ri
->attr
->extra
->originator_id
))
1109 if (BGP_DEBUG (filter
, FILTER
))
1110 zlog (rsclient
->log
, LOG_DEBUG
,
1111 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
1113 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1119 /* ORF prefix-list filter check */
1120 if (CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_RM_ADV
)
1121 && (CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_RCV
)
1122 || CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)))
1123 if (rsclient
->orf_plist
[afi
][safi
])
1125 if (prefix_list_apply (rsclient
->orf_plist
[afi
][safi
], p
) == PREFIX_DENY
)
1129 /* Output filter check. */
1130 if (bgp_output_filter (rsclient
, p
, ri
->attr
, afi
, safi
) == FILTER_DENY
)
1132 if (BGP_DEBUG (filter
, FILTER
))
1133 zlog (rsclient
->log
, LOG_DEBUG
,
1134 "%s [Update:SEND] %s/%d is filtered",
1136 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1141 #ifdef BGP_SEND_ASPATH_CHECK
1142 /* AS path loop check. */
1143 if (aspath_loop_check (ri
->attr
->aspath
, rsclient
->as
))
1145 if (BGP_DEBUG (filter
, FILTER
))
1146 zlog (rsclient
->log
, LOG_DEBUG
,
1147 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
1148 rsclient
->host
, rsclient
->as
);
1151 #endif /* BGP_SEND_ASPATH_CHECK */
1153 /* For modify attribute, copy it to temporary structure. */
1154 bgp_attr_dup (attr
, ri
->attr
);
1157 if ((p
->family
== AF_INET
&& attr
->nexthop
.s_addr
== 0)
1159 || (p
->family
== AF_INET6
&&
1160 IN6_IS_ADDR_UNSPECIFIED(&attr
->extra
->mp_nexthop_global
))
1161 #endif /* HAVE_IPV6 */
1164 /* Set IPv4 nexthop. */
1165 if (p
->family
== AF_INET
)
1167 if (safi
== SAFI_MPLS_VPN
)
1168 memcpy (&attr
->extra
->mp_nexthop_global_in
, &rsclient
->nexthop
.v4
,
1171 memcpy (&attr
->nexthop
, &rsclient
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
1174 /* Set IPv6 nexthop. */
1175 if (p
->family
== AF_INET6
)
1177 /* IPv6 global nexthop must be included. */
1178 memcpy (&attr
->extra
->mp_nexthop_global
, &rsclient
->nexthop
.v6_global
,
1180 attr
->extra
->mp_nexthop_len
= 16;
1182 #endif /* HAVE_IPV6 */
1186 if (p
->family
== AF_INET6
)
1188 struct attr_extra
*attre
= attr
->extra
;
1190 assert (attr
->extra
);
1192 /* Left nexthop_local unchanged if so configured. */
1193 if ( CHECK_FLAG (rsclient
->af_flags
[afi
][safi
],
1194 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) )
1196 if ( IN6_IS_ADDR_LINKLOCAL (&attre
->mp_nexthop_local
) )
1197 attre
->mp_nexthop_len
=32;
1199 attre
->mp_nexthop_len
=16;
1202 /* Default nexthop_local treatment for RS-Clients */
1205 /* Announcer and RS-Client are both in the same network */
1206 if (rsclient
->shared_network
&& from
->shared_network
&&
1207 (rsclient
->ifindex
== from
->ifindex
))
1209 if ( IN6_IS_ADDR_LINKLOCAL (&attre
->mp_nexthop_local
) )
1210 attre
->mp_nexthop_len
=32;
1212 attre
->mp_nexthop_len
=16;
1215 /* Set link-local address for shared network peer. */
1216 else if (rsclient
->shared_network
1217 && IN6_IS_ADDR_LINKLOCAL (&rsclient
->nexthop
.v6_local
))
1219 memcpy (&attre
->mp_nexthop_local
, &rsclient
->nexthop
.v6_local
,
1221 attre
->mp_nexthop_len
= 32;
1225 attre
->mp_nexthop_len
= 16;
1229 #endif /* HAVE_IPV6 */
1232 /* If this is EBGP peer and remove-private-AS is set. */
1233 if (peer_sort (rsclient
) == BGP_PEER_EBGP
1234 && peer_af_flag_check (rsclient
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)
1235 && aspath_private_as_check (attr
->aspath
))
1236 attr
->aspath
= aspath_empty_get ();
1238 /* Route map & unsuppress-map apply. */
1239 if (ROUTE_MAP_OUT_NAME (filter
) || (ri
->extra
&& ri
->extra
->suppress
) )
1241 info
.peer
= rsclient
;
1244 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1246 if (ri
->extra
&& ri
->extra
->suppress
)
1247 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
1249 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
1251 rsclient
->rmap_type
= 0;
1253 if (ret
== RMAP_DENYMATCH
)
1255 bgp_attr_flush (attr
);
1263 struct bgp_info_pair
1265 struct bgp_info
*old
;
1266 struct bgp_info
*new;
1270 bgp_best_selection (struct bgp
*bgp
, struct bgp_node
*rn
, struct bgp_info_pair
*result
)
1272 struct bgp_info
*new_select
;
1273 struct bgp_info
*old_select
;
1274 struct bgp_info
*ri
;
1275 struct bgp_info
*ri1
;
1276 struct bgp_info
*ri2
;
1277 struct bgp_info
*nextri
= NULL
;
1279 /* bgp deterministic-med */
1281 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
))
1282 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1284 if (CHECK_FLAG (ri1
->flags
, BGP_INFO_DMED_CHECK
))
1286 if (BGP_INFO_HOLDDOWN (ri1
))
1291 for (ri2
= ri1
->next
; ri2
; ri2
= ri2
->next
)
1293 if (CHECK_FLAG (ri2
->flags
, BGP_INFO_DMED_CHECK
))
1295 if (BGP_INFO_HOLDDOWN (ri2
))
1298 if (aspath_cmp_left (ri1
->attr
->aspath
, ri2
->attr
->aspath
)
1299 || aspath_cmp_left_confed (ri1
->attr
->aspath
,
1302 if (bgp_info_cmp (bgp
, ri2
, new_select
))
1304 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1308 bgp_info_set_flag (rn
, ri2
, BGP_INFO_DMED_CHECK
);
1311 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_CHECK
);
1312 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1315 /* Check old selected route and new selected route. */
1318 for (ri
= rn
->info
; (ri
!= NULL
) && (nextri
= ri
->next
, 1); ri
= nextri
)
1320 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1323 if (BGP_INFO_HOLDDOWN (ri
))
1325 /* reap REMOVED routes, if needs be
1326 * selected route must stay for a while longer though
1328 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
1329 && (ri
!= old_select
))
1330 bgp_info_reap (rn
, ri
);
1335 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
)
1336 && (! CHECK_FLAG (ri
->flags
, BGP_INFO_DMED_SELECTED
)))
1338 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1341 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1342 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_SELECTED
);
1344 if (bgp_info_cmp (bgp
, ri
, new_select
))
1348 result
->old
= old_select
;
1349 result
->new = new_select
;
1355 bgp_process_announce_selected (struct peer
*peer
, struct bgp_info
*selected
,
1356 struct bgp_node
*rn
, afi_t afi
, safi_t safi
)
1359 struct attr attr
= { 0 };
1363 /* Announce route to Established peer. */
1364 if (peer
->status
!= Established
)
1367 /* Address family configuration check. */
1368 if (! peer
->afc_nego
[afi
][safi
])
1371 /* First update is deferred until ORF or ROUTE-REFRESH is received */
1372 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
],
1373 PEER_STATUS_ORF_WAIT_REFRESH
))
1376 switch (rn
->table
->type
)
1378 case BGP_TABLE_MAIN
:
1379 /* Announcement to peer->conf. If the route is filtered,
1381 if (selected
&& bgp_announce_check (selected
, peer
, p
, &attr
, afi
, safi
))
1382 bgp_adj_out_set (rn
, peer
, p
, &attr
, afi
, safi
, selected
);
1384 bgp_adj_out_unset (rn
, peer
, p
, afi
, safi
);
1386 case BGP_TABLE_RSCLIENT
:
1387 /* Announcement to peer->conf. If the route is filtered,
1390 bgp_announce_check_rsclient (selected
, peer
, p
, &attr
, afi
, safi
))
1391 bgp_adj_out_set (rn
, peer
, p
, &attr
, afi
, safi
, selected
);
1393 bgp_adj_out_unset (rn
, peer
, p
, afi
, safi
);
1397 bgp_attr_extra_free (&attr
);
1402 struct bgp_process_queue
1405 struct bgp_node
*rn
;
1410 static wq_item_status
1411 bgp_process_rsclient (struct work_queue
*wq
, void *data
)
1413 struct bgp_process_queue
*pq
= data
;
1414 struct bgp
*bgp
= pq
->bgp
;
1415 struct bgp_node
*rn
= pq
->rn
;
1416 afi_t afi
= pq
->afi
;
1417 safi_t safi
= pq
->safi
;
1418 struct bgp_info
*new_select
;
1419 struct bgp_info
*old_select
;
1420 struct bgp_info_pair old_and_new
;
1421 struct listnode
*node
, *nnode
;
1422 struct peer
*rsclient
= rn
->table
->owner
;
1424 /* Best path selection. */
1425 bgp_best_selection (bgp
, rn
, &old_and_new
);
1426 new_select
= old_and_new
.new;
1427 old_select
= old_and_new
.old
;
1429 if (CHECK_FLAG (rsclient
->sflags
, PEER_STATUS_GROUP
))
1431 if (rsclient
->group
)
1432 for (ALL_LIST_ELEMENTS (rsclient
->group
->peer
, node
, nnode
, rsclient
))
1434 /* Nothing to do. */
1435 if (old_select
&& old_select
== new_select
)
1436 if (!CHECK_FLAG (old_select
->flags
, BGP_INFO_ATTR_CHANGED
))
1440 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1443 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1444 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1447 bgp_process_announce_selected (rsclient
, new_select
, rn
,
1454 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1457 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1458 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1460 bgp_process_announce_selected (rsclient
, new_select
, rn
, afi
, safi
);
1463 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
1464 bgp_info_reap (rn
, old_select
);
1466 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1470 static wq_item_status
1471 bgp_process_main (struct work_queue
*wq
, void *data
)
1473 struct bgp_process_queue
*pq
= data
;
1474 struct bgp
*bgp
= pq
->bgp
;
1475 struct bgp_node
*rn
= pq
->rn
;
1476 afi_t afi
= pq
->afi
;
1477 safi_t safi
= pq
->safi
;
1478 struct prefix
*p
= &rn
->p
;
1479 struct bgp_info
*new_select
;
1480 struct bgp_info
*old_select
;
1481 struct bgp_info_pair old_and_new
;
1482 struct listnode
*node
, *nnode
;
1485 /* Best path selection. */
1486 bgp_best_selection (bgp
, rn
, &old_and_new
);
1487 old_select
= old_and_new
.old
;
1488 new_select
= old_and_new
.new;
1490 /* Nothing to do. */
1491 if (old_select
&& old_select
== new_select
)
1493 if (! CHECK_FLAG (old_select
->flags
, BGP_INFO_ATTR_CHANGED
))
1495 if (CHECK_FLAG (old_select
->flags
, BGP_INFO_IGP_CHANGED
))
1496 bgp_zebra_announce (p
, old_select
, bgp
);
1498 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1504 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1507 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1508 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1512 /* Check each BGP peer. */
1513 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
1515 bgp_process_announce_selected (peer
, new_select
, rn
, afi
, safi
);
1519 if (safi
== SAFI_UNICAST
&& ! bgp
->name
&&
1520 ! bgp_option_check (BGP_OPT_NO_FIB
))
1523 && new_select
->type
== ZEBRA_ROUTE_BGP
1524 && new_select
->sub_type
== BGP_ROUTE_NORMAL
)
1525 bgp_zebra_announce (p
, new_select
, bgp
);
1528 /* Withdraw the route from the kernel. */
1530 && old_select
->type
== ZEBRA_ROUTE_BGP
1531 && old_select
->sub_type
== BGP_ROUTE_NORMAL
)
1532 bgp_zebra_withdraw (p
, old_select
);
1536 /* Reap old select bgp_info, it it has been removed */
1537 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
1538 bgp_info_reap (rn
, old_select
);
1540 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1545 bgp_processq_del (struct work_queue
*wq
, void *data
)
1547 struct bgp_process_queue
*pq
= data
;
1548 struct bgp_table
*table
= pq
->rn
->table
;
1550 bgp_unlock (pq
->bgp
);
1551 bgp_unlock_node (pq
->rn
);
1552 bgp_table_unlock (table
);
1553 XFREE (MTYPE_BGP_PROCESS_QUEUE
, pq
);
1557 bgp_process_queue_init (void)
1559 bm
->process_main_queue
1560 = work_queue_new (bm
->master
, "process_main_queue");
1561 bm
->process_rsclient_queue
1562 = work_queue_new (bm
->master
, "process_rsclient_queue");
1564 if ( !(bm
->process_main_queue
&& bm
->process_rsclient_queue
) )
1566 zlog_err ("%s: Failed to allocate work queue", __func__
);
1570 bm
->process_main_queue
->spec
.workfunc
= &bgp_process_main
;
1571 bm
->process_main_queue
->spec
.del_item_data
= &bgp_processq_del
;
1572 bm
->process_main_queue
->spec
.max_retries
= 0;
1573 bm
->process_main_queue
->spec
.hold
= 50;
1575 memcpy (bm
->process_rsclient_queue
, bm
->process_main_queue
,
1576 sizeof (struct work_queue
*));
1577 bm
->process_rsclient_queue
->spec
.workfunc
= &bgp_process_rsclient
;
1581 bgp_process (struct bgp
*bgp
, struct bgp_node
*rn
, afi_t afi
, safi_t safi
)
1583 struct bgp_process_queue
*pqnode
;
1585 /* already scheduled for processing? */
1586 if (CHECK_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
))
1589 if ( (bm
->process_main_queue
== NULL
) ||
1590 (bm
->process_rsclient_queue
== NULL
) )
1591 bgp_process_queue_init ();
1593 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
1594 sizeof (struct bgp_process_queue
));
1598 /* all unlocked in bgp_processq_del */
1599 bgp_table_lock (rn
->table
);
1600 pqnode
->rn
= bgp_lock_node (rn
);
1604 pqnode
->safi
= safi
;
1606 switch (rn
->table
->type
)
1608 case BGP_TABLE_MAIN
:
1609 work_queue_add (bm
->process_main_queue
, pqnode
);
1611 case BGP_TABLE_RSCLIENT
:
1612 work_queue_add (bm
->process_rsclient_queue
, pqnode
);
1620 bgp_maximum_prefix_restart_timer (struct thread
*thread
)
1624 peer
= THREAD_ARG (thread
);
1625 peer
->t_pmax_restart
= NULL
;
1627 if (BGP_DEBUG (events
, EVENTS
))
1628 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
1637 bgp_maximum_prefix_overflow (struct peer
*peer
, afi_t afi
,
1638 safi_t safi
, int always
)
1640 if (!CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
))
1643 if (peer
->pcount
[afi
][safi
] > peer
->pmax
[afi
][safi
])
1645 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
)
1649 zlog (peer
->log
, LOG_INFO
,
1650 "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
1651 "limit %ld", afi_safi_print (afi
, safi
), peer
->host
,
1652 peer
->pcount
[afi
][safi
], peer
->pmax
[afi
][safi
]);
1653 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
1655 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_WARNING
))
1661 if (safi
== SAFI_MPLS_VPN
)
1662 safi
= BGP_SAFI_VPNV4
;
1664 ndata
[0] = (afi
>> 8);
1667 ndata
[3] = (peer
->pmax
[afi
][safi
] >> 24);
1668 ndata
[4] = (peer
->pmax
[afi
][safi
] >> 16);
1669 ndata
[5] = (peer
->pmax
[afi
][safi
] >> 8);
1670 ndata
[6] = (peer
->pmax
[afi
][safi
]);
1672 SET_FLAG (peer
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
);
1673 bgp_notify_send_with_data (peer
, BGP_NOTIFY_CEASE
,
1674 BGP_NOTIFY_CEASE_MAX_PREFIX
, ndata
, 7);
1677 /* restart timer start */
1678 if (peer
->pmax_restart
[afi
][safi
])
1680 peer
->v_pmax_restart
= peer
->pmax_restart
[afi
][safi
] * 60;
1682 if (BGP_DEBUG (events
, EVENTS
))
1683 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
1684 peer
->host
, peer
->v_pmax_restart
);
1686 BGP_TIMER_ON (peer
->t_pmax_restart
, bgp_maximum_prefix_restart_timer
,
1687 peer
->v_pmax_restart
);
1693 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
1695 if (peer
->pcount
[afi
][safi
] > (peer
->pmax
[afi
][safi
] * peer
->pmax_threshold
[afi
][safi
] / 100))
1697 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
)
1701 zlog (peer
->log
, LOG_INFO
,
1702 "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
1703 afi_safi_print (afi
, safi
), peer
->host
, peer
->pcount
[afi
][safi
],
1704 peer
->pmax
[afi
][safi
]);
1705 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
1708 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
1712 /* Unconditionally remove the route from the RIB, without taking
1713 * damping into consideration (eg, because the session went down)
1716 bgp_rib_remove (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
1717 afi_t afi
, safi_t safi
)
1719 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
1721 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
1722 bgp_info_delete (rn
, ri
); /* keep historical info */
1724 bgp_process (peer
->bgp
, rn
, afi
, safi
);
1728 bgp_rib_withdraw (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
1729 afi_t afi
, safi_t safi
)
1731 int status
= BGP_DAMP_NONE
;
1733 /* apply dampening, if result is suppressed, we'll be retaining
1734 * the bgp_info in the RIB for historical reference.
1736 if (CHECK_FLAG (peer
->bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
1737 && peer_sort (peer
) == BGP_PEER_EBGP
)
1738 if ( (status
= bgp_damp_withdraw (ri
, rn
, afi
, safi
, 0))
1739 == BGP_DAMP_SUPPRESSED
)
1741 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
1745 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
1749 bgp_update_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
,
1750 struct attr
*attr
, struct peer
*peer
, struct prefix
*p
, int type
,
1751 int sub_type
, struct prefix_rd
*prd
, u_char
*tag
)
1753 struct bgp_node
*rn
;
1755 struct attr new_attr
= { 0 };
1756 struct attr
*attr_new
;
1757 struct attr
*attr_new2
;
1758 struct bgp_info
*ri
;
1759 struct bgp_info
*new;
1761 char buf
[SU_ADDRSTRLEN
];
1763 /* Do not insert announces from a rsclient into its own 'bgp_table'. */
1764 if (peer
== rsclient
)
1768 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
1770 /* Check previously received route. */
1771 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1772 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
1775 /* AS path loop check. */
1776 if (aspath_loop_check (attr
->aspath
, rsclient
->as
) > peer
->allowas_in
[afi
][safi
])
1778 reason
= "as-path contains our own AS;";
1782 /* Route reflector originator ID check. */
1783 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
1784 && IPV4_ADDR_SAME (&rsclient
->remote_id
, &attr
->extra
->originator_id
))
1786 reason
= "originator is us;";
1790 bgp_attr_dup (&new_attr
, attr
);
1792 /* Apply export policy. */
1793 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
) &&
1794 bgp_export_modifier (rsclient
, peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
1796 reason
= "export-policy;";
1800 attr_new2
= bgp_attr_intern (&new_attr
);
1802 /* Apply import policy. */
1803 if (bgp_import_modifier (rsclient
, peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
1805 bgp_attr_unintern (&attr_new2
);
1807 reason
= "import-policy;";
1811 attr_new
= bgp_attr_intern (&new_attr
);
1812 bgp_attr_unintern (&attr_new2
);
1814 /* IPv4 unicast next hop check. */
1815 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
1817 /* Next hop must not be 0.0.0.0 nor Class E address. */
1818 if (new_attr
.nexthop
.s_addr
== 0
1819 || ntohl (new_attr
.nexthop
.s_addr
) >= 0xe0000000)
1821 bgp_attr_unintern (&attr_new
);
1823 reason
= "martian next-hop;";
1828 /* new_attr isn't passed to any functions after here */
1829 bgp_attr_extra_free (&new_attr
);
1831 /* If the update is implicit withdraw. */
1834 ri
->uptime
= bgp_clock ();
1836 /* Same attribute comes in. */
1837 if (!CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
)
1838 && attrhash_cmp (ri
->attr
, attr_new
))
1841 bgp_info_unset_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
1843 if (BGP_DEBUG (update
, UPDATE_IN
))
1844 zlog (peer
->log
, LOG_DEBUG
,
1845 "%s rcvd %s/%d for RS-client %s...duplicate ignored",
1847 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1848 p
->prefixlen
, rsclient
->host
);
1850 bgp_unlock_node (rn
);
1851 bgp_attr_unintern (&attr_new
);
1856 /* Withdraw/Announce before we fully processed the withdraw */
1857 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
1858 bgp_info_restore (rn
, ri
);
1860 /* Received Logging. */
1861 if (BGP_DEBUG (update
, UPDATE_IN
))
1862 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d for RS-client %s",
1864 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1865 p
->prefixlen
, rsclient
->host
);
1867 /* The attribute is changed. */
1868 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
1870 /* Update to new attribute. */
1871 bgp_attr_unintern (&ri
->attr
);
1872 ri
->attr
= attr_new
;
1874 /* Update MPLS tag. */
1875 if (safi
== SAFI_MPLS_VPN
)
1876 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
1878 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
1880 /* Process change. */
1881 bgp_process (bgp
, rn
, afi
, safi
);
1882 bgp_unlock_node (rn
);
1887 /* Received Logging. */
1888 if (BGP_DEBUG (update
, UPDATE_IN
))
1890 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d for RS-client %s",
1892 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1893 p
->prefixlen
, rsclient
->host
);
1896 /* Make new BGP info. */
1897 new = bgp_info_new ();
1899 new->sub_type
= sub_type
;
1901 new->attr
= attr_new
;
1902 new->uptime
= bgp_clock ();
1904 /* Update MPLS tag. */
1905 if (safi
== SAFI_MPLS_VPN
)
1906 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
1908 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
1910 /* Register new BGP information. */
1911 bgp_info_add (rn
, new);
1913 /* route_node_get lock */
1914 bgp_unlock_node (rn
);
1916 /* Process change. */
1917 bgp_process (bgp
, rn
, afi
, safi
);
1919 bgp_attr_extra_free (&new_attr
);
1925 /* This BGP update is filtered. Log the reason then update BGP entry. */
1926 if (BGP_DEBUG (update
, UPDATE_IN
))
1927 zlog (peer
->log
, LOG_DEBUG
,
1928 "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s",
1930 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1931 p
->prefixlen
, rsclient
->host
, reason
);
1934 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
1936 bgp_unlock_node (rn
);
1939 bgp_attr_extra_free (&new_attr
);
1945 bgp_withdraw_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
,
1946 struct peer
*peer
, struct prefix
*p
, int type
, int sub_type
,
1947 struct prefix_rd
*prd
, u_char
*tag
)
1949 struct bgp_node
*rn
;
1950 struct bgp_info
*ri
;
1951 char buf
[SU_ADDRSTRLEN
];
1953 if (rsclient
== peer
)
1956 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
1958 /* Lookup withdrawn route. */
1959 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1960 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
1963 /* Withdraw specified route from routing table. */
1964 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
1965 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
1966 else if (BGP_DEBUG (update
, UPDATE_IN
))
1967 zlog (peer
->log
, LOG_DEBUG
,
1968 "%s Can't find the route %s/%d", peer
->host
,
1969 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1972 /* Unlock bgp_node_get() lock. */
1973 bgp_unlock_node (rn
);
1977 bgp_update_main (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
1978 afi_t afi
, safi_t safi
, int type
, int sub_type
,
1979 struct prefix_rd
*prd
, u_char
*tag
, int soft_reconfig
)
1982 int aspath_loop_count
= 0;
1983 struct bgp_node
*rn
;
1985 struct attr new_attr
= { 0 };
1986 struct attr
*attr_new
;
1987 struct bgp_info
*ri
;
1988 struct bgp_info
*new;
1990 char buf
[SU_ADDRSTRLEN
];
1993 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
1995 /* When peer's soft reconfiguration enabled. Record input packet in
1997 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
1998 && peer
!= bgp
->peer_self
&& ! soft_reconfig
)
1999 bgp_adj_in_set (rn
, peer
, attr
);
2001 /* Check previously received route. */
2002 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2003 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
2006 /* AS path local-as loop check. */
2007 if (peer
->change_local_as
)
2009 if (! CHECK_FLAG (peer
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
2010 aspath_loop_count
= 1;
2012 if (aspath_loop_check (attr
->aspath
, peer
->change_local_as
) > aspath_loop_count
)
2014 reason
= "as-path contains our own AS;";
2019 /* AS path loop check. */
2020 if (aspath_loop_check (attr
->aspath
, bgp
->as
) > peer
->allowas_in
[afi
][safi
]
2021 || (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
2022 && aspath_loop_check(attr
->aspath
, bgp
->confed_id
)
2023 > peer
->allowas_in
[afi
][safi
]))
2025 reason
= "as-path contains our own AS;";
2029 /* Route reflector originator ID check. */
2030 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
2031 && IPV4_ADDR_SAME (&bgp
->router_id
, &attr
->extra
->originator_id
))
2033 reason
= "originator is us;";
2037 /* Route reflector cluster ID check. */
2038 if (bgp_cluster_filter (peer
, attr
))
2040 reason
= "reflected from the same cluster;";
2044 /* Apply incoming filter. */
2045 if (bgp_input_filter (peer
, p
, attr
, afi
, safi
) == FILTER_DENY
)
2051 /* Apply incoming route-map. */
2052 bgp_attr_dup (&new_attr
, attr
);
2054 if (bgp_input_modifier (peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
2056 reason
= "route-map;";
2060 /* IPv4 unicast next hop check. */
2061 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2063 /* If the peer is EBGP and nexthop is not on connected route,
2065 if (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
== 1
2066 && ! bgp_nexthop_check_ebgp (afi
, &new_attr
)
2067 && ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
2069 reason
= "non-connected next-hop;";
2073 /* Next hop must not be 0.0.0.0 nor Class E address. Next hop
2074 must not be my own address. */
2075 if (bgp_nexthop_self (afi
, &new_attr
)
2076 || new_attr
.nexthop
.s_addr
== 0
2077 || ntohl (new_attr
.nexthop
.s_addr
) >= 0xe0000000)
2079 reason
= "martian next-hop;";
2084 attr_new
= bgp_attr_intern (&new_attr
);
2086 /* If the update is implicit withdraw. */
2089 ri
->uptime
= bgp_clock ();
2091 /* Same attribute comes in. */
2092 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
2093 && attrhash_cmp (ri
->attr
, attr_new
))
2095 bgp_info_unset_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2097 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2098 && peer_sort (peer
) == BGP_PEER_EBGP
2099 && CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2101 if (BGP_DEBUG (update
, UPDATE_IN
))
2102 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2104 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2107 if (bgp_damp_update (ri
, rn
, afi
, safi
) != BGP_DAMP_SUPPRESSED
)
2109 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2110 bgp_process (bgp
, rn
, afi
, safi
);
2113 else /* Duplicate - odd */
2115 if (BGP_DEBUG (update
, UPDATE_IN
))
2116 zlog (peer
->log
, LOG_DEBUG
,
2117 "%s rcvd %s/%d...duplicate ignored",
2119 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2122 /* graceful restart STALE flag unset. */
2123 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2125 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2126 bgp_process (bgp
, rn
, afi
, safi
);
2130 bgp_unlock_node (rn
);
2131 bgp_attr_unintern (&attr_new
);
2132 bgp_attr_extra_free (&new_attr
);
2137 /* Withdraw/Announce before we fully processed the withdraw */
2138 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
2140 if (BGP_DEBUG (update
, UPDATE_IN
))
2141 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d, flapped quicker than processing",
2143 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2145 bgp_info_restore (rn
, ri
);
2148 /* Received Logging. */
2149 if (BGP_DEBUG (update
, UPDATE_IN
))
2150 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2152 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2155 /* graceful restart STALE flag unset. */
2156 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2157 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2159 /* The attribute is changed. */
2160 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2162 /* implicit withdraw, decrement aggregate and pcount here.
2163 * only if update is accepted, they'll increment below.
2165 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
2167 /* Update bgp route dampening information. */
2168 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2169 && peer_sort (peer
) == BGP_PEER_EBGP
)
2171 /* This is implicit withdraw so we should update dampening
2173 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2174 bgp_damp_withdraw (ri
, rn
, afi
, safi
, 1);
2177 /* Update to new attribute. */
2178 bgp_attr_unintern (&ri
->attr
);
2179 ri
->attr
= attr_new
;
2181 /* Update MPLS tag. */
2182 if (safi
== SAFI_MPLS_VPN
)
2183 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
2185 /* Update bgp route dampening information. */
2186 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2187 && peer_sort (peer
) == BGP_PEER_EBGP
)
2189 /* Now we do normal update dampening. */
2190 ret
= bgp_damp_update (ri
, rn
, afi
, safi
);
2191 if (ret
== BGP_DAMP_SUPPRESSED
)
2193 bgp_unlock_node (rn
);
2194 bgp_attr_extra_free (&new_attr
);
2199 /* Nexthop reachability check. */
2200 if ((afi
== AFI_IP
|| afi
== AFI_IP6
)
2201 && safi
== SAFI_UNICAST
2202 && (peer_sort (peer
) == BGP_PEER_IBGP
2203 || peer_sort (peer
) == BGP_PEER_CONFED
2204 || (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)
2205 || CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)))
2207 if (bgp_nexthop_lookup (afi
, peer
, ri
, NULL
, NULL
))
2208 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2210 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
2213 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2215 /* Process change. */
2216 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2218 bgp_process (bgp
, rn
, afi
, safi
);
2219 bgp_unlock_node (rn
);
2220 bgp_attr_extra_free (&new_attr
);
2225 /* Received Logging. */
2226 if (BGP_DEBUG (update
, UPDATE_IN
))
2228 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2230 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2234 /* Make new BGP info. */
2235 new = bgp_info_new ();
2237 new->sub_type
= sub_type
;
2239 new->attr
= attr_new
;
2240 new->uptime
= bgp_clock ();
2242 /* Update MPLS tag. */
2243 if (safi
== SAFI_MPLS_VPN
)
2244 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
2246 /* Nexthop reachability check. */
2247 if ((afi
== AFI_IP
|| afi
== AFI_IP6
)
2248 && safi
== SAFI_UNICAST
2249 && (peer_sort (peer
) == BGP_PEER_IBGP
2250 || peer_sort (peer
) == BGP_PEER_CONFED
2251 || (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)
2252 || CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)))
2254 if (bgp_nexthop_lookup (afi
, peer
, new, NULL
, NULL
))
2255 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2257 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
2260 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2262 /* Increment prefix */
2263 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
2265 /* Register new BGP information. */
2266 bgp_info_add (rn
, new);
2268 /* route_node_get lock */
2269 bgp_unlock_node (rn
);
2271 bgp_attr_extra_free (&new_attr
);
2273 /* If maximum prefix count is configured and current prefix
2275 if (bgp_maximum_prefix_overflow (peer
, afi
, safi
, 0))
2278 /* Process change. */
2279 bgp_process (bgp
, rn
, afi
, safi
);
2283 /* This BGP update is filtered. Log the reason then update BGP
2286 if (BGP_DEBUG (update
, UPDATE_IN
))
2287 zlog (peer
->log
, LOG_DEBUG
,
2288 "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
2290 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2291 p
->prefixlen
, reason
);
2294 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2296 bgp_unlock_node (rn
);
2298 bgp_attr_extra_free (&new_attr
);
2304 bgp_update (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
2305 afi_t afi
, safi_t safi
, int type
, int sub_type
,
2306 struct prefix_rd
*prd
, u_char
*tag
, int soft_reconfig
)
2308 struct peer
*rsclient
;
2309 struct listnode
*node
, *nnode
;
2313 ret
= bgp_update_main (peer
, p
, attr
, afi
, safi
, type
, sub_type
, prd
, tag
,
2318 /* Process the update for each RS-client. */
2319 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
2321 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2322 bgp_update_rsclient (rsclient
, afi
, safi
, attr
, peer
, p
, type
,
2323 sub_type
, prd
, tag
);
2330 bgp_withdraw (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
2331 afi_t afi
, safi_t safi
, int type
, int sub_type
,
2332 struct prefix_rd
*prd
, u_char
*tag
)
2335 char buf
[SU_ADDRSTRLEN
];
2336 struct bgp_node
*rn
;
2337 struct bgp_info
*ri
;
2338 struct peer
*rsclient
;
2339 struct listnode
*node
, *nnode
;
2343 /* Process the withdraw for each RS-client. */
2344 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
2346 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2347 bgp_withdraw_rsclient (rsclient
, afi
, safi
, peer
, p
, type
, sub_type
, prd
, tag
);
2351 if (BGP_DEBUG (update
, UPDATE_IN
))
2352 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd UPDATE about %s/%d -- withdrawn",
2354 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2358 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2360 /* If peer is soft reconfiguration enabled. Record input packet for
2361 further calculation. */
2362 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2363 && peer
!= bgp
->peer_self
)
2364 bgp_adj_in_unset (rn
, peer
);
2366 /* Lookup withdrawn route. */
2367 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2368 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
2371 /* Withdraw specified route from routing table. */
2372 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2373 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
2374 else if (BGP_DEBUG (update
, UPDATE_IN
))
2375 zlog (peer
->log
, LOG_DEBUG
,
2376 "%s Can't find the route %s/%d", peer
->host
,
2377 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2380 /* Unlock bgp_node_get() lock. */
2381 bgp_unlock_node (rn
);
2387 bgp_default_originate (struct peer
*peer
, afi_t afi
, safi_t safi
, int withdraw
)
2390 struct attr attr
= { 0 };
2391 struct aspath
*aspath
= { 0 };
2393 struct bgp_info binfo
;
2395 int ret
= RMAP_DENYMATCH
;
2397 if (!(afi
== AFI_IP
|| afi
== AFI_IP6
))
2401 from
= bgp
->peer_self
;
2403 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
2404 aspath
= attr
.aspath
;
2405 attr
.local_pref
= bgp
->default_local_pref
;
2406 memcpy (&attr
.nexthop
, &peer
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
2409 str2prefix ("0.0.0.0/0", &p
);
2411 else if (afi
== AFI_IP6
)
2413 struct attr_extra
*ae
;
2416 ae
= bgp_attr_extra_get (&attr
);
2419 str2prefix ("::/0", &p
);
2421 /* IPv6 global nexthop must be included. */
2422 memcpy (&ae
->mp_nexthop_global
, &peer
->nexthop
.v6_global
,
2424 ae
->mp_nexthop_len
= 16;
2426 /* If the peer is on shared nextwork and we have link-local
2428 if (peer
->shared_network
2429 && !IN6_IS_ADDR_UNSPECIFIED (&peer
->nexthop
.v6_local
))
2431 memcpy (&ae
->mp_nexthop_local
, &peer
->nexthop
.v6_local
,
2433 ae
->mp_nexthop_len
= 32;
2436 #endif /* HAVE_IPV6 */
2438 if (peer
->default_rmap
[afi
][safi
].name
)
2440 binfo
.peer
= bgp
->peer_self
;
2443 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_DEFAULT
);
2445 ret
= route_map_apply (peer
->default_rmap
[afi
][safi
].map
, &p
,
2448 bgp
->peer_self
->rmap_type
= 0;
2450 if (ret
== RMAP_DENYMATCH
)
2452 bgp_attr_flush (&attr
);
2459 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
))
2460 bgp_default_withdraw_send (peer
, afi
, safi
);
2461 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
);
2465 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
);
2466 bgp_default_update_send (peer
, &attr
, afi
, safi
, from
);
2469 bgp_attr_extra_free (&attr
);
2470 aspath_unintern (&aspath
);
2474 bgp_announce_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2475 struct bgp_table
*table
, int rsclient
)
2477 struct bgp_node
*rn
;
2478 struct bgp_info
*ri
;
2479 struct attr attr
= { 0 };
2482 table
= (rsclient
) ? peer
->rib
[afi
][safi
] : peer
->bgp
->rib
[afi
][safi
];
2484 if (safi
!= SAFI_MPLS_VPN
2485 && CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_DEFAULT_ORIGINATE
))
2486 bgp_default_originate (peer
, afi
, safi
, 0);
2488 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next(rn
))
2489 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2490 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
) && ri
->peer
!= peer
)
2493 (bgp_announce_check_rsclient (ri
, peer
, &rn
->p
, &attr
, afi
, safi
))
2494 : (bgp_announce_check (ri
, peer
, &rn
->p
, &attr
, afi
, safi
)))
2495 bgp_adj_out_set (rn
, peer
, &rn
->p
, &attr
, afi
, safi
, ri
);
2497 bgp_adj_out_unset (rn
, peer
, &rn
->p
, afi
, safi
);
2499 bgp_attr_extra_free (&attr
);
2504 bgp_announce_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2506 struct bgp_node
*rn
;
2507 struct bgp_table
*table
;
2509 if (peer
->status
!= Established
)
2512 if (! peer
->afc_nego
[afi
][safi
])
2515 /* First update is deferred until ORF or ROUTE-REFRESH is received */
2516 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_ORF_WAIT_REFRESH
))
2519 if (safi
!= SAFI_MPLS_VPN
)
2520 bgp_announce_table (peer
, afi
, safi
, NULL
, 0);
2522 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2523 rn
= bgp_route_next(rn
))
2524 if ((table
= (rn
->info
)) != NULL
)
2525 bgp_announce_table (peer
, afi
, safi
, table
, 0);
2527 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2528 bgp_announce_table (peer
, afi
, safi
, NULL
, 1);
2532 bgp_announce_route_all (struct peer
*peer
)
2537 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2538 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2539 bgp_announce_route (peer
, afi
, safi
);
2543 bgp_soft_reconfig_table_rsclient (struct peer
*rsclient
, afi_t afi
,
2544 safi_t safi
, struct bgp_table
*table
)
2546 struct bgp_node
*rn
;
2547 struct bgp_adj_in
*ain
;
2550 table
= rsclient
->bgp
->rib
[afi
][safi
];
2552 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2553 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2555 bgp_update_rsclient (rsclient
, afi
, safi
, ain
->attr
, ain
->peer
,
2556 &rn
->p
, ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
2561 bgp_soft_reconfig_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
)
2563 struct bgp_table
*table
;
2564 struct bgp_node
*rn
;
2566 if (safi
!= SAFI_MPLS_VPN
)
2567 bgp_soft_reconfig_table_rsclient (rsclient
, afi
, safi
, NULL
);
2570 for (rn
= bgp_table_top (rsclient
->bgp
->rib
[afi
][safi
]); rn
;
2571 rn
= bgp_route_next (rn
))
2572 if ((table
= rn
->info
) != NULL
)
2573 bgp_soft_reconfig_table_rsclient (rsclient
, afi
, safi
, table
);
2577 bgp_soft_reconfig_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2578 struct bgp_table
*table
)
2581 struct bgp_node
*rn
;
2582 struct bgp_adj_in
*ain
;
2585 table
= peer
->bgp
->rib
[afi
][safi
];
2587 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2588 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2590 if (ain
->peer
== peer
)
2592 ret
= bgp_update (peer
, &rn
->p
, ain
->attr
, afi
, safi
,
2593 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
,
2597 bgp_unlock_node (rn
);
2606 bgp_soft_reconfig_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2608 struct bgp_node
*rn
;
2609 struct bgp_table
*table
;
2611 if (peer
->status
!= Established
)
2614 if (safi
!= SAFI_MPLS_VPN
)
2615 bgp_soft_reconfig_table (peer
, afi
, safi
, NULL
);
2617 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2618 rn
= bgp_route_next (rn
))
2619 if ((table
= rn
->info
) != NULL
)
2620 bgp_soft_reconfig_table (peer
, afi
, safi
, table
);
2624 struct bgp_clear_node_queue
2626 struct bgp_node
*rn
;
2627 enum bgp_clear_route_type purpose
;
2630 static wq_item_status
2631 bgp_clear_route_node (struct work_queue
*wq
, void *data
)
2633 struct bgp_clear_node_queue
*cnq
= data
;
2634 struct bgp_node
*rn
= cnq
->rn
;
2635 struct peer
*peer
= wq
->spec
.data
;
2636 struct bgp_info
*ri
;
2637 afi_t afi
= rn
->table
->afi
;
2638 safi_t safi
= rn
->table
->safi
;
2640 assert (rn
&& peer
);
2642 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2643 if (ri
->peer
== peer
|| cnq
->purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2645 /* graceful restart STALE flag set. */
2646 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_NSF_WAIT
)
2647 && peer
->nsf
[afi
][safi
]
2648 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
)
2649 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
2650 bgp_info_set_flag (rn
, ri
, BGP_INFO_STALE
);
2652 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2659 bgp_clear_node_queue_del (struct work_queue
*wq
, void *data
)
2661 struct bgp_clear_node_queue
*cnq
= data
;
2662 struct bgp_node
*rn
= cnq
->rn
;
2663 struct bgp_table
*table
= rn
->table
;
2665 bgp_unlock_node (rn
);
2666 bgp_table_unlock (table
);
2667 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE
, cnq
);
2671 bgp_clear_node_complete (struct work_queue
*wq
)
2673 struct peer
*peer
= wq
->spec
.data
;
2675 /* Tickle FSM to start moving again */
2676 BGP_EVENT_ADD (peer
, Clearing_Completed
);
2678 peer_unlock (peer
); /* bgp_clear_route */
2682 bgp_clear_node_queue_init (struct peer
*peer
)
2684 char wname
[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
2686 snprintf (wname
, sizeof(wname
), "clear %s", peer
->host
);
2687 #undef CLEAR_QUEUE_NAME_LEN
2689 if ( (peer
->clear_node_queue
= work_queue_new (bm
->master
, wname
)) == NULL
)
2691 zlog_err ("%s: Failed to allocate work queue", __func__
);
2694 peer
->clear_node_queue
->spec
.hold
= 10;
2695 peer
->clear_node_queue
->spec
.workfunc
= &bgp_clear_route_node
;
2696 peer
->clear_node_queue
->spec
.del_item_data
= &bgp_clear_node_queue_del
;
2697 peer
->clear_node_queue
->spec
.completion_func
= &bgp_clear_node_complete
;
2698 peer
->clear_node_queue
->spec
.max_retries
= 0;
2700 /* we only 'lock' this peer reference when the queue is actually active */
2701 peer
->clear_node_queue
->spec
.data
= peer
;
2705 bgp_clear_route_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2706 struct bgp_table
*table
, struct peer
*rsclient
,
2707 enum bgp_clear_route_type purpose
)
2709 struct bgp_node
*rn
;
2713 table
= (rsclient
) ? rsclient
->rib
[afi
][safi
] : peer
->bgp
->rib
[afi
][safi
];
2715 /* If still no table => afi/safi isn't configured at all or smth. */
2719 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2721 struct bgp_info
*ri
;
2722 struct bgp_adj_in
*ain
;
2723 struct bgp_adj_out
*aout
;
2725 if (rn
->info
== NULL
)
2728 /* XXX:TODO: This is suboptimal, every non-empty route_node is
2729 * queued for every clearing peer, regardless of whether it is
2730 * relevant to the peer at hand.
2732 * Overview: There are 3 different indices which need to be
2733 * scrubbed, potentially, when a peer is removed:
2735 * 1 peer's routes visible via the RIB (ie accepted routes)
2736 * 2 peer's routes visible by the (optional) peer's adj-in index
2737 * 3 other routes visible by the peer's adj-out index
2739 * 3 there is no hurry in scrubbing, once the struct peer is
2740 * removed from bgp->peer, we could just GC such deleted peer's
2741 * adj-outs at our leisure.
2743 * 1 and 2 must be 'scrubbed' in some way, at least made
2744 * invisible via RIB index before peer session is allowed to be
2745 * brought back up. So one needs to know when such a 'search' is
2750 * - there'd be a single global queue or a single RIB walker
2751 * - rather than tracking which route_nodes still need to be
2752 * examined on a peer basis, we'd track which peers still
2755 * Given that our per-peer prefix-counts now should be reliable,
2756 * this may actually be achievable. It doesn't seem to be a huge
2757 * problem at this time,
2759 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2760 if (ri
->peer
== peer
|| purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2762 struct bgp_clear_node_queue
*cnq
;
2764 /* both unlocked in bgp_clear_node_queue_del */
2765 bgp_table_lock (rn
->table
);
2767 cnq
= XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE
,
2768 sizeof (struct bgp_clear_node_queue
));
2770 cnq
->purpose
= purpose
;
2771 work_queue_add (peer
->clear_node_queue
, cnq
);
2775 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2776 if (ain
->peer
== peer
|| purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2778 bgp_adj_in_remove (rn
, ain
);
2779 bgp_unlock_node (rn
);
2782 for (aout
= rn
->adj_out
; aout
; aout
= aout
->next
)
2783 if (aout
->peer
== peer
|| purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2785 bgp_adj_out_remove (rn
, aout
, peer
, afi
, safi
);
2786 bgp_unlock_node (rn
);
2794 bgp_clear_route (struct peer
*peer
, afi_t afi
, safi_t safi
,
2795 enum bgp_clear_route_type purpose
)
2797 struct bgp_node
*rn
;
2798 struct bgp_table
*table
;
2799 struct peer
*rsclient
;
2800 struct listnode
*node
, *nnode
;
2802 if (peer
->clear_node_queue
== NULL
)
2803 bgp_clear_node_queue_init (peer
);
2805 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
2806 * Idle until it receives a Clearing_Completed event. This protects
2807 * against peers which flap faster than we can we clear, which could
2810 * a) race with routes from the new session being installed before
2811 * clear_route_node visits the node (to delete the route of that
2813 * b) resource exhaustion, clear_route_node likely leads to an entry
2814 * on the process_main queue. Fast-flapping could cause that queue
2817 if (!peer
->clear_node_queue
->thread
)
2818 peer_lock (peer
); /* bgp_clear_node_complete */
2822 case BGP_CLEAR_ROUTE_NORMAL
:
2823 if (safi
!= SAFI_MPLS_VPN
)
2824 bgp_clear_route_table (peer
, afi
, safi
, NULL
, NULL
, purpose
);
2826 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2827 rn
= bgp_route_next (rn
))
2828 if ((table
= rn
->info
) != NULL
)
2829 bgp_clear_route_table (peer
, afi
, safi
, table
, NULL
, purpose
);
2831 for (ALL_LIST_ELEMENTS (peer
->bgp
->rsclient
, node
, nnode
, rsclient
))
2832 if (CHECK_FLAG(rsclient
->af_flags
[afi
][safi
],
2833 PEER_FLAG_RSERVER_CLIENT
))
2834 bgp_clear_route_table (peer
, afi
, safi
, NULL
, rsclient
, purpose
);
2837 case BGP_CLEAR_ROUTE_MY_RSCLIENT
:
2838 bgp_clear_route_table (peer
, afi
, safi
, NULL
, peer
, purpose
);
2846 /* If no routes were cleared, nothing was added to workqueue, the
2847 * completion function won't be run by workqueue code - call it here.
2848 * XXX: Actually, this assumption doesn't hold, see
2849 * bgp_clear_route_table(), we queue all non-empty nodes.
2851 * Additionally, there is a presumption in FSM that clearing is only
2852 * really needed if peer state is Established - peers in
2853 * pre-Established states shouldn't have any route-update state
2854 * associated with them (in or out).
2856 * We still can get here in pre-Established though, through
2857 * peer_delete -> bgp_fsm_change_status, so this is a useful sanity
2858 * check to ensure the assumption above holds.
2860 * At some future point, this check could be move to the top of the
2861 * function, and do a quick early-return when state is
2862 * pre-Established, avoiding above list and table scans. Once we're
2865 if (!peer
->clear_node_queue
->thread
)
2866 bgp_clear_node_complete (peer
->clear_node_queue
);
2870 bgp_clear_route_all (struct peer
*peer
)
2875 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2876 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2877 bgp_clear_route (peer
, afi
, safi
, BGP_CLEAR_ROUTE_NORMAL
);
2881 bgp_clear_adj_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2883 struct bgp_table
*table
;
2884 struct bgp_node
*rn
;
2885 struct bgp_adj_in
*ain
;
2887 table
= peer
->bgp
->rib
[afi
][safi
];
2889 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2890 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2891 if (ain
->peer
== peer
)
2893 bgp_adj_in_remove (rn
, ain
);
2894 bgp_unlock_node (rn
);
2900 bgp_clear_stale_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2902 struct bgp_node
*rn
;
2903 struct bgp_info
*ri
;
2904 struct bgp_table
*table
;
2906 table
= peer
->bgp
->rib
[afi
][safi
];
2908 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2910 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2911 if (ri
->peer
== peer
)
2913 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2914 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2920 /* Delete all kernel routes. */
2922 bgp_cleanup_routes (void)
2925 struct listnode
*node
, *nnode
;
2926 struct bgp_node
*rn
;
2927 struct bgp_table
*table
;
2928 struct bgp_info
*ri
;
2930 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
2932 table
= bgp
->rib
[AFI_IP
][SAFI_UNICAST
];
2934 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2935 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2936 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
2937 && ri
->type
== ZEBRA_ROUTE_BGP
2938 && ri
->sub_type
== BGP_ROUTE_NORMAL
)
2939 bgp_zebra_withdraw (&rn
->p
, ri
);
2941 table
= bgp
->rib
[AFI_IP6
][SAFI_UNICAST
];
2943 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2944 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2945 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
2946 && ri
->type
== ZEBRA_ROUTE_BGP
2947 && ri
->sub_type
== BGP_ROUTE_NORMAL
)
2948 bgp_zebra_withdraw (&rn
->p
, ri
);
2956 bgp_zclient_reset ();
2957 access_list_reset ();
2958 prefix_list_reset ();
2961 /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
2964 bgp_nlri_parse (struct peer
*peer
, struct attr
*attr
, struct bgp_nlri
*packet
)
2972 /* Check peer status. */
2973 if (peer
->status
!= Established
)
2977 lim
= pnt
+ packet
->length
;
2979 for (; pnt
< lim
; pnt
+= psize
)
2981 /* Clear prefix structure. */
2982 memset (&p
, 0, sizeof (struct prefix
));
2984 /* Fetch prefix length. */
2985 p
.prefixlen
= *pnt
++;
2986 p
.family
= afi2family (packet
->afi
);
2988 /* Already checked in nlri_sanity_check(). We do double check
2990 if ((packet
->afi
== AFI_IP
&& p
.prefixlen
> 32)
2991 || (packet
->afi
== AFI_IP6
&& p
.prefixlen
> 128))
2994 /* Packet size overflow check. */
2995 psize
= PSIZE (p
.prefixlen
);
2997 /* When packet overflow occur return immediately. */
2998 if (pnt
+ psize
> lim
)
3001 /* Fetch prefix from NLRI packet. */
3002 memcpy (&p
.u
.prefix
, pnt
, psize
);
3004 /* Check address. */
3005 if (packet
->afi
== AFI_IP
&& packet
->safi
== SAFI_UNICAST
)
3007 if (IN_CLASSD (ntohl (p
.u
.prefix4
.s_addr
)))
3010 * From draft-ietf-idr-bgp4-22, Section 6.3:
3011 * If a BGP router receives an UPDATE message with a
3012 * semantically incorrect NLRI field, in which a prefix is
3013 * semantically incorrect (eg. an unexpected multicast IP
3014 * address), it should ignore the prefix.
3016 zlog (peer
->log
, LOG_ERR
,
3017 "IPv4 unicast NLRI is multicast address %s",
3018 inet_ntoa (p
.u
.prefix4
));
3025 /* Check address. */
3026 if (packet
->afi
== AFI_IP6
&& packet
->safi
== SAFI_UNICAST
)
3028 if (IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3032 zlog (peer
->log
, LOG_WARNING
,
3033 "IPv6 link-local NLRI received %s ignore this NLRI",
3034 inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3039 #endif /* HAVE_IPV6 */
3041 /* Normal process. */
3043 ret
= bgp_update (peer
, &p
, attr
, packet
->afi
, packet
->safi
,
3044 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
3046 ret
= bgp_withdraw (peer
, &p
, attr
, packet
->afi
, packet
->safi
,
3047 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
3049 /* Address family configuration mismatch or maximum-prefix count
3055 /* Packet length consistency check. */
3062 /* NLRI encode syntax check routine. */
3064 bgp_nlri_sanity_check (struct peer
*peer
, int afi
, u_char
*pnt
,
3073 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
3074 syntactic validity. If the field is syntactically incorrect,
3075 then the Error Subcode is set to Invalid Network Field. */
3081 /* Prefix length check. */
3082 if ((afi
== AFI_IP
&& prefixlen
> 32)
3083 || (afi
== AFI_IP6
&& prefixlen
> 128))
3085 plog_err (peer
->log
,
3086 "%s [Error] Update packet error (wrong prefix length %d)",
3087 peer
->host
, prefixlen
);
3088 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3089 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3093 /* Packet size overflow check. */
3094 psize
= PSIZE (prefixlen
);
3096 if (pnt
+ psize
> end
)
3098 plog_err (peer
->log
,
3099 "%s [Error] Update packet error"
3100 " (prefix data overflow prefix size is %d)",
3102 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3103 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3110 /* Packet length consistency check. */
3113 plog_err (peer
->log
,
3114 "%s [Error] Update packet error"
3115 " (prefix length mismatch with total length)",
3117 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3118 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3124 static struct bgp_static
*
3125 bgp_static_new (void)
3127 return XCALLOC (MTYPE_BGP_STATIC
, sizeof (struct bgp_static
));
3131 bgp_static_free (struct bgp_static
*bgp_static
)
3133 if (bgp_static
->rmap
.name
)
3134 free (bgp_static
->rmap
.name
);
3135 XFREE (MTYPE_BGP_STATIC
, bgp_static
);
3139 bgp_static_withdraw_rsclient (struct bgp
*bgp
, struct peer
*rsclient
,
3140 struct prefix
*p
, afi_t afi
, safi_t safi
)
3142 struct bgp_node
*rn
;
3143 struct bgp_info
*ri
;
3145 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3147 /* Check selected route and self inserted route. */
3148 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3149 if (ri
->peer
== bgp
->peer_self
3150 && ri
->type
== ZEBRA_ROUTE_BGP
3151 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3154 /* Withdraw static BGP route from routing table. */
3157 bgp_info_delete (rn
, ri
);
3158 bgp_process (bgp
, rn
, afi
, safi
);
3161 /* Unlock bgp_node_lookup. */
3162 bgp_unlock_node (rn
);
3166 bgp_static_update_rsclient (struct peer
*rsclient
, struct prefix
*p
,
3167 struct bgp_static
*bgp_static
,
3168 afi_t afi
, safi_t safi
)
3170 struct bgp_node
*rn
;
3171 struct bgp_info
*ri
;
3172 struct bgp_info
*new;
3173 struct bgp_info info
;
3174 struct attr
*attr_new
;
3175 struct attr attr
= {0 };
3176 struct attr new_attr
= { .extra
= 0 };
3179 char buf
[SU_ADDRSTRLEN
];
3181 bgp
= rsclient
->bgp
;
3183 assert (bgp_static
);
3187 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3189 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3191 attr
.nexthop
= bgp_static
->igpnexthop
;
3192 attr
.med
= bgp_static
->igpmetric
;
3193 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3195 if (bgp_static
->atomic
)
3196 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3198 /* Apply network route-map for export to this rsclient. */
3199 if (bgp_static
->rmap
.name
)
3201 struct attr attr_tmp
= attr
;
3202 info
.peer
= rsclient
;
3203 info
.attr
= &attr_tmp
;
3205 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_EXPORT
);
3206 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3208 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3210 rsclient
->rmap_type
= 0;
3212 if (ret
== RMAP_DENYMATCH
)
3214 /* Free uninterned attribute. */
3215 bgp_attr_flush (&attr_tmp
);
3217 /* Unintern original. */
3218 aspath_unintern (&attr
.aspath
);
3219 bgp_static_withdraw_rsclient (bgp
, rsclient
, p
, afi
, safi
);
3220 bgp_attr_extra_free (&attr
);
3224 attr_new
= bgp_attr_intern (&attr_tmp
);
3227 attr_new
= bgp_attr_intern (&attr
);
3229 bgp_attr_dup(&new_attr
, attr_new
);
3231 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3233 if (bgp_import_modifier (rsclient
, bgp
->peer_self
, p
, &new_attr
, afi
, safi
)
3236 /* This BGP update is filtered. Log the reason then update BGP entry. */
3237 if (BGP_DEBUG (update
, UPDATE_IN
))
3238 zlog (rsclient
->log
, LOG_DEBUG
,
3239 "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
3240 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
3241 p
->prefixlen
, rsclient
->host
);
3243 bgp
->peer_self
->rmap_type
= 0;
3245 bgp_attr_unintern (&attr_new
);
3246 aspath_unintern (&attr
.aspath
);
3247 bgp_attr_extra_free (&attr
);
3249 bgp_static_withdraw_rsclient (bgp
, rsclient
, p
, afi
, safi
);
3254 bgp
->peer_self
->rmap_type
= 0;
3256 bgp_attr_unintern (&attr_new
);
3257 attr_new
= bgp_attr_intern (&new_attr
);
3258 bgp_attr_extra_free (&new_attr
);
3260 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3261 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3262 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3267 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3268 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3270 bgp_unlock_node (rn
);
3271 bgp_attr_unintern (&attr_new
);
3272 aspath_unintern (&attr
.aspath
);
3273 bgp_attr_extra_free (&attr
);
3278 /* The attribute is changed. */
3279 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3281 /* Rewrite BGP route information. */
3282 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3283 bgp_info_restore(rn
, ri
);
3284 bgp_attr_unintern (&ri
->attr
);
3285 ri
->attr
= attr_new
;
3286 ri
->uptime
= bgp_clock ();
3288 /* Process change. */
3289 bgp_process (bgp
, rn
, afi
, safi
);
3290 bgp_unlock_node (rn
);
3291 aspath_unintern (&attr
.aspath
);
3292 bgp_attr_extra_free (&attr
);
3297 /* Make new BGP info. */
3298 new = bgp_info_new ();
3299 new->type
= ZEBRA_ROUTE_BGP
;
3300 new->sub_type
= BGP_ROUTE_STATIC
;
3301 new->peer
= bgp
->peer_self
;
3302 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3303 new->attr
= attr_new
;
3304 new->uptime
= bgp_clock ();
3306 /* Register new BGP information. */
3307 bgp_info_add (rn
, new);
3309 /* route_node_get lock */
3310 bgp_unlock_node (rn
);
3312 /* Process change. */
3313 bgp_process (bgp
, rn
, afi
, safi
);
3315 /* Unintern original. */
3316 aspath_unintern (&attr
.aspath
);
3317 bgp_attr_extra_free (&attr
);
3321 bgp_static_update_main (struct bgp
*bgp
, struct prefix
*p
,
3322 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3324 struct bgp_node
*rn
;
3325 struct bgp_info
*ri
;
3326 struct bgp_info
*new;
3327 struct bgp_info info
;
3328 struct attr attr
= { 0 };
3329 struct attr
*attr_new
;
3332 assert (bgp_static
);
3336 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3338 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3340 attr
.nexthop
= bgp_static
->igpnexthop
;
3341 attr
.med
= bgp_static
->igpmetric
;
3342 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3344 if (bgp_static
->atomic
)
3345 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3347 /* Apply route-map. */
3348 if (bgp_static
->rmap
.name
)
3350 struct attr attr_tmp
= attr
;
3351 info
.peer
= bgp
->peer_self
;
3352 info
.attr
= &attr_tmp
;
3354 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3356 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3358 bgp
->peer_self
->rmap_type
= 0;
3360 if (ret
== RMAP_DENYMATCH
)
3362 /* Free uninterned attribute. */
3363 bgp_attr_flush (&attr_tmp
);
3365 /* Unintern original. */
3366 aspath_unintern (&attr
.aspath
);
3367 bgp_attr_extra_free (&attr
);
3368 bgp_static_withdraw (bgp
, p
, afi
, safi
);
3371 attr_new
= bgp_attr_intern (&attr_tmp
);
3374 attr_new
= bgp_attr_intern (&attr
);
3376 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3377 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3378 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3383 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3384 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3386 bgp_unlock_node (rn
);
3387 bgp_attr_unintern (&attr_new
);
3388 aspath_unintern (&attr
.aspath
);
3389 bgp_attr_extra_free (&attr
);
3394 /* The attribute is changed. */
3395 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3397 /* Rewrite BGP route information. */
3398 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3399 bgp_info_restore(rn
, ri
);
3401 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3402 bgp_attr_unintern (&ri
->attr
);
3403 ri
->attr
= attr_new
;
3404 ri
->uptime
= bgp_clock ();
3406 /* Process change. */
3407 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3408 bgp_process (bgp
, rn
, afi
, safi
);
3409 bgp_unlock_node (rn
);
3410 aspath_unintern (&attr
.aspath
);
3411 bgp_attr_extra_free (&attr
);
3416 /* Make new BGP info. */
3417 new = bgp_info_new ();
3418 new->type
= ZEBRA_ROUTE_BGP
;
3419 new->sub_type
= BGP_ROUTE_STATIC
;
3420 new->peer
= bgp
->peer_self
;
3421 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3422 new->attr
= attr_new
;
3423 new->uptime
= bgp_clock ();
3425 /* Aggregate address increment. */
3426 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3428 /* Register new BGP information. */
3429 bgp_info_add (rn
, new);
3431 /* route_node_get lock */
3432 bgp_unlock_node (rn
);
3434 /* Process change. */
3435 bgp_process (bgp
, rn
, afi
, safi
);
3437 /* Unintern original. */
3438 aspath_unintern (&attr
.aspath
);
3439 bgp_attr_extra_free (&attr
);
3443 bgp_static_update (struct bgp
*bgp
, struct prefix
*p
,
3444 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3446 struct peer
*rsclient
;
3447 struct listnode
*node
, *nnode
;
3449 bgp_static_update_main (bgp
, p
, bgp_static
, afi
, safi
);
3451 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
3453 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
3454 bgp_static_update_rsclient (rsclient
, p
, bgp_static
, afi
, safi
);
3459 bgp_static_update_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3460 safi_t safi
, struct prefix_rd
*prd
, u_char
*tag
)
3462 struct bgp_node
*rn
;
3463 struct bgp_info
*new;
3465 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3467 /* Make new BGP info. */
3468 new = bgp_info_new ();
3469 new->type
= ZEBRA_ROUTE_BGP
;
3470 new->sub_type
= BGP_ROUTE_STATIC
;
3471 new->peer
= bgp
->peer_self
;
3472 new->attr
= bgp_attr_default_intern (BGP_ORIGIN_IGP
);
3473 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3474 new->uptime
= bgp_clock ();
3475 new->extra
= bgp_info_extra_new();
3476 memcpy (new->extra
->tag
, tag
, 3);
3478 /* Aggregate address increment. */
3479 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3481 /* Register new BGP information. */
3482 bgp_info_add (rn
, new);
3484 /* route_node_get lock */
3485 bgp_unlock_node (rn
);
3487 /* Process change. */
3488 bgp_process (bgp
, rn
, afi
, safi
);
3492 bgp_static_withdraw (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3495 struct bgp_node
*rn
;
3496 struct bgp_info
*ri
;
3498 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3500 /* Check selected route and self inserted route. */
3501 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3502 if (ri
->peer
== bgp
->peer_self
3503 && ri
->type
== ZEBRA_ROUTE_BGP
3504 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3507 /* Withdraw static BGP route from routing table. */
3510 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3511 bgp_info_delete (rn
, ri
);
3512 bgp_process (bgp
, rn
, afi
, safi
);
3515 /* Unlock bgp_node_lookup. */
3516 bgp_unlock_node (rn
);
3520 bgp_check_local_routes_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
)
3522 struct bgp_static
*bgp_static
;
3524 struct bgp_node
*rn
;
3527 bgp
= rsclient
->bgp
;
3529 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3530 if ((bgp_static
= rn
->info
) != NULL
)
3534 bgp_static_update_rsclient (rsclient
, p
, bgp_static
,
3540 bgp_static_withdraw_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3541 safi_t safi
, struct prefix_rd
*prd
, u_char
*tag
)
3543 struct bgp_node
*rn
;
3544 struct bgp_info
*ri
;
3546 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3548 /* Check selected route and self inserted route. */
3549 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3550 if (ri
->peer
== bgp
->peer_self
3551 && ri
->type
== ZEBRA_ROUTE_BGP
3552 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3555 /* Withdraw static BGP route from routing table. */
3558 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3559 bgp_info_delete (rn
, ri
);
3560 bgp_process (bgp
, rn
, afi
, safi
);
3563 /* Unlock bgp_node_lookup. */
3564 bgp_unlock_node (rn
);
3567 /* Configure static BGP network. When user don't run zebra, static
3568 route should be installed as valid. */
3570 bgp_static_set (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3571 afi_t afi
, safi_t safi
, const char *rmap
, int backdoor
)
3575 struct bgp_static
*bgp_static
;
3576 struct bgp_node
*rn
;
3577 u_char need_update
= 0;
3579 /* Convert IP prefix string to struct prefix. */
3580 ret
= str2prefix (ip_str
, &p
);
3583 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3587 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3589 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3593 #endif /* HAVE_IPV6 */
3597 /* Set BGP static route configuration. */
3598 rn
= bgp_node_get (bgp
->route
[afi
][safi
], &p
);
3602 /* Configuration change. */
3603 bgp_static
= rn
->info
;
3605 /* Check previous routes are installed into BGP. */
3606 if (bgp_static
->valid
&& bgp_static
->backdoor
!= backdoor
)
3609 bgp_static
->backdoor
= backdoor
;
3613 if (bgp_static
->rmap
.name
)
3614 free (bgp_static
->rmap
.name
);
3615 bgp_static
->rmap
.name
= strdup (rmap
);
3616 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3620 if (bgp_static
->rmap
.name
)
3621 free (bgp_static
->rmap
.name
);
3622 bgp_static
->rmap
.name
= NULL
;
3623 bgp_static
->rmap
.map
= NULL
;
3624 bgp_static
->valid
= 0;
3626 bgp_unlock_node (rn
);
3630 /* New configuration. */
3631 bgp_static
= bgp_static_new ();
3632 bgp_static
->backdoor
= backdoor
;
3633 bgp_static
->valid
= 0;
3634 bgp_static
->igpmetric
= 0;
3635 bgp_static
->igpnexthop
.s_addr
= 0;
3639 if (bgp_static
->rmap
.name
)
3640 free (bgp_static
->rmap
.name
);
3641 bgp_static
->rmap
.name
= strdup (rmap
);
3642 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3644 rn
->info
= bgp_static
;
3647 /* If BGP scan is not enabled, we should install this route here. */
3648 if (! bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3650 bgp_static
->valid
= 1;
3653 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3655 if (! bgp_static
->backdoor
)
3656 bgp_static_update (bgp
, &p
, bgp_static
, afi
, safi
);
3662 /* Configure static BGP network. */
3664 bgp_static_unset (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3665 afi_t afi
, safi_t safi
)
3669 struct bgp_static
*bgp_static
;
3670 struct bgp_node
*rn
;
3672 /* Convert IP prefix string to struct prefix. */
3673 ret
= str2prefix (ip_str
, &p
);
3676 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3680 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3682 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3686 #endif /* HAVE_IPV6 */
3690 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], &p
);
3693 vty_out (vty
, "%% Can't find specified static route configuration.%s",
3698 bgp_static
= rn
->info
;
3700 /* Update BGP RIB. */
3701 if (! bgp_static
->backdoor
)
3702 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3704 /* Clear configuration. */
3705 bgp_static_free (bgp_static
);
3707 bgp_unlock_node (rn
);
3708 bgp_unlock_node (rn
);
3713 /* Called from bgp_delete(). Delete all static routes from the BGP
3716 bgp_static_delete (struct bgp
*bgp
)
3720 struct bgp_node
*rn
;
3721 struct bgp_node
*rm
;
3722 struct bgp_table
*table
;
3723 struct bgp_static
*bgp_static
;
3725 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3726 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3727 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3728 if (rn
->info
!= NULL
)
3730 if (safi
== SAFI_MPLS_VPN
)
3734 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
3736 bgp_static
= rn
->info
;
3737 bgp_static_withdraw_vpnv4 (bgp
, &rm
->p
,
3738 AFI_IP
, SAFI_MPLS_VPN
,
3739 (struct prefix_rd
*)&rn
->p
,
3741 bgp_static_free (bgp_static
);
3743 bgp_unlock_node (rn
);
3748 bgp_static
= rn
->info
;
3749 bgp_static_withdraw (bgp
, &rn
->p
, afi
, safi
);
3750 bgp_static_free (bgp_static
);
3752 bgp_unlock_node (rn
);
3758 bgp_static_set_vpnv4 (struct vty
*vty
, const char *ip_str
, const char *rd_str
,
3759 const char *tag_str
)
3763 struct prefix_rd prd
;
3765 struct bgp_node
*prn
;
3766 struct bgp_node
*rn
;
3767 struct bgp_table
*table
;
3768 struct bgp_static
*bgp_static
;
3773 ret
= str2prefix (ip_str
, &p
);
3776 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3781 ret
= str2prefix_rd (rd_str
, &prd
);
3784 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3788 ret
= str2tag (tag_str
, tag
);
3791 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3795 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3796 (struct prefix
*)&prd
);
3797 if (prn
->info
== NULL
)
3798 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3800 bgp_unlock_node (prn
);
3803 rn
= bgp_node_get (table
, &p
);
3807 vty_out (vty
, "%% Same network configuration exists%s", VTY_NEWLINE
);
3808 bgp_unlock_node (rn
);
3812 /* New configuration. */
3813 bgp_static
= bgp_static_new ();
3814 bgp_static
->valid
= 1;
3815 memcpy (bgp_static
->tag
, tag
, 3);
3816 rn
->info
= bgp_static
;
3818 bgp_static_update_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3824 /* Configure static BGP network. */
3826 bgp_static_unset_vpnv4 (struct vty
*vty
, const char *ip_str
,
3827 const char *rd_str
, const char *tag_str
)
3832 struct prefix_rd prd
;
3833 struct bgp_node
*prn
;
3834 struct bgp_node
*rn
;
3835 struct bgp_table
*table
;
3836 struct bgp_static
*bgp_static
;
3841 /* Convert IP prefix string to struct prefix. */
3842 ret
= str2prefix (ip_str
, &p
);
3845 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3850 ret
= str2prefix_rd (rd_str
, &prd
);
3853 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3857 ret
= str2tag (tag_str
, tag
);
3860 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3864 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3865 (struct prefix
*)&prd
);
3866 if (prn
->info
== NULL
)
3867 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3869 bgp_unlock_node (prn
);
3872 rn
= bgp_node_lookup (table
, &p
);
3876 bgp_static_withdraw_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3878 bgp_static
= rn
->info
;
3879 bgp_static_free (bgp_static
);
3881 bgp_unlock_node (rn
);
3882 bgp_unlock_node (rn
);
3885 vty_out (vty
, "%% Can't find the route%s", VTY_NEWLINE
);
3892 "network A.B.C.D/M",
3893 "Specify a network to announce via BGP\n"
3894 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
3896 return bgp_static_set (vty
, vty
->index
, argv
[0],
3897 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
3900 DEFUN (bgp_network_route_map
,
3901 bgp_network_route_map_cmd
,
3902 "network A.B.C.D/M route-map WORD",
3903 "Specify a network to announce via BGP\n"
3904 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3905 "Route-map to modify the attributes\n"
3906 "Name of the route map\n")
3908 return bgp_static_set (vty
, vty
->index
, argv
[0],
3909 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
3912 DEFUN (bgp_network_backdoor
,
3913 bgp_network_backdoor_cmd
,
3914 "network A.B.C.D/M backdoor",
3915 "Specify a network to announce via BGP\n"
3916 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3917 "Specify a BGP backdoor route\n")
3919 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP
, SAFI_UNICAST
,
3923 DEFUN (bgp_network_mask
,
3924 bgp_network_mask_cmd
,
3925 "network A.B.C.D mask A.B.C.D",
3926 "Specify a network to announce via BGP\n"
3932 char prefix_str
[BUFSIZ
];
3934 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3937 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3941 return bgp_static_set (vty
, vty
->index
, prefix_str
,
3942 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
3945 DEFUN (bgp_network_mask_route_map
,
3946 bgp_network_mask_route_map_cmd
,
3947 "network A.B.C.D mask A.B.C.D route-map WORD",
3948 "Specify a network to announce via BGP\n"
3952 "Route-map to modify the attributes\n"
3953 "Name of the route map\n")
3956 char prefix_str
[BUFSIZ
];
3958 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3961 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3965 return bgp_static_set (vty
, vty
->index
, prefix_str
,
3966 AFI_IP
, bgp_node_safi (vty
), argv
[2], 0);
3969 DEFUN (bgp_network_mask_backdoor
,
3970 bgp_network_mask_backdoor_cmd
,
3971 "network A.B.C.D mask A.B.C.D backdoor",
3972 "Specify a network to announce via BGP\n"
3976 "Specify a BGP backdoor route\n")
3979 char prefix_str
[BUFSIZ
];
3981 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3984 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3988 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
3992 DEFUN (bgp_network_mask_natural
,
3993 bgp_network_mask_natural_cmd
,
3995 "Specify a network to announce via BGP\n"
3999 char prefix_str
[BUFSIZ
];
4001 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4004 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4008 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4009 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4012 DEFUN (bgp_network_mask_natural_route_map
,
4013 bgp_network_mask_natural_route_map_cmd
,
4014 "network A.B.C.D route-map WORD",
4015 "Specify a network to announce via BGP\n"
4017 "Route-map to modify the attributes\n"
4018 "Name of the route map\n")
4021 char prefix_str
[BUFSIZ
];
4023 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4026 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4030 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4031 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4034 DEFUN (bgp_network_mask_natural_backdoor
,
4035 bgp_network_mask_natural_backdoor_cmd
,
4036 "network A.B.C.D backdoor",
4037 "Specify a network to announce via BGP\n"
4039 "Specify a BGP backdoor route\n")
4042 char prefix_str
[BUFSIZ
];
4044 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4047 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4051 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4055 DEFUN (no_bgp_network
,
4057 "no network A.B.C.D/M",
4059 "Specify a network to announce via BGP\n"
4060 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4062 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP
,
4063 bgp_node_safi (vty
));
4066 ALIAS (no_bgp_network
,
4067 no_bgp_network_route_map_cmd
,
4068 "no network A.B.C.D/M route-map WORD",
4070 "Specify a network to announce via BGP\n"
4071 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4072 "Route-map to modify the attributes\n"
4073 "Name of the route map\n")
4075 ALIAS (no_bgp_network
,
4076 no_bgp_network_backdoor_cmd
,
4077 "no network A.B.C.D/M backdoor",
4079 "Specify a network to announce via BGP\n"
4080 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4081 "Specify a BGP backdoor route\n")
4083 DEFUN (no_bgp_network_mask
,
4084 no_bgp_network_mask_cmd
,
4085 "no network A.B.C.D mask A.B.C.D",
4087 "Specify a network to announce via BGP\n"
4093 char prefix_str
[BUFSIZ
];
4095 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4098 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4102 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4103 bgp_node_safi (vty
));
4106 ALIAS (no_bgp_network_mask
,
4107 no_bgp_network_mask_route_map_cmd
,
4108 "no network A.B.C.D mask A.B.C.D route-map WORD",
4110 "Specify a network to announce via BGP\n"
4114 "Route-map to modify the attributes\n"
4115 "Name of the route map\n")
4117 ALIAS (no_bgp_network_mask
,
4118 no_bgp_network_mask_backdoor_cmd
,
4119 "no network A.B.C.D mask A.B.C.D backdoor",
4121 "Specify a network to announce via BGP\n"
4125 "Specify a BGP backdoor route\n")
4127 DEFUN (no_bgp_network_mask_natural
,
4128 no_bgp_network_mask_natural_cmd
,
4129 "no network A.B.C.D",
4131 "Specify a network to announce via BGP\n"
4135 char prefix_str
[BUFSIZ
];
4137 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4140 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4144 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4145 bgp_node_safi (vty
));
4148 ALIAS (no_bgp_network_mask_natural
,
4149 no_bgp_network_mask_natural_route_map_cmd
,
4150 "no network A.B.C.D route-map WORD",
4152 "Specify a network to announce via BGP\n"
4154 "Route-map to modify the attributes\n"
4155 "Name of the route map\n")
4157 ALIAS (no_bgp_network_mask_natural
,
4158 no_bgp_network_mask_natural_backdoor_cmd
,
4159 "no network A.B.C.D backdoor",
4161 "Specify a network to announce via BGP\n"
4163 "Specify a BGP backdoor route\n")
4166 DEFUN (ipv6_bgp_network
,
4167 ipv6_bgp_network_cmd
,
4168 "network X:X::X:X/M",
4169 "Specify a network to announce via BGP\n"
4170 "IPv6 prefix <network>/<length>\n")
4172 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
4176 DEFUN (ipv6_bgp_network_route_map
,
4177 ipv6_bgp_network_route_map_cmd
,
4178 "network X:X::X:X/M route-map WORD",
4179 "Specify a network to announce via BGP\n"
4180 "IPv6 prefix <network>/<length>\n"
4181 "Route-map to modify the attributes\n"
4182 "Name of the route map\n")
4184 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
,
4185 bgp_node_safi (vty
), argv
[1], 0);
4188 DEFUN (no_ipv6_bgp_network
,
4189 no_ipv6_bgp_network_cmd
,
4190 "no network X:X::X:X/M",
4192 "Specify a network to announce via BGP\n"
4193 "IPv6 prefix <network>/<length>\n")
4195 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
4198 ALIAS (no_ipv6_bgp_network
,
4199 no_ipv6_bgp_network_route_map_cmd
,
4200 "no network X:X::X:X/M route-map WORD",
4202 "Specify a network to announce via BGP\n"
4203 "IPv6 prefix <network>/<length>\n"
4204 "Route-map to modify the attributes\n"
4205 "Name of the route map\n")
4207 ALIAS (ipv6_bgp_network
,
4208 old_ipv6_bgp_network_cmd
,
4209 "ipv6 bgp network X:X::X:X/M",
4212 "Specify a network to announce via BGP\n"
4213 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4215 ALIAS (no_ipv6_bgp_network
,
4216 old_no_ipv6_bgp_network_cmd
,
4217 "no ipv6 bgp network X:X::X:X/M",
4221 "Specify a network to announce via BGP\n"
4222 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4223 #endif /* HAVE_IPV6 */
4225 /* stubs for removed AS-Pathlimit commands, kept for config compatibility */
4226 ALIAS_DEPRECATED (bgp_network
,
4227 bgp_network_ttl_cmd
,
4228 "network A.B.C.D/M pathlimit <0-255>",
4229 "Specify a network to announce via BGP\n"
4230 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4231 "AS-Path hopcount limit attribute\n"
4232 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4233 ALIAS_DEPRECATED (bgp_network_backdoor
,
4234 bgp_network_backdoor_ttl_cmd
,
4235 "network A.B.C.D/M backdoor pathlimit <0-255>",
4236 "Specify a network to announce via BGP\n"
4237 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4238 "Specify a BGP backdoor route\n"
4239 "AS-Path hopcount limit attribute\n"
4240 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4241 ALIAS_DEPRECATED (bgp_network_mask
,
4242 bgp_network_mask_ttl_cmd
,
4243 "network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4244 "Specify a network to announce via BGP\n"
4248 "AS-Path hopcount limit attribute\n"
4249 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4250 ALIAS_DEPRECATED (bgp_network_mask_backdoor
,
4251 bgp_network_mask_backdoor_ttl_cmd
,
4252 "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4253 "Specify a network to announce via BGP\n"
4257 "Specify a BGP backdoor route\n"
4258 "AS-Path hopcount limit attribute\n"
4259 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4260 ALIAS_DEPRECATED (bgp_network_mask_natural
,
4261 bgp_network_mask_natural_ttl_cmd
,
4262 "network A.B.C.D pathlimit <0-255>",
4263 "Specify a network to announce via BGP\n"
4265 "AS-Path hopcount limit attribute\n"
4266 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4267 ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor
,
4268 bgp_network_mask_natural_backdoor_ttl_cmd
,
4269 "network A.B.C.D backdoor pathlimit (1-255>",
4270 "Specify a network to announce via BGP\n"
4272 "Specify a BGP backdoor route\n"
4273 "AS-Path hopcount limit attribute\n"
4274 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4275 ALIAS_DEPRECATED (no_bgp_network
,
4276 no_bgp_network_ttl_cmd
,
4277 "no network A.B.C.D/M pathlimit <0-255>",
4279 "Specify a network to announce via BGP\n"
4280 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4281 "AS-Path hopcount limit attribute\n"
4282 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4283 ALIAS_DEPRECATED (no_bgp_network
,
4284 no_bgp_network_backdoor_ttl_cmd
,
4285 "no network A.B.C.D/M backdoor pathlimit <0-255>",
4287 "Specify a network to announce via BGP\n"
4288 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4289 "Specify a BGP backdoor route\n"
4290 "AS-Path hopcount limit attribute\n"
4291 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4292 ALIAS_DEPRECATED (no_bgp_network
,
4293 no_bgp_network_mask_ttl_cmd
,
4294 "no network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4296 "Specify a network to announce via BGP\n"
4300 "AS-Path hopcount limit attribute\n"
4301 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4302 ALIAS_DEPRECATED (no_bgp_network_mask
,
4303 no_bgp_network_mask_backdoor_ttl_cmd
,
4304 "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4306 "Specify a network to announce via BGP\n"
4310 "Specify a BGP backdoor route\n"
4311 "AS-Path hopcount limit attribute\n"
4312 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4313 ALIAS_DEPRECATED (no_bgp_network_mask_natural
,
4314 no_bgp_network_mask_natural_ttl_cmd
,
4315 "no network A.B.C.D pathlimit <0-255>",
4317 "Specify a network to announce via BGP\n"
4319 "AS-Path hopcount limit attribute\n"
4320 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4321 ALIAS_DEPRECATED (no_bgp_network_mask_natural
,
4322 no_bgp_network_mask_natural_backdoor_ttl_cmd
,
4323 "no network A.B.C.D backdoor pathlimit <0-255>",
4325 "Specify a network to announce via BGP\n"
4327 "Specify a BGP backdoor route\n"
4328 "AS-Path hopcount limit attribute\n"
4329 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4331 ALIAS_DEPRECATED (ipv6_bgp_network
,
4332 ipv6_bgp_network_ttl_cmd
,
4333 "network X:X::X:X/M pathlimit <0-255>",
4334 "Specify a network to announce via BGP\n"
4335 "IPv6 prefix <network>/<length>\n"
4336 "AS-Path hopcount limit attribute\n"
4337 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4338 ALIAS_DEPRECATED (no_ipv6_bgp_network
,
4339 no_ipv6_bgp_network_ttl_cmd
,
4340 "no network X:X::X:X/M pathlimit <0-255>",
4342 "Specify a network to announce via BGP\n"
4343 "IPv6 prefix <network>/<length>\n"
4344 "AS-Path hopcount limit attribute\n"
4345 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4346 #endif /* HAVE_IPV6 */
4348 /* Aggreagete address:
4350 advertise-map Set condition to advertise attribute
4351 as-set Generate AS set path information
4352 attribute-map Set attributes of aggregate
4353 route-map Set parameters of aggregate
4354 summary-only Filter more specific routes from updates
4355 suppress-map Conditionally filter more specific routes from updates
4358 struct bgp_aggregate
4360 /* Summary-only flag. */
4361 u_char summary_only
;
4363 /* AS set generation. */
4366 /* Route-map for aggregated route. */
4367 struct route_map
*map
;
4369 /* Suppress-count. */
4370 unsigned long count
;
4372 /* SAFI configuration. */
4376 static struct bgp_aggregate
*
4377 bgp_aggregate_new (void)
4379 return XCALLOC (MTYPE_BGP_AGGREGATE
, sizeof (struct bgp_aggregate
));
4383 bgp_aggregate_free (struct bgp_aggregate
*aggregate
)
4385 XFREE (MTYPE_BGP_AGGREGATE
, aggregate
);
4389 bgp_aggregate_route (struct bgp
*bgp
, struct prefix
*p
, struct bgp_info
*rinew
,
4390 afi_t afi
, safi_t safi
, struct bgp_info
*del
,
4391 struct bgp_aggregate
*aggregate
)
4393 struct bgp_table
*table
;
4394 struct bgp_node
*top
;
4395 struct bgp_node
*rn
;
4397 struct aspath
*aspath
= NULL
;
4398 struct aspath
*asmerge
= NULL
;
4399 struct community
*community
= NULL
;
4400 struct community
*commerge
= NULL
;
4401 struct in_addr nexthop
;
4403 struct bgp_info
*ri
;
4404 struct bgp_info
*new;
4406 unsigned long match
= 0;
4408 /* Record adding route's nexthop and med. */
4411 nexthop
= rinew
->attr
->nexthop
;
4412 med
= rinew
->attr
->med
;
4415 /* ORIGIN attribute: If at least one route among routes that are
4416 aggregated has ORIGIN with the value INCOMPLETE, then the
4417 aggregated route must have the ORIGIN attribute with the value
4418 INCOMPLETE. Otherwise, if at least one route among routes that
4419 are aggregated has ORIGIN with the value EGP, then the aggregated
4420 route must have the origin attribute with the value EGP. In all
4421 other case the value of the ORIGIN attribute of the aggregated
4422 route is INTERNAL. */
4423 origin
= BGP_ORIGIN_IGP
;
4425 table
= bgp
->rib
[afi
][safi
];
4427 top
= bgp_node_get (table
, p
);
4428 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4429 if (rn
->p
.prefixlen
> p
->prefixlen
)
4433 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4435 if (BGP_INFO_HOLDDOWN (ri
))
4438 if (del
&& ri
== del
)
4441 if (! rinew
&& first
)
4443 nexthop
= ri
->attr
->nexthop
;
4444 med
= ri
->attr
->med
;
4448 #ifdef AGGREGATE_NEXTHOP_CHECK
4449 if (! IPV4_ADDR_SAME (&ri
->attr
->nexthop
, &nexthop
)
4450 || ri
->attr
->med
!= med
)
4453 aspath_free (aspath
);
4455 community_free (community
);
4456 bgp_unlock_node (rn
);
4457 bgp_unlock_node (top
);
4460 #endif /* AGGREGATE_NEXTHOP_CHECK */
4462 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4464 if (aggregate
->summary_only
)
4466 (bgp_info_extra_get (ri
))->suppress
++;
4467 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4473 if (aggregate
->as_set
)
4475 if (origin
< ri
->attr
->origin
)
4476 origin
= ri
->attr
->origin
;
4480 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4481 aspath_free (aspath
);
4485 aspath
= aspath_dup (ri
->attr
->aspath
);
4487 if (ri
->attr
->community
)
4491 commerge
= community_merge (community
,
4492 ri
->attr
->community
);
4493 community
= community_uniq_sort (commerge
);
4494 community_free (commerge
);
4497 community
= community_dup (ri
->attr
->community
);
4503 bgp_process (bgp
, rn
, afi
, safi
);
4505 bgp_unlock_node (top
);
4511 if (aggregate
->summary_only
)
4512 (bgp_info_extra_get (rinew
))->suppress
++;
4514 if (aggregate
->as_set
)
4516 if (origin
< rinew
->attr
->origin
)
4517 origin
= rinew
->attr
->origin
;
4521 asmerge
= aspath_aggregate (aspath
, rinew
->attr
->aspath
);
4522 aspath_free (aspath
);
4526 aspath
= aspath_dup (rinew
->attr
->aspath
);
4528 if (rinew
->attr
->community
)
4532 commerge
= community_merge (community
,
4533 rinew
->attr
->community
);
4534 community
= community_uniq_sort (commerge
);
4535 community_free (commerge
);
4538 community
= community_dup (rinew
->attr
->community
);
4543 if (aggregate
->count
> 0)
4545 rn
= bgp_node_get (table
, p
);
4546 new = bgp_info_new ();
4547 new->type
= ZEBRA_ROUTE_BGP
;
4548 new->sub_type
= BGP_ROUTE_AGGREGATE
;
4549 new->peer
= bgp
->peer_self
;
4550 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4551 new->attr
= bgp_attr_aggregate_intern (bgp
, origin
, aspath
, community
, aggregate
->as_set
);
4552 new->uptime
= bgp_clock ();
4554 bgp_info_add (rn
, new);
4555 bgp_unlock_node (rn
);
4556 bgp_process (bgp
, rn
, afi
, safi
);
4561 aspath_free (aspath
);
4563 community_free (community
);
4567 void bgp_aggregate_delete (struct bgp
*, struct prefix
*, afi_t
, safi_t
,
4568 struct bgp_aggregate
*);
4571 bgp_aggregate_increment (struct bgp
*bgp
, struct prefix
*p
,
4572 struct bgp_info
*ri
, afi_t afi
, safi_t safi
)
4574 struct bgp_node
*child
;
4575 struct bgp_node
*rn
;
4576 struct bgp_aggregate
*aggregate
;
4578 /* MPLS-VPN aggregation is not yet supported. */
4579 if (safi
== SAFI_MPLS_VPN
)
4582 if (p
->prefixlen
== 0)
4585 if (BGP_INFO_HOLDDOWN (ri
))
4588 child
= bgp_node_get (bgp
->aggregate
[afi
][safi
], p
);
4590 /* Aggregate address configuration check. */
4591 for (rn
= child
; rn
; rn
= rn
->parent
)
4592 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4594 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4595 bgp_aggregate_route (bgp
, &rn
->p
, ri
, afi
, safi
, NULL
, aggregate
);
4597 bgp_unlock_node (child
);
4601 bgp_aggregate_decrement (struct bgp
*bgp
, struct prefix
*p
,
4602 struct bgp_info
*del
, afi_t afi
, safi_t safi
)
4604 struct bgp_node
*child
;
4605 struct bgp_node
*rn
;
4606 struct bgp_aggregate
*aggregate
;
4608 /* MPLS-VPN aggregation is not yet supported. */
4609 if (safi
== SAFI_MPLS_VPN
)
4612 if (p
->prefixlen
== 0)
4615 child
= bgp_node_get (bgp
->aggregate
[afi
][safi
], p
);
4617 /* Aggregate address configuration check. */
4618 for (rn
= child
; rn
; rn
= rn
->parent
)
4619 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4621 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4622 bgp_aggregate_route (bgp
, &rn
->p
, NULL
, afi
, safi
, del
, aggregate
);
4624 bgp_unlock_node (child
);
4628 bgp_aggregate_add (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
, safi_t safi
,
4629 struct bgp_aggregate
*aggregate
)
4631 struct bgp_table
*table
;
4632 struct bgp_node
*top
;
4633 struct bgp_node
*rn
;
4634 struct bgp_info
*new;
4635 struct bgp_info
*ri
;
4636 unsigned long match
;
4637 u_char origin
= BGP_ORIGIN_IGP
;
4638 struct aspath
*aspath
= NULL
;
4639 struct aspath
*asmerge
= NULL
;
4640 struct community
*community
= NULL
;
4641 struct community
*commerge
= NULL
;
4643 table
= bgp
->rib
[afi
][safi
];
4646 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4648 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4651 /* If routes exists below this node, generate aggregate routes. */
4652 top
= bgp_node_get (table
, p
);
4653 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4654 if (rn
->p
.prefixlen
> p
->prefixlen
)
4658 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4660 if (BGP_INFO_HOLDDOWN (ri
))
4663 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4665 /* summary-only aggregate route suppress aggregated
4666 route announcement. */
4667 if (aggregate
->summary_only
)
4669 (bgp_info_extra_get (ri
))->suppress
++;
4670 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4673 /* as-set aggregate route generate origin, as path,
4674 community aggregation. */
4675 if (aggregate
->as_set
)
4677 if (origin
< ri
->attr
->origin
)
4678 origin
= ri
->attr
->origin
;
4682 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4683 aspath_free (aspath
);
4687 aspath
= aspath_dup (ri
->attr
->aspath
);
4689 if (ri
->attr
->community
)
4693 commerge
= community_merge (community
,
4694 ri
->attr
->community
);
4695 community
= community_uniq_sort (commerge
);
4696 community_free (commerge
);
4699 community
= community_dup (ri
->attr
->community
);
4706 /* If this node is suppressed, process the change. */
4708 bgp_process (bgp
, rn
, afi
, safi
);
4710 bgp_unlock_node (top
);
4712 /* Add aggregate route to BGP table. */
4713 if (aggregate
->count
)
4715 rn
= bgp_node_get (table
, p
);
4717 new = bgp_info_new ();
4718 new->type
= ZEBRA_ROUTE_BGP
;
4719 new->sub_type
= BGP_ROUTE_AGGREGATE
;
4720 new->peer
= bgp
->peer_self
;
4721 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4722 new->attr
= bgp_attr_aggregate_intern (bgp
, origin
, aspath
, community
, aggregate
->as_set
);
4723 new->uptime
= bgp_clock ();
4725 bgp_info_add (rn
, new);
4726 bgp_unlock_node (rn
);
4728 /* Process change. */
4729 bgp_process (bgp
, rn
, afi
, safi
);
4734 bgp_aggregate_delete (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
4735 safi_t safi
, struct bgp_aggregate
*aggregate
)
4737 struct bgp_table
*table
;
4738 struct bgp_node
*top
;
4739 struct bgp_node
*rn
;
4740 struct bgp_info
*ri
;
4741 unsigned long match
;
4743 table
= bgp
->rib
[afi
][safi
];
4745 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4747 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4750 /* If routes exists below this node, generate aggregate routes. */
4751 top
= bgp_node_get (table
, p
);
4752 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4753 if (rn
->p
.prefixlen
> p
->prefixlen
)
4757 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4759 if (BGP_INFO_HOLDDOWN (ri
))
4762 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4764 if (aggregate
->summary_only
&& ri
->extra
)
4766 ri
->extra
->suppress
--;
4768 if (ri
->extra
->suppress
== 0)
4770 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4778 /* If this node was suppressed, process the change. */
4780 bgp_process (bgp
, rn
, afi
, safi
);
4782 bgp_unlock_node (top
);
4784 /* Delete aggregate route from BGP table. */
4785 rn
= bgp_node_get (table
, p
);
4787 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4788 if (ri
->peer
== bgp
->peer_self
4789 && ri
->type
== ZEBRA_ROUTE_BGP
4790 && ri
->sub_type
== BGP_ROUTE_AGGREGATE
)
4793 /* Withdraw static BGP route from routing table. */
4796 bgp_info_delete (rn
, ri
);
4797 bgp_process (bgp
, rn
, afi
, safi
);
4800 /* Unlock bgp_node_lookup. */
4801 bgp_unlock_node (rn
);
4804 /* Aggregate route attribute. */
4805 #define AGGREGATE_SUMMARY_ONLY 1
4806 #define AGGREGATE_AS_SET 1
4809 bgp_aggregate_unset (struct vty
*vty
, const char *prefix_str
,
4810 afi_t afi
, safi_t safi
)
4814 struct bgp_node
*rn
;
4816 struct bgp_aggregate
*aggregate
;
4818 /* Convert string to prefix structure. */
4819 ret
= str2prefix (prefix_str
, &p
);
4822 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
4827 /* Get BGP structure. */
4830 /* Old configuration check. */
4831 rn
= bgp_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
4834 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
4839 aggregate
= rn
->info
;
4840 if (aggregate
->safi
& SAFI_UNICAST
)
4841 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
4842 if (aggregate
->safi
& SAFI_MULTICAST
)
4843 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
4845 /* Unlock aggregate address configuration. */
4847 bgp_aggregate_free (aggregate
);
4848 bgp_unlock_node (rn
);
4849 bgp_unlock_node (rn
);
4855 bgp_aggregate_set (struct vty
*vty
, const char *prefix_str
,
4856 afi_t afi
, safi_t safi
,
4857 u_char summary_only
, u_char as_set
)
4861 struct bgp_node
*rn
;
4863 struct bgp_aggregate
*aggregate
;
4865 /* Convert string to prefix structure. */
4866 ret
= str2prefix (prefix_str
, &p
);
4869 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
4874 /* Get BGP structure. */
4877 /* Old configuration check. */
4878 rn
= bgp_node_get (bgp
->aggregate
[afi
][safi
], &p
);
4882 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
4883 /* try to remove the old entry */
4884 ret
= bgp_aggregate_unset (vty
, prefix_str
, afi
, safi
);
4887 vty_out (vty
, "Error deleting aggregate.%s", VTY_NEWLINE
);
4888 bgp_unlock_node (rn
);
4893 /* Make aggregate address structure. */
4894 aggregate
= bgp_aggregate_new ();
4895 aggregate
->summary_only
= summary_only
;
4896 aggregate
->as_set
= as_set
;
4897 aggregate
->safi
= safi
;
4898 rn
->info
= aggregate
;
4900 /* Aggregate address insert into BGP routing table. */
4901 if (safi
& SAFI_UNICAST
)
4902 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
4903 if (safi
& SAFI_MULTICAST
)
4904 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
4909 DEFUN (aggregate_address
,
4910 aggregate_address_cmd
,
4911 "aggregate-address A.B.C.D/M",
4912 "Configure BGP aggregate entries\n"
4913 "Aggregate prefix\n")
4915 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
), 0, 0);
4918 DEFUN (aggregate_address_mask
,
4919 aggregate_address_mask_cmd
,
4920 "aggregate-address A.B.C.D A.B.C.D",
4921 "Configure BGP aggregate entries\n"
4922 "Aggregate address\n"
4926 char prefix_str
[BUFSIZ
];
4928 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4932 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4936 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
4940 DEFUN (aggregate_address_summary_only
,
4941 aggregate_address_summary_only_cmd
,
4942 "aggregate-address A.B.C.D/M summary-only",
4943 "Configure BGP aggregate entries\n"
4944 "Aggregate prefix\n"
4945 "Filter more specific routes from updates\n")
4947 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
4948 AGGREGATE_SUMMARY_ONLY
, 0);
4951 DEFUN (aggregate_address_mask_summary_only
,
4952 aggregate_address_mask_summary_only_cmd
,
4953 "aggregate-address A.B.C.D A.B.C.D summary-only",
4954 "Configure BGP aggregate entries\n"
4955 "Aggregate address\n"
4957 "Filter more specific routes from updates\n")
4960 char prefix_str
[BUFSIZ
];
4962 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4966 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4970 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
4971 AGGREGATE_SUMMARY_ONLY
, 0);
4974 DEFUN (aggregate_address_as_set
,
4975 aggregate_address_as_set_cmd
,
4976 "aggregate-address A.B.C.D/M as-set",
4977 "Configure BGP aggregate entries\n"
4978 "Aggregate prefix\n"
4979 "Generate AS set path information\n")
4981 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
4982 0, AGGREGATE_AS_SET
);
4985 DEFUN (aggregate_address_mask_as_set
,
4986 aggregate_address_mask_as_set_cmd
,
4987 "aggregate-address A.B.C.D A.B.C.D as-set",
4988 "Configure BGP aggregate entries\n"
4989 "Aggregate address\n"
4991 "Generate AS set path information\n")
4994 char prefix_str
[BUFSIZ
];
4996 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5000 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5004 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5005 0, AGGREGATE_AS_SET
);
5009 DEFUN (aggregate_address_as_set_summary
,
5010 aggregate_address_as_set_summary_cmd
,
5011 "aggregate-address A.B.C.D/M as-set summary-only",
5012 "Configure BGP aggregate entries\n"
5013 "Aggregate prefix\n"
5014 "Generate AS set path information\n"
5015 "Filter more specific routes from updates\n")
5017 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5018 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5021 ALIAS (aggregate_address_as_set_summary
,
5022 aggregate_address_summary_as_set_cmd
,
5023 "aggregate-address A.B.C.D/M summary-only as-set",
5024 "Configure BGP aggregate entries\n"
5025 "Aggregate prefix\n"
5026 "Filter more specific routes from updates\n"
5027 "Generate AS set path information\n")
5029 DEFUN (aggregate_address_mask_as_set_summary
,
5030 aggregate_address_mask_as_set_summary_cmd
,
5031 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5032 "Configure BGP aggregate entries\n"
5033 "Aggregate address\n"
5035 "Generate AS set path information\n"
5036 "Filter more specific routes from updates\n")
5039 char prefix_str
[BUFSIZ
];
5041 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5045 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5049 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5050 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5053 ALIAS (aggregate_address_mask_as_set_summary
,
5054 aggregate_address_mask_summary_as_set_cmd
,
5055 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5056 "Configure BGP aggregate entries\n"
5057 "Aggregate address\n"
5059 "Filter more specific routes from updates\n"
5060 "Generate AS set path information\n")
5062 DEFUN (no_aggregate_address
,
5063 no_aggregate_address_cmd
,
5064 "no aggregate-address A.B.C.D/M",
5066 "Configure BGP aggregate entries\n"
5067 "Aggregate prefix\n")
5069 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
));
5072 ALIAS (no_aggregate_address
,
5073 no_aggregate_address_summary_only_cmd
,
5074 "no aggregate-address A.B.C.D/M summary-only",
5076 "Configure BGP aggregate entries\n"
5077 "Aggregate prefix\n"
5078 "Filter more specific routes from updates\n")
5080 ALIAS (no_aggregate_address
,
5081 no_aggregate_address_as_set_cmd
,
5082 "no aggregate-address A.B.C.D/M as-set",
5084 "Configure BGP aggregate entries\n"
5085 "Aggregate prefix\n"
5086 "Generate AS set path information\n")
5088 ALIAS (no_aggregate_address
,
5089 no_aggregate_address_as_set_summary_cmd
,
5090 "no aggregate-address A.B.C.D/M as-set summary-only",
5092 "Configure BGP aggregate entries\n"
5093 "Aggregate prefix\n"
5094 "Generate AS set path information\n"
5095 "Filter more specific routes from updates\n")
5097 ALIAS (no_aggregate_address
,
5098 no_aggregate_address_summary_as_set_cmd
,
5099 "no aggregate-address A.B.C.D/M summary-only as-set",
5101 "Configure BGP aggregate entries\n"
5102 "Aggregate prefix\n"
5103 "Filter more specific routes from updates\n"
5104 "Generate AS set path information\n")
5106 DEFUN (no_aggregate_address_mask
,
5107 no_aggregate_address_mask_cmd
,
5108 "no aggregate-address A.B.C.D A.B.C.D",
5110 "Configure BGP aggregate entries\n"
5111 "Aggregate address\n"
5115 char prefix_str
[BUFSIZ
];
5117 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5121 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5125 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
5128 ALIAS (no_aggregate_address_mask
,
5129 no_aggregate_address_mask_summary_only_cmd
,
5130 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5132 "Configure BGP aggregate entries\n"
5133 "Aggregate address\n"
5135 "Filter more specific routes from updates\n")
5137 ALIAS (no_aggregate_address_mask
,
5138 no_aggregate_address_mask_as_set_cmd
,
5139 "no aggregate-address A.B.C.D A.B.C.D as-set",
5141 "Configure BGP aggregate entries\n"
5142 "Aggregate address\n"
5144 "Generate AS set path information\n")
5146 ALIAS (no_aggregate_address_mask
,
5147 no_aggregate_address_mask_as_set_summary_cmd
,
5148 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5150 "Configure BGP aggregate entries\n"
5151 "Aggregate address\n"
5153 "Generate AS set path information\n"
5154 "Filter more specific routes from updates\n")
5156 ALIAS (no_aggregate_address_mask
,
5157 no_aggregate_address_mask_summary_as_set_cmd
,
5158 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5160 "Configure BGP aggregate entries\n"
5161 "Aggregate address\n"
5163 "Filter more specific routes from updates\n"
5164 "Generate AS set path information\n")
5167 DEFUN (ipv6_aggregate_address
,
5168 ipv6_aggregate_address_cmd
,
5169 "aggregate-address X:X::X:X/M",
5170 "Configure BGP aggregate entries\n"
5171 "Aggregate prefix\n")
5173 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0, 0);
5176 DEFUN (ipv6_aggregate_address_summary_only
,
5177 ipv6_aggregate_address_summary_only_cmd
,
5178 "aggregate-address X:X::X:X/M summary-only",
5179 "Configure BGP aggregate entries\n"
5180 "Aggregate prefix\n"
5181 "Filter more specific routes from updates\n")
5183 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5184 AGGREGATE_SUMMARY_ONLY
, 0);
5187 DEFUN (no_ipv6_aggregate_address
,
5188 no_ipv6_aggregate_address_cmd
,
5189 "no aggregate-address X:X::X:X/M",
5191 "Configure BGP aggregate entries\n"
5192 "Aggregate prefix\n")
5194 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5197 DEFUN (no_ipv6_aggregate_address_summary_only
,
5198 no_ipv6_aggregate_address_summary_only_cmd
,
5199 "no aggregate-address X:X::X:X/M summary-only",
5201 "Configure BGP aggregate entries\n"
5202 "Aggregate prefix\n"
5203 "Filter more specific routes from updates\n")
5205 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5208 ALIAS (ipv6_aggregate_address
,
5209 old_ipv6_aggregate_address_cmd
,
5210 "ipv6 bgp aggregate-address X:X::X:X/M",
5213 "Configure BGP aggregate entries\n"
5214 "Aggregate prefix\n")
5216 ALIAS (ipv6_aggregate_address_summary_only
,
5217 old_ipv6_aggregate_address_summary_only_cmd
,
5218 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5221 "Configure BGP aggregate entries\n"
5222 "Aggregate prefix\n"
5223 "Filter more specific routes from updates\n")
5225 ALIAS (no_ipv6_aggregate_address
,
5226 old_no_ipv6_aggregate_address_cmd
,
5227 "no ipv6 bgp aggregate-address X:X::X:X/M",
5231 "Configure BGP aggregate entries\n"
5232 "Aggregate prefix\n")
5234 ALIAS (no_ipv6_aggregate_address_summary_only
,
5235 old_no_ipv6_aggregate_address_summary_only_cmd
,
5236 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5240 "Configure BGP aggregate entries\n"
5241 "Aggregate prefix\n"
5242 "Filter more specific routes from updates\n")
5243 #endif /* HAVE_IPV6 */
5245 /* Redistribute route treatment. */
5247 bgp_redistribute_add (struct prefix
*p
, struct in_addr
*nexthop
,
5248 u_int32_t metric
, u_char type
)
5251 struct listnode
*node
, *nnode
;
5252 struct bgp_info
*new;
5253 struct bgp_info
*bi
;
5254 struct bgp_info info
;
5255 struct bgp_node
*bn
;
5256 struct attr attr
= { 0 };
5257 struct attr attr_new
= { 0 };
5258 struct attr
*new_attr
;
5262 /* Make default attribute. */
5263 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
5265 attr
.nexthop
= *nexthop
;
5268 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
5270 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
5272 afi
= family2afi (p
->family
);
5274 if (bgp
->redist
[afi
][type
])
5276 /* Copy attribute for modification. */
5277 bgp_attr_dup (&attr_new
, &attr
);
5279 if (bgp
->redist_metric_flag
[afi
][type
])
5280 attr_new
.med
= bgp
->redist_metric
[afi
][type
];
5282 /* Apply route-map. */
5283 if (bgp
->rmap
[afi
][type
].map
)
5285 info
.peer
= bgp
->peer_self
;
5286 info
.attr
= &attr_new
;
5288 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
);
5290 ret
= route_map_apply (bgp
->rmap
[afi
][type
].map
, p
, RMAP_BGP
,
5293 bgp
->peer_self
->rmap_type
= 0;
5295 if (ret
== RMAP_DENYMATCH
)
5297 /* Free uninterned attribute. */
5298 bgp_attr_flush (&attr_new
);
5299 bgp_attr_extra_free (&attr_new
);
5301 /* Unintern original. */
5302 aspath_unintern (&attr
.aspath
);
5303 bgp_attr_extra_free (&attr
);
5304 bgp_redistribute_delete (p
, type
);
5309 bn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
],
5310 afi
, SAFI_UNICAST
, p
, NULL
);
5312 new_attr
= bgp_attr_intern (&attr_new
);
5313 bgp_attr_extra_free (&attr_new
);
5315 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
5316 if (bi
->peer
== bgp
->peer_self
5317 && bi
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
5322 if (attrhash_cmp (bi
->attr
, new_attr
) &&
5323 !CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5325 bgp_attr_unintern (&new_attr
);
5326 aspath_unintern (&attr
.aspath
);
5327 bgp_attr_extra_free (&attr
);
5328 bgp_unlock_node (bn
);
5333 /* The attribute is changed. */
5334 bgp_info_set_flag (bn
, bi
, BGP_INFO_ATTR_CHANGED
);
5336 /* Rewrite BGP route information. */
5337 if (CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5338 bgp_info_restore(bn
, bi
);
5340 bgp_aggregate_decrement (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5341 bgp_attr_unintern (&bi
->attr
);
5342 bi
->attr
= new_attr
;
5343 bi
->uptime
= bgp_clock ();
5345 /* Process change. */
5346 bgp_aggregate_increment (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5347 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5348 bgp_unlock_node (bn
);
5349 aspath_unintern (&attr
.aspath
);
5350 bgp_attr_extra_free (&attr
);
5355 new = bgp_info_new ();
5357 new->sub_type
= BGP_ROUTE_REDISTRIBUTE
;
5358 new->peer
= bgp
->peer_self
;
5359 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5360 new->attr
= new_attr
;
5361 new->uptime
= bgp_clock ();
5363 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
5364 bgp_info_add (bn
, new);
5365 bgp_unlock_node (bn
);
5366 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5370 /* Unintern original. */
5371 aspath_unintern (&attr
.aspath
);
5372 bgp_attr_extra_free (&attr
);
5376 bgp_redistribute_delete (struct prefix
*p
, u_char type
)
5379 struct listnode
*node
, *nnode
;
5381 struct bgp_node
*rn
;
5382 struct bgp_info
*ri
;
5384 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
5386 afi
= family2afi (p
->family
);
5388 if (bgp
->redist
[afi
][type
])
5390 rn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
5392 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5393 if (ri
->peer
== bgp
->peer_self
5394 && ri
->type
== type
)
5399 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
5400 bgp_info_delete (rn
, ri
);
5401 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5403 bgp_unlock_node (rn
);
5408 /* Withdraw specified route type's route. */
5410 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
)
5412 struct bgp_node
*rn
;
5413 struct bgp_info
*ri
;
5414 struct bgp_table
*table
;
5416 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
5418 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
5420 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5421 if (ri
->peer
== bgp
->peer_self
5422 && ri
->type
== type
)
5427 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
5428 bgp_info_delete (rn
, ri
);
5429 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5434 /* Static function to display route. */
5436 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
5439 u_int32_t destination
;
5442 if (p
->family
== AF_INET
)
5444 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
5445 destination
= ntohl (p
->u
.prefix4
.s_addr
);
5447 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
5448 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
5449 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
5450 || p
->u
.prefix4
.s_addr
== 0)
5452 /* When mask is natural, mask is not displayed. */
5455 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
5458 len
= vty_out (vty
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
5463 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
5465 vty_out (vty
, "%*s", len
, " ");
5468 enum bgp_display_type
5473 /* Print the short form route status for a bgp_info */
5475 route_vty_short_status_out (struct vty
*vty
, struct bgp_info
*binfo
)
5477 /* Route status display. */
5478 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5480 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5482 else if (binfo
->extra
&& binfo
->extra
->suppress
)
5484 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5490 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5492 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5494 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5499 /* Internal route. */
5500 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
5506 /* called from terminal list command */
5508 route_vty_out (struct vty
*vty
, struct prefix
*p
,
5509 struct bgp_info
*binfo
, int display
, safi_t safi
)
5513 /* short status lead text */
5514 route_vty_short_status_out (vty
, binfo
);
5516 /* print prefix and mask */
5518 route_vty_out_route (p
, vty
);
5520 vty_out (vty
, "%*s", 17, " ");
5522 /* Print attribute */
5526 if (p
->family
== AF_INET
)
5528 if (safi
== SAFI_MPLS_VPN
)
5529 vty_out (vty
, "%-16s",
5530 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5532 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5535 else if (p
->family
== AF_INET6
)
5540 len
= vty_out (vty
, "%s",
5541 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5545 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5547 vty_out (vty
, "%*s", len
, " ");
5549 #endif /* HAVE_IPV6 */
5551 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5552 vty_out (vty
, "%10u", attr
->med
);
5556 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5557 vty_out (vty
, "%7u", attr
->local_pref
);
5561 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
5565 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5568 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5570 vty_out (vty
, "%s", VTY_NEWLINE
);
5573 /* called from terminal list command */
5575 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
,
5576 struct attr
*attr
, safi_t safi
)
5578 /* Route status display. */
5583 /* print prefix and mask */
5584 route_vty_out_route (p
, vty
);
5586 /* Print attribute */
5589 if (p
->family
== AF_INET
)
5591 if (safi
== SAFI_MPLS_VPN
)
5592 vty_out (vty
, "%-16s",
5593 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5595 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5598 else if (p
->family
== AF_INET6
)
5603 assert (attr
->extra
);
5605 len
= vty_out (vty
, "%s",
5606 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5610 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5612 vty_out (vty
, "%*s", len
, " ");
5614 #endif /* HAVE_IPV6 */
5616 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5617 vty_out (vty
, "%10u", attr
->med
);
5621 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5622 vty_out (vty
, "%7u", attr
->local_pref
);
5626 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
5630 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5633 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5636 vty_out (vty
, "%s", VTY_NEWLINE
);
5640 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
5641 struct bgp_info
*binfo
, int display
, safi_t safi
)
5644 u_int32_t label
= 0;
5649 /* short status lead text */
5650 route_vty_short_status_out (vty
, binfo
);
5652 /* print prefix and mask */
5654 route_vty_out_route (p
, vty
);
5656 vty_out (vty
, "%*s", 17, " ");
5658 /* Print attribute */
5662 if (p
->family
== AF_INET
)
5664 if (safi
== SAFI_MPLS_VPN
)
5665 vty_out (vty
, "%-16s",
5666 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5668 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5671 else if (p
->family
== AF_INET6
)
5673 assert (attr
->extra
);
5676 if (attr
->extra
->mp_nexthop_len
== 16)
5678 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5680 else if (attr
->extra
->mp_nexthop_len
== 32)
5681 vty_out (vty
, "%s(%s)",
5682 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5684 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
5688 #endif /* HAVE_IPV6 */
5691 label
= decode_label (binfo
->extra
->tag
);
5693 vty_out (vty
, "notag/%d", label
);
5695 vty_out (vty
, "%s", VTY_NEWLINE
);
5698 /* dampening route */
5700 damp_route_vty_out (struct vty
*vty
, struct prefix
*p
,
5701 struct bgp_info
*binfo
, int display
, safi_t safi
)
5705 char timebuf
[BGP_UPTIME_LEN
];
5707 /* short status lead text */
5708 route_vty_short_status_out (vty
, binfo
);
5710 /* print prefix and mask */
5712 route_vty_out_route (p
, vty
);
5714 vty_out (vty
, "%*s", 17, " ");
5716 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
5719 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 34, " ");
5721 vty_out (vty
, "%*s", len
, " ");
5723 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
));
5725 /* Print attribute */
5731 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5734 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5736 vty_out (vty
, "%s", VTY_NEWLINE
);
5741 flap_route_vty_out (struct vty
*vty
, struct prefix
*p
,
5742 struct bgp_info
*binfo
, int display
, safi_t safi
)
5745 struct bgp_damp_info
*bdi
;
5746 char timebuf
[BGP_UPTIME_LEN
];
5752 bdi
= binfo
->extra
->damp_info
;
5754 /* short status lead text */
5755 route_vty_short_status_out (vty
, binfo
);
5757 /* print prefix and mask */
5759 route_vty_out_route (p
, vty
);
5761 vty_out (vty
, "%*s", 17, " ");
5763 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
5766 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 33, " ");
5768 vty_out (vty
, "%*s", len
, " ");
5770 len
= vty_out (vty
, "%d", bdi
->flap
);
5775 vty_out (vty
, "%*s ", len
, " ");
5777 vty_out (vty
, "%s ", peer_uptime (bdi
->start_time
,
5778 timebuf
, BGP_UPTIME_LEN
));
5780 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
)
5781 && ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5782 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
));
5784 vty_out (vty
, "%*s ", 8, " ");
5786 /* Print attribute */
5792 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5795 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5797 vty_out (vty
, "%s", VTY_NEWLINE
);
5801 route_vty_out_detail (struct vty
*vty
, struct bgp
*bgp
, struct prefix
*p
,
5802 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
)
5804 char buf
[INET6_ADDRSTRLEN
];
5807 int sockunion_vty_out (struct vty
*, union sockunion
*);
5808 #ifdef HAVE_CLOCK_MONOTONIC
5816 /* Line1 display AS-path, Aggregator */
5820 if (aspath_count_hops (attr
->aspath
) == 0)
5821 vty_out (vty
, "Local");
5823 aspath_print_vty (vty
, "%s", attr
->aspath
, "");
5826 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5827 vty_out (vty
, ", (removed)");
5828 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5829 vty_out (vty
, ", (stale)");
5830 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
5831 vty_out (vty
, ", (aggregated by %u %s)",
5832 attr
->extra
->aggregator_as
,
5833 inet_ntoa (attr
->extra
->aggregator_addr
));
5834 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
5835 vty_out (vty
, ", (Received from a RR-client)");
5836 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
5837 vty_out (vty
, ", (Received from a RS-client)");
5838 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5839 vty_out (vty
, ", (history entry)");
5840 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5841 vty_out (vty
, ", (suppressed due to dampening)");
5842 vty_out (vty
, "%s", VTY_NEWLINE
);
5844 /* Line2 display Next-hop, Neighbor, Router-id */
5845 if (p
->family
== AF_INET
)
5847 vty_out (vty
, " %s", safi
== SAFI_MPLS_VPN
?
5848 inet_ntoa (attr
->extra
->mp_nexthop_global_in
) :
5849 inet_ntoa (attr
->nexthop
));
5854 assert (attr
->extra
);
5855 vty_out (vty
, " %s",
5856 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5857 buf
, INET6_ADDRSTRLEN
));
5859 #endif /* HAVE_IPV6 */
5861 if (binfo
->peer
== bgp
->peer_self
)
5863 vty_out (vty
, " from %s ",
5864 p
->family
== AF_INET
? "0.0.0.0" : "::");
5865 vty_out (vty
, "(%s)", inet_ntoa(bgp
->router_id
));
5869 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
5870 vty_out (vty
, " (inaccessible)");
5871 else if (binfo
->extra
&& binfo
->extra
->igpmetric
)
5872 vty_out (vty
, " (metric %d)", binfo
->extra
->igpmetric
);
5873 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
5874 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
5875 vty_out (vty
, " (%s)", inet_ntoa (attr
->extra
->originator_id
));
5877 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
5879 vty_out (vty
, "%s", VTY_NEWLINE
);
5882 /* display nexthop local */
5883 if (attr
->extra
&& attr
->extra
->mp_nexthop_len
== 32)
5885 vty_out (vty
, " (%s)%s",
5886 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
5887 buf
, INET6_ADDRSTRLEN
),
5890 #endif /* HAVE_IPV6 */
5892 /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */
5893 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
5895 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
5896 vty_out (vty
, ", metric %u", attr
->med
);
5898 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
5899 vty_out (vty
, ", localpref %u", attr
->local_pref
);
5901 vty_out (vty
, ", localpref %u", bgp
->default_local_pref
);
5903 if (attr
->extra
&& attr
->extra
->weight
!= 0)
5904 vty_out (vty
, ", weight %u", attr
->extra
->weight
);
5906 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5907 vty_out (vty
, ", valid");
5909 if (binfo
->peer
!= bgp
->peer_self
)
5911 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
5912 vty_out (vty
, ", internal");
5914 vty_out (vty
, ", %s",
5915 (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
) ? "confed-external" : "external"));
5917 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
5918 vty_out (vty
, ", aggregated, local");
5919 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
5920 vty_out (vty
, ", sourced");
5922 vty_out (vty
, ", sourced, local");
5924 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
5925 vty_out (vty
, ", atomic-aggregate");
5927 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5928 vty_out (vty
, ", best");
5930 vty_out (vty
, "%s", VTY_NEWLINE
);
5932 /* Line 4 display Community */
5933 if (attr
->community
)
5934 vty_out (vty
, " Community: %s%s", attr
->community
->str
,
5937 /* Line 5 display Extended-community */
5938 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
5939 vty_out (vty
, " Extended Community: %s%s",
5940 attr
->extra
->ecommunity
->str
, VTY_NEWLINE
);
5942 /* Line 6 display Originator, Cluster-id */
5943 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
5944 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
5946 assert (attr
->extra
);
5947 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
5948 vty_out (vty
, " Originator: %s",
5949 inet_ntoa (attr
->extra
->originator_id
));
5951 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
5954 vty_out (vty
, ", Cluster list: ");
5955 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
5956 vty_out (vty
, "%s ",
5957 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
5959 vty_out (vty
, "%s", VTY_NEWLINE
);
5962 if (binfo
->extra
&& binfo
->extra
->damp_info
)
5963 bgp_damp_info_vty (vty
, binfo
);
5965 /* Line 7 display Uptime */
5966 #ifdef HAVE_CLOCK_MONOTONIC
5967 tbuf
= time(NULL
) - (bgp_clock() - binfo
->uptime
);
5968 vty_out (vty
, " Last update: %s", ctime(&tbuf
));
5970 vty_out (vty
, " Last update: %s", ctime(&binfo
->uptime
));
5971 #endif /* HAVE_CLOCK_MONOTONIC */
5973 vty_out (vty
, "%s", VTY_NEWLINE
);
5976 #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"
5977 #define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
5978 #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
5979 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
5980 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
5984 bgp_show_type_normal
,
5985 bgp_show_type_regexp
,
5986 bgp_show_type_prefix_list
,
5987 bgp_show_type_filter_list
,
5988 bgp_show_type_route_map
,
5989 bgp_show_type_neighbor
,
5990 bgp_show_type_cidr_only
,
5991 bgp_show_type_prefix_longer
,
5992 bgp_show_type_community_all
,
5993 bgp_show_type_community
,
5994 bgp_show_type_community_exact
,
5995 bgp_show_type_community_list
,
5996 bgp_show_type_community_list_exact
,
5997 bgp_show_type_flap_statistics
,
5998 bgp_show_type_flap_address
,
5999 bgp_show_type_flap_prefix
,
6000 bgp_show_type_flap_cidr_only
,
6001 bgp_show_type_flap_regexp
,
6002 bgp_show_type_flap_filter_list
,
6003 bgp_show_type_flap_prefix_list
,
6004 bgp_show_type_flap_prefix_longer
,
6005 bgp_show_type_flap_route_map
,
6006 bgp_show_type_flap_neighbor
,
6007 bgp_show_type_dampend_paths
,
6008 bgp_show_type_damp_neighbor
6012 bgp_show_table (struct vty
*vty
, struct bgp_table
*table
, struct in_addr
*router_id
,
6013 enum bgp_show_type type
, void *output_arg
)
6015 struct bgp_info
*ri
;
6016 struct bgp_node
*rn
;
6019 unsigned long output_count
;
6021 /* This is first entry point, so reset total line. */
6024 /* Start processing of routes. */
6025 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
6026 if (rn
->info
!= NULL
)
6030 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6032 if (type
== bgp_show_type_flap_statistics
6033 || type
== bgp_show_type_flap_address
6034 || type
== bgp_show_type_flap_prefix
6035 || type
== bgp_show_type_flap_cidr_only
6036 || type
== bgp_show_type_flap_regexp
6037 || type
== bgp_show_type_flap_filter_list
6038 || type
== bgp_show_type_flap_prefix_list
6039 || type
== bgp_show_type_flap_prefix_longer
6040 || type
== bgp_show_type_flap_route_map
6041 || type
== bgp_show_type_flap_neighbor
6042 || type
== bgp_show_type_dampend_paths
6043 || type
== bgp_show_type_damp_neighbor
)
6045 if (!(ri
->extra
&& ri
->extra
->damp_info
))
6048 if (type
== bgp_show_type_regexp
6049 || type
== bgp_show_type_flap_regexp
)
6051 regex_t
*regex
= output_arg
;
6053 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
6056 if (type
== bgp_show_type_prefix_list
6057 || type
== bgp_show_type_flap_prefix_list
)
6059 struct prefix_list
*plist
= output_arg
;
6061 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
6064 if (type
== bgp_show_type_filter_list
6065 || type
== bgp_show_type_flap_filter_list
)
6067 struct as_list
*as_list
= output_arg
;
6069 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
6072 if (type
== bgp_show_type_route_map
6073 || type
== bgp_show_type_flap_route_map
)
6075 struct route_map
*rmap
= output_arg
;
6076 struct bgp_info binfo
;
6077 struct attr dummy_attr
= { 0 };
6080 bgp_attr_dup (&dummy_attr
, ri
->attr
);
6081 binfo
.peer
= ri
->peer
;
6082 binfo
.attr
= &dummy_attr
;
6084 ret
= route_map_apply (rmap
, &rn
->p
, RMAP_BGP
, &binfo
);
6086 bgp_attr_extra_free (&dummy_attr
);
6088 if (ret
== RMAP_DENYMATCH
)
6091 if (type
== bgp_show_type_neighbor
6092 || type
== bgp_show_type_flap_neighbor
6093 || type
== bgp_show_type_damp_neighbor
)
6095 union sockunion
*su
= output_arg
;
6097 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
6100 if (type
== bgp_show_type_cidr_only
6101 || type
== bgp_show_type_flap_cidr_only
)
6103 u_int32_t destination
;
6105 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
6106 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
6108 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
6110 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
6113 if (type
== bgp_show_type_prefix_longer
6114 || type
== bgp_show_type_flap_prefix_longer
)
6116 struct prefix
*p
= output_arg
;
6118 if (! prefix_match (p
, &rn
->p
))
6121 if (type
== bgp_show_type_community_all
)
6123 if (! ri
->attr
->community
)
6126 if (type
== bgp_show_type_community
)
6128 struct community
*com
= output_arg
;
6130 if (! ri
->attr
->community
||
6131 ! community_match (ri
->attr
->community
, com
))
6134 if (type
== bgp_show_type_community_exact
)
6136 struct community
*com
= output_arg
;
6138 if (! ri
->attr
->community
||
6139 ! community_cmp (ri
->attr
->community
, com
))
6142 if (type
== bgp_show_type_community_list
)
6144 struct community_list
*list
= output_arg
;
6146 if (! community_list_match (ri
->attr
->community
, list
))
6149 if (type
== bgp_show_type_community_list_exact
)
6151 struct community_list
*list
= output_arg
;
6153 if (! community_list_exact_match (ri
->attr
->community
, list
))
6156 if (type
== bgp_show_type_flap_address
6157 || type
== bgp_show_type_flap_prefix
)
6159 struct prefix
*p
= output_arg
;
6161 if (! prefix_match (&rn
->p
, p
))
6164 if (type
== bgp_show_type_flap_prefix
)
6165 if (p
->prefixlen
!= rn
->p
.prefixlen
)
6168 if (type
== bgp_show_type_dampend_paths
6169 || type
== bgp_show_type_damp_neighbor
)
6171 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
)
6172 || CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
6178 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id
), VTY_NEWLINE
);
6179 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
6180 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
6181 if (type
== bgp_show_type_dampend_paths
6182 || type
== bgp_show_type_damp_neighbor
)
6183 vty_out (vty
, BGP_SHOW_DAMP_HEADER
, VTY_NEWLINE
);
6184 else if (type
== bgp_show_type_flap_statistics
6185 || type
== bgp_show_type_flap_address
6186 || type
== bgp_show_type_flap_prefix
6187 || type
== bgp_show_type_flap_cidr_only
6188 || type
== bgp_show_type_flap_regexp
6189 || type
== bgp_show_type_flap_filter_list
6190 || type
== bgp_show_type_flap_prefix_list
6191 || type
== bgp_show_type_flap_prefix_longer
6192 || type
== bgp_show_type_flap_route_map
6193 || type
== bgp_show_type_flap_neighbor
)
6194 vty_out (vty
, BGP_SHOW_FLAP_HEADER
, VTY_NEWLINE
);
6196 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
6200 if (type
== bgp_show_type_dampend_paths
6201 || type
== bgp_show_type_damp_neighbor
)
6202 damp_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6203 else if (type
== bgp_show_type_flap_statistics
6204 || type
== bgp_show_type_flap_address
6205 || type
== bgp_show_type_flap_prefix
6206 || type
== bgp_show_type_flap_cidr_only
6207 || type
== bgp_show_type_flap_regexp
6208 || type
== bgp_show_type_flap_filter_list
6209 || type
== bgp_show_type_flap_prefix_list
6210 || type
== bgp_show_type_flap_prefix_longer
6211 || type
== bgp_show_type_flap_route_map
6212 || type
== bgp_show_type_flap_neighbor
)
6213 flap_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6215 route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6222 /* No route is displayed */
6223 if (output_count
== 0)
6225 if (type
== bgp_show_type_normal
)
6226 vty_out (vty
, "No BGP network exists%s", VTY_NEWLINE
);
6229 vty_out (vty
, "%sTotal number of prefixes %ld%s",
6230 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
6236 bgp_show (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
6237 enum bgp_show_type type
, void *output_arg
)
6239 struct bgp_table
*table
;
6242 bgp
= bgp_get_default ();
6247 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
6252 table
= bgp
->rib
[afi
][safi
];
6254 return bgp_show_table (vty
, table
, &bgp
->router_id
, type
, output_arg
);
6257 /* Header of detailed BGP route information */
6259 route_vty_out_detail_header (struct vty
*vty
, struct bgp
*bgp
,
6260 struct bgp_node
*rn
,
6261 struct prefix_rd
*prd
, afi_t afi
, safi_t safi
)
6263 struct bgp_info
*ri
;
6266 struct listnode
*node
, *nnode
;
6267 char buf1
[INET6_ADDRSTRLEN
];
6268 char buf2
[INET6_ADDRSTRLEN
];
6273 int no_advertise
= 0;
6278 vty_out (vty
, "BGP routing table entry for %s%s%s/%d%s",
6279 (safi
== SAFI_MPLS_VPN
?
6280 prefix_rd2str (prd
, buf1
, RD_ADDRSTRLEN
) : ""),
6281 safi
== SAFI_MPLS_VPN
? ":" : "",
6282 inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
),
6283 p
->prefixlen
, VTY_NEWLINE
);
6285 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6288 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
6291 if (ri
->extra
&& ri
->extra
->suppress
)
6293 if (ri
->attr
->community
!= NULL
)
6295 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
6297 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
6299 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
6305 vty_out (vty
, "Paths: (%d available", count
);
6308 vty_out (vty
, ", best #%d", best
);
6309 if (safi
== SAFI_UNICAST
)
6310 vty_out (vty
, ", table Default-IP-Routing-Table");
6313 vty_out (vty
, ", no best path");
6315 vty_out (vty
, ", not advertised to any peer");
6317 vty_out (vty
, ", not advertised to EBGP peer");
6319 vty_out (vty
, ", not advertised outside local AS");
6321 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
6322 vty_out (vty
, ")%s", VTY_NEWLINE
);
6324 /* advertised peer */
6325 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
6327 if (bgp_adj_out_lookup (peer
, p
, afi
, safi
, rn
))
6330 vty_out (vty
, " Advertised to non peer-group peers:%s ", VTY_NEWLINE
);
6331 vty_out (vty
, " %s", sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6336 vty_out (vty
, " Not advertised to any peer");
6337 vty_out (vty
, "%s", VTY_NEWLINE
);
6340 /* Display specified route of BGP table. */
6342 bgp_show_route_in_table (struct vty
*vty
, struct bgp
*bgp
,
6343 struct bgp_table
*rib
, const char *ip_str
,
6344 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
6350 struct prefix match
;
6351 struct bgp_node
*rn
;
6352 struct bgp_node
*rm
;
6353 struct bgp_info
*ri
;
6354 struct bgp_table
*table
;
6356 /* Check IP address argument. */
6357 ret
= str2prefix (ip_str
, &match
);
6360 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
6364 match
.family
= afi2family (afi
);
6366 if (safi
== SAFI_MPLS_VPN
)
6368 for (rn
= bgp_table_top (rib
); rn
; rn
= bgp_route_next (rn
))
6370 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
6373 if ((table
= rn
->info
) != NULL
)
6377 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
6379 if (prefix_check
&& rm
->p
.prefixlen
!= match
.prefixlen
)
6381 bgp_unlock_node (rm
);
6385 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
6389 route_vty_out_detail_header (vty
, bgp
, rm
, (struct prefix_rd
*)&rn
->p
,
6390 AFI_IP
, SAFI_MPLS_VPN
);
6395 route_vty_out_detail (vty
, bgp
, &rm
->p
, ri
, AFI_IP
, SAFI_MPLS_VPN
);
6398 bgp_unlock_node (rm
);
6407 if ((rn
= bgp_node_match (rib
, &match
)) != NULL
)
6409 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
6411 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6415 route_vty_out_detail_header (vty
, bgp
, rn
, NULL
, afi
, safi
);
6419 route_vty_out_detail (vty
, bgp
, &rn
->p
, ri
, afi
, safi
);
6423 bgp_unlock_node (rn
);
6429 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
6436 /* Display specified route of Main RIB */
6438 bgp_show_route (struct vty
*vty
, const char *view_name
, const char *ip_str
,
6439 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
6444 /* BGP structure lookup. */
6447 bgp
= bgp_lookup_by_name (view_name
);
6450 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
6456 bgp
= bgp_get_default ();
6459 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
6464 return bgp_show_route_in_table (vty
, bgp
, bgp
->rib
[afi
][safi
], ip_str
,
6465 afi
, safi
, prd
, prefix_check
);
6468 /* BGP route print out function. */
6476 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6479 DEFUN (show_ip_bgp_ipv4
,
6480 show_ip_bgp_ipv4_cmd
,
6481 "show ip bgp ipv4 (unicast|multicast)",
6486 "Address Family modifier\n"
6487 "Address Family modifier\n")
6489 if (strncmp (argv
[0], "m", 1) == 0)
6490 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
, bgp_show_type_normal
,
6493 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6496 ALIAS (show_ip_bgp_ipv4
,
6497 show_bgp_ipv4_safi_cmd
,
6498 "show bgp ipv4 (unicast|multicast)",
6502 "Address Family modifier\n"
6503 "Address Family modifier\n")
6505 DEFUN (show_ip_bgp_route
,
6506 show_ip_bgp_route_cmd
,
6507 "show ip bgp A.B.C.D",
6511 "Network in the BGP routing table to display\n")
6513 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6516 DEFUN (show_ip_bgp_ipv4_route
,
6517 show_ip_bgp_ipv4_route_cmd
,
6518 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
6523 "Address Family modifier\n"
6524 "Address Family modifier\n"
6525 "Network in the BGP routing table to display\n")
6527 if (strncmp (argv
[0], "m", 1) == 0)
6528 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0);
6530 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6533 ALIAS (show_ip_bgp_ipv4_route
,
6534 show_bgp_ipv4_safi_route_cmd
,
6535 "show bgp ipv4 (unicast|multicast) A.B.C.D",
6539 "Address Family modifier\n"
6540 "Address Family modifier\n"
6541 "Network in the BGP routing table to display\n")
6543 DEFUN (show_ip_bgp_vpnv4_all_route
,
6544 show_ip_bgp_vpnv4_all_route_cmd
,
6545 "show ip bgp vpnv4 all A.B.C.D",
6549 "Display VPNv4 NLRI specific information\n"
6550 "Display information about all VPNv4 NLRIs\n"
6551 "Network in the BGP routing table to display\n")
6553 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 0);
6556 DEFUN (show_ip_bgp_vpnv4_rd_route
,
6557 show_ip_bgp_vpnv4_rd_route_cmd
,
6558 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
6562 "Display VPNv4 NLRI specific information\n"
6563 "Display information for a route distinguisher\n"
6564 "VPN Route Distinguisher\n"
6565 "Network in the BGP routing table to display\n")
6568 struct prefix_rd prd
;
6570 ret
= str2prefix_rd (argv
[0], &prd
);
6573 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
6576 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0);
6579 DEFUN (show_ip_bgp_prefix
,
6580 show_ip_bgp_prefix_cmd
,
6581 "show ip bgp A.B.C.D/M",
6585 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6587 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6590 DEFUN (show_ip_bgp_ipv4_prefix
,
6591 show_ip_bgp_ipv4_prefix_cmd
,
6592 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
6597 "Address Family modifier\n"
6598 "Address Family modifier\n"
6599 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6601 if (strncmp (argv
[0], "m", 1) == 0)
6602 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1);
6604 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6607 ALIAS (show_ip_bgp_ipv4_prefix
,
6608 show_bgp_ipv4_safi_prefix_cmd
,
6609 "show bgp ipv4 (unicast|multicast) A.B.C.D/M",
6613 "Address Family modifier\n"
6614 "Address Family modifier\n"
6615 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6617 DEFUN (show_ip_bgp_vpnv4_all_prefix
,
6618 show_ip_bgp_vpnv4_all_prefix_cmd
,
6619 "show ip bgp vpnv4 all A.B.C.D/M",
6623 "Display VPNv4 NLRI specific information\n"
6624 "Display information about all VPNv4 NLRIs\n"
6625 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6627 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 1);
6630 DEFUN (show_ip_bgp_vpnv4_rd_prefix
,
6631 show_ip_bgp_vpnv4_rd_prefix_cmd
,
6632 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
6636 "Display VPNv4 NLRI specific information\n"
6637 "Display information for a route distinguisher\n"
6638 "VPN Route Distinguisher\n"
6639 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6642 struct prefix_rd prd
;
6644 ret
= str2prefix_rd (argv
[0], &prd
);
6647 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
6650 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 1);
6653 DEFUN (show_ip_bgp_view
,
6654 show_ip_bgp_view_cmd
,
6655 "show ip bgp view WORD",
6664 /* BGP structure lookup. */
6665 bgp
= bgp_lookup_by_name (argv
[0]);
6668 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
6672 return bgp_show (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6675 DEFUN (show_ip_bgp_view_route
,
6676 show_ip_bgp_view_route_cmd
,
6677 "show ip bgp view WORD A.B.C.D",
6683 "Network in the BGP routing table to display\n")
6685 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6688 DEFUN (show_ip_bgp_view_prefix
,
6689 show_ip_bgp_view_prefix_cmd
,
6690 "show ip bgp view WORD A.B.C.D/M",
6696 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6698 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6708 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
6719 DEFUN (show_bgp_ipv6_safi
,
6720 show_bgp_ipv6_safi_cmd
,
6721 "show bgp ipv6 (unicast|multicast)",
6725 "Address Family modifier\n"
6726 "Address Family modifier\n")
6728 if (strncmp (argv
[0], "m", 1) == 0)
6729 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
6732 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6736 DEFUN (show_ipv6_bgp
,
6743 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
6747 DEFUN (show_bgp_route
,
6749 "show bgp X:X::X:X",
6752 "Network in the BGP routing table to display\n")
6754 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6757 ALIAS (show_bgp_route
,
6758 show_bgp_ipv6_route_cmd
,
6759 "show bgp ipv6 X:X::X:X",
6763 "Network in the BGP routing table to display\n")
6765 DEFUN (show_bgp_ipv6_safi_route
,
6766 show_bgp_ipv6_safi_route_cmd
,
6767 "show bgp ipv6 (unicast|multicast) X:X::X:X",
6771 "Address Family modifier\n"
6772 "Address Family modifier\n"
6773 "Network in the BGP routing table to display\n")
6775 if (strncmp (argv
[0], "m", 1) == 0)
6776 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0);
6778 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6782 DEFUN (show_ipv6_bgp_route
,
6783 show_ipv6_bgp_route_cmd
,
6784 "show ipv6 bgp X:X::X:X",
6788 "Network in the BGP routing table to display\n")
6790 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6793 DEFUN (show_bgp_prefix
,
6794 show_bgp_prefix_cmd
,
6795 "show bgp X:X::X:X/M",
6798 "IPv6 prefix <network>/<length>\n")
6800 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6803 ALIAS (show_bgp_prefix
,
6804 show_bgp_ipv6_prefix_cmd
,
6805 "show bgp ipv6 X:X::X:X/M",
6809 "IPv6 prefix <network>/<length>\n")
6811 DEFUN (show_bgp_ipv6_safi_prefix
,
6812 show_bgp_ipv6_safi_prefix_cmd
,
6813 "show bgp ipv6 (unicast|multicast) X:X::X:X/M",
6817 "Address Family modifier\n"
6818 "Address Family modifier\n"
6819 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6821 if (strncmp (argv
[0], "m", 1) == 0)
6822 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1);
6824 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6828 DEFUN (show_ipv6_bgp_prefix
,
6829 show_ipv6_bgp_prefix_cmd
,
6830 "show ipv6 bgp X:X::X:X/M",
6834 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6836 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6839 DEFUN (show_bgp_view
,
6841 "show bgp view WORD",
6849 /* BGP structure lookup. */
6850 bgp
= bgp_lookup_by_name (argv
[0]);
6853 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
6857 return bgp_show (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6860 ALIAS (show_bgp_view
,
6861 show_bgp_view_ipv6_cmd
,
6862 "show bgp view WORD ipv6",
6869 DEFUN (show_bgp_view_route
,
6870 show_bgp_view_route_cmd
,
6871 "show bgp view WORD X:X::X:X",
6876 "Network in the BGP routing table to display\n")
6878 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6881 ALIAS (show_bgp_view_route
,
6882 show_bgp_view_ipv6_route_cmd
,
6883 "show bgp view WORD ipv6 X:X::X:X",
6889 "Network in the BGP routing table to display\n")
6891 DEFUN (show_bgp_view_prefix
,
6892 show_bgp_view_prefix_cmd
,
6893 "show bgp view WORD X:X::X:X/M",
6898 "IPv6 prefix <network>/<length>\n")
6900 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6903 ALIAS (show_bgp_view_prefix
,
6904 show_bgp_view_ipv6_prefix_cmd
,
6905 "show bgp view WORD ipv6 X:X::X:X/M",
6911 "IPv6 prefix <network>/<length>\n")
6914 DEFUN (show_ipv6_mbgp
,
6921 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
6926 DEFUN (show_ipv6_mbgp_route
,
6927 show_ipv6_mbgp_route_cmd
,
6928 "show ipv6 mbgp X:X::X:X",
6932 "Network in the MBGP routing table to display\n")
6934 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0);
6938 DEFUN (show_ipv6_mbgp_prefix
,
6939 show_ipv6_mbgp_prefix_cmd
,
6940 "show ipv6 mbgp X:X::X:X/M",
6944 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6946 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1);
6952 bgp_show_regexp (struct vty
*vty
, int argc
, const char **argv
, afi_t afi
,
6953 safi_t safi
, enum bgp_show_type type
)
6963 b
= buffer_new (1024);
6964 for (i
= 0; i
< argc
; i
++)
6967 buffer_putc (b
, ' ');
6970 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
6975 buffer_putstr (b
, argv
[i
]);
6977 buffer_putc (b
, '\0');
6979 regstr
= buffer_getstr (b
);
6982 regex
= bgp_regcomp (regstr
);
6983 XFREE(MTYPE_TMP
, regstr
);
6986 vty_out (vty
, "Can't compile regexp %s%s", argv
[0],
6991 rc
= bgp_show (vty
, NULL
, afi
, safi
, type
, regex
);
6992 bgp_regex_free (regex
);
6996 DEFUN (show_ip_bgp_regexp
,
6997 show_ip_bgp_regexp_cmd
,
6998 "show ip bgp regexp .LINE",
7002 "Display routes matching the AS path regular expression\n"
7003 "A regular-expression to match the BGP AS paths\n")
7005 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
7006 bgp_show_type_regexp
);
7009 DEFUN (show_ip_bgp_flap_regexp
,
7010 show_ip_bgp_flap_regexp_cmd
,
7011 "show ip bgp flap-statistics regexp .LINE",
7015 "Display flap statistics of routes\n"
7016 "Display routes matching the AS path regular expression\n"
7017 "A regular-expression to match the BGP AS paths\n")
7019 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
7020 bgp_show_type_flap_regexp
);
7023 DEFUN (show_ip_bgp_ipv4_regexp
,
7024 show_ip_bgp_ipv4_regexp_cmd
,
7025 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
7030 "Address Family modifier\n"
7031 "Address Family modifier\n"
7032 "Display routes matching the AS path regular expression\n"
7033 "A regular-expression to match the BGP AS paths\n")
7035 if (strncmp (argv
[0], "m", 1) == 0)
7036 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_MULTICAST
,
7037 bgp_show_type_regexp
);
7039 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
7040 bgp_show_type_regexp
);
7044 DEFUN (show_bgp_regexp
,
7045 show_bgp_regexp_cmd
,
7046 "show bgp regexp .LINE",
7049 "Display routes matching the AS path regular expression\n"
7050 "A regular-expression to match the BGP AS paths\n")
7052 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
7053 bgp_show_type_regexp
);
7056 ALIAS (show_bgp_regexp
,
7057 show_bgp_ipv6_regexp_cmd
,
7058 "show bgp ipv6 regexp .LINE",
7062 "Display routes matching the AS path regular expression\n"
7063 "A regular-expression to match the BGP AS paths\n")
7066 DEFUN (show_ipv6_bgp_regexp
,
7067 show_ipv6_bgp_regexp_cmd
,
7068 "show ipv6 bgp regexp .LINE",
7072 "Display routes matching the AS path regular expression\n"
7073 "A regular-expression to match the BGP AS paths\n")
7075 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
7076 bgp_show_type_regexp
);
7080 DEFUN (show_ipv6_mbgp_regexp
,
7081 show_ipv6_mbgp_regexp_cmd
,
7082 "show ipv6 mbgp regexp .LINE",
7086 "Display routes matching the AS path regular expression\n"
7087 "A regular-expression to match the MBGP AS paths\n")
7089 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
,
7090 bgp_show_type_regexp
);
7092 #endif /* HAVE_IPV6 */
7095 bgp_show_prefix_list (struct vty
*vty
, const char *prefix_list_str
, afi_t afi
,
7096 safi_t safi
, enum bgp_show_type type
)
7098 struct prefix_list
*plist
;
7100 plist
= prefix_list_lookup (afi
, prefix_list_str
);
7103 vty_out (vty
, "%% %s is not a valid prefix-list name%s",
7104 prefix_list_str
, VTY_NEWLINE
);
7108 return bgp_show (vty
, NULL
, afi
, safi
, type
, plist
);
7111 DEFUN (show_ip_bgp_prefix_list
,
7112 show_ip_bgp_prefix_list_cmd
,
7113 "show ip bgp prefix-list WORD",
7117 "Display routes conforming to the prefix-list\n"
7118 "IP prefix-list name\n")
7120 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7121 bgp_show_type_prefix_list
);
7124 DEFUN (show_ip_bgp_flap_prefix_list
,
7125 show_ip_bgp_flap_prefix_list_cmd
,
7126 "show ip bgp flap-statistics prefix-list WORD",
7130 "Display flap statistics of routes\n"
7131 "Display routes conforming to the prefix-list\n"
7132 "IP prefix-list name\n")
7134 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7135 bgp_show_type_flap_prefix_list
);
7138 DEFUN (show_ip_bgp_ipv4_prefix_list
,
7139 show_ip_bgp_ipv4_prefix_list_cmd
,
7140 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
7145 "Address Family modifier\n"
7146 "Address Family modifier\n"
7147 "Display routes conforming to the prefix-list\n"
7148 "IP prefix-list name\n")
7150 if (strncmp (argv
[0], "m", 1) == 0)
7151 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
7152 bgp_show_type_prefix_list
);
7154 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
7155 bgp_show_type_prefix_list
);
7159 DEFUN (show_bgp_prefix_list
,
7160 show_bgp_prefix_list_cmd
,
7161 "show bgp prefix-list WORD",
7164 "Display routes conforming to the prefix-list\n"
7165 "IPv6 prefix-list name\n")
7167 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7168 bgp_show_type_prefix_list
);
7171 ALIAS (show_bgp_prefix_list
,
7172 show_bgp_ipv6_prefix_list_cmd
,
7173 "show bgp ipv6 prefix-list WORD",
7177 "Display routes conforming to the prefix-list\n"
7178 "IPv6 prefix-list name\n")
7181 DEFUN (show_ipv6_bgp_prefix_list
,
7182 show_ipv6_bgp_prefix_list_cmd
,
7183 "show ipv6 bgp prefix-list WORD",
7187 "Display routes matching the prefix-list\n"
7188 "IPv6 prefix-list name\n")
7190 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7191 bgp_show_type_prefix_list
);
7195 DEFUN (show_ipv6_mbgp_prefix_list
,
7196 show_ipv6_mbgp_prefix_list_cmd
,
7197 "show ipv6 mbgp prefix-list WORD",
7201 "Display routes matching the prefix-list\n"
7202 "IPv6 prefix-list name\n")
7204 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
7205 bgp_show_type_prefix_list
);
7207 #endif /* HAVE_IPV6 */
7210 bgp_show_filter_list (struct vty
*vty
, const char *filter
, afi_t afi
,
7211 safi_t safi
, enum bgp_show_type type
)
7213 struct as_list
*as_list
;
7215 as_list
= as_list_lookup (filter
);
7216 if (as_list
== NULL
)
7218 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
7222 return bgp_show (vty
, NULL
, afi
, safi
, type
, as_list
);
7225 DEFUN (show_ip_bgp_filter_list
,
7226 show_ip_bgp_filter_list_cmd
,
7227 "show ip bgp filter-list WORD",
7231 "Display routes conforming to the filter-list\n"
7232 "Regular expression access list name\n")
7234 return bgp_show_filter_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7235 bgp_show_type_filter_list
);
7238 DEFUN (show_ip_bgp_flap_filter_list
,
7239 show_ip_bgp_flap_filter_list_cmd
,
7240 "show ip bgp flap-statistics filter-list WORD",
7244 "Display flap statistics of routes\n"
7245 "Display routes conforming to the filter-list\n"
7246 "Regular expression access list name\n")
7248 return bgp_show_filter_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7249 bgp_show_type_flap_filter_list
);
7252 DEFUN (show_ip_bgp_ipv4_filter_list
,
7253 show_ip_bgp_ipv4_filter_list_cmd
,
7254 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
7259 "Address Family modifier\n"
7260 "Address Family modifier\n"
7261 "Display routes conforming to the filter-list\n"
7262 "Regular expression access list name\n")
7264 if (strncmp (argv
[0], "m", 1) == 0)
7265 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
7266 bgp_show_type_filter_list
);
7268 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
7269 bgp_show_type_filter_list
);
7273 DEFUN (show_bgp_filter_list
,
7274 show_bgp_filter_list_cmd
,
7275 "show bgp filter-list WORD",
7278 "Display routes conforming to the filter-list\n"
7279 "Regular expression access list name\n")
7281 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7282 bgp_show_type_filter_list
);
7285 ALIAS (show_bgp_filter_list
,
7286 show_bgp_ipv6_filter_list_cmd
,
7287 "show bgp ipv6 filter-list WORD",
7291 "Display routes conforming to the filter-list\n"
7292 "Regular expression access list name\n")
7295 DEFUN (show_ipv6_bgp_filter_list
,
7296 show_ipv6_bgp_filter_list_cmd
,
7297 "show ipv6 bgp filter-list WORD",
7301 "Display routes conforming to the filter-list\n"
7302 "Regular expression access list name\n")
7304 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7305 bgp_show_type_filter_list
);
7309 DEFUN (show_ipv6_mbgp_filter_list
,
7310 show_ipv6_mbgp_filter_list_cmd
,
7311 "show ipv6 mbgp filter-list WORD",
7315 "Display routes conforming to the filter-list\n"
7316 "Regular expression access list name\n")
7318 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
7319 bgp_show_type_filter_list
);
7321 #endif /* HAVE_IPV6 */
7324 bgp_show_route_map (struct vty
*vty
, const char *rmap_str
, afi_t afi
,
7325 safi_t safi
, enum bgp_show_type type
)
7327 struct route_map
*rmap
;
7329 rmap
= route_map_lookup_by_name (rmap_str
);
7332 vty_out (vty
, "%% %s is not a valid route-map name%s",
7333 rmap_str
, VTY_NEWLINE
);
7337 return bgp_show (vty
, NULL
, afi
, safi
, type
, rmap
);
7340 DEFUN (show_ip_bgp_route_map
,
7341 show_ip_bgp_route_map_cmd
,
7342 "show ip bgp route-map WORD",
7346 "Display routes matching the route-map\n"
7347 "A route-map to match on\n")
7349 return bgp_show_route_map (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7350 bgp_show_type_route_map
);
7353 DEFUN (show_ip_bgp_flap_route_map
,
7354 show_ip_bgp_flap_route_map_cmd
,
7355 "show ip bgp flap-statistics route-map WORD",
7359 "Display flap statistics of routes\n"
7360 "Display routes matching the route-map\n"
7361 "A route-map to match on\n")
7363 return bgp_show_route_map (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7364 bgp_show_type_flap_route_map
);
7367 DEFUN (show_ip_bgp_ipv4_route_map
,
7368 show_ip_bgp_ipv4_route_map_cmd
,
7369 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
7374 "Address Family modifier\n"
7375 "Address Family modifier\n"
7376 "Display routes matching the route-map\n"
7377 "A route-map to match on\n")
7379 if (strncmp (argv
[0], "m", 1) == 0)
7380 return bgp_show_route_map (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
7381 bgp_show_type_route_map
);
7383 return bgp_show_route_map (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
7384 bgp_show_type_route_map
);
7387 DEFUN (show_bgp_route_map
,
7388 show_bgp_route_map_cmd
,
7389 "show bgp route-map WORD",
7392 "Display routes matching the route-map\n"
7393 "A route-map to match on\n")
7395 return bgp_show_route_map (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7396 bgp_show_type_route_map
);
7399 ALIAS (show_bgp_route_map
,
7400 show_bgp_ipv6_route_map_cmd
,
7401 "show bgp ipv6 route-map WORD",
7405 "Display routes matching the route-map\n"
7406 "A route-map to match on\n")
7408 DEFUN (show_ip_bgp_cidr_only
,
7409 show_ip_bgp_cidr_only_cmd
,
7410 "show ip bgp cidr-only",
7414 "Display only routes with non-natural netmasks\n")
7416 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7417 bgp_show_type_cidr_only
, NULL
);
7420 DEFUN (show_ip_bgp_flap_cidr_only
,
7421 show_ip_bgp_flap_cidr_only_cmd
,
7422 "show ip bgp flap-statistics cidr-only",
7426 "Display flap statistics of routes\n"
7427 "Display only routes with non-natural netmasks\n")
7429 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7430 bgp_show_type_flap_cidr_only
, NULL
);
7433 DEFUN (show_ip_bgp_ipv4_cidr_only
,
7434 show_ip_bgp_ipv4_cidr_only_cmd
,
7435 "show ip bgp ipv4 (unicast|multicast) cidr-only",
7440 "Address Family modifier\n"
7441 "Address Family modifier\n"
7442 "Display only routes with non-natural netmasks\n")
7444 if (strncmp (argv
[0], "m", 1) == 0)
7445 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
7446 bgp_show_type_cidr_only
, NULL
);
7448 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7449 bgp_show_type_cidr_only
, NULL
);
7452 DEFUN (show_ip_bgp_community_all
,
7453 show_ip_bgp_community_all_cmd
,
7454 "show ip bgp community",
7458 "Display routes matching the communities\n")
7460 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7461 bgp_show_type_community_all
, NULL
);
7464 DEFUN (show_ip_bgp_ipv4_community_all
,
7465 show_ip_bgp_ipv4_community_all_cmd
,
7466 "show ip bgp ipv4 (unicast|multicast) community",
7471 "Address Family modifier\n"
7472 "Address Family modifier\n"
7473 "Display routes matching the communities\n")
7475 if (strncmp (argv
[0], "m", 1) == 0)
7476 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
7477 bgp_show_type_community_all
, NULL
);
7479 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7480 bgp_show_type_community_all
, NULL
);
7484 DEFUN (show_bgp_community_all
,
7485 show_bgp_community_all_cmd
,
7486 "show bgp community",
7489 "Display routes matching the communities\n")
7491 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
7492 bgp_show_type_community_all
, NULL
);
7495 ALIAS (show_bgp_community_all
,
7496 show_bgp_ipv6_community_all_cmd
,
7497 "show bgp ipv6 community",
7501 "Display routes matching the communities\n")
7504 DEFUN (show_ipv6_bgp_community_all
,
7505 show_ipv6_bgp_community_all_cmd
,
7506 "show ipv6 bgp community",
7510 "Display routes matching the communities\n")
7512 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
7513 bgp_show_type_community_all
, NULL
);
7517 DEFUN (show_ipv6_mbgp_community_all
,
7518 show_ipv6_mbgp_community_all_cmd
,
7519 "show ipv6 mbgp community",
7523 "Display routes matching the communities\n")
7525 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
7526 bgp_show_type_community_all
, NULL
);
7528 #endif /* HAVE_IPV6 */
7531 bgp_show_community (struct vty
*vty
, const char *view_name
, int argc
,
7532 const char **argv
, int exact
, afi_t afi
, safi_t safi
)
7534 struct community
*com
;
7541 /* BGP structure lookup */
7544 bgp
= bgp_lookup_by_name (view_name
);
7547 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
7553 bgp
= bgp_get_default ();
7556 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
7561 b
= buffer_new (1024);
7562 for (i
= 0; i
< argc
; i
++)
7565 buffer_putc (b
, ' ');
7568 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
7573 buffer_putstr (b
, argv
[i
]);
7575 buffer_putc (b
, '\0');
7577 str
= buffer_getstr (b
);
7580 com
= community_str2com (str
);
7581 XFREE (MTYPE_TMP
, str
);
7584 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
7588 return bgp_show (vty
, bgp
, afi
, safi
,
7589 (exact
? bgp_show_type_community_exact
:
7590 bgp_show_type_community
), com
);
7593 DEFUN (show_ip_bgp_community
,
7594 show_ip_bgp_community_cmd
,
7595 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
7599 "Display routes matching the communities\n"
7600 "community number\n"
7601 "Do not send outside local AS (well-known community)\n"
7602 "Do not advertise to any peer (well-known community)\n"
7603 "Do not export to next AS (well-known community)\n")
7605 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
7608 ALIAS (show_ip_bgp_community
,
7609 show_ip_bgp_community2_cmd
,
7610 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7614 "Display routes matching the communities\n"
7615 "community number\n"
7616 "Do not send outside local AS (well-known community)\n"
7617 "Do not advertise to any peer (well-known community)\n"
7618 "Do not export to next AS (well-known community)\n"
7619 "community number\n"
7620 "Do not send outside local AS (well-known community)\n"
7621 "Do not advertise to any peer (well-known community)\n"
7622 "Do not export to next AS (well-known community)\n")
7624 ALIAS (show_ip_bgp_community
,
7625 show_ip_bgp_community3_cmd
,
7626 "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)",
7630 "Display routes matching the communities\n"
7631 "community number\n"
7632 "Do not send outside local AS (well-known community)\n"
7633 "Do not advertise to any peer (well-known community)\n"
7634 "Do not export to next AS (well-known community)\n"
7635 "community number\n"
7636 "Do not send outside local AS (well-known community)\n"
7637 "Do not advertise to any peer (well-known community)\n"
7638 "Do not export to next AS (well-known community)\n"
7639 "community number\n"
7640 "Do not send outside local AS (well-known community)\n"
7641 "Do not advertise to any peer (well-known community)\n"
7642 "Do not export to next AS (well-known community)\n")
7644 ALIAS (show_ip_bgp_community
,
7645 show_ip_bgp_community4_cmd
,
7646 "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)",
7650 "Display routes matching the communities\n"
7651 "community number\n"
7652 "Do not send outside local AS (well-known community)\n"
7653 "Do not advertise to any peer (well-known community)\n"
7654 "Do not export to next AS (well-known community)\n"
7655 "community number\n"
7656 "Do not send outside local AS (well-known community)\n"
7657 "Do not advertise to any peer (well-known community)\n"
7658 "Do not export to next AS (well-known community)\n"
7659 "community number\n"
7660 "Do not send outside local AS (well-known community)\n"
7661 "Do not advertise to any peer (well-known community)\n"
7662 "Do not export to next AS (well-known community)\n"
7663 "community number\n"
7664 "Do not send outside local AS (well-known community)\n"
7665 "Do not advertise to any peer (well-known community)\n"
7666 "Do not export to next AS (well-known community)\n")
7668 DEFUN (show_ip_bgp_ipv4_community
,
7669 show_ip_bgp_ipv4_community_cmd
,
7670 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
7675 "Address Family modifier\n"
7676 "Address Family modifier\n"
7677 "Display routes matching the communities\n"
7678 "community number\n"
7679 "Do not send outside local AS (well-known community)\n"
7680 "Do not advertise to any peer (well-known community)\n"
7681 "Do not export to next AS (well-known community)\n")
7683 if (strncmp (argv
[0], "m", 1) == 0)
7684 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_MULTICAST
);
7686 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
7689 ALIAS (show_ip_bgp_ipv4_community
,
7690 show_ip_bgp_ipv4_community2_cmd
,
7691 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7696 "Address Family modifier\n"
7697 "Address Family modifier\n"
7698 "Display routes matching the communities\n"
7699 "community number\n"
7700 "Do not send outside local AS (well-known community)\n"
7701 "Do not advertise to any peer (well-known community)\n"
7702 "Do not export to next AS (well-known community)\n"
7703 "community number\n"
7704 "Do not send outside local AS (well-known community)\n"
7705 "Do not advertise to any peer (well-known community)\n"
7706 "Do not export to next AS (well-known community)\n")
7708 ALIAS (show_ip_bgp_ipv4_community
,
7709 show_ip_bgp_ipv4_community3_cmd
,
7710 "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)",
7715 "Address Family modifier\n"
7716 "Address Family modifier\n"
7717 "Display routes matching the communities\n"
7718 "community number\n"
7719 "Do not send outside local AS (well-known community)\n"
7720 "Do not advertise to any peer (well-known community)\n"
7721 "Do not export to next AS (well-known community)\n"
7722 "community number\n"
7723 "Do not send outside local AS (well-known community)\n"
7724 "Do not advertise to any peer (well-known community)\n"
7725 "Do not export to next AS (well-known community)\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")
7731 ALIAS (show_ip_bgp_ipv4_community
,
7732 show_ip_bgp_ipv4_community4_cmd
,
7733 "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)",
7738 "Address Family modifier\n"
7739 "Address Family modifier\n"
7740 "Display routes matching the communities\n"
7741 "community number\n"
7742 "Do not send outside local AS (well-known community)\n"
7743 "Do not advertise to any peer (well-known community)\n"
7744 "Do not export to next AS (well-known community)\n"
7745 "community number\n"
7746 "Do not send outside local AS (well-known community)\n"
7747 "Do not advertise to any peer (well-known community)\n"
7748 "Do not export to next AS (well-known community)\n"
7749 "community number\n"
7750 "Do not send outside local AS (well-known community)\n"
7751 "Do not advertise to any peer (well-known community)\n"
7752 "Do not export to next AS (well-known community)\n"
7753 "community number\n"
7754 "Do not send outside local AS (well-known community)\n"
7755 "Do not advertise to any peer (well-known community)\n"
7756 "Do not export to next AS (well-known community)\n")
7758 DEFUN (show_bgp_view_afi_safi_community_all
,
7759 show_bgp_view_afi_safi_community_all_cmd
,
7761 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community",
7763 "show bgp view WORD ipv4 (unicast|multicast) community",
7773 "Address Family modifier\n"
7774 "Address Family modifier\n"
7775 "Display routes containing communities\n")
7781 /* BGP structure lookup. */
7782 bgp
= bgp_lookup_by_name (argv
[0]);
7785 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
7790 afi
= (strncmp (argv
[1], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
7791 safi
= (strncmp (argv
[2], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
7794 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
7796 return bgp_show (vty
, bgp
, afi
, safi
, bgp_show_type_community_all
, NULL
);
7799 DEFUN (show_bgp_view_afi_safi_community
,
7800 show_bgp_view_afi_safi_community_cmd
,
7802 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
7804 "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
7814 "Address family modifier\n"
7815 "Address family modifier\n"
7816 "Display routes matching the communities\n"
7817 "community number\n"
7818 "Do not send outside local AS (well-known community)\n"
7819 "Do not advertise to any peer (well-known community)\n"
7820 "Do not export to next AS (well-known community)\n")
7826 afi
= (strncmp (argv
[1], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
7827 safi
= (strncmp (argv
[2], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
7828 return bgp_show_community (vty
, argv
[0], argc
-3, &argv
[3], 0, afi
, safi
);
7831 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
7832 return bgp_show_community (vty
, argv
[0], argc
-2, &argv
[2], 0, afi
, safi
);
7836 ALIAS (show_bgp_view_afi_safi_community
,
7837 show_bgp_view_afi_safi_community2_cmd
,
7839 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7841 "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7851 "Address family modifier\n"
7852 "Address family modifier\n"
7853 "Display routes matching the communities\n"
7854 "community number\n"
7855 "Do not send outside local AS (well-known community)\n"
7856 "Do not advertise to any peer (well-known community)\n"
7857 "Do not export to next AS (well-known community)\n"
7858 "community number\n"
7859 "Do not send outside local AS (well-known community)\n"
7860 "Do not advertise to any peer (well-known community)\n"
7861 "Do not export to next AS (well-known community)\n")
7863 ALIAS (show_bgp_view_afi_safi_community
,
7864 show_bgp_view_afi_safi_community3_cmd
,
7866 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7868 "show bgp view WORD 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)",
7878 "Address family modifier\n"
7879 "Address family modifier\n"
7880 "Display routes matching the communities\n"
7881 "community number\n"
7882 "Do not send outside local AS (well-known community)\n"
7883 "Do not advertise to any peer (well-known community)\n"
7884 "Do not export to next AS (well-known community)\n"
7885 "community number\n"
7886 "Do not send outside local AS (well-known community)\n"
7887 "Do not advertise to any peer (well-known community)\n"
7888 "Do not export to next AS (well-known community)\n"
7889 "community number\n"
7890 "Do not send outside local AS (well-known community)\n"
7891 "Do not advertise to any peer (well-known community)\n"
7892 "Do not export to next AS (well-known community)\n")
7894 ALIAS (show_bgp_view_afi_safi_community
,
7895 show_bgp_view_afi_safi_community4_cmd
,
7897 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7899 "show bgp view WORD 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)",
7909 "Address family modifier\n"
7910 "Address family modifier\n"
7911 "Display routes matching the communities\n"
7912 "community number\n"
7913 "Do not send outside local AS (well-known community)\n"
7914 "Do not advertise to any peer (well-known community)\n"
7915 "Do not export to next AS (well-known community)\n"
7916 "community number\n"
7917 "Do not send outside local AS (well-known community)\n"
7918 "Do not advertise to any peer (well-known community)\n"
7919 "Do not export to next AS (well-known community)\n"
7920 "community number\n"
7921 "Do not send outside local AS (well-known community)\n"
7922 "Do not advertise to any peer (well-known community)\n"
7923 "Do not export to next AS (well-known community)\n"
7924 "community number\n"
7925 "Do not send outside local AS (well-known community)\n"
7926 "Do not advertise to any peer (well-known community)\n"
7927 "Do not export to next AS (well-known community)\n")
7929 DEFUN (show_ip_bgp_community_exact
,
7930 show_ip_bgp_community_exact_cmd
,
7931 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7935 "Display routes matching the communities\n"
7936 "community number\n"
7937 "Do not send outside local AS (well-known community)\n"
7938 "Do not advertise to any peer (well-known community)\n"
7939 "Do not export to next AS (well-known community)\n"
7940 "Exact match of the communities")
7942 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
7945 ALIAS (show_ip_bgp_community_exact
,
7946 show_ip_bgp_community2_exact_cmd
,
7947 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7951 "Display routes matching the communities\n"
7952 "community number\n"
7953 "Do not send outside local AS (well-known community)\n"
7954 "Do not advertise to any peer (well-known community)\n"
7955 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
7962 ALIAS (show_ip_bgp_community_exact
,
7963 show_ip_bgp_community3_exact_cmd
,
7964 "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",
7968 "Display routes matching the communities\n"
7969 "community number\n"
7970 "Do not send outside local AS (well-known community)\n"
7971 "Do not advertise to any peer (well-known community)\n"
7972 "Do not export to next AS (well-known community)\n"
7973 "community number\n"
7974 "Do not send outside local AS (well-known community)\n"
7975 "Do not advertise to any peer (well-known community)\n"
7976 "Do not export to next AS (well-known community)\n"
7977 "community number\n"
7978 "Do not send outside local AS (well-known community)\n"
7979 "Do not advertise to any peer (well-known community)\n"
7980 "Do not export to next AS (well-known community)\n"
7981 "Exact match of the communities")
7983 ALIAS (show_ip_bgp_community_exact
,
7984 show_ip_bgp_community4_exact_cmd
,
7985 "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",
7989 "Display routes matching the communities\n"
7990 "community number\n"
7991 "Do not send outside local AS (well-known community)\n"
7992 "Do not advertise to any peer (well-known community)\n"
7993 "Do not export to next AS (well-known community)\n"
7994 "community number\n"
7995 "Do not send outside local AS (well-known community)\n"
7996 "Do not advertise to any peer (well-known community)\n"
7997 "Do not export to next AS (well-known community)\n"
7998 "community number\n"
7999 "Do not send outside local AS (well-known community)\n"
8000 "Do not advertise to any peer (well-known community)\n"
8001 "Do not export to next AS (well-known community)\n"
8002 "community number\n"
8003 "Do not send outside local AS (well-known community)\n"
8004 "Do not advertise to any peer (well-known community)\n"
8005 "Do not export to next AS (well-known community)\n"
8006 "Exact match of the communities")
8008 DEFUN (show_ip_bgp_ipv4_community_exact
,
8009 show_ip_bgp_ipv4_community_exact_cmd
,
8010 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8015 "Address Family modifier\n"
8016 "Address Family modifier\n"
8017 "Display routes matching the communities\n"
8018 "community number\n"
8019 "Do not send outside local AS (well-known community)\n"
8020 "Do not advertise to any peer (well-known community)\n"
8021 "Do not export to next AS (well-known community)\n"
8022 "Exact match of the communities")
8024 if (strncmp (argv
[0], "m", 1) == 0)
8025 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_MULTICAST
);
8027 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
8030 ALIAS (show_ip_bgp_ipv4_community_exact
,
8031 show_ip_bgp_ipv4_community2_exact_cmd
,
8032 "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",
8037 "Address Family modifier\n"
8038 "Address Family modifier\n"
8039 "Display routes matching the communities\n"
8040 "community number\n"
8041 "Do not send outside local AS (well-known community)\n"
8042 "Do not advertise to any peer (well-known community)\n"
8043 "Do not export to next AS (well-known community)\n"
8044 "community number\n"
8045 "Do not send outside local AS (well-known community)\n"
8046 "Do not advertise to any peer (well-known community)\n"
8047 "Do not export to next AS (well-known community)\n"
8048 "Exact match of the communities")
8050 ALIAS (show_ip_bgp_ipv4_community_exact
,
8051 show_ip_bgp_ipv4_community3_exact_cmd
,
8052 "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",
8057 "Address Family modifier\n"
8058 "Address Family modifier\n"
8059 "Display routes matching the communities\n"
8060 "community number\n"
8061 "Do not send outside local AS (well-known community)\n"
8062 "Do not advertise to any peer (well-known community)\n"
8063 "Do not export to next AS (well-known community)\n"
8064 "community number\n"
8065 "Do not send outside local AS (well-known community)\n"
8066 "Do not advertise to any peer (well-known community)\n"
8067 "Do not export to next AS (well-known community)\n"
8068 "community number\n"
8069 "Do not send outside local AS (well-known community)\n"
8070 "Do not advertise to any peer (well-known community)\n"
8071 "Do not export to next AS (well-known community)\n"
8072 "Exact match of the communities")
8074 ALIAS (show_ip_bgp_ipv4_community_exact
,
8075 show_ip_bgp_ipv4_community4_exact_cmd
,
8076 "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",
8081 "Address Family modifier\n"
8082 "Address Family modifier\n"
8083 "Display routes matching the communities\n"
8084 "community number\n"
8085 "Do not send outside local AS (well-known community)\n"
8086 "Do not advertise to any peer (well-known community)\n"
8087 "Do not export to next AS (well-known community)\n"
8088 "community number\n"
8089 "Do not send outside local AS (well-known community)\n"
8090 "Do not advertise to any peer (well-known community)\n"
8091 "Do not export to next AS (well-known community)\n"
8092 "community number\n"
8093 "Do not send outside local AS (well-known community)\n"
8094 "Do not advertise to any peer (well-known community)\n"
8095 "Do not export to next AS (well-known community)\n"
8096 "community number\n"
8097 "Do not send outside local AS (well-known community)\n"
8098 "Do not advertise to any peer (well-known community)\n"
8099 "Do not export to next AS (well-known community)\n"
8100 "Exact match of the communities")
8103 DEFUN (show_bgp_community
,
8104 show_bgp_community_cmd
,
8105 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
8108 "Display routes matching the communities\n"
8109 "community number\n"
8110 "Do not send outside local AS (well-known community)\n"
8111 "Do not advertise to any peer (well-known community)\n"
8112 "Do not export to next AS (well-known community)\n")
8114 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
8117 ALIAS (show_bgp_community
,
8118 show_bgp_ipv6_community_cmd
,
8119 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
8123 "Display routes matching the communities\n"
8124 "community number\n"
8125 "Do not send outside local AS (well-known community)\n"
8126 "Do not advertise to any peer (well-known community)\n"
8127 "Do not export to next AS (well-known community)\n")
8129 ALIAS (show_bgp_community
,
8130 show_bgp_community2_cmd
,
8131 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8134 "Display routes matching the communities\n"
8135 "community number\n"
8136 "Do not send outside local AS (well-known community)\n"
8137 "Do not advertise to any peer (well-known community)\n"
8138 "Do not export to next AS (well-known community)\n"
8139 "community number\n"
8140 "Do not send outside local AS (well-known community)\n"
8141 "Do not advertise to any peer (well-known community)\n"
8142 "Do not export to next AS (well-known community)\n")
8144 ALIAS (show_bgp_community
,
8145 show_bgp_ipv6_community2_cmd
,
8146 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8150 "Display routes matching the communities\n"
8151 "community number\n"
8152 "Do not send outside local AS (well-known community)\n"
8153 "Do not advertise to any peer (well-known community)\n"
8154 "Do not export to next AS (well-known community)\n"
8155 "community number\n"
8156 "Do not send outside local AS (well-known community)\n"
8157 "Do not advertise to any peer (well-known community)\n"
8158 "Do not export to next AS (well-known community)\n")
8160 ALIAS (show_bgp_community
,
8161 show_bgp_community3_cmd
,
8162 "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)",
8165 "Display routes matching the communities\n"
8166 "community number\n"
8167 "Do not send outside local AS (well-known community)\n"
8168 "Do not advertise to any peer (well-known community)\n"
8169 "Do not export to next AS (well-known community)\n"
8170 "community number\n"
8171 "Do not send outside local AS (well-known community)\n"
8172 "Do not advertise to any peer (well-known community)\n"
8173 "Do not export to next AS (well-known community)\n"
8174 "community number\n"
8175 "Do not send outside local AS (well-known community)\n"
8176 "Do not advertise to any peer (well-known community)\n"
8177 "Do not export to next AS (well-known community)\n")
8179 ALIAS (show_bgp_community
,
8180 show_bgp_ipv6_community3_cmd
,
8181 "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)",
8185 "Display routes matching the communities\n"
8186 "community number\n"
8187 "Do not send outside local AS (well-known community)\n"
8188 "Do not advertise to any peer (well-known community)\n"
8189 "Do not export to next AS (well-known community)\n"
8190 "community number\n"
8191 "Do not send outside local AS (well-known community)\n"
8192 "Do not advertise to any peer (well-known community)\n"
8193 "Do not export to next AS (well-known community)\n"
8194 "community number\n"
8195 "Do not send outside local AS (well-known community)\n"
8196 "Do not advertise to any peer (well-known community)\n"
8197 "Do not export to next AS (well-known community)\n")
8199 ALIAS (show_bgp_community
,
8200 show_bgp_community4_cmd
,
8201 "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)",
8204 "Display routes matching the communities\n"
8205 "community number\n"
8206 "Do not send outside local AS (well-known community)\n"
8207 "Do not advertise to any peer (well-known community)\n"
8208 "Do not export to next AS (well-known community)\n"
8209 "community number\n"
8210 "Do not send outside local AS (well-known community)\n"
8211 "Do not advertise to any peer (well-known community)\n"
8212 "Do not export to next AS (well-known community)\n"
8213 "community number\n"
8214 "Do not send outside local AS (well-known community)\n"
8215 "Do not advertise to any peer (well-known community)\n"
8216 "Do not export to next AS (well-known community)\n"
8217 "community number\n"
8218 "Do not send outside local AS (well-known community)\n"
8219 "Do not advertise to any peer (well-known community)\n"
8220 "Do not export to next AS (well-known community)\n")
8222 ALIAS (show_bgp_community
,
8223 show_bgp_ipv6_community4_cmd
,
8224 "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)",
8228 "Display routes matching the communities\n"
8229 "community number\n"
8230 "Do not send outside local AS (well-known community)\n"
8231 "Do not advertise to any peer (well-known community)\n"
8232 "Do not export to next AS (well-known community)\n"
8233 "community number\n"
8234 "Do not send outside local AS (well-known community)\n"
8235 "Do not advertise to any peer (well-known community)\n"
8236 "Do not export to next AS (well-known community)\n"
8237 "community number\n"
8238 "Do not send outside local AS (well-known community)\n"
8239 "Do not advertise to any peer (well-known community)\n"
8240 "Do not export to next AS (well-known community)\n"
8241 "community number\n"
8242 "Do not send outside local AS (well-known community)\n"
8243 "Do not advertise to any peer (well-known community)\n"
8244 "Do not export to next AS (well-known community)\n")
8247 DEFUN (show_ipv6_bgp_community
,
8248 show_ipv6_bgp_community_cmd
,
8249 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
8253 "Display routes matching the communities\n"
8254 "community number\n"
8255 "Do not send outside local AS (well-known community)\n"
8256 "Do not advertise to any peer (well-known community)\n"
8257 "Do not export to next AS (well-known community)\n")
8259 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
8263 ALIAS (show_ipv6_bgp_community
,
8264 show_ipv6_bgp_community2_cmd
,
8265 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8269 "Display routes matching the communities\n"
8270 "community number\n"
8271 "Do not send outside local AS (well-known community)\n"
8272 "Do not advertise to any peer (well-known community)\n"
8273 "Do not export to next AS (well-known community)\n"
8274 "community number\n"
8275 "Do not send outside local AS (well-known community)\n"
8276 "Do not advertise to any peer (well-known community)\n"
8277 "Do not export to next AS (well-known community)\n")
8280 ALIAS (show_ipv6_bgp_community
,
8281 show_ipv6_bgp_community3_cmd
,
8282 "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)",
8286 "Display routes matching the communities\n"
8287 "community number\n"
8288 "Do not send outside local AS (well-known community)\n"
8289 "Do not advertise to any peer (well-known community)\n"
8290 "Do not export to next AS (well-known community)\n"
8291 "community number\n"
8292 "Do not send outside local AS (well-known community)\n"
8293 "Do not advertise to any peer (well-known community)\n"
8294 "Do not export to next AS (well-known community)\n"
8295 "community number\n"
8296 "Do not send outside local AS (well-known community)\n"
8297 "Do not advertise to any peer (well-known community)\n"
8298 "Do not export to next AS (well-known community)\n")
8301 ALIAS (show_ipv6_bgp_community
,
8302 show_ipv6_bgp_community4_cmd
,
8303 "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)",
8307 "Display routes matching the communities\n"
8308 "community number\n"
8309 "Do not send outside local AS (well-known community)\n"
8310 "Do not advertise to any peer (well-known community)\n"
8311 "Do not export to next AS (well-known community)\n"
8312 "community number\n"
8313 "Do not send outside local AS (well-known community)\n"
8314 "Do not advertise to any peer (well-known community)\n"
8315 "Do not export to next AS (well-known community)\n"
8316 "community number\n"
8317 "Do not send outside local AS (well-known community)\n"
8318 "Do not advertise to any peer (well-known community)\n"
8319 "Do not export to next AS (well-known community)\n"
8320 "community number\n"
8321 "Do not send outside local AS (well-known community)\n"
8322 "Do not advertise to any peer (well-known community)\n"
8323 "Do not export to next AS (well-known community)\n")
8325 DEFUN (show_bgp_community_exact
,
8326 show_bgp_community_exact_cmd
,
8327 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8330 "Display routes matching the communities\n"
8331 "community number\n"
8332 "Do not send outside local AS (well-known community)\n"
8333 "Do not advertise to any peer (well-known community)\n"
8334 "Do not export to next AS (well-known community)\n"
8335 "Exact match of the communities")
8337 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
8340 ALIAS (show_bgp_community_exact
,
8341 show_bgp_ipv6_community_exact_cmd
,
8342 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8346 "Display routes matching the communities\n"
8347 "community number\n"
8348 "Do not send outside local AS (well-known community)\n"
8349 "Do not advertise to any peer (well-known community)\n"
8350 "Do not export to next AS (well-known community)\n"
8351 "Exact match of the communities")
8353 ALIAS (show_bgp_community_exact
,
8354 show_bgp_community2_exact_cmd
,
8355 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8358 "Display routes matching the communities\n"
8359 "community number\n"
8360 "Do not send outside local AS (well-known community)\n"
8361 "Do not advertise to any peer (well-known community)\n"
8362 "Do not export to next AS (well-known community)\n"
8363 "community number\n"
8364 "Do not send outside local AS (well-known community)\n"
8365 "Do not advertise to any peer (well-known community)\n"
8366 "Do not export to next AS (well-known community)\n"
8367 "Exact match of the communities")
8369 ALIAS (show_bgp_community_exact
,
8370 show_bgp_ipv6_community2_exact_cmd
,
8371 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8375 "Display routes matching the communities\n"
8376 "community number\n"
8377 "Do not send outside local AS (well-known community)\n"
8378 "Do not advertise to any peer (well-known community)\n"
8379 "Do not export to next AS (well-known community)\n"
8380 "community number\n"
8381 "Do not send outside local AS (well-known community)\n"
8382 "Do not advertise to any peer (well-known community)\n"
8383 "Do not export to next AS (well-known community)\n"
8384 "Exact match of the communities")
8386 ALIAS (show_bgp_community_exact
,
8387 show_bgp_community3_exact_cmd
,
8388 "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",
8391 "Display routes matching the communities\n"
8392 "community number\n"
8393 "Do not send outside local AS (well-known community)\n"
8394 "Do not advertise to any peer (well-known community)\n"
8395 "Do not export to next AS (well-known community)\n"
8396 "community number\n"
8397 "Do not send outside local AS (well-known community)\n"
8398 "Do not advertise to any peer (well-known community)\n"
8399 "Do not export to next AS (well-known community)\n"
8400 "community number\n"
8401 "Do not send outside local AS (well-known community)\n"
8402 "Do not advertise to any peer (well-known community)\n"
8403 "Do not export to next AS (well-known community)\n"
8404 "Exact match of the communities")
8406 ALIAS (show_bgp_community_exact
,
8407 show_bgp_ipv6_community3_exact_cmd
,
8408 "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",
8412 "Display routes matching the communities\n"
8413 "community number\n"
8414 "Do not send outside local AS (well-known community)\n"
8415 "Do not advertise to any peer (well-known community)\n"
8416 "Do not export to next AS (well-known community)\n"
8417 "community number\n"
8418 "Do not send outside local AS (well-known community)\n"
8419 "Do not advertise to any peer (well-known community)\n"
8420 "Do not export to next AS (well-known community)\n"
8421 "community number\n"
8422 "Do not send outside local AS (well-known community)\n"
8423 "Do not advertise to any peer (well-known community)\n"
8424 "Do not export to next AS (well-known community)\n"
8425 "Exact match of the communities")
8427 ALIAS (show_bgp_community_exact
,
8428 show_bgp_community4_exact_cmd
,
8429 "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",
8432 "Display routes matching the communities\n"
8433 "community number\n"
8434 "Do not send outside local AS (well-known community)\n"
8435 "Do not advertise to any peer (well-known community)\n"
8436 "Do not export to next AS (well-known community)\n"
8437 "community number\n"
8438 "Do not send outside local AS (well-known community)\n"
8439 "Do not advertise to any peer (well-known community)\n"
8440 "Do not export to next AS (well-known community)\n"
8441 "community number\n"
8442 "Do not send outside local AS (well-known community)\n"
8443 "Do not advertise to any peer (well-known community)\n"
8444 "Do not export to next AS (well-known community)\n"
8445 "community number\n"
8446 "Do not send outside local AS (well-known community)\n"
8447 "Do not advertise to any peer (well-known community)\n"
8448 "Do not export to next AS (well-known community)\n"
8449 "Exact match of the communities")
8451 ALIAS (show_bgp_community_exact
,
8452 show_bgp_ipv6_community4_exact_cmd
,
8453 "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",
8457 "Display routes matching the communities\n"
8458 "community number\n"
8459 "Do not send outside local AS (well-known community)\n"
8460 "Do not advertise to any peer (well-known community)\n"
8461 "Do not export to next AS (well-known community)\n"
8462 "community number\n"
8463 "Do not send outside local AS (well-known community)\n"
8464 "Do not advertise to any peer (well-known community)\n"
8465 "Do not export to next AS (well-known community)\n"
8466 "community number\n"
8467 "Do not send outside local AS (well-known community)\n"
8468 "Do not advertise to any peer (well-known community)\n"
8469 "Do not export to next AS (well-known community)\n"
8470 "community number\n"
8471 "Do not send outside local AS (well-known community)\n"
8472 "Do not advertise to any peer (well-known community)\n"
8473 "Do not export to next AS (well-known community)\n"
8474 "Exact match of the communities")
8477 DEFUN (show_ipv6_bgp_community_exact
,
8478 show_ipv6_bgp_community_exact_cmd
,
8479 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8483 "Display routes matching the communities\n"
8484 "community number\n"
8485 "Do not send outside local AS (well-known community)\n"
8486 "Do not advertise to any peer (well-known community)\n"
8487 "Do not export to next AS (well-known community)\n"
8488 "Exact match of the communities")
8490 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
8494 ALIAS (show_ipv6_bgp_community_exact
,
8495 show_ipv6_bgp_community2_exact_cmd
,
8496 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8500 "Display routes matching the communities\n"
8501 "community number\n"
8502 "Do not send outside local AS (well-known community)\n"
8503 "Do not advertise to any peer (well-known community)\n"
8504 "Do not export to next AS (well-known community)\n"
8505 "community number\n"
8506 "Do not send outside local AS (well-known community)\n"
8507 "Do not advertise to any peer (well-known community)\n"
8508 "Do not export to next AS (well-known community)\n"
8509 "Exact match of the communities")
8512 ALIAS (show_ipv6_bgp_community_exact
,
8513 show_ipv6_bgp_community3_exact_cmd
,
8514 "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",
8518 "Display routes matching the communities\n"
8519 "community number\n"
8520 "Do not send outside local AS (well-known community)\n"
8521 "Do not advertise to any peer (well-known community)\n"
8522 "Do not export to next AS (well-known community)\n"
8523 "community number\n"
8524 "Do not send outside local AS (well-known community)\n"
8525 "Do not advertise to any peer (well-known community)\n"
8526 "Do not export to next AS (well-known community)\n"
8527 "community number\n"
8528 "Do not send outside local AS (well-known community)\n"
8529 "Do not advertise to any peer (well-known community)\n"
8530 "Do not export to next AS (well-known community)\n"
8531 "Exact match of the communities")
8534 ALIAS (show_ipv6_bgp_community_exact
,
8535 show_ipv6_bgp_community4_exact_cmd
,
8536 "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",
8540 "Display routes matching the communities\n"
8541 "community number\n"
8542 "Do not send outside local AS (well-known community)\n"
8543 "Do not advertise to any peer (well-known community)\n"
8544 "Do not export to next AS (well-known community)\n"
8545 "community number\n"
8546 "Do not send outside local AS (well-known community)\n"
8547 "Do not advertise to any peer (well-known community)\n"
8548 "Do not export to next AS (well-known community)\n"
8549 "community number\n"
8550 "Do not send outside local AS (well-known community)\n"
8551 "Do not advertise to any peer (well-known community)\n"
8552 "Do not export to next AS (well-known community)\n"
8553 "community number\n"
8554 "Do not send outside local AS (well-known community)\n"
8555 "Do not advertise to any peer (well-known community)\n"
8556 "Do not export to next AS (well-known community)\n"
8557 "Exact match of the communities")
8560 DEFUN (show_ipv6_mbgp_community
,
8561 show_ipv6_mbgp_community_cmd
,
8562 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
8566 "Display routes matching the communities\n"
8567 "community number\n"
8568 "Do not send outside local AS (well-known community)\n"
8569 "Do not advertise to any peer (well-known community)\n"
8570 "Do not export to next AS (well-known community)\n")
8572 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
8576 ALIAS (show_ipv6_mbgp_community
,
8577 show_ipv6_mbgp_community2_cmd
,
8578 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8582 "Display routes matching the communities\n"
8583 "community number\n"
8584 "Do not send outside local AS (well-known community)\n"
8585 "Do not advertise to any peer (well-known community)\n"
8586 "Do not export to next AS (well-known community)\n"
8587 "community number\n"
8588 "Do not send outside local AS (well-known community)\n"
8589 "Do not advertise to any peer (well-known community)\n"
8590 "Do not export to next AS (well-known community)\n")
8593 ALIAS (show_ipv6_mbgp_community
,
8594 show_ipv6_mbgp_community3_cmd
,
8595 "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)",
8599 "Display routes matching the communities\n"
8600 "community number\n"
8601 "Do not send outside local AS (well-known community)\n"
8602 "Do not advertise to any peer (well-known community)\n"
8603 "Do not export to next AS (well-known community)\n"
8604 "community number\n"
8605 "Do not send outside local AS (well-known community)\n"
8606 "Do not advertise to any peer (well-known community)\n"
8607 "Do not export to next AS (well-known community)\n"
8608 "community number\n"
8609 "Do not send outside local AS (well-known community)\n"
8610 "Do not advertise to any peer (well-known community)\n"
8611 "Do not export to next AS (well-known community)\n")
8614 ALIAS (show_ipv6_mbgp_community
,
8615 show_ipv6_mbgp_community4_cmd
,
8616 "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)",
8620 "Display routes matching the communities\n"
8621 "community number\n"
8622 "Do not send outside local AS (well-known community)\n"
8623 "Do not advertise to any peer (well-known community)\n"
8624 "Do not export to next AS (well-known community)\n"
8625 "community number\n"
8626 "Do not send outside local AS (well-known community)\n"
8627 "Do not advertise to any peer (well-known community)\n"
8628 "Do not export to next AS (well-known community)\n"
8629 "community number\n"
8630 "Do not send outside local AS (well-known community)\n"
8631 "Do not advertise to any peer (well-known community)\n"
8632 "Do not export to next AS (well-known community)\n"
8633 "community number\n"
8634 "Do not send outside local AS (well-known community)\n"
8635 "Do not advertise to any peer (well-known community)\n"
8636 "Do not export to next AS (well-known community)\n")
8639 DEFUN (show_ipv6_mbgp_community_exact
,
8640 show_ipv6_mbgp_community_exact_cmd
,
8641 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8645 "Display routes matching the communities\n"
8646 "community number\n"
8647 "Do not send outside local AS (well-known community)\n"
8648 "Do not advertise to any peer (well-known community)\n"
8649 "Do not export to next AS (well-known community)\n"
8650 "Exact match of the communities")
8652 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
8656 ALIAS (show_ipv6_mbgp_community_exact
,
8657 show_ipv6_mbgp_community2_exact_cmd
,
8658 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8662 "Display routes matching the communities\n"
8663 "community number\n"
8664 "Do not send outside local AS (well-known community)\n"
8665 "Do not advertise to any peer (well-known community)\n"
8666 "Do not export to next AS (well-known community)\n"
8667 "community number\n"
8668 "Do not send outside local AS (well-known community)\n"
8669 "Do not advertise to any peer (well-known community)\n"
8670 "Do not export to next AS (well-known community)\n"
8671 "Exact match of the communities")
8674 ALIAS (show_ipv6_mbgp_community_exact
,
8675 show_ipv6_mbgp_community3_exact_cmd
,
8676 "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",
8680 "Display routes matching the communities\n"
8681 "community number\n"
8682 "Do not send outside local AS (well-known community)\n"
8683 "Do not advertise to any peer (well-known community)\n"
8684 "Do not export to next AS (well-known community)\n"
8685 "community number\n"
8686 "Do not send outside local AS (well-known community)\n"
8687 "Do not advertise to any peer (well-known community)\n"
8688 "Do not export to next AS (well-known community)\n"
8689 "community number\n"
8690 "Do not send outside local AS (well-known community)\n"
8691 "Do not advertise to any peer (well-known community)\n"
8692 "Do not export to next AS (well-known community)\n"
8693 "Exact match of the communities")
8696 ALIAS (show_ipv6_mbgp_community_exact
,
8697 show_ipv6_mbgp_community4_exact_cmd
,
8698 "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",
8702 "Display routes matching the communities\n"
8703 "community number\n"
8704 "Do not send outside local AS (well-known community)\n"
8705 "Do not advertise to any peer (well-known community)\n"
8706 "Do not export to next AS (well-known community)\n"
8707 "community number\n"
8708 "Do not send outside local AS (well-known community)\n"
8709 "Do not advertise to any peer (well-known community)\n"
8710 "Do not export to next AS (well-known community)\n"
8711 "community number\n"
8712 "Do not send outside local AS (well-known community)\n"
8713 "Do not advertise to any peer (well-known community)\n"
8714 "Do not export to next AS (well-known community)\n"
8715 "community number\n"
8716 "Do not send outside local AS (well-known community)\n"
8717 "Do not advertise to any peer (well-known community)\n"
8718 "Do not export to next AS (well-known community)\n"
8719 "Exact match of the communities")
8720 #endif /* HAVE_IPV6 */
8723 bgp_show_community_list (struct vty
*vty
, const char *com
, int exact
,
8724 afi_t afi
, safi_t safi
)
8726 struct community_list
*list
;
8728 list
= community_list_lookup (bgp_clist
, com
, COMMUNITY_LIST_MASTER
);
8731 vty_out (vty
, "%% %s is not a valid community-list name%s", com
,
8736 return bgp_show (vty
, NULL
, afi
, safi
,
8737 (exact
? bgp_show_type_community_list_exact
:
8738 bgp_show_type_community_list
), list
);
8741 DEFUN (show_ip_bgp_community_list
,
8742 show_ip_bgp_community_list_cmd
,
8743 "show ip bgp community-list (<1-500>|WORD)",
8747 "Display routes matching the community-list\n"
8748 "community-list number\n"
8749 "community-list name\n")
8751 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP
, SAFI_UNICAST
);
8754 DEFUN (show_ip_bgp_ipv4_community_list
,
8755 show_ip_bgp_ipv4_community_list_cmd
,
8756 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
8761 "Address Family modifier\n"
8762 "Address Family modifier\n"
8763 "Display routes matching the community-list\n"
8764 "community-list number\n"
8765 "community-list name\n")
8767 if (strncmp (argv
[0], "m", 1) == 0)
8768 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_MULTICAST
);
8770 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_UNICAST
);
8773 DEFUN (show_ip_bgp_community_list_exact
,
8774 show_ip_bgp_community_list_exact_cmd
,
8775 "show ip bgp community-list (<1-500>|WORD) exact-match",
8779 "Display routes matching the community-list\n"
8780 "community-list number\n"
8781 "community-list name\n"
8782 "Exact match of the communities\n")
8784 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP
, SAFI_UNICAST
);
8787 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
8788 show_ip_bgp_ipv4_community_list_exact_cmd
,
8789 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
8794 "Address Family modifier\n"
8795 "Address Family modifier\n"
8796 "Display routes matching the community-list\n"
8797 "community-list number\n"
8798 "community-list name\n"
8799 "Exact match of the communities\n")
8801 if (strncmp (argv
[0], "m", 1) == 0)
8802 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_MULTICAST
);
8804 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_UNICAST
);
8808 DEFUN (show_bgp_community_list
,
8809 show_bgp_community_list_cmd
,
8810 "show bgp community-list (<1-500>|WORD)",
8813 "Display routes matching the community-list\n"
8814 "community-list number\n"
8815 "community-list name\n")
8817 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
8820 ALIAS (show_bgp_community_list
,
8821 show_bgp_ipv6_community_list_cmd
,
8822 "show bgp ipv6 community-list (<1-500>|WORD)",
8826 "Display routes matching the community-list\n"
8827 "community-list number\n"
8828 "community-list name\n")
8831 DEFUN (show_ipv6_bgp_community_list
,
8832 show_ipv6_bgp_community_list_cmd
,
8833 "show ipv6 bgp community-list WORD",
8837 "Display routes matching the community-list\n"
8838 "community-list name\n")
8840 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
8844 DEFUN (show_ipv6_mbgp_community_list
,
8845 show_ipv6_mbgp_community_list_cmd
,
8846 "show ipv6 mbgp community-list WORD",
8850 "Display routes matching the community-list\n"
8851 "community-list name\n")
8853 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_MULTICAST
);
8856 DEFUN (show_bgp_community_list_exact
,
8857 show_bgp_community_list_exact_cmd
,
8858 "show bgp community-list (<1-500>|WORD) exact-match",
8861 "Display routes matching the community-list\n"
8862 "community-list number\n"
8863 "community-list name\n"
8864 "Exact match of the communities\n")
8866 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
8869 ALIAS (show_bgp_community_list_exact
,
8870 show_bgp_ipv6_community_list_exact_cmd
,
8871 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
8875 "Display routes matching the community-list\n"
8876 "community-list number\n"
8877 "community-list name\n"
8878 "Exact match of the communities\n")
8881 DEFUN (show_ipv6_bgp_community_list_exact
,
8882 show_ipv6_bgp_community_list_exact_cmd
,
8883 "show ipv6 bgp community-list WORD exact-match",
8887 "Display routes matching the community-list\n"
8888 "community-list name\n"
8889 "Exact match of the communities\n")
8891 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
8895 DEFUN (show_ipv6_mbgp_community_list_exact
,
8896 show_ipv6_mbgp_community_list_exact_cmd
,
8897 "show ipv6 mbgp community-list WORD exact-match",
8901 "Display routes matching the community-list\n"
8902 "community-list name\n"
8903 "Exact match of the communities\n")
8905 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_MULTICAST
);
8907 #endif /* HAVE_IPV6 */
8910 bgp_show_prefix_longer (struct vty
*vty
, const char *prefix
, afi_t afi
,
8911 safi_t safi
, enum bgp_show_type type
)
8918 ret
= str2prefix (prefix
, p
);
8921 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
8925 ret
= bgp_show (vty
, NULL
, afi
, safi
, type
, p
);
8930 DEFUN (show_ip_bgp_prefix_longer
,
8931 show_ip_bgp_prefix_longer_cmd
,
8932 "show ip bgp A.B.C.D/M longer-prefixes",
8936 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8937 "Display route and more specific routes\n")
8939 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8940 bgp_show_type_prefix_longer
);
8943 DEFUN (show_ip_bgp_flap_prefix_longer
,
8944 show_ip_bgp_flap_prefix_longer_cmd
,
8945 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
8949 "Display flap statistics of routes\n"
8950 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8951 "Display route and more specific routes\n")
8953 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8954 bgp_show_type_flap_prefix_longer
);
8957 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
8958 show_ip_bgp_ipv4_prefix_longer_cmd
,
8959 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
8964 "Address Family modifier\n"
8965 "Address Family modifier\n"
8966 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8967 "Display route and more specific routes\n")
8969 if (strncmp (argv
[0], "m", 1) == 0)
8970 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
8971 bgp_show_type_prefix_longer
);
8973 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
8974 bgp_show_type_prefix_longer
);
8977 DEFUN (show_ip_bgp_flap_address
,
8978 show_ip_bgp_flap_address_cmd
,
8979 "show ip bgp flap-statistics A.B.C.D",
8983 "Display flap statistics of routes\n"
8984 "Network in the BGP routing table to display\n")
8986 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8987 bgp_show_type_flap_address
);
8990 DEFUN (show_ip_bgp_flap_prefix
,
8991 show_ip_bgp_flap_prefix_cmd
,
8992 "show ip bgp flap-statistics A.B.C.D/M",
8996 "Display flap statistics of routes\n"
8997 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8999 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9000 bgp_show_type_flap_prefix
);
9003 DEFUN (show_bgp_prefix_longer
,
9004 show_bgp_prefix_longer_cmd
,
9005 "show bgp X:X::X:X/M longer-prefixes",
9008 "IPv6 prefix <network>/<length>\n"
9009 "Display route and more specific routes\n")
9011 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9012 bgp_show_type_prefix_longer
);
9015 ALIAS (show_bgp_prefix_longer
,
9016 show_bgp_ipv6_prefix_longer_cmd
,
9017 "show bgp ipv6 X:X::X:X/M longer-prefixes",
9021 "IPv6 prefix <network>/<length>\n"
9022 "Display route and more specific routes\n")
9025 DEFUN (show_ipv6_bgp_prefix_longer
,
9026 show_ipv6_bgp_prefix_longer_cmd
,
9027 "show ipv6 bgp X:X::X:X/M longer-prefixes",
9031 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
9032 "Display route and more specific routes\n")
9034 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9035 bgp_show_type_prefix_longer
);
9039 DEFUN (show_ipv6_mbgp_prefix_longer
,
9040 show_ipv6_mbgp_prefix_longer_cmd
,
9041 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
9045 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
9046 "Display route and more specific routes\n")
9048 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
9049 bgp_show_type_prefix_longer
);
9051 #endif /* HAVE_IPV6 */
9053 static struct peer
*
9054 peer_lookup_in_view (struct vty
*vty
, const char *view_name
,
9062 /* BGP structure lookup. */
9065 bgp
= bgp_lookup_by_name (view_name
);
9068 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
9074 bgp
= bgp_get_default ();
9077 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
9082 /* Get peer sockunion. */
9083 ret
= str2sockunion (ip_str
, &su
);
9086 vty_out (vty
, "Malformed address: %s%s", ip_str
, VTY_NEWLINE
);
9090 /* Peer structure lookup. */
9091 peer
= peer_lookup (bgp
, &su
);
9094 vty_out (vty
, "No such neighbor%s", VTY_NEWLINE
);
9103 BGP_STATS_MAXBITLEN
= 0,
9107 BGP_STATS_UNAGGREGATEABLE
,
9108 BGP_STATS_MAX_AGGREGATEABLE
,
9109 BGP_STATS_AGGREGATES
,
9111 BGP_STATS_ASPATH_COUNT
,
9112 BGP_STATS_ASPATH_MAXHOPS
,
9113 BGP_STATS_ASPATH_TOTHOPS
,
9114 BGP_STATS_ASPATH_MAXSIZE
,
9115 BGP_STATS_ASPATH_TOTSIZE
,
9116 BGP_STATS_ASN_HIGHEST
,
9120 static const char *table_stats_strs
[] =
9122 [BGP_STATS_PREFIXES
] = "Total Prefixes",
9123 [BGP_STATS_TOTPLEN
] = "Average prefix length",
9124 [BGP_STATS_RIB
] = "Total Advertisements",
9125 [BGP_STATS_UNAGGREGATEABLE
] = "Unaggregateable prefixes",
9126 [BGP_STATS_MAX_AGGREGATEABLE
] = "Maximum aggregateable prefixes",
9127 [BGP_STATS_AGGREGATES
] = "BGP Aggregate advertisements",
9128 [BGP_STATS_SPACE
] = "Address space advertised",
9129 [BGP_STATS_ASPATH_COUNT
] = "Advertisements with paths",
9130 [BGP_STATS_ASPATH_MAXHOPS
] = "Longest AS-Path (hops)",
9131 [BGP_STATS_ASPATH_MAXSIZE
] = "Largest AS-Path (bytes)",
9132 [BGP_STATS_ASPATH_TOTHOPS
] = "Average AS-Path length (hops)",
9133 [BGP_STATS_ASPATH_TOTSIZE
] = "Average AS-Path size (bytes)",
9134 [BGP_STATS_ASN_HIGHEST
] = "Highest public ASN",
9135 [BGP_STATS_MAX
] = NULL
,
9138 struct bgp_table_stats
9140 struct bgp_table
*table
;
9141 unsigned long long counts
[BGP_STATS_MAX
];
9145 #define TALLY_SIGFIG 100000
9146 static unsigned long
9147 ravg_tally (unsigned long count
, unsigned long oldavg
, unsigned long newval
)
9149 unsigned long newtot
= (count
-1) * oldavg
+ (newval
* TALLY_SIGFIG
);
9150 unsigned long res
= (newtot
* TALLY_SIGFIG
) / count
;
9151 unsigned long ret
= newtot
/ count
;
9153 if ((res
% TALLY_SIGFIG
) > (TALLY_SIGFIG
/2))
9161 bgp_table_stats_walker (struct thread
*t
)
9163 struct bgp_node
*rn
;
9164 struct bgp_node
*top
;
9165 struct bgp_table_stats
*ts
= THREAD_ARG (t
);
9166 unsigned int space
= 0;
9168 if (!(top
= bgp_table_top (ts
->table
)))
9171 switch (top
->p
.family
)
9174 space
= IPV4_MAX_BITLEN
;
9177 space
= IPV6_MAX_BITLEN
;
9181 ts
->counts
[BGP_STATS_MAXBITLEN
] = space
;
9183 for (rn
= top
; rn
; rn
= bgp_route_next (rn
))
9185 struct bgp_info
*ri
;
9186 struct bgp_node
*prn
= rn
->parent
;
9187 unsigned int rinum
= 0;
9195 ts
->counts
[BGP_STATS_PREFIXES
]++;
9196 ts
->counts
[BGP_STATS_TOTPLEN
] += rn
->p
.prefixlen
;
9199 ts
->counts
[BGP_STATS_AVGPLEN
]
9200 = ravg_tally (ts
->counts
[BGP_STATS_PREFIXES
],
9201 ts
->counts
[BGP_STATS_AVGPLEN
],
9205 /* check if the prefix is included by any other announcements */
9206 while (prn
&& !prn
->info
)
9209 if (prn
== NULL
|| prn
== top
)
9211 ts
->counts
[BGP_STATS_UNAGGREGATEABLE
]++;
9212 /* announced address space */
9214 ts
->counts
[BGP_STATS_SPACE
] += 1 << (space
- rn
->p
.prefixlen
);
9217 ts
->counts
[BGP_STATS_MAX_AGGREGATEABLE
]++;
9219 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
9222 ts
->counts
[BGP_STATS_RIB
]++;
9225 (CHECK_FLAG (ri
->attr
->flag
,
9226 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
))))
9227 ts
->counts
[BGP_STATS_AGGREGATES
]++;
9230 if (ri
->attr
&& ri
->attr
->aspath
)
9232 unsigned int hops
= aspath_count_hops (ri
->attr
->aspath
);
9233 unsigned int size
= aspath_size (ri
->attr
->aspath
);
9234 as_t highest
= aspath_highest (ri
->attr
->aspath
);
9236 ts
->counts
[BGP_STATS_ASPATH_COUNT
]++;
9238 if (hops
> ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
])
9239 ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
] = hops
;
9241 if (size
> ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
])
9242 ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
] = size
;
9244 ts
->counts
[BGP_STATS_ASPATH_TOTHOPS
] += hops
;
9245 ts
->counts
[BGP_STATS_ASPATH_TOTSIZE
] += size
;
9247 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
]
9248 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
9249 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
],
9251 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
]
9252 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
9253 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
],
9256 if (highest
> ts
->counts
[BGP_STATS_ASN_HIGHEST
])
9257 ts
->counts
[BGP_STATS_ASN_HIGHEST
] = highest
;
9265 bgp_table_stats (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
)
9267 struct bgp_table_stats ts
;
9270 if (!bgp
->rib
[afi
][safi
])
9272 vty_out (vty
, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE
);
9276 memset (&ts
, 0, sizeof (ts
));
9277 ts
.table
= bgp
->rib
[afi
][safi
];
9278 thread_execute (bm
->master
, bgp_table_stats_walker
, &ts
, 0);
9280 vty_out (vty
, "BGP %s RIB statistics%s%s",
9281 afi_safi_print (afi
, safi
), VTY_NEWLINE
, VTY_NEWLINE
);
9283 for (i
= 0; i
< BGP_STATS_MAX
; i
++)
9285 if (!table_stats_strs
[i
])
9291 case BGP_STATS_ASPATH_AVGHOPS
:
9292 case BGP_STATS_ASPATH_AVGSIZE
:
9293 case BGP_STATS_AVGPLEN
:
9294 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9295 vty_out (vty
, "%12.2f",
9296 (float)ts
.counts
[i
] / (float)TALLY_SIGFIG
);
9299 case BGP_STATS_ASPATH_TOTHOPS
:
9300 case BGP_STATS_ASPATH_TOTSIZE
:
9301 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9302 vty_out (vty
, "%12.2f",
9304 (float)ts
.counts
[i
] /
9305 (float)ts
.counts
[BGP_STATS_ASPATH_COUNT
]
9308 case BGP_STATS_TOTPLEN
:
9309 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9310 vty_out (vty
, "%12.2f",
9312 (float)ts
.counts
[i
] /
9313 (float)ts
.counts
[BGP_STATS_PREFIXES
]
9316 case BGP_STATS_SPACE
:
9317 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9318 vty_out (vty
, "%12llu%s", ts
.counts
[i
], VTY_NEWLINE
);
9319 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 9)
9321 vty_out (vty
, "%30s: ", "%% announced ");
9322 vty_out (vty
, "%12.2f%s",
9323 100 * (float)ts
.counts
[BGP_STATS_SPACE
] /
9324 (float)((uint64_t)1UL << ts
.counts
[BGP_STATS_MAXBITLEN
]),
9326 vty_out (vty
, "%30s: ", "/8 equivalent ");
9327 vty_out (vty
, "%12.2f%s",
9328 (float)ts
.counts
[BGP_STATS_SPACE
] /
9329 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 8)),
9331 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 25)
9333 vty_out (vty
, "%30s: ", "/24 equivalent ");
9334 vty_out (vty
, "%12.2f",
9335 (float)ts
.counts
[BGP_STATS_SPACE
] /
9336 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 24)));
9339 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9340 vty_out (vty
, "%12llu", ts
.counts
[i
]);
9343 vty_out (vty
, "%s", VTY_NEWLINE
);
9349 bgp_table_stats_vty (struct vty
*vty
, const char *name
,
9350 const char *afi_str
, const char *safi_str
)
9357 bgp
= bgp_lookup_by_name (name
);
9359 bgp
= bgp_get_default ();
9363 vty_out (vty
, "%% No such BGP instance exist%s", VTY_NEWLINE
);
9366 if (strncmp (afi_str
, "ipv", 3) == 0)
9368 if (strncmp (afi_str
, "ipv4", 4) == 0)
9370 else if (strncmp (afi_str
, "ipv6", 4) == 0)
9374 vty_out (vty
, "%% Invalid address family %s%s",
9375 afi_str
, VTY_NEWLINE
);
9378 if (strncmp (safi_str
, "m", 1) == 0)
9379 safi
= SAFI_MULTICAST
;
9380 else if (strncmp (safi_str
, "u", 1) == 0)
9381 safi
= SAFI_UNICAST
;
9382 else if (strncmp (safi_str
, "vpnv4", 5) == 0)
9383 safi
= BGP_SAFI_VPNV4
;
9384 else if (strncmp (safi_str
, "vpnv6", 6) == 0)
9385 safi
= BGP_SAFI_VPNV6
;
9388 vty_out (vty
, "%% Invalid subsequent address family %s%s",
9389 safi_str
, VTY_NEWLINE
);
9395 vty_out (vty
, "%% Invalid address family %s%s",
9396 afi_str
, VTY_NEWLINE
);
9400 if ((afi
== AFI_IP
&& safi
== BGP_SAFI_VPNV6
)
9401 || (afi
== AFI_IP6
&& safi
== BGP_SAFI_VPNV4
))
9403 vty_out (vty
, "%% Invalid subsequent address family %s for %s%s",
9404 afi_str
, safi_str
, VTY_NEWLINE
);
9407 return bgp_table_stats (vty
, bgp
, afi
, safi
);
9410 DEFUN (show_bgp_statistics
,
9411 show_bgp_statistics_cmd
,
9412 "show bgp (ipv4|ipv6) (unicast|multicast) statistics",
9417 "Address Family modifier\n"
9418 "Address Family modifier\n"
9419 "BGP RIB advertisement statistics\n")
9421 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
9424 ALIAS (show_bgp_statistics
,
9425 show_bgp_statistics_vpnv4_cmd
,
9426 "show bgp (ipv4) (vpnv4) statistics",
9430 "Address Family modifier\n"
9431 "BGP RIB advertisement statistics\n")
9433 DEFUN (show_bgp_statistics_view
,
9434 show_bgp_statistics_view_cmd
,
9435 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics",
9441 "Address Family modifier\n"
9442 "Address Family modifier\n"
9443 "BGP RIB advertisement statistics\n")
9445 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
9448 ALIAS (show_bgp_statistics_view
,
9449 show_bgp_statistics_view_vpnv4_cmd
,
9450 "show bgp view WORD (ipv4) (vpnv4) statistics",
9455 "Address Family modifier\n"
9456 "BGP RIB advertisement statistics\n")
9468 PCOUNT_PFCNT
, /* the figure we display to users */
9472 static const char *pcount_strs
[] =
9474 [PCOUNT_ADJ_IN
] = "Adj-in",
9475 [PCOUNT_DAMPED
] = "Damped",
9476 [PCOUNT_REMOVED
] = "Removed",
9477 [PCOUNT_HISTORY
] = "History",
9478 [PCOUNT_STALE
] = "Stale",
9479 [PCOUNT_VALID
] = "Valid",
9480 [PCOUNT_ALL
] = "All RIB",
9481 [PCOUNT_COUNTED
] = "PfxCt counted",
9482 [PCOUNT_PFCNT
] = "Useable",
9483 [PCOUNT_MAX
] = NULL
,
9488 unsigned int count
[PCOUNT_MAX
];
9489 const struct peer
*peer
;
9490 const struct bgp_table
*table
;
9494 bgp_peer_count_walker (struct thread
*t
)
9496 struct bgp_node
*rn
;
9497 struct peer_pcounts
*pc
= THREAD_ARG (t
);
9498 const struct peer
*peer
= pc
->peer
;
9500 for (rn
= bgp_table_top (pc
->table
); rn
; rn
= bgp_route_next (rn
))
9502 struct bgp_adj_in
*ain
;
9503 struct bgp_info
*ri
;
9505 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
9506 if (ain
->peer
== peer
)
9507 pc
->count
[PCOUNT_ADJ_IN
]++;
9509 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
9511 char buf
[SU_ADDRSTRLEN
];
9513 if (ri
->peer
!= peer
)
9516 pc
->count
[PCOUNT_ALL
]++;
9518 if (CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
))
9519 pc
->count
[PCOUNT_DAMPED
]++;
9520 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
9521 pc
->count
[PCOUNT_HISTORY
]++;
9522 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
9523 pc
->count
[PCOUNT_REMOVED
]++;
9524 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
9525 pc
->count
[PCOUNT_STALE
]++;
9526 if (CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
))
9527 pc
->count
[PCOUNT_VALID
]++;
9528 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9529 pc
->count
[PCOUNT_PFCNT
]++;
9531 if (CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
9533 pc
->count
[PCOUNT_COUNTED
]++;
9534 if (CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9535 plog_warn (peer
->log
,
9536 "%s [pcount] %s/%d is counted but flags 0x%x",
9538 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
9539 buf
, SU_ADDRSTRLEN
),
9545 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9546 plog_warn (peer
->log
,
9547 "%s [pcount] %s/%d not counted but flags 0x%x",
9549 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
9550 buf
, SU_ADDRSTRLEN
),
9560 bgp_peer_counts (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
)
9562 struct peer_pcounts pcounts
= { .peer
= peer
};
9565 if (!peer
|| !peer
->bgp
|| !peer
->afc
[afi
][safi
]
9566 || !peer
->bgp
->rib
[afi
][safi
])
9568 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
9572 memset (&pcounts
, 0, sizeof(pcounts
));
9573 pcounts
.peer
= peer
;
9574 pcounts
.table
= peer
->bgp
->rib
[afi
][safi
];
9576 /* in-place call via thread subsystem so as to record execution time
9577 * stats for the thread-walk (i.e. ensure this can't be blamed on
9578 * on just vty_read()).
9580 thread_execute (bm
->master
, bgp_peer_count_walker
, &pcounts
, 0);
9582 vty_out (vty
, "Prefix counts for %s, %s%s",
9583 peer
->host
, afi_safi_print (afi
, safi
), VTY_NEWLINE
);
9584 vty_out (vty
, "PfxCt: %ld%s", peer
->pcount
[afi
][safi
], VTY_NEWLINE
);
9585 vty_out (vty
, "%sCounts from RIB table walk:%s%s",
9586 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
9588 for (i
= 0; i
< PCOUNT_MAX
; i
++)
9589 vty_out (vty
, "%20s: %-10d%s",
9590 pcount_strs
[i
], pcounts
.count
[i
], VTY_NEWLINE
);
9592 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
9594 vty_out (vty
, "%s [pcount] PfxCt drift!%s",
9595 peer
->host
, VTY_NEWLINE
);
9596 vty_out (vty
, "Please report this bug, with the above command output%s",
9603 DEFUN (show_ip_bgp_neighbor_prefix_counts
,
9604 show_ip_bgp_neighbor_prefix_counts_cmd
,
9605 "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9609 "Detailed information on TCP and BGP neighbor connections\n"
9610 "Neighbor to display information about\n"
9611 "Neighbor to display information about\n"
9612 "Display detailed prefix count information\n")
9616 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9620 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
);
9623 DEFUN (show_bgp_ipv6_neighbor_prefix_counts
,
9624 show_bgp_ipv6_neighbor_prefix_counts_cmd
,
9625 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9629 "Detailed information on TCP and BGP neighbor connections\n"
9630 "Neighbor to display information about\n"
9631 "Neighbor to display information about\n"
9632 "Display detailed prefix count information\n")
9636 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9640 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
);
9643 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts
,
9644 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
,
9645 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9650 "Address Family modifier\n"
9651 "Address Family modifier\n"
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 detailed prefix count information\n")
9659 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9663 if (strncmp (argv
[0], "m", 1) == 0)
9664 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MULTICAST
);
9666 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
);
9669 DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts
,
9670 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
,
9671 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9676 "Address Family modifier\n"
9677 "Address Family modifier\n"
9678 "Detailed information on TCP and BGP neighbor connections\n"
9679 "Neighbor to display information about\n"
9680 "Neighbor to display information about\n"
9681 "Display detailed prefix count information\n")
9685 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9689 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MPLS_VPN
);
9694 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
9697 struct bgp_table
*table
;
9698 struct bgp_adj_in
*ain
;
9699 struct bgp_adj_out
*adj
;
9700 unsigned long output_count
;
9701 struct bgp_node
*rn
;
9711 table
= bgp
->rib
[afi
][safi
];
9715 if (! in
&& CHECK_FLAG (peer
->af_sflags
[afi
][safi
],
9716 PEER_STATUS_DEFAULT_ORIGINATE
))
9718 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9719 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9720 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9722 vty_out (vty
, "Originating default network 0.0.0.0%s%s",
9723 VTY_NEWLINE
, VTY_NEWLINE
);
9727 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
9730 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
9731 if (ain
->peer
== peer
)
9735 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9736 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9737 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9742 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
9747 route_vty_out_tmp (vty
, &rn
->p
, ain
->attr
, safi
);
9754 for (adj
= rn
->adj_out
; adj
; adj
= adj
->next
)
9755 if (adj
->peer
== peer
)
9759 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9760 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9761 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9766 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
9771 route_vty_out_tmp (vty
, &rn
->p
, adj
->attr
, safi
);
9777 if (output_count
!= 0)
9778 vty_out (vty
, "%sTotal number of prefixes %ld%s",
9779 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
9783 peer_adj_routes (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
, int in
)
9785 if (! peer
|| ! peer
->afc
[afi
][safi
])
9787 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
9791 if (in
&& ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
9793 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s",
9798 show_adj_route (vty
, peer
, afi
, safi
, in
);
9803 DEFUN (show_ip_bgp_view_neighbor_advertised_route
,
9804 show_ip_bgp_view_neighbor_advertised_route_cmd
,
9805 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9811 "Detailed information on TCP and BGP neighbor connections\n"
9812 "Neighbor to display information about\n"
9813 "Neighbor to display information about\n"
9814 "Display the routes advertised to a BGP neighbor\n")
9819 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9821 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9826 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0);
9829 ALIAS (show_ip_bgp_view_neighbor_advertised_route
,
9830 show_ip_bgp_neighbor_advertised_route_cmd
,
9831 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9835 "Detailed information on TCP and BGP neighbor connections\n"
9836 "Neighbor to display information about\n"
9837 "Neighbor to display information about\n"
9838 "Display the routes advertised to a BGP neighbor\n")
9840 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
9841 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
9842 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9847 "Address Family modifier\n"
9848 "Address Family modifier\n"
9849 "Detailed information on TCP and BGP neighbor connections\n"
9850 "Neighbor to display information about\n"
9851 "Neighbor to display information about\n"
9852 "Display the routes advertised to a BGP neighbor\n")
9856 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9860 if (strncmp (argv
[0], "m", 1) == 0)
9861 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 0);
9863 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0);
9867 DEFUN (show_bgp_view_neighbor_advertised_route
,
9868 show_bgp_view_neighbor_advertised_route_cmd
,
9869 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9874 "Detailed information on TCP and BGP neighbor connections\n"
9875 "Neighbor to display information about\n"
9876 "Neighbor to display information about\n"
9877 "Display the routes advertised to a BGP neighbor\n")
9882 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9884 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9889 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0);
9892 ALIAS (show_bgp_view_neighbor_advertised_route
,
9893 show_bgp_view_ipv6_neighbor_advertised_route_cmd
,
9894 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9900 "Detailed information on TCP and BGP neighbor connections\n"
9901 "Neighbor to display information about\n"
9902 "Neighbor to display information about\n"
9903 "Display the routes advertised to a BGP neighbor\n")
9905 DEFUN (show_bgp_view_neighbor_received_routes
,
9906 show_bgp_view_neighbor_received_routes_cmd
,
9907 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
9912 "Detailed information on TCP and BGP neighbor connections\n"
9913 "Neighbor to display information about\n"
9914 "Neighbor to display information about\n"
9915 "Display the received routes from neighbor\n")
9920 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9922 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9927 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1);
9930 ALIAS (show_bgp_view_neighbor_received_routes
,
9931 show_bgp_view_ipv6_neighbor_received_routes_cmd
,
9932 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
9938 "Detailed information on TCP and BGP neighbor connections\n"
9939 "Neighbor to display information about\n"
9940 "Neighbor to display information about\n"
9941 "Display the received routes from neighbor\n")
9943 ALIAS (show_bgp_view_neighbor_advertised_route
,
9944 show_bgp_neighbor_advertised_route_cmd
,
9945 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9948 "Detailed information on TCP and BGP neighbor connections\n"
9949 "Neighbor to display information about\n"
9950 "Neighbor to display information about\n"
9951 "Display the routes advertised to a BGP neighbor\n")
9953 ALIAS (show_bgp_view_neighbor_advertised_route
,
9954 show_bgp_ipv6_neighbor_advertised_route_cmd
,
9955 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9959 "Detailed information on TCP and BGP neighbor connections\n"
9960 "Neighbor to display information about\n"
9961 "Neighbor to display information about\n"
9962 "Display the routes advertised to a BGP neighbor\n")
9965 ALIAS (show_bgp_view_neighbor_advertised_route
,
9966 ipv6_bgp_neighbor_advertised_route_cmd
,
9967 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9971 "Detailed information on TCP and BGP neighbor connections\n"
9972 "Neighbor to display information about\n"
9973 "Neighbor to display information about\n"
9974 "Display the routes advertised to a BGP neighbor\n")
9977 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
9978 ipv6_mbgp_neighbor_advertised_route_cmd
,
9979 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9983 "Detailed information on TCP and BGP neighbor connections\n"
9984 "Neighbor to display information about\n"
9985 "Neighbor to display information about\n"
9986 "Display the routes advertised to a BGP neighbor\n")
9990 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9994 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 0);
9996 #endif /* HAVE_IPV6 */
9998 DEFUN (show_ip_bgp_view_neighbor_received_routes
,
9999 show_ip_bgp_view_neighbor_received_routes_cmd
,
10000 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
10006 "Detailed information on TCP and BGP neighbor connections\n"
10007 "Neighbor to display information about\n"
10008 "Neighbor to display information about\n"
10009 "Display the received routes from neighbor\n")
10014 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10016 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10019 return CMD_WARNING
;
10021 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1);
10024 ALIAS (show_ip_bgp_view_neighbor_received_routes
,
10025 show_ip_bgp_neighbor_received_routes_cmd
,
10026 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
10030 "Detailed information on TCP and BGP neighbor connections\n"
10031 "Neighbor to display information about\n"
10032 "Neighbor to display information about\n"
10033 "Display the received routes from neighbor\n")
10035 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
10036 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
10037 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
10042 "Address Family modifier\n"
10043 "Address Family modifier\n"
10044 "Detailed information on TCP and BGP neighbor connections\n"
10045 "Neighbor to display information about\n"
10046 "Neighbor to display information about\n"
10047 "Display the received routes from neighbor\n")
10051 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
10053 return CMD_WARNING
;
10055 if (strncmp (argv
[0], "m", 1) == 0)
10056 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 1);
10058 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1);
10061 DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes
,
10062 show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd
,
10064 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)",
10066 "show bgp view WORD ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)",
10076 "Address family modifier\n"
10077 "Address family modifier\n"
10078 "Detailed information on TCP and BGP neighbor connections\n"
10079 "Neighbor to display information about\n"
10080 "Neighbor to display information about\n"
10081 "Display the advertised routes to neighbor\n"
10082 "Display the received routes from neighbor\n")
10090 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[3]);
10092 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[2]);
10096 return CMD_WARNING
;
10099 afi
= (strncmp (argv
[1], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
10100 safi
= (strncmp (argv
[2], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10101 in
= (strncmp (argv
[4], "r", 1) == 0) ? 1 : 0;
10104 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10105 in
= (strncmp (argv
[3], "r", 1) == 0) ? 1 : 0;
10108 return peer_adj_routes (vty
, peer
, afi
, safi
, in
);
10111 DEFUN (show_ip_bgp_neighbor_received_prefix_filter
,
10112 show_ip_bgp_neighbor_received_prefix_filter_cmd
,
10113 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10117 "Detailed information on TCP and BGP neighbor connections\n"
10118 "Neighbor to display information about\n"
10119 "Neighbor to display information about\n"
10120 "Display information received from a BGP neighbor\n"
10121 "Display the prefixlist filter\n")
10124 union sockunion
*su
;
10128 su
= sockunion_str2su (argv
[0]);
10130 return CMD_WARNING
;
10132 peer
= peer_lookup (NULL
, su
);
10134 return CMD_WARNING
;
10136 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
10137 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
10140 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
10141 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
10144 return CMD_SUCCESS
;
10147 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter
,
10148 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
,
10149 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10154 "Address Family modifier\n"
10155 "Address Family modifier\n"
10156 "Detailed information on TCP and BGP neighbor connections\n"
10157 "Neighbor to display information about\n"
10158 "Neighbor to display information about\n"
10159 "Display information received from a BGP neighbor\n"
10160 "Display the prefixlist filter\n")
10163 union sockunion
*su
;
10167 su
= sockunion_str2su (argv
[1]);
10169 return CMD_WARNING
;
10171 peer
= peer_lookup (NULL
, su
);
10173 return CMD_WARNING
;
10175 if (strncmp (argv
[0], "m", 1) == 0)
10177 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_MULTICAST
);
10178 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
10181 vty_out (vty
, "Address family: IPv4 Multicast%s", VTY_NEWLINE
);
10182 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
10187 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
10188 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
10191 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
10192 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
10196 return CMD_SUCCESS
;
10201 ALIAS (show_bgp_view_neighbor_received_routes
,
10202 show_bgp_neighbor_received_routes_cmd
,
10203 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
10206 "Detailed information on TCP and BGP neighbor connections\n"
10207 "Neighbor to display information about\n"
10208 "Neighbor to display information about\n"
10209 "Display the received routes from neighbor\n")
10211 ALIAS (show_bgp_view_neighbor_received_routes
,
10212 show_bgp_ipv6_neighbor_received_routes_cmd
,
10213 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
10217 "Detailed information on TCP and BGP neighbor connections\n"
10218 "Neighbor to display information about\n"
10219 "Neighbor to display information about\n"
10220 "Display the received routes from neighbor\n")
10222 DEFUN (show_bgp_neighbor_received_prefix_filter
,
10223 show_bgp_neighbor_received_prefix_filter_cmd
,
10224 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10227 "Detailed information on TCP and BGP neighbor connections\n"
10228 "Neighbor to display information about\n"
10229 "Neighbor to display information about\n"
10230 "Display information received from a BGP neighbor\n"
10231 "Display the prefixlist filter\n")
10234 union sockunion
*su
;
10238 su
= sockunion_str2su (argv
[0]);
10240 return CMD_WARNING
;
10242 peer
= peer_lookup (NULL
, su
);
10244 return CMD_WARNING
;
10246 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
10247 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
);
10250 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
10251 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
);
10254 return CMD_SUCCESS
;
10257 ALIAS (show_bgp_neighbor_received_prefix_filter
,
10258 show_bgp_ipv6_neighbor_received_prefix_filter_cmd
,
10259 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10263 "Detailed information on TCP and BGP neighbor connections\n"
10264 "Neighbor to display information about\n"
10265 "Neighbor to display information about\n"
10266 "Display information received from a BGP neighbor\n"
10267 "Display the prefixlist filter\n")
10270 ALIAS (show_bgp_view_neighbor_received_routes
,
10271 ipv6_bgp_neighbor_received_routes_cmd
,
10272 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
10276 "Detailed information on TCP and BGP neighbor connections\n"
10277 "Neighbor to display information about\n"
10278 "Neighbor to display information about\n"
10279 "Display the received routes from neighbor\n")
10282 DEFUN (ipv6_mbgp_neighbor_received_routes
,
10283 ipv6_mbgp_neighbor_received_routes_cmd
,
10284 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
10288 "Detailed information on TCP and BGP neighbor connections\n"
10289 "Neighbor to display information about\n"
10290 "Neighbor to display information about\n"
10291 "Display the received routes from neighbor\n")
10295 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10297 return CMD_WARNING
;
10299 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 1);
10302 DEFUN (show_bgp_view_neighbor_received_prefix_filter
,
10303 show_bgp_view_neighbor_received_prefix_filter_cmd
,
10304 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10309 "Detailed information on TCP and BGP neighbor connections\n"
10310 "Neighbor to display information about\n"
10311 "Neighbor to display information about\n"
10312 "Display information received from a BGP neighbor\n"
10313 "Display the prefixlist filter\n")
10316 union sockunion
*su
;
10321 /* BGP structure lookup. */
10322 bgp
= bgp_lookup_by_name (argv
[0]);
10325 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10326 return CMD_WARNING
;
10329 su
= sockunion_str2su (argv
[1]);
10331 return CMD_WARNING
;
10333 peer
= peer_lookup (bgp
, su
);
10335 return CMD_WARNING
;
10337 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
10338 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
);
10341 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
10342 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
);
10345 return CMD_SUCCESS
;
10348 ALIAS (show_bgp_view_neighbor_received_prefix_filter
,
10349 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
,
10350 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10356 "Detailed information on TCP and BGP neighbor connections\n"
10357 "Neighbor to display information about\n"
10358 "Neighbor to display information about\n"
10359 "Display information received from a BGP neighbor\n"
10360 "Display the prefixlist filter\n")
10361 #endif /* HAVE_IPV6 */
10364 bgp_show_neighbor_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
,
10365 safi_t safi
, enum bgp_show_type type
)
10367 if (! peer
|| ! peer
->afc
[afi
][safi
])
10369 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
10370 return CMD_WARNING
;
10373 return bgp_show (vty
, peer
->bgp
, afi
, safi
, type
, &peer
->su
);
10376 DEFUN (show_ip_bgp_neighbor_routes
,
10377 show_ip_bgp_neighbor_routes_cmd
,
10378 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
10382 "Detailed information on TCP and BGP neighbor connections\n"
10383 "Neighbor to display information about\n"
10384 "Neighbor to display information about\n"
10385 "Display routes learned from neighbor\n")
10389 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10391 return CMD_WARNING
;
10393 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10394 bgp_show_type_neighbor
);
10397 DEFUN (show_ip_bgp_neighbor_flap
,
10398 show_ip_bgp_neighbor_flap_cmd
,
10399 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10403 "Detailed information on TCP and BGP neighbor connections\n"
10404 "Neighbor to display information about\n"
10405 "Neighbor to display information about\n"
10406 "Display flap statistics of the routes learned from neighbor\n")
10410 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10412 return CMD_WARNING
;
10414 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10415 bgp_show_type_flap_neighbor
);
10418 DEFUN (show_ip_bgp_neighbor_damp
,
10419 show_ip_bgp_neighbor_damp_cmd
,
10420 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10424 "Detailed information on TCP and BGP neighbor connections\n"
10425 "Neighbor to display information about\n"
10426 "Neighbor to display information about\n"
10427 "Display the dampened routes received from neighbor\n")
10431 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10433 return CMD_WARNING
;
10435 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10436 bgp_show_type_damp_neighbor
);
10439 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
10440 show_ip_bgp_ipv4_neighbor_routes_cmd
,
10441 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
10446 "Address Family modifier\n"
10447 "Address Family modifier\n"
10448 "Detailed information on TCP and BGP neighbor connections\n"
10449 "Neighbor to display information about\n"
10450 "Neighbor to display information about\n"
10451 "Display routes learned from neighbor\n")
10455 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
10457 return CMD_WARNING
;
10459 if (strncmp (argv
[0], "m", 1) == 0)
10460 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_MULTICAST
,
10461 bgp_show_type_neighbor
);
10463 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10464 bgp_show_type_neighbor
);
10467 DEFUN (show_ip_bgp_view_rsclient
,
10468 show_ip_bgp_view_rsclient_cmd
,
10469 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
10475 "Information about Route Server Client\n"
10478 struct bgp_table
*table
;
10482 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10484 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10487 return CMD_WARNING
;
10489 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
10491 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10493 return CMD_WARNING
;
10496 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
10497 PEER_FLAG_RSERVER_CLIENT
))
10499 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10501 return CMD_WARNING
;
10504 table
= peer
->rib
[AFI_IP
][SAFI_UNICAST
];
10506 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
10509 ALIAS (show_ip_bgp_view_rsclient
,
10510 show_ip_bgp_rsclient_cmd
,
10511 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
10515 "Information about Route Server Client\n"
10518 DEFUN (show_bgp_view_ipv4_safi_rsclient
,
10519 show_bgp_view_ipv4_safi_rsclient_cmd
,
10520 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
10526 "Address Family modifier\n"
10527 "Address Family modifier\n"
10528 "Information about Route Server Client\n"
10531 struct bgp_table
*table
;
10536 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[2]);
10537 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10539 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
10540 safi
= (strncmp (argv
[0], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10544 return CMD_WARNING
;
10546 if (! peer
->afc
[AFI_IP
][safi
])
10548 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10550 return CMD_WARNING
;
10553 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][safi
],
10554 PEER_FLAG_RSERVER_CLIENT
))
10556 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10558 return CMD_WARNING
;
10561 table
= peer
->rib
[AFI_IP
][safi
];
10563 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
10566 ALIAS (show_bgp_view_ipv4_safi_rsclient
,
10567 show_bgp_ipv4_safi_rsclient_cmd
,
10568 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
10572 "Address Family modifier\n"
10573 "Address Family modifier\n"
10574 "Information about Route Server Client\n"
10577 DEFUN (show_ip_bgp_view_rsclient_route
,
10578 show_ip_bgp_view_rsclient_route_cmd
,
10579 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
10585 "Information about Route Server Client\n"
10587 "Network in the BGP routing table to display\n")
10592 /* BGP structure lookup. */
10595 bgp
= bgp_lookup_by_name (argv
[0]);
10598 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10599 return CMD_WARNING
;
10604 bgp
= bgp_get_default ();
10607 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10608 return CMD_WARNING
;
10613 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10615 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10618 return CMD_WARNING
;
10620 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
10622 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10624 return CMD_WARNING
;
10627 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
10628 PEER_FLAG_RSERVER_CLIENT
))
10630 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10632 return CMD_WARNING
;
10635 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][SAFI_UNICAST
],
10636 (argc
== 3) ? argv
[2] : argv
[1],
10637 AFI_IP
, SAFI_UNICAST
, NULL
, 0);
10640 ALIAS (show_ip_bgp_view_rsclient_route
,
10641 show_ip_bgp_rsclient_route_cmd
,
10642 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
10646 "Information about Route Server Client\n"
10648 "Network in the BGP routing table to display\n")
10650 DEFUN (show_bgp_view_ipv4_safi_rsclient_route
,
10651 show_bgp_view_ipv4_safi_rsclient_route_cmd
,
10652 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
10658 "Address Family modifier\n"
10659 "Address Family modifier\n"
10660 "Information about Route Server Client\n"
10662 "Network in the BGP routing table to display\n")
10668 /* BGP structure lookup. */
10671 bgp
= bgp_lookup_by_name (argv
[0]);
10674 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10675 return CMD_WARNING
;
10680 bgp
= bgp_get_default ();
10683 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10684 return CMD_WARNING
;
10689 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[2]);
10690 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10692 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
10693 safi
= (strncmp (argv
[0], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10697 return CMD_WARNING
;
10699 if (! peer
->afc
[AFI_IP
][safi
])
10701 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10703 return CMD_WARNING
;
10706 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][safi
],
10707 PEER_FLAG_RSERVER_CLIENT
))
10709 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10711 return CMD_WARNING
;
10714 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][safi
],
10715 (argc
== 4) ? argv
[3] : argv
[2],
10716 AFI_IP
, safi
, NULL
, 0);
10719 ALIAS (show_bgp_view_ipv4_safi_rsclient_route
,
10720 show_bgp_ipv4_safi_rsclient_route_cmd
,
10721 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
10725 "Address Family modifier\n"
10726 "Address Family modifier\n"
10727 "Information about Route Server Client\n"
10729 "Network in the BGP routing table to display\n")
10731 DEFUN (show_ip_bgp_view_rsclient_prefix
,
10732 show_ip_bgp_view_rsclient_prefix_cmd
,
10733 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
10739 "Information about Route Server Client\n"
10741 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10746 /* BGP structure lookup. */
10749 bgp
= bgp_lookup_by_name (argv
[0]);
10752 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10753 return CMD_WARNING
;
10758 bgp
= bgp_get_default ();
10761 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10762 return CMD_WARNING
;
10767 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10769 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10772 return CMD_WARNING
;
10774 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
10776 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10778 return CMD_WARNING
;
10781 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
10782 PEER_FLAG_RSERVER_CLIENT
))
10784 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10786 return CMD_WARNING
;
10789 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][SAFI_UNICAST
],
10790 (argc
== 3) ? argv
[2] : argv
[1],
10791 AFI_IP
, SAFI_UNICAST
, NULL
, 1);
10794 ALIAS (show_ip_bgp_view_rsclient_prefix
,
10795 show_ip_bgp_rsclient_prefix_cmd
,
10796 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
10800 "Information about Route Server Client\n"
10802 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10804 DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix
,
10805 show_bgp_view_ipv4_safi_rsclient_prefix_cmd
,
10806 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
10812 "Address Family modifier\n"
10813 "Address Family modifier\n"
10814 "Information about Route Server Client\n"
10816 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10822 /* BGP structure lookup. */
10825 bgp
= bgp_lookup_by_name (argv
[0]);
10828 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10829 return CMD_WARNING
;
10834 bgp
= bgp_get_default ();
10837 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10838 return CMD_WARNING
;
10843 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[2]);
10844 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10846 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
10847 safi
= (strncmp (argv
[0], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10851 return CMD_WARNING
;
10853 if (! peer
->afc
[AFI_IP
][safi
])
10855 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10857 return CMD_WARNING
;
10860 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][safi
],
10861 PEER_FLAG_RSERVER_CLIENT
))
10863 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10865 return CMD_WARNING
;
10868 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][safi
],
10869 (argc
== 4) ? argv
[3] : argv
[2],
10870 AFI_IP
, safi
, NULL
, 1);
10873 ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix
,
10874 show_bgp_ipv4_safi_rsclient_prefix_cmd
,
10875 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
10879 "Address Family modifier\n"
10880 "Address Family modifier\n"
10881 "Information about Route Server Client\n"
10883 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10886 DEFUN (show_bgp_view_neighbor_routes
,
10887 show_bgp_view_neighbor_routes_cmd
,
10888 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
10893 "Detailed information on TCP and BGP neighbor connections\n"
10894 "Neighbor to display information about\n"
10895 "Neighbor to display information about\n"
10896 "Display routes learned from neighbor\n")
10901 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10903 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10906 return CMD_WARNING
;
10908 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
10909 bgp_show_type_neighbor
);
10912 ALIAS (show_bgp_view_neighbor_routes
,
10913 show_bgp_view_ipv6_neighbor_routes_cmd
,
10914 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
10920 "Detailed information on TCP and BGP neighbor connections\n"
10921 "Neighbor to display information about\n"
10922 "Neighbor to display information about\n"
10923 "Display routes learned from neighbor\n")
10925 DEFUN (show_bgp_view_neighbor_damp
,
10926 show_bgp_view_neighbor_damp_cmd
,
10927 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10932 "Detailed information on TCP and BGP neighbor connections\n"
10933 "Neighbor to display information about\n"
10934 "Neighbor to display information about\n"
10935 "Display the dampened routes received from neighbor\n")
10940 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10942 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10945 return CMD_WARNING
;
10947 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
10948 bgp_show_type_damp_neighbor
);
10951 ALIAS (show_bgp_view_neighbor_damp
,
10952 show_bgp_view_ipv6_neighbor_damp_cmd
,
10953 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10959 "Detailed information on TCP and BGP neighbor connections\n"
10960 "Neighbor to display information about\n"
10961 "Neighbor to display information about\n"
10962 "Display the dampened routes received from neighbor\n")
10964 DEFUN (show_bgp_view_neighbor_flap
,
10965 show_bgp_view_neighbor_flap_cmd
,
10966 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10971 "Detailed information on TCP and BGP neighbor connections\n"
10972 "Neighbor to display information about\n"
10973 "Neighbor to display information about\n"
10974 "Display flap statistics of the routes learned from neighbor\n")
10979 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10981 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10984 return CMD_WARNING
;
10986 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
10987 bgp_show_type_flap_neighbor
);
10990 ALIAS (show_bgp_view_neighbor_flap
,
10991 show_bgp_view_ipv6_neighbor_flap_cmd
,
10992 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10998 "Detailed information on TCP and BGP neighbor connections\n"
10999 "Neighbor to display information about\n"
11000 "Neighbor to display information about\n"
11001 "Display flap statistics of the routes learned from neighbor\n")
11003 ALIAS (show_bgp_view_neighbor_routes
,
11004 show_bgp_neighbor_routes_cmd
,
11005 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
11008 "Detailed information on TCP and BGP neighbor connections\n"
11009 "Neighbor to display information about\n"
11010 "Neighbor to display information about\n"
11011 "Display routes learned from neighbor\n")
11014 ALIAS (show_bgp_view_neighbor_routes
,
11015 show_bgp_ipv6_neighbor_routes_cmd
,
11016 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
11020 "Detailed information on TCP and BGP neighbor connections\n"
11021 "Neighbor to display information about\n"
11022 "Neighbor to display information about\n"
11023 "Display routes learned from neighbor\n")
11026 ALIAS (show_bgp_view_neighbor_routes
,
11027 ipv6_bgp_neighbor_routes_cmd
,
11028 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
11032 "Detailed information on TCP and BGP neighbor connections\n"
11033 "Neighbor to display information about\n"
11034 "Neighbor to display information about\n"
11035 "Display routes learned from neighbor\n")
11038 DEFUN (ipv6_mbgp_neighbor_routes
,
11039 ipv6_mbgp_neighbor_routes_cmd
,
11040 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
11044 "Detailed information on TCP and BGP neighbor connections\n"
11045 "Neighbor to display information about\n"
11046 "Neighbor to display information about\n"
11047 "Display routes learned from neighbor\n")
11051 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
11053 return CMD_WARNING
;
11055 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
,
11056 bgp_show_type_neighbor
);
11059 ALIAS (show_bgp_view_neighbor_flap
,
11060 show_bgp_neighbor_flap_cmd
,
11061 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
11064 "Detailed information on TCP and BGP neighbor connections\n"
11065 "Neighbor to display information about\n"
11066 "Neighbor to display information about\n"
11067 "Display flap statistics of the routes learned from neighbor\n")
11069 ALIAS (show_bgp_view_neighbor_flap
,
11070 show_bgp_ipv6_neighbor_flap_cmd
,
11071 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
11075 "Detailed information on TCP and BGP neighbor connections\n"
11076 "Neighbor to display information about\n"
11077 "Neighbor to display information about\n"
11078 "Display flap statistics of the routes learned from neighbor\n")
11080 ALIAS (show_bgp_view_neighbor_damp
,
11081 show_bgp_neighbor_damp_cmd
,
11082 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
11085 "Detailed information on TCP and BGP neighbor connections\n"
11086 "Neighbor to display information about\n"
11087 "Neighbor to display information about\n"
11088 "Display the dampened routes received from neighbor\n")
11090 ALIAS (show_bgp_view_neighbor_damp
,
11091 show_bgp_ipv6_neighbor_damp_cmd
,
11092 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
11096 "Detailed information on TCP and BGP neighbor connections\n"
11097 "Neighbor to display information about\n"
11098 "Neighbor to display information about\n"
11099 "Display the dampened routes received from neighbor\n")
11101 DEFUN (show_bgp_view_rsclient
,
11102 show_bgp_view_rsclient_cmd
,
11103 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
11108 "Information about Route Server Client\n"
11111 struct bgp_table
*table
;
11115 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
11117 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
11120 return CMD_WARNING
;
11122 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
11124 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
11126 return CMD_WARNING
;
11129 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
11130 PEER_FLAG_RSERVER_CLIENT
))
11132 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
11134 return CMD_WARNING
;
11137 table
= peer
->rib
[AFI_IP6
][SAFI_UNICAST
];
11139 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
11142 ALIAS (show_bgp_view_rsclient
,
11143 show_bgp_rsclient_cmd
,
11144 "show bgp rsclient (A.B.C.D|X:X::X:X)",
11147 "Information about Route Server Client\n"
11150 DEFUN (show_bgp_view_ipv6_safi_rsclient
,
11151 show_bgp_view_ipv6_safi_rsclient_cmd
,
11152 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
11158 "Address Family modifier\n"
11159 "Address Family modifier\n"
11160 "Information about Route Server Client\n"
11163 struct bgp_table
*table
;
11168 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[2]);
11169 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
11171 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
11172 safi
= (strncmp (argv
[0], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
11176 return CMD_WARNING
;
11178 if (! peer
->afc
[AFI_IP6
][safi
])
11180 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
11182 return CMD_WARNING
;
11185 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][safi
],
11186 PEER_FLAG_RSERVER_CLIENT
))
11188 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
11190 return CMD_WARNING
;
11193 table
= peer
->rib
[AFI_IP6
][safi
];
11195 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
11198 ALIAS (show_bgp_view_ipv6_safi_rsclient
,
11199 show_bgp_ipv6_safi_rsclient_cmd
,
11200 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
11204 "Address Family modifier\n"
11205 "Address Family modifier\n"
11206 "Information about Route Server Client\n"
11209 DEFUN (show_bgp_view_rsclient_route
,
11210 show_bgp_view_rsclient_route_cmd
,
11211 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
11216 "Information about Route Server Client\n"
11218 "Network in the BGP routing table to display\n")
11223 /* BGP structure lookup. */
11226 bgp
= bgp_lookup_by_name (argv
[0]);
11229 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
11230 return CMD_WARNING
;
11235 bgp
= bgp_get_default ();
11238 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
11239 return CMD_WARNING
;
11244 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
11246 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
11249 return CMD_WARNING
;
11251 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
11253 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
11255 return CMD_WARNING
;
11258 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
11259 PEER_FLAG_RSERVER_CLIENT
))
11261 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
11263 return CMD_WARNING
;
11266 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][SAFI_UNICAST
],
11267 (argc
== 3) ? argv
[2] : argv
[1],
11268 AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
11271 ALIAS (show_bgp_view_rsclient_route
,
11272 show_bgp_rsclient_route_cmd
,
11273 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
11276 "Information about Route Server Client\n"
11278 "Network in the BGP routing table to display\n")
11280 DEFUN (show_bgp_view_ipv6_safi_rsclient_route
,
11281 show_bgp_view_ipv6_safi_rsclient_route_cmd
,
11282 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
11288 "Address Family modifier\n"
11289 "Address Family modifier\n"
11290 "Information about Route Server Client\n"
11292 "Network in the BGP routing table to display\n")
11298 /* BGP structure lookup. */
11301 bgp
= bgp_lookup_by_name (argv
[0]);
11304 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
11305 return CMD_WARNING
;
11310 bgp
= bgp_get_default ();
11313 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
11314 return CMD_WARNING
;
11319 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[2]);
11320 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
11322 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
11323 safi
= (strncmp (argv
[0], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
11327 return CMD_WARNING
;
11329 if (! peer
->afc
[AFI_IP6
][safi
])
11331 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
11333 return CMD_WARNING
;
11336 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][safi
],
11337 PEER_FLAG_RSERVER_CLIENT
))
11339 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
11341 return CMD_WARNING
;
11344 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][safi
],
11345 (argc
== 4) ? argv
[3] : argv
[2],
11346 AFI_IP6
, safi
, NULL
, 0);
11349 ALIAS (show_bgp_view_ipv6_safi_rsclient_route
,
11350 show_bgp_ipv6_safi_rsclient_route_cmd
,
11351 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
11355 "Address Family modifier\n"
11356 "Address Family modifier\n"
11357 "Information about Route Server Client\n"
11359 "Network in the BGP routing table to display\n")
11361 DEFUN (show_bgp_view_rsclient_prefix
,
11362 show_bgp_view_rsclient_prefix_cmd
,
11363 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
11368 "Information about Route Server Client\n"
11370 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
11375 /* BGP structure lookup. */
11378 bgp
= bgp_lookup_by_name (argv
[0]);
11381 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
11382 return CMD_WARNING
;
11387 bgp
= bgp_get_default ();
11390 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
11391 return CMD_WARNING
;
11396 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
11398 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
11401 return CMD_WARNING
;
11403 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
11405 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
11407 return CMD_WARNING
;
11410 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
11411 PEER_FLAG_RSERVER_CLIENT
))
11413 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
11415 return CMD_WARNING
;
11418 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][SAFI_UNICAST
],
11419 (argc
== 3) ? argv
[2] : argv
[1],
11420 AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
11423 ALIAS (show_bgp_view_rsclient_prefix
,
11424 show_bgp_rsclient_prefix_cmd
,
11425 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
11428 "Information about Route Server Client\n"
11430 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
11432 DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix
,
11433 show_bgp_view_ipv6_safi_rsclient_prefix_cmd
,
11434 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
11440 "Address Family modifier\n"
11441 "Address Family modifier\n"
11442 "Information about Route Server Client\n"
11444 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
11450 /* BGP structure lookup. */
11453 bgp
= bgp_lookup_by_name (argv
[0]);
11456 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
11457 return CMD_WARNING
;
11462 bgp
= bgp_get_default ();
11465 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
11466 return CMD_WARNING
;
11471 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[2]);
11472 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
11474 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
11475 safi
= (strncmp (argv
[0], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
11479 return CMD_WARNING
;
11481 if (! peer
->afc
[AFI_IP6
][safi
])
11483 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
11485 return CMD_WARNING
;
11488 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][safi
],
11489 PEER_FLAG_RSERVER_CLIENT
))
11491 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
11493 return CMD_WARNING
;
11496 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][safi
],
11497 (argc
== 4) ? argv
[3] : argv
[2],
11498 AFI_IP6
, safi
, NULL
, 1);
11501 ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix
,
11502 show_bgp_ipv6_safi_rsclient_prefix_cmd
,
11503 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
11507 "Address Family modifier\n"
11508 "Address Family modifier\n"
11509 "Information about Route Server Client\n"
11511 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
11513 #endif /* HAVE_IPV6 */
11515 struct bgp_table
*bgp_distance_table
;
11517 struct bgp_distance
11519 /* Distance value for the IP source prefix. */
11522 /* Name of the access-list to be matched. */
11526 static struct bgp_distance
*
11527 bgp_distance_new (void)
11529 return XCALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
11533 bgp_distance_free (struct bgp_distance
*bdistance
)
11535 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
11539 bgp_distance_set (struct vty
*vty
, const char *distance_str
,
11540 const char *ip_str
, const char *access_list_str
)
11543 struct prefix_ipv4 p
;
11545 struct bgp_node
*rn
;
11546 struct bgp_distance
*bdistance
;
11548 ret
= str2prefix_ipv4 (ip_str
, &p
);
11551 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
11552 return CMD_WARNING
;
11555 distance
= atoi (distance_str
);
11557 /* Get BGP distance node. */
11558 rn
= bgp_node_get (bgp_distance_table
, (struct prefix
*) &p
);
11561 bdistance
= rn
->info
;
11562 bgp_unlock_node (rn
);
11566 bdistance
= bgp_distance_new ();
11567 rn
->info
= bdistance
;
11570 /* Set distance value. */
11571 bdistance
->distance
= distance
;
11573 /* Reset access-list configuration. */
11574 if (bdistance
->access_list
)
11576 free (bdistance
->access_list
);
11577 bdistance
->access_list
= NULL
;
11579 if (access_list_str
)
11580 bdistance
->access_list
= strdup (access_list_str
);
11582 return CMD_SUCCESS
;
11586 bgp_distance_unset (struct vty
*vty
, const char *distance_str
,
11587 const char *ip_str
, const char *access_list_str
)
11590 struct prefix_ipv4 p
;
11592 struct bgp_node
*rn
;
11593 struct bgp_distance
*bdistance
;
11595 ret
= str2prefix_ipv4 (ip_str
, &p
);
11598 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
11599 return CMD_WARNING
;
11602 distance
= atoi (distance_str
);
11604 rn
= bgp_node_lookup (bgp_distance_table
, (struct prefix
*)&p
);
11607 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
11608 return CMD_WARNING
;
11611 bdistance
= rn
->info
;
11613 if (bdistance
->access_list
)
11614 free (bdistance
->access_list
);
11615 bgp_distance_free (bdistance
);
11618 bgp_unlock_node (rn
);
11619 bgp_unlock_node (rn
);
11621 return CMD_SUCCESS
;
11624 /* Apply BGP information to distance method. */
11626 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, struct bgp
*bgp
)
11628 struct bgp_node
*rn
;
11629 struct prefix_ipv4 q
;
11631 struct bgp_distance
*bdistance
;
11632 struct access_list
*alist
;
11633 struct bgp_static
*bgp_static
;
11638 if (p
->family
!= AF_INET
)
11641 peer
= rinfo
->peer
;
11643 if (peer
->su
.sa
.sa_family
!= AF_INET
)
11646 memset (&q
, 0, sizeof (struct prefix_ipv4
));
11647 q
.family
= AF_INET
;
11648 q
.prefix
= peer
->su
.sin
.sin_addr
;
11649 q
.prefixlen
= IPV4_MAX_BITLEN
;
11651 /* Check source address. */
11652 rn
= bgp_node_match (bgp_distance_table
, (struct prefix
*) &q
);
11655 bdistance
= rn
->info
;
11656 bgp_unlock_node (rn
);
11658 if (bdistance
->access_list
)
11660 alist
= access_list_lookup (AFI_IP
, bdistance
->access_list
);
11661 if (alist
&& access_list_apply (alist
, p
) == FILTER_PERMIT
)
11662 return bdistance
->distance
;
11665 return bdistance
->distance
;
11668 /* Backdoor check. */
11669 rn
= bgp_node_lookup (bgp
->route
[AFI_IP
][SAFI_UNICAST
], p
);
11672 bgp_static
= rn
->info
;
11673 bgp_unlock_node (rn
);
11675 if (bgp_static
->backdoor
)
11677 if (bgp
->distance_local
)
11678 return bgp
->distance_local
;
11680 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
11684 if (peer_sort (peer
) == BGP_PEER_EBGP
)
11686 if (bgp
->distance_ebgp
)
11687 return bgp
->distance_ebgp
;
11688 return ZEBRA_EBGP_DISTANCE_DEFAULT
;
11692 if (bgp
->distance_ibgp
)
11693 return bgp
->distance_ibgp
;
11694 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
11698 DEFUN (bgp_distance
,
11700 "distance bgp <1-255> <1-255> <1-255>",
11701 "Define an administrative distance\n"
11703 "Distance for routes external to the AS\n"
11704 "Distance for routes internal to the AS\n"
11705 "Distance for local routes\n")
11711 bgp
->distance_ebgp
= atoi (argv
[0]);
11712 bgp
->distance_ibgp
= atoi (argv
[1]);
11713 bgp
->distance_local
= atoi (argv
[2]);
11714 return CMD_SUCCESS
;
11717 DEFUN (no_bgp_distance
,
11718 no_bgp_distance_cmd
,
11719 "no distance bgp <1-255> <1-255> <1-255>",
11721 "Define an administrative distance\n"
11723 "Distance for routes external to the AS\n"
11724 "Distance for routes internal to the AS\n"
11725 "Distance for local routes\n")
11731 bgp
->distance_ebgp
= 0;
11732 bgp
->distance_ibgp
= 0;
11733 bgp
->distance_local
= 0;
11734 return CMD_SUCCESS
;
11737 ALIAS (no_bgp_distance
,
11738 no_bgp_distance2_cmd
,
11741 "Define an administrative distance\n"
11744 DEFUN (bgp_distance_source
,
11745 bgp_distance_source_cmd
,
11746 "distance <1-255> A.B.C.D/M",
11747 "Define an administrative distance\n"
11748 "Administrative distance\n"
11749 "IP source prefix\n")
11751 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
11752 return CMD_SUCCESS
;
11755 DEFUN (no_bgp_distance_source
,
11756 no_bgp_distance_source_cmd
,
11757 "no distance <1-255> A.B.C.D/M",
11759 "Define an administrative distance\n"
11760 "Administrative distance\n"
11761 "IP source prefix\n")
11763 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
11764 return CMD_SUCCESS
;
11767 DEFUN (bgp_distance_source_access_list
,
11768 bgp_distance_source_access_list_cmd
,
11769 "distance <1-255> A.B.C.D/M WORD",
11770 "Define an administrative distance\n"
11771 "Administrative distance\n"
11772 "IP source prefix\n"
11773 "Access list name\n")
11775 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
11776 return CMD_SUCCESS
;
11779 DEFUN (no_bgp_distance_source_access_list
,
11780 no_bgp_distance_source_access_list_cmd
,
11781 "no distance <1-255> A.B.C.D/M WORD",
11783 "Define an administrative distance\n"
11784 "Administrative distance\n"
11785 "IP source prefix\n"
11786 "Access list name\n")
11788 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
11789 return CMD_SUCCESS
;
11792 DEFUN (bgp_damp_set
,
11794 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
11795 "BGP Specific commands\n"
11796 "Enable route-flap dampening\n"
11797 "Half-life time for the penalty\n"
11798 "Value to start reusing a route\n"
11799 "Value to start suppressing a route\n"
11800 "Maximum duration to suppress a stable route\n")
11803 int half
= DEFAULT_HALF_LIFE
* 60;
11804 int reuse
= DEFAULT_REUSE
;
11805 int suppress
= DEFAULT_SUPPRESS
;
11806 int max
= 4 * half
;
11810 half
= atoi (argv
[0]) * 60;
11811 reuse
= atoi (argv
[1]);
11812 suppress
= atoi (argv
[2]);
11813 max
= atoi (argv
[3]) * 60;
11815 else if (argc
== 1)
11817 half
= atoi (argv
[0]) * 60;
11822 return bgp_damp_enable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
),
11823 half
, reuse
, suppress
, max
);
11826 ALIAS (bgp_damp_set
,
11828 "bgp dampening <1-45>",
11829 "BGP Specific commands\n"
11830 "Enable route-flap dampening\n"
11831 "Half-life time for the penalty\n")
11833 ALIAS (bgp_damp_set
,
11836 "BGP Specific commands\n"
11837 "Enable route-flap dampening\n")
11839 DEFUN (bgp_damp_unset
,
11840 bgp_damp_unset_cmd
,
11841 "no bgp dampening",
11843 "BGP Specific commands\n"
11844 "Enable route-flap dampening\n")
11849 return bgp_damp_disable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
));
11852 ALIAS (bgp_damp_unset
,
11853 bgp_damp_unset2_cmd
,
11854 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
11856 "BGP Specific commands\n"
11857 "Enable route-flap dampening\n"
11858 "Half-life time for the penalty\n"
11859 "Value to start reusing a route\n"
11860 "Value to start suppressing a route\n"
11861 "Maximum duration to suppress a stable route\n")
11863 DEFUN (show_ip_bgp_dampened_paths
,
11864 show_ip_bgp_dampened_paths_cmd
,
11865 "show ip bgp dampened-paths",
11869 "Display paths suppressed due to dampening\n")
11871 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_dampend_paths
,
11875 DEFUN (show_ip_bgp_flap_statistics
,
11876 show_ip_bgp_flap_statistics_cmd
,
11877 "show ip bgp flap-statistics",
11881 "Display flap statistics of routes\n")
11883 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
11884 bgp_show_type_flap_statistics
, NULL
);
11887 /* Display specified route of BGP table. */
11889 bgp_clear_damp_route (struct vty
*vty
, const char *view_name
,
11890 const char *ip_str
, afi_t afi
, safi_t safi
,
11891 struct prefix_rd
*prd
, int prefix_check
)
11894 struct prefix match
;
11895 struct bgp_node
*rn
;
11896 struct bgp_node
*rm
;
11897 struct bgp_info
*ri
;
11898 struct bgp_info
*ri_temp
;
11900 struct bgp_table
*table
;
11902 /* BGP structure lookup. */
11905 bgp
= bgp_lookup_by_name (view_name
);
11908 vty_out (vty
, "%% Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
11909 return CMD_WARNING
;
11914 bgp
= bgp_get_default ();
11917 vty_out (vty
, "%% No BGP process is configured%s", VTY_NEWLINE
);
11918 return CMD_WARNING
;
11922 /* Check IP address argument. */
11923 ret
= str2prefix (ip_str
, &match
);
11926 vty_out (vty
, "%% address is malformed%s", VTY_NEWLINE
);
11927 return CMD_WARNING
;
11930 match
.family
= afi2family (afi
);
11932 if (safi
== SAFI_MPLS_VPN
)
11934 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][SAFI_MPLS_VPN
]); rn
; rn
= bgp_route_next (rn
))
11936 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
11939 if ((table
= rn
->info
) != NULL
)
11940 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
11942 if (! prefix_check
|| rm
->p
.prefixlen
== match
.prefixlen
)
11947 if (ri
->extra
&& ri
->extra
->damp_info
)
11949 ri_temp
= ri
->next
;
11950 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
11958 bgp_unlock_node (rm
);
11964 if ((rn
= bgp_node_match (bgp
->rib
[afi
][safi
], &match
)) != NULL
)
11966 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
11971 if (ri
->extra
&& ri
->extra
->damp_info
)
11973 ri_temp
= ri
->next
;
11974 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
11982 bgp_unlock_node (rn
);
11986 return CMD_SUCCESS
;
11989 DEFUN (clear_ip_bgp_dampening
,
11990 clear_ip_bgp_dampening_cmd
,
11991 "clear ip bgp dampening",
11995 "Clear route flap dampening information\n")
11997 bgp_damp_info_clean ();
11998 return CMD_SUCCESS
;
12001 DEFUN (clear_ip_bgp_dampening_prefix
,
12002 clear_ip_bgp_dampening_prefix_cmd
,
12003 "clear ip bgp dampening A.B.C.D/M",
12007 "Clear route flap dampening information\n"
12008 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
12010 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
12011 SAFI_UNICAST
, NULL
, 1);
12014 DEFUN (clear_ip_bgp_dampening_address
,
12015 clear_ip_bgp_dampening_address_cmd
,
12016 "clear ip bgp dampening A.B.C.D",
12020 "Clear route flap dampening information\n"
12021 "Network to clear damping information\n")
12023 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
12024 SAFI_UNICAST
, NULL
, 0);
12027 DEFUN (clear_ip_bgp_dampening_address_mask
,
12028 clear_ip_bgp_dampening_address_mask_cmd
,
12029 "clear ip bgp dampening A.B.C.D A.B.C.D",
12033 "Clear route flap dampening information\n"
12034 "Network to clear damping information\n"
12038 char prefix_str
[BUFSIZ
];
12040 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
12043 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
12044 return CMD_WARNING
;
12047 return bgp_clear_damp_route (vty
, NULL
, prefix_str
, AFI_IP
,
12048 SAFI_UNICAST
, NULL
, 0);
12052 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
12053 afi_t afi
, safi_t safi
, int *write
)
12055 struct bgp_node
*prn
;
12056 struct bgp_node
*rn
;
12057 struct bgp_table
*table
;
12059 struct prefix_rd
*prd
;
12060 struct bgp_static
*bgp_static
;
12062 char buf
[SU_ADDRSTRLEN
];
12063 char rdbuf
[RD_ADDRSTRLEN
];
12065 /* Network configuration. */
12066 for (prn
= bgp_table_top (bgp
->route
[afi
][safi
]); prn
; prn
= bgp_route_next (prn
))
12067 if ((table
= prn
->info
) != NULL
)
12068 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
12069 if ((bgp_static
= rn
->info
) != NULL
)
12072 prd
= (struct prefix_rd
*) &prn
->p
;
12074 /* "address-family" display. */
12075 bgp_config_write_family_header (vty
, afi
, safi
, write
);
12077 /* "network" configuration display. */
12078 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
12079 label
= decode_label (bgp_static
->tag
);
12081 vty_out (vty
, " network %s/%d rd %s tag %d",
12082 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
12085 vty_out (vty
, "%s", VTY_NEWLINE
);
12090 /* Configuration of static route announcement and aggregate
12093 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
12094 afi_t afi
, safi_t safi
, int *write
)
12096 struct bgp_node
*rn
;
12098 struct bgp_static
*bgp_static
;
12099 struct bgp_aggregate
*bgp_aggregate
;
12100 char buf
[SU_ADDRSTRLEN
];
12102 if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
12103 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
12105 /* Network configuration. */
12106 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
12107 if ((bgp_static
= rn
->info
) != NULL
)
12111 /* "address-family" display. */
12112 bgp_config_write_family_header (vty
, afi
, safi
, write
);
12114 /* "network" configuration display. */
12115 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
12117 u_int32_t destination
;
12118 struct in_addr netmask
;
12120 destination
= ntohl (p
->u
.prefix4
.s_addr
);
12121 masklen2ip (p
->prefixlen
, &netmask
);
12122 vty_out (vty
, " network %s",
12123 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
));
12125 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
12126 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
12127 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
12128 || p
->u
.prefix4
.s_addr
== 0)
12130 /* Natural mask is not display. */
12133 vty_out (vty
, " mask %s", inet_ntoa (netmask
));
12137 vty_out (vty
, " network %s/%d",
12138 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
12142 if (bgp_static
->rmap
.name
)
12143 vty_out (vty
, " route-map %s", bgp_static
->rmap
.name
);
12146 if (bgp_static
->backdoor
)
12147 vty_out (vty
, " backdoor");
12150 vty_out (vty
, "%s", VTY_NEWLINE
);
12153 /* Aggregate-address configuration. */
12154 for (rn
= bgp_table_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
12155 if ((bgp_aggregate
= rn
->info
) != NULL
)
12159 /* "address-family" display. */
12160 bgp_config_write_family_header (vty
, afi
, safi
, write
);
12162 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
12164 struct in_addr netmask
;
12166 masklen2ip (p
->prefixlen
, &netmask
);
12167 vty_out (vty
, " aggregate-address %s %s",
12168 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
12169 inet_ntoa (netmask
));
12173 vty_out (vty
, " aggregate-address %s/%d",
12174 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
12178 if (bgp_aggregate
->as_set
)
12179 vty_out (vty
, " as-set");
12181 if (bgp_aggregate
->summary_only
)
12182 vty_out (vty
, " summary-only");
12184 vty_out (vty
, "%s", VTY_NEWLINE
);
12191 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
)
12193 struct bgp_node
*rn
;
12194 struct bgp_distance
*bdistance
;
12196 /* Distance configuration. */
12197 if (bgp
->distance_ebgp
12198 && bgp
->distance_ibgp
12199 && bgp
->distance_local
12200 && (bgp
->distance_ebgp
!= ZEBRA_EBGP_DISTANCE_DEFAULT
12201 || bgp
->distance_ibgp
!= ZEBRA_IBGP_DISTANCE_DEFAULT
12202 || bgp
->distance_local
!= ZEBRA_IBGP_DISTANCE_DEFAULT
))
12203 vty_out (vty
, " distance bgp %d %d %d%s",
12204 bgp
->distance_ebgp
, bgp
->distance_ibgp
, bgp
->distance_local
,
12207 for (rn
= bgp_table_top (bgp_distance_table
); rn
; rn
= bgp_route_next (rn
))
12208 if ((bdistance
= rn
->info
) != NULL
)
12210 vty_out (vty
, " distance %d %s/%d %s%s", bdistance
->distance
,
12211 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
12212 bdistance
->access_list
? bdistance
->access_list
: "",
12219 /* Allocate routing table structure and install commands. */
12221 bgp_route_init (void)
12223 /* Init BGP distance table. */
12224 bgp_distance_table
= bgp_table_init (AFI_IP
, SAFI_UNICAST
);
12226 /* IPv4 BGP commands. */
12227 install_element (BGP_NODE
, &bgp_network_cmd
);
12228 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
12229 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
12230 install_element (BGP_NODE
, &bgp_network_route_map_cmd
);
12231 install_element (BGP_NODE
, &bgp_network_mask_route_map_cmd
);
12232 install_element (BGP_NODE
, &bgp_network_mask_natural_route_map_cmd
);
12233 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
12234 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
12235 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
12236 install_element (BGP_NODE
, &no_bgp_network_cmd
);
12237 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
12238 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
12239 install_element (BGP_NODE
, &no_bgp_network_route_map_cmd
);
12240 install_element (BGP_NODE
, &no_bgp_network_mask_route_map_cmd
);
12241 install_element (BGP_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
12242 install_element (BGP_NODE
, &no_bgp_network_backdoor_cmd
);
12243 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_cmd
);
12244 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_cmd
);
12246 install_element (BGP_NODE
, &aggregate_address_cmd
);
12247 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
12248 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
12249 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
12250 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
12251 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
12252 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
12253 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
12254 install_element (BGP_NODE
, &aggregate_address_summary_as_set_cmd
);
12255 install_element (BGP_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
12256 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
12257 install_element (BGP_NODE
, &no_aggregate_address_summary_only_cmd
);
12258 install_element (BGP_NODE
, &no_aggregate_address_as_set_cmd
);
12259 install_element (BGP_NODE
, &no_aggregate_address_as_set_summary_cmd
);
12260 install_element (BGP_NODE
, &no_aggregate_address_summary_as_set_cmd
);
12261 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
12262 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
12263 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_cmd
);
12264 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
12265 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
12267 /* IPv4 unicast configuration. */
12268 install_element (BGP_IPV4_NODE
, &bgp_network_cmd
);
12269 install_element (BGP_IPV4_NODE
, &bgp_network_mask_cmd
);
12270 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_cmd
);
12271 install_element (BGP_IPV4_NODE
, &bgp_network_route_map_cmd
);
12272 install_element (BGP_IPV4_NODE
, &bgp_network_mask_route_map_cmd
);
12273 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_route_map_cmd
);
12274 install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
12275 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_cmd
);
12276 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_cmd
);
12277 install_element (BGP_IPV4_NODE
, &no_bgp_network_route_map_cmd
);
12278 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_route_map_cmd
);
12279 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
12281 install_element (BGP_IPV4_NODE
, &aggregate_address_cmd
);
12282 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_cmd
);
12283 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_only_cmd
);
12284 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_only_cmd
);
12285 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_cmd
);
12286 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_cmd
);
12287 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_summary_cmd
);
12288 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
12289 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_as_set_cmd
);
12290 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
12291 install_element (BGP_IPV4_NODE
, &no_aggregate_address_cmd
);
12292 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_only_cmd
);
12293 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_cmd
);
12294 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_summary_cmd
);
12295 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_as_set_cmd
);
12296 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_cmd
);
12297 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
12298 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_cmd
);
12299 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
12300 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
12302 /* IPv4 multicast configuration. */
12303 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
12304 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
12305 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
12306 install_element (BGP_IPV4M_NODE
, &bgp_network_route_map_cmd
);
12307 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_route_map_cmd
);
12308 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_route_map_cmd
);
12309 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
12310 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
12311 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
12312 install_element (BGP_IPV4M_NODE
, &no_bgp_network_route_map_cmd
);
12313 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_route_map_cmd
);
12314 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
12315 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
12316 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
12317 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
12318 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
12319 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
12320 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
12321 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
12322 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
12323 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_as_set_cmd
);
12324 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
12325 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
12326 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_only_cmd
);
12327 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_cmd
);
12328 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_summary_cmd
);
12329 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_as_set_cmd
);
12330 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
12331 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
12332 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_cmd
);
12333 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
12334 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
12336 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
12337 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
12338 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_cmd
);
12339 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
12340 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
12341 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_cmd
);
12342 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
12343 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
12344 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
12345 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
12346 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
12347 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
12348 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
12349 install_element (VIEW_NODE
, &show_ip_bgp_view_cmd
);
12350 install_element (VIEW_NODE
, &show_ip_bgp_view_route_cmd
);
12351 install_element (VIEW_NODE
, &show_ip_bgp_view_prefix_cmd
);
12352 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
12353 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
12354 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
12355 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
12356 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
12357 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
12358 install_element (VIEW_NODE
, &show_ip_bgp_route_map_cmd
);
12359 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
12360 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
12361 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
12362 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
12363 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
12364 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
12365 install_element (VIEW_NODE
, &show_ip_bgp_community2_cmd
);
12366 install_element (VIEW_NODE
, &show_ip_bgp_community3_cmd
);
12367 install_element (VIEW_NODE
, &show_ip_bgp_community4_cmd
);
12368 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
12369 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
12370 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
12371 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
12372 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_community_all_cmd
);
12373 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_community_cmd
);
12374 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_community2_cmd
);
12375 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_community3_cmd
);
12376 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_community4_cmd
);
12377 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
12378 install_element (VIEW_NODE
, &show_ip_bgp_community2_exact_cmd
);
12379 install_element (VIEW_NODE
, &show_ip_bgp_community3_exact_cmd
);
12380 install_element (VIEW_NODE
, &show_ip_bgp_community4_exact_cmd
);
12381 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
12382 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
12383 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
12384 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
12385 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
12386 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
12387 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
12388 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
12389 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
12390 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
12391 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
12392 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
12393 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
12394 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
12395 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd
);
12396 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
12397 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
12398 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
12399 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
12400 install_element (VIEW_NODE
, &show_ip_bgp_dampened_paths_cmd
);
12401 install_element (VIEW_NODE
, &show_ip_bgp_flap_statistics_cmd
);
12402 install_element (VIEW_NODE
, &show_ip_bgp_flap_address_cmd
);
12403 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_cmd
);
12404 install_element (VIEW_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
12405 install_element (VIEW_NODE
, &show_ip_bgp_flap_regexp_cmd
);
12406 install_element (VIEW_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
12407 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
12408 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
12409 install_element (VIEW_NODE
, &show_ip_bgp_flap_route_map_cmd
);
12410 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
12411 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
12412 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_cmd
);
12413 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_rsclient_cmd
);
12414 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_route_cmd
);
12415 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_rsclient_route_cmd
);
12416 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
12417 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_rsclient_prefix_cmd
);
12418 install_element (VIEW_NODE
, &show_ip_bgp_view_neighbor_advertised_route_cmd
);
12419 install_element (VIEW_NODE
, &show_ip_bgp_view_neighbor_received_routes_cmd
);
12420 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_cmd
);
12421 install_element (VIEW_NODE
, &show_bgp_view_ipv4_safi_rsclient_cmd
);
12422 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
12423 install_element (VIEW_NODE
, &show_bgp_view_ipv4_safi_rsclient_route_cmd
);
12424 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
12425 install_element (VIEW_NODE
, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd
);
12427 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
12428 install_element (RESTRICTED_NODE
, &show_ip_bgp_route_cmd
);
12429 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_route_cmd
);
12430 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_route_cmd
);
12431 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
12432 install_element (RESTRICTED_NODE
, &show_ip_bgp_prefix_cmd
);
12433 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
12434 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
12435 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
12436 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
12437 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_route_cmd
);
12438 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_prefix_cmd
);
12439 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_cmd
);
12440 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_cmd
);
12441 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_cmd
);
12442 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_cmd
);
12443 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_cmd
);
12444 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
12445 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
12446 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
12447 install_element (RESTRICTED_NODE
, &show_bgp_view_afi_safi_community_all_cmd
);
12448 install_element (RESTRICTED_NODE
, &show_bgp_view_afi_safi_community_cmd
);
12449 install_element (RESTRICTED_NODE
, &show_bgp_view_afi_safi_community2_cmd
);
12450 install_element (RESTRICTED_NODE
, &show_bgp_view_afi_safi_community3_cmd
);
12451 install_element (RESTRICTED_NODE
, &show_bgp_view_afi_safi_community4_cmd
);
12452 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_exact_cmd
);
12453 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_exact_cmd
);
12454 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_exact_cmd
);
12455 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_exact_cmd
);
12456 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
12457 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
12458 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
12459 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
12460 install_element (RESTRICTED_NODE
, &show_ip_bgp_rsclient_route_cmd
);
12461 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_rsclient_route_cmd
);
12462 install_element (RESTRICTED_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
12463 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_rsclient_prefix_cmd
);
12464 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
12465 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv4_safi_rsclient_route_cmd
);
12466 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
12467 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd
);
12469 install_element (ENABLE_NODE
, &show_ip_bgp_cmd
);
12470 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cmd
);
12471 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_cmd
);
12472 install_element (ENABLE_NODE
, &show_ip_bgp_route_cmd
);
12473 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_cmd
);
12474 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_route_cmd
);
12475 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
12476 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
12477 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_cmd
);
12478 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
12479 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
12480 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
12481 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
12482 install_element (ENABLE_NODE
, &show_ip_bgp_view_cmd
);
12483 install_element (ENABLE_NODE
, &show_ip_bgp_view_route_cmd
);
12484 install_element (ENABLE_NODE
, &show_ip_bgp_view_prefix_cmd
);
12485 install_element (ENABLE_NODE
, &show_ip_bgp_regexp_cmd
);
12486 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
12487 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_list_cmd
);
12488 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
12489 install_element (ENABLE_NODE
, &show_ip_bgp_filter_list_cmd
);
12490 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
12491 install_element (ENABLE_NODE
, &show_ip_bgp_route_map_cmd
);
12492 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
12493 install_element (ENABLE_NODE
, &show_ip_bgp_cidr_only_cmd
);
12494 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
12495 install_element (ENABLE_NODE
, &show_ip_bgp_community_all_cmd
);
12496 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
12497 install_element (ENABLE_NODE
, &show_ip_bgp_community_cmd
);
12498 install_element (ENABLE_NODE
, &show_ip_bgp_community2_cmd
);
12499 install_element (ENABLE_NODE
, &show_ip_bgp_community3_cmd
);
12500 install_element (ENABLE_NODE
, &show_ip_bgp_community4_cmd
);
12501 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_cmd
);
12502 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
12503 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
12504 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
12505 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_community_all_cmd
);
12506 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_community_cmd
);
12507 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_community2_cmd
);
12508 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_community3_cmd
);
12509 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_community4_cmd
);
12510 install_element (ENABLE_NODE
, &show_ip_bgp_community_exact_cmd
);
12511 install_element (ENABLE_NODE
, &show_ip_bgp_community2_exact_cmd
);
12512 install_element (ENABLE_NODE
, &show_ip_bgp_community3_exact_cmd
);
12513 install_element (ENABLE_NODE
, &show_ip_bgp_community4_exact_cmd
);
12514 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
12515 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
12516 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
12517 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
12518 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_cmd
);
12519 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
12520 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_exact_cmd
);
12521 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
12522 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_longer_cmd
);
12523 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
12524 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
12525 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
12526 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
12527 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
12528 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd
);
12529 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
12530 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
12531 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
12532 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
12533 install_element (ENABLE_NODE
, &show_ip_bgp_dampened_paths_cmd
);
12534 install_element (ENABLE_NODE
, &show_ip_bgp_flap_statistics_cmd
);
12535 install_element (ENABLE_NODE
, &show_ip_bgp_flap_address_cmd
);
12536 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_cmd
);
12537 install_element (ENABLE_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
12538 install_element (ENABLE_NODE
, &show_ip_bgp_flap_regexp_cmd
);
12539 install_element (ENABLE_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
12540 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
12541 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
12542 install_element (ENABLE_NODE
, &show_ip_bgp_flap_route_map_cmd
);
12543 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
12544 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
12545 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_cmd
);
12546 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_rsclient_cmd
);
12547 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_route_cmd
);
12548 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_rsclient_route_cmd
);
12549 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
12550 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_rsclient_prefix_cmd
);
12551 install_element (ENABLE_NODE
, &show_ip_bgp_view_neighbor_advertised_route_cmd
);
12552 install_element (ENABLE_NODE
, &show_ip_bgp_view_neighbor_received_routes_cmd
);
12553 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_cmd
);
12554 install_element (ENABLE_NODE
, &show_bgp_view_ipv4_safi_rsclient_cmd
);
12555 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
12556 install_element (ENABLE_NODE
, &show_bgp_view_ipv4_safi_rsclient_route_cmd
);
12557 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
12558 install_element (ENABLE_NODE
, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd
);
12560 /* BGP dampening clear commands */
12561 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_cmd
);
12562 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_prefix_cmd
);
12563 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_cmd
);
12564 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_mask_cmd
);
12567 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_prefix_counts_cmd
);
12568 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
);
12569 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
);
12571 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_prefix_counts_cmd
);
12573 /* New config IPv6 BGP commands. */
12574 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
12575 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_route_map_cmd
);
12576 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
12577 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_route_map_cmd
);
12579 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
12580 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
12581 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
12582 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
12584 /* Old config IPv6 BGP commands. */
12585 install_element (BGP_NODE
, &old_ipv6_bgp_network_cmd
);
12586 install_element (BGP_NODE
, &old_no_ipv6_bgp_network_cmd
);
12588 install_element (BGP_NODE
, &old_ipv6_aggregate_address_cmd
);
12589 install_element (BGP_NODE
, &old_ipv6_aggregate_address_summary_only_cmd
);
12590 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_cmd
);
12591 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_summary_only_cmd
);
12593 install_element (VIEW_NODE
, &show_bgp_cmd
);
12594 install_element (VIEW_NODE
, &show_bgp_ipv6_cmd
);
12595 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_cmd
);
12596 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
12597 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
12598 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_cmd
);
12599 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
12600 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
12601 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
12602 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
12603 install_element (VIEW_NODE
, &show_bgp_ipv6_regexp_cmd
);
12604 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
12605 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
12606 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
12607 install_element (VIEW_NODE
, &show_bgp_ipv6_filter_list_cmd
);
12608 install_element (VIEW_NODE
, &show_bgp_route_map_cmd
);
12609 install_element (VIEW_NODE
, &show_bgp_ipv6_route_map_cmd
);
12610 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
12611 install_element (VIEW_NODE
, &show_bgp_ipv6_community_all_cmd
);
12612 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
12613 install_element (VIEW_NODE
, &show_bgp_ipv6_community_cmd
);
12614 install_element (VIEW_NODE
, &show_bgp_community2_cmd
);
12615 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_cmd
);
12616 install_element (VIEW_NODE
, &show_bgp_community3_cmd
);
12617 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_cmd
);
12618 install_element (VIEW_NODE
, &show_bgp_community4_cmd
);
12619 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_cmd
);
12620 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
12621 install_element (VIEW_NODE
, &show_bgp_ipv6_community_exact_cmd
);
12622 install_element (VIEW_NODE
, &show_bgp_community2_exact_cmd
);
12623 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
12624 install_element (VIEW_NODE
, &show_bgp_community3_exact_cmd
);
12625 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
12626 install_element (VIEW_NODE
, &show_bgp_community4_exact_cmd
);
12627 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
12628 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
12629 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_cmd
);
12630 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
12631 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
12632 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
12633 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
12634 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
12635 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
12636 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
12637 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
12638 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
12639 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
12640 install_element (VIEW_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
12641 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
12642 install_element (VIEW_NODE
, &show_bgp_neighbor_flap_cmd
);
12643 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
12644 install_element (VIEW_NODE
, &show_bgp_neighbor_damp_cmd
);
12645 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
12646 install_element (VIEW_NODE
, &show_bgp_rsclient_cmd
);
12647 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_rsclient_cmd
);
12648 install_element (VIEW_NODE
, &show_bgp_rsclient_route_cmd
);
12649 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_rsclient_route_cmd
);
12650 install_element (VIEW_NODE
, &show_bgp_rsclient_prefix_cmd
);
12651 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_rsclient_prefix_cmd
);
12652 install_element (VIEW_NODE
, &show_bgp_view_cmd
);
12653 install_element (VIEW_NODE
, &show_bgp_view_ipv6_cmd
);
12654 install_element (VIEW_NODE
, &show_bgp_view_route_cmd
);
12655 install_element (VIEW_NODE
, &show_bgp_view_ipv6_route_cmd
);
12656 install_element (VIEW_NODE
, &show_bgp_view_prefix_cmd
);
12657 install_element (VIEW_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
12658 install_element (VIEW_NODE
, &show_bgp_view_neighbor_advertised_route_cmd
);
12659 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_advertised_route_cmd
);
12660 install_element (VIEW_NODE
, &show_bgp_view_neighbor_received_routes_cmd
);
12661 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_received_routes_cmd
);
12662 install_element (VIEW_NODE
, &show_bgp_view_neighbor_routes_cmd
);
12663 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_routes_cmd
);
12664 install_element (VIEW_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
12665 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
12666 install_element (VIEW_NODE
, &show_bgp_view_neighbor_flap_cmd
);
12667 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_flap_cmd
);
12668 install_element (VIEW_NODE
, &show_bgp_view_neighbor_damp_cmd
);
12669 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_damp_cmd
);
12670 install_element (VIEW_NODE
, &show_bgp_view_rsclient_cmd
);
12671 install_element (VIEW_NODE
, &show_bgp_view_ipv6_safi_rsclient_cmd
);
12672 install_element (VIEW_NODE
, &show_bgp_view_rsclient_route_cmd
);
12673 install_element (VIEW_NODE
, &show_bgp_view_ipv6_safi_rsclient_route_cmd
);
12674 install_element (VIEW_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
12675 install_element (VIEW_NODE
, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd
);
12678 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
12680 install_element (RESTRICTED_NODE
, &show_bgp_route_cmd
);
12681 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_route_cmd
);
12682 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_route_cmd
);
12683 install_element (RESTRICTED_NODE
, &show_bgp_prefix_cmd
);
12684 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_prefix_cmd
);
12685 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
12686 install_element (RESTRICTED_NODE
, &show_bgp_community_cmd
);
12687 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_cmd
);
12688 install_element (RESTRICTED_NODE
, &show_bgp_community2_cmd
);
12689 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_cmd
);
12690 install_element (RESTRICTED_NODE
, &show_bgp_community3_cmd
);
12691 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_cmd
);
12692 install_element (RESTRICTED_NODE
, &show_bgp_community4_cmd
);
12693 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_cmd
);
12694 install_element (RESTRICTED_NODE
, &show_bgp_community_exact_cmd
);
12695 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_exact_cmd
);
12696 install_element (RESTRICTED_NODE
, &show_bgp_community2_exact_cmd
);
12697 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
12698 install_element (RESTRICTED_NODE
, &show_bgp_community3_exact_cmd
);
12699 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
12700 install_element (RESTRICTED_NODE
, &show_bgp_community4_exact_cmd
);
12701 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
12702 install_element (RESTRICTED_NODE
, &show_bgp_rsclient_route_cmd
);
12703 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_rsclient_route_cmd
);
12704 install_element (RESTRICTED_NODE
, &show_bgp_rsclient_prefix_cmd
);
12705 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_rsclient_prefix_cmd
);
12706 install_element (RESTRICTED_NODE
, &show_bgp_view_route_cmd
);
12707 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_route_cmd
);
12708 install_element (RESTRICTED_NODE
, &show_bgp_view_prefix_cmd
);
12709 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
12710 install_element (RESTRICTED_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
12711 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
12712 install_element (RESTRICTED_NODE
, &show_bgp_view_rsclient_route_cmd
);
12713 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_safi_rsclient_route_cmd
);
12714 install_element (RESTRICTED_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
12715 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd
);
12717 install_element (ENABLE_NODE
, &show_bgp_cmd
);
12718 install_element (ENABLE_NODE
, &show_bgp_ipv6_cmd
);
12719 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_cmd
);
12720 install_element (ENABLE_NODE
, &show_bgp_route_cmd
);
12721 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_cmd
);
12722 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_route_cmd
);
12723 install_element (ENABLE_NODE
, &show_bgp_prefix_cmd
);
12724 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_cmd
);
12725 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
12726 install_element (ENABLE_NODE
, &show_bgp_regexp_cmd
);
12727 install_element (ENABLE_NODE
, &show_bgp_ipv6_regexp_cmd
);
12728 install_element (ENABLE_NODE
, &show_bgp_prefix_list_cmd
);
12729 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
12730 install_element (ENABLE_NODE
, &show_bgp_filter_list_cmd
);
12731 install_element (ENABLE_NODE
, &show_bgp_ipv6_filter_list_cmd
);
12732 install_element (ENABLE_NODE
, &show_bgp_route_map_cmd
);
12733 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_map_cmd
);
12734 install_element (ENABLE_NODE
, &show_bgp_community_all_cmd
);
12735 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_all_cmd
);
12736 install_element (ENABLE_NODE
, &show_bgp_community_cmd
);
12737 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_cmd
);
12738 install_element (ENABLE_NODE
, &show_bgp_community2_cmd
);
12739 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_cmd
);
12740 install_element (ENABLE_NODE
, &show_bgp_community3_cmd
);
12741 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_cmd
);
12742 install_element (ENABLE_NODE
, &show_bgp_community4_cmd
);
12743 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_cmd
);
12744 install_element (ENABLE_NODE
, &show_bgp_community_exact_cmd
);
12745 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_exact_cmd
);
12746 install_element (ENABLE_NODE
, &show_bgp_community2_exact_cmd
);
12747 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
12748 install_element (ENABLE_NODE
, &show_bgp_community3_exact_cmd
);
12749 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
12750 install_element (ENABLE_NODE
, &show_bgp_community4_exact_cmd
);
12751 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
12752 install_element (ENABLE_NODE
, &show_bgp_community_list_cmd
);
12753 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_cmd
);
12754 install_element (ENABLE_NODE
, &show_bgp_community_list_exact_cmd
);
12755 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
12756 install_element (ENABLE_NODE
, &show_bgp_prefix_longer_cmd
);
12757 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
12758 install_element (ENABLE_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
12759 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
12760 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_routes_cmd
);
12761 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
12762 install_element (ENABLE_NODE
, &show_bgp_neighbor_routes_cmd
);
12763 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
12764 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
12765 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
12766 install_element (ENABLE_NODE
, &show_bgp_neighbor_flap_cmd
);
12767 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
12768 install_element (ENABLE_NODE
, &show_bgp_neighbor_damp_cmd
);
12769 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
12770 install_element (ENABLE_NODE
, &show_bgp_rsclient_cmd
);
12771 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_rsclient_cmd
);
12772 install_element (ENABLE_NODE
, &show_bgp_rsclient_route_cmd
);
12773 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_rsclient_route_cmd
);
12774 install_element (ENABLE_NODE
, &show_bgp_rsclient_prefix_cmd
);
12775 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_rsclient_prefix_cmd
);
12776 install_element (ENABLE_NODE
, &show_bgp_view_cmd
);
12777 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_cmd
);
12778 install_element (ENABLE_NODE
, &show_bgp_view_route_cmd
);
12779 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_route_cmd
);
12780 install_element (ENABLE_NODE
, &show_bgp_view_prefix_cmd
);
12781 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
12782 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_advertised_route_cmd
);
12783 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_advertised_route_cmd
);
12784 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_received_routes_cmd
);
12785 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_received_routes_cmd
);
12786 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_routes_cmd
);
12787 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_routes_cmd
);
12788 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
12789 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
12790 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_flap_cmd
);
12791 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_flap_cmd
);
12792 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_damp_cmd
);
12793 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_damp_cmd
);
12794 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_cmd
);
12795 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_safi_rsclient_cmd
);
12796 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_route_cmd
);
12797 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_safi_rsclient_route_cmd
);
12798 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
12799 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd
);
12802 install_element (ENABLE_NODE
, &show_bgp_statistics_cmd
);
12803 install_element (ENABLE_NODE
, &show_bgp_statistics_vpnv4_cmd
);
12804 install_element (ENABLE_NODE
, &show_bgp_statistics_view_cmd
);
12805 install_element (ENABLE_NODE
, &show_bgp_statistics_view_vpnv4_cmd
);
12808 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
12809 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
12810 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
12811 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
12812 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
12813 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
12814 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
12815 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
12816 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_cmd
);
12817 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_cmd
);
12818 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_cmd
);
12819 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
12820 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
12821 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
12822 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
12823 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
12824 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
12825 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
12826 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
12827 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
12828 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
12829 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
12830 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
12831 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
12832 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
12833 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
12834 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_cmd
);
12835 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_cmd
);
12836 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_cmd
);
12837 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
12838 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
12839 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
12840 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
12841 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
12842 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
12843 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
12846 install_element (ENABLE_NODE
, &show_ipv6_bgp_cmd
);
12847 install_element (ENABLE_NODE
, &show_ipv6_bgp_route_cmd
);
12848 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_cmd
);
12849 install_element (ENABLE_NODE
, &show_ipv6_bgp_regexp_cmd
);
12850 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
12851 install_element (ENABLE_NODE
, &show_ipv6_bgp_filter_list_cmd
);
12852 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_all_cmd
);
12853 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_cmd
);
12854 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_cmd
);
12855 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_cmd
);
12856 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_cmd
);
12857 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_exact_cmd
);
12858 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
12859 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
12860 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
12861 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_cmd
);
12862 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
12863 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
12864 install_element (ENABLE_NODE
, &show_ipv6_mbgp_cmd
);
12865 install_element (ENABLE_NODE
, &show_ipv6_mbgp_route_cmd
);
12866 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_cmd
);
12867 install_element (ENABLE_NODE
, &show_ipv6_mbgp_regexp_cmd
);
12868 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
12869 install_element (ENABLE_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
12870 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_all_cmd
);
12871 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_cmd
);
12872 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_cmd
);
12873 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_cmd
);
12874 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_cmd
);
12875 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
12876 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
12877 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
12878 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
12879 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_cmd
);
12880 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
12881 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
12884 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
12885 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
12886 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
12887 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
12890 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
12891 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
12892 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
12893 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
12896 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
12897 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
12898 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
12899 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
12900 #endif /* HAVE_IPV6 */
12902 install_element (BGP_NODE
, &bgp_distance_cmd
);
12903 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
12904 install_element (BGP_NODE
, &no_bgp_distance2_cmd
);
12905 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
12906 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
12907 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
12908 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
12910 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
12911 install_element (BGP_NODE
, &bgp_damp_set2_cmd
);
12912 install_element (BGP_NODE
, &bgp_damp_set3_cmd
);
12913 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
12914 install_element (BGP_NODE
, &bgp_damp_unset2_cmd
);
12915 install_element (BGP_IPV4_NODE
, &bgp_damp_set_cmd
);
12916 install_element (BGP_IPV4_NODE
, &bgp_damp_set2_cmd
);
12917 install_element (BGP_IPV4_NODE
, &bgp_damp_set3_cmd
);
12918 install_element (BGP_IPV4_NODE
, &bgp_damp_unset_cmd
);
12919 install_element (BGP_IPV4_NODE
, &bgp_damp_unset2_cmd
);
12921 /* Deprecated AS-Pathlimit commands */
12922 install_element (BGP_NODE
, &bgp_network_ttl_cmd
);
12923 install_element (BGP_NODE
, &bgp_network_mask_ttl_cmd
);
12924 install_element (BGP_NODE
, &bgp_network_mask_natural_ttl_cmd
);
12925 install_element (BGP_NODE
, &bgp_network_backdoor_ttl_cmd
);
12926 install_element (BGP_NODE
, &bgp_network_mask_backdoor_ttl_cmd
);
12927 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_ttl_cmd
);
12929 install_element (BGP_NODE
, &no_bgp_network_ttl_cmd
);
12930 install_element (BGP_NODE
, &no_bgp_network_mask_ttl_cmd
);
12931 install_element (BGP_NODE
, &no_bgp_network_mask_natural_ttl_cmd
);
12932 install_element (BGP_NODE
, &no_bgp_network_backdoor_ttl_cmd
);
12933 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_ttl_cmd
);
12934 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_ttl_cmd
);
12936 install_element (BGP_IPV4_NODE
, &bgp_network_ttl_cmd
);
12937 install_element (BGP_IPV4_NODE
, &bgp_network_mask_ttl_cmd
);
12938 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_ttl_cmd
);
12939 install_element (BGP_IPV4_NODE
, &bgp_network_backdoor_ttl_cmd
);
12940 install_element (BGP_IPV4_NODE
, &bgp_network_mask_backdoor_ttl_cmd
);
12941 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_backdoor_ttl_cmd
);
12943 install_element (BGP_IPV4_NODE
, &no_bgp_network_ttl_cmd
);
12944 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_ttl_cmd
);
12945 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_ttl_cmd
);
12946 install_element (BGP_IPV4_NODE
, &no_bgp_network_backdoor_ttl_cmd
);
12947 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_backdoor_ttl_cmd
);
12948 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_backdoor_ttl_cmd
);
12950 install_element (BGP_IPV4M_NODE
, &bgp_network_ttl_cmd
);
12951 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_ttl_cmd
);
12952 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_ttl_cmd
);
12953 install_element (BGP_IPV4M_NODE
, &bgp_network_backdoor_ttl_cmd
);
12954 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_backdoor_ttl_cmd
);
12955 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_backdoor_ttl_cmd
);
12957 install_element (BGP_IPV4M_NODE
, &no_bgp_network_ttl_cmd
);
12958 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_ttl_cmd
);
12959 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_ttl_cmd
);
12960 install_element (BGP_IPV4M_NODE
, &no_bgp_network_backdoor_ttl_cmd
);
12961 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_backdoor_ttl_cmd
);
12962 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_backdoor_ttl_cmd
);
12965 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_ttl_cmd
);
12966 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_ttl_cmd
);
12971 bgp_route_finish (void)
12973 bgp_table_unlock (bgp_distance_table
);
12974 bgp_distance_table
= NULL
;