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
;
1074 filter
= &rsclient
->filter
[afi
][safi
];
1076 if (DISABLE_BGP_ANNOUNCE
)
1079 /* Do not send back route to sender. */
1080 if (from
== rsclient
)
1083 /* Aggregate-address suppress check. */
1084 if (ri
->extra
&& ri
->extra
->suppress
)
1085 if (! UNSUPPRESS_MAP_NAME (filter
))
1088 /* Default route check. */
1089 if (CHECK_FLAG (rsclient
->af_sflags
[afi
][safi
],
1090 PEER_STATUS_DEFAULT_ORIGINATE
))
1092 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
)
1095 else if (p
->family
== AF_INET6
&& p
->prefixlen
== 0)
1097 #endif /* HAVE_IPV6 */
1100 /* If the attribute has originator-id and it is same as remote
1102 if (ri
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
))
1104 if (IPV4_ADDR_SAME (&rsclient
->remote_id
,
1105 &ri
->attr
->extra
->originator_id
))
1107 if (BGP_DEBUG (filter
, FILTER
))
1108 zlog (rsclient
->log
, LOG_DEBUG
,
1109 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
1111 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1117 /* ORF prefix-list filter check */
1118 if (CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_RM_ADV
)
1119 && (CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_RCV
)
1120 || CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)))
1121 if (rsclient
->orf_plist
[afi
][safi
])
1123 if (prefix_list_apply (rsclient
->orf_plist
[afi
][safi
], p
) == PREFIX_DENY
)
1127 /* Output filter check. */
1128 if (bgp_output_filter (rsclient
, p
, ri
->attr
, afi
, safi
) == FILTER_DENY
)
1130 if (BGP_DEBUG (filter
, FILTER
))
1131 zlog (rsclient
->log
, LOG_DEBUG
,
1132 "%s [Update:SEND] %s/%d is filtered",
1134 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1139 #ifdef BGP_SEND_ASPATH_CHECK
1140 /* AS path loop check. */
1141 if (aspath_loop_check (ri
->attr
->aspath
, rsclient
->as
))
1143 if (BGP_DEBUG (filter
, FILTER
))
1144 zlog (rsclient
->log
, LOG_DEBUG
,
1145 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
1146 rsclient
->host
, rsclient
->as
);
1149 #endif /* BGP_SEND_ASPATH_CHECK */
1151 /* For modify attribute, copy it to temporary structure. */
1152 bgp_attr_dup (attr
, ri
->attr
);
1155 if ((p
->family
== AF_INET
&& attr
->nexthop
.s_addr
== 0)
1157 || (p
->family
== AF_INET6
&&
1158 IN6_IS_ADDR_UNSPECIFIED(&attr
->extra
->mp_nexthop_global
))
1159 #endif /* HAVE_IPV6 */
1162 /* Set IPv4 nexthop. */
1163 if (p
->family
== AF_INET
)
1165 if (safi
== SAFI_MPLS_VPN
)
1166 memcpy (&attr
->extra
->mp_nexthop_global_in
, &rsclient
->nexthop
.v4
,
1169 memcpy (&attr
->nexthop
, &rsclient
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
1172 /* Set IPv6 nexthop. */
1173 if (p
->family
== AF_INET6
)
1175 /* IPv6 global nexthop must be included. */
1176 memcpy (&attr
->extra
->mp_nexthop_global
, &rsclient
->nexthop
.v6_global
,
1178 attr
->extra
->mp_nexthop_len
= 16;
1180 #endif /* HAVE_IPV6 */
1184 if (p
->family
== AF_INET6
)
1186 struct attr_extra
*attre
= attr
->extra
;
1188 assert (attr
->extra
);
1190 /* Left nexthop_local unchanged if so configured. */
1191 if ( CHECK_FLAG (rsclient
->af_flags
[afi
][safi
],
1192 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) )
1194 if ( IN6_IS_ADDR_LINKLOCAL (&attre
->mp_nexthop_local
) )
1195 attre
->mp_nexthop_len
=32;
1197 attre
->mp_nexthop_len
=16;
1200 /* Default nexthop_local treatment for RS-Clients */
1203 /* Announcer and RS-Client are both in the same network */
1204 if (rsclient
->shared_network
&& from
->shared_network
&&
1205 (rsclient
->ifindex
== from
->ifindex
))
1207 if ( IN6_IS_ADDR_LINKLOCAL (&attre
->mp_nexthop_local
) )
1208 attre
->mp_nexthop_len
=32;
1210 attre
->mp_nexthop_len
=16;
1213 /* Set link-local address for shared network peer. */
1214 else if (rsclient
->shared_network
1215 && IN6_IS_ADDR_LINKLOCAL (&rsclient
->nexthop
.v6_local
))
1217 memcpy (&attre
->mp_nexthop_local
, &rsclient
->nexthop
.v6_local
,
1219 attre
->mp_nexthop_len
= 32;
1223 attre
->mp_nexthop_len
= 16;
1227 #endif /* HAVE_IPV6 */
1230 /* If this is EBGP peer and remove-private-AS is set. */
1231 if (peer_sort (rsclient
) == BGP_PEER_EBGP
1232 && peer_af_flag_check (rsclient
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)
1233 && aspath_private_as_check (attr
->aspath
))
1234 attr
->aspath
= aspath_empty_get ();
1236 /* Route map & unsuppress-map apply. */
1237 if (ROUTE_MAP_OUT_NAME (filter
) || (ri
->extra
&& ri
->extra
->suppress
) )
1239 info
.peer
= rsclient
;
1242 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1244 if (ri
->extra
&& ri
->extra
->suppress
)
1245 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
1247 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
1249 rsclient
->rmap_type
= 0;
1251 if (ret
== RMAP_DENYMATCH
)
1253 bgp_attr_flush (attr
);
1261 struct bgp_info_pair
1263 struct bgp_info
*old
;
1264 struct bgp_info
*new;
1268 bgp_best_selection (struct bgp
*bgp
, struct bgp_node
*rn
, struct bgp_info_pair
*result
)
1270 struct bgp_info
*new_select
;
1271 struct bgp_info
*old_select
;
1272 struct bgp_info
*ri
;
1273 struct bgp_info
*ri1
;
1274 struct bgp_info
*ri2
;
1275 struct bgp_info
*nextri
= NULL
;
1277 /* bgp deterministic-med */
1279 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
))
1280 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1282 if (CHECK_FLAG (ri1
->flags
, BGP_INFO_DMED_CHECK
))
1284 if (BGP_INFO_HOLDDOWN (ri1
))
1289 for (ri2
= ri1
->next
; ri2
; ri2
= ri2
->next
)
1291 if (CHECK_FLAG (ri2
->flags
, BGP_INFO_DMED_CHECK
))
1293 if (BGP_INFO_HOLDDOWN (ri2
))
1296 if (aspath_cmp_left (ri1
->attr
->aspath
, ri2
->attr
->aspath
)
1297 || aspath_cmp_left_confed (ri1
->attr
->aspath
,
1300 if (bgp_info_cmp (bgp
, ri2
, new_select
))
1302 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1306 bgp_info_set_flag (rn
, ri2
, BGP_INFO_DMED_CHECK
);
1309 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_CHECK
);
1310 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1313 /* Check old selected route and new selected route. */
1316 for (ri
= rn
->info
; (ri
!= NULL
) && (nextri
= ri
->next
, 1); ri
= nextri
)
1318 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1321 if (BGP_INFO_HOLDDOWN (ri
))
1323 /* reap REMOVED routes, if needs be
1324 * selected route must stay for a while longer though
1326 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
1327 && (ri
!= old_select
))
1328 bgp_info_reap (rn
, ri
);
1333 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
)
1334 && (! CHECK_FLAG (ri
->flags
, BGP_INFO_DMED_SELECTED
)))
1336 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1339 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1340 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_SELECTED
);
1342 if (bgp_info_cmp (bgp
, ri
, new_select
))
1346 result
->old
= old_select
;
1347 result
->new = new_select
;
1353 bgp_process_announce_selected (struct peer
*peer
, struct bgp_info
*selected
,
1354 struct bgp_node
*rn
, afi_t afi
, safi_t safi
)
1357 struct attr attr
= { 0 };
1361 /* Announce route to Established peer. */
1362 if (peer
->status
!= Established
)
1365 /* Address family configuration check. */
1366 if (! peer
->afc_nego
[afi
][safi
])
1369 /* First update is deferred until ORF or ROUTE-REFRESH is received */
1370 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
],
1371 PEER_STATUS_ORF_WAIT_REFRESH
))
1374 switch (rn
->table
->type
)
1376 case BGP_TABLE_MAIN
:
1377 /* Announcement to peer->conf. If the route is filtered,
1379 if (selected
&& bgp_announce_check (selected
, peer
, p
, &attr
, afi
, safi
))
1380 bgp_adj_out_set (rn
, peer
, p
, &attr
, afi
, safi
, selected
);
1382 bgp_adj_out_unset (rn
, peer
, p
, afi
, safi
);
1384 case BGP_TABLE_RSCLIENT
:
1385 /* Announcement to peer->conf. If the route is filtered,
1388 bgp_announce_check_rsclient (selected
, peer
, p
, &attr
, afi
, safi
))
1389 bgp_adj_out_set (rn
, peer
, p
, &attr
, afi
, safi
, selected
);
1391 bgp_adj_out_unset (rn
, peer
, p
, afi
, safi
);
1395 bgp_attr_extra_free (&attr
);
1400 struct bgp_process_queue
1403 struct bgp_node
*rn
;
1408 static wq_item_status
1409 bgp_process_rsclient (struct work_queue
*wq
, void *data
)
1411 struct bgp_process_queue
*pq
= data
;
1412 struct bgp
*bgp
= pq
->bgp
;
1413 struct bgp_node
*rn
= pq
->rn
;
1414 afi_t afi
= pq
->afi
;
1415 safi_t safi
= pq
->safi
;
1416 struct bgp_info
*new_select
;
1417 struct bgp_info
*old_select
;
1418 struct bgp_info_pair old_and_new
;
1419 struct listnode
*node
, *nnode
;
1420 struct peer
*rsclient
= rn
->table
->owner
;
1422 /* Best path selection. */
1423 bgp_best_selection (bgp
, rn
, &old_and_new
);
1424 new_select
= old_and_new
.new;
1425 old_select
= old_and_new
.old
;
1427 if (CHECK_FLAG (rsclient
->sflags
, PEER_STATUS_GROUP
))
1429 if (rsclient
->group
)
1430 for (ALL_LIST_ELEMENTS (rsclient
->group
->peer
, node
, nnode
, rsclient
))
1432 /* Nothing to do. */
1433 if (old_select
&& old_select
== new_select
)
1434 if (!CHECK_FLAG (old_select
->flags
, BGP_INFO_ATTR_CHANGED
))
1438 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1441 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1442 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1445 bgp_process_announce_selected (rsclient
, new_select
, rn
,
1452 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1455 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1456 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1458 bgp_process_announce_selected (rsclient
, new_select
, rn
, afi
, safi
);
1461 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
1462 bgp_info_reap (rn
, old_select
);
1464 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1468 static wq_item_status
1469 bgp_process_main (struct work_queue
*wq
, void *data
)
1471 struct bgp_process_queue
*pq
= data
;
1472 struct bgp
*bgp
= pq
->bgp
;
1473 struct bgp_node
*rn
= pq
->rn
;
1474 afi_t afi
= pq
->afi
;
1475 safi_t safi
= pq
->safi
;
1476 struct prefix
*p
= &rn
->p
;
1477 struct bgp_info
*new_select
;
1478 struct bgp_info
*old_select
;
1479 struct bgp_info_pair old_and_new
;
1480 struct listnode
*node
, *nnode
;
1483 /* Best path selection. */
1484 bgp_best_selection (bgp
, rn
, &old_and_new
);
1485 old_select
= old_and_new
.old
;
1486 new_select
= old_and_new
.new;
1488 /* Nothing to do. */
1489 if (old_select
&& old_select
== new_select
)
1491 if (! CHECK_FLAG (old_select
->flags
, BGP_INFO_ATTR_CHANGED
))
1493 if (CHECK_FLAG (old_select
->flags
, BGP_INFO_IGP_CHANGED
))
1494 bgp_zebra_announce (p
, old_select
, bgp
, safi
);
1496 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1502 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1505 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1506 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1510 /* Check each BGP peer. */
1511 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
1513 bgp_process_announce_selected (peer
, new_select
, rn
, afi
, safi
);
1517 if ((safi
== SAFI_UNICAST
|| safi
== SAFI_MULTICAST
) && (! bgp
->name
&&
1518 ! bgp_option_check (BGP_OPT_NO_FIB
)))
1521 && new_select
->type
== ZEBRA_ROUTE_BGP
1522 && new_select
->sub_type
== BGP_ROUTE_NORMAL
)
1523 bgp_zebra_announce (p
, new_select
, bgp
, safi
);
1526 /* Withdraw the route from the kernel. */
1528 && old_select
->type
== ZEBRA_ROUTE_BGP
1529 && old_select
->sub_type
== BGP_ROUTE_NORMAL
)
1530 bgp_zebra_withdraw (p
, old_select
, safi
);
1534 /* Reap old select bgp_info, it it has been removed */
1535 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
1536 bgp_info_reap (rn
, old_select
);
1538 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1543 bgp_processq_del (struct work_queue
*wq
, void *data
)
1545 struct bgp_process_queue
*pq
= data
;
1546 struct bgp_table
*table
= pq
->rn
->table
;
1548 bgp_unlock (pq
->bgp
);
1549 bgp_unlock_node (pq
->rn
);
1550 bgp_table_unlock (table
);
1551 XFREE (MTYPE_BGP_PROCESS_QUEUE
, pq
);
1555 bgp_process_queue_init (void)
1557 bm
->process_main_queue
1558 = work_queue_new (bm
->master
, "process_main_queue");
1559 bm
->process_rsclient_queue
1560 = work_queue_new (bm
->master
, "process_rsclient_queue");
1562 if ( !(bm
->process_main_queue
&& bm
->process_rsclient_queue
) )
1564 zlog_err ("%s: Failed to allocate work queue", __func__
);
1568 bm
->process_main_queue
->spec
.workfunc
= &bgp_process_main
;
1569 bm
->process_main_queue
->spec
.del_item_data
= &bgp_processq_del
;
1570 bm
->process_main_queue
->spec
.max_retries
= 0;
1571 bm
->process_main_queue
->spec
.hold
= 50;
1573 memcpy (bm
->process_rsclient_queue
, bm
->process_main_queue
,
1574 sizeof (struct work_queue
*));
1575 bm
->process_rsclient_queue
->spec
.workfunc
= &bgp_process_rsclient
;
1579 bgp_process (struct bgp
*bgp
, struct bgp_node
*rn
, afi_t afi
, safi_t safi
)
1581 struct bgp_process_queue
*pqnode
;
1583 /* already scheduled for processing? */
1584 if (CHECK_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
))
1587 if ( (bm
->process_main_queue
== NULL
) ||
1588 (bm
->process_rsclient_queue
== NULL
) )
1589 bgp_process_queue_init ();
1591 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
1592 sizeof (struct bgp_process_queue
));
1596 /* all unlocked in bgp_processq_del */
1597 bgp_table_lock (rn
->table
);
1598 pqnode
->rn
= bgp_lock_node (rn
);
1602 pqnode
->safi
= safi
;
1604 switch (rn
->table
->type
)
1606 case BGP_TABLE_MAIN
:
1607 work_queue_add (bm
->process_main_queue
, pqnode
);
1609 case BGP_TABLE_RSCLIENT
:
1610 work_queue_add (bm
->process_rsclient_queue
, pqnode
);
1618 bgp_maximum_prefix_restart_timer (struct thread
*thread
)
1622 peer
= THREAD_ARG (thread
);
1623 peer
->t_pmax_restart
= NULL
;
1625 if (BGP_DEBUG (events
, EVENTS
))
1626 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
1635 bgp_maximum_prefix_overflow (struct peer
*peer
, afi_t afi
,
1636 safi_t safi
, int always
)
1638 if (!CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
))
1641 if (peer
->pcount
[afi
][safi
] > peer
->pmax
[afi
][safi
])
1643 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
)
1647 zlog (peer
->log
, LOG_INFO
,
1648 "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
1649 "limit %ld", afi_safi_print (afi
, safi
), peer
->host
,
1650 peer
->pcount
[afi
][safi
], peer
->pmax
[afi
][safi
]);
1651 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
1653 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_WARNING
))
1659 if (safi
== SAFI_MPLS_VPN
)
1660 safi
= SAFI_MPLS_LABELED_VPN
;
1662 ndata
[0] = (afi
>> 8);
1665 ndata
[3] = (peer
->pmax
[afi
][safi
] >> 24);
1666 ndata
[4] = (peer
->pmax
[afi
][safi
] >> 16);
1667 ndata
[5] = (peer
->pmax
[afi
][safi
] >> 8);
1668 ndata
[6] = (peer
->pmax
[afi
][safi
]);
1670 SET_FLAG (peer
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
);
1671 bgp_notify_send_with_data (peer
, BGP_NOTIFY_CEASE
,
1672 BGP_NOTIFY_CEASE_MAX_PREFIX
, ndata
, 7);
1675 /* restart timer start */
1676 if (peer
->pmax_restart
[afi
][safi
])
1678 peer
->v_pmax_restart
= peer
->pmax_restart
[afi
][safi
] * 60;
1680 if (BGP_DEBUG (events
, EVENTS
))
1681 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
1682 peer
->host
, peer
->v_pmax_restart
);
1684 BGP_TIMER_ON (peer
->t_pmax_restart
, bgp_maximum_prefix_restart_timer
,
1685 peer
->v_pmax_restart
);
1691 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
1693 if (peer
->pcount
[afi
][safi
] > (peer
->pmax
[afi
][safi
] * peer
->pmax_threshold
[afi
][safi
] / 100))
1695 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
)
1699 zlog (peer
->log
, LOG_INFO
,
1700 "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
1701 afi_safi_print (afi
, safi
), peer
->host
, peer
->pcount
[afi
][safi
],
1702 peer
->pmax
[afi
][safi
]);
1703 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
1706 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
1710 /* Unconditionally remove the route from the RIB, without taking
1711 * damping into consideration (eg, because the session went down)
1714 bgp_rib_remove (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
1715 afi_t afi
, safi_t safi
)
1717 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
1719 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
1720 bgp_info_delete (rn
, ri
); /* keep historical info */
1722 bgp_process (peer
->bgp
, rn
, afi
, safi
);
1726 bgp_rib_withdraw (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
1727 afi_t afi
, safi_t safi
)
1729 int status
= BGP_DAMP_NONE
;
1731 /* apply dampening, if result is suppressed, we'll be retaining
1732 * the bgp_info in the RIB for historical reference.
1734 if (CHECK_FLAG (peer
->bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
1735 && peer_sort (peer
) == BGP_PEER_EBGP
)
1736 if ( (status
= bgp_damp_withdraw (ri
, rn
, afi
, safi
, 0))
1737 == BGP_DAMP_SUPPRESSED
)
1739 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
1743 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
1747 bgp_update_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
,
1748 struct attr
*attr
, struct peer
*peer
, struct prefix
*p
, int type
,
1749 int sub_type
, struct prefix_rd
*prd
, u_char
*tag
)
1751 struct bgp_node
*rn
;
1753 struct attr new_attr
= { 0 };
1754 struct attr
*attr_new
;
1755 struct attr
*attr_new2
;
1756 struct bgp_info
*ri
;
1757 struct bgp_info
*new;
1759 char buf
[SU_ADDRSTRLEN
];
1761 /* Do not insert announces from a rsclient into its own 'bgp_table'. */
1762 if (peer
== rsclient
)
1766 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
1768 /* Check previously received route. */
1769 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1770 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
1773 /* AS path loop check. */
1774 if (aspath_loop_check (attr
->aspath
, rsclient
->as
) > peer
->allowas_in
[afi
][safi
])
1776 reason
= "as-path contains our own AS;";
1780 /* Route reflector originator ID check. */
1781 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
1782 && IPV4_ADDR_SAME (&rsclient
->remote_id
, &attr
->extra
->originator_id
))
1784 reason
= "originator is us;";
1788 bgp_attr_dup (&new_attr
, attr
);
1790 /* Apply export policy. */
1791 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
) &&
1792 bgp_export_modifier (rsclient
, peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
1794 reason
= "export-policy;";
1798 attr_new2
= bgp_attr_intern (&new_attr
);
1800 /* Apply import policy. */
1801 if (bgp_import_modifier (rsclient
, peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
1803 bgp_attr_unintern (&attr_new2
);
1805 reason
= "import-policy;";
1809 attr_new
= bgp_attr_intern (&new_attr
);
1810 bgp_attr_unintern (&attr_new2
);
1812 /* IPv4 unicast next hop check. */
1813 if ((afi
== AFI_IP
) && ((safi
== SAFI_UNICAST
) || safi
== SAFI_MULTICAST
))
1815 /* Next hop must not be 0.0.0.0 nor Class D/E address. */
1816 if (new_attr
.nexthop
.s_addr
== 0
1817 || IPV4_CLASS_DE (ntohl (new_attr
.nexthop
.s_addr
)))
1819 bgp_attr_unintern (&attr_new
);
1821 reason
= "martian next-hop;";
1826 /* new_attr isn't passed to any functions after here */
1827 bgp_attr_extra_free (&new_attr
);
1829 /* If the update is implicit withdraw. */
1832 ri
->uptime
= bgp_clock ();
1834 /* Same attribute comes in. */
1835 if (!CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
)
1836 && attrhash_cmp (ri
->attr
, attr_new
))
1839 bgp_info_unset_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
1841 if (BGP_DEBUG (update
, UPDATE_IN
))
1842 zlog (peer
->log
, LOG_DEBUG
,
1843 "%s rcvd %s/%d for RS-client %s...duplicate ignored",
1845 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1846 p
->prefixlen
, rsclient
->host
);
1848 bgp_unlock_node (rn
);
1849 bgp_attr_unintern (&attr_new
);
1854 /* Withdraw/Announce before we fully processed the withdraw */
1855 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
1856 bgp_info_restore (rn
, ri
);
1858 /* Received Logging. */
1859 if (BGP_DEBUG (update
, UPDATE_IN
))
1860 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d for RS-client %s",
1862 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1863 p
->prefixlen
, rsclient
->host
);
1865 /* The attribute is changed. */
1866 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
1868 /* Update to new attribute. */
1869 bgp_attr_unintern (&ri
->attr
);
1870 ri
->attr
= attr_new
;
1872 /* Update MPLS tag. */
1873 if (safi
== SAFI_MPLS_VPN
)
1874 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
1876 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
1878 /* Process change. */
1879 bgp_process (bgp
, rn
, afi
, safi
);
1880 bgp_unlock_node (rn
);
1885 /* Received Logging. */
1886 if (BGP_DEBUG (update
, UPDATE_IN
))
1888 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d for RS-client %s",
1890 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1891 p
->prefixlen
, rsclient
->host
);
1894 /* Make new BGP info. */
1895 new = bgp_info_new ();
1897 new->sub_type
= sub_type
;
1899 new->attr
= attr_new
;
1900 new->uptime
= bgp_clock ();
1902 /* Update MPLS tag. */
1903 if (safi
== SAFI_MPLS_VPN
)
1904 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
1906 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
1908 /* Register new BGP information. */
1909 bgp_info_add (rn
, new);
1911 /* route_node_get lock */
1912 bgp_unlock_node (rn
);
1914 /* Process change. */
1915 bgp_process (bgp
, rn
, afi
, safi
);
1917 bgp_attr_extra_free (&new_attr
);
1923 /* This BGP update is filtered. Log the reason then update BGP entry. */
1924 if (BGP_DEBUG (update
, UPDATE_IN
))
1925 zlog (peer
->log
, LOG_DEBUG
,
1926 "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s",
1928 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1929 p
->prefixlen
, rsclient
->host
, reason
);
1932 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
1934 bgp_unlock_node (rn
);
1937 bgp_attr_extra_free (&new_attr
);
1943 bgp_withdraw_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
,
1944 struct peer
*peer
, struct prefix
*p
, int type
, int sub_type
,
1945 struct prefix_rd
*prd
, u_char
*tag
)
1947 struct bgp_node
*rn
;
1948 struct bgp_info
*ri
;
1949 char buf
[SU_ADDRSTRLEN
];
1951 if (rsclient
== peer
)
1954 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
1956 /* Lookup withdrawn route. */
1957 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1958 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
1961 /* Withdraw specified route from routing table. */
1962 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
1963 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
1964 else if (BGP_DEBUG (update
, UPDATE_IN
))
1965 zlog (peer
->log
, LOG_DEBUG
,
1966 "%s Can't find the route %s/%d", peer
->host
,
1967 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1970 /* Unlock bgp_node_get() lock. */
1971 bgp_unlock_node (rn
);
1975 bgp_update_main (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
1976 afi_t afi
, safi_t safi
, int type
, int sub_type
,
1977 struct prefix_rd
*prd
, u_char
*tag
, int soft_reconfig
)
1980 int aspath_loop_count
= 0;
1981 struct bgp_node
*rn
;
1983 struct attr new_attr
= { 0 };
1984 struct attr
*attr_new
;
1985 struct bgp_info
*ri
;
1986 struct bgp_info
*new;
1988 char buf
[SU_ADDRSTRLEN
];
1991 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
1993 /* When peer's soft reconfiguration enabled. Record input packet in
1995 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
1996 && peer
!= bgp
->peer_self
&& ! soft_reconfig
)
1997 bgp_adj_in_set (rn
, peer
, attr
);
1999 /* Check previously received route. */
2000 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2001 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
2004 /* AS path local-as loop check. */
2005 if (peer
->change_local_as
)
2007 if (! CHECK_FLAG (peer
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
2008 aspath_loop_count
= 1;
2010 if (aspath_loop_check (attr
->aspath
, peer
->change_local_as
) > aspath_loop_count
)
2012 reason
= "as-path contains our own AS;";
2017 /* AS path loop check. */
2018 if (aspath_loop_check (attr
->aspath
, bgp
->as
) > peer
->allowas_in
[afi
][safi
]
2019 || (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
2020 && aspath_loop_check(attr
->aspath
, bgp
->confed_id
)
2021 > peer
->allowas_in
[afi
][safi
]))
2023 reason
= "as-path contains our own AS;";
2027 /* Route reflector originator ID check. */
2028 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
2029 && IPV4_ADDR_SAME (&bgp
->router_id
, &attr
->extra
->originator_id
))
2031 reason
= "originator is us;";
2035 /* Route reflector cluster ID check. */
2036 if (bgp_cluster_filter (peer
, attr
))
2038 reason
= "reflected from the same cluster;";
2042 /* Apply incoming filter. */
2043 if (bgp_input_filter (peer
, p
, attr
, afi
, safi
) == FILTER_DENY
)
2049 /* Apply incoming route-map. */
2050 bgp_attr_dup (&new_attr
, attr
);
2052 if (bgp_input_modifier (peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
2054 reason
= "route-map;";
2058 /* IPv4 unicast next hop check. */
2059 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2061 /* If the peer is EBGP and nexthop is not on connected route,
2063 if (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
== 1
2064 && ! bgp_nexthop_onlink (afi
, &new_attr
)
2065 && ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
2067 reason
= "non-connected next-hop;";
2071 /* Next hop must not be 0.0.0.0 nor Class D/E address. Next hop
2072 must not be my own address. */
2073 if (bgp_nexthop_self (afi
, &new_attr
)
2074 || new_attr
.nexthop
.s_addr
== 0
2075 || IPV4_CLASS_DE (ntohl (new_attr
.nexthop
.s_addr
)))
2077 reason
= "martian next-hop;";
2082 attr_new
= bgp_attr_intern (&new_attr
);
2084 /* If the update is implicit withdraw. */
2087 ri
->uptime
= bgp_clock ();
2089 /* Same attribute comes in. */
2090 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
2091 && attrhash_cmp (ri
->attr
, attr_new
))
2093 bgp_info_unset_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2095 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2096 && peer_sort (peer
) == BGP_PEER_EBGP
2097 && CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2099 if (BGP_DEBUG (update
, UPDATE_IN
))
2100 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2102 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2105 if (bgp_damp_update (ri
, rn
, afi
, safi
) != BGP_DAMP_SUPPRESSED
)
2107 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2108 bgp_process (bgp
, rn
, afi
, safi
);
2111 else /* Duplicate - odd */
2113 if (BGP_DEBUG (update
, UPDATE_IN
))
2114 zlog (peer
->log
, LOG_DEBUG
,
2115 "%s rcvd %s/%d...duplicate ignored",
2117 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2120 /* graceful restart STALE flag unset. */
2121 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2123 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2124 bgp_process (bgp
, rn
, afi
, safi
);
2128 bgp_unlock_node (rn
);
2129 bgp_attr_unintern (&attr_new
);
2130 bgp_attr_extra_free (&new_attr
);
2135 /* Withdraw/Announce before we fully processed the withdraw */
2136 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
2138 if (BGP_DEBUG (update
, UPDATE_IN
))
2139 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d, flapped quicker than processing",
2141 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2143 bgp_info_restore (rn
, ri
);
2146 /* Received Logging. */
2147 if (BGP_DEBUG (update
, UPDATE_IN
))
2148 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2150 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2153 /* graceful restart STALE flag unset. */
2154 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2155 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2157 /* The attribute is changed. */
2158 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2160 /* implicit withdraw, decrement aggregate and pcount here.
2161 * only if update is accepted, they'll increment below.
2163 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
2165 /* Update bgp route dampening information. */
2166 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2167 && peer_sort (peer
) == BGP_PEER_EBGP
)
2169 /* This is implicit withdraw so we should update dampening
2171 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2172 bgp_damp_withdraw (ri
, rn
, afi
, safi
, 1);
2175 /* Update to new attribute. */
2176 bgp_attr_unintern (&ri
->attr
);
2177 ri
->attr
= attr_new
;
2179 /* Update MPLS tag. */
2180 if (safi
== SAFI_MPLS_VPN
)
2181 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
2183 /* Update bgp route dampening information. */
2184 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2185 && peer_sort (peer
) == BGP_PEER_EBGP
)
2187 /* Now we do normal update dampening. */
2188 ret
= bgp_damp_update (ri
, rn
, afi
, safi
);
2189 if (ret
== BGP_DAMP_SUPPRESSED
)
2191 bgp_unlock_node (rn
);
2192 bgp_attr_extra_free (&new_attr
);
2197 /* Nexthop reachability check. */
2198 if ((afi
== AFI_IP
|| afi
== AFI_IP6
)
2199 && safi
== SAFI_UNICAST
2200 && (peer_sort (peer
) == BGP_PEER_IBGP
2201 || peer_sort (peer
) == BGP_PEER_CONFED
2202 || (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)
2203 || CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)))
2205 if (bgp_nexthop_lookup (afi
, peer
, ri
, NULL
, NULL
))
2206 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2208 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
2211 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2213 /* Process change. */
2214 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2216 bgp_process (bgp
, rn
, afi
, safi
);
2217 bgp_unlock_node (rn
);
2218 bgp_attr_extra_free (&new_attr
);
2223 /* Received Logging. */
2224 if (BGP_DEBUG (update
, UPDATE_IN
))
2226 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2228 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2232 /* Make new BGP info. */
2233 new = bgp_info_new ();
2235 new->sub_type
= sub_type
;
2237 new->attr
= attr_new
;
2238 new->uptime
= bgp_clock ();
2240 /* Update MPLS tag. */
2241 if (safi
== SAFI_MPLS_VPN
)
2242 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
2244 /* Nexthop reachability check. */
2245 if ((afi
== AFI_IP
|| afi
== AFI_IP6
)
2246 && safi
== SAFI_UNICAST
2247 && (peer_sort (peer
) == BGP_PEER_IBGP
2248 || peer_sort (peer
) == BGP_PEER_CONFED
2249 || (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)
2250 || CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)))
2252 if (bgp_nexthop_lookup (afi
, peer
, new, NULL
, NULL
))
2253 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2255 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
2258 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2260 /* Increment prefix */
2261 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
2263 /* Register new BGP information. */
2264 bgp_info_add (rn
, new);
2266 /* route_node_get lock */
2267 bgp_unlock_node (rn
);
2269 bgp_attr_extra_free (&new_attr
);
2271 /* If maximum prefix count is configured and current prefix
2273 if (bgp_maximum_prefix_overflow (peer
, afi
, safi
, 0))
2276 /* Process change. */
2277 bgp_process (bgp
, rn
, afi
, safi
);
2281 /* This BGP update is filtered. Log the reason then update BGP
2284 if (BGP_DEBUG (update
, UPDATE_IN
))
2285 zlog (peer
->log
, LOG_DEBUG
,
2286 "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
2288 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2289 p
->prefixlen
, reason
);
2292 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2294 bgp_unlock_node (rn
);
2296 bgp_attr_extra_free (&new_attr
);
2302 bgp_update (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
2303 afi_t afi
, safi_t safi
, int type
, int sub_type
,
2304 struct prefix_rd
*prd
, u_char
*tag
, int soft_reconfig
)
2306 struct peer
*rsclient
;
2307 struct listnode
*node
, *nnode
;
2311 ret
= bgp_update_main (peer
, p
, attr
, afi
, safi
, type
, sub_type
, prd
, tag
,
2316 /* Process the update for each RS-client. */
2317 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
2319 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2320 bgp_update_rsclient (rsclient
, afi
, safi
, attr
, peer
, p
, type
,
2321 sub_type
, prd
, tag
);
2328 bgp_withdraw (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
2329 afi_t afi
, safi_t safi
, int type
, int sub_type
,
2330 struct prefix_rd
*prd
, u_char
*tag
)
2333 char buf
[SU_ADDRSTRLEN
];
2334 struct bgp_node
*rn
;
2335 struct bgp_info
*ri
;
2336 struct peer
*rsclient
;
2337 struct listnode
*node
, *nnode
;
2341 /* Process the withdraw for each RS-client. */
2342 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
2344 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2345 bgp_withdraw_rsclient (rsclient
, afi
, safi
, peer
, p
, type
, sub_type
, prd
, tag
);
2349 if (BGP_DEBUG (update
, UPDATE_IN
))
2350 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd UPDATE about %s/%d -- withdrawn",
2352 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2356 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2358 /* If peer is soft reconfiguration enabled. Record input packet for
2359 further calculation. */
2360 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2361 && peer
!= bgp
->peer_self
)
2362 bgp_adj_in_unset (rn
, peer
);
2364 /* Lookup withdrawn route. */
2365 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2366 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
2369 /* Withdraw specified route from routing table. */
2370 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2371 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
2372 else if (BGP_DEBUG (update
, UPDATE_IN
))
2373 zlog (peer
->log
, LOG_DEBUG
,
2374 "%s Can't find the route %s/%d", peer
->host
,
2375 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2378 /* Unlock bgp_node_get() lock. */
2379 bgp_unlock_node (rn
);
2385 bgp_default_originate (struct peer
*peer
, afi_t afi
, safi_t safi
, int withdraw
)
2388 struct attr attr
= { 0 };
2389 struct aspath
*aspath
= { 0 };
2391 struct bgp_info binfo
;
2393 int ret
= RMAP_DENYMATCH
;
2395 if (!(afi
== AFI_IP
|| afi
== AFI_IP6
))
2399 from
= bgp
->peer_self
;
2401 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
2402 aspath
= attr
.aspath
;
2403 attr
.local_pref
= bgp
->default_local_pref
;
2404 memcpy (&attr
.nexthop
, &peer
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
2407 str2prefix ("0.0.0.0/0", &p
);
2409 else if (afi
== AFI_IP6
)
2411 struct attr_extra
*ae
;
2414 ae
= bgp_attr_extra_get (&attr
);
2417 str2prefix ("::/0", &p
);
2419 /* IPv6 global nexthop must be included. */
2420 memcpy (&ae
->mp_nexthop_global
, &peer
->nexthop
.v6_global
,
2422 ae
->mp_nexthop_len
= 16;
2424 /* If the peer is on shared nextwork and we have link-local
2426 if (peer
->shared_network
2427 && !IN6_IS_ADDR_UNSPECIFIED (&peer
->nexthop
.v6_local
))
2429 memcpy (&ae
->mp_nexthop_local
, &peer
->nexthop
.v6_local
,
2431 ae
->mp_nexthop_len
= 32;
2434 #endif /* HAVE_IPV6 */
2436 if (peer
->default_rmap
[afi
][safi
].name
)
2438 binfo
.peer
= bgp
->peer_self
;
2441 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_DEFAULT
);
2443 ret
= route_map_apply (peer
->default_rmap
[afi
][safi
].map
, &p
,
2446 bgp
->peer_self
->rmap_type
= 0;
2448 if (ret
== RMAP_DENYMATCH
)
2450 bgp_attr_flush (&attr
);
2457 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
))
2458 bgp_default_withdraw_send (peer
, afi
, safi
);
2459 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
);
2463 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
);
2464 bgp_default_update_send (peer
, &attr
, afi
, safi
, from
);
2467 bgp_attr_extra_free (&attr
);
2468 aspath_unintern (&aspath
);
2472 bgp_announce_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2473 struct bgp_table
*table
, int rsclient
)
2475 struct bgp_node
*rn
;
2476 struct bgp_info
*ri
;
2477 struct attr attr
= { 0 };
2480 table
= (rsclient
) ? peer
->rib
[afi
][safi
] : peer
->bgp
->rib
[afi
][safi
];
2482 if (safi
!= SAFI_MPLS_VPN
2483 && CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_DEFAULT_ORIGINATE
))
2484 bgp_default_originate (peer
, afi
, safi
, 0);
2486 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next(rn
))
2487 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2488 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
) && ri
->peer
!= peer
)
2491 (bgp_announce_check_rsclient (ri
, peer
, &rn
->p
, &attr
, afi
, safi
))
2492 : (bgp_announce_check (ri
, peer
, &rn
->p
, &attr
, afi
, safi
)))
2493 bgp_adj_out_set (rn
, peer
, &rn
->p
, &attr
, afi
, safi
, ri
);
2495 bgp_adj_out_unset (rn
, peer
, &rn
->p
, afi
, safi
);
2497 bgp_attr_extra_free (&attr
);
2502 bgp_announce_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2504 struct bgp_node
*rn
;
2505 struct bgp_table
*table
;
2507 if (peer
->status
!= Established
)
2510 if (! peer
->afc_nego
[afi
][safi
])
2513 /* First update is deferred until ORF or ROUTE-REFRESH is received */
2514 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_ORF_WAIT_REFRESH
))
2517 if (safi
!= SAFI_MPLS_VPN
)
2518 bgp_announce_table (peer
, afi
, safi
, NULL
, 0);
2520 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2521 rn
= bgp_route_next(rn
))
2522 if ((table
= (rn
->info
)) != NULL
)
2523 bgp_announce_table (peer
, afi
, safi
, table
, 0);
2525 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2526 bgp_announce_table (peer
, afi
, safi
, NULL
, 1);
2530 bgp_announce_route_all (struct peer
*peer
)
2535 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2536 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2537 bgp_announce_route (peer
, afi
, safi
);
2541 bgp_soft_reconfig_table_rsclient (struct peer
*rsclient
, afi_t afi
,
2542 safi_t safi
, struct bgp_table
*table
)
2544 struct bgp_node
*rn
;
2545 struct bgp_adj_in
*ain
;
2548 table
= rsclient
->bgp
->rib
[afi
][safi
];
2550 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2551 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2553 bgp_update_rsclient (rsclient
, afi
, safi
, ain
->attr
, ain
->peer
,
2554 &rn
->p
, ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
2559 bgp_soft_reconfig_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
)
2561 struct bgp_table
*table
;
2562 struct bgp_node
*rn
;
2564 if (safi
!= SAFI_MPLS_VPN
)
2565 bgp_soft_reconfig_table_rsclient (rsclient
, afi
, safi
, NULL
);
2568 for (rn
= bgp_table_top (rsclient
->bgp
->rib
[afi
][safi
]); rn
;
2569 rn
= bgp_route_next (rn
))
2570 if ((table
= rn
->info
) != NULL
)
2571 bgp_soft_reconfig_table_rsclient (rsclient
, afi
, safi
, table
);
2575 bgp_soft_reconfig_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2576 struct bgp_table
*table
)
2579 struct bgp_node
*rn
;
2580 struct bgp_adj_in
*ain
;
2583 table
= peer
->bgp
->rib
[afi
][safi
];
2585 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2586 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2588 if (ain
->peer
== peer
)
2590 ret
= bgp_update (peer
, &rn
->p
, ain
->attr
, afi
, safi
,
2591 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
,
2595 bgp_unlock_node (rn
);
2604 bgp_soft_reconfig_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2606 struct bgp_node
*rn
;
2607 struct bgp_table
*table
;
2609 if (peer
->status
!= Established
)
2612 if (safi
!= SAFI_MPLS_VPN
)
2613 bgp_soft_reconfig_table (peer
, afi
, safi
, NULL
);
2615 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2616 rn
= bgp_route_next (rn
))
2617 if ((table
= rn
->info
) != NULL
)
2618 bgp_soft_reconfig_table (peer
, afi
, safi
, table
);
2622 struct bgp_clear_node_queue
2624 struct bgp_node
*rn
;
2625 enum bgp_clear_route_type purpose
;
2628 static wq_item_status
2629 bgp_clear_route_node (struct work_queue
*wq
, void *data
)
2631 struct bgp_clear_node_queue
*cnq
= data
;
2632 struct bgp_node
*rn
= cnq
->rn
;
2633 struct peer
*peer
= wq
->spec
.data
;
2634 struct bgp_info
*ri
;
2635 afi_t afi
= rn
->table
->afi
;
2636 safi_t safi
= rn
->table
->safi
;
2638 assert (rn
&& peer
);
2640 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2641 if (ri
->peer
== peer
|| cnq
->purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2643 /* graceful restart STALE flag set. */
2644 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_NSF_WAIT
)
2645 && peer
->nsf
[afi
][safi
]
2646 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
)
2647 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
2648 bgp_info_set_flag (rn
, ri
, BGP_INFO_STALE
);
2650 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2657 bgp_clear_node_queue_del (struct work_queue
*wq
, void *data
)
2659 struct bgp_clear_node_queue
*cnq
= data
;
2660 struct bgp_node
*rn
= cnq
->rn
;
2661 struct bgp_table
*table
= rn
->table
;
2663 bgp_unlock_node (rn
);
2664 bgp_table_unlock (table
);
2665 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE
, cnq
);
2669 bgp_clear_node_complete (struct work_queue
*wq
)
2671 struct peer
*peer
= wq
->spec
.data
;
2673 /* Tickle FSM to start moving again */
2674 BGP_EVENT_ADD (peer
, Clearing_Completed
);
2676 peer_unlock (peer
); /* bgp_clear_route */
2680 bgp_clear_node_queue_init (struct peer
*peer
)
2682 char wname
[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
2684 snprintf (wname
, sizeof(wname
), "clear %s", peer
->host
);
2685 #undef CLEAR_QUEUE_NAME_LEN
2687 if ( (peer
->clear_node_queue
= work_queue_new (bm
->master
, wname
)) == NULL
)
2689 zlog_err ("%s: Failed to allocate work queue", __func__
);
2692 peer
->clear_node_queue
->spec
.hold
= 10;
2693 peer
->clear_node_queue
->spec
.workfunc
= &bgp_clear_route_node
;
2694 peer
->clear_node_queue
->spec
.del_item_data
= &bgp_clear_node_queue_del
;
2695 peer
->clear_node_queue
->spec
.completion_func
= &bgp_clear_node_complete
;
2696 peer
->clear_node_queue
->spec
.max_retries
= 0;
2698 /* we only 'lock' this peer reference when the queue is actually active */
2699 peer
->clear_node_queue
->spec
.data
= peer
;
2703 bgp_clear_route_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2704 struct bgp_table
*table
, struct peer
*rsclient
,
2705 enum bgp_clear_route_type purpose
)
2707 struct bgp_node
*rn
;
2711 table
= (rsclient
) ? rsclient
->rib
[afi
][safi
] : peer
->bgp
->rib
[afi
][safi
];
2713 /* If still no table => afi/safi isn't configured at all or smth. */
2717 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2719 struct bgp_info
*ri
;
2720 struct bgp_adj_in
*ain
;
2721 struct bgp_adj_out
*aout
;
2723 if (rn
->info
== NULL
)
2726 /* XXX:TODO: This is suboptimal, every non-empty route_node is
2727 * queued for every clearing peer, regardless of whether it is
2728 * relevant to the peer at hand.
2730 * Overview: There are 3 different indices which need to be
2731 * scrubbed, potentially, when a peer is removed:
2733 * 1 peer's routes visible via the RIB (ie accepted routes)
2734 * 2 peer's routes visible by the (optional) peer's adj-in index
2735 * 3 other routes visible by the peer's adj-out index
2737 * 3 there is no hurry in scrubbing, once the struct peer is
2738 * removed from bgp->peer, we could just GC such deleted peer's
2739 * adj-outs at our leisure.
2741 * 1 and 2 must be 'scrubbed' in some way, at least made
2742 * invisible via RIB index before peer session is allowed to be
2743 * brought back up. So one needs to know when such a 'search' is
2748 * - there'd be a single global queue or a single RIB walker
2749 * - rather than tracking which route_nodes still need to be
2750 * examined on a peer basis, we'd track which peers still
2753 * Given that our per-peer prefix-counts now should be reliable,
2754 * this may actually be achievable. It doesn't seem to be a huge
2755 * problem at this time,
2757 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2758 if (ri
->peer
== peer
|| purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2760 struct bgp_clear_node_queue
*cnq
;
2762 /* both unlocked in bgp_clear_node_queue_del */
2763 bgp_table_lock (rn
->table
);
2765 cnq
= XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE
,
2766 sizeof (struct bgp_clear_node_queue
));
2768 cnq
->purpose
= purpose
;
2769 work_queue_add (peer
->clear_node_queue
, cnq
);
2773 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2774 if (ain
->peer
== peer
|| purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2776 bgp_adj_in_remove (rn
, ain
);
2777 bgp_unlock_node (rn
);
2780 for (aout
= rn
->adj_out
; aout
; aout
= aout
->next
)
2781 if (aout
->peer
== peer
|| purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2783 bgp_adj_out_remove (rn
, aout
, peer
, afi
, safi
);
2784 bgp_unlock_node (rn
);
2792 bgp_clear_route (struct peer
*peer
, afi_t afi
, safi_t safi
,
2793 enum bgp_clear_route_type purpose
)
2795 struct bgp_node
*rn
;
2796 struct bgp_table
*table
;
2797 struct peer
*rsclient
;
2798 struct listnode
*node
, *nnode
;
2800 if (peer
->clear_node_queue
== NULL
)
2801 bgp_clear_node_queue_init (peer
);
2803 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
2804 * Idle until it receives a Clearing_Completed event. This protects
2805 * against peers which flap faster than we can we clear, which could
2808 * a) race with routes from the new session being installed before
2809 * clear_route_node visits the node (to delete the route of that
2811 * b) resource exhaustion, clear_route_node likely leads to an entry
2812 * on the process_main queue. Fast-flapping could cause that queue
2815 if (!peer
->clear_node_queue
->thread
)
2816 peer_lock (peer
); /* bgp_clear_node_complete */
2820 case BGP_CLEAR_ROUTE_NORMAL
:
2821 if (safi
!= SAFI_MPLS_VPN
)
2822 bgp_clear_route_table (peer
, afi
, safi
, NULL
, NULL
, purpose
);
2824 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2825 rn
= bgp_route_next (rn
))
2826 if ((table
= rn
->info
) != NULL
)
2827 bgp_clear_route_table (peer
, afi
, safi
, table
, NULL
, purpose
);
2829 for (ALL_LIST_ELEMENTS (peer
->bgp
->rsclient
, node
, nnode
, rsclient
))
2830 if (CHECK_FLAG(rsclient
->af_flags
[afi
][safi
],
2831 PEER_FLAG_RSERVER_CLIENT
))
2832 bgp_clear_route_table (peer
, afi
, safi
, NULL
, rsclient
, purpose
);
2835 case BGP_CLEAR_ROUTE_MY_RSCLIENT
:
2836 bgp_clear_route_table (peer
, afi
, safi
, NULL
, peer
, purpose
);
2844 /* If no routes were cleared, nothing was added to workqueue, the
2845 * completion function won't be run by workqueue code - call it here.
2846 * XXX: Actually, this assumption doesn't hold, see
2847 * bgp_clear_route_table(), we queue all non-empty nodes.
2849 * Additionally, there is a presumption in FSM that clearing is only
2850 * really needed if peer state is Established - peers in
2851 * pre-Established states shouldn't have any route-update state
2852 * associated with them (in or out).
2854 * We still can get here in pre-Established though, through
2855 * peer_delete -> bgp_fsm_change_status, so this is a useful sanity
2856 * check to ensure the assumption above holds.
2858 * At some future point, this check could be move to the top of the
2859 * function, and do a quick early-return when state is
2860 * pre-Established, avoiding above list and table scans. Once we're
2863 if (!peer
->clear_node_queue
->thread
)
2864 bgp_clear_node_complete (peer
->clear_node_queue
);
2868 bgp_clear_route_all (struct peer
*peer
)
2873 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2874 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2875 bgp_clear_route (peer
, afi
, safi
, BGP_CLEAR_ROUTE_NORMAL
);
2879 bgp_clear_adj_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2881 struct bgp_table
*table
;
2882 struct bgp_node
*rn
;
2883 struct bgp_adj_in
*ain
;
2885 table
= peer
->bgp
->rib
[afi
][safi
];
2887 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2888 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2889 if (ain
->peer
== peer
)
2891 bgp_adj_in_remove (rn
, ain
);
2892 bgp_unlock_node (rn
);
2898 bgp_clear_stale_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2900 struct bgp_node
*rn
;
2901 struct bgp_info
*ri
;
2902 struct bgp_table
*table
;
2904 table
= peer
->bgp
->rib
[afi
][safi
];
2906 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2908 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2909 if (ri
->peer
== peer
)
2911 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2912 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2918 /* Delete all kernel routes. */
2920 bgp_cleanup_routes (void)
2923 struct listnode
*node
, *nnode
;
2924 struct bgp_node
*rn
;
2925 struct bgp_table
*table
;
2926 struct bgp_info
*ri
;
2928 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
2930 table
= bgp
->rib
[AFI_IP
][SAFI_UNICAST
];
2932 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2933 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2934 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
2935 && ri
->type
== ZEBRA_ROUTE_BGP
2936 && ri
->sub_type
== BGP_ROUTE_NORMAL
)
2937 bgp_zebra_withdraw (&rn
->p
, ri
,SAFI_UNICAST
);
2939 table
= bgp
->rib
[AFI_IP6
][SAFI_UNICAST
];
2941 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2942 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2943 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
2944 && ri
->type
== ZEBRA_ROUTE_BGP
2945 && ri
->sub_type
== BGP_ROUTE_NORMAL
)
2946 bgp_zebra_withdraw (&rn
->p
, ri
,SAFI_UNICAST
);
2954 bgp_zclient_reset ();
2955 access_list_reset ();
2956 prefix_list_reset ();
2959 /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
2962 bgp_nlri_parse (struct peer
*peer
, struct attr
*attr
, struct bgp_nlri
*packet
)
2970 /* Check peer status. */
2971 if (peer
->status
!= Established
)
2975 lim
= pnt
+ packet
->length
;
2977 for (; pnt
< lim
; pnt
+= psize
)
2979 /* Clear prefix structure. */
2980 memset (&p
, 0, sizeof (struct prefix
));
2982 /* Fetch prefix length. */
2983 p
.prefixlen
= *pnt
++;
2984 p
.family
= afi2family (packet
->afi
);
2986 /* Already checked in nlri_sanity_check(). We do double check
2988 if ((packet
->afi
== AFI_IP
&& p
.prefixlen
> 32)
2989 || (packet
->afi
== AFI_IP6
&& p
.prefixlen
> 128))
2992 /* Packet size overflow check. */
2993 psize
= PSIZE (p
.prefixlen
);
2995 /* When packet overflow occur return immediately. */
2996 if (pnt
+ psize
> lim
)
2999 /* Fetch prefix from NLRI packet. */
3000 memcpy (&p
.u
.prefix
, pnt
, psize
);
3002 /* Check address. */
3003 if (packet
->afi
== AFI_IP
&& packet
->safi
== SAFI_UNICAST
)
3005 if (IN_CLASSD (ntohl (p
.u
.prefix4
.s_addr
)))
3008 * From draft-ietf-idr-bgp4-22, Section 6.3:
3009 * If a BGP router receives an UPDATE message with a
3010 * semantically incorrect NLRI field, in which a prefix is
3011 * semantically incorrect (eg. an unexpected multicast IP
3012 * address), it should ignore the prefix.
3014 zlog (peer
->log
, LOG_ERR
,
3015 "IPv4 unicast NLRI is multicast address %s",
3016 inet_ntoa (p
.u
.prefix4
));
3023 /* Check address. */
3024 if (packet
->afi
== AFI_IP6
&& packet
->safi
== SAFI_UNICAST
)
3026 if (IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3030 zlog (peer
->log
, LOG_WARNING
,
3031 "IPv6 link-local NLRI received %s ignore this NLRI",
3032 inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3037 #endif /* HAVE_IPV6 */
3039 /* Normal process. */
3041 ret
= bgp_update (peer
, &p
, attr
, packet
->afi
, packet
->safi
,
3042 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
3044 ret
= bgp_withdraw (peer
, &p
, attr
, packet
->afi
, packet
->safi
,
3045 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
3047 /* Address family configuration mismatch or maximum-prefix count
3053 /* Packet length consistency check. */
3060 /* NLRI encode syntax check routine. */
3062 bgp_nlri_sanity_check (struct peer
*peer
, int afi
, u_char
*pnt
,
3071 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
3072 syntactic validity. If the field is syntactically incorrect,
3073 then the Error Subcode is set to Invalid Network Field. */
3079 /* Prefix length check. */
3080 if ((afi
== AFI_IP
&& prefixlen
> 32)
3081 || (afi
== AFI_IP6
&& prefixlen
> 128))
3083 plog_err (peer
->log
,
3084 "%s [Error] Update packet error (wrong prefix length %d)",
3085 peer
->host
, prefixlen
);
3086 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3087 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3091 /* Packet size overflow check. */
3092 psize
= PSIZE (prefixlen
);
3094 if (pnt
+ psize
> end
)
3096 plog_err (peer
->log
,
3097 "%s [Error] Update packet error"
3098 " (prefix data overflow prefix size is %d)",
3100 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3101 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3108 /* Packet length consistency check. */
3111 plog_err (peer
->log
,
3112 "%s [Error] Update packet error"
3113 " (prefix length mismatch with total length)",
3115 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3116 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3122 static struct bgp_static
*
3123 bgp_static_new (void)
3125 return XCALLOC (MTYPE_BGP_STATIC
, sizeof (struct bgp_static
));
3129 bgp_static_free (struct bgp_static
*bgp_static
)
3131 if (bgp_static
->rmap
.name
)
3132 free (bgp_static
->rmap
.name
);
3133 XFREE (MTYPE_BGP_STATIC
, bgp_static
);
3137 bgp_static_withdraw_rsclient (struct bgp
*bgp
, struct peer
*rsclient
,
3138 struct prefix
*p
, afi_t afi
, safi_t safi
)
3140 struct bgp_node
*rn
;
3141 struct bgp_info
*ri
;
3143 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3145 /* Check selected route and self inserted route. */
3146 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3147 if (ri
->peer
== bgp
->peer_self
3148 && ri
->type
== ZEBRA_ROUTE_BGP
3149 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3152 /* Withdraw static BGP route from routing table. */
3155 bgp_info_delete (rn
, ri
);
3156 bgp_process (bgp
, rn
, afi
, safi
);
3159 /* Unlock bgp_node_lookup. */
3160 bgp_unlock_node (rn
);
3164 bgp_static_update_rsclient (struct peer
*rsclient
, struct prefix
*p
,
3165 struct bgp_static
*bgp_static
,
3166 afi_t afi
, safi_t safi
)
3168 struct bgp_node
*rn
;
3169 struct bgp_info
*ri
;
3170 struct bgp_info
*new;
3171 struct bgp_info info
;
3172 struct attr
*attr_new
;
3173 struct attr attr
= {0 };
3174 struct attr new_attr
= { .extra
= 0 };
3177 char buf
[SU_ADDRSTRLEN
];
3179 bgp
= rsclient
->bgp
;
3181 assert (bgp_static
);
3185 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3187 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3189 attr
.nexthop
= bgp_static
->igpnexthop
;
3190 attr
.med
= bgp_static
->igpmetric
;
3191 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3193 if (bgp_static
->atomic
)
3194 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3196 /* Apply network route-map for export to this rsclient. */
3197 if (bgp_static
->rmap
.name
)
3199 struct attr attr_tmp
= attr
;
3200 info
.peer
= rsclient
;
3201 info
.attr
= &attr_tmp
;
3203 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_EXPORT
);
3204 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3206 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3208 rsclient
->rmap_type
= 0;
3210 if (ret
== RMAP_DENYMATCH
)
3212 /* Free uninterned attribute. */
3213 bgp_attr_flush (&attr_tmp
);
3215 /* Unintern original. */
3216 aspath_unintern (&attr
.aspath
);
3217 bgp_static_withdraw_rsclient (bgp
, rsclient
, p
, afi
, safi
);
3218 bgp_attr_extra_free (&attr
);
3222 attr_new
= bgp_attr_intern (&attr_tmp
);
3225 attr_new
= bgp_attr_intern (&attr
);
3227 bgp_attr_dup(&new_attr
, attr_new
);
3229 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3231 if (bgp_import_modifier (rsclient
, bgp
->peer_self
, p
, &new_attr
, afi
, safi
)
3234 /* This BGP update is filtered. Log the reason then update BGP entry. */
3235 if (BGP_DEBUG (update
, UPDATE_IN
))
3236 zlog (rsclient
->log
, LOG_DEBUG
,
3237 "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
3238 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
3239 p
->prefixlen
, rsclient
->host
);
3241 bgp
->peer_self
->rmap_type
= 0;
3243 bgp_attr_unintern (&attr_new
);
3244 aspath_unintern (&attr
.aspath
);
3245 bgp_attr_extra_free (&attr
);
3247 bgp_static_withdraw_rsclient (bgp
, rsclient
, p
, afi
, safi
);
3252 bgp
->peer_self
->rmap_type
= 0;
3254 bgp_attr_unintern (&attr_new
);
3255 attr_new
= bgp_attr_intern (&new_attr
);
3256 bgp_attr_extra_free (&new_attr
);
3258 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3259 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3260 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3265 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3266 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3268 bgp_unlock_node (rn
);
3269 bgp_attr_unintern (&attr_new
);
3270 aspath_unintern (&attr
.aspath
);
3271 bgp_attr_extra_free (&attr
);
3276 /* The attribute is changed. */
3277 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3279 /* Rewrite BGP route information. */
3280 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3281 bgp_info_restore(rn
, ri
);
3282 bgp_attr_unintern (&ri
->attr
);
3283 ri
->attr
= attr_new
;
3284 ri
->uptime
= bgp_clock ();
3286 /* Process change. */
3287 bgp_process (bgp
, rn
, afi
, safi
);
3288 bgp_unlock_node (rn
);
3289 aspath_unintern (&attr
.aspath
);
3290 bgp_attr_extra_free (&attr
);
3295 /* Make new BGP info. */
3296 new = bgp_info_new ();
3297 new->type
= ZEBRA_ROUTE_BGP
;
3298 new->sub_type
= BGP_ROUTE_STATIC
;
3299 new->peer
= bgp
->peer_self
;
3300 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3301 new->attr
= attr_new
;
3302 new->uptime
= bgp_clock ();
3304 /* Register new BGP information. */
3305 bgp_info_add (rn
, new);
3307 /* route_node_get lock */
3308 bgp_unlock_node (rn
);
3310 /* Process change. */
3311 bgp_process (bgp
, rn
, afi
, safi
);
3313 /* Unintern original. */
3314 aspath_unintern (&attr
.aspath
);
3315 bgp_attr_extra_free (&attr
);
3319 bgp_static_update_main (struct bgp
*bgp
, struct prefix
*p
,
3320 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3322 struct bgp_node
*rn
;
3323 struct bgp_info
*ri
;
3324 struct bgp_info
*new;
3325 struct bgp_info info
;
3326 struct attr attr
= { 0 };
3327 struct attr
*attr_new
;
3330 assert (bgp_static
);
3334 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3336 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3338 attr
.nexthop
= bgp_static
->igpnexthop
;
3339 attr
.med
= bgp_static
->igpmetric
;
3340 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3342 if (bgp_static
->atomic
)
3343 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3345 /* Apply route-map. */
3346 if (bgp_static
->rmap
.name
)
3348 struct attr attr_tmp
= attr
;
3349 info
.peer
= bgp
->peer_self
;
3350 info
.attr
= &attr_tmp
;
3352 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3354 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3356 bgp
->peer_self
->rmap_type
= 0;
3358 if (ret
== RMAP_DENYMATCH
)
3360 /* Free uninterned attribute. */
3361 bgp_attr_flush (&attr_tmp
);
3363 /* Unintern original. */
3364 aspath_unintern (&attr
.aspath
);
3365 bgp_attr_extra_free (&attr
);
3366 bgp_static_withdraw (bgp
, p
, afi
, safi
);
3369 attr_new
= bgp_attr_intern (&attr_tmp
);
3372 attr_new
= bgp_attr_intern (&attr
);
3374 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3375 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3376 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3381 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3382 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3384 bgp_unlock_node (rn
);
3385 bgp_attr_unintern (&attr_new
);
3386 aspath_unintern (&attr
.aspath
);
3387 bgp_attr_extra_free (&attr
);
3392 /* The attribute is changed. */
3393 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3395 /* Rewrite BGP route information. */
3396 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3397 bgp_info_restore(rn
, ri
);
3399 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3400 bgp_attr_unintern (&ri
->attr
);
3401 ri
->attr
= attr_new
;
3402 ri
->uptime
= bgp_clock ();
3404 /* Process change. */
3405 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3406 bgp_process (bgp
, rn
, afi
, safi
);
3407 bgp_unlock_node (rn
);
3408 aspath_unintern (&attr
.aspath
);
3409 bgp_attr_extra_free (&attr
);
3414 /* Make new BGP info. */
3415 new = bgp_info_new ();
3416 new->type
= ZEBRA_ROUTE_BGP
;
3417 new->sub_type
= BGP_ROUTE_STATIC
;
3418 new->peer
= bgp
->peer_self
;
3419 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3420 new->attr
= attr_new
;
3421 new->uptime
= bgp_clock ();
3423 /* Aggregate address increment. */
3424 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3426 /* Register new BGP information. */
3427 bgp_info_add (rn
, new);
3429 /* route_node_get lock */
3430 bgp_unlock_node (rn
);
3432 /* Process change. */
3433 bgp_process (bgp
, rn
, afi
, safi
);
3435 /* Unintern original. */
3436 aspath_unintern (&attr
.aspath
);
3437 bgp_attr_extra_free (&attr
);
3441 bgp_static_update (struct bgp
*bgp
, struct prefix
*p
,
3442 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3444 struct peer
*rsclient
;
3445 struct listnode
*node
, *nnode
;
3447 bgp_static_update_main (bgp
, p
, bgp_static
, afi
, safi
);
3449 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
3451 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
3452 bgp_static_update_rsclient (rsclient
, p
, bgp_static
, afi
, safi
);
3457 bgp_static_update_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3458 safi_t safi
, struct prefix_rd
*prd
, u_char
*tag
)
3460 struct bgp_node
*rn
;
3461 struct bgp_info
*new;
3463 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3465 /* Make new BGP info. */
3466 new = bgp_info_new ();
3467 new->type
= ZEBRA_ROUTE_BGP
;
3468 new->sub_type
= BGP_ROUTE_STATIC
;
3469 new->peer
= bgp
->peer_self
;
3470 new->attr
= bgp_attr_default_intern (BGP_ORIGIN_IGP
);
3471 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3472 new->uptime
= bgp_clock ();
3473 new->extra
= bgp_info_extra_new();
3474 memcpy (new->extra
->tag
, tag
, 3);
3476 /* Aggregate address increment. */
3477 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3479 /* Register new BGP information. */
3480 bgp_info_add (rn
, new);
3482 /* route_node_get lock */
3483 bgp_unlock_node (rn
);
3485 /* Process change. */
3486 bgp_process (bgp
, rn
, afi
, safi
);
3490 bgp_static_withdraw (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3493 struct bgp_node
*rn
;
3494 struct bgp_info
*ri
;
3496 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3498 /* Check selected route and self inserted route. */
3499 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3500 if (ri
->peer
== bgp
->peer_self
3501 && ri
->type
== ZEBRA_ROUTE_BGP
3502 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3505 /* Withdraw static BGP route from routing table. */
3508 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3509 bgp_info_delete (rn
, ri
);
3510 bgp_process (bgp
, rn
, afi
, safi
);
3513 /* Unlock bgp_node_lookup. */
3514 bgp_unlock_node (rn
);
3518 bgp_check_local_routes_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
)
3520 struct bgp_static
*bgp_static
;
3522 struct bgp_node
*rn
;
3525 bgp
= rsclient
->bgp
;
3527 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3528 if ((bgp_static
= rn
->info
) != NULL
)
3532 bgp_static_update_rsclient (rsclient
, p
, bgp_static
,
3538 bgp_static_withdraw_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3539 safi_t safi
, struct prefix_rd
*prd
, u_char
*tag
)
3541 struct bgp_node
*rn
;
3542 struct bgp_info
*ri
;
3544 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3546 /* Check selected route and self inserted route. */
3547 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3548 if (ri
->peer
== bgp
->peer_self
3549 && ri
->type
== ZEBRA_ROUTE_BGP
3550 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3553 /* Withdraw static BGP route from routing table. */
3556 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3557 bgp_info_delete (rn
, ri
);
3558 bgp_process (bgp
, rn
, afi
, safi
);
3561 /* Unlock bgp_node_lookup. */
3562 bgp_unlock_node (rn
);
3565 /* Configure static BGP network. When user don't run zebra, static
3566 route should be installed as valid. */
3568 bgp_static_set (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3569 afi_t afi
, safi_t safi
, const char *rmap
, int backdoor
)
3573 struct bgp_static
*bgp_static
;
3574 struct bgp_node
*rn
;
3575 u_char need_update
= 0;
3577 /* Convert IP prefix string to struct prefix. */
3578 ret
= str2prefix (ip_str
, &p
);
3581 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3585 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3587 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3591 #endif /* HAVE_IPV6 */
3595 /* Set BGP static route configuration. */
3596 rn
= bgp_node_get (bgp
->route
[afi
][safi
], &p
);
3600 /* Configuration change. */
3601 bgp_static
= rn
->info
;
3603 /* Check previous routes are installed into BGP. */
3604 if (bgp_static
->valid
&& bgp_static
->backdoor
!= backdoor
)
3607 bgp_static
->backdoor
= backdoor
;
3611 if (bgp_static
->rmap
.name
)
3612 free (bgp_static
->rmap
.name
);
3613 bgp_static
->rmap
.name
= strdup (rmap
);
3614 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3618 if (bgp_static
->rmap
.name
)
3619 free (bgp_static
->rmap
.name
);
3620 bgp_static
->rmap
.name
= NULL
;
3621 bgp_static
->rmap
.map
= NULL
;
3622 bgp_static
->valid
= 0;
3624 bgp_unlock_node (rn
);
3628 /* New configuration. */
3629 bgp_static
= bgp_static_new ();
3630 bgp_static
->backdoor
= backdoor
;
3631 bgp_static
->valid
= 0;
3632 bgp_static
->igpmetric
= 0;
3633 bgp_static
->igpnexthop
.s_addr
= 0;
3637 if (bgp_static
->rmap
.name
)
3638 free (bgp_static
->rmap
.name
);
3639 bgp_static
->rmap
.name
= strdup (rmap
);
3640 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3642 rn
->info
= bgp_static
;
3645 /* If BGP scan is not enabled, we should install this route here. */
3646 if (! bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3648 bgp_static
->valid
= 1;
3651 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3653 if (! bgp_static
->backdoor
)
3654 bgp_static_update (bgp
, &p
, bgp_static
, afi
, safi
);
3660 /* Configure static BGP network. */
3662 bgp_static_unset (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3663 afi_t afi
, safi_t safi
)
3667 struct bgp_static
*bgp_static
;
3668 struct bgp_node
*rn
;
3670 /* Convert IP prefix string to struct prefix. */
3671 ret
= str2prefix (ip_str
, &p
);
3674 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3678 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3680 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3684 #endif /* HAVE_IPV6 */
3688 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], &p
);
3691 vty_out (vty
, "%% Can't find specified static route configuration.%s",
3696 bgp_static
= rn
->info
;
3698 /* Update BGP RIB. */
3699 if (! bgp_static
->backdoor
)
3700 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3702 /* Clear configuration. */
3703 bgp_static_free (bgp_static
);
3705 bgp_unlock_node (rn
);
3706 bgp_unlock_node (rn
);
3711 /* Called from bgp_delete(). Delete all static routes from the BGP
3714 bgp_static_delete (struct bgp
*bgp
)
3718 struct bgp_node
*rn
;
3719 struct bgp_node
*rm
;
3720 struct bgp_table
*table
;
3721 struct bgp_static
*bgp_static
;
3723 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3724 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3725 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3726 if (rn
->info
!= NULL
)
3728 if (safi
== SAFI_MPLS_VPN
)
3732 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
3734 bgp_static
= rn
->info
;
3735 bgp_static_withdraw_vpnv4 (bgp
, &rm
->p
,
3736 AFI_IP
, SAFI_MPLS_VPN
,
3737 (struct prefix_rd
*)&rn
->p
,
3739 bgp_static_free (bgp_static
);
3741 bgp_unlock_node (rn
);
3746 bgp_static
= rn
->info
;
3747 bgp_static_withdraw (bgp
, &rn
->p
, afi
, safi
);
3748 bgp_static_free (bgp_static
);
3750 bgp_unlock_node (rn
);
3756 bgp_static_set_vpnv4 (struct vty
*vty
, const char *ip_str
, const char *rd_str
,
3757 const char *tag_str
)
3761 struct prefix_rd prd
;
3763 struct bgp_node
*prn
;
3764 struct bgp_node
*rn
;
3765 struct bgp_table
*table
;
3766 struct bgp_static
*bgp_static
;
3771 ret
= str2prefix (ip_str
, &p
);
3774 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3779 ret
= str2prefix_rd (rd_str
, &prd
);
3782 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3786 ret
= str2tag (tag_str
, tag
);
3789 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3793 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3794 (struct prefix
*)&prd
);
3795 if (prn
->info
== NULL
)
3796 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3798 bgp_unlock_node (prn
);
3801 rn
= bgp_node_get (table
, &p
);
3805 vty_out (vty
, "%% Same network configuration exists%s", VTY_NEWLINE
);
3806 bgp_unlock_node (rn
);
3810 /* New configuration. */
3811 bgp_static
= bgp_static_new ();
3812 bgp_static
->valid
= 1;
3813 memcpy (bgp_static
->tag
, tag
, 3);
3814 rn
->info
= bgp_static
;
3816 bgp_static_update_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3822 /* Configure static BGP network. */
3824 bgp_static_unset_vpnv4 (struct vty
*vty
, const char *ip_str
,
3825 const char *rd_str
, const char *tag_str
)
3830 struct prefix_rd prd
;
3831 struct bgp_node
*prn
;
3832 struct bgp_node
*rn
;
3833 struct bgp_table
*table
;
3834 struct bgp_static
*bgp_static
;
3839 /* Convert IP prefix string to struct prefix. */
3840 ret
= str2prefix (ip_str
, &p
);
3843 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3848 ret
= str2prefix_rd (rd_str
, &prd
);
3851 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3855 ret
= str2tag (tag_str
, tag
);
3858 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3862 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3863 (struct prefix
*)&prd
);
3864 if (prn
->info
== NULL
)
3865 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3867 bgp_unlock_node (prn
);
3870 rn
= bgp_node_lookup (table
, &p
);
3874 bgp_static_withdraw_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3876 bgp_static
= rn
->info
;
3877 bgp_static_free (bgp_static
);
3879 bgp_unlock_node (rn
);
3880 bgp_unlock_node (rn
);
3883 vty_out (vty
, "%% Can't find the route%s", VTY_NEWLINE
);
3890 "network A.B.C.D/M",
3891 "Specify a network to announce via BGP\n"
3892 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
3894 return bgp_static_set (vty
, vty
->index
, argv
[0],
3895 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
3898 DEFUN (bgp_network_route_map
,
3899 bgp_network_route_map_cmd
,
3900 "network A.B.C.D/M route-map WORD",
3901 "Specify a network to announce via BGP\n"
3902 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3903 "Route-map to modify the attributes\n"
3904 "Name of the route map\n")
3906 return bgp_static_set (vty
, vty
->index
, argv
[0],
3907 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
3910 DEFUN (bgp_network_backdoor
,
3911 bgp_network_backdoor_cmd
,
3912 "network A.B.C.D/M backdoor",
3913 "Specify a network to announce via BGP\n"
3914 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3915 "Specify a BGP backdoor route\n")
3917 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP
, SAFI_UNICAST
,
3921 DEFUN (bgp_network_mask
,
3922 bgp_network_mask_cmd
,
3923 "network A.B.C.D mask A.B.C.D",
3924 "Specify a network to announce via BGP\n"
3930 char prefix_str
[BUFSIZ
];
3932 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3935 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3939 return bgp_static_set (vty
, vty
->index
, prefix_str
,
3940 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
3943 DEFUN (bgp_network_mask_route_map
,
3944 bgp_network_mask_route_map_cmd
,
3945 "network A.B.C.D mask A.B.C.D route-map WORD",
3946 "Specify a network to announce via BGP\n"
3950 "Route-map to modify the attributes\n"
3951 "Name of the route map\n")
3954 char prefix_str
[BUFSIZ
];
3956 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3959 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3963 return bgp_static_set (vty
, vty
->index
, prefix_str
,
3964 AFI_IP
, bgp_node_safi (vty
), argv
[2], 0);
3967 DEFUN (bgp_network_mask_backdoor
,
3968 bgp_network_mask_backdoor_cmd
,
3969 "network A.B.C.D mask A.B.C.D backdoor",
3970 "Specify a network to announce via BGP\n"
3974 "Specify a BGP backdoor route\n")
3977 char prefix_str
[BUFSIZ
];
3979 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3982 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3986 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
3990 DEFUN (bgp_network_mask_natural
,
3991 bgp_network_mask_natural_cmd
,
3993 "Specify a network to announce via BGP\n"
3997 char prefix_str
[BUFSIZ
];
3999 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4002 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4006 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4007 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4010 DEFUN (bgp_network_mask_natural_route_map
,
4011 bgp_network_mask_natural_route_map_cmd
,
4012 "network A.B.C.D route-map WORD",
4013 "Specify a network to announce via BGP\n"
4015 "Route-map to modify the attributes\n"
4016 "Name of the route map\n")
4019 char prefix_str
[BUFSIZ
];
4021 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4024 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4028 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4029 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4032 DEFUN (bgp_network_mask_natural_backdoor
,
4033 bgp_network_mask_natural_backdoor_cmd
,
4034 "network A.B.C.D backdoor",
4035 "Specify a network to announce via BGP\n"
4037 "Specify a BGP backdoor route\n")
4040 char prefix_str
[BUFSIZ
];
4042 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4045 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4049 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4053 DEFUN (no_bgp_network
,
4055 "no network A.B.C.D/M",
4057 "Specify a network to announce via BGP\n"
4058 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4060 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP
,
4061 bgp_node_safi (vty
));
4064 ALIAS (no_bgp_network
,
4065 no_bgp_network_route_map_cmd
,
4066 "no network A.B.C.D/M route-map WORD",
4068 "Specify a network to announce via BGP\n"
4069 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4070 "Route-map to modify the attributes\n"
4071 "Name of the route map\n")
4073 ALIAS (no_bgp_network
,
4074 no_bgp_network_backdoor_cmd
,
4075 "no network A.B.C.D/M backdoor",
4077 "Specify a network to announce via BGP\n"
4078 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4079 "Specify a BGP backdoor route\n")
4081 DEFUN (no_bgp_network_mask
,
4082 no_bgp_network_mask_cmd
,
4083 "no network A.B.C.D mask A.B.C.D",
4085 "Specify a network to announce via BGP\n"
4091 char prefix_str
[BUFSIZ
];
4093 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4096 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4100 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4101 bgp_node_safi (vty
));
4104 ALIAS (no_bgp_network_mask
,
4105 no_bgp_network_mask_route_map_cmd
,
4106 "no network A.B.C.D mask A.B.C.D route-map WORD",
4108 "Specify a network to announce via BGP\n"
4112 "Route-map to modify the attributes\n"
4113 "Name of the route map\n")
4115 ALIAS (no_bgp_network_mask
,
4116 no_bgp_network_mask_backdoor_cmd
,
4117 "no network A.B.C.D mask A.B.C.D backdoor",
4119 "Specify a network to announce via BGP\n"
4123 "Specify a BGP backdoor route\n")
4125 DEFUN (no_bgp_network_mask_natural
,
4126 no_bgp_network_mask_natural_cmd
,
4127 "no network A.B.C.D",
4129 "Specify a network to announce via BGP\n"
4133 char prefix_str
[BUFSIZ
];
4135 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4138 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4142 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4143 bgp_node_safi (vty
));
4146 ALIAS (no_bgp_network_mask_natural
,
4147 no_bgp_network_mask_natural_route_map_cmd
,
4148 "no network A.B.C.D route-map WORD",
4150 "Specify a network to announce via BGP\n"
4152 "Route-map to modify the attributes\n"
4153 "Name of the route map\n")
4155 ALIAS (no_bgp_network_mask_natural
,
4156 no_bgp_network_mask_natural_backdoor_cmd
,
4157 "no network A.B.C.D backdoor",
4159 "Specify a network to announce via BGP\n"
4161 "Specify a BGP backdoor route\n")
4164 DEFUN (ipv6_bgp_network
,
4165 ipv6_bgp_network_cmd
,
4166 "network X:X::X:X/M",
4167 "Specify a network to announce via BGP\n"
4168 "IPv6 prefix <network>/<length>\n")
4170 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
),
4174 DEFUN (ipv6_bgp_network_route_map
,
4175 ipv6_bgp_network_route_map_cmd
,
4176 "network X:X::X:X/M route-map WORD",
4177 "Specify a network to announce via BGP\n"
4178 "IPv6 prefix <network>/<length>\n"
4179 "Route-map to modify the attributes\n"
4180 "Name of the route map\n")
4182 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
,
4183 bgp_node_safi (vty
), argv
[1], 0);
4186 DEFUN (no_ipv6_bgp_network
,
4187 no_ipv6_bgp_network_cmd
,
4188 "no network X:X::X:X/M",
4190 "Specify a network to announce via BGP\n"
4191 "IPv6 prefix <network>/<length>\n")
4193 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
));
4196 ALIAS (no_ipv6_bgp_network
,
4197 no_ipv6_bgp_network_route_map_cmd
,
4198 "no network X:X::X:X/M route-map WORD",
4200 "Specify a network to announce via BGP\n"
4201 "IPv6 prefix <network>/<length>\n"
4202 "Route-map to modify the attributes\n"
4203 "Name of the route map\n")
4205 ALIAS (ipv6_bgp_network
,
4206 old_ipv6_bgp_network_cmd
,
4207 "ipv6 bgp network X:X::X:X/M",
4210 "Specify a network to announce via BGP\n"
4211 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4213 ALIAS (no_ipv6_bgp_network
,
4214 old_no_ipv6_bgp_network_cmd
,
4215 "no ipv6 bgp network X:X::X:X/M",
4219 "Specify a network to announce via BGP\n"
4220 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4221 #endif /* HAVE_IPV6 */
4223 /* stubs for removed AS-Pathlimit commands, kept for config compatibility */
4224 ALIAS_DEPRECATED (bgp_network
,
4225 bgp_network_ttl_cmd
,
4226 "network A.B.C.D/M pathlimit <0-255>",
4227 "Specify a network to announce via BGP\n"
4228 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4229 "AS-Path hopcount limit attribute\n"
4230 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4231 ALIAS_DEPRECATED (bgp_network_backdoor
,
4232 bgp_network_backdoor_ttl_cmd
,
4233 "network A.B.C.D/M backdoor pathlimit <0-255>",
4234 "Specify a network to announce via BGP\n"
4235 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4236 "Specify a BGP backdoor route\n"
4237 "AS-Path hopcount limit attribute\n"
4238 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4239 ALIAS_DEPRECATED (bgp_network_mask
,
4240 bgp_network_mask_ttl_cmd
,
4241 "network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4242 "Specify a network to announce via BGP\n"
4246 "AS-Path hopcount limit attribute\n"
4247 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4248 ALIAS_DEPRECATED (bgp_network_mask_backdoor
,
4249 bgp_network_mask_backdoor_ttl_cmd
,
4250 "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4251 "Specify a network to announce via BGP\n"
4255 "Specify a BGP backdoor route\n"
4256 "AS-Path hopcount limit attribute\n"
4257 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4258 ALIAS_DEPRECATED (bgp_network_mask_natural
,
4259 bgp_network_mask_natural_ttl_cmd
,
4260 "network A.B.C.D pathlimit <0-255>",
4261 "Specify a network to announce via BGP\n"
4263 "AS-Path hopcount limit attribute\n"
4264 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4265 ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor
,
4266 bgp_network_mask_natural_backdoor_ttl_cmd
,
4267 "network A.B.C.D backdoor pathlimit (1-255>",
4268 "Specify a network to announce via BGP\n"
4270 "Specify a BGP backdoor route\n"
4271 "AS-Path hopcount limit attribute\n"
4272 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4273 ALIAS_DEPRECATED (no_bgp_network
,
4274 no_bgp_network_ttl_cmd
,
4275 "no network A.B.C.D/M pathlimit <0-255>",
4277 "Specify a network to announce via BGP\n"
4278 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4279 "AS-Path hopcount limit attribute\n"
4280 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4281 ALIAS_DEPRECATED (no_bgp_network
,
4282 no_bgp_network_backdoor_ttl_cmd
,
4283 "no network A.B.C.D/M backdoor pathlimit <0-255>",
4285 "Specify a network to announce via BGP\n"
4286 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4287 "Specify a BGP backdoor route\n"
4288 "AS-Path hopcount limit attribute\n"
4289 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4290 ALIAS_DEPRECATED (no_bgp_network
,
4291 no_bgp_network_mask_ttl_cmd
,
4292 "no network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4294 "Specify a network to announce via BGP\n"
4298 "AS-Path hopcount limit attribute\n"
4299 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4300 ALIAS_DEPRECATED (no_bgp_network_mask
,
4301 no_bgp_network_mask_backdoor_ttl_cmd
,
4302 "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4304 "Specify a network to announce via BGP\n"
4308 "Specify a BGP backdoor route\n"
4309 "AS-Path hopcount limit attribute\n"
4310 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4311 ALIAS_DEPRECATED (no_bgp_network_mask_natural
,
4312 no_bgp_network_mask_natural_ttl_cmd
,
4313 "no network A.B.C.D pathlimit <0-255>",
4315 "Specify a network to announce via BGP\n"
4317 "AS-Path hopcount limit attribute\n"
4318 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4319 ALIAS_DEPRECATED (no_bgp_network_mask_natural
,
4320 no_bgp_network_mask_natural_backdoor_ttl_cmd
,
4321 "no network A.B.C.D backdoor pathlimit <0-255>",
4323 "Specify a network to announce via BGP\n"
4325 "Specify a BGP backdoor route\n"
4326 "AS-Path hopcount limit attribute\n"
4327 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4329 ALIAS_DEPRECATED (ipv6_bgp_network
,
4330 ipv6_bgp_network_ttl_cmd
,
4331 "network X:X::X:X/M pathlimit <0-255>",
4332 "Specify a network to announce via BGP\n"
4333 "IPv6 prefix <network>/<length>\n"
4334 "AS-Path hopcount limit attribute\n"
4335 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4336 ALIAS_DEPRECATED (no_ipv6_bgp_network
,
4337 no_ipv6_bgp_network_ttl_cmd
,
4338 "no network X:X::X:X/M pathlimit <0-255>",
4340 "Specify a network to announce via BGP\n"
4341 "IPv6 prefix <network>/<length>\n"
4342 "AS-Path hopcount limit attribute\n"
4343 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4344 #endif /* HAVE_IPV6 */
4346 /* Aggreagete address:
4348 advertise-map Set condition to advertise attribute
4349 as-set Generate AS set path information
4350 attribute-map Set attributes of aggregate
4351 route-map Set parameters of aggregate
4352 summary-only Filter more specific routes from updates
4353 suppress-map Conditionally filter more specific routes from updates
4356 struct bgp_aggregate
4358 /* Summary-only flag. */
4359 u_char summary_only
;
4361 /* AS set generation. */
4364 /* Route-map for aggregated route. */
4365 struct route_map
*map
;
4367 /* Suppress-count. */
4368 unsigned long count
;
4370 /* SAFI configuration. */
4374 static struct bgp_aggregate
*
4375 bgp_aggregate_new (void)
4377 return XCALLOC (MTYPE_BGP_AGGREGATE
, sizeof (struct bgp_aggregate
));
4381 bgp_aggregate_free (struct bgp_aggregate
*aggregate
)
4383 XFREE (MTYPE_BGP_AGGREGATE
, aggregate
);
4387 bgp_aggregate_route (struct bgp
*bgp
, struct prefix
*p
, struct bgp_info
*rinew
,
4388 afi_t afi
, safi_t safi
, struct bgp_info
*del
,
4389 struct bgp_aggregate
*aggregate
)
4391 struct bgp_table
*table
;
4392 struct bgp_node
*top
;
4393 struct bgp_node
*rn
;
4395 struct aspath
*aspath
= NULL
;
4396 struct aspath
*asmerge
= NULL
;
4397 struct community
*community
= NULL
;
4398 struct community
*commerge
= NULL
;
4399 struct in_addr nexthop
;
4401 struct bgp_info
*ri
;
4402 struct bgp_info
*new;
4404 unsigned long match
= 0;
4406 /* Record adding route's nexthop and med. */
4409 nexthop
= rinew
->attr
->nexthop
;
4410 med
= rinew
->attr
->med
;
4413 /* ORIGIN attribute: If at least one route among routes that are
4414 aggregated has ORIGIN with the value INCOMPLETE, then the
4415 aggregated route must have the ORIGIN attribute with the value
4416 INCOMPLETE. Otherwise, if at least one route among routes that
4417 are aggregated has ORIGIN with the value EGP, then the aggregated
4418 route must have the origin attribute with the value EGP. In all
4419 other case the value of the ORIGIN attribute of the aggregated
4420 route is INTERNAL. */
4421 origin
= BGP_ORIGIN_IGP
;
4423 table
= bgp
->rib
[afi
][safi
];
4425 top
= bgp_node_get (table
, p
);
4426 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4427 if (rn
->p
.prefixlen
> p
->prefixlen
)
4431 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4433 if (BGP_INFO_HOLDDOWN (ri
))
4436 if (del
&& ri
== del
)
4439 if (! rinew
&& first
)
4441 nexthop
= ri
->attr
->nexthop
;
4442 med
= ri
->attr
->med
;
4446 #ifdef AGGREGATE_NEXTHOP_CHECK
4447 if (! IPV4_ADDR_SAME (&ri
->attr
->nexthop
, &nexthop
)
4448 || ri
->attr
->med
!= med
)
4451 aspath_free (aspath
);
4453 community_free (community
);
4454 bgp_unlock_node (rn
);
4455 bgp_unlock_node (top
);
4458 #endif /* AGGREGATE_NEXTHOP_CHECK */
4460 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4462 if (aggregate
->summary_only
)
4464 (bgp_info_extra_get (ri
))->suppress
++;
4465 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4471 if (aggregate
->as_set
)
4473 if (origin
< ri
->attr
->origin
)
4474 origin
= ri
->attr
->origin
;
4478 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4479 aspath_free (aspath
);
4483 aspath
= aspath_dup (ri
->attr
->aspath
);
4485 if (ri
->attr
->community
)
4489 commerge
= community_merge (community
,
4490 ri
->attr
->community
);
4491 community
= community_uniq_sort (commerge
);
4492 community_free (commerge
);
4495 community
= community_dup (ri
->attr
->community
);
4501 bgp_process (bgp
, rn
, afi
, safi
);
4503 bgp_unlock_node (top
);
4509 if (aggregate
->summary_only
)
4510 (bgp_info_extra_get (rinew
))->suppress
++;
4512 if (aggregate
->as_set
)
4514 if (origin
< rinew
->attr
->origin
)
4515 origin
= rinew
->attr
->origin
;
4519 asmerge
= aspath_aggregate (aspath
, rinew
->attr
->aspath
);
4520 aspath_free (aspath
);
4524 aspath
= aspath_dup (rinew
->attr
->aspath
);
4526 if (rinew
->attr
->community
)
4530 commerge
= community_merge (community
,
4531 rinew
->attr
->community
);
4532 community
= community_uniq_sort (commerge
);
4533 community_free (commerge
);
4536 community
= community_dup (rinew
->attr
->community
);
4541 if (aggregate
->count
> 0)
4543 rn
= bgp_node_get (table
, p
);
4544 new = bgp_info_new ();
4545 new->type
= ZEBRA_ROUTE_BGP
;
4546 new->sub_type
= BGP_ROUTE_AGGREGATE
;
4547 new->peer
= bgp
->peer_self
;
4548 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4549 new->attr
= bgp_attr_aggregate_intern (bgp
, origin
, aspath
, community
, aggregate
->as_set
);
4550 new->uptime
= bgp_clock ();
4552 bgp_info_add (rn
, new);
4553 bgp_unlock_node (rn
);
4554 bgp_process (bgp
, rn
, afi
, safi
);
4559 aspath_free (aspath
);
4561 community_free (community
);
4565 void bgp_aggregate_delete (struct bgp
*, struct prefix
*, afi_t
, safi_t
,
4566 struct bgp_aggregate
*);
4569 bgp_aggregate_increment (struct bgp
*bgp
, struct prefix
*p
,
4570 struct bgp_info
*ri
, afi_t afi
, safi_t safi
)
4572 struct bgp_node
*child
;
4573 struct bgp_node
*rn
;
4574 struct bgp_aggregate
*aggregate
;
4576 /* MPLS-VPN aggregation is not yet supported. */
4577 if (safi
== SAFI_MPLS_VPN
)
4580 if (p
->prefixlen
== 0)
4583 if (BGP_INFO_HOLDDOWN (ri
))
4586 child
= bgp_node_get (bgp
->aggregate
[afi
][safi
], p
);
4588 /* Aggregate address configuration check. */
4589 for (rn
= child
; rn
; rn
= rn
->parent
)
4590 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4592 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4593 bgp_aggregate_route (bgp
, &rn
->p
, ri
, afi
, safi
, NULL
, aggregate
);
4595 bgp_unlock_node (child
);
4599 bgp_aggregate_decrement (struct bgp
*bgp
, struct prefix
*p
,
4600 struct bgp_info
*del
, afi_t afi
, safi_t safi
)
4602 struct bgp_node
*child
;
4603 struct bgp_node
*rn
;
4604 struct bgp_aggregate
*aggregate
;
4606 /* MPLS-VPN aggregation is not yet supported. */
4607 if (safi
== SAFI_MPLS_VPN
)
4610 if (p
->prefixlen
== 0)
4613 child
= bgp_node_get (bgp
->aggregate
[afi
][safi
], p
);
4615 /* Aggregate address configuration check. */
4616 for (rn
= child
; rn
; rn
= rn
->parent
)
4617 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4619 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4620 bgp_aggregate_route (bgp
, &rn
->p
, NULL
, afi
, safi
, del
, aggregate
);
4622 bgp_unlock_node (child
);
4626 bgp_aggregate_add (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
, safi_t safi
,
4627 struct bgp_aggregate
*aggregate
)
4629 struct bgp_table
*table
;
4630 struct bgp_node
*top
;
4631 struct bgp_node
*rn
;
4632 struct bgp_info
*new;
4633 struct bgp_info
*ri
;
4634 unsigned long match
;
4635 u_char origin
= BGP_ORIGIN_IGP
;
4636 struct aspath
*aspath
= NULL
;
4637 struct aspath
*asmerge
= NULL
;
4638 struct community
*community
= NULL
;
4639 struct community
*commerge
= NULL
;
4641 table
= bgp
->rib
[afi
][safi
];
4644 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4646 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4649 /* If routes exists below this node, generate aggregate routes. */
4650 top
= bgp_node_get (table
, p
);
4651 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4652 if (rn
->p
.prefixlen
> p
->prefixlen
)
4656 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4658 if (BGP_INFO_HOLDDOWN (ri
))
4661 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4663 /* summary-only aggregate route suppress aggregated
4664 route announcement. */
4665 if (aggregate
->summary_only
)
4667 (bgp_info_extra_get (ri
))->suppress
++;
4668 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4671 /* as-set aggregate route generate origin, as path,
4672 community aggregation. */
4673 if (aggregate
->as_set
)
4675 if (origin
< ri
->attr
->origin
)
4676 origin
= ri
->attr
->origin
;
4680 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4681 aspath_free (aspath
);
4685 aspath
= aspath_dup (ri
->attr
->aspath
);
4687 if (ri
->attr
->community
)
4691 commerge
= community_merge (community
,
4692 ri
->attr
->community
);
4693 community
= community_uniq_sort (commerge
);
4694 community_free (commerge
);
4697 community
= community_dup (ri
->attr
->community
);
4704 /* If this node is suppressed, process the change. */
4706 bgp_process (bgp
, rn
, afi
, safi
);
4708 bgp_unlock_node (top
);
4710 /* Add aggregate route to BGP table. */
4711 if (aggregate
->count
)
4713 rn
= bgp_node_get (table
, p
);
4715 new = bgp_info_new ();
4716 new->type
= ZEBRA_ROUTE_BGP
;
4717 new->sub_type
= BGP_ROUTE_AGGREGATE
;
4718 new->peer
= bgp
->peer_self
;
4719 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4720 new->attr
= bgp_attr_aggregate_intern (bgp
, origin
, aspath
, community
, aggregate
->as_set
);
4721 new->uptime
= bgp_clock ();
4723 bgp_info_add (rn
, new);
4724 bgp_unlock_node (rn
);
4726 /* Process change. */
4727 bgp_process (bgp
, rn
, afi
, safi
);
4732 bgp_aggregate_delete (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
4733 safi_t safi
, struct bgp_aggregate
*aggregate
)
4735 struct bgp_table
*table
;
4736 struct bgp_node
*top
;
4737 struct bgp_node
*rn
;
4738 struct bgp_info
*ri
;
4739 unsigned long match
;
4741 table
= bgp
->rib
[afi
][safi
];
4743 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4745 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4748 /* If routes exists below this node, generate aggregate routes. */
4749 top
= bgp_node_get (table
, p
);
4750 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4751 if (rn
->p
.prefixlen
> p
->prefixlen
)
4755 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4757 if (BGP_INFO_HOLDDOWN (ri
))
4760 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4762 if (aggregate
->summary_only
&& ri
->extra
)
4764 ri
->extra
->suppress
--;
4766 if (ri
->extra
->suppress
== 0)
4768 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4776 /* If this node was suppressed, process the change. */
4778 bgp_process (bgp
, rn
, afi
, safi
);
4780 bgp_unlock_node (top
);
4782 /* Delete aggregate route from BGP table. */
4783 rn
= bgp_node_get (table
, p
);
4785 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4786 if (ri
->peer
== bgp
->peer_self
4787 && ri
->type
== ZEBRA_ROUTE_BGP
4788 && ri
->sub_type
== BGP_ROUTE_AGGREGATE
)
4791 /* Withdraw static BGP route from routing table. */
4794 bgp_info_delete (rn
, ri
);
4795 bgp_process (bgp
, rn
, afi
, safi
);
4798 /* Unlock bgp_node_lookup. */
4799 bgp_unlock_node (rn
);
4802 /* Aggregate route attribute. */
4803 #define AGGREGATE_SUMMARY_ONLY 1
4804 #define AGGREGATE_AS_SET 1
4807 bgp_aggregate_unset (struct vty
*vty
, const char *prefix_str
,
4808 afi_t afi
, safi_t safi
)
4812 struct bgp_node
*rn
;
4814 struct bgp_aggregate
*aggregate
;
4816 /* Convert string to prefix structure. */
4817 ret
= str2prefix (prefix_str
, &p
);
4820 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
4825 /* Get BGP structure. */
4828 /* Old configuration check. */
4829 rn
= bgp_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
4832 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
4837 aggregate
= rn
->info
;
4838 if (aggregate
->safi
& SAFI_UNICAST
)
4839 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
4840 if (aggregate
->safi
& SAFI_MULTICAST
)
4841 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
4843 /* Unlock aggregate address configuration. */
4845 bgp_aggregate_free (aggregate
);
4846 bgp_unlock_node (rn
);
4847 bgp_unlock_node (rn
);
4853 bgp_aggregate_set (struct vty
*vty
, const char *prefix_str
,
4854 afi_t afi
, safi_t safi
,
4855 u_char summary_only
, u_char as_set
)
4859 struct bgp_node
*rn
;
4861 struct bgp_aggregate
*aggregate
;
4863 /* Convert string to prefix structure. */
4864 ret
= str2prefix (prefix_str
, &p
);
4867 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
4872 /* Get BGP structure. */
4875 /* Old configuration check. */
4876 rn
= bgp_node_get (bgp
->aggregate
[afi
][safi
], &p
);
4880 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
4881 /* try to remove the old entry */
4882 ret
= bgp_aggregate_unset (vty
, prefix_str
, afi
, safi
);
4885 vty_out (vty
, "Error deleting aggregate.%s", VTY_NEWLINE
);
4886 bgp_unlock_node (rn
);
4891 /* Make aggregate address structure. */
4892 aggregate
= bgp_aggregate_new ();
4893 aggregate
->summary_only
= summary_only
;
4894 aggregate
->as_set
= as_set
;
4895 aggregate
->safi
= safi
;
4896 rn
->info
= aggregate
;
4898 /* Aggregate address insert into BGP routing table. */
4899 if (safi
& SAFI_UNICAST
)
4900 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
4901 if (safi
& SAFI_MULTICAST
)
4902 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
4907 DEFUN (aggregate_address
,
4908 aggregate_address_cmd
,
4909 "aggregate-address A.B.C.D/M",
4910 "Configure BGP aggregate entries\n"
4911 "Aggregate prefix\n")
4913 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
), 0, 0);
4916 DEFUN (aggregate_address_mask
,
4917 aggregate_address_mask_cmd
,
4918 "aggregate-address A.B.C.D A.B.C.D",
4919 "Configure BGP aggregate entries\n"
4920 "Aggregate address\n"
4924 char prefix_str
[BUFSIZ
];
4926 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4930 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4934 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
4938 DEFUN (aggregate_address_summary_only
,
4939 aggregate_address_summary_only_cmd
,
4940 "aggregate-address A.B.C.D/M summary-only",
4941 "Configure BGP aggregate entries\n"
4942 "Aggregate prefix\n"
4943 "Filter more specific routes from updates\n")
4945 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
4946 AGGREGATE_SUMMARY_ONLY
, 0);
4949 DEFUN (aggregate_address_mask_summary_only
,
4950 aggregate_address_mask_summary_only_cmd
,
4951 "aggregate-address A.B.C.D A.B.C.D summary-only",
4952 "Configure BGP aggregate entries\n"
4953 "Aggregate address\n"
4955 "Filter more specific routes from updates\n")
4958 char prefix_str
[BUFSIZ
];
4960 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4964 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4968 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
4969 AGGREGATE_SUMMARY_ONLY
, 0);
4972 DEFUN (aggregate_address_as_set
,
4973 aggregate_address_as_set_cmd
,
4974 "aggregate-address A.B.C.D/M as-set",
4975 "Configure BGP aggregate entries\n"
4976 "Aggregate prefix\n"
4977 "Generate AS set path information\n")
4979 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
4980 0, AGGREGATE_AS_SET
);
4983 DEFUN (aggregate_address_mask_as_set
,
4984 aggregate_address_mask_as_set_cmd
,
4985 "aggregate-address A.B.C.D A.B.C.D as-set",
4986 "Configure BGP aggregate entries\n"
4987 "Aggregate address\n"
4989 "Generate AS set path information\n")
4992 char prefix_str
[BUFSIZ
];
4994 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4998 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5002 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5003 0, AGGREGATE_AS_SET
);
5007 DEFUN (aggregate_address_as_set_summary
,
5008 aggregate_address_as_set_summary_cmd
,
5009 "aggregate-address A.B.C.D/M as-set summary-only",
5010 "Configure BGP aggregate entries\n"
5011 "Aggregate prefix\n"
5012 "Generate AS set path information\n"
5013 "Filter more specific routes from updates\n")
5015 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5016 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5019 ALIAS (aggregate_address_as_set_summary
,
5020 aggregate_address_summary_as_set_cmd
,
5021 "aggregate-address A.B.C.D/M summary-only as-set",
5022 "Configure BGP aggregate entries\n"
5023 "Aggregate prefix\n"
5024 "Filter more specific routes from updates\n"
5025 "Generate AS set path information\n")
5027 DEFUN (aggregate_address_mask_as_set_summary
,
5028 aggregate_address_mask_as_set_summary_cmd
,
5029 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5030 "Configure BGP aggregate entries\n"
5031 "Aggregate address\n"
5033 "Generate AS set path information\n"
5034 "Filter more specific routes from updates\n")
5037 char prefix_str
[BUFSIZ
];
5039 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5043 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5047 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5048 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5051 ALIAS (aggregate_address_mask_as_set_summary
,
5052 aggregate_address_mask_summary_as_set_cmd
,
5053 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5054 "Configure BGP aggregate entries\n"
5055 "Aggregate address\n"
5057 "Filter more specific routes from updates\n"
5058 "Generate AS set path information\n")
5060 DEFUN (no_aggregate_address
,
5061 no_aggregate_address_cmd
,
5062 "no aggregate-address A.B.C.D/M",
5064 "Configure BGP aggregate entries\n"
5065 "Aggregate prefix\n")
5067 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
));
5070 ALIAS (no_aggregate_address
,
5071 no_aggregate_address_summary_only_cmd
,
5072 "no aggregate-address A.B.C.D/M summary-only",
5074 "Configure BGP aggregate entries\n"
5075 "Aggregate prefix\n"
5076 "Filter more specific routes from updates\n")
5078 ALIAS (no_aggregate_address
,
5079 no_aggregate_address_as_set_cmd
,
5080 "no aggregate-address A.B.C.D/M as-set",
5082 "Configure BGP aggregate entries\n"
5083 "Aggregate prefix\n"
5084 "Generate AS set path information\n")
5086 ALIAS (no_aggregate_address
,
5087 no_aggregate_address_as_set_summary_cmd
,
5088 "no aggregate-address A.B.C.D/M as-set summary-only",
5090 "Configure BGP aggregate entries\n"
5091 "Aggregate prefix\n"
5092 "Generate AS set path information\n"
5093 "Filter more specific routes from updates\n")
5095 ALIAS (no_aggregate_address
,
5096 no_aggregate_address_summary_as_set_cmd
,
5097 "no aggregate-address A.B.C.D/M summary-only as-set",
5099 "Configure BGP aggregate entries\n"
5100 "Aggregate prefix\n"
5101 "Filter more specific routes from updates\n"
5102 "Generate AS set path information\n")
5104 DEFUN (no_aggregate_address_mask
,
5105 no_aggregate_address_mask_cmd
,
5106 "no aggregate-address A.B.C.D A.B.C.D",
5108 "Configure BGP aggregate entries\n"
5109 "Aggregate address\n"
5113 char prefix_str
[BUFSIZ
];
5115 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5119 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5123 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
5126 ALIAS (no_aggregate_address_mask
,
5127 no_aggregate_address_mask_summary_only_cmd
,
5128 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5130 "Configure BGP aggregate entries\n"
5131 "Aggregate address\n"
5133 "Filter more specific routes from updates\n")
5135 ALIAS (no_aggregate_address_mask
,
5136 no_aggregate_address_mask_as_set_cmd
,
5137 "no aggregate-address A.B.C.D A.B.C.D as-set",
5139 "Configure BGP aggregate entries\n"
5140 "Aggregate address\n"
5142 "Generate AS set path information\n")
5144 ALIAS (no_aggregate_address_mask
,
5145 no_aggregate_address_mask_as_set_summary_cmd
,
5146 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5148 "Configure BGP aggregate entries\n"
5149 "Aggregate address\n"
5151 "Generate AS set path information\n"
5152 "Filter more specific routes from updates\n")
5154 ALIAS (no_aggregate_address_mask
,
5155 no_aggregate_address_mask_summary_as_set_cmd
,
5156 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5158 "Configure BGP aggregate entries\n"
5159 "Aggregate address\n"
5161 "Filter more specific routes from updates\n"
5162 "Generate AS set path information\n")
5165 DEFUN (ipv6_aggregate_address
,
5166 ipv6_aggregate_address_cmd
,
5167 "aggregate-address X:X::X:X/M",
5168 "Configure BGP aggregate entries\n"
5169 "Aggregate prefix\n")
5171 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0, 0);
5174 DEFUN (ipv6_aggregate_address_summary_only
,
5175 ipv6_aggregate_address_summary_only_cmd
,
5176 "aggregate-address X:X::X:X/M summary-only",
5177 "Configure BGP aggregate entries\n"
5178 "Aggregate prefix\n"
5179 "Filter more specific routes from updates\n")
5181 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5182 AGGREGATE_SUMMARY_ONLY
, 0);
5185 DEFUN (no_ipv6_aggregate_address
,
5186 no_ipv6_aggregate_address_cmd
,
5187 "no aggregate-address X:X::X:X/M",
5189 "Configure BGP aggregate entries\n"
5190 "Aggregate prefix\n")
5192 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5195 DEFUN (no_ipv6_aggregate_address_summary_only
,
5196 no_ipv6_aggregate_address_summary_only_cmd
,
5197 "no aggregate-address X:X::X:X/M summary-only",
5199 "Configure BGP aggregate entries\n"
5200 "Aggregate prefix\n"
5201 "Filter more specific routes from updates\n")
5203 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5206 ALIAS (ipv6_aggregate_address
,
5207 old_ipv6_aggregate_address_cmd
,
5208 "ipv6 bgp aggregate-address X:X::X:X/M",
5211 "Configure BGP aggregate entries\n"
5212 "Aggregate prefix\n")
5214 ALIAS (ipv6_aggregate_address_summary_only
,
5215 old_ipv6_aggregate_address_summary_only_cmd
,
5216 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5219 "Configure BGP aggregate entries\n"
5220 "Aggregate prefix\n"
5221 "Filter more specific routes from updates\n")
5223 ALIAS (no_ipv6_aggregate_address
,
5224 old_no_ipv6_aggregate_address_cmd
,
5225 "no ipv6 bgp aggregate-address X:X::X:X/M",
5229 "Configure BGP aggregate entries\n"
5230 "Aggregate prefix\n")
5232 ALIAS (no_ipv6_aggregate_address_summary_only
,
5233 old_no_ipv6_aggregate_address_summary_only_cmd
,
5234 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5238 "Configure BGP aggregate entries\n"
5239 "Aggregate prefix\n"
5240 "Filter more specific routes from updates\n")
5241 #endif /* HAVE_IPV6 */
5243 /* Redistribute route treatment. */
5245 bgp_redistribute_add (struct prefix
*p
, const struct in_addr
*nexthop
,
5246 const struct in6_addr
*nexthop6
,
5247 u_int32_t metric
, u_char type
)
5250 struct listnode
*node
, *nnode
;
5251 struct bgp_info
*new;
5252 struct bgp_info
*bi
;
5253 struct bgp_info info
;
5254 struct bgp_node
*bn
;
5255 struct attr attr
= { 0 };
5256 struct attr attr_new
= { 0 };
5257 struct attr
*new_attr
;
5261 /* Make default attribute. */
5262 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
5264 attr
.nexthop
= *nexthop
;
5269 struct attr_extra
*extra
= bgp_attr_extra_get(&attr
);
5270 extra
->mp_nexthop_global
= *nexthop6
;
5271 extra
->mp_nexthop_len
= 16;
5276 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
5278 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
5280 afi
= family2afi (p
->family
);
5282 if (bgp
->redist
[afi
][type
])
5284 /* Copy attribute for modification. */
5285 bgp_attr_dup (&attr_new
, &attr
);
5287 if (bgp
->redist_metric_flag
[afi
][type
])
5288 attr_new
.med
= bgp
->redist_metric
[afi
][type
];
5290 /* Apply route-map. */
5291 if (bgp
->rmap
[afi
][type
].map
)
5293 info
.peer
= bgp
->peer_self
;
5294 info
.attr
= &attr_new
;
5296 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
);
5298 ret
= route_map_apply (bgp
->rmap
[afi
][type
].map
, p
, RMAP_BGP
,
5301 bgp
->peer_self
->rmap_type
= 0;
5303 if (ret
== RMAP_DENYMATCH
)
5305 /* Free uninterned attribute. */
5306 bgp_attr_flush (&attr_new
);
5307 bgp_attr_extra_free (&attr_new
);
5309 /* Unintern original. */
5310 aspath_unintern (&attr
.aspath
);
5311 bgp_attr_extra_free (&attr
);
5312 bgp_redistribute_delete (p
, type
);
5317 bn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
],
5318 afi
, SAFI_UNICAST
, p
, NULL
);
5320 new_attr
= bgp_attr_intern (&attr_new
);
5321 bgp_attr_extra_free (&attr_new
);
5323 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
5324 if (bi
->peer
== bgp
->peer_self
5325 && bi
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
5330 if (attrhash_cmp (bi
->attr
, new_attr
) &&
5331 !CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5333 bgp_attr_unintern (&new_attr
);
5334 aspath_unintern (&attr
.aspath
);
5335 bgp_attr_extra_free (&attr
);
5336 bgp_unlock_node (bn
);
5341 /* The attribute is changed. */
5342 bgp_info_set_flag (bn
, bi
, BGP_INFO_ATTR_CHANGED
);
5344 /* Rewrite BGP route information. */
5345 if (CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5346 bgp_info_restore(bn
, bi
);
5348 bgp_aggregate_decrement (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5349 bgp_attr_unintern (&bi
->attr
);
5350 bi
->attr
= new_attr
;
5351 bi
->uptime
= bgp_clock ();
5353 /* Process change. */
5354 bgp_aggregate_increment (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5355 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5356 bgp_unlock_node (bn
);
5357 aspath_unintern (&attr
.aspath
);
5358 bgp_attr_extra_free (&attr
);
5363 new = bgp_info_new ();
5365 new->sub_type
= BGP_ROUTE_REDISTRIBUTE
;
5366 new->peer
= bgp
->peer_self
;
5367 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5368 new->attr
= new_attr
;
5369 new->uptime
= bgp_clock ();
5371 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
5372 bgp_info_add (bn
, new);
5373 bgp_unlock_node (bn
);
5374 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5378 /* Unintern original. */
5379 aspath_unintern (&attr
.aspath
);
5380 bgp_attr_extra_free (&attr
);
5384 bgp_redistribute_delete (struct prefix
*p
, u_char type
)
5387 struct listnode
*node
, *nnode
;
5389 struct bgp_node
*rn
;
5390 struct bgp_info
*ri
;
5392 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
5394 afi
= family2afi (p
->family
);
5396 if (bgp
->redist
[afi
][type
])
5398 rn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
5400 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5401 if (ri
->peer
== bgp
->peer_self
5402 && ri
->type
== type
)
5407 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
5408 bgp_info_delete (rn
, ri
);
5409 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5411 bgp_unlock_node (rn
);
5416 /* Withdraw specified route type's route. */
5418 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
)
5420 struct bgp_node
*rn
;
5421 struct bgp_info
*ri
;
5422 struct bgp_table
*table
;
5424 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
5426 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
5428 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5429 if (ri
->peer
== bgp
->peer_self
5430 && ri
->type
== type
)
5435 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
5436 bgp_info_delete (rn
, ri
);
5437 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5442 /* Static function to display route. */
5444 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
5447 u_int32_t destination
;
5450 if (p
->family
== AF_INET
)
5452 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
5453 destination
= ntohl (p
->u
.prefix4
.s_addr
);
5455 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
5456 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
5457 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
5458 || p
->u
.prefix4
.s_addr
== 0)
5460 /* When mask is natural, mask is not displayed. */
5463 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
5466 len
= vty_out (vty
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
5471 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
5473 vty_out (vty
, "%*s", len
, " ");
5476 enum bgp_display_type
5481 /* Print the short form route status for a bgp_info */
5483 route_vty_short_status_out (struct vty
*vty
, struct bgp_info
*binfo
)
5485 /* Route status display. */
5486 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5488 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5490 else if (binfo
->extra
&& binfo
->extra
->suppress
)
5492 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5498 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5500 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5502 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5507 /* Internal route. */
5508 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
5514 /* called from terminal list command */
5516 route_vty_out (struct vty
*vty
, struct prefix
*p
,
5517 struct bgp_info
*binfo
, int display
, safi_t safi
)
5521 /* short status lead text */
5522 route_vty_short_status_out (vty
, binfo
);
5524 /* print prefix and mask */
5526 route_vty_out_route (p
, vty
);
5528 vty_out (vty
, "%*s", 17, " ");
5530 /* Print attribute */
5534 if (p
->family
== AF_INET
)
5536 if (safi
== SAFI_MPLS_VPN
)
5537 vty_out (vty
, "%-16s",
5538 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5540 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5543 else if (p
->family
== AF_INET6
)
5548 len
= vty_out (vty
, "%s",
5549 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5553 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5555 vty_out (vty
, "%*s", len
, " ");
5557 #endif /* HAVE_IPV6 */
5559 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5560 vty_out (vty
, "%10u", attr
->med
);
5564 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5565 vty_out (vty
, "%7u", attr
->local_pref
);
5569 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
5573 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5576 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5578 vty_out (vty
, "%s", VTY_NEWLINE
);
5581 /* called from terminal list command */
5583 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
,
5584 struct attr
*attr
, safi_t safi
)
5586 /* Route status display. */
5591 /* print prefix and mask */
5592 route_vty_out_route (p
, vty
);
5594 /* Print attribute */
5597 if (p
->family
== AF_INET
)
5599 if (safi
== SAFI_MPLS_VPN
)
5600 vty_out (vty
, "%-16s",
5601 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5603 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5606 else if (p
->family
== AF_INET6
)
5611 assert (attr
->extra
);
5613 len
= vty_out (vty
, "%s",
5614 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5618 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5620 vty_out (vty
, "%*s", len
, " ");
5622 #endif /* HAVE_IPV6 */
5624 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5625 vty_out (vty
, "%10u", attr
->med
);
5629 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5630 vty_out (vty
, "%7u", attr
->local_pref
);
5634 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
5638 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5641 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5644 vty_out (vty
, "%s", VTY_NEWLINE
);
5648 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
5649 struct bgp_info
*binfo
, int display
, safi_t safi
)
5652 u_int32_t label
= 0;
5657 /* short status lead text */
5658 route_vty_short_status_out (vty
, binfo
);
5660 /* print prefix and mask */
5662 route_vty_out_route (p
, vty
);
5664 vty_out (vty
, "%*s", 17, " ");
5666 /* Print attribute */
5670 if (p
->family
== AF_INET
)
5672 if (safi
== SAFI_MPLS_VPN
)
5673 vty_out (vty
, "%-16s",
5674 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5676 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5679 else if (p
->family
== AF_INET6
)
5681 assert (attr
->extra
);
5684 if (attr
->extra
->mp_nexthop_len
== 16)
5686 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5688 else if (attr
->extra
->mp_nexthop_len
== 32)
5689 vty_out (vty
, "%s(%s)",
5690 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5692 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
5696 #endif /* HAVE_IPV6 */
5699 label
= decode_label (binfo
->extra
->tag
);
5701 vty_out (vty
, "notag/%d", label
);
5703 vty_out (vty
, "%s", VTY_NEWLINE
);
5706 /* dampening route */
5708 damp_route_vty_out (struct vty
*vty
, struct prefix
*p
,
5709 struct bgp_info
*binfo
, int display
, safi_t safi
)
5713 char timebuf
[BGP_UPTIME_LEN
];
5715 /* short status lead text */
5716 route_vty_short_status_out (vty
, binfo
);
5718 /* print prefix and mask */
5720 route_vty_out_route (p
, vty
);
5722 vty_out (vty
, "%*s", 17, " ");
5724 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
5727 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 34, " ");
5729 vty_out (vty
, "%*s", len
, " ");
5731 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
));
5733 /* Print attribute */
5739 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5742 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5744 vty_out (vty
, "%s", VTY_NEWLINE
);
5749 flap_route_vty_out (struct vty
*vty
, struct prefix
*p
,
5750 struct bgp_info
*binfo
, int display
, safi_t safi
)
5753 struct bgp_damp_info
*bdi
;
5754 char timebuf
[BGP_UPTIME_LEN
];
5760 bdi
= binfo
->extra
->damp_info
;
5762 /* short status lead text */
5763 route_vty_short_status_out (vty
, binfo
);
5765 /* print prefix and mask */
5767 route_vty_out_route (p
, vty
);
5769 vty_out (vty
, "%*s", 17, " ");
5771 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
5774 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 33, " ");
5776 vty_out (vty
, "%*s", len
, " ");
5778 len
= vty_out (vty
, "%d", bdi
->flap
);
5783 vty_out (vty
, "%*s ", len
, " ");
5785 vty_out (vty
, "%s ", peer_uptime (bdi
->start_time
,
5786 timebuf
, BGP_UPTIME_LEN
));
5788 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
)
5789 && ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5790 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
));
5792 vty_out (vty
, "%*s ", 8, " ");
5794 /* Print attribute */
5800 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5803 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5805 vty_out (vty
, "%s", VTY_NEWLINE
);
5809 route_vty_out_detail (struct vty
*vty
, struct bgp
*bgp
, struct prefix
*p
,
5810 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
)
5812 char buf
[INET6_ADDRSTRLEN
];
5815 int sockunion_vty_out (struct vty
*, union sockunion
*);
5816 #ifdef HAVE_CLOCK_MONOTONIC
5824 /* Line1 display AS-path, Aggregator */
5828 if (aspath_count_hops (attr
->aspath
) == 0)
5829 vty_out (vty
, "Local");
5831 aspath_print_vty (vty
, "%s", attr
->aspath
, "");
5834 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5835 vty_out (vty
, ", (removed)");
5836 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5837 vty_out (vty
, ", (stale)");
5838 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
5839 vty_out (vty
, ", (aggregated by %u %s)",
5840 attr
->extra
->aggregator_as
,
5841 inet_ntoa (attr
->extra
->aggregator_addr
));
5842 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
5843 vty_out (vty
, ", (Received from a RR-client)");
5844 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
5845 vty_out (vty
, ", (Received from a RS-client)");
5846 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5847 vty_out (vty
, ", (history entry)");
5848 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5849 vty_out (vty
, ", (suppressed due to dampening)");
5850 vty_out (vty
, "%s", VTY_NEWLINE
);
5852 /* Line2 display Next-hop, Neighbor, Router-id */
5853 if (p
->family
== AF_INET
)
5855 vty_out (vty
, " %s", safi
== SAFI_MPLS_VPN
?
5856 inet_ntoa (attr
->extra
->mp_nexthop_global_in
) :
5857 inet_ntoa (attr
->nexthop
));
5862 assert (attr
->extra
);
5863 vty_out (vty
, " %s",
5864 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5865 buf
, INET6_ADDRSTRLEN
));
5867 #endif /* HAVE_IPV6 */
5869 if (binfo
->peer
== bgp
->peer_self
)
5871 vty_out (vty
, " from %s ",
5872 p
->family
== AF_INET
? "0.0.0.0" : "::");
5873 vty_out (vty
, "(%s)", inet_ntoa(bgp
->router_id
));
5877 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
5878 vty_out (vty
, " (inaccessible)");
5879 else if (binfo
->extra
&& binfo
->extra
->igpmetric
)
5880 vty_out (vty
, " (metric %d)", binfo
->extra
->igpmetric
);
5881 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
5882 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
5883 vty_out (vty
, " (%s)", inet_ntoa (attr
->extra
->originator_id
));
5885 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
5887 vty_out (vty
, "%s", VTY_NEWLINE
);
5890 /* display nexthop local */
5891 if (attr
->extra
&& attr
->extra
->mp_nexthop_len
== 32)
5893 vty_out (vty
, " (%s)%s",
5894 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
5895 buf
, INET6_ADDRSTRLEN
),
5898 #endif /* HAVE_IPV6 */
5900 /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */
5901 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
5903 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
5904 vty_out (vty
, ", metric %u", attr
->med
);
5906 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
5907 vty_out (vty
, ", localpref %u", attr
->local_pref
);
5909 vty_out (vty
, ", localpref %u", bgp
->default_local_pref
);
5911 if (attr
->extra
&& attr
->extra
->weight
!= 0)
5912 vty_out (vty
, ", weight %u", attr
->extra
->weight
);
5914 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5915 vty_out (vty
, ", valid");
5917 if (binfo
->peer
!= bgp
->peer_self
)
5919 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
5920 vty_out (vty
, ", internal");
5922 vty_out (vty
, ", %s",
5923 (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
) ? "confed-external" : "external"));
5925 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
5926 vty_out (vty
, ", aggregated, local");
5927 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
5928 vty_out (vty
, ", sourced");
5930 vty_out (vty
, ", sourced, local");
5932 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
5933 vty_out (vty
, ", atomic-aggregate");
5935 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5936 vty_out (vty
, ", best");
5938 vty_out (vty
, "%s", VTY_NEWLINE
);
5940 /* Line 4 display Community */
5941 if (attr
->community
)
5942 vty_out (vty
, " Community: %s%s", attr
->community
->str
,
5945 /* Line 5 display Extended-community */
5946 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
5947 vty_out (vty
, " Extended Community: %s%s",
5948 attr
->extra
->ecommunity
->str
, VTY_NEWLINE
);
5950 /* Line 6 display Originator, Cluster-id */
5951 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
5952 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
5954 assert (attr
->extra
);
5955 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
5956 vty_out (vty
, " Originator: %s",
5957 inet_ntoa (attr
->extra
->originator_id
));
5959 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
5962 vty_out (vty
, ", Cluster list: ");
5963 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
5964 vty_out (vty
, "%s ",
5965 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
5967 vty_out (vty
, "%s", VTY_NEWLINE
);
5970 if (binfo
->extra
&& binfo
->extra
->damp_info
)
5971 bgp_damp_info_vty (vty
, binfo
);
5973 /* Line 7 display Uptime */
5974 #ifdef HAVE_CLOCK_MONOTONIC
5975 tbuf
= time(NULL
) - (bgp_clock() - binfo
->uptime
);
5976 vty_out (vty
, " Last update: %s", ctime(&tbuf
));
5978 vty_out (vty
, " Last update: %s", ctime(&binfo
->uptime
));
5979 #endif /* HAVE_CLOCK_MONOTONIC */
5981 vty_out (vty
, "%s", VTY_NEWLINE
);
5984 #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"
5985 #define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
5986 #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
5987 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
5988 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
5992 bgp_show_type_normal
,
5993 bgp_show_type_regexp
,
5994 bgp_show_type_prefix_list
,
5995 bgp_show_type_filter_list
,
5996 bgp_show_type_route_map
,
5997 bgp_show_type_neighbor
,
5998 bgp_show_type_cidr_only
,
5999 bgp_show_type_prefix_longer
,
6000 bgp_show_type_community_all
,
6001 bgp_show_type_community
,
6002 bgp_show_type_community_exact
,
6003 bgp_show_type_community_list
,
6004 bgp_show_type_community_list_exact
,
6005 bgp_show_type_flap_statistics
,
6006 bgp_show_type_flap_address
,
6007 bgp_show_type_flap_prefix
,
6008 bgp_show_type_flap_cidr_only
,
6009 bgp_show_type_flap_regexp
,
6010 bgp_show_type_flap_filter_list
,
6011 bgp_show_type_flap_prefix_list
,
6012 bgp_show_type_flap_prefix_longer
,
6013 bgp_show_type_flap_route_map
,
6014 bgp_show_type_flap_neighbor
,
6015 bgp_show_type_dampend_paths
,
6016 bgp_show_type_damp_neighbor
6020 bgp_show_table (struct vty
*vty
, struct bgp_table
*table
, struct in_addr
*router_id
,
6021 enum bgp_show_type type
, void *output_arg
)
6023 struct bgp_info
*ri
;
6024 struct bgp_node
*rn
;
6027 unsigned long output_count
;
6029 /* This is first entry point, so reset total line. */
6032 /* Start processing of routes. */
6033 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
6034 if (rn
->info
!= NULL
)
6038 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6040 if (type
== bgp_show_type_flap_statistics
6041 || type
== bgp_show_type_flap_address
6042 || type
== bgp_show_type_flap_prefix
6043 || type
== bgp_show_type_flap_cidr_only
6044 || type
== bgp_show_type_flap_regexp
6045 || type
== bgp_show_type_flap_filter_list
6046 || type
== bgp_show_type_flap_prefix_list
6047 || type
== bgp_show_type_flap_prefix_longer
6048 || type
== bgp_show_type_flap_route_map
6049 || type
== bgp_show_type_flap_neighbor
6050 || type
== bgp_show_type_dampend_paths
6051 || type
== bgp_show_type_damp_neighbor
)
6053 if (!(ri
->extra
&& ri
->extra
->damp_info
))
6056 if (type
== bgp_show_type_regexp
6057 || type
== bgp_show_type_flap_regexp
)
6059 regex_t
*regex
= output_arg
;
6061 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
6064 if (type
== bgp_show_type_prefix_list
6065 || type
== bgp_show_type_flap_prefix_list
)
6067 struct prefix_list
*plist
= output_arg
;
6069 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
6072 if (type
== bgp_show_type_filter_list
6073 || type
== bgp_show_type_flap_filter_list
)
6075 struct as_list
*as_list
= output_arg
;
6077 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
6080 if (type
== bgp_show_type_route_map
6081 || type
== bgp_show_type_flap_route_map
)
6083 struct route_map
*rmap
= output_arg
;
6084 struct bgp_info binfo
;
6085 struct attr dummy_attr
= { 0 };
6088 bgp_attr_dup (&dummy_attr
, ri
->attr
);
6089 binfo
.peer
= ri
->peer
;
6090 binfo
.attr
= &dummy_attr
;
6092 ret
= route_map_apply (rmap
, &rn
->p
, RMAP_BGP
, &binfo
);
6094 bgp_attr_extra_free (&dummy_attr
);
6096 if (ret
== RMAP_DENYMATCH
)
6099 if (type
== bgp_show_type_neighbor
6100 || type
== bgp_show_type_flap_neighbor
6101 || type
== bgp_show_type_damp_neighbor
)
6103 union sockunion
*su
= output_arg
;
6105 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
6108 if (type
== bgp_show_type_cidr_only
6109 || type
== bgp_show_type_flap_cidr_only
)
6111 u_int32_t destination
;
6113 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
6114 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
6116 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
6118 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
6121 if (type
== bgp_show_type_prefix_longer
6122 || type
== bgp_show_type_flap_prefix_longer
)
6124 struct prefix
*p
= output_arg
;
6126 if (! prefix_match (p
, &rn
->p
))
6129 if (type
== bgp_show_type_community_all
)
6131 if (! ri
->attr
->community
)
6134 if (type
== bgp_show_type_community
)
6136 struct community
*com
= output_arg
;
6138 if (! ri
->attr
->community
||
6139 ! community_match (ri
->attr
->community
, com
))
6142 if (type
== bgp_show_type_community_exact
)
6144 struct community
*com
= output_arg
;
6146 if (! ri
->attr
->community
||
6147 ! community_cmp (ri
->attr
->community
, com
))
6150 if (type
== bgp_show_type_community_list
)
6152 struct community_list
*list
= output_arg
;
6154 if (! community_list_match (ri
->attr
->community
, list
))
6157 if (type
== bgp_show_type_community_list_exact
)
6159 struct community_list
*list
= output_arg
;
6161 if (! community_list_exact_match (ri
->attr
->community
, list
))
6164 if (type
== bgp_show_type_flap_address
6165 || type
== bgp_show_type_flap_prefix
)
6167 struct prefix
*p
= output_arg
;
6169 if (! prefix_match (&rn
->p
, p
))
6172 if (type
== bgp_show_type_flap_prefix
)
6173 if (p
->prefixlen
!= rn
->p
.prefixlen
)
6176 if (type
== bgp_show_type_dampend_paths
6177 || type
== bgp_show_type_damp_neighbor
)
6179 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
)
6180 || CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
6186 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id
), VTY_NEWLINE
);
6187 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
6188 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
6189 if (type
== bgp_show_type_dampend_paths
6190 || type
== bgp_show_type_damp_neighbor
)
6191 vty_out (vty
, BGP_SHOW_DAMP_HEADER
, VTY_NEWLINE
);
6192 else if (type
== bgp_show_type_flap_statistics
6193 || type
== bgp_show_type_flap_address
6194 || type
== bgp_show_type_flap_prefix
6195 || type
== bgp_show_type_flap_cidr_only
6196 || type
== bgp_show_type_flap_regexp
6197 || type
== bgp_show_type_flap_filter_list
6198 || type
== bgp_show_type_flap_prefix_list
6199 || type
== bgp_show_type_flap_prefix_longer
6200 || type
== bgp_show_type_flap_route_map
6201 || type
== bgp_show_type_flap_neighbor
)
6202 vty_out (vty
, BGP_SHOW_FLAP_HEADER
, VTY_NEWLINE
);
6204 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
6208 if (type
== bgp_show_type_dampend_paths
6209 || type
== bgp_show_type_damp_neighbor
)
6210 damp_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6211 else if (type
== bgp_show_type_flap_statistics
6212 || type
== bgp_show_type_flap_address
6213 || type
== bgp_show_type_flap_prefix
6214 || type
== bgp_show_type_flap_cidr_only
6215 || type
== bgp_show_type_flap_regexp
6216 || type
== bgp_show_type_flap_filter_list
6217 || type
== bgp_show_type_flap_prefix_list
6218 || type
== bgp_show_type_flap_prefix_longer
6219 || type
== bgp_show_type_flap_route_map
6220 || type
== bgp_show_type_flap_neighbor
)
6221 flap_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6223 route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6230 /* No route is displayed */
6231 if (output_count
== 0)
6233 if (type
== bgp_show_type_normal
)
6234 vty_out (vty
, "No BGP network exists%s", VTY_NEWLINE
);
6237 vty_out (vty
, "%sTotal number of prefixes %ld%s",
6238 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
6244 bgp_show (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
6245 enum bgp_show_type type
, void *output_arg
)
6247 struct bgp_table
*table
;
6250 bgp
= bgp_get_default ();
6255 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
6260 table
= bgp
->rib
[afi
][safi
];
6262 return bgp_show_table (vty
, table
, &bgp
->router_id
, type
, output_arg
);
6265 /* Header of detailed BGP route information */
6267 route_vty_out_detail_header (struct vty
*vty
, struct bgp
*bgp
,
6268 struct bgp_node
*rn
,
6269 struct prefix_rd
*prd
, afi_t afi
, safi_t safi
)
6271 struct bgp_info
*ri
;
6274 struct listnode
*node
, *nnode
;
6275 char buf1
[INET6_ADDRSTRLEN
];
6276 char buf2
[INET6_ADDRSTRLEN
];
6281 int no_advertise
= 0;
6286 vty_out (vty
, "BGP routing table entry for %s%s%s/%d%s",
6287 (safi
== SAFI_MPLS_VPN
?
6288 prefix_rd2str (prd
, buf1
, RD_ADDRSTRLEN
) : ""),
6289 safi
== SAFI_MPLS_VPN
? ":" : "",
6290 inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
),
6291 p
->prefixlen
, VTY_NEWLINE
);
6293 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6296 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
6299 if (ri
->extra
&& ri
->extra
->suppress
)
6301 if (ri
->attr
->community
!= NULL
)
6303 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
6305 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
6307 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
6313 vty_out (vty
, "Paths: (%d available", count
);
6316 vty_out (vty
, ", best #%d", best
);
6317 if (safi
== SAFI_UNICAST
)
6318 vty_out (vty
, ", table Default-IP-Routing-Table");
6321 vty_out (vty
, ", no best path");
6323 vty_out (vty
, ", not advertised to any peer");
6325 vty_out (vty
, ", not advertised to EBGP peer");
6327 vty_out (vty
, ", not advertised outside local AS");
6329 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
6330 vty_out (vty
, ")%s", VTY_NEWLINE
);
6332 /* advertised peer */
6333 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
6335 if (bgp_adj_out_lookup (peer
, p
, afi
, safi
, rn
))
6338 vty_out (vty
, " Advertised to non peer-group peers:%s ", VTY_NEWLINE
);
6339 vty_out (vty
, " %s", sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6344 vty_out (vty
, " Not advertised to any peer");
6345 vty_out (vty
, "%s", VTY_NEWLINE
);
6348 /* Display specified route of BGP table. */
6350 bgp_show_route_in_table (struct vty
*vty
, struct bgp
*bgp
,
6351 struct bgp_table
*rib
, const char *ip_str
,
6352 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
6358 struct prefix match
;
6359 struct bgp_node
*rn
;
6360 struct bgp_node
*rm
;
6361 struct bgp_info
*ri
;
6362 struct bgp_table
*table
;
6364 /* Check IP address argument. */
6365 ret
= str2prefix (ip_str
, &match
);
6368 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
6372 match
.family
= afi2family (afi
);
6374 if (safi
== SAFI_MPLS_VPN
)
6376 for (rn
= bgp_table_top (rib
); rn
; rn
= bgp_route_next (rn
))
6378 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
6381 if ((table
= rn
->info
) != NULL
)
6385 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
6387 if (prefix_check
&& rm
->p
.prefixlen
!= match
.prefixlen
)
6389 bgp_unlock_node (rm
);
6393 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
6397 route_vty_out_detail_header (vty
, bgp
, rm
, (struct prefix_rd
*)&rn
->p
,
6398 AFI_IP
, SAFI_MPLS_VPN
);
6403 route_vty_out_detail (vty
, bgp
, &rm
->p
, ri
, AFI_IP
, SAFI_MPLS_VPN
);
6406 bgp_unlock_node (rm
);
6415 if ((rn
= bgp_node_match (rib
, &match
)) != NULL
)
6417 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
6419 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6423 route_vty_out_detail_header (vty
, bgp
, rn
, NULL
, afi
, safi
);
6427 route_vty_out_detail (vty
, bgp
, &rn
->p
, ri
, afi
, safi
);
6431 bgp_unlock_node (rn
);
6437 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
6444 /* Display specified route of Main RIB */
6446 bgp_show_route (struct vty
*vty
, const char *view_name
, const char *ip_str
,
6447 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
6452 /* BGP structure lookup. */
6455 bgp
= bgp_lookup_by_name (view_name
);
6458 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
6464 bgp
= bgp_get_default ();
6467 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
6472 return bgp_show_route_in_table (vty
, bgp
, bgp
->rib
[afi
][safi
], ip_str
,
6473 afi
, safi
, prd
, prefix_check
);
6476 /* BGP route print out function. */
6484 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6487 DEFUN (show_ip_bgp_ipv4
,
6488 show_ip_bgp_ipv4_cmd
,
6489 "show ip bgp ipv4 (unicast|multicast)",
6494 "Address Family modifier\n"
6495 "Address Family modifier\n")
6497 if (strncmp (argv
[0], "m", 1) == 0)
6498 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
, bgp_show_type_normal
,
6501 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6504 ALIAS (show_ip_bgp_ipv4
,
6505 show_bgp_ipv4_safi_cmd
,
6506 "show bgp ipv4 (unicast|multicast)",
6510 "Address Family modifier\n"
6511 "Address Family modifier\n")
6513 DEFUN (show_ip_bgp_route
,
6514 show_ip_bgp_route_cmd
,
6515 "show ip bgp A.B.C.D",
6519 "Network in the BGP routing table to display\n")
6521 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6524 DEFUN (show_ip_bgp_ipv4_route
,
6525 show_ip_bgp_ipv4_route_cmd
,
6526 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
6531 "Address Family modifier\n"
6532 "Address Family modifier\n"
6533 "Network in the BGP routing table to display\n")
6535 if (strncmp (argv
[0], "m", 1) == 0)
6536 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0);
6538 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6541 ALIAS (show_ip_bgp_ipv4_route
,
6542 show_bgp_ipv4_safi_route_cmd
,
6543 "show bgp ipv4 (unicast|multicast) A.B.C.D",
6547 "Address Family modifier\n"
6548 "Address Family modifier\n"
6549 "Network in the BGP routing table to display\n")
6551 DEFUN (show_ip_bgp_vpnv4_all_route
,
6552 show_ip_bgp_vpnv4_all_route_cmd
,
6553 "show ip bgp vpnv4 all A.B.C.D",
6557 "Display VPNv4 NLRI specific information\n"
6558 "Display information about all VPNv4 NLRIs\n"
6559 "Network in the BGP routing table to display\n")
6561 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 0);
6564 DEFUN (show_ip_bgp_vpnv4_rd_route
,
6565 show_ip_bgp_vpnv4_rd_route_cmd
,
6566 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
6570 "Display VPNv4 NLRI specific information\n"
6571 "Display information for a route distinguisher\n"
6572 "VPN Route Distinguisher\n"
6573 "Network in the BGP routing table to display\n")
6576 struct prefix_rd prd
;
6578 ret
= str2prefix_rd (argv
[0], &prd
);
6581 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
6584 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0);
6587 DEFUN (show_ip_bgp_prefix
,
6588 show_ip_bgp_prefix_cmd
,
6589 "show ip bgp A.B.C.D/M",
6593 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6595 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6598 DEFUN (show_ip_bgp_ipv4_prefix
,
6599 show_ip_bgp_ipv4_prefix_cmd
,
6600 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
6605 "Address Family modifier\n"
6606 "Address Family modifier\n"
6607 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6609 if (strncmp (argv
[0], "m", 1) == 0)
6610 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1);
6612 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6615 ALIAS (show_ip_bgp_ipv4_prefix
,
6616 show_bgp_ipv4_safi_prefix_cmd
,
6617 "show bgp ipv4 (unicast|multicast) A.B.C.D/M",
6621 "Address Family modifier\n"
6622 "Address Family modifier\n"
6623 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6625 DEFUN (show_ip_bgp_vpnv4_all_prefix
,
6626 show_ip_bgp_vpnv4_all_prefix_cmd
,
6627 "show ip bgp vpnv4 all A.B.C.D/M",
6631 "Display VPNv4 NLRI specific information\n"
6632 "Display information about all VPNv4 NLRIs\n"
6633 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6635 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 1);
6638 DEFUN (show_ip_bgp_vpnv4_rd_prefix
,
6639 show_ip_bgp_vpnv4_rd_prefix_cmd
,
6640 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
6644 "Display VPNv4 NLRI specific information\n"
6645 "Display information for a route distinguisher\n"
6646 "VPN Route Distinguisher\n"
6647 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6650 struct prefix_rd prd
;
6652 ret
= str2prefix_rd (argv
[0], &prd
);
6655 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
6658 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 1);
6661 DEFUN (show_ip_bgp_view
,
6662 show_ip_bgp_view_cmd
,
6663 "show ip bgp view WORD",
6672 /* BGP structure lookup. */
6673 bgp
= bgp_lookup_by_name (argv
[0]);
6676 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
6680 return bgp_show (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6683 DEFUN (show_ip_bgp_view_route
,
6684 show_ip_bgp_view_route_cmd
,
6685 "show ip bgp view WORD A.B.C.D",
6691 "Network in the BGP routing table to display\n")
6693 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6696 DEFUN (show_ip_bgp_view_prefix
,
6697 show_ip_bgp_view_prefix_cmd
,
6698 "show ip bgp view WORD A.B.C.D/M",
6704 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6706 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6716 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
6727 DEFUN (show_bgp_ipv6_safi
,
6728 show_bgp_ipv6_safi_cmd
,
6729 "show bgp ipv6 (unicast|multicast)",
6733 "Address Family modifier\n"
6734 "Address Family modifier\n")
6736 if (strncmp (argv
[0], "m", 1) == 0)
6737 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
6740 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6744 DEFUN (show_ipv6_bgp
,
6751 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
6755 DEFUN (show_bgp_route
,
6757 "show bgp X:X::X:X",
6760 "Network in the BGP routing table to display\n")
6762 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6765 ALIAS (show_bgp_route
,
6766 show_bgp_ipv6_route_cmd
,
6767 "show bgp ipv6 X:X::X:X",
6771 "Network in the BGP routing table to display\n")
6773 DEFUN (show_bgp_ipv6_safi_route
,
6774 show_bgp_ipv6_safi_route_cmd
,
6775 "show bgp ipv6 (unicast|multicast) X:X::X:X",
6779 "Address Family modifier\n"
6780 "Address Family modifier\n"
6781 "Network in the BGP routing table to display\n")
6783 if (strncmp (argv
[0], "m", 1) == 0)
6784 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0);
6786 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6790 DEFUN (show_ipv6_bgp_route
,
6791 show_ipv6_bgp_route_cmd
,
6792 "show ipv6 bgp X:X::X:X",
6796 "Network in the BGP routing table to display\n")
6798 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6801 DEFUN (show_bgp_prefix
,
6802 show_bgp_prefix_cmd
,
6803 "show bgp X:X::X:X/M",
6806 "IPv6 prefix <network>/<length>\n")
6808 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6811 ALIAS (show_bgp_prefix
,
6812 show_bgp_ipv6_prefix_cmd
,
6813 "show bgp ipv6 X:X::X:X/M",
6817 "IPv6 prefix <network>/<length>\n")
6819 DEFUN (show_bgp_ipv6_safi_prefix
,
6820 show_bgp_ipv6_safi_prefix_cmd
,
6821 "show bgp ipv6 (unicast|multicast) X:X::X:X/M",
6825 "Address Family modifier\n"
6826 "Address Family modifier\n"
6827 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6829 if (strncmp (argv
[0], "m", 1) == 0)
6830 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1);
6832 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6836 DEFUN (show_ipv6_bgp_prefix
,
6837 show_ipv6_bgp_prefix_cmd
,
6838 "show ipv6 bgp X:X::X:X/M",
6842 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6844 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6847 DEFUN (show_bgp_view
,
6849 "show bgp view WORD",
6857 /* BGP structure lookup. */
6858 bgp
= bgp_lookup_by_name (argv
[0]);
6861 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
6865 return bgp_show (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6868 ALIAS (show_bgp_view
,
6869 show_bgp_view_ipv6_cmd
,
6870 "show bgp view WORD ipv6",
6877 DEFUN (show_bgp_view_route
,
6878 show_bgp_view_route_cmd
,
6879 "show bgp view WORD X:X::X:X",
6884 "Network in the BGP routing table to display\n")
6886 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6889 ALIAS (show_bgp_view_route
,
6890 show_bgp_view_ipv6_route_cmd
,
6891 "show bgp view WORD ipv6 X:X::X:X",
6897 "Network in the BGP routing table to display\n")
6899 DEFUN (show_bgp_view_prefix
,
6900 show_bgp_view_prefix_cmd
,
6901 "show bgp view WORD X:X::X:X/M",
6906 "IPv6 prefix <network>/<length>\n")
6908 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6911 ALIAS (show_bgp_view_prefix
,
6912 show_bgp_view_ipv6_prefix_cmd
,
6913 "show bgp view WORD ipv6 X:X::X:X/M",
6919 "IPv6 prefix <network>/<length>\n")
6922 DEFUN (show_ipv6_mbgp
,
6929 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
6934 DEFUN (show_ipv6_mbgp_route
,
6935 show_ipv6_mbgp_route_cmd
,
6936 "show ipv6 mbgp X:X::X:X",
6940 "Network in the MBGP routing table to display\n")
6942 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0);
6946 DEFUN (show_ipv6_mbgp_prefix
,
6947 show_ipv6_mbgp_prefix_cmd
,
6948 "show ipv6 mbgp X:X::X:X/M",
6952 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6954 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1);
6960 bgp_show_regexp (struct vty
*vty
, int argc
, const char **argv
, afi_t afi
,
6961 safi_t safi
, enum bgp_show_type type
)
6971 b
= buffer_new (1024);
6972 for (i
= 0; i
< argc
; i
++)
6975 buffer_putc (b
, ' ');
6978 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
6983 buffer_putstr (b
, argv
[i
]);
6985 buffer_putc (b
, '\0');
6987 regstr
= buffer_getstr (b
);
6990 regex
= bgp_regcomp (regstr
);
6991 XFREE(MTYPE_TMP
, regstr
);
6994 vty_out (vty
, "Can't compile regexp %s%s", argv
[0],
6999 rc
= bgp_show (vty
, NULL
, afi
, safi
, type
, regex
);
7000 bgp_regex_free (regex
);
7004 DEFUN (show_ip_bgp_regexp
,
7005 show_ip_bgp_regexp_cmd
,
7006 "show ip bgp regexp .LINE",
7010 "Display routes matching the AS path regular expression\n"
7011 "A regular-expression to match the BGP AS paths\n")
7013 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
7014 bgp_show_type_regexp
);
7017 DEFUN (show_ip_bgp_flap_regexp
,
7018 show_ip_bgp_flap_regexp_cmd
,
7019 "show ip bgp flap-statistics regexp .LINE",
7023 "Display flap statistics of routes\n"
7024 "Display routes matching the AS path regular expression\n"
7025 "A regular-expression to match the BGP AS paths\n")
7027 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
7028 bgp_show_type_flap_regexp
);
7031 DEFUN (show_ip_bgp_ipv4_regexp
,
7032 show_ip_bgp_ipv4_regexp_cmd
,
7033 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
7038 "Address Family modifier\n"
7039 "Address Family modifier\n"
7040 "Display routes matching the AS path regular expression\n"
7041 "A regular-expression to match the BGP AS paths\n")
7043 if (strncmp (argv
[0], "m", 1) == 0)
7044 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_MULTICAST
,
7045 bgp_show_type_regexp
);
7047 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
7048 bgp_show_type_regexp
);
7052 DEFUN (show_bgp_regexp
,
7053 show_bgp_regexp_cmd
,
7054 "show bgp regexp .LINE",
7057 "Display routes matching the AS path regular expression\n"
7058 "A regular-expression to match the BGP AS paths\n")
7060 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
7061 bgp_show_type_regexp
);
7064 ALIAS (show_bgp_regexp
,
7065 show_bgp_ipv6_regexp_cmd
,
7066 "show bgp ipv6 regexp .LINE",
7070 "Display routes matching the AS path regular expression\n"
7071 "A regular-expression to match the BGP AS paths\n")
7074 DEFUN (show_ipv6_bgp_regexp
,
7075 show_ipv6_bgp_regexp_cmd
,
7076 "show ipv6 bgp regexp .LINE",
7080 "Display routes matching the AS path regular expression\n"
7081 "A regular-expression to match the BGP AS paths\n")
7083 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
7084 bgp_show_type_regexp
);
7088 DEFUN (show_ipv6_mbgp_regexp
,
7089 show_ipv6_mbgp_regexp_cmd
,
7090 "show ipv6 mbgp regexp .LINE",
7094 "Display routes matching the AS path regular expression\n"
7095 "A regular-expression to match the MBGP AS paths\n")
7097 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
,
7098 bgp_show_type_regexp
);
7100 #endif /* HAVE_IPV6 */
7103 bgp_show_prefix_list (struct vty
*vty
, const char *prefix_list_str
, afi_t afi
,
7104 safi_t safi
, enum bgp_show_type type
)
7106 struct prefix_list
*plist
;
7108 plist
= prefix_list_lookup (afi
, prefix_list_str
);
7111 vty_out (vty
, "%% %s is not a valid prefix-list name%s",
7112 prefix_list_str
, VTY_NEWLINE
);
7116 return bgp_show (vty
, NULL
, afi
, safi
, type
, plist
);
7119 DEFUN (show_ip_bgp_prefix_list
,
7120 show_ip_bgp_prefix_list_cmd
,
7121 "show ip bgp prefix-list WORD",
7125 "Display routes conforming to the prefix-list\n"
7126 "IP prefix-list name\n")
7128 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7129 bgp_show_type_prefix_list
);
7132 DEFUN (show_ip_bgp_flap_prefix_list
,
7133 show_ip_bgp_flap_prefix_list_cmd
,
7134 "show ip bgp flap-statistics prefix-list WORD",
7138 "Display flap statistics of routes\n"
7139 "Display routes conforming to the prefix-list\n"
7140 "IP prefix-list name\n")
7142 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7143 bgp_show_type_flap_prefix_list
);
7146 DEFUN (show_ip_bgp_ipv4_prefix_list
,
7147 show_ip_bgp_ipv4_prefix_list_cmd
,
7148 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
7153 "Address Family modifier\n"
7154 "Address Family modifier\n"
7155 "Display routes conforming to the prefix-list\n"
7156 "IP prefix-list name\n")
7158 if (strncmp (argv
[0], "m", 1) == 0)
7159 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
7160 bgp_show_type_prefix_list
);
7162 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
7163 bgp_show_type_prefix_list
);
7167 DEFUN (show_bgp_prefix_list
,
7168 show_bgp_prefix_list_cmd
,
7169 "show bgp prefix-list WORD",
7172 "Display routes conforming to the prefix-list\n"
7173 "IPv6 prefix-list name\n")
7175 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7176 bgp_show_type_prefix_list
);
7179 ALIAS (show_bgp_prefix_list
,
7180 show_bgp_ipv6_prefix_list_cmd
,
7181 "show bgp ipv6 prefix-list WORD",
7185 "Display routes conforming to the prefix-list\n"
7186 "IPv6 prefix-list name\n")
7189 DEFUN (show_ipv6_bgp_prefix_list
,
7190 show_ipv6_bgp_prefix_list_cmd
,
7191 "show ipv6 bgp prefix-list WORD",
7195 "Display routes matching the prefix-list\n"
7196 "IPv6 prefix-list name\n")
7198 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7199 bgp_show_type_prefix_list
);
7203 DEFUN (show_ipv6_mbgp_prefix_list
,
7204 show_ipv6_mbgp_prefix_list_cmd
,
7205 "show ipv6 mbgp prefix-list WORD",
7209 "Display routes matching the prefix-list\n"
7210 "IPv6 prefix-list name\n")
7212 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
7213 bgp_show_type_prefix_list
);
7215 #endif /* HAVE_IPV6 */
7218 bgp_show_filter_list (struct vty
*vty
, const char *filter
, afi_t afi
,
7219 safi_t safi
, enum bgp_show_type type
)
7221 struct as_list
*as_list
;
7223 as_list
= as_list_lookup (filter
);
7224 if (as_list
== NULL
)
7226 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
7230 return bgp_show (vty
, NULL
, afi
, safi
, type
, as_list
);
7233 DEFUN (show_ip_bgp_filter_list
,
7234 show_ip_bgp_filter_list_cmd
,
7235 "show ip bgp filter-list WORD",
7239 "Display routes conforming to the filter-list\n"
7240 "Regular expression access list name\n")
7242 return bgp_show_filter_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7243 bgp_show_type_filter_list
);
7246 DEFUN (show_ip_bgp_flap_filter_list
,
7247 show_ip_bgp_flap_filter_list_cmd
,
7248 "show ip bgp flap-statistics filter-list WORD",
7252 "Display flap statistics of routes\n"
7253 "Display routes conforming to the filter-list\n"
7254 "Regular expression access list name\n")
7256 return bgp_show_filter_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7257 bgp_show_type_flap_filter_list
);
7260 DEFUN (show_ip_bgp_ipv4_filter_list
,
7261 show_ip_bgp_ipv4_filter_list_cmd
,
7262 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
7267 "Address Family modifier\n"
7268 "Address Family modifier\n"
7269 "Display routes conforming to the filter-list\n"
7270 "Regular expression access list name\n")
7272 if (strncmp (argv
[0], "m", 1) == 0)
7273 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
7274 bgp_show_type_filter_list
);
7276 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
7277 bgp_show_type_filter_list
);
7281 DEFUN (show_bgp_filter_list
,
7282 show_bgp_filter_list_cmd
,
7283 "show bgp filter-list WORD",
7286 "Display routes conforming to the filter-list\n"
7287 "Regular expression access list name\n")
7289 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7290 bgp_show_type_filter_list
);
7293 ALIAS (show_bgp_filter_list
,
7294 show_bgp_ipv6_filter_list_cmd
,
7295 "show bgp ipv6 filter-list WORD",
7299 "Display routes conforming to the filter-list\n"
7300 "Regular expression access list name\n")
7303 DEFUN (show_ipv6_bgp_filter_list
,
7304 show_ipv6_bgp_filter_list_cmd
,
7305 "show ipv6 bgp filter-list WORD",
7309 "Display routes conforming to the filter-list\n"
7310 "Regular expression access list name\n")
7312 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7313 bgp_show_type_filter_list
);
7317 DEFUN (show_ipv6_mbgp_filter_list
,
7318 show_ipv6_mbgp_filter_list_cmd
,
7319 "show ipv6 mbgp filter-list WORD",
7323 "Display routes conforming to the filter-list\n"
7324 "Regular expression access list name\n")
7326 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
7327 bgp_show_type_filter_list
);
7329 #endif /* HAVE_IPV6 */
7332 bgp_show_route_map (struct vty
*vty
, const char *rmap_str
, afi_t afi
,
7333 safi_t safi
, enum bgp_show_type type
)
7335 struct route_map
*rmap
;
7337 rmap
= route_map_lookup_by_name (rmap_str
);
7340 vty_out (vty
, "%% %s is not a valid route-map name%s",
7341 rmap_str
, VTY_NEWLINE
);
7345 return bgp_show (vty
, NULL
, afi
, safi
, type
, rmap
);
7348 DEFUN (show_ip_bgp_route_map
,
7349 show_ip_bgp_route_map_cmd
,
7350 "show ip bgp route-map WORD",
7354 "Display routes matching the route-map\n"
7355 "A route-map to match on\n")
7357 return bgp_show_route_map (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7358 bgp_show_type_route_map
);
7361 DEFUN (show_ip_bgp_flap_route_map
,
7362 show_ip_bgp_flap_route_map_cmd
,
7363 "show ip bgp flap-statistics route-map WORD",
7367 "Display flap statistics of routes\n"
7368 "Display routes matching the route-map\n"
7369 "A route-map to match on\n")
7371 return bgp_show_route_map (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7372 bgp_show_type_flap_route_map
);
7375 DEFUN (show_ip_bgp_ipv4_route_map
,
7376 show_ip_bgp_ipv4_route_map_cmd
,
7377 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
7382 "Address Family modifier\n"
7383 "Address Family modifier\n"
7384 "Display routes matching the route-map\n"
7385 "A route-map to match on\n")
7387 if (strncmp (argv
[0], "m", 1) == 0)
7388 return bgp_show_route_map (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
7389 bgp_show_type_route_map
);
7391 return bgp_show_route_map (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
7392 bgp_show_type_route_map
);
7395 DEFUN (show_bgp_route_map
,
7396 show_bgp_route_map_cmd
,
7397 "show bgp route-map WORD",
7400 "Display routes matching the route-map\n"
7401 "A route-map to match on\n")
7403 return bgp_show_route_map (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7404 bgp_show_type_route_map
);
7407 ALIAS (show_bgp_route_map
,
7408 show_bgp_ipv6_route_map_cmd
,
7409 "show bgp ipv6 route-map WORD",
7413 "Display routes matching the route-map\n"
7414 "A route-map to match on\n")
7416 DEFUN (show_ip_bgp_cidr_only
,
7417 show_ip_bgp_cidr_only_cmd
,
7418 "show ip bgp cidr-only",
7422 "Display only routes with non-natural netmasks\n")
7424 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7425 bgp_show_type_cidr_only
, NULL
);
7428 DEFUN (show_ip_bgp_flap_cidr_only
,
7429 show_ip_bgp_flap_cidr_only_cmd
,
7430 "show ip bgp flap-statistics cidr-only",
7434 "Display flap statistics of routes\n"
7435 "Display only routes with non-natural netmasks\n")
7437 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7438 bgp_show_type_flap_cidr_only
, NULL
);
7441 DEFUN (show_ip_bgp_ipv4_cidr_only
,
7442 show_ip_bgp_ipv4_cidr_only_cmd
,
7443 "show ip bgp ipv4 (unicast|multicast) cidr-only",
7448 "Address Family modifier\n"
7449 "Address Family modifier\n"
7450 "Display only routes with non-natural netmasks\n")
7452 if (strncmp (argv
[0], "m", 1) == 0)
7453 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
7454 bgp_show_type_cidr_only
, NULL
);
7456 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7457 bgp_show_type_cidr_only
, NULL
);
7460 DEFUN (show_ip_bgp_community_all
,
7461 show_ip_bgp_community_all_cmd
,
7462 "show ip bgp community",
7466 "Display routes matching the communities\n")
7468 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7469 bgp_show_type_community_all
, NULL
);
7472 DEFUN (show_ip_bgp_ipv4_community_all
,
7473 show_ip_bgp_ipv4_community_all_cmd
,
7474 "show ip bgp ipv4 (unicast|multicast) community",
7479 "Address Family modifier\n"
7480 "Address Family modifier\n"
7481 "Display routes matching the communities\n")
7483 if (strncmp (argv
[0], "m", 1) == 0)
7484 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
7485 bgp_show_type_community_all
, NULL
);
7487 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7488 bgp_show_type_community_all
, NULL
);
7492 DEFUN (show_bgp_community_all
,
7493 show_bgp_community_all_cmd
,
7494 "show bgp community",
7497 "Display routes matching the communities\n")
7499 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
7500 bgp_show_type_community_all
, NULL
);
7503 ALIAS (show_bgp_community_all
,
7504 show_bgp_ipv6_community_all_cmd
,
7505 "show bgp ipv6 community",
7509 "Display routes matching the communities\n")
7512 DEFUN (show_ipv6_bgp_community_all
,
7513 show_ipv6_bgp_community_all_cmd
,
7514 "show ipv6 bgp community",
7518 "Display routes matching the communities\n")
7520 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
7521 bgp_show_type_community_all
, NULL
);
7525 DEFUN (show_ipv6_mbgp_community_all
,
7526 show_ipv6_mbgp_community_all_cmd
,
7527 "show ipv6 mbgp community",
7531 "Display routes matching the communities\n")
7533 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
7534 bgp_show_type_community_all
, NULL
);
7536 #endif /* HAVE_IPV6 */
7539 bgp_show_community (struct vty
*vty
, const char *view_name
, int argc
,
7540 const char **argv
, int exact
, afi_t afi
, safi_t safi
)
7542 struct community
*com
;
7549 /* BGP structure lookup */
7552 bgp
= bgp_lookup_by_name (view_name
);
7555 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
7561 bgp
= bgp_get_default ();
7564 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
7569 b
= buffer_new (1024);
7570 for (i
= 0; i
< argc
; i
++)
7573 buffer_putc (b
, ' ');
7576 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
7581 buffer_putstr (b
, argv
[i
]);
7583 buffer_putc (b
, '\0');
7585 str
= buffer_getstr (b
);
7588 com
= community_str2com (str
);
7589 XFREE (MTYPE_TMP
, str
);
7592 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
7596 return bgp_show (vty
, bgp
, afi
, safi
,
7597 (exact
? bgp_show_type_community_exact
:
7598 bgp_show_type_community
), com
);
7601 DEFUN (show_ip_bgp_community
,
7602 show_ip_bgp_community_cmd
,
7603 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
7607 "Display routes matching the communities\n"
7608 "community number\n"
7609 "Do not send outside local AS (well-known community)\n"
7610 "Do not advertise to any peer (well-known community)\n"
7611 "Do not export to next AS (well-known community)\n")
7613 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
7616 ALIAS (show_ip_bgp_community
,
7617 show_ip_bgp_community2_cmd
,
7618 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7622 "Display routes matching the communities\n"
7623 "community number\n"
7624 "Do not send outside local AS (well-known community)\n"
7625 "Do not advertise to any peer (well-known community)\n"
7626 "Do not export to next AS (well-known community)\n"
7627 "community number\n"
7628 "Do not send outside local AS (well-known community)\n"
7629 "Do not advertise to any peer (well-known community)\n"
7630 "Do not export to next AS (well-known community)\n")
7632 ALIAS (show_ip_bgp_community
,
7633 show_ip_bgp_community3_cmd
,
7634 "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)",
7638 "Display routes matching the communities\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"
7643 "community number\n"
7644 "Do not send outside local AS (well-known community)\n"
7645 "Do not advertise to any peer (well-known community)\n"
7646 "Do not export to next AS (well-known community)\n"
7647 "community number\n"
7648 "Do not send outside local AS (well-known community)\n"
7649 "Do not advertise to any peer (well-known community)\n"
7650 "Do not export to next AS (well-known community)\n")
7652 ALIAS (show_ip_bgp_community
,
7653 show_ip_bgp_community4_cmd
,
7654 "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)",
7658 "Display routes matching the communities\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"
7667 "community number\n"
7668 "Do not send outside local AS (well-known community)\n"
7669 "Do not advertise to any peer (well-known community)\n"
7670 "Do not export to next AS (well-known community)\n"
7671 "community number\n"
7672 "Do not send outside local AS (well-known community)\n"
7673 "Do not advertise to any peer (well-known community)\n"
7674 "Do not export to next AS (well-known community)\n")
7676 DEFUN (show_ip_bgp_ipv4_community
,
7677 show_ip_bgp_ipv4_community_cmd
,
7678 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
7683 "Address Family modifier\n"
7684 "Address Family modifier\n"
7685 "Display routes matching the communities\n"
7686 "community number\n"
7687 "Do not send outside local AS (well-known community)\n"
7688 "Do not advertise to any peer (well-known community)\n"
7689 "Do not export to next AS (well-known community)\n")
7691 if (strncmp (argv
[0], "m", 1) == 0)
7692 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_MULTICAST
);
7694 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
7697 ALIAS (show_ip_bgp_ipv4_community
,
7698 show_ip_bgp_ipv4_community2_cmd
,
7699 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7704 "Address Family modifier\n"
7705 "Address Family modifier\n"
7706 "Display routes matching the communities\n"
7707 "community number\n"
7708 "Do not send outside local AS (well-known community)\n"
7709 "Do not advertise to any peer (well-known community)\n"
7710 "Do not export to next AS (well-known community)\n"
7711 "community number\n"
7712 "Do not send outside local AS (well-known community)\n"
7713 "Do not advertise to any peer (well-known community)\n"
7714 "Do not export to next AS (well-known community)\n")
7716 ALIAS (show_ip_bgp_ipv4_community
,
7717 show_ip_bgp_ipv4_community3_cmd
,
7718 "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)",
7723 "Address Family modifier\n"
7724 "Address Family modifier\n"
7725 "Display routes matching the communities\n"
7726 "community number\n"
7727 "Do not send outside local AS (well-known community)\n"
7728 "Do not advertise to any peer (well-known community)\n"
7729 "Do not export to next AS (well-known community)\n"
7730 "community number\n"
7731 "Do not send outside local AS (well-known community)\n"
7732 "Do not advertise to any peer (well-known community)\n"
7733 "Do not export to next AS (well-known community)\n"
7734 "community number\n"
7735 "Do not send outside local AS (well-known community)\n"
7736 "Do not advertise to any peer (well-known community)\n"
7737 "Do not export to next AS (well-known community)\n")
7739 ALIAS (show_ip_bgp_ipv4_community
,
7740 show_ip_bgp_ipv4_community4_cmd
,
7741 "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)",
7746 "Address Family modifier\n"
7747 "Address Family modifier\n"
7748 "Display routes matching the communities\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"
7757 "community number\n"
7758 "Do not send outside local AS (well-known community)\n"
7759 "Do not advertise to any peer (well-known community)\n"
7760 "Do not export to next AS (well-known community)\n"
7761 "community number\n"
7762 "Do not send outside local AS (well-known community)\n"
7763 "Do not advertise to any peer (well-known community)\n"
7764 "Do not export to next AS (well-known community)\n")
7766 DEFUN (show_bgp_view_afi_safi_community_all
,
7767 show_bgp_view_afi_safi_community_all_cmd
,
7769 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community",
7771 "show bgp view WORD ipv4 (unicast|multicast) community",
7781 "Address Family modifier\n"
7782 "Address Family modifier\n"
7783 "Display routes containing communities\n")
7789 /* BGP structure lookup. */
7790 bgp
= bgp_lookup_by_name (argv
[0]);
7793 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
7798 afi
= (strncmp (argv
[1], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
7799 safi
= (strncmp (argv
[2], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
7802 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
7804 return bgp_show (vty
, bgp
, afi
, safi
, bgp_show_type_community_all
, NULL
);
7807 DEFUN (show_bgp_view_afi_safi_community
,
7808 show_bgp_view_afi_safi_community_cmd
,
7810 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
7812 "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
7822 "Address family modifier\n"
7823 "Address family modifier\n"
7824 "Display routes matching the communities\n"
7825 "community number\n"
7826 "Do not send outside local AS (well-known community)\n"
7827 "Do not advertise to any peer (well-known community)\n"
7828 "Do not export to next AS (well-known community)\n")
7834 afi
= (strncmp (argv
[1], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
7835 safi
= (strncmp (argv
[2], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
7836 return bgp_show_community (vty
, argv
[0], argc
-3, &argv
[3], 0, afi
, safi
);
7839 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
7840 return bgp_show_community (vty
, argv
[0], argc
-2, &argv
[2], 0, afi
, safi
);
7844 ALIAS (show_bgp_view_afi_safi_community
,
7845 show_bgp_view_afi_safi_community2_cmd
,
7847 "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)",
7849 "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7859 "Address family modifier\n"
7860 "Address family modifier\n"
7861 "Display routes matching the communities\n"
7862 "community number\n"
7863 "Do not send outside local AS (well-known community)\n"
7864 "Do not advertise to any peer (well-known community)\n"
7865 "Do not export to next AS (well-known community)\n"
7866 "community number\n"
7867 "Do not send outside local AS (well-known community)\n"
7868 "Do not advertise to any peer (well-known community)\n"
7869 "Do not export to next AS (well-known community)\n")
7871 ALIAS (show_bgp_view_afi_safi_community
,
7872 show_bgp_view_afi_safi_community3_cmd
,
7874 "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)",
7876 "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)",
7886 "Address family modifier\n"
7887 "Address family modifier\n"
7888 "Display routes matching the communities\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"
7893 "community number\n"
7894 "Do not send outside local AS (well-known community)\n"
7895 "Do not advertise to any peer (well-known community)\n"
7896 "Do not export to next AS (well-known community)\n"
7897 "community number\n"
7898 "Do not send outside local AS (well-known community)\n"
7899 "Do not advertise to any peer (well-known community)\n"
7900 "Do not export to next AS (well-known community)\n")
7902 ALIAS (show_bgp_view_afi_safi_community
,
7903 show_bgp_view_afi_safi_community4_cmd
,
7905 "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)",
7907 "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)",
7917 "Address family modifier\n"
7918 "Address family modifier\n"
7919 "Display routes matching the communities\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"
7928 "community number\n"
7929 "Do not send outside local AS (well-known community)\n"
7930 "Do not advertise to any peer (well-known community)\n"
7931 "Do not export to next AS (well-known community)\n"
7932 "community number\n"
7933 "Do not send outside local AS (well-known community)\n"
7934 "Do not advertise to any peer (well-known community)\n"
7935 "Do not export to next AS (well-known community)\n")
7937 DEFUN (show_ip_bgp_community_exact
,
7938 show_ip_bgp_community_exact_cmd
,
7939 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7943 "Display routes matching the communities\n"
7944 "community number\n"
7945 "Do not send outside local AS (well-known community)\n"
7946 "Do not advertise to any peer (well-known community)\n"
7947 "Do not export to next AS (well-known community)\n"
7948 "Exact match of the communities")
7950 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
7953 ALIAS (show_ip_bgp_community_exact
,
7954 show_ip_bgp_community2_exact_cmd
,
7955 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7959 "Display routes matching the communities\n"
7960 "community number\n"
7961 "Do not send outside local AS (well-known community)\n"
7962 "Do not advertise to any peer (well-known community)\n"
7963 "Do not export to next AS (well-known community)\n"
7964 "community number\n"
7965 "Do not send outside local AS (well-known community)\n"
7966 "Do not advertise to any peer (well-known community)\n"
7967 "Do not export to next AS (well-known community)\n"
7968 "Exact match of the communities")
7970 ALIAS (show_ip_bgp_community_exact
,
7971 show_ip_bgp_community3_exact_cmd
,
7972 "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",
7976 "Display routes matching the communities\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 "community number\n"
7982 "Do not send outside local AS (well-known community)\n"
7983 "Do not advertise to any peer (well-known community)\n"
7984 "Do not export to next AS (well-known community)\n"
7985 "community number\n"
7986 "Do not send outside local AS (well-known community)\n"
7987 "Do not advertise to any peer (well-known community)\n"
7988 "Do not export to next AS (well-known community)\n"
7989 "Exact match of the communities")
7991 ALIAS (show_ip_bgp_community_exact
,
7992 show_ip_bgp_community4_exact_cmd
,
7993 "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",
7997 "Display routes matching the communities\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 "community number\n"
8007 "Do not send outside local AS (well-known community)\n"
8008 "Do not advertise to any peer (well-known community)\n"
8009 "Do not export to next AS (well-known community)\n"
8010 "community number\n"
8011 "Do not send outside local AS (well-known community)\n"
8012 "Do not advertise to any peer (well-known community)\n"
8013 "Do not export to next AS (well-known community)\n"
8014 "Exact match of the communities")
8016 DEFUN (show_ip_bgp_ipv4_community_exact
,
8017 show_ip_bgp_ipv4_community_exact_cmd
,
8018 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8023 "Address Family modifier\n"
8024 "Address Family modifier\n"
8025 "Display routes matching the communities\n"
8026 "community number\n"
8027 "Do not send outside local AS (well-known community)\n"
8028 "Do not advertise to any peer (well-known community)\n"
8029 "Do not export to next AS (well-known community)\n"
8030 "Exact match of the communities")
8032 if (strncmp (argv
[0], "m", 1) == 0)
8033 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_MULTICAST
);
8035 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
8038 ALIAS (show_ip_bgp_ipv4_community_exact
,
8039 show_ip_bgp_ipv4_community2_exact_cmd
,
8040 "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",
8045 "Address Family modifier\n"
8046 "Address Family modifier\n"
8047 "Display routes matching the communities\n"
8048 "community number\n"
8049 "Do not send outside local AS (well-known community)\n"
8050 "Do not advertise to any peer (well-known community)\n"
8051 "Do not export to next AS (well-known community)\n"
8052 "community number\n"
8053 "Do not send outside local AS (well-known community)\n"
8054 "Do not advertise to any peer (well-known community)\n"
8055 "Do not export to next AS (well-known community)\n"
8056 "Exact match of the communities")
8058 ALIAS (show_ip_bgp_ipv4_community_exact
,
8059 show_ip_bgp_ipv4_community3_exact_cmd
,
8060 "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",
8065 "Address Family modifier\n"
8066 "Address Family modifier\n"
8067 "Display routes matching the communities\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 "community number\n"
8073 "Do not send outside local AS (well-known community)\n"
8074 "Do not advertise to any peer (well-known community)\n"
8075 "Do not export to next AS (well-known community)\n"
8076 "community number\n"
8077 "Do not send outside local AS (well-known community)\n"
8078 "Do not advertise to any peer (well-known community)\n"
8079 "Do not export to next AS (well-known community)\n"
8080 "Exact match of the communities")
8082 ALIAS (show_ip_bgp_ipv4_community_exact
,
8083 show_ip_bgp_ipv4_community4_exact_cmd
,
8084 "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",
8089 "Address Family modifier\n"
8090 "Address Family modifier\n"
8091 "Display routes matching the communities\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 "community number\n"
8101 "Do not send outside local AS (well-known community)\n"
8102 "Do not advertise to any peer (well-known community)\n"
8103 "Do not export to next AS (well-known community)\n"
8104 "community number\n"
8105 "Do not send outside local AS (well-known community)\n"
8106 "Do not advertise to any peer (well-known community)\n"
8107 "Do not export to next AS (well-known community)\n"
8108 "Exact match of the communities")
8111 DEFUN (show_bgp_community
,
8112 show_bgp_community_cmd
,
8113 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
8116 "Display routes matching the communities\n"
8117 "community number\n"
8118 "Do not send outside local AS (well-known community)\n"
8119 "Do not advertise to any peer (well-known community)\n"
8120 "Do not export to next AS (well-known community)\n")
8122 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
8125 ALIAS (show_bgp_community
,
8126 show_bgp_ipv6_community_cmd
,
8127 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
8131 "Display routes matching the communities\n"
8132 "community number\n"
8133 "Do not send outside local AS (well-known community)\n"
8134 "Do not advertise to any peer (well-known community)\n"
8135 "Do not export to next AS (well-known community)\n")
8137 ALIAS (show_bgp_community
,
8138 show_bgp_community2_cmd
,
8139 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8142 "Display routes matching the communities\n"
8143 "community number\n"
8144 "Do not send outside local AS (well-known community)\n"
8145 "Do not advertise to any peer (well-known community)\n"
8146 "Do not export to next AS (well-known community)\n"
8147 "community number\n"
8148 "Do not send outside local AS (well-known community)\n"
8149 "Do not advertise to any peer (well-known community)\n"
8150 "Do not export to next AS (well-known community)\n")
8152 ALIAS (show_bgp_community
,
8153 show_bgp_ipv6_community2_cmd
,
8154 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8158 "Display routes matching the communities\n"
8159 "community number\n"
8160 "Do not send outside local AS (well-known community)\n"
8161 "Do not advertise to any peer (well-known community)\n"
8162 "Do not export to next AS (well-known community)\n"
8163 "community number\n"
8164 "Do not send outside local AS (well-known community)\n"
8165 "Do not advertise to any peer (well-known community)\n"
8166 "Do not export to next AS (well-known community)\n")
8168 ALIAS (show_bgp_community
,
8169 show_bgp_community3_cmd
,
8170 "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)",
8173 "Display routes matching the communities\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"
8178 "community number\n"
8179 "Do not send outside local AS (well-known community)\n"
8180 "Do not advertise to any peer (well-known community)\n"
8181 "Do not export to next AS (well-known community)\n"
8182 "community number\n"
8183 "Do not send outside local AS (well-known community)\n"
8184 "Do not advertise to any peer (well-known community)\n"
8185 "Do not export to next AS (well-known community)\n")
8187 ALIAS (show_bgp_community
,
8188 show_bgp_ipv6_community3_cmd
,
8189 "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)",
8193 "Display routes matching the communities\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"
8198 "community number\n"
8199 "Do not send outside local AS (well-known community)\n"
8200 "Do not advertise to any peer (well-known community)\n"
8201 "Do not export to next AS (well-known community)\n"
8202 "community number\n"
8203 "Do not send outside local AS (well-known community)\n"
8204 "Do not advertise to any peer (well-known community)\n"
8205 "Do not export to next AS (well-known community)\n")
8207 ALIAS (show_bgp_community
,
8208 show_bgp_community4_cmd
,
8209 "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)",
8212 "Display routes matching the communities\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"
8221 "community number\n"
8222 "Do not send outside local AS (well-known community)\n"
8223 "Do not advertise to any peer (well-known community)\n"
8224 "Do not export to next AS (well-known community)\n"
8225 "community number\n"
8226 "Do not send outside local AS (well-known community)\n"
8227 "Do not advertise to any peer (well-known community)\n"
8228 "Do not export to next AS (well-known community)\n")
8230 ALIAS (show_bgp_community
,
8231 show_bgp_ipv6_community4_cmd
,
8232 "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)",
8236 "Display routes matching the communities\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"
8245 "community number\n"
8246 "Do not send outside local AS (well-known community)\n"
8247 "Do not advertise to any peer (well-known community)\n"
8248 "Do not export to next AS (well-known community)\n"
8249 "community number\n"
8250 "Do not send outside local AS (well-known community)\n"
8251 "Do not advertise to any peer (well-known community)\n"
8252 "Do not export to next AS (well-known community)\n")
8255 DEFUN (show_ipv6_bgp_community
,
8256 show_ipv6_bgp_community_cmd
,
8257 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
8261 "Display routes matching the communities\n"
8262 "community number\n"
8263 "Do not send outside local AS (well-known community)\n"
8264 "Do not advertise to any peer (well-known community)\n"
8265 "Do not export to next AS (well-known community)\n")
8267 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
8271 ALIAS (show_ipv6_bgp_community
,
8272 show_ipv6_bgp_community2_cmd
,
8273 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8277 "Display routes matching the communities\n"
8278 "community number\n"
8279 "Do not send outside local AS (well-known community)\n"
8280 "Do not advertise to any peer (well-known community)\n"
8281 "Do not export to next AS (well-known community)\n"
8282 "community number\n"
8283 "Do not send outside local AS (well-known community)\n"
8284 "Do not advertise to any peer (well-known community)\n"
8285 "Do not export to next AS (well-known community)\n")
8288 ALIAS (show_ipv6_bgp_community
,
8289 show_ipv6_bgp_community3_cmd
,
8290 "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)",
8294 "Display routes matching the communities\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"
8299 "community number\n"
8300 "Do not send outside local AS (well-known community)\n"
8301 "Do not advertise to any peer (well-known community)\n"
8302 "Do not export to next AS (well-known community)\n"
8303 "community number\n"
8304 "Do not send outside local AS (well-known community)\n"
8305 "Do not advertise to any peer (well-known community)\n"
8306 "Do not export to next AS (well-known community)\n")
8309 ALIAS (show_ipv6_bgp_community
,
8310 show_ipv6_bgp_community4_cmd
,
8311 "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)",
8315 "Display routes matching the communities\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"
8324 "community number\n"
8325 "Do not send outside local AS (well-known community)\n"
8326 "Do not advertise to any peer (well-known community)\n"
8327 "Do not export to next AS (well-known community)\n"
8328 "community number\n"
8329 "Do not send outside local AS (well-known community)\n"
8330 "Do not advertise to any peer (well-known community)\n"
8331 "Do not export to next AS (well-known community)\n")
8333 DEFUN (show_bgp_community_exact
,
8334 show_bgp_community_exact_cmd
,
8335 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8338 "Display routes matching the communities\n"
8339 "community number\n"
8340 "Do not send outside local AS (well-known community)\n"
8341 "Do not advertise to any peer (well-known community)\n"
8342 "Do not export to next AS (well-known community)\n"
8343 "Exact match of the communities")
8345 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
8348 ALIAS (show_bgp_community_exact
,
8349 show_bgp_ipv6_community_exact_cmd
,
8350 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8354 "Display routes matching the communities\n"
8355 "community number\n"
8356 "Do not send outside local AS (well-known community)\n"
8357 "Do not advertise to any peer (well-known community)\n"
8358 "Do not export to next AS (well-known community)\n"
8359 "Exact match of the communities")
8361 ALIAS (show_bgp_community_exact
,
8362 show_bgp_community2_exact_cmd
,
8363 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8366 "Display routes matching the communities\n"
8367 "community number\n"
8368 "Do not send outside local AS (well-known community)\n"
8369 "Do not advertise to any peer (well-known community)\n"
8370 "Do not export to next AS (well-known community)\n"
8371 "community number\n"
8372 "Do not send outside local AS (well-known community)\n"
8373 "Do not advertise to any peer (well-known community)\n"
8374 "Do not export to next AS (well-known community)\n"
8375 "Exact match of the communities")
8377 ALIAS (show_bgp_community_exact
,
8378 show_bgp_ipv6_community2_exact_cmd
,
8379 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8383 "Display routes matching the communities\n"
8384 "community number\n"
8385 "Do not send outside local AS (well-known community)\n"
8386 "Do not advertise to any peer (well-known community)\n"
8387 "Do not export to next AS (well-known community)\n"
8388 "community number\n"
8389 "Do not send outside local AS (well-known community)\n"
8390 "Do not advertise to any peer (well-known community)\n"
8391 "Do not export to next AS (well-known community)\n"
8392 "Exact match of the communities")
8394 ALIAS (show_bgp_community_exact
,
8395 show_bgp_community3_exact_cmd
,
8396 "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",
8399 "Display routes matching the communities\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 "community number\n"
8405 "Do not send outside local AS (well-known community)\n"
8406 "Do not advertise to any peer (well-known community)\n"
8407 "Do not export to next AS (well-known community)\n"
8408 "community number\n"
8409 "Do not send outside local AS (well-known community)\n"
8410 "Do not advertise to any peer (well-known community)\n"
8411 "Do not export to next AS (well-known community)\n"
8412 "Exact match of the communities")
8414 ALIAS (show_bgp_community_exact
,
8415 show_bgp_ipv6_community3_exact_cmd
,
8416 "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",
8420 "Display routes matching the communities\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 "community number\n"
8426 "Do not send outside local AS (well-known community)\n"
8427 "Do not advertise to any peer (well-known community)\n"
8428 "Do not export to next AS (well-known community)\n"
8429 "community number\n"
8430 "Do not send outside local AS (well-known community)\n"
8431 "Do not advertise to any peer (well-known community)\n"
8432 "Do not export to next AS (well-known community)\n"
8433 "Exact match of the communities")
8435 ALIAS (show_bgp_community_exact
,
8436 show_bgp_community4_exact_cmd
,
8437 "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",
8440 "Display routes matching the communities\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 "community number\n"
8450 "Do not send outside local AS (well-known community)\n"
8451 "Do not advertise to any peer (well-known community)\n"
8452 "Do not export to next AS (well-known community)\n"
8453 "community number\n"
8454 "Do not send outside local AS (well-known community)\n"
8455 "Do not advertise to any peer (well-known community)\n"
8456 "Do not export to next AS (well-known community)\n"
8457 "Exact match of the communities")
8459 ALIAS (show_bgp_community_exact
,
8460 show_bgp_ipv6_community4_exact_cmd
,
8461 "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",
8465 "Display routes matching the communities\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 "community number\n"
8475 "Do not send outside local AS (well-known community)\n"
8476 "Do not advertise to any peer (well-known community)\n"
8477 "Do not export to next AS (well-known community)\n"
8478 "community number\n"
8479 "Do not send outside local AS (well-known community)\n"
8480 "Do not advertise to any peer (well-known community)\n"
8481 "Do not export to next AS (well-known community)\n"
8482 "Exact match of the communities")
8485 DEFUN (show_ipv6_bgp_community_exact
,
8486 show_ipv6_bgp_community_exact_cmd
,
8487 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8491 "Display routes matching the communities\n"
8492 "community number\n"
8493 "Do not send outside local AS (well-known community)\n"
8494 "Do not advertise to any peer (well-known community)\n"
8495 "Do not export to next AS (well-known community)\n"
8496 "Exact match of the communities")
8498 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
8502 ALIAS (show_ipv6_bgp_community_exact
,
8503 show_ipv6_bgp_community2_exact_cmd
,
8504 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8508 "Display routes matching the communities\n"
8509 "community number\n"
8510 "Do not send outside local AS (well-known community)\n"
8511 "Do not advertise to any peer (well-known community)\n"
8512 "Do not export to next AS (well-known community)\n"
8513 "community number\n"
8514 "Do not send outside local AS (well-known community)\n"
8515 "Do not advertise to any peer (well-known community)\n"
8516 "Do not export to next AS (well-known community)\n"
8517 "Exact match of the communities")
8520 ALIAS (show_ipv6_bgp_community_exact
,
8521 show_ipv6_bgp_community3_exact_cmd
,
8522 "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",
8526 "Display routes matching the communities\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 "community number\n"
8532 "Do not send outside local AS (well-known community)\n"
8533 "Do not advertise to any peer (well-known community)\n"
8534 "Do not export to next AS (well-known community)\n"
8535 "community number\n"
8536 "Do not send outside local AS (well-known community)\n"
8537 "Do not advertise to any peer (well-known community)\n"
8538 "Do not export to next AS (well-known community)\n"
8539 "Exact match of the communities")
8542 ALIAS (show_ipv6_bgp_community_exact
,
8543 show_ipv6_bgp_community4_exact_cmd
,
8544 "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",
8548 "Display routes matching the communities\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 "community number\n"
8558 "Do not send outside local AS (well-known community)\n"
8559 "Do not advertise to any peer (well-known community)\n"
8560 "Do not export to next AS (well-known community)\n"
8561 "community number\n"
8562 "Do not send outside local AS (well-known community)\n"
8563 "Do not advertise to any peer (well-known community)\n"
8564 "Do not export to next AS (well-known community)\n"
8565 "Exact match of the communities")
8568 DEFUN (show_ipv6_mbgp_community
,
8569 show_ipv6_mbgp_community_cmd
,
8570 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
8574 "Display routes matching the communities\n"
8575 "community number\n"
8576 "Do not send outside local AS (well-known community)\n"
8577 "Do not advertise to any peer (well-known community)\n"
8578 "Do not export to next AS (well-known community)\n")
8580 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
8584 ALIAS (show_ipv6_mbgp_community
,
8585 show_ipv6_mbgp_community2_cmd
,
8586 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8590 "Display routes matching the communities\n"
8591 "community number\n"
8592 "Do not send outside local AS (well-known community)\n"
8593 "Do not advertise to any peer (well-known community)\n"
8594 "Do not export to next AS (well-known community)\n"
8595 "community number\n"
8596 "Do not send outside local AS (well-known community)\n"
8597 "Do not advertise to any peer (well-known community)\n"
8598 "Do not export to next AS (well-known community)\n")
8601 ALIAS (show_ipv6_mbgp_community
,
8602 show_ipv6_mbgp_community3_cmd
,
8603 "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)",
8607 "Display routes matching the communities\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"
8612 "community number\n"
8613 "Do not send outside local AS (well-known community)\n"
8614 "Do not advertise to any peer (well-known community)\n"
8615 "Do not export to next AS (well-known community)\n"
8616 "community number\n"
8617 "Do not send outside local AS (well-known community)\n"
8618 "Do not advertise to any peer (well-known community)\n"
8619 "Do not export to next AS (well-known community)\n")
8622 ALIAS (show_ipv6_mbgp_community
,
8623 show_ipv6_mbgp_community4_cmd
,
8624 "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)",
8628 "Display routes matching the communities\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"
8637 "community number\n"
8638 "Do not send outside local AS (well-known community)\n"
8639 "Do not advertise to any peer (well-known community)\n"
8640 "Do not export to next AS (well-known community)\n"
8641 "community number\n"
8642 "Do not send outside local AS (well-known community)\n"
8643 "Do not advertise to any peer (well-known community)\n"
8644 "Do not export to next AS (well-known community)\n")
8647 DEFUN (show_ipv6_mbgp_community_exact
,
8648 show_ipv6_mbgp_community_exact_cmd
,
8649 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8653 "Display routes matching the communities\n"
8654 "community number\n"
8655 "Do not send outside local AS (well-known community)\n"
8656 "Do not advertise to any peer (well-known community)\n"
8657 "Do not export to next AS (well-known community)\n"
8658 "Exact match of the communities")
8660 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
8664 ALIAS (show_ipv6_mbgp_community_exact
,
8665 show_ipv6_mbgp_community2_exact_cmd
,
8666 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8670 "Display routes matching the communities\n"
8671 "community number\n"
8672 "Do not send outside local AS (well-known community)\n"
8673 "Do not advertise to any peer (well-known community)\n"
8674 "Do not export to next AS (well-known community)\n"
8675 "community number\n"
8676 "Do not send outside local AS (well-known community)\n"
8677 "Do not advertise to any peer (well-known community)\n"
8678 "Do not export to next AS (well-known community)\n"
8679 "Exact match of the communities")
8682 ALIAS (show_ipv6_mbgp_community_exact
,
8683 show_ipv6_mbgp_community3_exact_cmd
,
8684 "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",
8688 "Display routes matching the communities\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 "community number\n"
8694 "Do not send outside local AS (well-known community)\n"
8695 "Do not advertise to any peer (well-known community)\n"
8696 "Do not export to next AS (well-known community)\n"
8697 "community number\n"
8698 "Do not send outside local AS (well-known community)\n"
8699 "Do not advertise to any peer (well-known community)\n"
8700 "Do not export to next AS (well-known community)\n"
8701 "Exact match of the communities")
8704 ALIAS (show_ipv6_mbgp_community_exact
,
8705 show_ipv6_mbgp_community4_exact_cmd
,
8706 "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",
8710 "Display routes matching the communities\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 "community number\n"
8720 "Do not send outside local AS (well-known community)\n"
8721 "Do not advertise to any peer (well-known community)\n"
8722 "Do not export to next AS (well-known community)\n"
8723 "community number\n"
8724 "Do not send outside local AS (well-known community)\n"
8725 "Do not advertise to any peer (well-known community)\n"
8726 "Do not export to next AS (well-known community)\n"
8727 "Exact match of the communities")
8728 #endif /* HAVE_IPV6 */
8731 bgp_show_community_list (struct vty
*vty
, const char *com
, int exact
,
8732 afi_t afi
, safi_t safi
)
8734 struct community_list
*list
;
8736 list
= community_list_lookup (bgp_clist
, com
, COMMUNITY_LIST_MASTER
);
8739 vty_out (vty
, "%% %s is not a valid community-list name%s", com
,
8744 return bgp_show (vty
, NULL
, afi
, safi
,
8745 (exact
? bgp_show_type_community_list_exact
:
8746 bgp_show_type_community_list
), list
);
8749 DEFUN (show_ip_bgp_community_list
,
8750 show_ip_bgp_community_list_cmd
,
8751 "show ip bgp community-list (<1-500>|WORD)",
8755 "Display routes matching the community-list\n"
8756 "community-list number\n"
8757 "community-list name\n")
8759 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP
, SAFI_UNICAST
);
8762 DEFUN (show_ip_bgp_ipv4_community_list
,
8763 show_ip_bgp_ipv4_community_list_cmd
,
8764 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
8769 "Address Family modifier\n"
8770 "Address Family modifier\n"
8771 "Display routes matching the community-list\n"
8772 "community-list number\n"
8773 "community-list name\n")
8775 if (strncmp (argv
[0], "m", 1) == 0)
8776 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_MULTICAST
);
8778 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_UNICAST
);
8781 DEFUN (show_ip_bgp_community_list_exact
,
8782 show_ip_bgp_community_list_exact_cmd
,
8783 "show ip bgp community-list (<1-500>|WORD) exact-match",
8787 "Display routes matching the community-list\n"
8788 "community-list number\n"
8789 "community-list name\n"
8790 "Exact match of the communities\n")
8792 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP
, SAFI_UNICAST
);
8795 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
8796 show_ip_bgp_ipv4_community_list_exact_cmd
,
8797 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
8802 "Address Family modifier\n"
8803 "Address Family modifier\n"
8804 "Display routes matching the community-list\n"
8805 "community-list number\n"
8806 "community-list name\n"
8807 "Exact match of the communities\n")
8809 if (strncmp (argv
[0], "m", 1) == 0)
8810 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_MULTICAST
);
8812 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_UNICAST
);
8816 DEFUN (show_bgp_community_list
,
8817 show_bgp_community_list_cmd
,
8818 "show bgp community-list (<1-500>|WORD)",
8821 "Display routes matching the community-list\n"
8822 "community-list number\n"
8823 "community-list name\n")
8825 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
8828 ALIAS (show_bgp_community_list
,
8829 show_bgp_ipv6_community_list_cmd
,
8830 "show bgp ipv6 community-list (<1-500>|WORD)",
8834 "Display routes matching the community-list\n"
8835 "community-list number\n"
8836 "community-list name\n")
8839 DEFUN (show_ipv6_bgp_community_list
,
8840 show_ipv6_bgp_community_list_cmd
,
8841 "show ipv6 bgp community-list WORD",
8845 "Display routes matching the community-list\n"
8846 "community-list name\n")
8848 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
8852 DEFUN (show_ipv6_mbgp_community_list
,
8853 show_ipv6_mbgp_community_list_cmd
,
8854 "show ipv6 mbgp community-list WORD",
8858 "Display routes matching the community-list\n"
8859 "community-list name\n")
8861 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_MULTICAST
);
8864 DEFUN (show_bgp_community_list_exact
,
8865 show_bgp_community_list_exact_cmd
,
8866 "show bgp community-list (<1-500>|WORD) exact-match",
8869 "Display routes matching the community-list\n"
8870 "community-list number\n"
8871 "community-list name\n"
8872 "Exact match of the communities\n")
8874 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
8877 ALIAS (show_bgp_community_list_exact
,
8878 show_bgp_ipv6_community_list_exact_cmd
,
8879 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
8883 "Display routes matching the community-list\n"
8884 "community-list number\n"
8885 "community-list name\n"
8886 "Exact match of the communities\n")
8889 DEFUN (show_ipv6_bgp_community_list_exact
,
8890 show_ipv6_bgp_community_list_exact_cmd
,
8891 "show ipv6 bgp community-list WORD exact-match",
8895 "Display routes matching the community-list\n"
8896 "community-list name\n"
8897 "Exact match of the communities\n")
8899 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
8903 DEFUN (show_ipv6_mbgp_community_list_exact
,
8904 show_ipv6_mbgp_community_list_exact_cmd
,
8905 "show ipv6 mbgp community-list WORD exact-match",
8909 "Display routes matching the community-list\n"
8910 "community-list name\n"
8911 "Exact match of the communities\n")
8913 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_MULTICAST
);
8915 #endif /* HAVE_IPV6 */
8918 bgp_show_prefix_longer (struct vty
*vty
, const char *prefix
, afi_t afi
,
8919 safi_t safi
, enum bgp_show_type type
)
8926 ret
= str2prefix (prefix
, p
);
8929 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
8933 ret
= bgp_show (vty
, NULL
, afi
, safi
, type
, p
);
8938 DEFUN (show_ip_bgp_prefix_longer
,
8939 show_ip_bgp_prefix_longer_cmd
,
8940 "show ip bgp A.B.C.D/M longer-prefixes",
8944 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8945 "Display route and more specific routes\n")
8947 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8948 bgp_show_type_prefix_longer
);
8951 DEFUN (show_ip_bgp_flap_prefix_longer
,
8952 show_ip_bgp_flap_prefix_longer_cmd
,
8953 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
8957 "Display flap statistics of routes\n"
8958 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8959 "Display route and more specific routes\n")
8961 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8962 bgp_show_type_flap_prefix_longer
);
8965 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
8966 show_ip_bgp_ipv4_prefix_longer_cmd
,
8967 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
8972 "Address Family modifier\n"
8973 "Address Family modifier\n"
8974 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8975 "Display route and more specific routes\n")
8977 if (strncmp (argv
[0], "m", 1) == 0)
8978 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
8979 bgp_show_type_prefix_longer
);
8981 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
8982 bgp_show_type_prefix_longer
);
8985 DEFUN (show_ip_bgp_flap_address
,
8986 show_ip_bgp_flap_address_cmd
,
8987 "show ip bgp flap-statistics A.B.C.D",
8991 "Display flap statistics of routes\n"
8992 "Network in the BGP routing table to display\n")
8994 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8995 bgp_show_type_flap_address
);
8998 DEFUN (show_ip_bgp_flap_prefix
,
8999 show_ip_bgp_flap_prefix_cmd
,
9000 "show ip bgp flap-statistics A.B.C.D/M",
9004 "Display flap statistics of routes\n"
9005 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
9007 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9008 bgp_show_type_flap_prefix
);
9011 DEFUN (show_bgp_prefix_longer
,
9012 show_bgp_prefix_longer_cmd
,
9013 "show bgp X:X::X:X/M longer-prefixes",
9016 "IPv6 prefix <network>/<length>\n"
9017 "Display route and more specific routes\n")
9019 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9020 bgp_show_type_prefix_longer
);
9023 ALIAS (show_bgp_prefix_longer
,
9024 show_bgp_ipv6_prefix_longer_cmd
,
9025 "show bgp ipv6 X:X::X:X/M longer-prefixes",
9029 "IPv6 prefix <network>/<length>\n"
9030 "Display route and more specific routes\n")
9033 DEFUN (show_ipv6_bgp_prefix_longer
,
9034 show_ipv6_bgp_prefix_longer_cmd
,
9035 "show ipv6 bgp X:X::X:X/M longer-prefixes",
9039 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
9040 "Display route and more specific routes\n")
9042 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9043 bgp_show_type_prefix_longer
);
9047 DEFUN (show_ipv6_mbgp_prefix_longer
,
9048 show_ipv6_mbgp_prefix_longer_cmd
,
9049 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
9053 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
9054 "Display route and more specific routes\n")
9056 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
9057 bgp_show_type_prefix_longer
);
9059 #endif /* HAVE_IPV6 */
9061 static struct peer
*
9062 peer_lookup_in_view (struct vty
*vty
, const char *view_name
,
9070 /* BGP structure lookup. */
9073 bgp
= bgp_lookup_by_name (view_name
);
9076 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
9082 bgp
= bgp_get_default ();
9085 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
9090 /* Get peer sockunion. */
9091 ret
= str2sockunion (ip_str
, &su
);
9094 vty_out (vty
, "Malformed address: %s%s", ip_str
, VTY_NEWLINE
);
9098 /* Peer structure lookup. */
9099 peer
= peer_lookup (bgp
, &su
);
9102 vty_out (vty
, "No such neighbor%s", VTY_NEWLINE
);
9111 BGP_STATS_MAXBITLEN
= 0,
9115 BGP_STATS_UNAGGREGATEABLE
,
9116 BGP_STATS_MAX_AGGREGATEABLE
,
9117 BGP_STATS_AGGREGATES
,
9119 BGP_STATS_ASPATH_COUNT
,
9120 BGP_STATS_ASPATH_MAXHOPS
,
9121 BGP_STATS_ASPATH_TOTHOPS
,
9122 BGP_STATS_ASPATH_MAXSIZE
,
9123 BGP_STATS_ASPATH_TOTSIZE
,
9124 BGP_STATS_ASN_HIGHEST
,
9128 static const char *table_stats_strs
[] =
9130 [BGP_STATS_PREFIXES
] = "Total Prefixes",
9131 [BGP_STATS_TOTPLEN
] = "Average prefix length",
9132 [BGP_STATS_RIB
] = "Total Advertisements",
9133 [BGP_STATS_UNAGGREGATEABLE
] = "Unaggregateable prefixes",
9134 [BGP_STATS_MAX_AGGREGATEABLE
] = "Maximum aggregateable prefixes",
9135 [BGP_STATS_AGGREGATES
] = "BGP Aggregate advertisements",
9136 [BGP_STATS_SPACE
] = "Address space advertised",
9137 [BGP_STATS_ASPATH_COUNT
] = "Advertisements with paths",
9138 [BGP_STATS_ASPATH_MAXHOPS
] = "Longest AS-Path (hops)",
9139 [BGP_STATS_ASPATH_MAXSIZE
] = "Largest AS-Path (bytes)",
9140 [BGP_STATS_ASPATH_TOTHOPS
] = "Average AS-Path length (hops)",
9141 [BGP_STATS_ASPATH_TOTSIZE
] = "Average AS-Path size (bytes)",
9142 [BGP_STATS_ASN_HIGHEST
] = "Highest public ASN",
9143 [BGP_STATS_MAX
] = NULL
,
9146 struct bgp_table_stats
9148 struct bgp_table
*table
;
9149 unsigned long long counts
[BGP_STATS_MAX
];
9153 #define TALLY_SIGFIG 100000
9154 static unsigned long
9155 ravg_tally (unsigned long count
, unsigned long oldavg
, unsigned long newval
)
9157 unsigned long newtot
= (count
-1) * oldavg
+ (newval
* TALLY_SIGFIG
);
9158 unsigned long res
= (newtot
* TALLY_SIGFIG
) / count
;
9159 unsigned long ret
= newtot
/ count
;
9161 if ((res
% TALLY_SIGFIG
) > (TALLY_SIGFIG
/2))
9169 bgp_table_stats_walker (struct thread
*t
)
9171 struct bgp_node
*rn
;
9172 struct bgp_node
*top
;
9173 struct bgp_table_stats
*ts
= THREAD_ARG (t
);
9174 unsigned int space
= 0;
9176 if (!(top
= bgp_table_top (ts
->table
)))
9179 switch (top
->p
.family
)
9182 space
= IPV4_MAX_BITLEN
;
9185 space
= IPV6_MAX_BITLEN
;
9189 ts
->counts
[BGP_STATS_MAXBITLEN
] = space
;
9191 for (rn
= top
; rn
; rn
= bgp_route_next (rn
))
9193 struct bgp_info
*ri
;
9194 struct bgp_node
*prn
= rn
->parent
;
9195 unsigned int rinum
= 0;
9203 ts
->counts
[BGP_STATS_PREFIXES
]++;
9204 ts
->counts
[BGP_STATS_TOTPLEN
] += rn
->p
.prefixlen
;
9207 ts
->counts
[BGP_STATS_AVGPLEN
]
9208 = ravg_tally (ts
->counts
[BGP_STATS_PREFIXES
],
9209 ts
->counts
[BGP_STATS_AVGPLEN
],
9213 /* check if the prefix is included by any other announcements */
9214 while (prn
&& !prn
->info
)
9217 if (prn
== NULL
|| prn
== top
)
9219 ts
->counts
[BGP_STATS_UNAGGREGATEABLE
]++;
9220 /* announced address space */
9222 ts
->counts
[BGP_STATS_SPACE
] += 1 << (space
- rn
->p
.prefixlen
);
9225 ts
->counts
[BGP_STATS_MAX_AGGREGATEABLE
]++;
9227 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
9230 ts
->counts
[BGP_STATS_RIB
]++;
9233 (CHECK_FLAG (ri
->attr
->flag
,
9234 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
))))
9235 ts
->counts
[BGP_STATS_AGGREGATES
]++;
9238 if (ri
->attr
&& ri
->attr
->aspath
)
9240 unsigned int hops
= aspath_count_hops (ri
->attr
->aspath
);
9241 unsigned int size
= aspath_size (ri
->attr
->aspath
);
9242 as_t highest
= aspath_highest (ri
->attr
->aspath
);
9244 ts
->counts
[BGP_STATS_ASPATH_COUNT
]++;
9246 if (hops
> ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
])
9247 ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
] = hops
;
9249 if (size
> ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
])
9250 ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
] = size
;
9252 ts
->counts
[BGP_STATS_ASPATH_TOTHOPS
] += hops
;
9253 ts
->counts
[BGP_STATS_ASPATH_TOTSIZE
] += size
;
9255 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
]
9256 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
9257 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
],
9259 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
]
9260 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
9261 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
],
9264 if (highest
> ts
->counts
[BGP_STATS_ASN_HIGHEST
])
9265 ts
->counts
[BGP_STATS_ASN_HIGHEST
] = highest
;
9273 bgp_table_stats (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
)
9275 struct bgp_table_stats ts
;
9278 if (!bgp
->rib
[afi
][safi
])
9280 vty_out (vty
, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE
);
9284 memset (&ts
, 0, sizeof (ts
));
9285 ts
.table
= bgp
->rib
[afi
][safi
];
9286 thread_execute (bm
->master
, bgp_table_stats_walker
, &ts
, 0);
9288 vty_out (vty
, "BGP %s RIB statistics%s%s",
9289 afi_safi_print (afi
, safi
), VTY_NEWLINE
, VTY_NEWLINE
);
9291 for (i
= 0; i
< BGP_STATS_MAX
; i
++)
9293 if (!table_stats_strs
[i
])
9299 case BGP_STATS_ASPATH_AVGHOPS
:
9300 case BGP_STATS_ASPATH_AVGSIZE
:
9301 case BGP_STATS_AVGPLEN
:
9302 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9303 vty_out (vty
, "%12.2f",
9304 (float)ts
.counts
[i
] / (float)TALLY_SIGFIG
);
9307 case BGP_STATS_ASPATH_TOTHOPS
:
9308 case BGP_STATS_ASPATH_TOTSIZE
:
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_ASPATH_COUNT
]
9316 case BGP_STATS_TOTPLEN
:
9317 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9318 vty_out (vty
, "%12.2f",
9320 (float)ts
.counts
[i
] /
9321 (float)ts
.counts
[BGP_STATS_PREFIXES
]
9324 case BGP_STATS_SPACE
:
9325 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9326 vty_out (vty
, "%12llu%s", ts
.counts
[i
], VTY_NEWLINE
);
9327 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 9)
9329 vty_out (vty
, "%30s: ", "%% announced ");
9330 vty_out (vty
, "%12.2f%s",
9331 100 * (float)ts
.counts
[BGP_STATS_SPACE
] /
9332 (float)((uint64_t)1UL << ts
.counts
[BGP_STATS_MAXBITLEN
]),
9334 vty_out (vty
, "%30s: ", "/8 equivalent ");
9335 vty_out (vty
, "%12.2f%s",
9336 (float)ts
.counts
[BGP_STATS_SPACE
] /
9337 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 8)),
9339 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 25)
9341 vty_out (vty
, "%30s: ", "/24 equivalent ");
9342 vty_out (vty
, "%12.2f",
9343 (float)ts
.counts
[BGP_STATS_SPACE
] /
9344 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 24)));
9347 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9348 vty_out (vty
, "%12llu", ts
.counts
[i
]);
9351 vty_out (vty
, "%s", VTY_NEWLINE
);
9357 bgp_table_stats_vty (struct vty
*vty
, const char *name
,
9358 const char *afi_str
, const char *safi_str
)
9365 bgp
= bgp_lookup_by_name (name
);
9367 bgp
= bgp_get_default ();
9371 vty_out (vty
, "%% No such BGP instance exist%s", VTY_NEWLINE
);
9374 if (strncmp (afi_str
, "ipv", 3) == 0)
9376 if (strncmp (afi_str
, "ipv4", 4) == 0)
9378 else if (strncmp (afi_str
, "ipv6", 4) == 0)
9382 vty_out (vty
, "%% Invalid address family %s%s",
9383 afi_str
, VTY_NEWLINE
);
9386 if (strncmp (safi_str
, "m", 1) == 0)
9387 safi
= SAFI_MULTICAST
;
9388 else if (strncmp (safi_str
, "u", 1) == 0)
9389 safi
= SAFI_UNICAST
;
9390 else if (strncmp (safi_str
, "vpnv4", 5) == 0 || strncmp (safi_str
, "vpnv6", 5) == 0)
9391 safi
= SAFI_MPLS_LABELED_VPN
;
9394 vty_out (vty
, "%% Invalid subsequent address family %s%s",
9395 safi_str
, VTY_NEWLINE
);
9401 vty_out (vty
, "%% Invalid address family %s%s",
9402 afi_str
, VTY_NEWLINE
);
9406 return bgp_table_stats (vty
, bgp
, afi
, safi
);
9409 DEFUN (show_bgp_statistics
,
9410 show_bgp_statistics_cmd
,
9411 "show bgp (ipv4|ipv6) (unicast|multicast) statistics",
9416 "Address Family modifier\n"
9417 "Address Family modifier\n"
9418 "BGP RIB advertisement statistics\n")
9420 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
9423 ALIAS (show_bgp_statistics
,
9424 show_bgp_statistics_vpnv4_cmd
,
9425 "show bgp (ipv4) (vpnv4) statistics",
9429 "Address Family modifier\n"
9430 "BGP RIB advertisement statistics\n")
9432 DEFUN (show_bgp_statistics_view
,
9433 show_bgp_statistics_view_cmd
,
9434 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics",
9440 "Address Family modifier\n"
9441 "Address Family modifier\n"
9442 "BGP RIB advertisement statistics\n")
9444 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
9447 ALIAS (show_bgp_statistics_view
,
9448 show_bgp_statistics_view_vpnv4_cmd
,
9449 "show bgp view WORD (ipv4) (vpnv4) statistics",
9454 "Address Family modifier\n"
9455 "BGP RIB advertisement statistics\n")
9467 PCOUNT_PFCNT
, /* the figure we display to users */
9471 static const char *pcount_strs
[] =
9473 [PCOUNT_ADJ_IN
] = "Adj-in",
9474 [PCOUNT_DAMPED
] = "Damped",
9475 [PCOUNT_REMOVED
] = "Removed",
9476 [PCOUNT_HISTORY
] = "History",
9477 [PCOUNT_STALE
] = "Stale",
9478 [PCOUNT_VALID
] = "Valid",
9479 [PCOUNT_ALL
] = "All RIB",
9480 [PCOUNT_COUNTED
] = "PfxCt counted",
9481 [PCOUNT_PFCNT
] = "Useable",
9482 [PCOUNT_MAX
] = NULL
,
9487 unsigned int count
[PCOUNT_MAX
];
9488 const struct peer
*peer
;
9489 const struct bgp_table
*table
;
9493 bgp_peer_count_walker (struct thread
*t
)
9495 struct bgp_node
*rn
;
9496 struct peer_pcounts
*pc
= THREAD_ARG (t
);
9497 const struct peer
*peer
= pc
->peer
;
9499 for (rn
= bgp_table_top (pc
->table
); rn
; rn
= bgp_route_next (rn
))
9501 struct bgp_adj_in
*ain
;
9502 struct bgp_info
*ri
;
9504 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
9505 if (ain
->peer
== peer
)
9506 pc
->count
[PCOUNT_ADJ_IN
]++;
9508 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
9510 char buf
[SU_ADDRSTRLEN
];
9512 if (ri
->peer
!= peer
)
9515 pc
->count
[PCOUNT_ALL
]++;
9517 if (CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
))
9518 pc
->count
[PCOUNT_DAMPED
]++;
9519 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
9520 pc
->count
[PCOUNT_HISTORY
]++;
9521 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
9522 pc
->count
[PCOUNT_REMOVED
]++;
9523 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
9524 pc
->count
[PCOUNT_STALE
]++;
9525 if (CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
))
9526 pc
->count
[PCOUNT_VALID
]++;
9527 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9528 pc
->count
[PCOUNT_PFCNT
]++;
9530 if (CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
9532 pc
->count
[PCOUNT_COUNTED
]++;
9533 if (CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9534 plog_warn (peer
->log
,
9535 "%s [pcount] %s/%d is counted but flags 0x%x",
9537 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
9538 buf
, SU_ADDRSTRLEN
),
9544 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9545 plog_warn (peer
->log
,
9546 "%s [pcount] %s/%d not counted but flags 0x%x",
9548 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
9549 buf
, SU_ADDRSTRLEN
),
9559 bgp_peer_counts (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
)
9561 struct peer_pcounts pcounts
= { .peer
= peer
};
9564 if (!peer
|| !peer
->bgp
|| !peer
->afc
[afi
][safi
]
9565 || !peer
->bgp
->rib
[afi
][safi
])
9567 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
9571 memset (&pcounts
, 0, sizeof(pcounts
));
9572 pcounts
.peer
= peer
;
9573 pcounts
.table
= peer
->bgp
->rib
[afi
][safi
];
9575 /* in-place call via thread subsystem so as to record execution time
9576 * stats for the thread-walk (i.e. ensure this can't be blamed on
9577 * on just vty_read()).
9579 thread_execute (bm
->master
, bgp_peer_count_walker
, &pcounts
, 0);
9581 vty_out (vty
, "Prefix counts for %s, %s%s",
9582 peer
->host
, afi_safi_print (afi
, safi
), VTY_NEWLINE
);
9583 vty_out (vty
, "PfxCt: %ld%s", peer
->pcount
[afi
][safi
], VTY_NEWLINE
);
9584 vty_out (vty
, "%sCounts from RIB table walk:%s%s",
9585 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
9587 for (i
= 0; i
< PCOUNT_MAX
; i
++)
9588 vty_out (vty
, "%20s: %-10d%s",
9589 pcount_strs
[i
], pcounts
.count
[i
], VTY_NEWLINE
);
9591 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
9593 vty_out (vty
, "%s [pcount] PfxCt drift!%s",
9594 peer
->host
, VTY_NEWLINE
);
9595 vty_out (vty
, "Please report this bug, with the above command output%s",
9602 DEFUN (show_ip_bgp_neighbor_prefix_counts
,
9603 show_ip_bgp_neighbor_prefix_counts_cmd
,
9604 "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9608 "Detailed information on TCP and BGP neighbor connections\n"
9609 "Neighbor to display information about\n"
9610 "Neighbor to display information about\n"
9611 "Display detailed prefix count information\n")
9615 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9619 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
);
9622 DEFUN (show_bgp_ipv6_neighbor_prefix_counts
,
9623 show_bgp_ipv6_neighbor_prefix_counts_cmd
,
9624 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9628 "Detailed information on TCP and BGP neighbor connections\n"
9629 "Neighbor to display information about\n"
9630 "Neighbor to display information about\n"
9631 "Display detailed prefix count information\n")
9635 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9639 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
);
9642 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts
,
9643 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
,
9644 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9649 "Address Family modifier\n"
9650 "Address Family modifier\n"
9651 "Detailed information on TCP and BGP neighbor connections\n"
9652 "Neighbor to display information about\n"
9653 "Neighbor to display information about\n"
9654 "Display detailed prefix count information\n")
9658 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9662 if (strncmp (argv
[0], "m", 1) == 0)
9663 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MULTICAST
);
9665 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
);
9668 DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts
,
9669 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
,
9670 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9675 "Address Family modifier\n"
9676 "Address Family modifier\n"
9677 "Detailed information on TCP and BGP neighbor connections\n"
9678 "Neighbor to display information about\n"
9679 "Neighbor to display information about\n"
9680 "Display detailed prefix count information\n")
9684 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9688 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MPLS_VPN
);
9693 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
9696 struct bgp_table
*table
;
9697 struct bgp_adj_in
*ain
;
9698 struct bgp_adj_out
*adj
;
9699 unsigned long output_count
;
9700 struct bgp_node
*rn
;
9710 table
= bgp
->rib
[afi
][safi
];
9714 if (! in
&& CHECK_FLAG (peer
->af_sflags
[afi
][safi
],
9715 PEER_STATUS_DEFAULT_ORIGINATE
))
9717 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9718 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9719 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9721 vty_out (vty
, "Originating default network 0.0.0.0%s%s",
9722 VTY_NEWLINE
, VTY_NEWLINE
);
9726 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
9729 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
9730 if (ain
->peer
== peer
)
9734 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9735 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9736 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9741 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
9746 route_vty_out_tmp (vty
, &rn
->p
, ain
->attr
, safi
);
9753 for (adj
= rn
->adj_out
; adj
; adj
= adj
->next
)
9754 if (adj
->peer
== peer
)
9758 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9759 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9760 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9765 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
9770 route_vty_out_tmp (vty
, &rn
->p
, adj
->attr
, safi
);
9776 if (output_count
!= 0)
9777 vty_out (vty
, "%sTotal number of prefixes %ld%s",
9778 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
9782 peer_adj_routes (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
, int in
)
9784 if (! peer
|| ! peer
->afc
[afi
][safi
])
9786 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
9790 if (in
&& ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
9792 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s",
9797 show_adj_route (vty
, peer
, afi
, safi
, in
);
9802 DEFUN (show_ip_bgp_view_neighbor_advertised_route
,
9803 show_ip_bgp_view_neighbor_advertised_route_cmd
,
9804 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9810 "Detailed information on TCP and BGP neighbor connections\n"
9811 "Neighbor to display information about\n"
9812 "Neighbor to display information about\n"
9813 "Display the routes advertised to a BGP neighbor\n")
9818 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9820 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9825 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0);
9828 ALIAS (show_ip_bgp_view_neighbor_advertised_route
,
9829 show_ip_bgp_neighbor_advertised_route_cmd
,
9830 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9834 "Detailed information on TCP and BGP neighbor connections\n"
9835 "Neighbor to display information about\n"
9836 "Neighbor to display information about\n"
9837 "Display the routes advertised to a BGP neighbor\n")
9839 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
9840 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
9841 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9846 "Address Family modifier\n"
9847 "Address Family modifier\n"
9848 "Detailed information on TCP and BGP neighbor connections\n"
9849 "Neighbor to display information about\n"
9850 "Neighbor to display information about\n"
9851 "Display the routes advertised to a BGP neighbor\n")
9855 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9859 if (strncmp (argv
[0], "m", 1) == 0)
9860 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 0);
9862 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0);
9866 DEFUN (show_bgp_view_neighbor_advertised_route
,
9867 show_bgp_view_neighbor_advertised_route_cmd
,
9868 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9873 "Detailed information on TCP and BGP neighbor connections\n"
9874 "Neighbor to display information about\n"
9875 "Neighbor to display information about\n"
9876 "Display the routes advertised to a BGP neighbor\n")
9881 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9883 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9888 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0);
9891 ALIAS (show_bgp_view_neighbor_advertised_route
,
9892 show_bgp_view_ipv6_neighbor_advertised_route_cmd
,
9893 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9899 "Detailed information on TCP and BGP neighbor connections\n"
9900 "Neighbor to display information about\n"
9901 "Neighbor to display information about\n"
9902 "Display the routes advertised to a BGP neighbor\n")
9904 DEFUN (show_bgp_view_neighbor_received_routes
,
9905 show_bgp_view_neighbor_received_routes_cmd
,
9906 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
9911 "Detailed information on TCP and BGP neighbor connections\n"
9912 "Neighbor to display information about\n"
9913 "Neighbor to display information about\n"
9914 "Display the received routes from neighbor\n")
9919 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9921 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9926 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1);
9929 ALIAS (show_bgp_view_neighbor_received_routes
,
9930 show_bgp_view_ipv6_neighbor_received_routes_cmd
,
9931 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
9937 "Detailed information on TCP and BGP neighbor connections\n"
9938 "Neighbor to display information about\n"
9939 "Neighbor to display information about\n"
9940 "Display the received routes from neighbor\n")
9942 ALIAS (show_bgp_view_neighbor_advertised_route
,
9943 show_bgp_neighbor_advertised_route_cmd
,
9944 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9947 "Detailed information on TCP and BGP neighbor connections\n"
9948 "Neighbor to display information about\n"
9949 "Neighbor to display information about\n"
9950 "Display the routes advertised to a BGP neighbor\n")
9952 ALIAS (show_bgp_view_neighbor_advertised_route
,
9953 show_bgp_ipv6_neighbor_advertised_route_cmd
,
9954 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9958 "Detailed information on TCP and BGP neighbor connections\n"
9959 "Neighbor to display information about\n"
9960 "Neighbor to display information about\n"
9961 "Display the routes advertised to a BGP neighbor\n")
9964 ALIAS (show_bgp_view_neighbor_advertised_route
,
9965 ipv6_bgp_neighbor_advertised_route_cmd
,
9966 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9970 "Detailed information on TCP and BGP neighbor connections\n"
9971 "Neighbor to display information about\n"
9972 "Neighbor to display information about\n"
9973 "Display the routes advertised to a BGP neighbor\n")
9976 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
9977 ipv6_mbgp_neighbor_advertised_route_cmd
,
9978 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9982 "Detailed information on TCP and BGP neighbor connections\n"
9983 "Neighbor to display information about\n"
9984 "Neighbor to display information about\n"
9985 "Display the routes advertised to a BGP neighbor\n")
9989 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9993 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 0);
9995 #endif /* HAVE_IPV6 */
9997 DEFUN (show_ip_bgp_view_neighbor_received_routes
,
9998 show_ip_bgp_view_neighbor_received_routes_cmd
,
9999 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
10005 "Detailed information on TCP and BGP neighbor connections\n"
10006 "Neighbor to display information about\n"
10007 "Neighbor to display information about\n"
10008 "Display the received routes from neighbor\n")
10013 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10015 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10018 return CMD_WARNING
;
10020 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1);
10023 ALIAS (show_ip_bgp_view_neighbor_received_routes
,
10024 show_ip_bgp_neighbor_received_routes_cmd
,
10025 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
10029 "Detailed information on TCP and BGP neighbor connections\n"
10030 "Neighbor to display information about\n"
10031 "Neighbor to display information about\n"
10032 "Display the received routes from neighbor\n")
10034 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
10035 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
10036 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
10041 "Address Family modifier\n"
10042 "Address Family modifier\n"
10043 "Detailed information on TCP and BGP neighbor connections\n"
10044 "Neighbor to display information about\n"
10045 "Neighbor to display information about\n"
10046 "Display the received routes from neighbor\n")
10050 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
10052 return CMD_WARNING
;
10054 if (strncmp (argv
[0], "m", 1) == 0)
10055 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 1);
10057 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1);
10060 DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes
,
10061 show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd
,
10063 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)",
10065 "show bgp view WORD ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)",
10075 "Address family modifier\n"
10076 "Address family modifier\n"
10077 "Detailed information on TCP and BGP neighbor connections\n"
10078 "Neighbor to display information about\n"
10079 "Neighbor to display information about\n"
10080 "Display the advertised routes to neighbor\n"
10081 "Display the received routes from neighbor\n")
10089 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[3]);
10091 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[2]);
10095 return CMD_WARNING
;
10098 afi
= (strncmp (argv
[1], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
10099 safi
= (strncmp (argv
[2], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10100 in
= (strncmp (argv
[4], "r", 1) == 0) ? 1 : 0;
10103 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10104 in
= (strncmp (argv
[3], "r", 1) == 0) ? 1 : 0;
10107 return peer_adj_routes (vty
, peer
, afi
, safi
, in
);
10110 DEFUN (show_ip_bgp_neighbor_received_prefix_filter
,
10111 show_ip_bgp_neighbor_received_prefix_filter_cmd
,
10112 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10116 "Detailed information on TCP and BGP neighbor connections\n"
10117 "Neighbor to display information about\n"
10118 "Neighbor to display information about\n"
10119 "Display information received from a BGP neighbor\n"
10120 "Display the prefixlist filter\n")
10123 union sockunion
*su
;
10127 su
= sockunion_str2su (argv
[0]);
10129 return CMD_WARNING
;
10131 peer
= peer_lookup (NULL
, su
);
10133 return CMD_WARNING
;
10135 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
10136 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
10139 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
10140 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
10143 return CMD_SUCCESS
;
10146 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter
,
10147 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
,
10148 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10153 "Address Family modifier\n"
10154 "Address Family modifier\n"
10155 "Detailed information on TCP and BGP neighbor connections\n"
10156 "Neighbor to display information about\n"
10157 "Neighbor to display information about\n"
10158 "Display information received from a BGP neighbor\n"
10159 "Display the prefixlist filter\n")
10162 union sockunion
*su
;
10166 su
= sockunion_str2su (argv
[1]);
10168 return CMD_WARNING
;
10170 peer
= peer_lookup (NULL
, su
);
10172 return CMD_WARNING
;
10174 if (strncmp (argv
[0], "m", 1) == 0)
10176 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_MULTICAST
);
10177 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
10180 vty_out (vty
, "Address family: IPv4 Multicast%s", VTY_NEWLINE
);
10181 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
10186 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
10187 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
10190 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
10191 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
10195 return CMD_SUCCESS
;
10200 ALIAS (show_bgp_view_neighbor_received_routes
,
10201 show_bgp_neighbor_received_routes_cmd
,
10202 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
10205 "Detailed information on TCP and BGP neighbor connections\n"
10206 "Neighbor to display information about\n"
10207 "Neighbor to display information about\n"
10208 "Display the received routes from neighbor\n")
10210 ALIAS (show_bgp_view_neighbor_received_routes
,
10211 show_bgp_ipv6_neighbor_received_routes_cmd
,
10212 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
10216 "Detailed information on TCP and BGP neighbor connections\n"
10217 "Neighbor to display information about\n"
10218 "Neighbor to display information about\n"
10219 "Display the received routes from neighbor\n")
10221 DEFUN (show_bgp_neighbor_received_prefix_filter
,
10222 show_bgp_neighbor_received_prefix_filter_cmd
,
10223 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10226 "Detailed information on TCP and BGP neighbor connections\n"
10227 "Neighbor to display information about\n"
10228 "Neighbor to display information about\n"
10229 "Display information received from a BGP neighbor\n"
10230 "Display the prefixlist filter\n")
10233 union sockunion
*su
;
10237 su
= sockunion_str2su (argv
[0]);
10239 return CMD_WARNING
;
10241 peer
= peer_lookup (NULL
, su
);
10243 return CMD_WARNING
;
10245 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
10246 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
);
10249 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
10250 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
);
10253 return CMD_SUCCESS
;
10256 ALIAS (show_bgp_neighbor_received_prefix_filter
,
10257 show_bgp_ipv6_neighbor_received_prefix_filter_cmd
,
10258 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10262 "Detailed information on TCP and BGP neighbor connections\n"
10263 "Neighbor to display information about\n"
10264 "Neighbor to display information about\n"
10265 "Display information received from a BGP neighbor\n"
10266 "Display the prefixlist filter\n")
10269 ALIAS (show_bgp_view_neighbor_received_routes
,
10270 ipv6_bgp_neighbor_received_routes_cmd
,
10271 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
10275 "Detailed information on TCP and BGP neighbor connections\n"
10276 "Neighbor to display information about\n"
10277 "Neighbor to display information about\n"
10278 "Display the received routes from neighbor\n")
10281 DEFUN (ipv6_mbgp_neighbor_received_routes
,
10282 ipv6_mbgp_neighbor_received_routes_cmd
,
10283 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
10287 "Detailed information on TCP and BGP neighbor connections\n"
10288 "Neighbor to display information about\n"
10289 "Neighbor to display information about\n"
10290 "Display the received routes from neighbor\n")
10294 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10296 return CMD_WARNING
;
10298 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 1);
10301 DEFUN (show_bgp_view_neighbor_received_prefix_filter
,
10302 show_bgp_view_neighbor_received_prefix_filter_cmd
,
10303 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10308 "Detailed information on TCP and BGP neighbor connections\n"
10309 "Neighbor to display information about\n"
10310 "Neighbor to display information about\n"
10311 "Display information received from a BGP neighbor\n"
10312 "Display the prefixlist filter\n")
10315 union sockunion
*su
;
10320 /* BGP structure lookup. */
10321 bgp
= bgp_lookup_by_name (argv
[0]);
10324 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10325 return CMD_WARNING
;
10328 su
= sockunion_str2su (argv
[1]);
10330 return CMD_WARNING
;
10332 peer
= peer_lookup (bgp
, su
);
10334 return CMD_WARNING
;
10336 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
10337 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
);
10340 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
10341 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
);
10344 return CMD_SUCCESS
;
10347 ALIAS (show_bgp_view_neighbor_received_prefix_filter
,
10348 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
,
10349 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10355 "Detailed information on TCP and BGP neighbor connections\n"
10356 "Neighbor to display information about\n"
10357 "Neighbor to display information about\n"
10358 "Display information received from a BGP neighbor\n"
10359 "Display the prefixlist filter\n")
10360 #endif /* HAVE_IPV6 */
10363 bgp_show_neighbor_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
,
10364 safi_t safi
, enum bgp_show_type type
)
10366 if (! peer
|| ! peer
->afc
[afi
][safi
])
10368 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
10369 return CMD_WARNING
;
10372 return bgp_show (vty
, peer
->bgp
, afi
, safi
, type
, &peer
->su
);
10375 DEFUN (show_ip_bgp_neighbor_routes
,
10376 show_ip_bgp_neighbor_routes_cmd
,
10377 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
10381 "Detailed information on TCP and BGP neighbor connections\n"
10382 "Neighbor to display information about\n"
10383 "Neighbor to display information about\n"
10384 "Display routes learned from neighbor\n")
10388 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10390 return CMD_WARNING
;
10392 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10393 bgp_show_type_neighbor
);
10396 DEFUN (show_ip_bgp_neighbor_flap
,
10397 show_ip_bgp_neighbor_flap_cmd
,
10398 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10402 "Detailed information on TCP and BGP neighbor connections\n"
10403 "Neighbor to display information about\n"
10404 "Neighbor to display information about\n"
10405 "Display flap statistics of the routes learned from neighbor\n")
10409 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10411 return CMD_WARNING
;
10413 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10414 bgp_show_type_flap_neighbor
);
10417 DEFUN (show_ip_bgp_neighbor_damp
,
10418 show_ip_bgp_neighbor_damp_cmd
,
10419 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10423 "Detailed information on TCP and BGP neighbor connections\n"
10424 "Neighbor to display information about\n"
10425 "Neighbor to display information about\n"
10426 "Display the dampened routes received from neighbor\n")
10430 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10432 return CMD_WARNING
;
10434 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10435 bgp_show_type_damp_neighbor
);
10438 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
10439 show_ip_bgp_ipv4_neighbor_routes_cmd
,
10440 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
10445 "Address Family modifier\n"
10446 "Address Family modifier\n"
10447 "Detailed information on TCP and BGP neighbor connections\n"
10448 "Neighbor to display information about\n"
10449 "Neighbor to display information about\n"
10450 "Display routes learned from neighbor\n")
10454 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
10456 return CMD_WARNING
;
10458 if (strncmp (argv
[0], "m", 1) == 0)
10459 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_MULTICAST
,
10460 bgp_show_type_neighbor
);
10462 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10463 bgp_show_type_neighbor
);
10466 DEFUN (show_ip_bgp_view_rsclient
,
10467 show_ip_bgp_view_rsclient_cmd
,
10468 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
10474 "Information about Route Server Client\n"
10477 struct bgp_table
*table
;
10481 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10483 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10486 return CMD_WARNING
;
10488 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
10490 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10492 return CMD_WARNING
;
10495 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
10496 PEER_FLAG_RSERVER_CLIENT
))
10498 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10500 return CMD_WARNING
;
10503 table
= peer
->rib
[AFI_IP
][SAFI_UNICAST
];
10505 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
10508 ALIAS (show_ip_bgp_view_rsclient
,
10509 show_ip_bgp_rsclient_cmd
,
10510 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
10514 "Information about Route Server Client\n"
10517 DEFUN (show_bgp_view_ipv4_safi_rsclient
,
10518 show_bgp_view_ipv4_safi_rsclient_cmd
,
10519 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
10525 "Address Family modifier\n"
10526 "Address Family modifier\n"
10527 "Information about Route Server Client\n"
10530 struct bgp_table
*table
;
10535 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[2]);
10536 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10538 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
10539 safi
= (strncmp (argv
[0], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10543 return CMD_WARNING
;
10545 if (! peer
->afc
[AFI_IP
][safi
])
10547 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10549 return CMD_WARNING
;
10552 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][safi
],
10553 PEER_FLAG_RSERVER_CLIENT
))
10555 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10557 return CMD_WARNING
;
10560 table
= peer
->rib
[AFI_IP
][safi
];
10562 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
10565 ALIAS (show_bgp_view_ipv4_safi_rsclient
,
10566 show_bgp_ipv4_safi_rsclient_cmd
,
10567 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
10571 "Address Family modifier\n"
10572 "Address Family modifier\n"
10573 "Information about Route Server Client\n"
10576 DEFUN (show_ip_bgp_view_rsclient_route
,
10577 show_ip_bgp_view_rsclient_route_cmd
,
10578 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
10584 "Information about Route Server Client\n"
10586 "Network in the BGP routing table to display\n")
10591 /* BGP structure lookup. */
10594 bgp
= bgp_lookup_by_name (argv
[0]);
10597 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10598 return CMD_WARNING
;
10603 bgp
= bgp_get_default ();
10606 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10607 return CMD_WARNING
;
10612 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10614 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10617 return CMD_WARNING
;
10619 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
10621 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10623 return CMD_WARNING
;
10626 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
10627 PEER_FLAG_RSERVER_CLIENT
))
10629 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10631 return CMD_WARNING
;
10634 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][SAFI_UNICAST
],
10635 (argc
== 3) ? argv
[2] : argv
[1],
10636 AFI_IP
, SAFI_UNICAST
, NULL
, 0);
10639 ALIAS (show_ip_bgp_view_rsclient_route
,
10640 show_ip_bgp_rsclient_route_cmd
,
10641 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
10645 "Information about Route Server Client\n"
10647 "Network in the BGP routing table to display\n")
10649 DEFUN (show_bgp_view_ipv4_safi_rsclient_route
,
10650 show_bgp_view_ipv4_safi_rsclient_route_cmd
,
10651 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
10657 "Address Family modifier\n"
10658 "Address Family modifier\n"
10659 "Information about Route Server Client\n"
10661 "Network in the BGP routing table to display\n")
10667 /* BGP structure lookup. */
10670 bgp
= bgp_lookup_by_name (argv
[0]);
10673 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10674 return CMD_WARNING
;
10679 bgp
= bgp_get_default ();
10682 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10683 return CMD_WARNING
;
10688 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[2]);
10689 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10691 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
10692 safi
= (strncmp (argv
[0], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10696 return CMD_WARNING
;
10698 if (! peer
->afc
[AFI_IP
][safi
])
10700 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10702 return CMD_WARNING
;
10705 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][safi
],
10706 PEER_FLAG_RSERVER_CLIENT
))
10708 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10710 return CMD_WARNING
;
10713 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][safi
],
10714 (argc
== 4) ? argv
[3] : argv
[2],
10715 AFI_IP
, safi
, NULL
, 0);
10718 ALIAS (show_bgp_view_ipv4_safi_rsclient_route
,
10719 show_bgp_ipv4_safi_rsclient_route_cmd
,
10720 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
10724 "Address Family modifier\n"
10725 "Address Family modifier\n"
10726 "Information about Route Server Client\n"
10728 "Network in the BGP routing table to display\n")
10730 DEFUN (show_ip_bgp_view_rsclient_prefix
,
10731 show_ip_bgp_view_rsclient_prefix_cmd
,
10732 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
10738 "Information about Route Server Client\n"
10740 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10745 /* BGP structure lookup. */
10748 bgp
= bgp_lookup_by_name (argv
[0]);
10751 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10752 return CMD_WARNING
;
10757 bgp
= bgp_get_default ();
10760 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10761 return CMD_WARNING
;
10766 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10768 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10771 return CMD_WARNING
;
10773 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
10775 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10777 return CMD_WARNING
;
10780 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
10781 PEER_FLAG_RSERVER_CLIENT
))
10783 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10785 return CMD_WARNING
;
10788 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][SAFI_UNICAST
],
10789 (argc
== 3) ? argv
[2] : argv
[1],
10790 AFI_IP
, SAFI_UNICAST
, NULL
, 1);
10793 ALIAS (show_ip_bgp_view_rsclient_prefix
,
10794 show_ip_bgp_rsclient_prefix_cmd
,
10795 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
10799 "Information about Route Server Client\n"
10801 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10803 DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix
,
10804 show_bgp_view_ipv4_safi_rsclient_prefix_cmd
,
10805 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
10811 "Address Family modifier\n"
10812 "Address Family modifier\n"
10813 "Information about Route Server Client\n"
10815 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10821 /* BGP structure lookup. */
10824 bgp
= bgp_lookup_by_name (argv
[0]);
10827 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10828 return CMD_WARNING
;
10833 bgp
= bgp_get_default ();
10836 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10837 return CMD_WARNING
;
10842 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[2]);
10843 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10845 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
10846 safi
= (strncmp (argv
[0], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10850 return CMD_WARNING
;
10852 if (! peer
->afc
[AFI_IP
][safi
])
10854 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10856 return CMD_WARNING
;
10859 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][safi
],
10860 PEER_FLAG_RSERVER_CLIENT
))
10862 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10864 return CMD_WARNING
;
10867 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][safi
],
10868 (argc
== 4) ? argv
[3] : argv
[2],
10869 AFI_IP
, safi
, NULL
, 1);
10872 ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix
,
10873 show_bgp_ipv4_safi_rsclient_prefix_cmd
,
10874 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
10878 "Address Family modifier\n"
10879 "Address Family modifier\n"
10880 "Information about Route Server Client\n"
10882 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10885 DEFUN (show_bgp_view_neighbor_routes
,
10886 show_bgp_view_neighbor_routes_cmd
,
10887 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
10892 "Detailed information on TCP and BGP neighbor connections\n"
10893 "Neighbor to display information about\n"
10894 "Neighbor to display information about\n"
10895 "Display routes learned from neighbor\n")
10900 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10902 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10905 return CMD_WARNING
;
10907 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
10908 bgp_show_type_neighbor
);
10911 ALIAS (show_bgp_view_neighbor_routes
,
10912 show_bgp_view_ipv6_neighbor_routes_cmd
,
10913 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
10919 "Detailed information on TCP and BGP neighbor connections\n"
10920 "Neighbor to display information about\n"
10921 "Neighbor to display information about\n"
10922 "Display routes learned from neighbor\n")
10924 DEFUN (show_bgp_view_neighbor_damp
,
10925 show_bgp_view_neighbor_damp_cmd
,
10926 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10931 "Detailed information on TCP and BGP neighbor connections\n"
10932 "Neighbor to display information about\n"
10933 "Neighbor to display information about\n"
10934 "Display the dampened routes received from neighbor\n")
10939 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10941 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10944 return CMD_WARNING
;
10946 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
10947 bgp_show_type_damp_neighbor
);
10950 ALIAS (show_bgp_view_neighbor_damp
,
10951 show_bgp_view_ipv6_neighbor_damp_cmd
,
10952 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10958 "Detailed information on TCP and BGP neighbor connections\n"
10959 "Neighbor to display information about\n"
10960 "Neighbor to display information about\n"
10961 "Display the dampened routes received from neighbor\n")
10963 DEFUN (show_bgp_view_neighbor_flap
,
10964 show_bgp_view_neighbor_flap_cmd
,
10965 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10970 "Detailed information on TCP and BGP neighbor connections\n"
10971 "Neighbor to display information about\n"
10972 "Neighbor to display information about\n"
10973 "Display flap statistics of the routes learned from neighbor\n")
10978 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10980 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10983 return CMD_WARNING
;
10985 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
10986 bgp_show_type_flap_neighbor
);
10989 ALIAS (show_bgp_view_neighbor_flap
,
10990 show_bgp_view_ipv6_neighbor_flap_cmd
,
10991 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10997 "Detailed information on TCP and BGP neighbor connections\n"
10998 "Neighbor to display information about\n"
10999 "Neighbor to display information about\n"
11000 "Display flap statistics of the routes learned from neighbor\n")
11002 ALIAS (show_bgp_view_neighbor_routes
,
11003 show_bgp_neighbor_routes_cmd
,
11004 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
11007 "Detailed information on TCP and BGP neighbor connections\n"
11008 "Neighbor to display information about\n"
11009 "Neighbor to display information about\n"
11010 "Display routes learned from neighbor\n")
11013 ALIAS (show_bgp_view_neighbor_routes
,
11014 show_bgp_ipv6_neighbor_routes_cmd
,
11015 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
11019 "Detailed information on TCP and BGP neighbor connections\n"
11020 "Neighbor to display information about\n"
11021 "Neighbor to display information about\n"
11022 "Display routes learned from neighbor\n")
11025 ALIAS (show_bgp_view_neighbor_routes
,
11026 ipv6_bgp_neighbor_routes_cmd
,
11027 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
11031 "Detailed information on TCP and BGP neighbor connections\n"
11032 "Neighbor to display information about\n"
11033 "Neighbor to display information about\n"
11034 "Display routes learned from neighbor\n")
11037 DEFUN (ipv6_mbgp_neighbor_routes
,
11038 ipv6_mbgp_neighbor_routes_cmd
,
11039 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
11043 "Detailed information on TCP and BGP neighbor connections\n"
11044 "Neighbor to display information about\n"
11045 "Neighbor to display information about\n"
11046 "Display routes learned from neighbor\n")
11050 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
11052 return CMD_WARNING
;
11054 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
,
11055 bgp_show_type_neighbor
);
11058 ALIAS (show_bgp_view_neighbor_flap
,
11059 show_bgp_neighbor_flap_cmd
,
11060 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
11063 "Detailed information on TCP and BGP neighbor connections\n"
11064 "Neighbor to display information about\n"
11065 "Neighbor to display information about\n"
11066 "Display flap statistics of the routes learned from neighbor\n")
11068 ALIAS (show_bgp_view_neighbor_flap
,
11069 show_bgp_ipv6_neighbor_flap_cmd
,
11070 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
11074 "Detailed information on TCP and BGP neighbor connections\n"
11075 "Neighbor to display information about\n"
11076 "Neighbor to display information about\n"
11077 "Display flap statistics of the routes learned from neighbor\n")
11079 ALIAS (show_bgp_view_neighbor_damp
,
11080 show_bgp_neighbor_damp_cmd
,
11081 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
11084 "Detailed information on TCP and BGP neighbor connections\n"
11085 "Neighbor to display information about\n"
11086 "Neighbor to display information about\n"
11087 "Display the dampened routes received from neighbor\n")
11089 ALIAS (show_bgp_view_neighbor_damp
,
11090 show_bgp_ipv6_neighbor_damp_cmd
,
11091 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
11095 "Detailed information on TCP and BGP neighbor connections\n"
11096 "Neighbor to display information about\n"
11097 "Neighbor to display information about\n"
11098 "Display the dampened routes received from neighbor\n")
11100 DEFUN (show_bgp_view_rsclient
,
11101 show_bgp_view_rsclient_cmd
,
11102 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
11107 "Information about Route Server Client\n"
11110 struct bgp_table
*table
;
11114 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
11116 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
11119 return CMD_WARNING
;
11121 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
11123 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
11125 return CMD_WARNING
;
11128 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
11129 PEER_FLAG_RSERVER_CLIENT
))
11131 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
11133 return CMD_WARNING
;
11136 table
= peer
->rib
[AFI_IP6
][SAFI_UNICAST
];
11138 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
11141 ALIAS (show_bgp_view_rsclient
,
11142 show_bgp_rsclient_cmd
,
11143 "show bgp rsclient (A.B.C.D|X:X::X:X)",
11146 "Information about Route Server Client\n"
11149 DEFUN (show_bgp_view_ipv6_safi_rsclient
,
11150 show_bgp_view_ipv6_safi_rsclient_cmd
,
11151 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
11157 "Address Family modifier\n"
11158 "Address Family modifier\n"
11159 "Information about Route Server Client\n"
11162 struct bgp_table
*table
;
11167 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[2]);
11168 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
11170 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
11171 safi
= (strncmp (argv
[0], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
11175 return CMD_WARNING
;
11177 if (! peer
->afc
[AFI_IP6
][safi
])
11179 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
11181 return CMD_WARNING
;
11184 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][safi
],
11185 PEER_FLAG_RSERVER_CLIENT
))
11187 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
11189 return CMD_WARNING
;
11192 table
= peer
->rib
[AFI_IP6
][safi
];
11194 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
11197 ALIAS (show_bgp_view_ipv6_safi_rsclient
,
11198 show_bgp_ipv6_safi_rsclient_cmd
,
11199 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
11203 "Address Family modifier\n"
11204 "Address Family modifier\n"
11205 "Information about Route Server Client\n"
11208 DEFUN (show_bgp_view_rsclient_route
,
11209 show_bgp_view_rsclient_route_cmd
,
11210 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
11215 "Information about Route Server Client\n"
11217 "Network in the BGP routing table to display\n")
11222 /* BGP structure lookup. */
11225 bgp
= bgp_lookup_by_name (argv
[0]);
11228 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
11229 return CMD_WARNING
;
11234 bgp
= bgp_get_default ();
11237 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
11238 return CMD_WARNING
;
11243 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
11245 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
11248 return CMD_WARNING
;
11250 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
11252 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
11254 return CMD_WARNING
;
11257 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
11258 PEER_FLAG_RSERVER_CLIENT
))
11260 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
11262 return CMD_WARNING
;
11265 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][SAFI_UNICAST
],
11266 (argc
== 3) ? argv
[2] : argv
[1],
11267 AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
11270 ALIAS (show_bgp_view_rsclient_route
,
11271 show_bgp_rsclient_route_cmd
,
11272 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
11275 "Information about Route Server Client\n"
11277 "Network in the BGP routing table to display\n")
11279 DEFUN (show_bgp_view_ipv6_safi_rsclient_route
,
11280 show_bgp_view_ipv6_safi_rsclient_route_cmd
,
11281 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
11287 "Address Family modifier\n"
11288 "Address Family modifier\n"
11289 "Information about Route Server Client\n"
11291 "Network in the BGP routing table to display\n")
11297 /* BGP structure lookup. */
11300 bgp
= bgp_lookup_by_name (argv
[0]);
11303 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
11304 return CMD_WARNING
;
11309 bgp
= bgp_get_default ();
11312 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
11313 return CMD_WARNING
;
11318 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[2]);
11319 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
11321 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
11322 safi
= (strncmp (argv
[0], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
11326 return CMD_WARNING
;
11328 if (! peer
->afc
[AFI_IP6
][safi
])
11330 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
11332 return CMD_WARNING
;
11335 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][safi
],
11336 PEER_FLAG_RSERVER_CLIENT
))
11338 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
11340 return CMD_WARNING
;
11343 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][safi
],
11344 (argc
== 4) ? argv
[3] : argv
[2],
11345 AFI_IP6
, safi
, NULL
, 0);
11348 ALIAS (show_bgp_view_ipv6_safi_rsclient_route
,
11349 show_bgp_ipv6_safi_rsclient_route_cmd
,
11350 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
11354 "Address Family modifier\n"
11355 "Address Family modifier\n"
11356 "Information about Route Server Client\n"
11358 "Network in the BGP routing table to display\n")
11360 DEFUN (show_bgp_view_rsclient_prefix
,
11361 show_bgp_view_rsclient_prefix_cmd
,
11362 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
11367 "Information about Route Server Client\n"
11369 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
11374 /* BGP structure lookup. */
11377 bgp
= bgp_lookup_by_name (argv
[0]);
11380 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
11381 return CMD_WARNING
;
11386 bgp
= bgp_get_default ();
11389 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
11390 return CMD_WARNING
;
11395 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
11397 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
11400 return CMD_WARNING
;
11402 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
11404 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
11406 return CMD_WARNING
;
11409 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
11410 PEER_FLAG_RSERVER_CLIENT
))
11412 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
11414 return CMD_WARNING
;
11417 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][SAFI_UNICAST
],
11418 (argc
== 3) ? argv
[2] : argv
[1],
11419 AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
11422 ALIAS (show_bgp_view_rsclient_prefix
,
11423 show_bgp_rsclient_prefix_cmd
,
11424 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
11427 "Information about Route Server Client\n"
11429 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
11431 DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix
,
11432 show_bgp_view_ipv6_safi_rsclient_prefix_cmd
,
11433 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
11439 "Address Family modifier\n"
11440 "Address Family modifier\n"
11441 "Information about Route Server Client\n"
11443 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
11449 /* BGP structure lookup. */
11452 bgp
= bgp_lookup_by_name (argv
[0]);
11455 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
11456 return CMD_WARNING
;
11461 bgp
= bgp_get_default ();
11464 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
11465 return CMD_WARNING
;
11470 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[2]);
11471 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
11473 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
11474 safi
= (strncmp (argv
[0], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
11478 return CMD_WARNING
;
11480 if (! peer
->afc
[AFI_IP6
][safi
])
11482 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
11484 return CMD_WARNING
;
11487 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][safi
],
11488 PEER_FLAG_RSERVER_CLIENT
))
11490 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
11492 return CMD_WARNING
;
11495 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][safi
],
11496 (argc
== 4) ? argv
[3] : argv
[2],
11497 AFI_IP6
, safi
, NULL
, 1);
11500 ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix
,
11501 show_bgp_ipv6_safi_rsclient_prefix_cmd
,
11502 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
11506 "Address Family modifier\n"
11507 "Address Family modifier\n"
11508 "Information about Route Server Client\n"
11510 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
11512 #endif /* HAVE_IPV6 */
11514 struct bgp_table
*bgp_distance_table
;
11516 struct bgp_distance
11518 /* Distance value for the IP source prefix. */
11521 /* Name of the access-list to be matched. */
11525 static struct bgp_distance
*
11526 bgp_distance_new (void)
11528 return XCALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
11532 bgp_distance_free (struct bgp_distance
*bdistance
)
11534 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
11538 bgp_distance_set (struct vty
*vty
, const char *distance_str
,
11539 const char *ip_str
, const char *access_list_str
)
11542 struct prefix_ipv4 p
;
11544 struct bgp_node
*rn
;
11545 struct bgp_distance
*bdistance
;
11547 ret
= str2prefix_ipv4 (ip_str
, &p
);
11550 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
11551 return CMD_WARNING
;
11554 distance
= atoi (distance_str
);
11556 /* Get BGP distance node. */
11557 rn
= bgp_node_get (bgp_distance_table
, (struct prefix
*) &p
);
11560 bdistance
= rn
->info
;
11561 bgp_unlock_node (rn
);
11565 bdistance
= bgp_distance_new ();
11566 rn
->info
= bdistance
;
11569 /* Set distance value. */
11570 bdistance
->distance
= distance
;
11572 /* Reset access-list configuration. */
11573 if (bdistance
->access_list
)
11575 free (bdistance
->access_list
);
11576 bdistance
->access_list
= NULL
;
11578 if (access_list_str
)
11579 bdistance
->access_list
= strdup (access_list_str
);
11581 return CMD_SUCCESS
;
11585 bgp_distance_unset (struct vty
*vty
, const char *distance_str
,
11586 const char *ip_str
, const char *access_list_str
)
11589 struct prefix_ipv4 p
;
11591 struct bgp_node
*rn
;
11592 struct bgp_distance
*bdistance
;
11594 ret
= str2prefix_ipv4 (ip_str
, &p
);
11597 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
11598 return CMD_WARNING
;
11601 distance
= atoi (distance_str
);
11603 rn
= bgp_node_lookup (bgp_distance_table
, (struct prefix
*)&p
);
11606 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
11607 return CMD_WARNING
;
11610 bdistance
= rn
->info
;
11612 if (bdistance
->access_list
)
11613 free (bdistance
->access_list
);
11614 bgp_distance_free (bdistance
);
11617 bgp_unlock_node (rn
);
11618 bgp_unlock_node (rn
);
11620 return CMD_SUCCESS
;
11623 /* Apply BGP information to distance method. */
11625 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, struct bgp
*bgp
)
11627 struct bgp_node
*rn
;
11628 struct prefix_ipv4 q
;
11630 struct bgp_distance
*bdistance
;
11631 struct access_list
*alist
;
11632 struct bgp_static
*bgp_static
;
11637 if (p
->family
!= AF_INET
)
11640 peer
= rinfo
->peer
;
11642 if (peer
->su
.sa
.sa_family
!= AF_INET
)
11645 memset (&q
, 0, sizeof (struct prefix_ipv4
));
11646 q
.family
= AF_INET
;
11647 q
.prefix
= peer
->su
.sin
.sin_addr
;
11648 q
.prefixlen
= IPV4_MAX_BITLEN
;
11650 /* Check source address. */
11651 rn
= bgp_node_match (bgp_distance_table
, (struct prefix
*) &q
);
11654 bdistance
= rn
->info
;
11655 bgp_unlock_node (rn
);
11657 if (bdistance
->access_list
)
11659 alist
= access_list_lookup (AFI_IP
, bdistance
->access_list
);
11660 if (alist
&& access_list_apply (alist
, p
) == FILTER_PERMIT
)
11661 return bdistance
->distance
;
11664 return bdistance
->distance
;
11667 /* Backdoor check. */
11668 rn
= bgp_node_lookup (bgp
->route
[AFI_IP
][SAFI_UNICAST
], p
);
11671 bgp_static
= rn
->info
;
11672 bgp_unlock_node (rn
);
11674 if (bgp_static
->backdoor
)
11676 if (bgp
->distance_local
)
11677 return bgp
->distance_local
;
11679 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
11683 if (peer_sort (peer
) == BGP_PEER_EBGP
)
11685 if (bgp
->distance_ebgp
)
11686 return bgp
->distance_ebgp
;
11687 return ZEBRA_EBGP_DISTANCE_DEFAULT
;
11691 if (bgp
->distance_ibgp
)
11692 return bgp
->distance_ibgp
;
11693 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
11697 DEFUN (bgp_distance
,
11699 "distance bgp <1-255> <1-255> <1-255>",
11700 "Define an administrative distance\n"
11702 "Distance for routes external to the AS\n"
11703 "Distance for routes internal to the AS\n"
11704 "Distance for local routes\n")
11710 bgp
->distance_ebgp
= atoi (argv
[0]);
11711 bgp
->distance_ibgp
= atoi (argv
[1]);
11712 bgp
->distance_local
= atoi (argv
[2]);
11713 return CMD_SUCCESS
;
11716 DEFUN (no_bgp_distance
,
11717 no_bgp_distance_cmd
,
11718 "no distance bgp <1-255> <1-255> <1-255>",
11720 "Define an administrative distance\n"
11722 "Distance for routes external to the AS\n"
11723 "Distance for routes internal to the AS\n"
11724 "Distance for local routes\n")
11730 bgp
->distance_ebgp
= 0;
11731 bgp
->distance_ibgp
= 0;
11732 bgp
->distance_local
= 0;
11733 return CMD_SUCCESS
;
11736 ALIAS (no_bgp_distance
,
11737 no_bgp_distance2_cmd
,
11740 "Define an administrative distance\n"
11743 DEFUN (bgp_distance_source
,
11744 bgp_distance_source_cmd
,
11745 "distance <1-255> A.B.C.D/M",
11746 "Define an administrative distance\n"
11747 "Administrative distance\n"
11748 "IP source prefix\n")
11750 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
11751 return CMD_SUCCESS
;
11754 DEFUN (no_bgp_distance_source
,
11755 no_bgp_distance_source_cmd
,
11756 "no distance <1-255> A.B.C.D/M",
11758 "Define an administrative distance\n"
11759 "Administrative distance\n"
11760 "IP source prefix\n")
11762 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
11763 return CMD_SUCCESS
;
11766 DEFUN (bgp_distance_source_access_list
,
11767 bgp_distance_source_access_list_cmd
,
11768 "distance <1-255> A.B.C.D/M WORD",
11769 "Define an administrative distance\n"
11770 "Administrative distance\n"
11771 "IP source prefix\n"
11772 "Access list name\n")
11774 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
11775 return CMD_SUCCESS
;
11778 DEFUN (no_bgp_distance_source_access_list
,
11779 no_bgp_distance_source_access_list_cmd
,
11780 "no distance <1-255> A.B.C.D/M WORD",
11782 "Define an administrative distance\n"
11783 "Administrative distance\n"
11784 "IP source prefix\n"
11785 "Access list name\n")
11787 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
11788 return CMD_SUCCESS
;
11791 DEFUN (bgp_damp_set
,
11793 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
11794 "BGP Specific commands\n"
11795 "Enable route-flap dampening\n"
11796 "Half-life time for the penalty\n"
11797 "Value to start reusing a route\n"
11798 "Value to start suppressing a route\n"
11799 "Maximum duration to suppress a stable route\n")
11802 int half
= DEFAULT_HALF_LIFE
* 60;
11803 int reuse
= DEFAULT_REUSE
;
11804 int suppress
= DEFAULT_SUPPRESS
;
11805 int max
= 4 * half
;
11809 half
= atoi (argv
[0]) * 60;
11810 reuse
= atoi (argv
[1]);
11811 suppress
= atoi (argv
[2]);
11812 max
= atoi (argv
[3]) * 60;
11814 else if (argc
== 1)
11816 half
= atoi (argv
[0]) * 60;
11821 return bgp_damp_enable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
),
11822 half
, reuse
, suppress
, max
);
11825 ALIAS (bgp_damp_set
,
11827 "bgp dampening <1-45>",
11828 "BGP Specific commands\n"
11829 "Enable route-flap dampening\n"
11830 "Half-life time for the penalty\n")
11832 ALIAS (bgp_damp_set
,
11835 "BGP Specific commands\n"
11836 "Enable route-flap dampening\n")
11838 DEFUN (bgp_damp_unset
,
11839 bgp_damp_unset_cmd
,
11840 "no bgp dampening",
11842 "BGP Specific commands\n"
11843 "Enable route-flap dampening\n")
11848 return bgp_damp_disable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
));
11851 ALIAS (bgp_damp_unset
,
11852 bgp_damp_unset2_cmd
,
11853 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
11855 "BGP Specific commands\n"
11856 "Enable route-flap dampening\n"
11857 "Half-life time for the penalty\n"
11858 "Value to start reusing a route\n"
11859 "Value to start suppressing a route\n"
11860 "Maximum duration to suppress a stable route\n")
11862 DEFUN (show_ip_bgp_dampened_paths
,
11863 show_ip_bgp_dampened_paths_cmd
,
11864 "show ip bgp dampened-paths",
11868 "Display paths suppressed due to dampening\n")
11870 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_dampend_paths
,
11874 DEFUN (show_ip_bgp_flap_statistics
,
11875 show_ip_bgp_flap_statistics_cmd
,
11876 "show ip bgp flap-statistics",
11880 "Display flap statistics of routes\n")
11882 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
11883 bgp_show_type_flap_statistics
, NULL
);
11886 /* Display specified route of BGP table. */
11888 bgp_clear_damp_route (struct vty
*vty
, const char *view_name
,
11889 const char *ip_str
, afi_t afi
, safi_t safi
,
11890 struct prefix_rd
*prd
, int prefix_check
)
11893 struct prefix match
;
11894 struct bgp_node
*rn
;
11895 struct bgp_node
*rm
;
11896 struct bgp_info
*ri
;
11897 struct bgp_info
*ri_temp
;
11899 struct bgp_table
*table
;
11901 /* BGP structure lookup. */
11904 bgp
= bgp_lookup_by_name (view_name
);
11907 vty_out (vty
, "%% Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
11908 return CMD_WARNING
;
11913 bgp
= bgp_get_default ();
11916 vty_out (vty
, "%% No BGP process is configured%s", VTY_NEWLINE
);
11917 return CMD_WARNING
;
11921 /* Check IP address argument. */
11922 ret
= str2prefix (ip_str
, &match
);
11925 vty_out (vty
, "%% address is malformed%s", VTY_NEWLINE
);
11926 return CMD_WARNING
;
11929 match
.family
= afi2family (afi
);
11931 if (safi
== SAFI_MPLS_VPN
)
11933 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][SAFI_MPLS_VPN
]); rn
; rn
= bgp_route_next (rn
))
11935 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
11938 if ((table
= rn
->info
) != NULL
)
11939 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
11941 if (! prefix_check
|| rm
->p
.prefixlen
== match
.prefixlen
)
11946 if (ri
->extra
&& ri
->extra
->damp_info
)
11948 ri_temp
= ri
->next
;
11949 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
11957 bgp_unlock_node (rm
);
11963 if ((rn
= bgp_node_match (bgp
->rib
[afi
][safi
], &match
)) != NULL
)
11965 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
11970 if (ri
->extra
&& ri
->extra
->damp_info
)
11972 ri_temp
= ri
->next
;
11973 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
11981 bgp_unlock_node (rn
);
11985 return CMD_SUCCESS
;
11988 DEFUN (clear_ip_bgp_dampening
,
11989 clear_ip_bgp_dampening_cmd
,
11990 "clear ip bgp dampening",
11994 "Clear route flap dampening information\n")
11996 bgp_damp_info_clean ();
11997 return CMD_SUCCESS
;
12000 DEFUN (clear_ip_bgp_dampening_prefix
,
12001 clear_ip_bgp_dampening_prefix_cmd
,
12002 "clear ip bgp dampening A.B.C.D/M",
12006 "Clear route flap dampening information\n"
12007 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
12009 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
12010 SAFI_UNICAST
, NULL
, 1);
12013 DEFUN (clear_ip_bgp_dampening_address
,
12014 clear_ip_bgp_dampening_address_cmd
,
12015 "clear ip bgp dampening A.B.C.D",
12019 "Clear route flap dampening information\n"
12020 "Network to clear damping information\n")
12022 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
12023 SAFI_UNICAST
, NULL
, 0);
12026 DEFUN (clear_ip_bgp_dampening_address_mask
,
12027 clear_ip_bgp_dampening_address_mask_cmd
,
12028 "clear ip bgp dampening A.B.C.D A.B.C.D",
12032 "Clear route flap dampening information\n"
12033 "Network to clear damping information\n"
12037 char prefix_str
[BUFSIZ
];
12039 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
12042 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
12043 return CMD_WARNING
;
12046 return bgp_clear_damp_route (vty
, NULL
, prefix_str
, AFI_IP
,
12047 SAFI_UNICAST
, NULL
, 0);
12051 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
12052 afi_t afi
, safi_t safi
, int *write
)
12054 struct bgp_node
*prn
;
12055 struct bgp_node
*rn
;
12056 struct bgp_table
*table
;
12058 struct prefix_rd
*prd
;
12059 struct bgp_static
*bgp_static
;
12061 char buf
[SU_ADDRSTRLEN
];
12062 char rdbuf
[RD_ADDRSTRLEN
];
12064 /* Network configuration. */
12065 for (prn
= bgp_table_top (bgp
->route
[afi
][safi
]); prn
; prn
= bgp_route_next (prn
))
12066 if ((table
= prn
->info
) != NULL
)
12067 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
12068 if ((bgp_static
= rn
->info
) != NULL
)
12071 prd
= (struct prefix_rd
*) &prn
->p
;
12073 /* "address-family" display. */
12074 bgp_config_write_family_header (vty
, afi
, safi
, write
);
12076 /* "network" configuration display. */
12077 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
12078 label
= decode_label (bgp_static
->tag
);
12080 vty_out (vty
, " network %s/%d rd %s tag %d",
12081 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
12084 vty_out (vty
, "%s", VTY_NEWLINE
);
12089 /* Configuration of static route announcement and aggregate
12092 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
12093 afi_t afi
, safi_t safi
, int *write
)
12095 struct bgp_node
*rn
;
12097 struct bgp_static
*bgp_static
;
12098 struct bgp_aggregate
*bgp_aggregate
;
12099 char buf
[SU_ADDRSTRLEN
];
12101 if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
12102 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
12104 /* Network configuration. */
12105 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
12106 if ((bgp_static
= rn
->info
) != NULL
)
12110 /* "address-family" display. */
12111 bgp_config_write_family_header (vty
, afi
, safi
, write
);
12113 /* "network" configuration display. */
12114 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
12116 u_int32_t destination
;
12117 struct in_addr netmask
;
12119 destination
= ntohl (p
->u
.prefix4
.s_addr
);
12120 masklen2ip (p
->prefixlen
, &netmask
);
12121 vty_out (vty
, " network %s",
12122 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
));
12124 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
12125 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
12126 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
12127 || p
->u
.prefix4
.s_addr
== 0)
12129 /* Natural mask is not display. */
12132 vty_out (vty
, " mask %s", inet_ntoa (netmask
));
12136 vty_out (vty
, " network %s/%d",
12137 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
12141 if (bgp_static
->rmap
.name
)
12142 vty_out (vty
, " route-map %s", bgp_static
->rmap
.name
);
12145 if (bgp_static
->backdoor
)
12146 vty_out (vty
, " backdoor");
12149 vty_out (vty
, "%s", VTY_NEWLINE
);
12152 /* Aggregate-address configuration. */
12153 for (rn
= bgp_table_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
12154 if ((bgp_aggregate
= rn
->info
) != NULL
)
12158 /* "address-family" display. */
12159 bgp_config_write_family_header (vty
, afi
, safi
, write
);
12161 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
12163 struct in_addr netmask
;
12165 masklen2ip (p
->prefixlen
, &netmask
);
12166 vty_out (vty
, " aggregate-address %s %s",
12167 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
12168 inet_ntoa (netmask
));
12172 vty_out (vty
, " aggregate-address %s/%d",
12173 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
12177 if (bgp_aggregate
->as_set
)
12178 vty_out (vty
, " as-set");
12180 if (bgp_aggregate
->summary_only
)
12181 vty_out (vty
, " summary-only");
12183 vty_out (vty
, "%s", VTY_NEWLINE
);
12190 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
)
12192 struct bgp_node
*rn
;
12193 struct bgp_distance
*bdistance
;
12195 /* Distance configuration. */
12196 if (bgp
->distance_ebgp
12197 && bgp
->distance_ibgp
12198 && bgp
->distance_local
12199 && (bgp
->distance_ebgp
!= ZEBRA_EBGP_DISTANCE_DEFAULT
12200 || bgp
->distance_ibgp
!= ZEBRA_IBGP_DISTANCE_DEFAULT
12201 || bgp
->distance_local
!= ZEBRA_IBGP_DISTANCE_DEFAULT
))
12202 vty_out (vty
, " distance bgp %d %d %d%s",
12203 bgp
->distance_ebgp
, bgp
->distance_ibgp
, bgp
->distance_local
,
12206 for (rn
= bgp_table_top (bgp_distance_table
); rn
; rn
= bgp_route_next (rn
))
12207 if ((bdistance
= rn
->info
) != NULL
)
12209 vty_out (vty
, " distance %d %s/%d %s%s", bdistance
->distance
,
12210 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
12211 bdistance
->access_list
? bdistance
->access_list
: "",
12218 /* Allocate routing table structure and install commands. */
12220 bgp_route_init (void)
12222 /* Init BGP distance table. */
12223 bgp_distance_table
= bgp_table_init (AFI_IP
, SAFI_UNICAST
);
12225 /* IPv4 BGP commands. */
12226 install_element (BGP_NODE
, &bgp_network_cmd
);
12227 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
12228 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
12229 install_element (BGP_NODE
, &bgp_network_route_map_cmd
);
12230 install_element (BGP_NODE
, &bgp_network_mask_route_map_cmd
);
12231 install_element (BGP_NODE
, &bgp_network_mask_natural_route_map_cmd
);
12232 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
12233 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
12234 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
12235 install_element (BGP_NODE
, &no_bgp_network_cmd
);
12236 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
12237 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
12238 install_element (BGP_NODE
, &no_bgp_network_route_map_cmd
);
12239 install_element (BGP_NODE
, &no_bgp_network_mask_route_map_cmd
);
12240 install_element (BGP_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
12241 install_element (BGP_NODE
, &no_bgp_network_backdoor_cmd
);
12242 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_cmd
);
12243 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_cmd
);
12245 install_element (BGP_NODE
, &aggregate_address_cmd
);
12246 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
12247 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
12248 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
12249 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
12250 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
12251 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
12252 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
12253 install_element (BGP_NODE
, &aggregate_address_summary_as_set_cmd
);
12254 install_element (BGP_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
12255 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
12256 install_element (BGP_NODE
, &no_aggregate_address_summary_only_cmd
);
12257 install_element (BGP_NODE
, &no_aggregate_address_as_set_cmd
);
12258 install_element (BGP_NODE
, &no_aggregate_address_as_set_summary_cmd
);
12259 install_element (BGP_NODE
, &no_aggregate_address_summary_as_set_cmd
);
12260 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
12261 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
12262 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_cmd
);
12263 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
12264 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
12266 /* IPv4 unicast configuration. */
12267 install_element (BGP_IPV4_NODE
, &bgp_network_cmd
);
12268 install_element (BGP_IPV4_NODE
, &bgp_network_mask_cmd
);
12269 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_cmd
);
12270 install_element (BGP_IPV4_NODE
, &bgp_network_route_map_cmd
);
12271 install_element (BGP_IPV4_NODE
, &bgp_network_mask_route_map_cmd
);
12272 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_route_map_cmd
);
12273 install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
12274 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_cmd
);
12275 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_cmd
);
12276 install_element (BGP_IPV4_NODE
, &no_bgp_network_route_map_cmd
);
12277 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_route_map_cmd
);
12278 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
12280 install_element (BGP_IPV4_NODE
, &aggregate_address_cmd
);
12281 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_cmd
);
12282 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_only_cmd
);
12283 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_only_cmd
);
12284 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_cmd
);
12285 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_cmd
);
12286 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_summary_cmd
);
12287 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
12288 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_as_set_cmd
);
12289 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
12290 install_element (BGP_IPV4_NODE
, &no_aggregate_address_cmd
);
12291 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_only_cmd
);
12292 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_cmd
);
12293 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_summary_cmd
);
12294 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_as_set_cmd
);
12295 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_cmd
);
12296 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
12297 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_cmd
);
12298 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
12299 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
12301 /* IPv4 multicast configuration. */
12302 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
12303 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
12304 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
12305 install_element (BGP_IPV4M_NODE
, &bgp_network_route_map_cmd
);
12306 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_route_map_cmd
);
12307 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_route_map_cmd
);
12308 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
12309 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
12310 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
12311 install_element (BGP_IPV4M_NODE
, &no_bgp_network_route_map_cmd
);
12312 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_route_map_cmd
);
12313 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
12314 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
12315 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
12316 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
12317 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
12318 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
12319 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
12320 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
12321 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
12322 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_as_set_cmd
);
12323 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
12324 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
12325 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_only_cmd
);
12326 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_cmd
);
12327 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_summary_cmd
);
12328 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_as_set_cmd
);
12329 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
12330 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
12331 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_cmd
);
12332 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
12333 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
12335 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
12336 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
12337 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_cmd
);
12338 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
12339 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
12340 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_cmd
);
12341 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
12342 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
12343 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
12344 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
12345 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
12346 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
12347 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
12348 install_element (VIEW_NODE
, &show_ip_bgp_view_cmd
);
12349 install_element (VIEW_NODE
, &show_ip_bgp_view_route_cmd
);
12350 install_element (VIEW_NODE
, &show_ip_bgp_view_prefix_cmd
);
12351 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
12352 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
12353 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
12354 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
12355 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
12356 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
12357 install_element (VIEW_NODE
, &show_ip_bgp_route_map_cmd
);
12358 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
12359 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
12360 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
12361 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
12362 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
12363 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
12364 install_element (VIEW_NODE
, &show_ip_bgp_community2_cmd
);
12365 install_element (VIEW_NODE
, &show_ip_bgp_community3_cmd
);
12366 install_element (VIEW_NODE
, &show_ip_bgp_community4_cmd
);
12367 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
12368 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
12369 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
12370 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
12371 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_community_all_cmd
);
12372 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_community_cmd
);
12373 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_community2_cmd
);
12374 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_community3_cmd
);
12375 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_community4_cmd
);
12376 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
12377 install_element (VIEW_NODE
, &show_ip_bgp_community2_exact_cmd
);
12378 install_element (VIEW_NODE
, &show_ip_bgp_community3_exact_cmd
);
12379 install_element (VIEW_NODE
, &show_ip_bgp_community4_exact_cmd
);
12380 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
12381 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
12382 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
12383 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
12384 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
12385 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
12386 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
12387 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
12388 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
12389 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
12390 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
12391 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
12392 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
12393 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
12394 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd
);
12395 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
12396 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
12397 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
12398 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
12399 install_element (VIEW_NODE
, &show_ip_bgp_dampened_paths_cmd
);
12400 install_element (VIEW_NODE
, &show_ip_bgp_flap_statistics_cmd
);
12401 install_element (VIEW_NODE
, &show_ip_bgp_flap_address_cmd
);
12402 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_cmd
);
12403 install_element (VIEW_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
12404 install_element (VIEW_NODE
, &show_ip_bgp_flap_regexp_cmd
);
12405 install_element (VIEW_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
12406 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
12407 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
12408 install_element (VIEW_NODE
, &show_ip_bgp_flap_route_map_cmd
);
12409 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
12410 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
12411 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_cmd
);
12412 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_rsclient_cmd
);
12413 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_route_cmd
);
12414 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_rsclient_route_cmd
);
12415 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
12416 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_rsclient_prefix_cmd
);
12417 install_element (VIEW_NODE
, &show_ip_bgp_view_neighbor_advertised_route_cmd
);
12418 install_element (VIEW_NODE
, &show_ip_bgp_view_neighbor_received_routes_cmd
);
12419 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_cmd
);
12420 install_element (VIEW_NODE
, &show_bgp_view_ipv4_safi_rsclient_cmd
);
12421 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
12422 install_element (VIEW_NODE
, &show_bgp_view_ipv4_safi_rsclient_route_cmd
);
12423 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
12424 install_element (VIEW_NODE
, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd
);
12426 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
12427 install_element (RESTRICTED_NODE
, &show_ip_bgp_route_cmd
);
12428 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_route_cmd
);
12429 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_route_cmd
);
12430 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
12431 install_element (RESTRICTED_NODE
, &show_ip_bgp_prefix_cmd
);
12432 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
12433 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
12434 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
12435 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
12436 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_route_cmd
);
12437 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_prefix_cmd
);
12438 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_cmd
);
12439 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_cmd
);
12440 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_cmd
);
12441 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_cmd
);
12442 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_cmd
);
12443 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
12444 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
12445 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
12446 install_element (RESTRICTED_NODE
, &show_bgp_view_afi_safi_community_all_cmd
);
12447 install_element (RESTRICTED_NODE
, &show_bgp_view_afi_safi_community_cmd
);
12448 install_element (RESTRICTED_NODE
, &show_bgp_view_afi_safi_community2_cmd
);
12449 install_element (RESTRICTED_NODE
, &show_bgp_view_afi_safi_community3_cmd
);
12450 install_element (RESTRICTED_NODE
, &show_bgp_view_afi_safi_community4_cmd
);
12451 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_exact_cmd
);
12452 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_exact_cmd
);
12453 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_exact_cmd
);
12454 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_exact_cmd
);
12455 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
12456 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
12457 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
12458 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
12459 install_element (RESTRICTED_NODE
, &show_ip_bgp_rsclient_route_cmd
);
12460 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_rsclient_route_cmd
);
12461 install_element (RESTRICTED_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
12462 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_rsclient_prefix_cmd
);
12463 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
12464 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv4_safi_rsclient_route_cmd
);
12465 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
12466 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd
);
12468 install_element (ENABLE_NODE
, &show_ip_bgp_cmd
);
12469 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cmd
);
12470 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_cmd
);
12471 install_element (ENABLE_NODE
, &show_ip_bgp_route_cmd
);
12472 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_cmd
);
12473 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_route_cmd
);
12474 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
12475 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
12476 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_cmd
);
12477 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
12478 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
12479 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
12480 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
12481 install_element (ENABLE_NODE
, &show_ip_bgp_view_cmd
);
12482 install_element (ENABLE_NODE
, &show_ip_bgp_view_route_cmd
);
12483 install_element (ENABLE_NODE
, &show_ip_bgp_view_prefix_cmd
);
12484 install_element (ENABLE_NODE
, &show_ip_bgp_regexp_cmd
);
12485 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
12486 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_list_cmd
);
12487 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
12488 install_element (ENABLE_NODE
, &show_ip_bgp_filter_list_cmd
);
12489 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
12490 install_element (ENABLE_NODE
, &show_ip_bgp_route_map_cmd
);
12491 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
12492 install_element (ENABLE_NODE
, &show_ip_bgp_cidr_only_cmd
);
12493 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
12494 install_element (ENABLE_NODE
, &show_ip_bgp_community_all_cmd
);
12495 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
12496 install_element (ENABLE_NODE
, &show_ip_bgp_community_cmd
);
12497 install_element (ENABLE_NODE
, &show_ip_bgp_community2_cmd
);
12498 install_element (ENABLE_NODE
, &show_ip_bgp_community3_cmd
);
12499 install_element (ENABLE_NODE
, &show_ip_bgp_community4_cmd
);
12500 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_cmd
);
12501 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
12502 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
12503 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
12504 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_community_all_cmd
);
12505 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_community_cmd
);
12506 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_community2_cmd
);
12507 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_community3_cmd
);
12508 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_community4_cmd
);
12509 install_element (ENABLE_NODE
, &show_ip_bgp_community_exact_cmd
);
12510 install_element (ENABLE_NODE
, &show_ip_bgp_community2_exact_cmd
);
12511 install_element (ENABLE_NODE
, &show_ip_bgp_community3_exact_cmd
);
12512 install_element (ENABLE_NODE
, &show_ip_bgp_community4_exact_cmd
);
12513 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
12514 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
12515 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
12516 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
12517 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_cmd
);
12518 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
12519 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_exact_cmd
);
12520 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
12521 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_longer_cmd
);
12522 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
12523 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
12524 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
12525 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
12526 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
12527 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd
);
12528 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
12529 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
12530 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
12531 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
12532 install_element (ENABLE_NODE
, &show_ip_bgp_dampened_paths_cmd
);
12533 install_element (ENABLE_NODE
, &show_ip_bgp_flap_statistics_cmd
);
12534 install_element (ENABLE_NODE
, &show_ip_bgp_flap_address_cmd
);
12535 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_cmd
);
12536 install_element (ENABLE_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
12537 install_element (ENABLE_NODE
, &show_ip_bgp_flap_regexp_cmd
);
12538 install_element (ENABLE_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
12539 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
12540 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
12541 install_element (ENABLE_NODE
, &show_ip_bgp_flap_route_map_cmd
);
12542 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
12543 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
12544 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_cmd
);
12545 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_rsclient_cmd
);
12546 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_route_cmd
);
12547 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_rsclient_route_cmd
);
12548 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
12549 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_rsclient_prefix_cmd
);
12550 install_element (ENABLE_NODE
, &show_ip_bgp_view_neighbor_advertised_route_cmd
);
12551 install_element (ENABLE_NODE
, &show_ip_bgp_view_neighbor_received_routes_cmd
);
12552 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_cmd
);
12553 install_element (ENABLE_NODE
, &show_bgp_view_ipv4_safi_rsclient_cmd
);
12554 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
12555 install_element (ENABLE_NODE
, &show_bgp_view_ipv4_safi_rsclient_route_cmd
);
12556 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
12557 install_element (ENABLE_NODE
, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd
);
12559 /* BGP dampening clear commands */
12560 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_cmd
);
12561 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_prefix_cmd
);
12562 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_cmd
);
12563 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_mask_cmd
);
12566 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_prefix_counts_cmd
);
12567 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
);
12568 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
);
12570 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_prefix_counts_cmd
);
12572 /* New config IPv6 BGP commands. */
12573 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
12574 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_route_map_cmd
);
12575 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
12576 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_route_map_cmd
);
12578 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
12579 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
12580 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
12581 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
12583 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_network_cmd
);
12584 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_network_cmd
);
12586 /* Old config IPv6 BGP commands. */
12587 install_element (BGP_NODE
, &old_ipv6_bgp_network_cmd
);
12588 install_element (BGP_NODE
, &old_no_ipv6_bgp_network_cmd
);
12590 install_element (BGP_NODE
, &old_ipv6_aggregate_address_cmd
);
12591 install_element (BGP_NODE
, &old_ipv6_aggregate_address_summary_only_cmd
);
12592 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_cmd
);
12593 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_summary_only_cmd
);
12595 install_element (VIEW_NODE
, &show_bgp_cmd
);
12596 install_element (VIEW_NODE
, &show_bgp_ipv6_cmd
);
12597 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_cmd
);
12598 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
12599 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
12600 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_cmd
);
12601 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
12602 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
12603 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
12604 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
12605 install_element (VIEW_NODE
, &show_bgp_ipv6_regexp_cmd
);
12606 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
12607 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
12608 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
12609 install_element (VIEW_NODE
, &show_bgp_ipv6_filter_list_cmd
);
12610 install_element (VIEW_NODE
, &show_bgp_route_map_cmd
);
12611 install_element (VIEW_NODE
, &show_bgp_ipv6_route_map_cmd
);
12612 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
12613 install_element (VIEW_NODE
, &show_bgp_ipv6_community_all_cmd
);
12614 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
12615 install_element (VIEW_NODE
, &show_bgp_ipv6_community_cmd
);
12616 install_element (VIEW_NODE
, &show_bgp_community2_cmd
);
12617 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_cmd
);
12618 install_element (VIEW_NODE
, &show_bgp_community3_cmd
);
12619 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_cmd
);
12620 install_element (VIEW_NODE
, &show_bgp_community4_cmd
);
12621 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_cmd
);
12622 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
12623 install_element (VIEW_NODE
, &show_bgp_ipv6_community_exact_cmd
);
12624 install_element (VIEW_NODE
, &show_bgp_community2_exact_cmd
);
12625 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
12626 install_element (VIEW_NODE
, &show_bgp_community3_exact_cmd
);
12627 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
12628 install_element (VIEW_NODE
, &show_bgp_community4_exact_cmd
);
12629 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
12630 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
12631 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_cmd
);
12632 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
12633 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
12634 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
12635 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
12636 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
12637 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
12638 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
12639 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
12640 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
12641 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
12642 install_element (VIEW_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
12643 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
12644 install_element (VIEW_NODE
, &show_bgp_neighbor_flap_cmd
);
12645 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
12646 install_element (VIEW_NODE
, &show_bgp_neighbor_damp_cmd
);
12647 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
12648 install_element (VIEW_NODE
, &show_bgp_rsclient_cmd
);
12649 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_rsclient_cmd
);
12650 install_element (VIEW_NODE
, &show_bgp_rsclient_route_cmd
);
12651 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_rsclient_route_cmd
);
12652 install_element (VIEW_NODE
, &show_bgp_rsclient_prefix_cmd
);
12653 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_rsclient_prefix_cmd
);
12654 install_element (VIEW_NODE
, &show_bgp_view_cmd
);
12655 install_element (VIEW_NODE
, &show_bgp_view_ipv6_cmd
);
12656 install_element (VIEW_NODE
, &show_bgp_view_route_cmd
);
12657 install_element (VIEW_NODE
, &show_bgp_view_ipv6_route_cmd
);
12658 install_element (VIEW_NODE
, &show_bgp_view_prefix_cmd
);
12659 install_element (VIEW_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
12660 install_element (VIEW_NODE
, &show_bgp_view_neighbor_advertised_route_cmd
);
12661 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_advertised_route_cmd
);
12662 install_element (VIEW_NODE
, &show_bgp_view_neighbor_received_routes_cmd
);
12663 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_received_routes_cmd
);
12664 install_element (VIEW_NODE
, &show_bgp_view_neighbor_routes_cmd
);
12665 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_routes_cmd
);
12666 install_element (VIEW_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
12667 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
12668 install_element (VIEW_NODE
, &show_bgp_view_neighbor_flap_cmd
);
12669 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_flap_cmd
);
12670 install_element (VIEW_NODE
, &show_bgp_view_neighbor_damp_cmd
);
12671 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_damp_cmd
);
12672 install_element (VIEW_NODE
, &show_bgp_view_rsclient_cmd
);
12673 install_element (VIEW_NODE
, &show_bgp_view_ipv6_safi_rsclient_cmd
);
12674 install_element (VIEW_NODE
, &show_bgp_view_rsclient_route_cmd
);
12675 install_element (VIEW_NODE
, &show_bgp_view_ipv6_safi_rsclient_route_cmd
);
12676 install_element (VIEW_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
12677 install_element (VIEW_NODE
, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd
);
12680 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
12682 install_element (RESTRICTED_NODE
, &show_bgp_route_cmd
);
12683 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_route_cmd
);
12684 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_route_cmd
);
12685 install_element (RESTRICTED_NODE
, &show_bgp_prefix_cmd
);
12686 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_prefix_cmd
);
12687 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
12688 install_element (RESTRICTED_NODE
, &show_bgp_community_cmd
);
12689 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_cmd
);
12690 install_element (RESTRICTED_NODE
, &show_bgp_community2_cmd
);
12691 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_cmd
);
12692 install_element (RESTRICTED_NODE
, &show_bgp_community3_cmd
);
12693 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_cmd
);
12694 install_element (RESTRICTED_NODE
, &show_bgp_community4_cmd
);
12695 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_cmd
);
12696 install_element (RESTRICTED_NODE
, &show_bgp_community_exact_cmd
);
12697 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_exact_cmd
);
12698 install_element (RESTRICTED_NODE
, &show_bgp_community2_exact_cmd
);
12699 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
12700 install_element (RESTRICTED_NODE
, &show_bgp_community3_exact_cmd
);
12701 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
12702 install_element (RESTRICTED_NODE
, &show_bgp_community4_exact_cmd
);
12703 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
12704 install_element (RESTRICTED_NODE
, &show_bgp_rsclient_route_cmd
);
12705 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_rsclient_route_cmd
);
12706 install_element (RESTRICTED_NODE
, &show_bgp_rsclient_prefix_cmd
);
12707 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_rsclient_prefix_cmd
);
12708 install_element (RESTRICTED_NODE
, &show_bgp_view_route_cmd
);
12709 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_route_cmd
);
12710 install_element (RESTRICTED_NODE
, &show_bgp_view_prefix_cmd
);
12711 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
12712 install_element (RESTRICTED_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
12713 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
12714 install_element (RESTRICTED_NODE
, &show_bgp_view_rsclient_route_cmd
);
12715 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_safi_rsclient_route_cmd
);
12716 install_element (RESTRICTED_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
12717 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd
);
12719 install_element (ENABLE_NODE
, &show_bgp_cmd
);
12720 install_element (ENABLE_NODE
, &show_bgp_ipv6_cmd
);
12721 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_cmd
);
12722 install_element (ENABLE_NODE
, &show_bgp_route_cmd
);
12723 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_cmd
);
12724 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_route_cmd
);
12725 install_element (ENABLE_NODE
, &show_bgp_prefix_cmd
);
12726 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_cmd
);
12727 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
12728 install_element (ENABLE_NODE
, &show_bgp_regexp_cmd
);
12729 install_element (ENABLE_NODE
, &show_bgp_ipv6_regexp_cmd
);
12730 install_element (ENABLE_NODE
, &show_bgp_prefix_list_cmd
);
12731 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
12732 install_element (ENABLE_NODE
, &show_bgp_filter_list_cmd
);
12733 install_element (ENABLE_NODE
, &show_bgp_ipv6_filter_list_cmd
);
12734 install_element (ENABLE_NODE
, &show_bgp_route_map_cmd
);
12735 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_map_cmd
);
12736 install_element (ENABLE_NODE
, &show_bgp_community_all_cmd
);
12737 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_all_cmd
);
12738 install_element (ENABLE_NODE
, &show_bgp_community_cmd
);
12739 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_cmd
);
12740 install_element (ENABLE_NODE
, &show_bgp_community2_cmd
);
12741 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_cmd
);
12742 install_element (ENABLE_NODE
, &show_bgp_community3_cmd
);
12743 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_cmd
);
12744 install_element (ENABLE_NODE
, &show_bgp_community4_cmd
);
12745 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_cmd
);
12746 install_element (ENABLE_NODE
, &show_bgp_community_exact_cmd
);
12747 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_exact_cmd
);
12748 install_element (ENABLE_NODE
, &show_bgp_community2_exact_cmd
);
12749 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
12750 install_element (ENABLE_NODE
, &show_bgp_community3_exact_cmd
);
12751 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
12752 install_element (ENABLE_NODE
, &show_bgp_community4_exact_cmd
);
12753 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
12754 install_element (ENABLE_NODE
, &show_bgp_community_list_cmd
);
12755 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_cmd
);
12756 install_element (ENABLE_NODE
, &show_bgp_community_list_exact_cmd
);
12757 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
12758 install_element (ENABLE_NODE
, &show_bgp_prefix_longer_cmd
);
12759 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
12760 install_element (ENABLE_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
12761 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
12762 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_routes_cmd
);
12763 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
12764 install_element (ENABLE_NODE
, &show_bgp_neighbor_routes_cmd
);
12765 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
12766 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
12767 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
12768 install_element (ENABLE_NODE
, &show_bgp_neighbor_flap_cmd
);
12769 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
12770 install_element (ENABLE_NODE
, &show_bgp_neighbor_damp_cmd
);
12771 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
12772 install_element (ENABLE_NODE
, &show_bgp_rsclient_cmd
);
12773 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_rsclient_cmd
);
12774 install_element (ENABLE_NODE
, &show_bgp_rsclient_route_cmd
);
12775 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_rsclient_route_cmd
);
12776 install_element (ENABLE_NODE
, &show_bgp_rsclient_prefix_cmd
);
12777 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_rsclient_prefix_cmd
);
12778 install_element (ENABLE_NODE
, &show_bgp_view_cmd
);
12779 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_cmd
);
12780 install_element (ENABLE_NODE
, &show_bgp_view_route_cmd
);
12781 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_route_cmd
);
12782 install_element (ENABLE_NODE
, &show_bgp_view_prefix_cmd
);
12783 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
12784 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_advertised_route_cmd
);
12785 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_advertised_route_cmd
);
12786 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_received_routes_cmd
);
12787 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_received_routes_cmd
);
12788 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_routes_cmd
);
12789 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_routes_cmd
);
12790 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
12791 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
12792 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_flap_cmd
);
12793 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_flap_cmd
);
12794 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_damp_cmd
);
12795 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_damp_cmd
);
12796 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_cmd
);
12797 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_safi_rsclient_cmd
);
12798 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_route_cmd
);
12799 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_safi_rsclient_route_cmd
);
12800 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
12801 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd
);
12804 install_element (ENABLE_NODE
, &show_bgp_statistics_cmd
);
12805 install_element (ENABLE_NODE
, &show_bgp_statistics_vpnv4_cmd
);
12806 install_element (ENABLE_NODE
, &show_bgp_statistics_view_cmd
);
12807 install_element (ENABLE_NODE
, &show_bgp_statistics_view_vpnv4_cmd
);
12810 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
12811 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
12812 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
12813 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
12814 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
12815 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
12816 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
12817 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
12818 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_cmd
);
12819 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_cmd
);
12820 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_cmd
);
12821 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
12822 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
12823 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
12824 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
12825 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
12826 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
12827 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
12828 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
12829 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
12830 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
12831 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
12832 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
12833 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
12834 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
12835 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
12836 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_cmd
);
12837 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_cmd
);
12838 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_cmd
);
12839 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
12840 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
12841 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
12842 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
12843 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
12844 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
12845 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
12848 install_element (ENABLE_NODE
, &show_ipv6_bgp_cmd
);
12849 install_element (ENABLE_NODE
, &show_ipv6_bgp_route_cmd
);
12850 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_cmd
);
12851 install_element (ENABLE_NODE
, &show_ipv6_bgp_regexp_cmd
);
12852 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
12853 install_element (ENABLE_NODE
, &show_ipv6_bgp_filter_list_cmd
);
12854 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_all_cmd
);
12855 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_cmd
);
12856 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_cmd
);
12857 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_cmd
);
12858 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_cmd
);
12859 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_exact_cmd
);
12860 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
12861 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
12862 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
12863 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_cmd
);
12864 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
12865 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
12866 install_element (ENABLE_NODE
, &show_ipv6_mbgp_cmd
);
12867 install_element (ENABLE_NODE
, &show_ipv6_mbgp_route_cmd
);
12868 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_cmd
);
12869 install_element (ENABLE_NODE
, &show_ipv6_mbgp_regexp_cmd
);
12870 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
12871 install_element (ENABLE_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
12872 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_all_cmd
);
12873 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_cmd
);
12874 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_cmd
);
12875 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_cmd
);
12876 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_cmd
);
12877 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
12878 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
12879 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
12880 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
12881 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_cmd
);
12882 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
12883 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
12886 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
12887 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
12888 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
12889 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
12892 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
12893 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
12894 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
12895 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
12898 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
12899 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
12900 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
12901 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
12902 #endif /* HAVE_IPV6 */
12904 install_element (BGP_NODE
, &bgp_distance_cmd
);
12905 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
12906 install_element (BGP_NODE
, &no_bgp_distance2_cmd
);
12907 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
12908 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
12909 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
12910 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
12912 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
12913 install_element (BGP_NODE
, &bgp_damp_set2_cmd
);
12914 install_element (BGP_NODE
, &bgp_damp_set3_cmd
);
12915 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
12916 install_element (BGP_NODE
, &bgp_damp_unset2_cmd
);
12917 install_element (BGP_IPV4_NODE
, &bgp_damp_set_cmd
);
12918 install_element (BGP_IPV4_NODE
, &bgp_damp_set2_cmd
);
12919 install_element (BGP_IPV4_NODE
, &bgp_damp_set3_cmd
);
12920 install_element (BGP_IPV4_NODE
, &bgp_damp_unset_cmd
);
12921 install_element (BGP_IPV4_NODE
, &bgp_damp_unset2_cmd
);
12923 /* Deprecated AS-Pathlimit commands */
12924 install_element (BGP_NODE
, &bgp_network_ttl_cmd
);
12925 install_element (BGP_NODE
, &bgp_network_mask_ttl_cmd
);
12926 install_element (BGP_NODE
, &bgp_network_mask_natural_ttl_cmd
);
12927 install_element (BGP_NODE
, &bgp_network_backdoor_ttl_cmd
);
12928 install_element (BGP_NODE
, &bgp_network_mask_backdoor_ttl_cmd
);
12929 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_ttl_cmd
);
12931 install_element (BGP_NODE
, &no_bgp_network_ttl_cmd
);
12932 install_element (BGP_NODE
, &no_bgp_network_mask_ttl_cmd
);
12933 install_element (BGP_NODE
, &no_bgp_network_mask_natural_ttl_cmd
);
12934 install_element (BGP_NODE
, &no_bgp_network_backdoor_ttl_cmd
);
12935 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_ttl_cmd
);
12936 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_ttl_cmd
);
12938 install_element (BGP_IPV4_NODE
, &bgp_network_ttl_cmd
);
12939 install_element (BGP_IPV4_NODE
, &bgp_network_mask_ttl_cmd
);
12940 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_ttl_cmd
);
12941 install_element (BGP_IPV4_NODE
, &bgp_network_backdoor_ttl_cmd
);
12942 install_element (BGP_IPV4_NODE
, &bgp_network_mask_backdoor_ttl_cmd
);
12943 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_backdoor_ttl_cmd
);
12945 install_element (BGP_IPV4_NODE
, &no_bgp_network_ttl_cmd
);
12946 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_ttl_cmd
);
12947 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_ttl_cmd
);
12948 install_element (BGP_IPV4_NODE
, &no_bgp_network_backdoor_ttl_cmd
);
12949 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_backdoor_ttl_cmd
);
12950 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_backdoor_ttl_cmd
);
12952 install_element (BGP_IPV4M_NODE
, &bgp_network_ttl_cmd
);
12953 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_ttl_cmd
);
12954 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_ttl_cmd
);
12955 install_element (BGP_IPV4M_NODE
, &bgp_network_backdoor_ttl_cmd
);
12956 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_backdoor_ttl_cmd
);
12957 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_backdoor_ttl_cmd
);
12959 install_element (BGP_IPV4M_NODE
, &no_bgp_network_ttl_cmd
);
12960 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_ttl_cmd
);
12961 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_ttl_cmd
);
12962 install_element (BGP_IPV4M_NODE
, &no_bgp_network_backdoor_ttl_cmd
);
12963 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_backdoor_ttl_cmd
);
12964 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_backdoor_ttl_cmd
);
12967 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_ttl_cmd
);
12968 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_ttl_cmd
);
12973 bgp_route_finish (void)
12975 bgp_table_unlock (bgp_distance_table
);
12976 bgp_distance_table
= NULL
;