1 /* BGP routing information
2 Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro
4 This file is part of GNU Zebra.
6 GNU Zebra is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 GNU Zebra is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Zebra; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
33 #include "sockunion.h"
36 #include "workqueue.h"
38 #include "bgpd/bgpd.h"
39 #include "bgpd/bgp_table.h"
40 #include "bgpd/bgp_route.h"
41 #include "bgpd/bgp_attr.h"
42 #include "bgpd/bgp_debug.h"
43 #include "bgpd/bgp_aspath.h"
44 #include "bgpd/bgp_regex.h"
45 #include "bgpd/bgp_community.h"
46 #include "bgpd/bgp_ecommunity.h"
47 #include "bgpd/bgp_clist.h"
48 #include "bgpd/bgp_packet.h"
49 #include "bgpd/bgp_filter.h"
50 #include "bgpd/bgp_fsm.h"
51 #include "bgpd/bgp_mplsvpn.h"
52 #include "bgpd/bgp_nexthop.h"
53 #include "bgpd/bgp_damp.h"
54 #include "bgpd/bgp_advertise.h"
55 #include "bgpd/bgp_zebra.h"
56 #include "bgpd/bgp_vty.h"
58 /* Extern from bgp_dump.c */
59 extern const char *bgp_origin_str
[];
60 extern const char *bgp_origin_long_str
[];
62 static struct bgp_node
*
63 bgp_afi_node_get (struct bgp_table
*table
, afi_t afi
, safi_t safi
, struct prefix
*p
,
64 struct prefix_rd
*prd
)
67 struct bgp_node
*prn
= NULL
;
73 if (safi
== SAFI_MPLS_VPN
)
75 prn
= bgp_node_get (table
, (struct prefix
*) prd
);
77 if (prn
->info
== NULL
)
78 prn
->info
= bgp_table_init (afi
, safi
);
80 bgp_unlock_node (prn
);
84 rn
= bgp_node_get (table
, p
);
86 if (safi
== SAFI_MPLS_VPN
)
92 /* Allocate bgp_info_extra */
93 static struct bgp_info_extra
*
94 bgp_info_extra_new (void)
96 struct bgp_info_extra
*new;
97 new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA
, sizeof (struct bgp_info_extra
));
102 bgp_info_extra_free (struct bgp_info_extra
**extra
)
106 if ((*extra
)->damp_info
)
107 bgp_damp_info_free ((*extra
)->damp_info
, 0);
109 (*extra
)->damp_info
= NULL
;
111 XFREE (MTYPE_BGP_ROUTE_EXTRA
, *extra
);
117 /* Get bgp_info extra information for the given bgp_info, lazy allocated
120 struct bgp_info_extra
*
121 bgp_info_extra_get (struct bgp_info
*ri
)
124 ri
->extra
= bgp_info_extra_new();
128 /* Allocate new bgp info structure. */
129 static struct bgp_info
*
132 return XCALLOC (MTYPE_BGP_ROUTE
, sizeof (struct bgp_info
));
135 /* Free bgp route information. */
137 bgp_info_free (struct bgp_info
*binfo
)
140 bgp_attr_unintern (binfo
->attr
);
142 bgp_info_extra_free (&binfo
->extra
);
144 peer_unlock (binfo
->peer
); /* bgp_info peer reference */
146 XFREE (MTYPE_BGP_ROUTE
, binfo
);
150 bgp_info_lock (struct bgp_info
*binfo
)
157 bgp_info_unlock (struct bgp_info
*binfo
)
159 assert (binfo
&& binfo
->lock
> 0);
162 if (binfo
->lock
== 0)
165 zlog_debug ("%s: unlocked and freeing", __func__
);
166 zlog_backtrace (LOG_DEBUG
);
168 bgp_info_free (binfo
);
173 if (binfo
->lock
== 1)
175 zlog_debug ("%s: unlocked to 1", __func__
);
176 zlog_backtrace (LOG_DEBUG
);
184 bgp_info_add (struct bgp_node
*rn
, struct bgp_info
*ri
)
186 struct bgp_info
*top
;
198 peer_lock (ri
->peer
); /* bgp_info peer reference */
201 /* Do the actual removal of info from RIB, for use by bgp_process
202 completion callback *only* */
204 bgp_info_reap (struct bgp_node
*rn
, struct bgp_info
*ri
)
207 ri
->next
->prev
= ri
->prev
;
209 ri
->prev
->next
= ri
->next
;
213 bgp_info_unlock (ri
);
214 bgp_unlock_node (rn
);
218 bgp_info_delete (struct bgp_node
*rn
, struct bgp_info
*ri
)
220 bgp_info_set_flag (rn
, ri
, BGP_INFO_REMOVED
);
221 /* set of previous already took care of pcount */
222 UNSET_FLAG (ri
->flags
, BGP_INFO_VALID
);
225 /* undo the effects of a previous call to bgp_info_delete; typically
226 called when a route is deleted and then quickly re-added before the
227 deletion has been processed */
229 bgp_info_restore (struct bgp_node
*rn
, struct bgp_info
*ri
)
231 bgp_info_unset_flag (rn
, ri
, BGP_INFO_REMOVED
);
232 /* unset of previous already took care of pcount */
233 SET_FLAG (ri
->flags
, BGP_INFO_VALID
);
236 /* Adjust pcount as required */
238 bgp_pcount_adjust (struct bgp_node
*rn
, struct bgp_info
*ri
)
240 assert (rn
&& rn
->table
);
241 assert (ri
&& ri
->peer
&& ri
->peer
->bgp
);
243 /* Ignore 'pcount' for RS-client tables */
244 if (rn
->table
->type
!= BGP_TABLE_MAIN
245 || ri
->peer
== ri
->peer
->bgp
->peer_self
)
248 if (BGP_INFO_HOLDDOWN (ri
)
249 && CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
252 UNSET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
254 /* slight hack, but more robust against errors. */
255 if (ri
->peer
->pcount
[rn
->table
->afi
][rn
->table
->safi
])
256 ri
->peer
->pcount
[rn
->table
->afi
][rn
->table
->safi
]--;
259 zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s",
260 __func__
, ri
->peer
->host
);
261 zlog_backtrace (LOG_WARNING
);
262 zlog_warn ("%s: Please report to Quagga bugzilla", __func__
);
265 else if (!BGP_INFO_HOLDDOWN (ri
)
266 && !CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
268 SET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
269 ri
->peer
->pcount
[rn
->table
->afi
][rn
->table
->safi
]++;
274 /* Set/unset bgp_info flags, adjusting any other state as needed.
275 * This is here primarily to keep prefix-count in check.
278 bgp_info_set_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
280 SET_FLAG (ri
->flags
, flag
);
282 /* early bath if we know it's not a flag that changes useability state */
283 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_UNUSEABLE
))
286 bgp_pcount_adjust (rn
, ri
);
290 bgp_info_unset_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
292 UNSET_FLAG (ri
->flags
, flag
);
294 /* early bath if we know it's not a flag that changes useability state */
295 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_UNUSEABLE
))
298 bgp_pcount_adjust (rn
, ri
);
301 /* Get MED value. If MED value is missing and "bgp bestpath
302 missing-as-worst" is specified, treat it as the worst value. */
304 bgp_med_value (struct attr
*attr
, struct bgp
*bgp
)
306 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
310 if (bgp_flag_check (bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
317 /* Compare two bgp route entity. br is preferable then return 1. */
319 bgp_info_cmp (struct bgp
*bgp
, struct bgp_info
*new, struct bgp_info
*exist
)
322 u_int32_t exist_pref
;
325 u_int32_t new_weight
= 0;
326 u_int32_t exist_weight
= 0;
327 struct in_addr new_id
;
328 struct in_addr exist_id
;
331 int internal_as_route
= 0;
332 int confed_as_route
= 0;
341 /* 1. Weight check. */
342 if (new->attr
->extra
)
343 new_weight
= new->attr
->extra
->weight
;
344 if (exist
->attr
->extra
)
345 exist_weight
= exist
->attr
->extra
->weight
;
346 if (new_weight
> exist_weight
)
348 if (new_weight
< exist_weight
)
351 /* 2. Local preference check. */
352 if (new->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
353 new_pref
= new->attr
->local_pref
;
355 new_pref
= bgp
->default_local_pref
;
357 if (exist
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
358 exist_pref
= exist
->attr
->local_pref
;
360 exist_pref
= bgp
->default_local_pref
;
362 if (new_pref
> exist_pref
)
364 if (new_pref
< exist_pref
)
367 /* 3. Local route check. */
368 if (new->sub_type
== BGP_ROUTE_STATIC
)
370 if (exist
->sub_type
== BGP_ROUTE_STATIC
)
373 if (new->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
375 if (exist
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
378 if (new->sub_type
== BGP_ROUTE_AGGREGATE
)
380 if (exist
->sub_type
== BGP_ROUTE_AGGREGATE
)
383 /* 4. AS path length check. */
384 if (! bgp_flag_check (bgp
, BGP_FLAG_ASPATH_IGNORE
))
386 int exist_hops
= aspath_count_hops (exist
->attr
->aspath
);
387 int exist_confeds
= aspath_count_confeds (exist
->attr
->aspath
);
389 if (bgp_flag_check (bgp
, BGP_FLAG_ASPATH_CONFED
))
393 aspath_hops
= aspath_count_hops (new->attr
->aspath
);
394 aspath_hops
+= aspath_count_confeds (new->attr
->aspath
);
396 if ( aspath_hops
< (exist_hops
+ exist_confeds
))
398 if ( aspath_hops
> (exist_hops
+ exist_confeds
))
403 int newhops
= aspath_count_hops (new->attr
->aspath
);
405 if (newhops
< exist_hops
)
407 if (newhops
> exist_hops
)
412 /* 5. Origin check. */
413 if (new->attr
->origin
< exist
->attr
->origin
)
415 if (new->attr
->origin
> exist
->attr
->origin
)
419 internal_as_route
= (aspath_count_hops (new->attr
->aspath
) == 0
420 && aspath_count_hops (exist
->attr
->aspath
) == 0);
421 confed_as_route
= (aspath_count_confeds (new->attr
->aspath
) > 0
422 && aspath_count_confeds (exist
->attr
->aspath
) > 0
423 && aspath_count_hops (new->attr
->aspath
) == 0
424 && aspath_count_hops (exist
->attr
->aspath
) == 0);
426 if (bgp_flag_check (bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
)
427 || (bgp_flag_check (bgp
, BGP_FLAG_MED_CONFED
)
429 || aspath_cmp_left (new->attr
->aspath
, exist
->attr
->aspath
)
430 || aspath_cmp_left_confed (new->attr
->aspath
, exist
->attr
->aspath
)
431 || internal_as_route
)
433 new_med
= bgp_med_value (new->attr
, bgp
);
434 exist_med
= bgp_med_value (exist
->attr
, bgp
);
436 if (new_med
< exist_med
)
438 if (new_med
> exist_med
)
442 /* 7. Peer type check. */
443 if (peer_sort (new->peer
) == BGP_PEER_EBGP
444 && peer_sort (exist
->peer
) == BGP_PEER_IBGP
)
446 if (peer_sort (new->peer
) == BGP_PEER_EBGP
447 && peer_sort (exist
->peer
) == BGP_PEER_CONFED
)
449 if (peer_sort (new->peer
) == BGP_PEER_IBGP
450 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
452 if (peer_sort (new->peer
) == BGP_PEER_CONFED
453 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
456 /* 8. IGP metric check. */
457 if (new->extra
|| exist
->extra
)
459 uint32_t newm
= (new->extra
? new->extra
->igpmetric
: 0);
460 uint32_t existm
= (exist
->extra
? exist
->extra
->igpmetric
: 0);
468 /* 9. Maximum path check. */
470 /* 10. If both paths are external, prefer the path that was received
471 first (the oldest one). This step minimizes route-flap, since a
472 newer path won't displace an older one, even if it was the
473 preferred route based on the additional decision criteria below. */
474 if (! bgp_flag_check (bgp
, BGP_FLAG_COMPARE_ROUTER_ID
)
475 && peer_sort (new->peer
) == BGP_PEER_EBGP
476 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
478 if (CHECK_FLAG (new->flags
, BGP_INFO_SELECTED
))
480 if (CHECK_FLAG (exist
->flags
, BGP_INFO_SELECTED
))
484 /* 11. Rourter-ID comparision. */
485 if (new->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
486 new_id
.s_addr
= new->attr
->extra
->originator_id
.s_addr
;
488 new_id
.s_addr
= new->peer
->remote_id
.s_addr
;
489 if (exist
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
490 exist_id
.s_addr
= exist
->attr
->extra
->originator_id
.s_addr
;
492 exist_id
.s_addr
= exist
->peer
->remote_id
.s_addr
;
494 if (ntohl (new_id
.s_addr
) < ntohl (exist_id
.s_addr
))
496 if (ntohl (new_id
.s_addr
) > ntohl (exist_id
.s_addr
))
499 /* 12. Cluster length comparision. */
500 if (new->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
501 new_cluster
= new->attr
->extra
->cluster
->length
;
504 if (exist
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
505 exist_cluster
= exist
->attr
->extra
->cluster
->length
;
509 if (new_cluster
< exist_cluster
)
511 if (new_cluster
> exist_cluster
)
514 /* 13. Neighbor address comparision. */
515 ret
= sockunion_cmp (new->peer
->su_remote
, exist
->peer
->su_remote
);
525 static enum filter_type
526 bgp_input_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
527 afi_t afi
, safi_t safi
)
529 struct bgp_filter
*filter
;
531 filter
= &peer
->filter
[afi
][safi
];
533 #define FILTER_EXIST_WARN(F,f,filter) \
534 if (BGP_DEBUG (update, UPDATE_IN) \
535 && !(F ## _IN (filter))) \
536 plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \
537 peer->host, #f, F ## _IN_NAME(filter));
539 if (DISTRIBUTE_IN_NAME (filter
)) {
540 FILTER_EXIST_WARN(DISTRIBUTE
, distribute
, filter
);
542 if (access_list_apply (DISTRIBUTE_IN (filter
), p
) == FILTER_DENY
)
546 if (PREFIX_LIST_IN_NAME (filter
)) {
547 FILTER_EXIST_WARN(PREFIX_LIST
, prefix
, filter
);
549 if (prefix_list_apply (PREFIX_LIST_IN (filter
), p
) == PREFIX_DENY
)
553 if (FILTER_LIST_IN_NAME (filter
)) {
554 FILTER_EXIST_WARN(FILTER_LIST
, as
, filter
);
556 if (as_list_apply (FILTER_LIST_IN (filter
), attr
->aspath
)== AS_FILTER_DENY
)
560 return FILTER_PERMIT
;
561 #undef FILTER_EXIST_WARN
564 static enum filter_type
565 bgp_output_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
566 afi_t afi
, safi_t safi
)
568 struct bgp_filter
*filter
;
570 filter
= &peer
->filter
[afi
][safi
];
572 #define FILTER_EXIST_WARN(F,f,filter) \
573 if (BGP_DEBUG (update, UPDATE_OUT) \
574 && !(F ## _OUT (filter))) \
575 plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \
576 peer->host, #f, F ## _OUT_NAME(filter));
578 if (DISTRIBUTE_OUT_NAME (filter
)) {
579 FILTER_EXIST_WARN(DISTRIBUTE
, distribute
, filter
);
581 if (access_list_apply (DISTRIBUTE_OUT (filter
), p
) == FILTER_DENY
)
585 if (PREFIX_LIST_OUT_NAME (filter
)) {
586 FILTER_EXIST_WARN(PREFIX_LIST
, prefix
, filter
);
588 if (prefix_list_apply (PREFIX_LIST_OUT (filter
), p
) == PREFIX_DENY
)
592 if (FILTER_LIST_OUT_NAME (filter
)) {
593 FILTER_EXIST_WARN(FILTER_LIST
, as
, filter
);
595 if (as_list_apply (FILTER_LIST_OUT (filter
), attr
->aspath
) == AS_FILTER_DENY
)
599 return FILTER_PERMIT
;
600 #undef FILTER_EXIST_WARN
603 /* If community attribute includes no_export then return 1. */
605 bgp_community_filter (struct peer
*peer
, struct attr
*attr
)
609 /* NO_ADVERTISE check. */
610 if (community_include (attr
->community
, COMMUNITY_NO_ADVERTISE
))
613 /* NO_EXPORT check. */
614 if (peer_sort (peer
) == BGP_PEER_EBGP
&&
615 community_include (attr
->community
, COMMUNITY_NO_EXPORT
))
618 /* NO_EXPORT_SUBCONFED check. */
619 if (peer_sort (peer
) == BGP_PEER_EBGP
620 || peer_sort (peer
) == BGP_PEER_CONFED
)
621 if (community_include (attr
->community
, COMMUNITY_NO_EXPORT_SUBCONFED
))
627 /* Route reflection loop check. */
629 bgp_cluster_filter (struct peer
*peer
, struct attr
*attr
)
631 struct in_addr cluster_id
;
633 if (attr
->extra
&& attr
->extra
->cluster
)
635 if (peer
->bgp
->config
& BGP_CONFIG_CLUSTER_ID
)
636 cluster_id
= peer
->bgp
->cluster_id
;
638 cluster_id
= peer
->bgp
->router_id
;
640 if (cluster_loop_check (attr
->extra
->cluster
, cluster_id
))
647 bgp_input_modifier (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
648 afi_t afi
, safi_t safi
)
650 struct bgp_filter
*filter
;
651 struct bgp_info info
;
652 route_map_result_t ret
;
654 filter
= &peer
->filter
[afi
][safi
];
656 /* Apply default weight value. */
658 (bgp_attr_extra_get (attr
))->weight
= peer
->weight
;
660 /* Route map apply. */
661 if (ROUTE_MAP_IN_NAME (filter
))
663 /* Duplicate current value to new strucutre for modification. */
667 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IN
);
669 /* Apply BGP route map to the attribute. */
670 ret
= route_map_apply (ROUTE_MAP_IN (filter
), p
, RMAP_BGP
, &info
);
674 if (ret
== RMAP_DENYMATCH
)
676 /* Free newly generated AS path and community by route-map. */
677 bgp_attr_flush (attr
);
685 bgp_export_modifier (struct peer
*rsclient
, struct peer
*peer
,
686 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
688 struct bgp_filter
*filter
;
689 struct bgp_info info
;
690 route_map_result_t ret
;
692 filter
= &peer
->filter
[afi
][safi
];
694 /* Route map apply. */
695 if (ROUTE_MAP_EXPORT_NAME (filter
))
697 /* Duplicate current value to new strucutre for modification. */
698 info
.peer
= rsclient
;
701 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_EXPORT
);
703 /* Apply BGP route map to the attribute. */
704 ret
= route_map_apply (ROUTE_MAP_EXPORT (filter
), p
, RMAP_BGP
, &info
);
706 rsclient
->rmap_type
= 0;
708 if (ret
== RMAP_DENYMATCH
)
710 /* Free newly generated AS path and community by route-map. */
711 bgp_attr_flush (attr
);
719 bgp_import_modifier (struct peer
*rsclient
, struct peer
*peer
,
720 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
722 struct bgp_filter
*filter
;
723 struct bgp_info info
;
724 route_map_result_t ret
;
726 filter
= &rsclient
->filter
[afi
][safi
];
728 /* Apply default weight value. */
730 (bgp_attr_extra_get (attr
))->weight
= peer
->weight
;
732 /* Route map apply. */
733 if (ROUTE_MAP_IMPORT_NAME (filter
))
735 /* Duplicate current value to new strucutre for modification. */
739 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
);
741 /* Apply BGP route map to the attribute. */
742 ret
= route_map_apply (ROUTE_MAP_IMPORT (filter
), p
, RMAP_BGP
, &info
);
746 if (ret
== RMAP_DENYMATCH
)
748 /* Free newly generated AS path and community by route-map. */
749 bgp_attr_flush (attr
);
757 bgp_announce_check (struct bgp_info
*ri
, struct peer
*peer
, struct prefix
*p
,
758 struct attr
*attr
, afi_t afi
, safi_t safi
)
761 char buf
[SU_ADDRSTRLEN
];
762 struct bgp_filter
*filter
;
769 filter
= &peer
->filter
[afi
][safi
];
772 if (DISABLE_BGP_ANNOUNCE
)
775 /* Do not send announces to RS-clients from the 'normal' bgp_table. */
776 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
779 /* Do not send back route to sender. */
783 /* If peer's id and route's nexthop are same. draft-ietf-idr-bgp4-23 5.1.3 */
784 if (p
->family
== AF_INET
785 && IPV4_ADDR_SAME(&peer
->remote_id
, &ri
->attr
->nexthop
))
788 if (p
->family
== AF_INET6
789 && IPV6_ADDR_SAME(&peer
->remote_id
, &ri
->attr
->nexthop
))
793 /* Aggregate-address suppress check. */
794 if (ri
->extra
&& ri
->extra
->suppress
)
795 if (! UNSUPPRESS_MAP_NAME (filter
))
798 /* Default route check. */
799 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
))
801 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
)
804 else if (p
->family
== AF_INET6
&& p
->prefixlen
== 0)
806 #endif /* HAVE_IPV6 */
809 /* Transparency check. */
810 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
)
811 && CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
816 /* If community is not disabled check the no-export and local. */
817 if (! transparent
&& bgp_community_filter (peer
, ri
->attr
))
820 /* If the attribute has originator-id and it is same as remote
822 if (ri
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
))
824 if (IPV4_ADDR_SAME (&peer
->remote_id
, &ri
->attr
->extra
->originator_id
))
826 if (BGP_DEBUG (filter
, FILTER
))
827 zlog (peer
->log
, LOG_DEBUG
,
828 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
830 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
836 /* ORF prefix-list filter check */
837 if (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_RM_ADV
)
838 && (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_RCV
)
839 || CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)))
840 if (peer
->orf_plist
[afi
][safi
])
842 if (prefix_list_apply (peer
->orf_plist
[afi
][safi
], p
) == PREFIX_DENY
)
846 /* Output filter check. */
847 if (bgp_output_filter (peer
, p
, ri
->attr
, afi
, safi
) == FILTER_DENY
)
849 if (BGP_DEBUG (filter
, FILTER
))
850 zlog (peer
->log
, LOG_DEBUG
,
851 "%s [Update:SEND] %s/%d is filtered",
853 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
858 #ifdef BGP_SEND_ASPATH_CHECK
859 /* AS path loop check. */
860 if (aspath_loop_check (ri
->attr
->aspath
, peer
->as
))
862 if (BGP_DEBUG (filter
, FILTER
))
863 zlog (peer
->log
, LOG_DEBUG
,
864 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
865 peer
->host
, peer
->as
);
868 #endif /* BGP_SEND_ASPATH_CHECK */
870 /* If we're a CONFED we need to loop check the CONFED ID too */
871 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
873 if (aspath_loop_check(ri
->attr
->aspath
, bgp
->confed_id
))
875 if (BGP_DEBUG (filter
, FILTER
))
876 zlog (peer
->log
, LOG_DEBUG
,
877 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
884 /* Route-Reflect check. */
885 if (peer_sort (from
) == BGP_PEER_IBGP
&& peer_sort (peer
) == BGP_PEER_IBGP
)
890 /* IBGP reflection check. */
893 /* A route from a Client peer. */
894 if (CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
896 /* Reflect to all the Non-Client peers and also to the
897 Client peers other than the originator. Originator check
898 is already done. So there is noting to do. */
899 /* no bgp client-to-client reflection check. */
900 if (bgp_flag_check (bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
901 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
906 /* A route from a Non-client peer. Reflect to all other
908 if (! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
913 /* For modify attribute, copy it to temporary structure. */
914 bgp_attr_dup (attr
, ri
->attr
);
916 /* If local-preference is not set. */
917 if ((peer_sort (peer
) == BGP_PEER_IBGP
918 || peer_sort (peer
) == BGP_PEER_CONFED
)
919 && (! (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))))
921 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
);
922 attr
->local_pref
= bgp
->default_local_pref
;
925 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
926 if (peer_sort (peer
) == BGP_PEER_EBGP
927 && attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
929 if (ri
->peer
!= bgp
->peer_self
&& ! transparent
930 && ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
931 attr
->flag
&= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
));
935 if (transparent
|| reflect
936 || (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_UNCHANGED
)
937 && ((p
->family
== AF_INET
&& attr
->nexthop
.s_addr
)
939 || (p
->family
== AF_INET6
&&
940 ! IN6_IS_ADDR_UNSPECIFIED(&attr
->extra
->mp_nexthop_global
))
941 #endif /* HAVE_IPV6 */
944 /* NEXT-HOP Unchanged. */
946 else if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
947 || (p
->family
== AF_INET
&& attr
->nexthop
.s_addr
== 0)
949 || (p
->family
== AF_INET6
&&
950 IN6_IS_ADDR_UNSPECIFIED(&attr
->extra
->mp_nexthop_global
))
951 #endif /* HAVE_IPV6 */
952 || (peer_sort (peer
) == BGP_PEER_EBGP
953 && bgp_multiaccess_check_v4 (attr
->nexthop
, peer
->host
) == 0))
955 /* Set IPv4 nexthop. */
956 if (p
->family
== AF_INET
)
958 if (safi
== SAFI_MPLS_VPN
)
959 memcpy (&attr
->extra
->mp_nexthop_global_in
, &peer
->nexthop
.v4
,
962 memcpy (&attr
->nexthop
, &peer
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
965 /* Set IPv6 nexthop. */
966 if (p
->family
== AF_INET6
)
968 /* IPv6 global nexthop must be included. */
969 memcpy (&attr
->extra
->mp_nexthop_global
, &peer
->nexthop
.v6_global
,
971 attr
->extra
->mp_nexthop_len
= 16;
973 #endif /* HAVE_IPV6 */
977 if (p
->family
== AF_INET6
)
979 /* Left nexthop_local unchanged if so configured. */
980 if ( CHECK_FLAG (peer
->af_flags
[afi
][safi
],
981 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) )
983 if ( IN6_IS_ADDR_LINKLOCAL (&attr
->extra
->mp_nexthop_local
) )
984 attr
->extra
->mp_nexthop_len
=32;
986 attr
->extra
->mp_nexthop_len
=16;
989 /* Default nexthop_local treatment for non-RS-Clients */
992 /* Link-local address should not be transit to different peer. */
993 attr
->extra
->mp_nexthop_len
= 16;
995 /* Set link-local address for shared network peer. */
996 if (peer
->shared_network
997 && ! IN6_IS_ADDR_UNSPECIFIED (&peer
->nexthop
.v6_local
))
999 memcpy (&attr
->extra
->mp_nexthop_local
, &peer
->nexthop
.v6_local
,
1001 attr
->extra
->mp_nexthop_len
= 32;
1004 /* If bgpd act as BGP-4+ route-reflector, do not send link-local
1007 attr
->extra
->mp_nexthop_len
= 16;
1009 /* If BGP-4+ link-local nexthop is not link-local nexthop. */
1010 if (! IN6_IS_ADDR_LINKLOCAL (&peer
->nexthop
.v6_local
))
1011 attr
->extra
->mp_nexthop_len
= 16;
1015 #endif /* HAVE_IPV6 */
1017 /* If this is EBGP peer and remove-private-AS is set. */
1018 if (peer_sort (peer
) == BGP_PEER_EBGP
1019 && peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)
1020 && aspath_private_as_check (attr
->aspath
))
1021 attr
->aspath
= aspath_empty_get ();
1023 /* Route map & unsuppress-map apply. */
1024 if (ROUTE_MAP_OUT_NAME (filter
)
1025 || (ri
->extra
&& ri
->extra
->suppress
) )
1027 struct bgp_info info
;
1028 struct attr dummy_attr
= { 0 };
1033 /* The route reflector is not allowed to modify the attributes
1034 of the reflected IBGP routes. */
1035 if (peer_sort (from
) == BGP_PEER_IBGP
1036 && peer_sort (peer
) == BGP_PEER_IBGP
)
1038 bgp_attr_dup (&dummy_attr
, attr
);
1039 info
.attr
= &dummy_attr
;
1042 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1044 if (ri
->extra
&& ri
->extra
->suppress
)
1045 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
1047 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
1049 peer
->rmap_type
= 0;
1051 if (dummy_attr
.extra
)
1052 bgp_attr_extra_free (&dummy_attr
);
1054 if (ret
== RMAP_DENYMATCH
)
1056 bgp_attr_flush (attr
);
1064 bgp_announce_check_rsclient (struct bgp_info
*ri
, struct peer
*rsclient
,
1065 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
1068 char buf
[SU_ADDRSTRLEN
];
1069 struct bgp_filter
*filter
;
1070 struct bgp_info info
;
1075 filter
= &rsclient
->filter
[afi
][safi
];
1076 bgp
= rsclient
->bgp
;
1078 if (DISABLE_BGP_ANNOUNCE
)
1081 /* Do not send back route to sender. */
1082 if (from
== rsclient
)
1085 /* Aggregate-address suppress check. */
1086 if (ri
->extra
&& ri
->extra
->suppress
)
1087 if (! UNSUPPRESS_MAP_NAME (filter
))
1090 /* Default route check. */
1091 if (CHECK_FLAG (rsclient
->af_sflags
[afi
][safi
],
1092 PEER_STATUS_DEFAULT_ORIGINATE
))
1094 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
)
1097 else if (p
->family
== AF_INET6
&& p
->prefixlen
== 0)
1099 #endif /* HAVE_IPV6 */
1102 /* If the attribute has originator-id and it is same as remote
1104 if (ri
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
))
1106 if (IPV4_ADDR_SAME (&rsclient
->remote_id
,
1107 &ri
->attr
->extra
->originator_id
))
1109 if (BGP_DEBUG (filter
, FILTER
))
1110 zlog (rsclient
->log
, LOG_DEBUG
,
1111 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
1113 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1119 /* ORF prefix-list filter check */
1120 if (CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_RM_ADV
)
1121 && (CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_RCV
)
1122 || CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)))
1123 if (rsclient
->orf_plist
[afi
][safi
])
1125 if (prefix_list_apply (rsclient
->orf_plist
[afi
][safi
], p
) == PREFIX_DENY
)
1129 /* Output filter check. */
1130 if (bgp_output_filter (rsclient
, p
, ri
->attr
, afi
, safi
) == FILTER_DENY
)
1132 if (BGP_DEBUG (filter
, FILTER
))
1133 zlog (rsclient
->log
, LOG_DEBUG
,
1134 "%s [Update:SEND] %s/%d is filtered",
1136 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1141 #ifdef BGP_SEND_ASPATH_CHECK
1142 /* AS path loop check. */
1143 if (aspath_loop_check (ri
->attr
->aspath
, rsclient
->as
))
1145 if (BGP_DEBUG (filter
, FILTER
))
1146 zlog (rsclient
->log
, LOG_DEBUG
,
1147 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
1148 rsclient
->host
, rsclient
->as
);
1151 #endif /* BGP_SEND_ASPATH_CHECK */
1153 /* For modify attribute, copy it to temporary structure. */
1154 bgp_attr_dup (attr
, ri
->attr
);
1157 if ((p
->family
== AF_INET
&& attr
->nexthop
.s_addr
== 0)
1159 || (p
->family
== AF_INET6
&&
1160 IN6_IS_ADDR_UNSPECIFIED(&attr
->extra
->mp_nexthop_global
))
1161 #endif /* HAVE_IPV6 */
1164 /* Set IPv4 nexthop. */
1165 if (p
->family
== AF_INET
)
1167 if (safi
== SAFI_MPLS_VPN
)
1168 memcpy (&attr
->extra
->mp_nexthop_global_in
, &rsclient
->nexthop
.v4
,
1171 memcpy (&attr
->nexthop
, &rsclient
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
1174 /* Set IPv6 nexthop. */
1175 if (p
->family
== AF_INET6
)
1177 /* IPv6 global nexthop must be included. */
1178 memcpy (&attr
->extra
->mp_nexthop_global
, &rsclient
->nexthop
.v6_global
,
1180 attr
->extra
->mp_nexthop_len
= 16;
1182 #endif /* HAVE_IPV6 */
1186 if (p
->family
== AF_INET6
)
1188 struct attr_extra
*attre
= attr
->extra
;
1190 assert (attr
->extra
);
1192 /* Left nexthop_local unchanged if so configured. */
1193 if ( CHECK_FLAG (rsclient
->af_flags
[afi
][safi
],
1194 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) )
1196 if ( IN6_IS_ADDR_LINKLOCAL (&attre
->mp_nexthop_local
) )
1197 attre
->mp_nexthop_len
=32;
1199 attre
->mp_nexthop_len
=16;
1202 /* Default nexthop_local treatment for RS-Clients */
1205 /* Announcer and RS-Client are both in the same network */
1206 if (rsclient
->shared_network
&& from
->shared_network
&&
1207 (rsclient
->ifindex
== from
->ifindex
))
1209 if ( IN6_IS_ADDR_LINKLOCAL (&attre
->mp_nexthop_local
) )
1210 attre
->mp_nexthop_len
=32;
1212 attre
->mp_nexthop_len
=16;
1215 /* Set link-local address for shared network peer. */
1216 else if (rsclient
->shared_network
1217 && IN6_IS_ADDR_LINKLOCAL (&rsclient
->nexthop
.v6_local
))
1219 memcpy (&attre
->mp_nexthop_local
, &rsclient
->nexthop
.v6_local
,
1221 attre
->mp_nexthop_len
= 32;
1225 attre
->mp_nexthop_len
= 16;
1229 #endif /* HAVE_IPV6 */
1232 /* If this is EBGP peer and remove-private-AS is set. */
1233 if (peer_sort (rsclient
) == BGP_PEER_EBGP
1234 && peer_af_flag_check (rsclient
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)
1235 && aspath_private_as_check (attr
->aspath
))
1236 attr
->aspath
= aspath_empty_get ();
1238 /* Route map & unsuppress-map apply. */
1239 if (ROUTE_MAP_OUT_NAME (filter
) || (ri
->extra
&& ri
->extra
->suppress
) )
1241 info
.peer
= rsclient
;
1244 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1246 if (ri
->extra
&& ri
->extra
->suppress
)
1247 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
1249 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
1251 rsclient
->rmap_type
= 0;
1253 if (ret
== RMAP_DENYMATCH
)
1255 bgp_attr_flush (attr
);
1263 struct bgp_info_pair
1265 struct bgp_info
*old
;
1266 struct bgp_info
*new;
1270 bgp_best_selection (struct bgp
*bgp
, struct bgp_node
*rn
, struct bgp_info_pair
*result
)
1272 struct bgp_info
*new_select
;
1273 struct bgp_info
*old_select
;
1274 struct bgp_info
*ri
;
1275 struct bgp_info
*ri1
;
1276 struct bgp_info
*ri2
;
1277 struct bgp_info
*nextri
= NULL
;
1279 /* bgp deterministic-med */
1281 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
))
1282 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1284 if (CHECK_FLAG (ri1
->flags
, BGP_INFO_DMED_CHECK
))
1286 if (BGP_INFO_HOLDDOWN (ri1
))
1291 for (ri2
= ri1
->next
; ri2
; ri2
= ri2
->next
)
1293 if (CHECK_FLAG (ri2
->flags
, BGP_INFO_DMED_CHECK
))
1295 if (BGP_INFO_HOLDDOWN (ri2
))
1298 if (aspath_cmp_left (ri1
->attr
->aspath
, ri2
->attr
->aspath
)
1299 || aspath_cmp_left_confed (ri1
->attr
->aspath
,
1302 if (bgp_info_cmp (bgp
, ri2
, new_select
))
1304 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1308 bgp_info_set_flag (rn
, ri2
, BGP_INFO_DMED_CHECK
);
1311 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_CHECK
);
1312 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1315 /* Check old selected route and new selected route. */
1318 for (ri
= rn
->info
; (ri
!= NULL
) && (nextri
= ri
->next
, 1); ri
= nextri
)
1320 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1323 if (BGP_INFO_HOLDDOWN (ri
))
1325 /* reap REMOVED routes, if needs be
1326 * selected route must stay for a while longer though
1328 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
1329 && (ri
!= old_select
))
1330 bgp_info_reap (rn
, ri
);
1335 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
)
1336 && (! CHECK_FLAG (ri
->flags
, BGP_INFO_DMED_SELECTED
)))
1338 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1341 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1342 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_SELECTED
);
1344 if (bgp_info_cmp (bgp
, ri
, new_select
))
1348 result
->old
= old_select
;
1349 result
->new = new_select
;
1355 bgp_process_announce_selected (struct peer
*peer
, struct bgp_info
*selected
,
1356 struct bgp_node
*rn
, afi_t afi
, safi_t safi
)
1359 struct attr attr
= { 0 };
1363 /* Announce route to Established peer. */
1364 if (peer
->status
!= Established
)
1367 /* Address family configuration check. */
1368 if (! peer
->afc_nego
[afi
][safi
])
1371 /* First update is deferred until ORF or ROUTE-REFRESH is received */
1372 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
],
1373 PEER_STATUS_ORF_WAIT_REFRESH
))
1376 switch (rn
->table
->type
)
1378 case BGP_TABLE_MAIN
:
1379 /* Announcement to peer->conf. If the route is filtered,
1381 if (selected
&& bgp_announce_check (selected
, peer
, p
, &attr
, afi
, safi
))
1382 bgp_adj_out_set (rn
, peer
, p
, &attr
, afi
, safi
, selected
);
1384 bgp_adj_out_unset (rn
, peer
, p
, afi
, safi
);
1386 case BGP_TABLE_RSCLIENT
:
1387 /* Announcement to peer->conf. If the route is filtered,
1390 bgp_announce_check_rsclient (selected
, peer
, p
, &attr
, afi
, safi
))
1391 bgp_adj_out_set (rn
, peer
, p
, &attr
, afi
, safi
, selected
);
1393 bgp_adj_out_unset (rn
, peer
, p
, afi
, safi
);
1397 bgp_attr_extra_free (&attr
);
1402 struct bgp_process_queue
1405 struct bgp_node
*rn
;
1410 static wq_item_status
1411 bgp_process_rsclient (struct work_queue
*wq
, void *data
)
1413 struct bgp_process_queue
*pq
= data
;
1414 struct bgp
*bgp
= pq
->bgp
;
1415 struct bgp_node
*rn
= pq
->rn
;
1416 afi_t afi
= pq
->afi
;
1417 safi_t safi
= pq
->safi
;
1418 struct bgp_info
*new_select
;
1419 struct bgp_info
*old_select
;
1420 struct bgp_info_pair old_and_new
;
1421 struct listnode
*node
, *nnode
;
1422 struct peer
*rsclient
= rn
->table
->owner
;
1424 /* Best path selection. */
1425 bgp_best_selection (bgp
, rn
, &old_and_new
);
1426 new_select
= old_and_new
.new;
1427 old_select
= old_and_new
.old
;
1429 if (CHECK_FLAG (rsclient
->sflags
, PEER_STATUS_GROUP
))
1431 if (rsclient
->group
)
1432 for (ALL_LIST_ELEMENTS (rsclient
->group
->peer
, node
, nnode
, rsclient
))
1434 /* Nothing to do. */
1435 if (old_select
&& old_select
== new_select
)
1436 if (!CHECK_FLAG (old_select
->flags
, BGP_INFO_ATTR_CHANGED
))
1440 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1443 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1444 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1447 bgp_process_announce_selected (rsclient
, new_select
, rn
,
1454 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1457 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1458 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1460 bgp_process_announce_selected (rsclient
, new_select
, rn
, afi
, safi
);
1463 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
1464 bgp_info_reap (rn
, old_select
);
1466 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1470 static wq_item_status
1471 bgp_process_main (struct work_queue
*wq
, void *data
)
1473 struct bgp_process_queue
*pq
= data
;
1474 struct bgp
*bgp
= pq
->bgp
;
1475 struct bgp_node
*rn
= pq
->rn
;
1476 afi_t afi
= pq
->afi
;
1477 safi_t safi
= pq
->safi
;
1478 struct prefix
*p
= &rn
->p
;
1479 struct bgp_info
*new_select
;
1480 struct bgp_info
*old_select
;
1481 struct bgp_info_pair old_and_new
;
1482 struct listnode
*node
, *nnode
;
1485 /* Best path selection. */
1486 bgp_best_selection (bgp
, rn
, &old_and_new
);
1487 old_select
= old_and_new
.old
;
1488 new_select
= old_and_new
.new;
1490 /* Nothing to do. */
1491 if (old_select
&& old_select
== new_select
)
1493 if (! CHECK_FLAG (old_select
->flags
, BGP_INFO_ATTR_CHANGED
))
1495 if (CHECK_FLAG (old_select
->flags
, BGP_INFO_IGP_CHANGED
))
1496 bgp_zebra_announce (p
, old_select
, bgp
);
1498 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1504 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1507 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1508 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1512 /* Check each BGP peer. */
1513 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
1515 bgp_process_announce_selected (peer
, new_select
, rn
, afi
, safi
);
1519 if (safi
== SAFI_UNICAST
&& ! bgp
->name
&&
1520 ! bgp_option_check (BGP_OPT_NO_FIB
))
1523 && new_select
->type
== ZEBRA_ROUTE_BGP
1524 && new_select
->sub_type
== BGP_ROUTE_NORMAL
)
1525 bgp_zebra_announce (p
, new_select
, bgp
);
1528 /* Withdraw the route from the kernel. */
1530 && old_select
->type
== ZEBRA_ROUTE_BGP
1531 && old_select
->sub_type
== BGP_ROUTE_NORMAL
)
1532 bgp_zebra_withdraw (p
, old_select
);
1536 /* Reap old select bgp_info, it it has been removed */
1537 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
1538 bgp_info_reap (rn
, old_select
);
1540 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1545 bgp_processq_del (struct work_queue
*wq
, void *data
)
1547 struct bgp_process_queue
*pq
= data
;
1548 struct bgp_table
*table
= pq
->rn
->table
;
1550 bgp_unlock (pq
->bgp
);
1551 bgp_unlock_node (pq
->rn
);
1552 bgp_table_unlock (table
);
1553 XFREE (MTYPE_BGP_PROCESS_QUEUE
, pq
);
1557 bgp_process_queue_init (void)
1559 bm
->process_main_queue
1560 = work_queue_new (bm
->master
, "process_main_queue");
1561 bm
->process_rsclient_queue
1562 = work_queue_new (bm
->master
, "process_rsclient_queue");
1564 if ( !(bm
->process_main_queue
&& bm
->process_rsclient_queue
) )
1566 zlog_err ("%s: Failed to allocate work queue", __func__
);
1570 bm
->process_main_queue
->spec
.workfunc
= &bgp_process_main
;
1571 bm
->process_rsclient_queue
->spec
.workfunc
= &bgp_process_rsclient
;
1572 bm
->process_main_queue
->spec
.del_item_data
= &bgp_processq_del
;
1573 bm
->process_rsclient_queue
->spec
.del_item_data
1574 = bm
->process_main_queue
->spec
.del_item_data
;
1575 bm
->process_main_queue
->spec
.max_retries
1576 = bm
->process_main_queue
->spec
.max_retries
= 0;
1577 bm
->process_rsclient_queue
->spec
.hold
1578 = bm
->process_main_queue
->spec
.hold
= 50;
1582 bgp_process (struct bgp
*bgp
, struct bgp_node
*rn
, afi_t afi
, safi_t safi
)
1584 struct bgp_process_queue
*pqnode
;
1586 /* already scheduled for processing? */
1587 if (CHECK_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
))
1590 if ( (bm
->process_main_queue
== NULL
) ||
1591 (bm
->process_rsclient_queue
== NULL
) )
1592 bgp_process_queue_init ();
1594 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
1595 sizeof (struct bgp_process_queue
));
1599 /* all unlocked in bgp_processq_del */
1600 bgp_table_lock (rn
->table
);
1601 pqnode
->rn
= bgp_lock_node (rn
);
1605 pqnode
->safi
= safi
;
1607 switch (rn
->table
->type
)
1609 case BGP_TABLE_MAIN
:
1610 work_queue_add (bm
->process_main_queue
, pqnode
);
1612 case BGP_TABLE_RSCLIENT
:
1613 work_queue_add (bm
->process_rsclient_queue
, pqnode
);
1621 bgp_maximum_prefix_restart_timer (struct thread
*thread
)
1625 peer
= THREAD_ARG (thread
);
1626 peer
->t_pmax_restart
= NULL
;
1628 if (BGP_DEBUG (events
, EVENTS
))
1629 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
1638 bgp_maximum_prefix_overflow (struct peer
*peer
, afi_t afi
,
1639 safi_t safi
, int always
)
1641 if (!CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
))
1644 if (peer
->pcount
[afi
][safi
] > peer
->pmax
[afi
][safi
])
1646 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
)
1650 zlog (peer
->log
, LOG_INFO
,
1651 "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
1652 "limit %ld", afi_safi_print (afi
, safi
), peer
->host
,
1653 peer
->pcount
[afi
][safi
], peer
->pmax
[afi
][safi
]);
1654 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
1656 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_WARNING
))
1662 if (safi
== SAFI_MPLS_VPN
)
1663 safi
= BGP_SAFI_VPNV4
;
1665 ndata
[0] = (afi
>> 8);
1668 ndata
[3] = (peer
->pmax
[afi
][safi
] >> 24);
1669 ndata
[4] = (peer
->pmax
[afi
][safi
] >> 16);
1670 ndata
[5] = (peer
->pmax
[afi
][safi
] >> 8);
1671 ndata
[6] = (peer
->pmax
[afi
][safi
]);
1673 SET_FLAG (peer
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
);
1674 bgp_notify_send_with_data (peer
, BGP_NOTIFY_CEASE
,
1675 BGP_NOTIFY_CEASE_MAX_PREFIX
, ndata
, 7);
1678 /* restart timer start */
1679 if (peer
->pmax_restart
[afi
][safi
])
1681 peer
->v_pmax_restart
= peer
->pmax_restart
[afi
][safi
] * 60;
1683 if (BGP_DEBUG (events
, EVENTS
))
1684 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
1685 peer
->host
, peer
->v_pmax_restart
);
1687 BGP_TIMER_ON (peer
->t_pmax_restart
, bgp_maximum_prefix_restart_timer
,
1688 peer
->v_pmax_restart
);
1694 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
1696 if (peer
->pcount
[afi
][safi
] > (peer
->pmax
[afi
][safi
] * peer
->pmax_threshold
[afi
][safi
] / 100))
1698 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
)
1702 zlog (peer
->log
, LOG_INFO
,
1703 "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
1704 afi_safi_print (afi
, safi
), peer
->host
, peer
->pcount
[afi
][safi
],
1705 peer
->pmax
[afi
][safi
]);
1706 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
1709 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
1713 /* Unconditionally remove the route from the RIB, without taking
1714 * damping into consideration (eg, because the session went down)
1717 bgp_rib_remove (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
1718 afi_t afi
, safi_t safi
)
1720 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
1722 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
1723 bgp_info_delete (rn
, ri
); /* keep historical info */
1725 bgp_process (peer
->bgp
, rn
, afi
, safi
);
1729 bgp_rib_withdraw (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
1730 afi_t afi
, safi_t safi
)
1732 int status
= BGP_DAMP_NONE
;
1734 /* apply dampening, if result is suppressed, we'll be retaining
1735 * the bgp_info in the RIB for historical reference.
1737 if (CHECK_FLAG (peer
->bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
1738 && peer_sort (peer
) == BGP_PEER_EBGP
)
1739 if ( (status
= bgp_damp_withdraw (ri
, rn
, afi
, safi
, 0))
1740 == BGP_DAMP_SUPPRESSED
)
1742 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
1746 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
1750 bgp_update_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
,
1751 struct attr
*attr
, struct peer
*peer
, struct prefix
*p
, int type
,
1752 int sub_type
, struct prefix_rd
*prd
, u_char
*tag
)
1754 struct bgp_node
*rn
;
1756 struct attr new_attr
= { 0 };
1757 struct attr
*attr_new
;
1758 struct attr
*attr_new2
;
1759 struct bgp_info
*ri
;
1760 struct bgp_info
*new;
1762 char buf
[SU_ADDRSTRLEN
];
1764 /* Do not insert announces from a rsclient into its own 'bgp_table'. */
1765 if (peer
== rsclient
)
1769 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
1771 /* Check previously received route. */
1772 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1773 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
1776 /* AS path loop check. */
1777 if (aspath_loop_check (attr
->aspath
, rsclient
->as
) > peer
->allowas_in
[afi
][safi
])
1779 reason
= "as-path contains our own AS;";
1783 /* Route reflector originator ID check. */
1784 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
1785 && IPV4_ADDR_SAME (&rsclient
->remote_id
, &attr
->extra
->originator_id
))
1787 reason
= "originator is us;";
1791 bgp_attr_dup (&new_attr
, attr
);
1793 /* Apply export policy. */
1794 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
) &&
1795 bgp_export_modifier (rsclient
, peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
1797 reason
= "export-policy;";
1801 attr_new2
= bgp_attr_intern (&new_attr
);
1803 /* Apply import policy. */
1804 if (bgp_import_modifier (rsclient
, peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
1806 bgp_attr_unintern (attr_new2
);
1808 reason
= "import-policy;";
1812 attr_new
= bgp_attr_intern (&new_attr
);
1813 bgp_attr_unintern (attr_new2
);
1815 /* IPv4 unicast next hop check. */
1816 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
1818 /* Next hop must not be 0.0.0.0 nor Class E address. */
1819 if (new_attr
.nexthop
.s_addr
== 0
1820 || ntohl (new_attr
.nexthop
.s_addr
) >= 0xe0000000)
1822 bgp_attr_unintern (attr_new
);
1824 reason
= "martian next-hop;";
1829 /* new_attr isn't passed to any functions after here */
1830 bgp_attr_extra_free (&new_attr
);
1832 /* If the update is implicit withdraw. */
1835 ri
->uptime
= bgp_clock ();
1837 /* Same attribute comes in. */
1838 if (!CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
)
1839 && attrhash_cmp (ri
->attr
, attr_new
))
1842 bgp_info_unset_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
1844 if (BGP_DEBUG (update
, UPDATE_IN
))
1845 zlog (peer
->log
, LOG_DEBUG
,
1846 "%s rcvd %s/%d for RS-client %s...duplicate ignored",
1848 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1849 p
->prefixlen
, rsclient
->host
);
1851 bgp_unlock_node (rn
);
1852 bgp_attr_unintern (attr_new
);
1857 /* Withdraw/Announce before we fully processed the withdraw */
1858 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
1859 bgp_info_restore (rn
, ri
);
1861 /* Received Logging. */
1862 if (BGP_DEBUG (update
, UPDATE_IN
))
1863 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d for RS-client %s",
1865 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1866 p
->prefixlen
, rsclient
->host
);
1868 /* The attribute is changed. */
1869 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
1871 /* Update to new attribute. */
1872 bgp_attr_unintern (ri
->attr
);
1873 ri
->attr
= attr_new
;
1875 /* Update MPLS tag. */
1876 if (safi
== SAFI_MPLS_VPN
)
1877 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
1879 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
1881 /* Process change. */
1882 bgp_process (bgp
, rn
, afi
, safi
);
1883 bgp_unlock_node (rn
);
1888 /* Received Logging. */
1889 if (BGP_DEBUG (update
, UPDATE_IN
))
1891 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d for RS-client %s",
1893 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1894 p
->prefixlen
, rsclient
->host
);
1897 /* Make new BGP info. */
1898 new = bgp_info_new ();
1900 new->sub_type
= sub_type
;
1902 new->attr
= attr_new
;
1903 new->uptime
= bgp_clock ();
1905 /* Update MPLS tag. */
1906 if (safi
== SAFI_MPLS_VPN
)
1907 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
1909 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
1911 /* Register new BGP information. */
1912 bgp_info_add (rn
, new);
1914 /* route_node_get lock */
1915 bgp_unlock_node (rn
);
1917 /* Process change. */
1918 bgp_process (bgp
, rn
, afi
, safi
);
1920 bgp_attr_extra_free (&new_attr
);
1926 /* This BGP update is filtered. Log the reason then update BGP entry. */
1927 if (BGP_DEBUG (update
, UPDATE_IN
))
1928 zlog (peer
->log
, LOG_DEBUG
,
1929 "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s",
1931 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1932 p
->prefixlen
, rsclient
->host
, reason
);
1935 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
1937 bgp_unlock_node (rn
);
1940 bgp_attr_extra_free (&new_attr
);
1946 bgp_withdraw_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
,
1947 struct peer
*peer
, struct prefix
*p
, int type
, int sub_type
,
1948 struct prefix_rd
*prd
, u_char
*tag
)
1950 struct bgp_node
*rn
;
1951 struct bgp_info
*ri
;
1952 char buf
[SU_ADDRSTRLEN
];
1954 if (rsclient
== peer
)
1957 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
1959 /* Lookup withdrawn route. */
1960 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1961 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
1964 /* Withdraw specified route from routing table. */
1965 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
1966 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
1967 else if (BGP_DEBUG (update
, UPDATE_IN
))
1968 zlog (peer
->log
, LOG_DEBUG
,
1969 "%s Can't find the route %s/%d", peer
->host
,
1970 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1973 /* Unlock bgp_node_get() lock. */
1974 bgp_unlock_node (rn
);
1978 bgp_update_main (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
1979 afi_t afi
, safi_t safi
, int type
, int sub_type
,
1980 struct prefix_rd
*prd
, u_char
*tag
, int soft_reconfig
)
1983 int aspath_loop_count
= 0;
1984 struct bgp_node
*rn
;
1986 struct attr new_attr
= { 0 };
1987 struct attr
*attr_new
;
1988 struct bgp_info
*ri
;
1989 struct bgp_info
*new;
1991 char buf
[SU_ADDRSTRLEN
];
1994 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
1996 /* When peer's soft reconfiguration enabled. Record input packet in
1998 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
1999 && peer
!= bgp
->peer_self
&& ! soft_reconfig
)
2000 bgp_adj_in_set (rn
, peer
, attr
);
2002 /* Check previously received route. */
2003 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2004 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
2007 /* AS path local-as loop check. */
2008 if (peer
->change_local_as
)
2010 if (! CHECK_FLAG (peer
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
2011 aspath_loop_count
= 1;
2013 if (aspath_loop_check (attr
->aspath
, peer
->change_local_as
) > aspath_loop_count
)
2015 reason
= "as-path contains our own AS;";
2020 /* AS path loop check. */
2021 if (aspath_loop_check (attr
->aspath
, bgp
->as
) > peer
->allowas_in
[afi
][safi
]
2022 || (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
2023 && aspath_loop_check(attr
->aspath
, bgp
->confed_id
)
2024 > peer
->allowas_in
[afi
][safi
]))
2026 reason
= "as-path contains our own AS;";
2030 /* Route reflector originator ID check. */
2031 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
2032 && IPV4_ADDR_SAME (&bgp
->router_id
, &attr
->extra
->originator_id
))
2034 reason
= "originator is us;";
2038 /* Route reflector cluster ID check. */
2039 if (bgp_cluster_filter (peer
, attr
))
2041 reason
= "reflected from the same cluster;";
2045 /* Apply incoming filter. */
2046 if (bgp_input_filter (peer
, p
, attr
, afi
, safi
) == FILTER_DENY
)
2052 /* Apply incoming route-map. */
2053 bgp_attr_dup (&new_attr
, attr
);
2055 if (bgp_input_modifier (peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
2057 reason
= "route-map;";
2061 /* IPv4 unicast next hop check. */
2062 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2064 /* If the peer is EBGP and nexthop is not on connected route,
2066 if (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
== 1
2067 && ! bgp_nexthop_check_ebgp (afi
, &new_attr
)
2068 && ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
2070 reason
= "non-connected next-hop;";
2074 /* Next hop must not be 0.0.0.0 nor Class E address. Next hop
2075 must not be my own address. */
2076 if (bgp_nexthop_self (afi
, &new_attr
)
2077 || new_attr
.nexthop
.s_addr
== 0
2078 || ntohl (new_attr
.nexthop
.s_addr
) >= 0xe0000000)
2080 reason
= "martian next-hop;";
2085 attr_new
= bgp_attr_intern (&new_attr
);
2087 /* If the update is implicit withdraw. */
2090 ri
->uptime
= bgp_clock ();
2092 /* Same attribute comes in. */
2093 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
2094 && attrhash_cmp (ri
->attr
, attr_new
))
2096 bgp_info_unset_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2098 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2099 && peer_sort (peer
) == BGP_PEER_EBGP
2100 && CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2102 if (BGP_DEBUG (update
, UPDATE_IN
))
2103 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2105 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2108 if (bgp_damp_update (ri
, rn
, afi
, safi
) != BGP_DAMP_SUPPRESSED
)
2110 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2111 bgp_process (bgp
, rn
, afi
, safi
);
2114 else /* Duplicate - odd */
2116 if (BGP_DEBUG (update
, UPDATE_IN
))
2117 zlog (peer
->log
, LOG_DEBUG
,
2118 "%s rcvd %s/%d...duplicate ignored",
2120 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2123 /* graceful restart STALE flag unset. */
2124 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2126 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2127 bgp_process (bgp
, rn
, afi
, safi
);
2131 bgp_unlock_node (rn
);
2132 bgp_attr_unintern (attr_new
);
2133 bgp_attr_extra_free (&new_attr
);
2138 /* Withdraw/Announce before we fully processed the withdraw */
2139 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
2141 if (BGP_DEBUG (update
, UPDATE_IN
))
2142 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d, flapped quicker than processing",
2144 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2146 bgp_info_restore (rn
, ri
);
2149 /* Received Logging. */
2150 if (BGP_DEBUG (update
, UPDATE_IN
))
2151 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2153 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2156 /* graceful restart STALE flag unset. */
2157 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2158 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2160 /* The attribute is changed. */
2161 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2163 /* implicit withdraw, decrement aggregate and pcount here.
2164 * only if update is accepted, they'll increment below.
2166 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
2168 /* Update bgp route dampening information. */
2169 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2170 && peer_sort (peer
) == BGP_PEER_EBGP
)
2172 /* This is implicit withdraw so we should update dampening
2174 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2175 bgp_damp_withdraw (ri
, rn
, afi
, safi
, 1);
2178 /* Update to new attribute. */
2179 bgp_attr_unintern (ri
->attr
);
2180 ri
->attr
= attr_new
;
2182 /* Update MPLS tag. */
2183 if (safi
== SAFI_MPLS_VPN
)
2184 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
2186 /* Update bgp route dampening information. */
2187 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2188 && peer_sort (peer
) == BGP_PEER_EBGP
)
2190 /* Now we do normal update dampening. */
2191 ret
= bgp_damp_update (ri
, rn
, afi
, safi
);
2192 if (ret
== BGP_DAMP_SUPPRESSED
)
2194 bgp_unlock_node (rn
);
2195 bgp_attr_extra_free (&new_attr
);
2200 /* Nexthop reachability check. */
2201 if ((afi
== AFI_IP
|| afi
== AFI_IP6
)
2202 && safi
== SAFI_UNICAST
2203 && (peer_sort (peer
) == BGP_PEER_IBGP
2204 || peer_sort (peer
) == BGP_PEER_CONFED
2205 || (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)
2206 || CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)))
2208 if (bgp_nexthop_lookup (afi
, peer
, ri
, NULL
, NULL
))
2209 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2211 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
2214 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2216 /* Process change. */
2217 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2219 bgp_process (bgp
, rn
, afi
, safi
);
2220 bgp_unlock_node (rn
);
2221 bgp_attr_extra_free (&new_attr
);
2226 /* Received Logging. */
2227 if (BGP_DEBUG (update
, UPDATE_IN
))
2229 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2231 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2235 /* Make new BGP info. */
2236 new = bgp_info_new ();
2238 new->sub_type
= sub_type
;
2240 new->attr
= attr_new
;
2241 new->uptime
= bgp_clock ();
2243 /* Update MPLS tag. */
2244 if (safi
== SAFI_MPLS_VPN
)
2245 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
2247 /* Nexthop reachability check. */
2248 if ((afi
== AFI_IP
|| afi
== AFI_IP6
)
2249 && safi
== SAFI_UNICAST
2250 && (peer_sort (peer
) == BGP_PEER_IBGP
2251 || peer_sort (peer
) == BGP_PEER_CONFED
2252 || (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)
2253 || CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)))
2255 if (bgp_nexthop_lookup (afi
, peer
, new, NULL
, NULL
))
2256 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2258 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
2261 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2263 /* Increment prefix */
2264 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
2266 /* Register new BGP information. */
2267 bgp_info_add (rn
, new);
2269 /* route_node_get lock */
2270 bgp_unlock_node (rn
);
2272 bgp_attr_extra_free (&new_attr
);
2274 /* If maximum prefix count is configured and current prefix
2276 if (bgp_maximum_prefix_overflow (peer
, afi
, safi
, 0))
2279 /* Process change. */
2280 bgp_process (bgp
, rn
, afi
, safi
);
2284 /* This BGP update is filtered. Log the reason then update BGP
2287 if (BGP_DEBUG (update
, UPDATE_IN
))
2288 zlog (peer
->log
, LOG_DEBUG
,
2289 "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
2291 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2292 p
->prefixlen
, reason
);
2295 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2297 bgp_unlock_node (rn
);
2299 bgp_attr_extra_free (&new_attr
);
2305 bgp_update (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
2306 afi_t afi
, safi_t safi
, int type
, int sub_type
,
2307 struct prefix_rd
*prd
, u_char
*tag
, int soft_reconfig
)
2309 struct peer
*rsclient
;
2310 struct listnode
*node
, *nnode
;
2314 ret
= bgp_update_main (peer
, p
, attr
, afi
, safi
, type
, sub_type
, prd
, tag
,
2319 /* Process the update for each RS-client. */
2320 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
2322 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2323 bgp_update_rsclient (rsclient
, afi
, safi
, attr
, peer
, p
, type
,
2324 sub_type
, prd
, tag
);
2331 bgp_withdraw (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
2332 afi_t afi
, safi_t safi
, int type
, int sub_type
,
2333 struct prefix_rd
*prd
, u_char
*tag
)
2336 char buf
[SU_ADDRSTRLEN
];
2337 struct bgp_node
*rn
;
2338 struct bgp_info
*ri
;
2339 struct peer
*rsclient
;
2340 struct listnode
*node
, *nnode
;
2344 /* Process the withdraw for each RS-client. */
2345 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
2347 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2348 bgp_withdraw_rsclient (rsclient
, afi
, safi
, peer
, p
, type
, sub_type
, prd
, tag
);
2352 if (BGP_DEBUG (update
, UPDATE_IN
))
2353 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd UPDATE about %s/%d -- withdrawn",
2355 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2359 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2361 /* If peer is soft reconfiguration enabled. Record input packet for
2362 further calculation. */
2363 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2364 && peer
!= bgp
->peer_self
)
2365 bgp_adj_in_unset (rn
, peer
);
2367 /* Lookup withdrawn route. */
2368 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2369 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
2372 /* Withdraw specified route from routing table. */
2373 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2374 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
2375 else if (BGP_DEBUG (update
, UPDATE_IN
))
2376 zlog (peer
->log
, LOG_DEBUG
,
2377 "%s Can't find the route %s/%d", peer
->host
,
2378 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2381 /* Unlock bgp_node_get() lock. */
2382 bgp_unlock_node (rn
);
2388 bgp_default_originate (struct peer
*peer
, afi_t afi
, safi_t safi
, int withdraw
)
2391 struct attr attr
= { 0 };
2392 struct aspath
*aspath
= { 0 };
2394 struct bgp_info binfo
;
2396 int ret
= RMAP_DENYMATCH
;
2398 if (!(afi
== AFI_IP
|| afi
== AFI_IP6
))
2402 from
= bgp
->peer_self
;
2404 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
2405 aspath
= attr
.aspath
;
2406 attr
.local_pref
= bgp
->default_local_pref
;
2407 memcpy (&attr
.nexthop
, &peer
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
2410 str2prefix ("0.0.0.0/0", &p
);
2412 else if (afi
== AFI_IP6
)
2414 struct attr_extra
*ae
;
2417 ae
= bgp_attr_extra_get (&attr
);
2420 str2prefix ("::/0", &p
);
2422 /* IPv6 global nexthop must be included. */
2423 memcpy (&ae
->mp_nexthop_global
, &peer
->nexthop
.v6_global
,
2425 ae
->mp_nexthop_len
= 16;
2427 /* If the peer is on shared nextwork and we have link-local
2429 if (peer
->shared_network
2430 && !IN6_IS_ADDR_UNSPECIFIED (&peer
->nexthop
.v6_local
))
2432 memcpy (&ae
->mp_nexthop_local
, &peer
->nexthop
.v6_local
,
2434 ae
->mp_nexthop_len
= 32;
2437 #endif /* HAVE_IPV6 */
2439 if (peer
->default_rmap
[afi
][safi
].name
)
2441 binfo
.peer
= bgp
->peer_self
;
2444 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_DEFAULT
);
2446 ret
= route_map_apply (peer
->default_rmap
[afi
][safi
].map
, &p
,
2449 bgp
->peer_self
->rmap_type
= 0;
2451 if (ret
== RMAP_DENYMATCH
)
2453 bgp_attr_flush (&attr
);
2460 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
))
2461 bgp_default_withdraw_send (peer
, afi
, safi
);
2462 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
);
2466 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
);
2467 bgp_default_update_send (peer
, &attr
, afi
, safi
, from
);
2470 bgp_attr_extra_free (&attr
);
2471 aspath_unintern (aspath
);
2475 bgp_announce_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2476 struct bgp_table
*table
, int rsclient
)
2478 struct bgp_node
*rn
;
2479 struct bgp_info
*ri
;
2480 struct attr attr
= { 0 };
2483 table
= (rsclient
) ? peer
->rib
[afi
][safi
] : peer
->bgp
->rib
[afi
][safi
];
2485 if (safi
!= SAFI_MPLS_VPN
2486 && CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_DEFAULT_ORIGINATE
))
2487 bgp_default_originate (peer
, afi
, safi
, 0);
2489 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next(rn
))
2490 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2491 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
) && ri
->peer
!= peer
)
2494 (bgp_announce_check_rsclient (ri
, peer
, &rn
->p
, &attr
, afi
, safi
))
2495 : (bgp_announce_check (ri
, peer
, &rn
->p
, &attr
, afi
, safi
)))
2496 bgp_adj_out_set (rn
, peer
, &rn
->p
, &attr
, afi
, safi
, ri
);
2498 bgp_adj_out_unset (rn
, peer
, &rn
->p
, afi
, safi
);
2500 bgp_attr_extra_free (&attr
);
2505 bgp_announce_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2507 struct bgp_node
*rn
;
2508 struct bgp_table
*table
;
2510 if (peer
->status
!= Established
)
2513 if (! peer
->afc_nego
[afi
][safi
])
2516 /* First update is deferred until ORF or ROUTE-REFRESH is received */
2517 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_ORF_WAIT_REFRESH
))
2520 if (safi
!= SAFI_MPLS_VPN
)
2521 bgp_announce_table (peer
, afi
, safi
, NULL
, 0);
2523 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2524 rn
= bgp_route_next(rn
))
2525 if ((table
= (rn
->info
)) != NULL
)
2526 bgp_announce_table (peer
, afi
, safi
, table
, 0);
2528 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2529 bgp_announce_table (peer
, afi
, safi
, NULL
, 1);
2533 bgp_announce_route_all (struct peer
*peer
)
2538 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2539 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2540 bgp_announce_route (peer
, afi
, safi
);
2544 bgp_soft_reconfig_table_rsclient (struct peer
*rsclient
, afi_t afi
,
2545 safi_t safi
, struct bgp_table
*table
)
2547 struct bgp_node
*rn
;
2548 struct bgp_adj_in
*ain
;
2551 table
= rsclient
->bgp
->rib
[afi
][safi
];
2553 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2554 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2556 bgp_update_rsclient (rsclient
, afi
, safi
, ain
->attr
, ain
->peer
,
2557 &rn
->p
, ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
2562 bgp_soft_reconfig_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
)
2564 struct bgp_table
*table
;
2565 struct bgp_node
*rn
;
2567 if (safi
!= SAFI_MPLS_VPN
)
2568 bgp_soft_reconfig_table_rsclient (rsclient
, afi
, safi
, NULL
);
2571 for (rn
= bgp_table_top (rsclient
->bgp
->rib
[afi
][safi
]); rn
;
2572 rn
= bgp_route_next (rn
))
2573 if ((table
= rn
->info
) != NULL
)
2574 bgp_soft_reconfig_table_rsclient (rsclient
, afi
, safi
, table
);
2578 bgp_soft_reconfig_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2579 struct bgp_table
*table
)
2582 struct bgp_node
*rn
;
2583 struct bgp_adj_in
*ain
;
2586 table
= peer
->bgp
->rib
[afi
][safi
];
2588 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2589 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2591 if (ain
->peer
== peer
)
2593 ret
= bgp_update (peer
, &rn
->p
, ain
->attr
, afi
, safi
,
2594 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
,
2598 bgp_unlock_node (rn
);
2607 bgp_soft_reconfig_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2609 struct bgp_node
*rn
;
2610 struct bgp_table
*table
;
2612 if (peer
->status
!= Established
)
2615 if (safi
!= SAFI_MPLS_VPN
)
2616 bgp_soft_reconfig_table (peer
, afi
, safi
, NULL
);
2618 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2619 rn
= bgp_route_next (rn
))
2620 if ((table
= rn
->info
) != NULL
)
2621 bgp_soft_reconfig_table (peer
, afi
, safi
, table
);
2625 struct bgp_clear_node_queue
2627 struct bgp_node
*rn
;
2628 enum bgp_clear_route_type purpose
;
2631 static wq_item_status
2632 bgp_clear_route_node (struct work_queue
*wq
, void *data
)
2634 struct bgp_clear_node_queue
*cnq
= data
;
2635 struct bgp_node
*rn
= cnq
->rn
;
2636 struct peer
*peer
= wq
->spec
.data
;
2637 struct bgp_info
*ri
;
2638 afi_t afi
= rn
->table
->afi
;
2639 safi_t safi
= rn
->table
->safi
;
2641 assert (rn
&& peer
);
2643 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2644 if (ri
->peer
== peer
|| cnq
->purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2646 /* graceful restart STALE flag set. */
2647 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_NSF_WAIT
)
2648 && peer
->nsf
[afi
][safi
]
2649 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
)
2650 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
2651 bgp_info_set_flag (rn
, ri
, BGP_INFO_STALE
);
2653 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2660 bgp_clear_node_queue_del (struct work_queue
*wq
, void *data
)
2662 struct bgp_clear_node_queue
*cnq
= data
;
2663 struct bgp_node
*rn
= cnq
->rn
;
2664 struct bgp_table
*table
= rn
->table
;
2666 bgp_unlock_node (rn
);
2667 bgp_table_unlock (table
);
2668 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE
, cnq
);
2672 bgp_clear_node_complete (struct work_queue
*wq
)
2674 struct peer
*peer
= wq
->spec
.data
;
2676 /* Tickle FSM to start moving again */
2677 BGP_EVENT_ADD (peer
, Clearing_Completed
);
2679 peer_unlock (peer
); /* bgp_clear_route */
2683 bgp_clear_node_queue_init (struct peer
*peer
)
2685 char wname
[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
2687 snprintf (wname
, sizeof(wname
), "clear %s", peer
->host
);
2688 #undef CLEAR_QUEUE_NAME_LEN
2690 if ( (peer
->clear_node_queue
= work_queue_new (bm
->master
, wname
)) == NULL
)
2692 zlog_err ("%s: Failed to allocate work queue", __func__
);
2695 peer
->clear_node_queue
->spec
.hold
= 10;
2696 peer
->clear_node_queue
->spec
.workfunc
= &bgp_clear_route_node
;
2697 peer
->clear_node_queue
->spec
.del_item_data
= &bgp_clear_node_queue_del
;
2698 peer
->clear_node_queue
->spec
.completion_func
= &bgp_clear_node_complete
;
2699 peer
->clear_node_queue
->spec
.max_retries
= 0;
2701 /* we only 'lock' this peer reference when the queue is actually active */
2702 peer
->clear_node_queue
->spec
.data
= peer
;
2706 bgp_clear_route_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2707 struct bgp_table
*table
, struct peer
*rsclient
,
2708 enum bgp_clear_route_type purpose
)
2710 struct bgp_node
*rn
;
2714 table
= (rsclient
) ? rsclient
->rib
[afi
][safi
] : peer
->bgp
->rib
[afi
][safi
];
2716 /* If still no table => afi/safi isn't configured at all or smth. */
2720 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2722 struct bgp_info
*ri
;
2723 struct bgp_adj_in
*ain
;
2724 struct bgp_adj_out
*aout
;
2726 if (rn
->info
== NULL
)
2729 /* XXX:TODO: This is suboptimal, every non-empty route_node is
2730 * queued for every clearing peer, regardless of whether it is
2731 * relevant to the peer at hand.
2733 * Overview: There are 3 different indices which need to be
2734 * scrubbed, potentially, when a peer is removed:
2736 * 1 peer's routes visible via the RIB (ie accepted routes)
2737 * 2 peer's routes visible by the (optional) peer's adj-in index
2738 * 3 other routes visible by the peer's adj-out index
2740 * 3 there is no hurry in scrubbing, once the struct peer is
2741 * removed from bgp->peer, we could just GC such deleted peer's
2742 * adj-outs at our leisure.
2744 * 1 and 2 must be 'scrubbed' in some way, at least made
2745 * invisible via RIB index before peer session is allowed to be
2746 * brought back up. So one needs to know when such a 'search' is
2751 * - there'd be a single global queue or a single RIB walker
2752 * - rather than tracking which route_nodes still need to be
2753 * examined on a peer basis, we'd track which peers still
2756 * Given that our per-peer prefix-counts now should be reliable,
2757 * this may actually be achievable. It doesn't seem to be a huge
2758 * problem at this time,
2760 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2761 if (ri
->peer
== peer
|| purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2763 struct bgp_clear_node_queue
*cnq
;
2765 /* both unlocked in bgp_clear_node_queue_del */
2766 bgp_table_lock (rn
->table
);
2768 cnq
= XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE
,
2769 sizeof (struct bgp_clear_node_queue
));
2771 cnq
->purpose
= purpose
;
2772 work_queue_add (peer
->clear_node_queue
, cnq
);
2776 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2777 if (ain
->peer
== peer
|| purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2779 bgp_adj_in_remove (rn
, ain
);
2780 bgp_unlock_node (rn
);
2783 for (aout
= rn
->adj_out
; aout
; aout
= aout
->next
)
2784 if (aout
->peer
== peer
|| purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2786 bgp_adj_out_remove (rn
, aout
, peer
, afi
, safi
);
2787 bgp_unlock_node (rn
);
2795 bgp_clear_route (struct peer
*peer
, afi_t afi
, safi_t safi
,
2796 enum bgp_clear_route_type purpose
)
2798 struct bgp_node
*rn
;
2799 struct bgp_table
*table
;
2800 struct peer
*rsclient
;
2801 struct listnode
*node
, *nnode
;
2803 if (peer
->clear_node_queue
== NULL
)
2804 bgp_clear_node_queue_init (peer
);
2806 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
2807 * Idle until it receives a Clearing_Completed event. This protects
2808 * against peers which flap faster than we can we clear, which could
2811 * a) race with routes from the new session being installed before
2812 * clear_route_node visits the node (to delete the route of that
2814 * b) resource exhaustion, clear_route_node likely leads to an entry
2815 * on the process_main queue. Fast-flapping could cause that queue
2818 if (!peer
->clear_node_queue
->thread
)
2819 peer_lock (peer
); /* bgp_clear_node_complete */
2823 case BGP_CLEAR_ROUTE_NORMAL
:
2824 if (safi
!= SAFI_MPLS_VPN
)
2825 bgp_clear_route_table (peer
, afi
, safi
, NULL
, NULL
, purpose
);
2827 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2828 rn
= bgp_route_next (rn
))
2829 if ((table
= rn
->info
) != NULL
)
2830 bgp_clear_route_table (peer
, afi
, safi
, table
, NULL
, purpose
);
2832 for (ALL_LIST_ELEMENTS (peer
->bgp
->rsclient
, node
, nnode
, rsclient
))
2833 if (CHECK_FLAG(rsclient
->af_flags
[afi
][safi
],
2834 PEER_FLAG_RSERVER_CLIENT
))
2835 bgp_clear_route_table (peer
, afi
, safi
, NULL
, rsclient
, purpose
);
2838 case BGP_CLEAR_ROUTE_MY_RSCLIENT
:
2839 bgp_clear_route_table (peer
, afi
, safi
, NULL
, peer
, purpose
);
2847 /* If no routes were cleared, nothing was added to workqueue, the
2848 * completion function won't be run by workqueue code - call it here.
2849 * XXX: Actually, this assumption doesn't hold, see
2850 * bgp_clear_route_table(), we queue all non-empty nodes.
2852 * Additionally, there is a presumption in FSM that clearing is only
2853 * really needed if peer state is Established - peers in
2854 * pre-Established states shouldn't have any route-update state
2855 * associated with them (in or out).
2857 * We still can get here in pre-Established though, through
2858 * peer_delete -> bgp_fsm_change_status, so this is a useful sanity
2859 * check to ensure the assumption above holds.
2861 * At some future point, this check could be move to the top of the
2862 * function, and do a quick early-return when state is
2863 * pre-Established, avoiding above list and table scans. Once we're
2866 if (!peer
->clear_node_queue
->thread
)
2867 bgp_clear_node_complete (peer
->clear_node_queue
);
2871 bgp_clear_route_all (struct peer
*peer
)
2876 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2877 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2878 bgp_clear_route (peer
, afi
, safi
, BGP_CLEAR_ROUTE_NORMAL
);
2882 bgp_clear_adj_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2884 struct bgp_table
*table
;
2885 struct bgp_node
*rn
;
2886 struct bgp_adj_in
*ain
;
2888 table
= peer
->bgp
->rib
[afi
][safi
];
2890 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2891 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2892 if (ain
->peer
== peer
)
2894 bgp_adj_in_remove (rn
, ain
);
2895 bgp_unlock_node (rn
);
2901 bgp_clear_stale_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2903 struct bgp_node
*rn
;
2904 struct bgp_info
*ri
;
2905 struct bgp_table
*table
;
2907 table
= peer
->bgp
->rib
[afi
][safi
];
2909 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2911 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2912 if (ri
->peer
== peer
)
2914 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2915 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2921 /* Delete all kernel routes. */
2923 bgp_cleanup_routes (void)
2926 struct listnode
*node
, *nnode
;
2927 struct bgp_node
*rn
;
2928 struct bgp_table
*table
;
2929 struct bgp_info
*ri
;
2931 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
2933 table
= bgp
->rib
[AFI_IP
][SAFI_UNICAST
];
2935 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2936 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2937 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
2938 && ri
->type
== ZEBRA_ROUTE_BGP
2939 && ri
->sub_type
== BGP_ROUTE_NORMAL
)
2940 bgp_zebra_withdraw (&rn
->p
, ri
);
2942 table
= bgp
->rib
[AFI_IP6
][SAFI_UNICAST
];
2944 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2945 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2946 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
2947 && ri
->type
== ZEBRA_ROUTE_BGP
2948 && ri
->sub_type
== BGP_ROUTE_NORMAL
)
2949 bgp_zebra_withdraw (&rn
->p
, ri
);
2957 bgp_zclient_reset ();
2958 access_list_reset ();
2959 prefix_list_reset ();
2962 /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
2965 bgp_nlri_parse (struct peer
*peer
, struct attr
*attr
, struct bgp_nlri
*packet
)
2973 /* Check peer status. */
2974 if (peer
->status
!= Established
)
2978 lim
= pnt
+ packet
->length
;
2980 for (; pnt
< lim
; pnt
+= psize
)
2982 /* Clear prefix structure. */
2983 memset (&p
, 0, sizeof (struct prefix
));
2985 /* Fetch prefix length. */
2986 p
.prefixlen
= *pnt
++;
2987 p
.family
= afi2family (packet
->afi
);
2989 /* Already checked in nlri_sanity_check(). We do double check
2991 if ((packet
->afi
== AFI_IP
&& p
.prefixlen
> 32)
2992 || (packet
->afi
== AFI_IP6
&& p
.prefixlen
> 128))
2995 /* Packet size overflow check. */
2996 psize
= PSIZE (p
.prefixlen
);
2998 /* When packet overflow occur return immediately. */
2999 if (pnt
+ psize
> lim
)
3002 /* Fetch prefix from NLRI packet. */
3003 memcpy (&p
.u
.prefix
, pnt
, psize
);
3005 /* Check address. */
3006 if (packet
->afi
== AFI_IP
&& packet
->safi
== SAFI_UNICAST
)
3008 if (IN_CLASSD (ntohl (p
.u
.prefix4
.s_addr
)))
3011 * From draft-ietf-idr-bgp4-22, Section 6.3:
3012 * If a BGP router receives an UPDATE message with a
3013 * semantically incorrect NLRI field, in which a prefix is
3014 * semantically incorrect (eg. an unexpected multicast IP
3015 * address), it should ignore the prefix.
3017 zlog (peer
->log
, LOG_ERR
,
3018 "IPv4 unicast NLRI is multicast address %s",
3019 inet_ntoa (p
.u
.prefix4
));
3026 /* Check address. */
3027 if (packet
->afi
== AFI_IP6
&& packet
->safi
== SAFI_UNICAST
)
3029 if (IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3033 zlog (peer
->log
, LOG_WARNING
,
3034 "IPv6 link-local NLRI received %s ignore this NLRI",
3035 inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3040 #endif /* HAVE_IPV6 */
3042 /* Normal process. */
3044 ret
= bgp_update (peer
, &p
, attr
, packet
->afi
, packet
->safi
,
3045 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
3047 ret
= bgp_withdraw (peer
, &p
, attr
, packet
->afi
, packet
->safi
,
3048 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
3050 /* Address family configuration mismatch or maximum-prefix count
3056 /* Packet length consistency check. */
3063 /* NLRI encode syntax check routine. */
3065 bgp_nlri_sanity_check (struct peer
*peer
, int afi
, u_char
*pnt
,
3074 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
3075 syntactic validity. If the field is syntactically incorrect,
3076 then the Error Subcode is set to Invalid Network Field. */
3082 /* Prefix length check. */
3083 if ((afi
== AFI_IP
&& prefixlen
> 32)
3084 || (afi
== AFI_IP6
&& prefixlen
> 128))
3086 plog_err (peer
->log
,
3087 "%s [Error] Update packet error (wrong prefix length %d)",
3088 peer
->host
, prefixlen
);
3089 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3090 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3094 /* Packet size overflow check. */
3095 psize
= PSIZE (prefixlen
);
3097 if (pnt
+ psize
> end
)
3099 plog_err (peer
->log
,
3100 "%s [Error] Update packet error"
3101 " (prefix data overflow prefix size is %d)",
3103 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3104 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3111 /* Packet length consistency check. */
3114 plog_err (peer
->log
,
3115 "%s [Error] Update packet error"
3116 " (prefix length mismatch with total length)",
3118 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3119 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3125 static struct bgp_static
*
3126 bgp_static_new (void)
3128 return XCALLOC (MTYPE_BGP_STATIC
, sizeof (struct bgp_static
));
3132 bgp_static_free (struct bgp_static
*bgp_static
)
3134 if (bgp_static
->rmap
.name
)
3135 free (bgp_static
->rmap
.name
);
3136 XFREE (MTYPE_BGP_STATIC
, bgp_static
);
3140 bgp_static_withdraw_rsclient (struct bgp
*bgp
, struct peer
*rsclient
,
3141 struct prefix
*p
, afi_t afi
, safi_t safi
)
3143 struct bgp_node
*rn
;
3144 struct bgp_info
*ri
;
3146 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3148 /* Check selected route and self inserted route. */
3149 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3150 if (ri
->peer
== bgp
->peer_self
3151 && ri
->type
== ZEBRA_ROUTE_BGP
3152 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3155 /* Withdraw static BGP route from routing table. */
3158 bgp_info_delete (rn
, ri
);
3159 bgp_process (bgp
, rn
, afi
, safi
);
3162 /* Unlock bgp_node_lookup. */
3163 bgp_unlock_node (rn
);
3167 bgp_static_update_rsclient (struct peer
*rsclient
, struct prefix
*p
,
3168 struct bgp_static
*bgp_static
,
3169 afi_t afi
, safi_t safi
)
3171 struct bgp_node
*rn
;
3172 struct bgp_info
*ri
;
3173 struct bgp_info
*new;
3174 struct bgp_info info
;
3175 struct attr
*attr_new
;
3176 struct attr attr
= {0 };
3177 struct attr new_attr
= { .extra
= 0 };
3180 char buf
[SU_ADDRSTRLEN
];
3182 bgp
= rsclient
->bgp
;
3184 assert (bgp_static
);
3188 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3190 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3192 attr
.nexthop
= bgp_static
->igpnexthop
;
3193 attr
.med
= bgp_static
->igpmetric
;
3194 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3196 if (bgp_static
->atomic
)
3197 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3199 /* Apply network route-map for export to this rsclient. */
3200 if (bgp_static
->rmap
.name
)
3202 struct attr attr_tmp
= attr
;
3203 info
.peer
= rsclient
;
3204 info
.attr
= &attr_tmp
;
3206 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_EXPORT
);
3207 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3209 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3211 rsclient
->rmap_type
= 0;
3213 if (ret
== RMAP_DENYMATCH
)
3215 /* Free uninterned attribute. */
3216 bgp_attr_flush (&attr_tmp
);
3218 /* Unintern original. */
3219 aspath_unintern (attr
.aspath
);
3220 bgp_static_withdraw_rsclient (bgp
, rsclient
, p
, afi
, safi
);
3221 bgp_attr_extra_free (&attr
);
3225 attr_new
= bgp_attr_intern (&attr_tmp
);
3228 attr_new
= bgp_attr_intern (&attr
);
3230 new_attr
= *attr_new
;
3232 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3234 if (bgp_import_modifier (rsclient
, bgp
->peer_self
, p
, &new_attr
, afi
, safi
)
3237 /* This BGP update is filtered. Log the reason then update BGP entry. */
3238 if (BGP_DEBUG (update
, UPDATE_IN
))
3239 zlog (rsclient
->log
, LOG_DEBUG
,
3240 "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
3241 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
3242 p
->prefixlen
, rsclient
->host
);
3244 bgp
->peer_self
->rmap_type
= 0;
3246 bgp_attr_unintern (attr_new
);
3247 aspath_unintern (attr
.aspath
);
3248 bgp_attr_extra_free (&attr
);
3250 bgp_static_withdraw_rsclient (bgp
, rsclient
, p
, afi
, safi
);
3255 bgp
->peer_self
->rmap_type
= 0;
3257 bgp_attr_unintern (attr_new
);
3258 attr_new
= bgp_attr_intern (&new_attr
);
3260 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3261 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3262 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3267 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3268 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3270 bgp_unlock_node (rn
);
3271 bgp_attr_unintern (attr_new
);
3272 aspath_unintern (attr
.aspath
);
3273 bgp_attr_extra_free (&attr
);
3278 /* The attribute is changed. */
3279 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3281 /* Rewrite BGP route information. */
3282 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3283 bgp_info_restore(rn
, ri
);
3284 bgp_attr_unintern (ri
->attr
);
3285 ri
->attr
= attr_new
;
3286 ri
->uptime
= bgp_clock ();
3288 /* Process change. */
3289 bgp_process (bgp
, rn
, afi
, safi
);
3290 bgp_unlock_node (rn
);
3291 aspath_unintern (attr
.aspath
);
3292 bgp_attr_extra_free (&attr
);
3297 /* Make new BGP info. */
3298 new = bgp_info_new ();
3299 new->type
= ZEBRA_ROUTE_BGP
;
3300 new->sub_type
= BGP_ROUTE_STATIC
;
3301 new->peer
= bgp
->peer_self
;
3302 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3303 new->attr
= attr_new
;
3304 new->uptime
= bgp_clock ();
3306 /* Register new BGP information. */
3307 bgp_info_add (rn
, new);
3309 /* route_node_get lock */
3310 bgp_unlock_node (rn
);
3312 /* Process change. */
3313 bgp_process (bgp
, rn
, afi
, safi
);
3315 /* Unintern original. */
3316 aspath_unintern (attr
.aspath
);
3317 bgp_attr_extra_free (&attr
);
3321 bgp_static_update_main (struct bgp
*bgp
, struct prefix
*p
,
3322 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3324 struct bgp_node
*rn
;
3325 struct bgp_info
*ri
;
3326 struct bgp_info
*new;
3327 struct bgp_info info
;
3328 struct attr attr
= { 0 };
3329 struct attr
*attr_new
;
3332 assert (bgp_static
);
3336 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3338 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3340 attr
.nexthop
= bgp_static
->igpnexthop
;
3341 attr
.med
= bgp_static
->igpmetric
;
3342 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3344 if (bgp_static
->atomic
)
3345 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3347 /* Apply route-map. */
3348 if (bgp_static
->rmap
.name
)
3350 struct attr attr_tmp
= attr
;
3351 info
.peer
= bgp
->peer_self
;
3352 info
.attr
= &attr_tmp
;
3354 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3356 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3358 bgp
->peer_self
->rmap_type
= 0;
3360 if (ret
== RMAP_DENYMATCH
)
3362 /* Free uninterned attribute. */
3363 bgp_attr_flush (&attr_tmp
);
3365 /* Unintern original. */
3366 aspath_unintern (attr
.aspath
);
3367 bgp_attr_extra_free (&attr
);
3368 bgp_static_withdraw (bgp
, p
, afi
, safi
);
3371 attr_new
= bgp_attr_intern (&attr_tmp
);
3374 attr_new
= bgp_attr_intern (&attr
);
3376 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3377 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3378 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3383 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3384 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3386 bgp_unlock_node (rn
);
3387 bgp_attr_unintern (attr_new
);
3388 aspath_unintern (attr
.aspath
);
3389 bgp_attr_extra_free (&attr
);
3394 /* The attribute is changed. */
3395 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3397 /* Rewrite BGP route information. */
3398 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3399 bgp_info_restore(rn
, ri
);
3401 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3402 bgp_attr_unintern (ri
->attr
);
3403 ri
->attr
= attr_new
;
3404 ri
->uptime
= bgp_clock ();
3406 /* Process change. */
3407 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3408 bgp_process (bgp
, rn
, afi
, safi
);
3409 bgp_unlock_node (rn
);
3410 aspath_unintern (attr
.aspath
);
3411 bgp_attr_extra_free (&attr
);
3416 /* Make new BGP info. */
3417 new = bgp_info_new ();
3418 new->type
= ZEBRA_ROUTE_BGP
;
3419 new->sub_type
= BGP_ROUTE_STATIC
;
3420 new->peer
= bgp
->peer_self
;
3421 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3422 new->attr
= attr_new
;
3423 new->uptime
= bgp_clock ();
3425 /* Aggregate address increment. */
3426 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3428 /* Register new BGP information. */
3429 bgp_info_add (rn
, new);
3431 /* route_node_get lock */
3432 bgp_unlock_node (rn
);
3434 /* Process change. */
3435 bgp_process (bgp
, rn
, afi
, safi
);
3437 /* Unintern original. */
3438 aspath_unintern (attr
.aspath
);
3439 bgp_attr_extra_free (&attr
);
3443 bgp_static_update (struct bgp
*bgp
, struct prefix
*p
,
3444 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3446 struct peer
*rsclient
;
3447 struct listnode
*node
, *nnode
;
3449 bgp_static_update_main (bgp
, p
, bgp_static
, afi
, safi
);
3451 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
3453 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
3454 bgp_static_update_rsclient (rsclient
, p
, bgp_static
, afi
, safi
);
3459 bgp_static_update_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3460 safi_t safi
, struct prefix_rd
*prd
, u_char
*tag
)
3462 struct bgp_node
*rn
;
3463 struct bgp_info
*new;
3465 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3467 /* Make new BGP info. */
3468 new = bgp_info_new ();
3469 new->type
= ZEBRA_ROUTE_BGP
;
3470 new->sub_type
= BGP_ROUTE_STATIC
;
3471 new->peer
= bgp
->peer_self
;
3472 new->attr
= bgp_attr_default_intern (BGP_ORIGIN_IGP
);
3473 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3474 new->uptime
= bgp_clock ();
3475 new->extra
= bgp_info_extra_new();
3476 memcpy (new->extra
->tag
, tag
, 3);
3478 /* Aggregate address increment. */
3479 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3481 /* Register new BGP information. */
3482 bgp_info_add (rn
, new);
3484 /* route_node_get lock */
3485 bgp_unlock_node (rn
);
3487 /* Process change. */
3488 bgp_process (bgp
, rn
, afi
, safi
);
3492 bgp_static_withdraw (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3495 struct bgp_node
*rn
;
3496 struct bgp_info
*ri
;
3498 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3500 /* Check selected route and self inserted route. */
3501 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3502 if (ri
->peer
== bgp
->peer_self
3503 && ri
->type
== ZEBRA_ROUTE_BGP
3504 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3507 /* Withdraw static BGP route from routing table. */
3510 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3511 bgp_info_delete (rn
, ri
);
3512 bgp_process (bgp
, rn
, afi
, safi
);
3515 /* Unlock bgp_node_lookup. */
3516 bgp_unlock_node (rn
);
3520 bgp_check_local_routes_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
)
3522 struct bgp_static
*bgp_static
;
3524 struct bgp_node
*rn
;
3527 bgp
= rsclient
->bgp
;
3529 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3530 if ((bgp_static
= rn
->info
) != NULL
)
3534 bgp_static_update_rsclient (rsclient
, p
, bgp_static
,
3540 bgp_static_withdraw_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3541 safi_t safi
, struct prefix_rd
*prd
, u_char
*tag
)
3543 struct bgp_node
*rn
;
3544 struct bgp_info
*ri
;
3546 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3548 /* Check selected route and self inserted route. */
3549 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3550 if (ri
->peer
== bgp
->peer_self
3551 && ri
->type
== ZEBRA_ROUTE_BGP
3552 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3555 /* Withdraw static BGP route from routing table. */
3558 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3559 bgp_info_delete (rn
, ri
);
3560 bgp_process (bgp
, rn
, afi
, safi
);
3563 /* Unlock bgp_node_lookup. */
3564 bgp_unlock_node (rn
);
3567 /* Configure static BGP network. When user don't run zebra, static
3568 route should be installed as valid. */
3570 bgp_static_set (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3571 afi_t afi
, safi_t safi
, const char *rmap
, int backdoor
)
3575 struct bgp_static
*bgp_static
;
3576 struct bgp_node
*rn
;
3577 u_char need_update
= 0;
3579 /* Convert IP prefix string to struct prefix. */
3580 ret
= str2prefix (ip_str
, &p
);
3583 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3587 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3589 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3593 #endif /* HAVE_IPV6 */
3597 /* Set BGP static route configuration. */
3598 rn
= bgp_node_get (bgp
->route
[afi
][safi
], &p
);
3602 /* Configuration change. */
3603 bgp_static
= rn
->info
;
3605 /* Check previous routes are installed into BGP. */
3606 if (bgp_static
->valid
&& bgp_static
->backdoor
!= backdoor
)
3609 bgp_static
->backdoor
= backdoor
;
3613 if (bgp_static
->rmap
.name
)
3614 free (bgp_static
->rmap
.name
);
3615 bgp_static
->rmap
.name
= strdup (rmap
);
3616 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3620 if (bgp_static
->rmap
.name
)
3621 free (bgp_static
->rmap
.name
);
3622 bgp_static
->rmap
.name
= NULL
;
3623 bgp_static
->rmap
.map
= NULL
;
3624 bgp_static
->valid
= 0;
3626 bgp_unlock_node (rn
);
3630 /* New configuration. */
3631 bgp_static
= bgp_static_new ();
3632 bgp_static
->backdoor
= backdoor
;
3633 bgp_static
->valid
= 0;
3634 bgp_static
->igpmetric
= 0;
3635 bgp_static
->igpnexthop
.s_addr
= 0;
3639 if (bgp_static
->rmap
.name
)
3640 free (bgp_static
->rmap
.name
);
3641 bgp_static
->rmap
.name
= strdup (rmap
);
3642 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3644 rn
->info
= bgp_static
;
3647 /* If BGP scan is not enabled, we should install this route here. */
3648 if (! bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3650 bgp_static
->valid
= 1;
3653 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3655 if (! bgp_static
->backdoor
)
3656 bgp_static_update (bgp
, &p
, bgp_static
, afi
, safi
);
3662 /* Configure static BGP network. */
3664 bgp_static_unset (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3665 afi_t afi
, safi_t safi
)
3669 struct bgp_static
*bgp_static
;
3670 struct bgp_node
*rn
;
3672 /* Convert IP prefix string to struct prefix. */
3673 ret
= str2prefix (ip_str
, &p
);
3676 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3680 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3682 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3686 #endif /* HAVE_IPV6 */
3690 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], &p
);
3693 vty_out (vty
, "%% Can't find specified static route configuration.%s",
3698 bgp_static
= rn
->info
;
3700 /* Update BGP RIB. */
3701 if (! bgp_static
->backdoor
)
3702 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3704 /* Clear configuration. */
3705 bgp_static_free (bgp_static
);
3707 bgp_unlock_node (rn
);
3708 bgp_unlock_node (rn
);
3713 /* Called from bgp_delete(). Delete all static routes from the BGP
3716 bgp_static_delete (struct bgp
*bgp
)
3720 struct bgp_node
*rn
;
3721 struct bgp_node
*rm
;
3722 struct bgp_table
*table
;
3723 struct bgp_static
*bgp_static
;
3725 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3726 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3727 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3728 if (rn
->info
!= NULL
)
3730 if (safi
== SAFI_MPLS_VPN
)
3734 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
3736 bgp_static
= rn
->info
;
3737 bgp_static_withdraw_vpnv4 (bgp
, &rm
->p
,
3738 AFI_IP
, SAFI_MPLS_VPN
,
3739 (struct prefix_rd
*)&rn
->p
,
3741 bgp_static_free (bgp_static
);
3743 bgp_unlock_node (rn
);
3748 bgp_static
= rn
->info
;
3749 bgp_static_withdraw (bgp
, &rn
->p
, afi
, safi
);
3750 bgp_static_free (bgp_static
);
3752 bgp_unlock_node (rn
);
3758 bgp_static_set_vpnv4 (struct vty
*vty
, const char *ip_str
, const char *rd_str
,
3759 const char *tag_str
)
3763 struct prefix_rd prd
;
3765 struct bgp_node
*prn
;
3766 struct bgp_node
*rn
;
3767 struct bgp_table
*table
;
3768 struct bgp_static
*bgp_static
;
3773 ret
= str2prefix (ip_str
, &p
);
3776 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3781 ret
= str2prefix_rd (rd_str
, &prd
);
3784 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3788 ret
= str2tag (tag_str
, tag
);
3791 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3795 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3796 (struct prefix
*)&prd
);
3797 if (prn
->info
== NULL
)
3798 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3800 bgp_unlock_node (prn
);
3803 rn
= bgp_node_get (table
, &p
);
3807 vty_out (vty
, "%% Same network configuration exists%s", VTY_NEWLINE
);
3808 bgp_unlock_node (rn
);
3812 /* New configuration. */
3813 bgp_static
= bgp_static_new ();
3814 bgp_static
->valid
= 1;
3815 memcpy (bgp_static
->tag
, tag
, 3);
3816 rn
->info
= bgp_static
;
3818 bgp_static_update_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3824 /* Configure static BGP network. */
3826 bgp_static_unset_vpnv4 (struct vty
*vty
, const char *ip_str
,
3827 const char *rd_str
, const char *tag_str
)
3832 struct prefix_rd prd
;
3833 struct bgp_node
*prn
;
3834 struct bgp_node
*rn
;
3835 struct bgp_table
*table
;
3836 struct bgp_static
*bgp_static
;
3841 /* Convert IP prefix string to struct prefix. */
3842 ret
= str2prefix (ip_str
, &p
);
3845 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3850 ret
= str2prefix_rd (rd_str
, &prd
);
3853 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3857 ret
= str2tag (tag_str
, tag
);
3860 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3864 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3865 (struct prefix
*)&prd
);
3866 if (prn
->info
== NULL
)
3867 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3869 bgp_unlock_node (prn
);
3872 rn
= bgp_node_lookup (table
, &p
);
3876 bgp_static_withdraw_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3878 bgp_static
= rn
->info
;
3879 bgp_static_free (bgp_static
);
3881 bgp_unlock_node (rn
);
3882 bgp_unlock_node (rn
);
3885 vty_out (vty
, "%% Can't find the route%s", VTY_NEWLINE
);
3892 "network A.B.C.D/M",
3893 "Specify a network to announce via BGP\n"
3894 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
3896 return bgp_static_set (vty
, vty
->index
, argv
[0],
3897 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
3900 DEFUN (bgp_network_route_map
,
3901 bgp_network_route_map_cmd
,
3902 "network A.B.C.D/M route-map WORD",
3903 "Specify a network to announce via BGP\n"
3904 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3905 "Route-map to modify the attributes\n"
3906 "Name of the route map\n")
3908 return bgp_static_set (vty
, vty
->index
, argv
[0],
3909 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
3912 DEFUN (bgp_network_backdoor
,
3913 bgp_network_backdoor_cmd
,
3914 "network A.B.C.D/M backdoor",
3915 "Specify a network to announce via BGP\n"
3916 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3917 "Specify a BGP backdoor route\n")
3919 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP
, SAFI_UNICAST
,
3923 DEFUN (bgp_network_mask
,
3924 bgp_network_mask_cmd
,
3925 "network A.B.C.D mask A.B.C.D",
3926 "Specify a network to announce via BGP\n"
3932 char prefix_str
[BUFSIZ
];
3934 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3937 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3941 return bgp_static_set (vty
, vty
->index
, prefix_str
,
3942 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
3945 DEFUN (bgp_network_mask_route_map
,
3946 bgp_network_mask_route_map_cmd
,
3947 "network A.B.C.D mask A.B.C.D route-map WORD",
3948 "Specify a network to announce via BGP\n"
3952 "Route-map to modify the attributes\n"
3953 "Name of the route map\n")
3956 char prefix_str
[BUFSIZ
];
3958 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3961 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3965 return bgp_static_set (vty
, vty
->index
, prefix_str
,
3966 AFI_IP
, bgp_node_safi (vty
), argv
[2], 0);
3969 DEFUN (bgp_network_mask_backdoor
,
3970 bgp_network_mask_backdoor_cmd
,
3971 "network A.B.C.D mask A.B.C.D backdoor",
3972 "Specify a network to announce via BGP\n"
3976 "Specify a BGP backdoor route\n")
3979 char prefix_str
[BUFSIZ
];
3981 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3984 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3988 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
3992 DEFUN (bgp_network_mask_natural
,
3993 bgp_network_mask_natural_cmd
,
3995 "Specify a network to announce via BGP\n"
3999 char prefix_str
[BUFSIZ
];
4001 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4004 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4008 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4009 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4012 DEFUN (bgp_network_mask_natural_route_map
,
4013 bgp_network_mask_natural_route_map_cmd
,
4014 "network A.B.C.D route-map WORD",
4015 "Specify a network to announce via BGP\n"
4017 "Route-map to modify the attributes\n"
4018 "Name of the route map\n")
4021 char prefix_str
[BUFSIZ
];
4023 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4026 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4030 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4031 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4034 DEFUN (bgp_network_mask_natural_backdoor
,
4035 bgp_network_mask_natural_backdoor_cmd
,
4036 "network A.B.C.D backdoor",
4037 "Specify a network to announce via BGP\n"
4039 "Specify a BGP backdoor route\n")
4042 char prefix_str
[BUFSIZ
];
4044 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4047 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4051 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4055 DEFUN (no_bgp_network
,
4057 "no network A.B.C.D/M",
4059 "Specify a network to announce via BGP\n"
4060 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4062 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP
,
4063 bgp_node_safi (vty
));
4066 ALIAS (no_bgp_network
,
4067 no_bgp_network_route_map_cmd
,
4068 "no network A.B.C.D/M route-map WORD",
4070 "Specify a network to announce via BGP\n"
4071 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4072 "Route-map to modify the attributes\n"
4073 "Name of the route map\n")
4075 ALIAS (no_bgp_network
,
4076 no_bgp_network_backdoor_cmd
,
4077 "no network A.B.C.D/M backdoor",
4079 "Specify a network to announce via BGP\n"
4080 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4081 "Specify a BGP backdoor route\n")
4083 DEFUN (no_bgp_network_mask
,
4084 no_bgp_network_mask_cmd
,
4085 "no network A.B.C.D mask A.B.C.D",
4087 "Specify a network to announce via BGP\n"
4093 char prefix_str
[BUFSIZ
];
4095 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4098 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4102 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4103 bgp_node_safi (vty
));
4106 ALIAS (no_bgp_network_mask
,
4107 no_bgp_network_mask_route_map_cmd
,
4108 "no network A.B.C.D mask A.B.C.D route-map WORD",
4110 "Specify a network to announce via BGP\n"
4114 "Route-map to modify the attributes\n"
4115 "Name of the route map\n")
4117 ALIAS (no_bgp_network_mask
,
4118 no_bgp_network_mask_backdoor_cmd
,
4119 "no network A.B.C.D mask A.B.C.D backdoor",
4121 "Specify a network to announce via BGP\n"
4125 "Specify a BGP backdoor route\n")
4127 DEFUN (no_bgp_network_mask_natural
,
4128 no_bgp_network_mask_natural_cmd
,
4129 "no network A.B.C.D",
4131 "Specify a network to announce via BGP\n"
4135 char prefix_str
[BUFSIZ
];
4137 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4140 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4144 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4145 bgp_node_safi (vty
));
4148 ALIAS (no_bgp_network_mask_natural
,
4149 no_bgp_network_mask_natural_route_map_cmd
,
4150 "no network A.B.C.D route-map WORD",
4152 "Specify a network to announce via BGP\n"
4154 "Route-map to modify the attributes\n"
4155 "Name of the route map\n")
4157 ALIAS (no_bgp_network_mask_natural
,
4158 no_bgp_network_mask_natural_backdoor_cmd
,
4159 "no network A.B.C.D backdoor",
4161 "Specify a network to announce via BGP\n"
4163 "Specify a BGP backdoor route\n")
4166 DEFUN (ipv6_bgp_network
,
4167 ipv6_bgp_network_cmd
,
4168 "network X:X::X:X/M",
4169 "Specify a network to announce via BGP\n"
4170 "IPv6 prefix <network>/<length>\n")
4172 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
4176 DEFUN (ipv6_bgp_network_route_map
,
4177 ipv6_bgp_network_route_map_cmd
,
4178 "network X:X::X:X/M route-map WORD",
4179 "Specify a network to announce via BGP\n"
4180 "IPv6 prefix <network>/<length>\n"
4181 "Route-map to modify the attributes\n"
4182 "Name of the route map\n")
4184 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
,
4185 bgp_node_safi (vty
), argv
[1], 0);
4188 DEFUN (no_ipv6_bgp_network
,
4189 no_ipv6_bgp_network_cmd
,
4190 "no network X:X::X:X/M",
4192 "Specify a network to announce via BGP\n"
4193 "IPv6 prefix <network>/<length>\n")
4195 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
4198 ALIAS (no_ipv6_bgp_network
,
4199 no_ipv6_bgp_network_route_map_cmd
,
4200 "no network X:X::X:X/M route-map WORD",
4202 "Specify a network to announce via BGP\n"
4203 "IPv6 prefix <network>/<length>\n"
4204 "Route-map to modify the attributes\n"
4205 "Name of the route map\n")
4207 ALIAS (ipv6_bgp_network
,
4208 old_ipv6_bgp_network_cmd
,
4209 "ipv6 bgp network X:X::X:X/M",
4212 "Specify a network to announce via BGP\n"
4213 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4215 ALIAS (no_ipv6_bgp_network
,
4216 old_no_ipv6_bgp_network_cmd
,
4217 "no ipv6 bgp network X:X::X:X/M",
4221 "Specify a network to announce via BGP\n"
4222 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4223 #endif /* HAVE_IPV6 */
4225 /* stubs for removed AS-Pathlimit commands, kept for config compatibility */
4226 ALIAS_DEPRECATED (bgp_network
,
4227 bgp_network_ttl_cmd
,
4228 "network A.B.C.D/M pathlimit <0-255>",
4229 "Specify a network to announce via BGP\n"
4230 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4231 "AS-Path hopcount limit attribute\n"
4232 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4233 ALIAS_DEPRECATED (bgp_network_backdoor
,
4234 bgp_network_backdoor_ttl_cmd
,
4235 "network A.B.C.D/M backdoor pathlimit <0-255>",
4236 "Specify a network to announce via BGP\n"
4237 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4238 "Specify a BGP backdoor route\n"
4239 "AS-Path hopcount limit attribute\n"
4240 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4241 ALIAS_DEPRECATED (bgp_network_mask
,
4242 bgp_network_mask_ttl_cmd
,
4243 "network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4244 "Specify a network to announce via BGP\n"
4248 "AS-Path hopcount limit attribute\n"
4249 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4250 ALIAS_DEPRECATED (bgp_network_mask_backdoor
,
4251 bgp_network_mask_backdoor_ttl_cmd
,
4252 "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4253 "Specify a network to announce via BGP\n"
4257 "Specify a BGP backdoor route\n"
4258 "AS-Path hopcount limit attribute\n"
4259 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4260 ALIAS_DEPRECATED (bgp_network_mask_natural
,
4261 bgp_network_mask_natural_ttl_cmd
,
4262 "network A.B.C.D pathlimit <0-255>",
4263 "Specify a network to announce via BGP\n"
4265 "AS-Path hopcount limit attribute\n"
4266 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4267 ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor
,
4268 bgp_network_mask_natural_backdoor_ttl_cmd
,
4269 "network A.B.C.D backdoor pathlimit (1-255>",
4270 "Specify a network to announce via BGP\n"
4272 "Specify a BGP backdoor route\n"
4273 "AS-Path hopcount limit attribute\n"
4274 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4275 ALIAS_DEPRECATED (no_bgp_network
,
4276 no_bgp_network_ttl_cmd
,
4277 "no network A.B.C.D/M pathlimit <0-255>",
4279 "Specify a network to announce via BGP\n"
4280 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4281 "AS-Path hopcount limit attribute\n"
4282 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4283 ALIAS_DEPRECATED (no_bgp_network
,
4284 no_bgp_network_backdoor_ttl_cmd
,
4285 "no network A.B.C.D/M backdoor pathlimit <0-255>",
4287 "Specify a network to announce via BGP\n"
4288 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4289 "Specify a BGP backdoor route\n"
4290 "AS-Path hopcount limit attribute\n"
4291 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4292 ALIAS_DEPRECATED (no_bgp_network
,
4293 no_bgp_network_mask_ttl_cmd
,
4294 "no network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4296 "Specify a network to announce via BGP\n"
4300 "AS-Path hopcount limit attribute\n"
4301 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4302 ALIAS_DEPRECATED (no_bgp_network_mask
,
4303 no_bgp_network_mask_backdoor_ttl_cmd
,
4304 "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4306 "Specify a network to announce via BGP\n"
4310 "Specify a BGP backdoor route\n"
4311 "AS-Path hopcount limit attribute\n"
4312 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4313 ALIAS_DEPRECATED (no_bgp_network_mask_natural
,
4314 no_bgp_network_mask_natural_ttl_cmd
,
4315 "no network A.B.C.D pathlimit <0-255>",
4317 "Specify a network to announce via BGP\n"
4319 "AS-Path hopcount limit attribute\n"
4320 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4321 ALIAS_DEPRECATED (no_bgp_network_mask_natural
,
4322 no_bgp_network_mask_natural_backdoor_ttl_cmd
,
4323 "no network A.B.C.D backdoor pathlimit <0-255>",
4325 "Specify a network to announce via BGP\n"
4327 "Specify a BGP backdoor route\n"
4328 "AS-Path hopcount limit attribute\n"
4329 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4330 ALIAS_DEPRECATED (ipv6_bgp_network
,
4331 ipv6_bgp_network_ttl_cmd
,
4332 "network X:X::X:X/M pathlimit <0-255>",
4333 "Specify a network to announce via BGP\n"
4334 "IPv6 prefix <network>/<length>\n"
4335 "AS-Path hopcount limit attribute\n"
4336 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4337 ALIAS_DEPRECATED (no_ipv6_bgp_network
,
4338 no_ipv6_bgp_network_ttl_cmd
,
4339 "no network X:X::X:X/M pathlimit <0-255>",
4341 "Specify a network to announce via BGP\n"
4342 "IPv6 prefix <network>/<length>\n"
4343 "AS-Path hopcount limit attribute\n"
4344 "AS-Pathlimit TTL, in number of AS-Path hops\n")
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_set (struct vty
*vty
, const char *prefix_str
,
4808 afi_t afi
, safi_t safi
,
4809 u_char summary_only
, u_char as_set
)
4813 struct bgp_node
*rn
;
4815 struct bgp_aggregate
*aggregate
;
4817 /* Convert string to prefix structure. */
4818 ret
= str2prefix (prefix_str
, &p
);
4821 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
4826 /* Get BGP structure. */
4829 /* Old configuration check. */
4830 rn
= bgp_node_get (bgp
->aggregate
[afi
][safi
], &p
);
4834 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
4835 bgp_unlock_node (rn
);
4839 /* Make aggregate address structure. */
4840 aggregate
= bgp_aggregate_new ();
4841 aggregate
->summary_only
= summary_only
;
4842 aggregate
->as_set
= as_set
;
4843 aggregate
->safi
= safi
;
4844 rn
->info
= aggregate
;
4846 /* Aggregate address insert into BGP routing table. */
4847 if (safi
& SAFI_UNICAST
)
4848 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
4849 if (safi
& SAFI_MULTICAST
)
4850 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
4856 bgp_aggregate_unset (struct vty
*vty
, const char *prefix_str
,
4857 afi_t afi
, safi_t safi
)
4861 struct bgp_node
*rn
;
4863 struct bgp_aggregate
*aggregate
;
4865 /* Convert string to prefix structure. */
4866 ret
= str2prefix (prefix_str
, &p
);
4869 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
4874 /* Get BGP structure. */
4877 /* Old configuration check. */
4878 rn
= bgp_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
4881 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
4886 aggregate
= rn
->info
;
4887 if (aggregate
->safi
& SAFI_UNICAST
)
4888 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
4889 if (aggregate
->safi
& SAFI_MULTICAST
)
4890 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
4892 /* Unlock aggregate address configuration. */
4894 bgp_aggregate_free (aggregate
);
4895 bgp_unlock_node (rn
);
4896 bgp_unlock_node (rn
);
4901 DEFUN (aggregate_address
,
4902 aggregate_address_cmd
,
4903 "aggregate-address A.B.C.D/M",
4904 "Configure BGP aggregate entries\n"
4905 "Aggregate prefix\n")
4907 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
), 0, 0);
4910 DEFUN (aggregate_address_mask
,
4911 aggregate_address_mask_cmd
,
4912 "aggregate-address A.B.C.D A.B.C.D",
4913 "Configure BGP aggregate entries\n"
4914 "Aggregate address\n"
4918 char prefix_str
[BUFSIZ
];
4920 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4924 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4928 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
4932 DEFUN (aggregate_address_summary_only
,
4933 aggregate_address_summary_only_cmd
,
4934 "aggregate-address A.B.C.D/M summary-only",
4935 "Configure BGP aggregate entries\n"
4936 "Aggregate prefix\n"
4937 "Filter more specific routes from updates\n")
4939 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
4940 AGGREGATE_SUMMARY_ONLY
, 0);
4943 DEFUN (aggregate_address_mask_summary_only
,
4944 aggregate_address_mask_summary_only_cmd
,
4945 "aggregate-address A.B.C.D A.B.C.D summary-only",
4946 "Configure BGP aggregate entries\n"
4947 "Aggregate address\n"
4949 "Filter more specific routes from updates\n")
4952 char prefix_str
[BUFSIZ
];
4954 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4958 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4962 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
4963 AGGREGATE_SUMMARY_ONLY
, 0);
4966 DEFUN (aggregate_address_as_set
,
4967 aggregate_address_as_set_cmd
,
4968 "aggregate-address A.B.C.D/M as-set",
4969 "Configure BGP aggregate entries\n"
4970 "Aggregate prefix\n"
4971 "Generate AS set path information\n")
4973 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
4974 0, AGGREGATE_AS_SET
);
4977 DEFUN (aggregate_address_mask_as_set
,
4978 aggregate_address_mask_as_set_cmd
,
4979 "aggregate-address A.B.C.D A.B.C.D as-set",
4980 "Configure BGP aggregate entries\n"
4981 "Aggregate address\n"
4983 "Generate AS set path information\n")
4986 char prefix_str
[BUFSIZ
];
4988 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4992 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4996 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
4997 0, AGGREGATE_AS_SET
);
5001 DEFUN (aggregate_address_as_set_summary
,
5002 aggregate_address_as_set_summary_cmd
,
5003 "aggregate-address A.B.C.D/M as-set summary-only",
5004 "Configure BGP aggregate entries\n"
5005 "Aggregate prefix\n"
5006 "Generate AS set path information\n"
5007 "Filter more specific routes from updates\n")
5009 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5010 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5013 ALIAS (aggregate_address_as_set_summary
,
5014 aggregate_address_summary_as_set_cmd
,
5015 "aggregate-address A.B.C.D/M summary-only as-set",
5016 "Configure BGP aggregate entries\n"
5017 "Aggregate prefix\n"
5018 "Filter more specific routes from updates\n"
5019 "Generate AS set path information\n")
5021 DEFUN (aggregate_address_mask_as_set_summary
,
5022 aggregate_address_mask_as_set_summary_cmd
,
5023 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5024 "Configure BGP aggregate entries\n"
5025 "Aggregate address\n"
5027 "Generate AS set path information\n"
5028 "Filter more specific routes from updates\n")
5031 char prefix_str
[BUFSIZ
];
5033 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5037 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5041 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5042 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5045 ALIAS (aggregate_address_mask_as_set_summary
,
5046 aggregate_address_mask_summary_as_set_cmd
,
5047 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5048 "Configure BGP aggregate entries\n"
5049 "Aggregate address\n"
5051 "Filter more specific routes from updates\n"
5052 "Generate AS set path information\n")
5054 DEFUN (no_aggregate_address
,
5055 no_aggregate_address_cmd
,
5056 "no aggregate-address A.B.C.D/M",
5058 "Configure BGP aggregate entries\n"
5059 "Aggregate prefix\n")
5061 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
));
5064 ALIAS (no_aggregate_address
,
5065 no_aggregate_address_summary_only_cmd
,
5066 "no aggregate-address A.B.C.D/M summary-only",
5068 "Configure BGP aggregate entries\n"
5069 "Aggregate prefix\n"
5070 "Filter more specific routes from updates\n")
5072 ALIAS (no_aggregate_address
,
5073 no_aggregate_address_as_set_cmd
,
5074 "no aggregate-address A.B.C.D/M as-set",
5076 "Configure BGP aggregate entries\n"
5077 "Aggregate prefix\n"
5078 "Generate AS set path information\n")
5080 ALIAS (no_aggregate_address
,
5081 no_aggregate_address_as_set_summary_cmd
,
5082 "no aggregate-address A.B.C.D/M as-set summary-only",
5084 "Configure BGP aggregate entries\n"
5085 "Aggregate prefix\n"
5086 "Generate AS set path information\n"
5087 "Filter more specific routes from updates\n")
5089 ALIAS (no_aggregate_address
,
5090 no_aggregate_address_summary_as_set_cmd
,
5091 "no aggregate-address A.B.C.D/M summary-only as-set",
5093 "Configure BGP aggregate entries\n"
5094 "Aggregate prefix\n"
5095 "Filter more specific routes from updates\n"
5096 "Generate AS set path information\n")
5098 DEFUN (no_aggregate_address_mask
,
5099 no_aggregate_address_mask_cmd
,
5100 "no aggregate-address A.B.C.D A.B.C.D",
5102 "Configure BGP aggregate entries\n"
5103 "Aggregate address\n"
5107 char prefix_str
[BUFSIZ
];
5109 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5113 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5117 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
5120 ALIAS (no_aggregate_address_mask
,
5121 no_aggregate_address_mask_summary_only_cmd
,
5122 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5124 "Configure BGP aggregate entries\n"
5125 "Aggregate address\n"
5127 "Filter more specific routes from updates\n")
5129 ALIAS (no_aggregate_address_mask
,
5130 no_aggregate_address_mask_as_set_cmd
,
5131 "no aggregate-address A.B.C.D A.B.C.D as-set",
5133 "Configure BGP aggregate entries\n"
5134 "Aggregate address\n"
5136 "Generate AS set path information\n")
5138 ALIAS (no_aggregate_address_mask
,
5139 no_aggregate_address_mask_as_set_summary_cmd
,
5140 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5142 "Configure BGP aggregate entries\n"
5143 "Aggregate address\n"
5145 "Generate AS set path information\n"
5146 "Filter more specific routes from updates\n")
5148 ALIAS (no_aggregate_address_mask
,
5149 no_aggregate_address_mask_summary_as_set_cmd
,
5150 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5152 "Configure BGP aggregate entries\n"
5153 "Aggregate address\n"
5155 "Filter more specific routes from updates\n"
5156 "Generate AS set path information\n")
5159 DEFUN (ipv6_aggregate_address
,
5160 ipv6_aggregate_address_cmd
,
5161 "aggregate-address X:X::X:X/M",
5162 "Configure BGP aggregate entries\n"
5163 "Aggregate prefix\n")
5165 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0, 0);
5168 DEFUN (ipv6_aggregate_address_summary_only
,
5169 ipv6_aggregate_address_summary_only_cmd
,
5170 "aggregate-address X:X::X:X/M summary-only",
5171 "Configure BGP aggregate entries\n"
5172 "Aggregate prefix\n"
5173 "Filter more specific routes from updates\n")
5175 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5176 AGGREGATE_SUMMARY_ONLY
, 0);
5179 DEFUN (no_ipv6_aggregate_address
,
5180 no_ipv6_aggregate_address_cmd
,
5181 "no aggregate-address X:X::X:X/M",
5183 "Configure BGP aggregate entries\n"
5184 "Aggregate prefix\n")
5186 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5189 DEFUN (no_ipv6_aggregate_address_summary_only
,
5190 no_ipv6_aggregate_address_summary_only_cmd
,
5191 "no aggregate-address X:X::X:X/M summary-only",
5193 "Configure BGP aggregate entries\n"
5194 "Aggregate prefix\n"
5195 "Filter more specific routes from updates\n")
5197 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5200 ALIAS (ipv6_aggregate_address
,
5201 old_ipv6_aggregate_address_cmd
,
5202 "ipv6 bgp aggregate-address X:X::X:X/M",
5205 "Configure BGP aggregate entries\n"
5206 "Aggregate prefix\n")
5208 ALIAS (ipv6_aggregate_address_summary_only
,
5209 old_ipv6_aggregate_address_summary_only_cmd
,
5210 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5213 "Configure BGP aggregate entries\n"
5214 "Aggregate prefix\n"
5215 "Filter more specific routes from updates\n")
5217 ALIAS (no_ipv6_aggregate_address
,
5218 old_no_ipv6_aggregate_address_cmd
,
5219 "no ipv6 bgp aggregate-address X:X::X:X/M",
5223 "Configure BGP aggregate entries\n"
5224 "Aggregate prefix\n")
5226 ALIAS (no_ipv6_aggregate_address_summary_only
,
5227 old_no_ipv6_aggregate_address_summary_only_cmd
,
5228 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5232 "Configure BGP aggregate entries\n"
5233 "Aggregate prefix\n"
5234 "Filter more specific routes from updates\n")
5235 #endif /* HAVE_IPV6 */
5237 /* Redistribute route treatment. */
5239 bgp_redistribute_add (struct prefix
*p
, struct in_addr
*nexthop
,
5240 u_int32_t metric
, u_char type
)
5243 struct listnode
*node
, *nnode
;
5244 struct bgp_info
*new;
5245 struct bgp_info
*bi
;
5246 struct bgp_info info
;
5247 struct bgp_node
*bn
;
5248 struct attr attr
= { 0 };
5249 struct attr attr_new
= { 0 };
5250 struct attr
*new_attr
;
5254 /* Make default attribute. */
5255 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
5257 attr
.nexthop
= *nexthop
;
5260 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
5262 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
5264 afi
= family2afi (p
->family
);
5266 if (bgp
->redist
[afi
][type
])
5268 /* Copy attribute for modification. */
5269 bgp_attr_dup (&attr_new
, &attr
);
5271 if (bgp
->redist_metric_flag
[afi
][type
])
5272 attr_new
.med
= bgp
->redist_metric
[afi
][type
];
5274 /* Apply route-map. */
5275 if (bgp
->rmap
[afi
][type
].map
)
5277 info
.peer
= bgp
->peer_self
;
5278 info
.attr
= &attr_new
;
5280 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
);
5282 ret
= route_map_apply (bgp
->rmap
[afi
][type
].map
, p
, RMAP_BGP
,
5285 bgp
->peer_self
->rmap_type
= 0;
5287 if (ret
== RMAP_DENYMATCH
)
5289 /* Free uninterned attribute. */
5290 bgp_attr_flush (&attr_new
);
5291 bgp_attr_extra_free (&attr_new
);
5293 /* Unintern original. */
5294 aspath_unintern (attr
.aspath
);
5295 bgp_attr_extra_free (&attr
);
5296 bgp_redistribute_delete (p
, type
);
5301 bn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
],
5302 afi
, SAFI_UNICAST
, p
, NULL
);
5304 new_attr
= bgp_attr_intern (&attr_new
);
5305 bgp_attr_extra_free (&attr_new
);
5307 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
5308 if (bi
->peer
== bgp
->peer_self
5309 && bi
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
5314 if (attrhash_cmp (bi
->attr
, new_attr
) &&
5315 !CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5317 bgp_attr_unintern (new_attr
);
5318 aspath_unintern (attr
.aspath
);
5319 bgp_attr_extra_free (&attr
);
5320 bgp_unlock_node (bn
);
5325 /* The attribute is changed. */
5326 bgp_info_set_flag (bn
, bi
, BGP_INFO_ATTR_CHANGED
);
5328 /* Rewrite BGP route information. */
5329 if (CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5330 bgp_info_restore(bn
, bi
);
5332 bgp_aggregate_decrement (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5333 bgp_attr_unintern (bi
->attr
);
5334 bi
->attr
= new_attr
;
5335 bi
->uptime
= bgp_clock ();
5337 /* Process change. */
5338 bgp_aggregate_increment (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5339 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5340 bgp_unlock_node (bn
);
5341 aspath_unintern (attr
.aspath
);
5342 bgp_attr_extra_free (&attr
);
5347 new = bgp_info_new ();
5349 new->sub_type
= BGP_ROUTE_REDISTRIBUTE
;
5350 new->peer
= bgp
->peer_self
;
5351 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5352 new->attr
= new_attr
;
5353 new->uptime
= bgp_clock ();
5355 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
5356 bgp_info_add (bn
, new);
5357 bgp_unlock_node (bn
);
5358 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5362 /* Unintern original. */
5363 aspath_unintern (attr
.aspath
);
5364 bgp_attr_extra_free (&attr
);
5368 bgp_redistribute_delete (struct prefix
*p
, u_char type
)
5371 struct listnode
*node
, *nnode
;
5373 struct bgp_node
*rn
;
5374 struct bgp_info
*ri
;
5376 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
5378 afi
= family2afi (p
->family
);
5380 if (bgp
->redist
[afi
][type
])
5382 rn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
5384 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5385 if (ri
->peer
== bgp
->peer_self
5386 && ri
->type
== type
)
5391 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
5392 bgp_info_delete (rn
, ri
);
5393 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5395 bgp_unlock_node (rn
);
5400 /* Withdraw specified route type's route. */
5402 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
)
5404 struct bgp_node
*rn
;
5405 struct bgp_info
*ri
;
5406 struct bgp_table
*table
;
5408 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
5410 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
5412 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5413 if (ri
->peer
== bgp
->peer_self
5414 && ri
->type
== type
)
5419 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
5420 bgp_info_delete (rn
, ri
);
5421 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5426 /* Static function to display route. */
5428 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
5431 u_int32_t destination
;
5434 if (p
->family
== AF_INET
)
5436 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
5437 destination
= ntohl (p
->u
.prefix4
.s_addr
);
5439 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
5440 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
5441 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
5442 || p
->u
.prefix4
.s_addr
== 0)
5444 /* When mask is natural, mask is not displayed. */
5447 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
5450 len
= vty_out (vty
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
5455 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
5457 vty_out (vty
, "%*s", len
, " ");
5460 enum bgp_display_type
5465 /* Print the short form route status for a bgp_info */
5467 route_vty_short_status_out (struct vty
*vty
, struct bgp_info
*binfo
)
5469 /* Route status display. */
5470 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5472 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5474 else if (binfo
->extra
&& binfo
->extra
->suppress
)
5476 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5482 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5484 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5486 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5491 /* Internal route. */
5492 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
5498 /* called from terminal list command */
5500 route_vty_out (struct vty
*vty
, struct prefix
*p
,
5501 struct bgp_info
*binfo
, int display
, safi_t safi
)
5505 /* short status lead text */
5506 route_vty_short_status_out (vty
, binfo
);
5508 /* print prefix and mask */
5510 route_vty_out_route (p
, vty
);
5512 vty_out (vty
, "%*s", 17, " ");
5514 /* Print attribute */
5518 if (p
->family
== AF_INET
)
5520 if (safi
== SAFI_MPLS_VPN
)
5521 vty_out (vty
, "%-16s",
5522 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5524 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5527 else if (p
->family
== AF_INET6
)
5532 len
= vty_out (vty
, "%s",
5533 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5537 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5539 vty_out (vty
, "%*s", len
, " ");
5541 #endif /* HAVE_IPV6 */
5543 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5544 vty_out (vty
, "%10d", attr
->med
);
5548 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5549 vty_out (vty
, "%7d", attr
->local_pref
);
5553 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
5557 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5560 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5562 vty_out (vty
, "%s", VTY_NEWLINE
);
5565 /* called from terminal list command */
5567 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
,
5568 struct attr
*attr
, safi_t safi
)
5570 /* Route status display. */
5575 /* print prefix and mask */
5576 route_vty_out_route (p
, vty
);
5578 /* Print attribute */
5581 if (p
->family
== AF_INET
)
5583 if (safi
== SAFI_MPLS_VPN
)
5584 vty_out (vty
, "%-16s",
5585 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5587 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5590 else if (p
->family
== AF_INET6
)
5595 assert (attr
->extra
);
5597 len
= vty_out (vty
, "%s",
5598 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5602 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5604 vty_out (vty
, "%*s", len
, " ");
5606 #endif /* HAVE_IPV6 */
5608 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5609 vty_out (vty
, "%10d", attr
->med
);
5613 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5614 vty_out (vty
, "%7d", attr
->local_pref
);
5618 vty_out (vty
, "%7d ", (attr
->extra
? attr
->extra
->weight
: 0));
5622 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5625 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5628 vty_out (vty
, "%s", VTY_NEWLINE
);
5632 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
5633 struct bgp_info
*binfo
, int display
, safi_t safi
)
5636 u_int32_t label
= 0;
5641 /* short status lead text */
5642 route_vty_short_status_out (vty
, binfo
);
5644 /* print prefix and mask */
5646 route_vty_out_route (p
, vty
);
5648 vty_out (vty
, "%*s", 17, " ");
5650 /* Print attribute */
5654 if (p
->family
== AF_INET
)
5656 if (safi
== SAFI_MPLS_VPN
)
5657 vty_out (vty
, "%-16s",
5658 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5660 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5663 else if (p
->family
== AF_INET6
)
5665 assert (attr
->extra
);
5668 if (attr
->extra
->mp_nexthop_len
== 16)
5670 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5672 else if (attr
->extra
->mp_nexthop_len
== 32)
5673 vty_out (vty
, "%s(%s)",
5674 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5676 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
5680 #endif /* HAVE_IPV6 */
5683 label
= decode_label (binfo
->extra
->tag
);
5685 vty_out (vty
, "notag/%d", label
);
5687 vty_out (vty
, "%s", VTY_NEWLINE
);
5690 /* dampening route */
5692 damp_route_vty_out (struct vty
*vty
, struct prefix
*p
,
5693 struct bgp_info
*binfo
, int display
, safi_t safi
)
5697 char timebuf
[BGP_UPTIME_LEN
];
5699 /* short status lead text */
5700 route_vty_short_status_out (vty
, binfo
);
5702 /* print prefix and mask */
5704 route_vty_out_route (p
, vty
);
5706 vty_out (vty
, "%*s", 17, " ");
5708 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
5711 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 34, " ");
5713 vty_out (vty
, "%*s", len
, " ");
5715 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
));
5717 /* Print attribute */
5723 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5726 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5728 vty_out (vty
, "%s", VTY_NEWLINE
);
5733 flap_route_vty_out (struct vty
*vty
, struct prefix
*p
,
5734 struct bgp_info
*binfo
, int display
, safi_t safi
)
5737 struct bgp_damp_info
*bdi
;
5738 char timebuf
[BGP_UPTIME_LEN
];
5744 bdi
= binfo
->extra
->damp_info
;
5746 /* short status lead text */
5747 route_vty_short_status_out (vty
, binfo
);
5749 /* print prefix and mask */
5751 route_vty_out_route (p
, vty
);
5753 vty_out (vty
, "%*s", 17, " ");
5755 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
5758 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 33, " ");
5760 vty_out (vty
, "%*s", len
, " ");
5762 len
= vty_out (vty
, "%d", bdi
->flap
);
5767 vty_out (vty
, "%*s ", len
, " ");
5769 vty_out (vty
, "%s ", peer_uptime (bdi
->start_time
,
5770 timebuf
, BGP_UPTIME_LEN
));
5772 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
)
5773 && ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5774 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
));
5776 vty_out (vty
, "%*s ", 8, " ");
5778 /* Print attribute */
5784 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5787 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5789 vty_out (vty
, "%s", VTY_NEWLINE
);
5793 route_vty_out_detail (struct vty
*vty
, struct bgp
*bgp
, struct prefix
*p
,
5794 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
)
5796 char buf
[INET6_ADDRSTRLEN
];
5799 int sockunion_vty_out (struct vty
*, union sockunion
*);
5805 /* Line1 display AS-path, Aggregator */
5809 if (aspath_count_hops (attr
->aspath
) == 0)
5810 vty_out (vty
, "Local");
5812 aspath_print_vty (vty
, "%s", attr
->aspath
, "");
5815 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5816 vty_out (vty
, ", (removed)");
5817 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5818 vty_out (vty
, ", (stale)");
5819 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
5820 vty_out (vty
, ", (aggregated by %u %s)",
5821 attr
->extra
->aggregator_as
,
5822 inet_ntoa (attr
->extra
->aggregator_addr
));
5823 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
5824 vty_out (vty
, ", (Received from a RR-client)");
5825 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
5826 vty_out (vty
, ", (Received from a RS-client)");
5827 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5828 vty_out (vty
, ", (history entry)");
5829 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5830 vty_out (vty
, ", (suppressed due to dampening)");
5831 vty_out (vty
, "%s", VTY_NEWLINE
);
5833 /* Line2 display Next-hop, Neighbor, Router-id */
5834 if (p
->family
== AF_INET
)
5836 vty_out (vty
, " %s", safi
== SAFI_MPLS_VPN
?
5837 inet_ntoa (attr
->extra
->mp_nexthop_global_in
) :
5838 inet_ntoa (attr
->nexthop
));
5843 assert (attr
->extra
);
5844 vty_out (vty
, " %s",
5845 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5846 buf
, INET6_ADDRSTRLEN
));
5848 #endif /* HAVE_IPV6 */
5850 if (binfo
->peer
== bgp
->peer_self
)
5852 vty_out (vty
, " from %s ",
5853 p
->family
== AF_INET
? "0.0.0.0" : "::");
5854 vty_out (vty
, "(%s)", inet_ntoa(bgp
->router_id
));
5858 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
5859 vty_out (vty
, " (inaccessible)");
5860 else if (binfo
->extra
&& binfo
->extra
->igpmetric
)
5861 vty_out (vty
, " (metric %d)", binfo
->extra
->igpmetric
);
5862 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
5863 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
5864 vty_out (vty
, " (%s)", inet_ntoa (attr
->extra
->originator_id
));
5866 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
5868 vty_out (vty
, "%s", VTY_NEWLINE
);
5871 /* display nexthop local */
5872 if (attr
->extra
&& attr
->extra
->mp_nexthop_len
== 32)
5874 vty_out (vty
, " (%s)%s",
5875 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
5876 buf
, INET6_ADDRSTRLEN
),
5879 #endif /* HAVE_IPV6 */
5881 /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */
5882 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
5884 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
5885 vty_out (vty
, ", metric %d", attr
->med
);
5887 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
5888 vty_out (vty
, ", localpref %d", attr
->local_pref
);
5890 vty_out (vty
, ", localpref %d", bgp
->default_local_pref
);
5892 if (attr
->extra
&& attr
->extra
->weight
!= 0)
5893 vty_out (vty
, ", weight %d", attr
->extra
->weight
);
5895 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5896 vty_out (vty
, ", valid");
5898 if (binfo
->peer
!= bgp
->peer_self
)
5900 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
5901 vty_out (vty
, ", internal");
5903 vty_out (vty
, ", %s",
5904 (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
) ? "confed-external" : "external"));
5906 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
5907 vty_out (vty
, ", aggregated, local");
5908 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
5909 vty_out (vty
, ", sourced");
5911 vty_out (vty
, ", sourced, local");
5913 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
5914 vty_out (vty
, ", atomic-aggregate");
5916 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5917 vty_out (vty
, ", best");
5919 vty_out (vty
, "%s", VTY_NEWLINE
);
5921 /* Line 4 display Community */
5922 if (attr
->community
)
5923 vty_out (vty
, " Community: %s%s", attr
->community
->str
,
5926 /* Line 5 display Extended-community */
5927 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
5928 vty_out (vty
, " Extended Community: %s%s",
5929 attr
->extra
->ecommunity
->str
, VTY_NEWLINE
);
5931 /* Line 6 display Originator, Cluster-id */
5932 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
5933 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
5935 assert (attr
->extra
);
5936 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
5937 vty_out (vty
, " Originator: %s",
5938 inet_ntoa (attr
->extra
->originator_id
));
5940 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
5943 vty_out (vty
, ", Cluster list: ");
5944 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
5945 vty_out (vty
, "%s ",
5946 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
5948 vty_out (vty
, "%s", VTY_NEWLINE
);
5951 if (binfo
->extra
&& binfo
->extra
->damp_info
)
5952 bgp_damp_info_vty (vty
, binfo
);
5954 /* Line 7 display Uptime */
5955 time_t tbuf
= time(NULL
) - (bgp_clock() - binfo
->uptime
);
5956 vty_out (vty
, " Last update: %s", ctime(&tbuf
));
5958 vty_out (vty
, "%s", VTY_NEWLINE
);
5961 #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"
5962 #define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
5963 #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
5964 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
5965 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
5969 bgp_show_type_normal
,
5970 bgp_show_type_regexp
,
5971 bgp_show_type_prefix_list
,
5972 bgp_show_type_filter_list
,
5973 bgp_show_type_route_map
,
5974 bgp_show_type_neighbor
,
5975 bgp_show_type_cidr_only
,
5976 bgp_show_type_prefix_longer
,
5977 bgp_show_type_community_all
,
5978 bgp_show_type_community
,
5979 bgp_show_type_community_exact
,
5980 bgp_show_type_community_list
,
5981 bgp_show_type_community_list_exact
,
5982 bgp_show_type_flap_statistics
,
5983 bgp_show_type_flap_address
,
5984 bgp_show_type_flap_prefix
,
5985 bgp_show_type_flap_cidr_only
,
5986 bgp_show_type_flap_regexp
,
5987 bgp_show_type_flap_filter_list
,
5988 bgp_show_type_flap_prefix_list
,
5989 bgp_show_type_flap_prefix_longer
,
5990 bgp_show_type_flap_route_map
,
5991 bgp_show_type_flap_neighbor
,
5992 bgp_show_type_dampend_paths
,
5993 bgp_show_type_damp_neighbor
5997 bgp_show_table (struct vty
*vty
, struct bgp_table
*table
, struct in_addr
*router_id
,
5998 enum bgp_show_type type
, void *output_arg
)
6000 struct bgp_info
*ri
;
6001 struct bgp_node
*rn
;
6004 unsigned long output_count
;
6006 /* This is first entry point, so reset total line. */
6009 /* Start processing of routes. */
6010 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
6011 if (rn
->info
!= NULL
)
6015 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6017 if (type
== bgp_show_type_flap_statistics
6018 || type
== bgp_show_type_flap_address
6019 || type
== bgp_show_type_flap_prefix
6020 || type
== bgp_show_type_flap_cidr_only
6021 || type
== bgp_show_type_flap_regexp
6022 || type
== bgp_show_type_flap_filter_list
6023 || type
== bgp_show_type_flap_prefix_list
6024 || type
== bgp_show_type_flap_prefix_longer
6025 || type
== bgp_show_type_flap_route_map
6026 || type
== bgp_show_type_flap_neighbor
6027 || type
== bgp_show_type_dampend_paths
6028 || type
== bgp_show_type_damp_neighbor
)
6030 if (!(ri
->extra
&& ri
->extra
->damp_info
))
6033 if (type
== bgp_show_type_regexp
6034 || type
== bgp_show_type_flap_regexp
)
6036 regex_t
*regex
= output_arg
;
6038 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
6041 if (type
== bgp_show_type_prefix_list
6042 || type
== bgp_show_type_flap_prefix_list
)
6044 struct prefix_list
*plist
= output_arg
;
6046 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
6049 if (type
== bgp_show_type_filter_list
6050 || type
== bgp_show_type_flap_filter_list
)
6052 struct as_list
*as_list
= output_arg
;
6054 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
6057 if (type
== bgp_show_type_route_map
6058 || type
== bgp_show_type_flap_route_map
)
6060 struct route_map
*rmap
= output_arg
;
6061 struct bgp_info binfo
;
6062 struct attr dummy_attr
= { 0 };
6065 bgp_attr_dup (&dummy_attr
, ri
->attr
);
6066 binfo
.peer
= ri
->peer
;
6067 binfo
.attr
= &dummy_attr
;
6069 ret
= route_map_apply (rmap
, &rn
->p
, RMAP_BGP
, &binfo
);
6071 bgp_attr_extra_free (&dummy_attr
);
6073 if (ret
== RMAP_DENYMATCH
)
6076 if (type
== bgp_show_type_neighbor
6077 || type
== bgp_show_type_flap_neighbor
6078 || type
== bgp_show_type_damp_neighbor
)
6080 union sockunion
*su
= output_arg
;
6082 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
6085 if (type
== bgp_show_type_cidr_only
6086 || type
== bgp_show_type_flap_cidr_only
)
6088 u_int32_t destination
;
6090 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
6091 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
6093 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
6095 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
6098 if (type
== bgp_show_type_prefix_longer
6099 || type
== bgp_show_type_flap_prefix_longer
)
6101 struct prefix
*p
= output_arg
;
6103 if (! prefix_match (p
, &rn
->p
))
6106 if (type
== bgp_show_type_community_all
)
6108 if (! ri
->attr
->community
)
6111 if (type
== bgp_show_type_community
)
6113 struct community
*com
= output_arg
;
6115 if (! ri
->attr
->community
||
6116 ! community_match (ri
->attr
->community
, com
))
6119 if (type
== bgp_show_type_community_exact
)
6121 struct community
*com
= output_arg
;
6123 if (! ri
->attr
->community
||
6124 ! community_cmp (ri
->attr
->community
, com
))
6127 if (type
== bgp_show_type_community_list
)
6129 struct community_list
*list
= output_arg
;
6131 if (! community_list_match (ri
->attr
->community
, list
))
6134 if (type
== bgp_show_type_community_list_exact
)
6136 struct community_list
*list
= output_arg
;
6138 if (! community_list_exact_match (ri
->attr
->community
, list
))
6141 if (type
== bgp_show_type_flap_address
6142 || type
== bgp_show_type_flap_prefix
)
6144 struct prefix
*p
= output_arg
;
6146 if (! prefix_match (&rn
->p
, p
))
6149 if (type
== bgp_show_type_flap_prefix
)
6150 if (p
->prefixlen
!= rn
->p
.prefixlen
)
6153 if (type
== bgp_show_type_dampend_paths
6154 || type
== bgp_show_type_damp_neighbor
)
6156 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
)
6157 || CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
6163 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id
), VTY_NEWLINE
);
6164 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
6165 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
6166 if (type
== bgp_show_type_dampend_paths
6167 || type
== bgp_show_type_damp_neighbor
)
6168 vty_out (vty
, BGP_SHOW_DAMP_HEADER
, VTY_NEWLINE
);
6169 else if (type
== bgp_show_type_flap_statistics
6170 || type
== bgp_show_type_flap_address
6171 || type
== bgp_show_type_flap_prefix
6172 || type
== bgp_show_type_flap_cidr_only
6173 || type
== bgp_show_type_flap_regexp
6174 || type
== bgp_show_type_flap_filter_list
6175 || type
== bgp_show_type_flap_prefix_list
6176 || type
== bgp_show_type_flap_prefix_longer
6177 || type
== bgp_show_type_flap_route_map
6178 || type
== bgp_show_type_flap_neighbor
)
6179 vty_out (vty
, BGP_SHOW_FLAP_HEADER
, VTY_NEWLINE
);
6181 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
6185 if (type
== bgp_show_type_dampend_paths
6186 || type
== bgp_show_type_damp_neighbor
)
6187 damp_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6188 else if (type
== bgp_show_type_flap_statistics
6189 || type
== bgp_show_type_flap_address
6190 || type
== bgp_show_type_flap_prefix
6191 || type
== bgp_show_type_flap_cidr_only
6192 || type
== bgp_show_type_flap_regexp
6193 || type
== bgp_show_type_flap_filter_list
6194 || type
== bgp_show_type_flap_prefix_list
6195 || type
== bgp_show_type_flap_prefix_longer
6196 || type
== bgp_show_type_flap_route_map
6197 || type
== bgp_show_type_flap_neighbor
)
6198 flap_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6200 route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6207 /* No route is displayed */
6208 if (output_count
== 0)
6210 if (type
== bgp_show_type_normal
)
6211 vty_out (vty
, "No BGP network exists%s", VTY_NEWLINE
);
6214 vty_out (vty
, "%sTotal number of prefixes %ld%s",
6215 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
6221 bgp_show (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
6222 enum bgp_show_type type
, void *output_arg
)
6224 struct bgp_table
*table
;
6227 bgp
= bgp_get_default ();
6232 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
6237 table
= bgp
->rib
[afi
][safi
];
6239 return bgp_show_table (vty
, table
, &bgp
->router_id
, type
, output_arg
);
6242 /* Header of detailed BGP route information */
6244 route_vty_out_detail_header (struct vty
*vty
, struct bgp
*bgp
,
6245 struct bgp_node
*rn
,
6246 struct prefix_rd
*prd
, afi_t afi
, safi_t safi
)
6248 struct bgp_info
*ri
;
6251 struct listnode
*node
, *nnode
;
6252 char buf1
[INET6_ADDRSTRLEN
];
6253 char buf2
[INET6_ADDRSTRLEN
];
6258 int no_advertise
= 0;
6263 vty_out (vty
, "BGP routing table entry for %s%s%s/%d%s",
6264 (safi
== SAFI_MPLS_VPN
?
6265 prefix_rd2str (prd
, buf1
, RD_ADDRSTRLEN
) : ""),
6266 safi
== SAFI_MPLS_VPN
? ":" : "",
6267 inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
),
6268 p
->prefixlen
, VTY_NEWLINE
);
6270 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6273 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
6276 if (ri
->extra
&& ri
->extra
->suppress
)
6278 if (ri
->attr
->community
!= NULL
)
6280 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
6282 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
6284 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
6290 vty_out (vty
, "Paths: (%d available", count
);
6293 vty_out (vty
, ", best #%d", best
);
6294 if (safi
== SAFI_UNICAST
)
6295 vty_out (vty
, ", table Default-IP-Routing-Table");
6298 vty_out (vty
, ", no best path");
6300 vty_out (vty
, ", not advertised to any peer");
6302 vty_out (vty
, ", not advertised to EBGP peer");
6304 vty_out (vty
, ", not advertised outside local AS");
6306 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
6307 vty_out (vty
, ")%s", VTY_NEWLINE
);
6309 /* advertised peer */
6310 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
6312 if (bgp_adj_out_lookup (peer
, p
, afi
, safi
, rn
))
6315 vty_out (vty
, " Advertised to non peer-group peers:%s ", VTY_NEWLINE
);
6316 vty_out (vty
, " %s", sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6321 vty_out (vty
, " Not advertised to any peer");
6322 vty_out (vty
, "%s", VTY_NEWLINE
);
6325 /* Display specified route of BGP table. */
6327 bgp_show_route_in_table (struct vty
*vty
, struct bgp
*bgp
,
6328 struct bgp_table
*rib
, const char *ip_str
,
6329 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
6335 struct prefix match
;
6336 struct bgp_node
*rn
;
6337 struct bgp_node
*rm
;
6338 struct bgp_info
*ri
;
6339 struct bgp_table
*table
;
6341 /* Check IP address argument. */
6342 ret
= str2prefix (ip_str
, &match
);
6345 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
6349 match
.family
= afi2family (afi
);
6351 if (safi
== SAFI_MPLS_VPN
)
6353 for (rn
= bgp_table_top (rib
); rn
; rn
= bgp_route_next (rn
))
6355 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
6358 if ((table
= rn
->info
) != NULL
)
6362 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
6364 if (prefix_check
&& rm
->p
.prefixlen
!= match
.prefixlen
)
6367 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
6371 route_vty_out_detail_header (vty
, bgp
, rm
, (struct prefix_rd
*)&rn
->p
,
6372 AFI_IP
, SAFI_MPLS_VPN
);
6377 route_vty_out_detail (vty
, bgp
, &rm
->p
, ri
, AFI_IP
, SAFI_MPLS_VPN
);
6387 if ((rn
= bgp_node_match (rib
, &match
)) != NULL
)
6389 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
6391 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6395 route_vty_out_detail_header (vty
, bgp
, rn
, NULL
, afi
, safi
);
6399 route_vty_out_detail (vty
, bgp
, &rn
->p
, ri
, afi
, safi
);
6407 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
6414 /* Display specified route of Main RIB */
6416 bgp_show_route (struct vty
*vty
, const char *view_name
, const char *ip_str
,
6417 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
6422 /* BGP structure lookup. */
6425 bgp
= bgp_lookup_by_name (view_name
);
6428 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
6434 bgp
= bgp_get_default ();
6437 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
6442 return bgp_show_route_in_table (vty
, bgp
, bgp
->rib
[afi
][safi
], ip_str
,
6443 afi
, safi
, prd
, prefix_check
);
6446 /* BGP route print out function. */
6454 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6457 DEFUN (show_ip_bgp_ipv4
,
6458 show_ip_bgp_ipv4_cmd
,
6459 "show ip bgp ipv4 (unicast|multicast)",
6464 "Address Family modifier\n"
6465 "Address Family modifier\n")
6467 if (strncmp (argv
[0], "m", 1) == 0)
6468 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
, bgp_show_type_normal
,
6471 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6474 DEFUN (show_ip_bgp_route
,
6475 show_ip_bgp_route_cmd
,
6476 "show ip bgp A.B.C.D",
6480 "Network in the BGP routing table to display\n")
6482 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6485 DEFUN (show_ip_bgp_ipv4_route
,
6486 show_ip_bgp_ipv4_route_cmd
,
6487 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
6492 "Address Family modifier\n"
6493 "Address Family modifier\n"
6494 "Network in the BGP routing table to display\n")
6496 if (strncmp (argv
[0], "m", 1) == 0)
6497 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0);
6499 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6502 DEFUN (show_ip_bgp_vpnv4_all_route
,
6503 show_ip_bgp_vpnv4_all_route_cmd
,
6504 "show ip bgp vpnv4 all A.B.C.D",
6508 "Display VPNv4 NLRI specific information\n"
6509 "Display information about all VPNv4 NLRIs\n"
6510 "Network in the BGP routing table to display\n")
6512 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 0);
6515 DEFUN (show_ip_bgp_vpnv4_rd_route
,
6516 show_ip_bgp_vpnv4_rd_route_cmd
,
6517 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
6521 "Display VPNv4 NLRI specific information\n"
6522 "Display information for a route distinguisher\n"
6523 "VPN Route Distinguisher\n"
6524 "Network in the BGP routing table to display\n")
6527 struct prefix_rd prd
;
6529 ret
= str2prefix_rd (argv
[0], &prd
);
6532 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
6535 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0);
6538 DEFUN (show_ip_bgp_prefix
,
6539 show_ip_bgp_prefix_cmd
,
6540 "show ip bgp A.B.C.D/M",
6544 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6546 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6549 DEFUN (show_ip_bgp_ipv4_prefix
,
6550 show_ip_bgp_ipv4_prefix_cmd
,
6551 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
6556 "Address Family modifier\n"
6557 "Address Family modifier\n"
6558 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6560 if (strncmp (argv
[0], "m", 1) == 0)
6561 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1);
6563 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6566 DEFUN (show_ip_bgp_vpnv4_all_prefix
,
6567 show_ip_bgp_vpnv4_all_prefix_cmd
,
6568 "show ip bgp vpnv4 all A.B.C.D/M",
6572 "Display VPNv4 NLRI specific information\n"
6573 "Display information about all VPNv4 NLRIs\n"
6574 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6576 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 1);
6579 DEFUN (show_ip_bgp_vpnv4_rd_prefix
,
6580 show_ip_bgp_vpnv4_rd_prefix_cmd
,
6581 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
6585 "Display VPNv4 NLRI specific information\n"
6586 "Display information for a route distinguisher\n"
6587 "VPN Route Distinguisher\n"
6588 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6591 struct prefix_rd prd
;
6593 ret
= str2prefix_rd (argv
[0], &prd
);
6596 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
6599 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 1);
6602 DEFUN (show_ip_bgp_view
,
6603 show_ip_bgp_view_cmd
,
6604 "show ip bgp view WORD",
6613 /* BGP structure lookup. */
6614 bgp
= bgp_lookup_by_name (argv
[0]);
6617 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
6621 return bgp_show (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6624 DEFUN (show_ip_bgp_view_route
,
6625 show_ip_bgp_view_route_cmd
,
6626 "show ip bgp view WORD A.B.C.D",
6632 "Network in the BGP routing table to display\n")
6634 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6637 DEFUN (show_ip_bgp_view_prefix
,
6638 show_ip_bgp_view_prefix_cmd
,
6639 "show ip bgp view WORD A.B.C.D/M",
6645 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6647 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6657 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
6669 DEFUN (show_ipv6_bgp
,
6676 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
6680 DEFUN (show_bgp_route
,
6682 "show bgp X:X::X:X",
6685 "Network in the BGP routing table to display\n")
6687 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6690 ALIAS (show_bgp_route
,
6691 show_bgp_ipv6_route_cmd
,
6692 "show bgp ipv6 X:X::X:X",
6696 "Network in the BGP routing table to display\n")
6699 DEFUN (show_ipv6_bgp_route
,
6700 show_ipv6_bgp_route_cmd
,
6701 "show ipv6 bgp X:X::X:X",
6705 "Network in the BGP routing table to display\n")
6707 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6710 DEFUN (show_bgp_prefix
,
6711 show_bgp_prefix_cmd
,
6712 "show bgp X:X::X:X/M",
6715 "IPv6 prefix <network>/<length>\n")
6717 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6720 ALIAS (show_bgp_prefix
,
6721 show_bgp_ipv6_prefix_cmd
,
6722 "show bgp ipv6 X:X::X:X/M",
6726 "IPv6 prefix <network>/<length>\n")
6729 DEFUN (show_ipv6_bgp_prefix
,
6730 show_ipv6_bgp_prefix_cmd
,
6731 "show ipv6 bgp X:X::X:X/M",
6735 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6737 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6740 DEFUN (show_bgp_view
,
6742 "show bgp view WORD",
6750 /* BGP structure lookup. */
6751 bgp
= bgp_lookup_by_name (argv
[0]);
6754 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
6758 return bgp_show (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6761 ALIAS (show_bgp_view
,
6762 show_bgp_view_ipv6_cmd
,
6763 "show bgp view WORD ipv6",
6770 DEFUN (show_bgp_view_route
,
6771 show_bgp_view_route_cmd
,
6772 "show bgp view WORD X:X::X:X",
6777 "Network in the BGP routing table to display\n")
6779 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6782 ALIAS (show_bgp_view_route
,
6783 show_bgp_view_ipv6_route_cmd
,
6784 "show bgp view WORD ipv6 X:X::X:X",
6790 "Network in the BGP routing table to display\n")
6792 DEFUN (show_bgp_view_prefix
,
6793 show_bgp_view_prefix_cmd
,
6794 "show bgp view WORD X:X::X:X/M",
6799 "IPv6 prefix <network>/<length>\n")
6801 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6804 ALIAS (show_bgp_view_prefix
,
6805 show_bgp_view_ipv6_prefix_cmd
,
6806 "show bgp view WORD ipv6 X:X::X:X/M",
6812 "IPv6 prefix <network>/<length>\n")
6815 DEFUN (show_ipv6_mbgp
,
6822 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
6827 DEFUN (show_ipv6_mbgp_route
,
6828 show_ipv6_mbgp_route_cmd
,
6829 "show ipv6 mbgp X:X::X:X",
6833 "Network in the MBGP routing table to display\n")
6835 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0);
6839 DEFUN (show_ipv6_mbgp_prefix
,
6840 show_ipv6_mbgp_prefix_cmd
,
6841 "show ipv6 mbgp X:X::X:X/M",
6845 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6847 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1);
6853 bgp_show_regexp (struct vty
*vty
, int argc
, const char **argv
, afi_t afi
,
6854 safi_t safi
, enum bgp_show_type type
)
6864 b
= buffer_new (1024);
6865 for (i
= 0; i
< argc
; i
++)
6868 buffer_putc (b
, ' ');
6871 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
6876 buffer_putstr (b
, argv
[i
]);
6878 buffer_putc (b
, '\0');
6880 regstr
= buffer_getstr (b
);
6883 regex
= bgp_regcomp (regstr
);
6884 XFREE(MTYPE_TMP
, regstr
);
6887 vty_out (vty
, "Can't compile regexp %s%s", argv
[0],
6892 rc
= bgp_show (vty
, NULL
, afi
, safi
, type
, regex
);
6893 bgp_regex_free (regex
);
6897 DEFUN (show_ip_bgp_regexp
,
6898 show_ip_bgp_regexp_cmd
,
6899 "show ip bgp regexp .LINE",
6903 "Display routes matching the AS path regular expression\n"
6904 "A regular-expression to match the BGP AS paths\n")
6906 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
6907 bgp_show_type_regexp
);
6910 DEFUN (show_ip_bgp_flap_regexp
,
6911 show_ip_bgp_flap_regexp_cmd
,
6912 "show ip bgp flap-statistics regexp .LINE",
6916 "Display flap statistics of routes\n"
6917 "Display routes matching the AS path regular expression\n"
6918 "A regular-expression to match the BGP AS paths\n")
6920 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
6921 bgp_show_type_flap_regexp
);
6924 DEFUN (show_ip_bgp_ipv4_regexp
,
6925 show_ip_bgp_ipv4_regexp_cmd
,
6926 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
6931 "Address Family modifier\n"
6932 "Address Family modifier\n"
6933 "Display routes matching the AS path regular expression\n"
6934 "A regular-expression to match the BGP AS paths\n")
6936 if (strncmp (argv
[0], "m", 1) == 0)
6937 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_MULTICAST
,
6938 bgp_show_type_regexp
);
6940 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
6941 bgp_show_type_regexp
);
6945 DEFUN (show_bgp_regexp
,
6946 show_bgp_regexp_cmd
,
6947 "show bgp regexp .LINE",
6950 "Display routes matching the AS path regular expression\n"
6951 "A regular-expression to match the BGP AS paths\n")
6953 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
6954 bgp_show_type_regexp
);
6957 ALIAS (show_bgp_regexp
,
6958 show_bgp_ipv6_regexp_cmd
,
6959 "show bgp ipv6 regexp .LINE",
6963 "Display routes matching the AS path regular expression\n"
6964 "A regular-expression to match the BGP AS paths\n")
6967 DEFUN (show_ipv6_bgp_regexp
,
6968 show_ipv6_bgp_regexp_cmd
,
6969 "show ipv6 bgp regexp .LINE",
6973 "Display routes matching the AS path regular expression\n"
6974 "A regular-expression to match the BGP AS paths\n")
6976 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
6977 bgp_show_type_regexp
);
6981 DEFUN (show_ipv6_mbgp_regexp
,
6982 show_ipv6_mbgp_regexp_cmd
,
6983 "show ipv6 mbgp regexp .LINE",
6987 "Display routes matching the AS path regular expression\n"
6988 "A regular-expression to match the MBGP AS paths\n")
6990 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
,
6991 bgp_show_type_regexp
);
6993 #endif /* HAVE_IPV6 */
6996 bgp_show_prefix_list (struct vty
*vty
, const char *prefix_list_str
, afi_t afi
,
6997 safi_t safi
, enum bgp_show_type type
)
6999 struct prefix_list
*plist
;
7001 plist
= prefix_list_lookup (afi
, prefix_list_str
);
7004 vty_out (vty
, "%% %s is not a valid prefix-list name%s",
7005 prefix_list_str
, VTY_NEWLINE
);
7009 return bgp_show (vty
, NULL
, afi
, safi
, type
, plist
);
7012 DEFUN (show_ip_bgp_prefix_list
,
7013 show_ip_bgp_prefix_list_cmd
,
7014 "show ip bgp prefix-list WORD",
7018 "Display routes conforming to the prefix-list\n"
7019 "IP prefix-list name\n")
7021 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7022 bgp_show_type_prefix_list
);
7025 DEFUN (show_ip_bgp_flap_prefix_list
,
7026 show_ip_bgp_flap_prefix_list_cmd
,
7027 "show ip bgp flap-statistics prefix-list WORD",
7031 "Display flap statistics of routes\n"
7032 "Display routes conforming to the prefix-list\n"
7033 "IP prefix-list name\n")
7035 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7036 bgp_show_type_flap_prefix_list
);
7039 DEFUN (show_ip_bgp_ipv4_prefix_list
,
7040 show_ip_bgp_ipv4_prefix_list_cmd
,
7041 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
7046 "Address Family modifier\n"
7047 "Address Family modifier\n"
7048 "Display routes conforming to the prefix-list\n"
7049 "IP prefix-list name\n")
7051 if (strncmp (argv
[0], "m", 1) == 0)
7052 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
7053 bgp_show_type_prefix_list
);
7055 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
7056 bgp_show_type_prefix_list
);
7060 DEFUN (show_bgp_prefix_list
,
7061 show_bgp_prefix_list_cmd
,
7062 "show bgp prefix-list WORD",
7065 "Display routes conforming to the prefix-list\n"
7066 "IPv6 prefix-list name\n")
7068 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7069 bgp_show_type_prefix_list
);
7072 ALIAS (show_bgp_prefix_list
,
7073 show_bgp_ipv6_prefix_list_cmd
,
7074 "show bgp ipv6 prefix-list WORD",
7078 "Display routes conforming to the prefix-list\n"
7079 "IPv6 prefix-list name\n")
7082 DEFUN (show_ipv6_bgp_prefix_list
,
7083 show_ipv6_bgp_prefix_list_cmd
,
7084 "show ipv6 bgp prefix-list WORD",
7088 "Display routes matching the prefix-list\n"
7089 "IPv6 prefix-list name\n")
7091 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7092 bgp_show_type_prefix_list
);
7096 DEFUN (show_ipv6_mbgp_prefix_list
,
7097 show_ipv6_mbgp_prefix_list_cmd
,
7098 "show ipv6 mbgp prefix-list WORD",
7102 "Display routes matching the prefix-list\n"
7103 "IPv6 prefix-list name\n")
7105 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
7106 bgp_show_type_prefix_list
);
7108 #endif /* HAVE_IPV6 */
7111 bgp_show_filter_list (struct vty
*vty
, const char *filter
, afi_t afi
,
7112 safi_t safi
, enum bgp_show_type type
)
7114 struct as_list
*as_list
;
7116 as_list
= as_list_lookup (filter
);
7117 if (as_list
== NULL
)
7119 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
7123 return bgp_show (vty
, NULL
, afi
, safi
, type
, as_list
);
7126 DEFUN (show_ip_bgp_filter_list
,
7127 show_ip_bgp_filter_list_cmd
,
7128 "show ip bgp filter-list WORD",
7132 "Display routes conforming to the filter-list\n"
7133 "Regular expression access list name\n")
7135 return bgp_show_filter_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7136 bgp_show_type_filter_list
);
7139 DEFUN (show_ip_bgp_flap_filter_list
,
7140 show_ip_bgp_flap_filter_list_cmd
,
7141 "show ip bgp flap-statistics filter-list WORD",
7145 "Display flap statistics of routes\n"
7146 "Display routes conforming to the filter-list\n"
7147 "Regular expression access list name\n")
7149 return bgp_show_filter_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7150 bgp_show_type_flap_filter_list
);
7153 DEFUN (show_ip_bgp_ipv4_filter_list
,
7154 show_ip_bgp_ipv4_filter_list_cmd
,
7155 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
7160 "Address Family modifier\n"
7161 "Address Family modifier\n"
7162 "Display routes conforming to the filter-list\n"
7163 "Regular expression access list name\n")
7165 if (strncmp (argv
[0], "m", 1) == 0)
7166 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
7167 bgp_show_type_filter_list
);
7169 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
7170 bgp_show_type_filter_list
);
7174 DEFUN (show_bgp_filter_list
,
7175 show_bgp_filter_list_cmd
,
7176 "show bgp filter-list WORD",
7179 "Display routes conforming to the filter-list\n"
7180 "Regular expression access list name\n")
7182 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7183 bgp_show_type_filter_list
);
7186 ALIAS (show_bgp_filter_list
,
7187 show_bgp_ipv6_filter_list_cmd
,
7188 "show bgp ipv6 filter-list WORD",
7192 "Display routes conforming to the filter-list\n"
7193 "Regular expression access list name\n")
7196 DEFUN (show_ipv6_bgp_filter_list
,
7197 show_ipv6_bgp_filter_list_cmd
,
7198 "show ipv6 bgp filter-list WORD",
7202 "Display routes conforming to the filter-list\n"
7203 "Regular expression access list name\n")
7205 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7206 bgp_show_type_filter_list
);
7210 DEFUN (show_ipv6_mbgp_filter_list
,
7211 show_ipv6_mbgp_filter_list_cmd
,
7212 "show ipv6 mbgp filter-list WORD",
7216 "Display routes conforming to the filter-list\n"
7217 "Regular expression access list name\n")
7219 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
7220 bgp_show_type_filter_list
);
7222 #endif /* HAVE_IPV6 */
7225 bgp_show_route_map (struct vty
*vty
, const char *rmap_str
, afi_t afi
,
7226 safi_t safi
, enum bgp_show_type type
)
7228 struct route_map
*rmap
;
7230 rmap
= route_map_lookup_by_name (rmap_str
);
7233 vty_out (vty
, "%% %s is not a valid route-map name%s",
7234 rmap_str
, VTY_NEWLINE
);
7238 return bgp_show (vty
, NULL
, afi
, safi
, type
, rmap
);
7241 DEFUN (show_ip_bgp_route_map
,
7242 show_ip_bgp_route_map_cmd
,
7243 "show ip bgp route-map WORD",
7247 "Display routes matching the route-map\n"
7248 "A route-map to match on\n")
7250 return bgp_show_route_map (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7251 bgp_show_type_route_map
);
7254 DEFUN (show_ip_bgp_flap_route_map
,
7255 show_ip_bgp_flap_route_map_cmd
,
7256 "show ip bgp flap-statistics route-map WORD",
7260 "Display flap statistics of routes\n"
7261 "Display routes matching the route-map\n"
7262 "A route-map to match on\n")
7264 return bgp_show_route_map (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7265 bgp_show_type_flap_route_map
);
7268 DEFUN (show_ip_bgp_ipv4_route_map
,
7269 show_ip_bgp_ipv4_route_map_cmd
,
7270 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
7275 "Address Family modifier\n"
7276 "Address Family modifier\n"
7277 "Display routes matching the route-map\n"
7278 "A route-map to match on\n")
7280 if (strncmp (argv
[0], "m", 1) == 0)
7281 return bgp_show_route_map (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
7282 bgp_show_type_route_map
);
7284 return bgp_show_route_map (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
7285 bgp_show_type_route_map
);
7288 DEFUN (show_bgp_route_map
,
7289 show_bgp_route_map_cmd
,
7290 "show bgp route-map WORD",
7293 "Display routes matching the route-map\n"
7294 "A route-map to match on\n")
7296 return bgp_show_route_map (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7297 bgp_show_type_route_map
);
7300 ALIAS (show_bgp_route_map
,
7301 show_bgp_ipv6_route_map_cmd
,
7302 "show bgp ipv6 route-map WORD",
7306 "Display routes matching the route-map\n"
7307 "A route-map to match on\n")
7309 DEFUN (show_ip_bgp_cidr_only
,
7310 show_ip_bgp_cidr_only_cmd
,
7311 "show ip bgp cidr-only",
7315 "Display only routes with non-natural netmasks\n")
7317 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7318 bgp_show_type_cidr_only
, NULL
);
7321 DEFUN (show_ip_bgp_flap_cidr_only
,
7322 show_ip_bgp_flap_cidr_only_cmd
,
7323 "show ip bgp flap-statistics cidr-only",
7327 "Display flap statistics of routes\n"
7328 "Display only routes with non-natural netmasks\n")
7330 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7331 bgp_show_type_flap_cidr_only
, NULL
);
7334 DEFUN (show_ip_bgp_ipv4_cidr_only
,
7335 show_ip_bgp_ipv4_cidr_only_cmd
,
7336 "show ip bgp ipv4 (unicast|multicast) cidr-only",
7341 "Address Family modifier\n"
7342 "Address Family modifier\n"
7343 "Display only routes with non-natural netmasks\n")
7345 if (strncmp (argv
[0], "m", 1) == 0)
7346 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
7347 bgp_show_type_cidr_only
, NULL
);
7349 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7350 bgp_show_type_cidr_only
, NULL
);
7353 DEFUN (show_ip_bgp_community_all
,
7354 show_ip_bgp_community_all_cmd
,
7355 "show ip bgp community",
7359 "Display routes matching the communities\n")
7361 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7362 bgp_show_type_community_all
, NULL
);
7365 DEFUN (show_ip_bgp_ipv4_community_all
,
7366 show_ip_bgp_ipv4_community_all_cmd
,
7367 "show ip bgp ipv4 (unicast|multicast) community",
7372 "Address Family modifier\n"
7373 "Address Family modifier\n"
7374 "Display routes matching the communities\n")
7376 if (strncmp (argv
[0], "m", 1) == 0)
7377 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
7378 bgp_show_type_community_all
, NULL
);
7380 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7381 bgp_show_type_community_all
, NULL
);
7385 DEFUN (show_bgp_community_all
,
7386 show_bgp_community_all_cmd
,
7387 "show bgp community",
7390 "Display routes matching the communities\n")
7392 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
7393 bgp_show_type_community_all
, NULL
);
7396 ALIAS (show_bgp_community_all
,
7397 show_bgp_ipv6_community_all_cmd
,
7398 "show bgp ipv6 community",
7402 "Display routes matching the communities\n")
7405 DEFUN (show_ipv6_bgp_community_all
,
7406 show_ipv6_bgp_community_all_cmd
,
7407 "show ipv6 bgp community",
7411 "Display routes matching the communities\n")
7413 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
7414 bgp_show_type_community_all
, NULL
);
7418 DEFUN (show_ipv6_mbgp_community_all
,
7419 show_ipv6_mbgp_community_all_cmd
,
7420 "show ipv6 mbgp community",
7424 "Display routes matching the communities\n")
7426 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
7427 bgp_show_type_community_all
, NULL
);
7429 #endif /* HAVE_IPV6 */
7432 bgp_show_community (struct vty
*vty
, int argc
, const char **argv
, int exact
,
7433 afi_t afi
, safi_t safi
)
7435 struct community
*com
;
7441 b
= buffer_new (1024);
7442 for (i
= 0; i
< argc
; i
++)
7445 buffer_putc (b
, ' ');
7448 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
7453 buffer_putstr (b
, argv
[i
]);
7455 buffer_putc (b
, '\0');
7457 str
= buffer_getstr (b
);
7460 com
= community_str2com (str
);
7461 XFREE (MTYPE_TMP
, str
);
7464 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
7468 return bgp_show (vty
, NULL
, afi
, safi
,
7469 (exact
? bgp_show_type_community_exact
:
7470 bgp_show_type_community
), com
);
7473 DEFUN (show_ip_bgp_community
,
7474 show_ip_bgp_community_cmd
,
7475 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
7479 "Display routes matching the communities\n"
7480 "community number\n"
7481 "Do not send outside local AS (well-known community)\n"
7482 "Do not advertise to any peer (well-known community)\n"
7483 "Do not export to next AS (well-known community)\n")
7485 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
7488 ALIAS (show_ip_bgp_community
,
7489 show_ip_bgp_community2_cmd
,
7490 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7494 "Display routes matching the communities\n"
7495 "community number\n"
7496 "Do not send outside local AS (well-known community)\n"
7497 "Do not advertise to any peer (well-known community)\n"
7498 "Do not export to next AS (well-known community)\n"
7499 "community number\n"
7500 "Do not send outside local AS (well-known community)\n"
7501 "Do not advertise to any peer (well-known community)\n"
7502 "Do not export to next AS (well-known community)\n")
7504 ALIAS (show_ip_bgp_community
,
7505 show_ip_bgp_community3_cmd
,
7506 "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)",
7510 "Display routes matching the communities\n"
7511 "community number\n"
7512 "Do not send outside local AS (well-known community)\n"
7513 "Do not advertise to any peer (well-known community)\n"
7514 "Do not export to next AS (well-known community)\n"
7515 "community number\n"
7516 "Do not send outside local AS (well-known community)\n"
7517 "Do not advertise to any peer (well-known community)\n"
7518 "Do not export to next AS (well-known community)\n"
7519 "community number\n"
7520 "Do not send outside local AS (well-known community)\n"
7521 "Do not advertise to any peer (well-known community)\n"
7522 "Do not export to next AS (well-known community)\n")
7524 ALIAS (show_ip_bgp_community
,
7525 show_ip_bgp_community4_cmd
,
7526 "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)",
7530 "Display routes matching the communities\n"
7531 "community number\n"
7532 "Do not send outside local AS (well-known community)\n"
7533 "Do not advertise to any peer (well-known community)\n"
7534 "Do not export to next AS (well-known community)\n"
7535 "community number\n"
7536 "Do not send outside local AS (well-known community)\n"
7537 "Do not advertise to any peer (well-known community)\n"
7538 "Do not export to next AS (well-known community)\n"
7539 "community number\n"
7540 "Do not send outside local AS (well-known community)\n"
7541 "Do not advertise to any peer (well-known community)\n"
7542 "Do not export to next AS (well-known community)\n"
7543 "community number\n"
7544 "Do not send outside local AS (well-known community)\n"
7545 "Do not advertise to any peer (well-known community)\n"
7546 "Do not export to next AS (well-known community)\n")
7548 DEFUN (show_ip_bgp_ipv4_community
,
7549 show_ip_bgp_ipv4_community_cmd
,
7550 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
7555 "Address Family modifier\n"
7556 "Address Family modifier\n"
7557 "Display routes matching the communities\n"
7558 "community number\n"
7559 "Do not send outside local AS (well-known community)\n"
7560 "Do not advertise to any peer (well-known community)\n"
7561 "Do not export to next AS (well-known community)\n")
7563 if (strncmp (argv
[0], "m", 1) == 0)
7564 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_MULTICAST
);
7566 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
7569 ALIAS (show_ip_bgp_ipv4_community
,
7570 show_ip_bgp_ipv4_community2_cmd
,
7571 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7576 "Address Family modifier\n"
7577 "Address Family modifier\n"
7578 "Display routes matching the communities\n"
7579 "community number\n"
7580 "Do not send outside local AS (well-known community)\n"
7581 "Do not advertise to any peer (well-known community)\n"
7582 "Do not export to next AS (well-known community)\n"
7583 "community number\n"
7584 "Do not send outside local AS (well-known community)\n"
7585 "Do not advertise to any peer (well-known community)\n"
7586 "Do not export to next AS (well-known community)\n")
7588 ALIAS (show_ip_bgp_ipv4_community
,
7589 show_ip_bgp_ipv4_community3_cmd
,
7590 "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)",
7595 "Address Family modifier\n"
7596 "Address Family modifier\n"
7597 "Display routes matching the communities\n"
7598 "community number\n"
7599 "Do not send outside local AS (well-known community)\n"
7600 "Do not advertise to any peer (well-known community)\n"
7601 "Do not export to next AS (well-known community)\n"
7602 "community number\n"
7603 "Do not send outside local AS (well-known community)\n"
7604 "Do not advertise to any peer (well-known community)\n"
7605 "Do not export to next AS (well-known community)\n"
7606 "community number\n"
7607 "Do not send outside local AS (well-known community)\n"
7608 "Do not advertise to any peer (well-known community)\n"
7609 "Do not export to next AS (well-known community)\n")
7611 ALIAS (show_ip_bgp_ipv4_community
,
7612 show_ip_bgp_ipv4_community4_cmd
,
7613 "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)",
7618 "Address Family modifier\n"
7619 "Address Family modifier\n"
7620 "Display routes matching the communities\n"
7621 "community number\n"
7622 "Do not send outside local AS (well-known community)\n"
7623 "Do not advertise to any peer (well-known community)\n"
7624 "Do not export to next AS (well-known community)\n"
7625 "community number\n"
7626 "Do not send outside local AS (well-known community)\n"
7627 "Do not advertise to any peer (well-known community)\n"
7628 "Do not export to next AS (well-known community)\n"
7629 "community number\n"
7630 "Do not send outside local AS (well-known community)\n"
7631 "Do not advertise to any peer (well-known community)\n"
7632 "Do not export to next AS (well-known community)\n"
7633 "community number\n"
7634 "Do not send outside local AS (well-known community)\n"
7635 "Do not advertise to any peer (well-known community)\n"
7636 "Do not export to next AS (well-known community)\n")
7638 DEFUN (show_ip_bgp_community_exact
,
7639 show_ip_bgp_community_exact_cmd
,
7640 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7644 "Display routes matching the communities\n"
7645 "community number\n"
7646 "Do not send outside local AS (well-known community)\n"
7647 "Do not advertise to any peer (well-known community)\n"
7648 "Do not export to next AS (well-known community)\n"
7649 "Exact match of the communities")
7651 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
7654 ALIAS (show_ip_bgp_community_exact
,
7655 show_ip_bgp_community2_exact_cmd
,
7656 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7660 "Display routes matching the communities\n"
7661 "community number\n"
7662 "Do not send outside local AS (well-known community)\n"
7663 "Do not advertise to any peer (well-known community)\n"
7664 "Do not export to next AS (well-known community)\n"
7665 "community number\n"
7666 "Do not send outside local AS (well-known community)\n"
7667 "Do not advertise to any peer (well-known community)\n"
7668 "Do not export to next AS (well-known community)\n"
7669 "Exact match of the communities")
7671 ALIAS (show_ip_bgp_community_exact
,
7672 show_ip_bgp_community3_exact_cmd
,
7673 "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",
7677 "Display routes matching the communities\n"
7678 "community number\n"
7679 "Do not send outside local AS (well-known community)\n"
7680 "Do not advertise to any peer (well-known community)\n"
7681 "Do not export to next AS (well-known community)\n"
7682 "community number\n"
7683 "Do not send outside local AS (well-known community)\n"
7684 "Do not advertise to any peer (well-known community)\n"
7685 "Do not export to next AS (well-known community)\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"
7690 "Exact match of the communities")
7692 ALIAS (show_ip_bgp_community_exact
,
7693 show_ip_bgp_community4_exact_cmd
,
7694 "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",
7698 "Display routes matching the communities\n"
7699 "community number\n"
7700 "Do not send outside local AS (well-known community)\n"
7701 "Do not advertise to any peer (well-known community)\n"
7702 "Do not export to next AS (well-known community)\n"
7703 "community number\n"
7704 "Do not send outside local AS (well-known community)\n"
7705 "Do not advertise to any peer (well-known community)\n"
7706 "Do not export to next AS (well-known community)\n"
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"
7715 "Exact match of the communities")
7717 DEFUN (show_ip_bgp_ipv4_community_exact
,
7718 show_ip_bgp_ipv4_community_exact_cmd
,
7719 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7724 "Address Family modifier\n"
7725 "Address Family modifier\n"
7726 "Display routes matching the communities\n"
7727 "community number\n"
7728 "Do not send outside local AS (well-known community)\n"
7729 "Do not advertise to any peer (well-known community)\n"
7730 "Do not export to next AS (well-known community)\n"
7731 "Exact match of the communities")
7733 if (strncmp (argv
[0], "m", 1) == 0)
7734 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_MULTICAST
);
7736 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
7739 ALIAS (show_ip_bgp_ipv4_community_exact
,
7740 show_ip_bgp_ipv4_community2_exact_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) exact-match",
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 "Exact match of the communities")
7759 ALIAS (show_ip_bgp_ipv4_community_exact
,
7760 show_ip_bgp_ipv4_community3_exact_cmd
,
7761 "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",
7766 "Address Family modifier\n"
7767 "Address Family modifier\n"
7768 "Display routes matching the communities\n"
7769 "community number\n"
7770 "Do not send outside local AS (well-known community)\n"
7771 "Do not advertise to any peer (well-known community)\n"
7772 "Do not export to next AS (well-known community)\n"
7773 "community number\n"
7774 "Do not send outside local AS (well-known community)\n"
7775 "Do not advertise to any peer (well-known community)\n"
7776 "Do not export to next AS (well-known community)\n"
7777 "community number\n"
7778 "Do not send outside local AS (well-known community)\n"
7779 "Do not advertise to any peer (well-known community)\n"
7780 "Do not export to next AS (well-known community)\n"
7781 "Exact match of the communities")
7783 ALIAS (show_ip_bgp_ipv4_community_exact
,
7784 show_ip_bgp_ipv4_community4_exact_cmd
,
7785 "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",
7790 "Address Family modifier\n"
7791 "Address Family modifier\n"
7792 "Display routes matching the communities\n"
7793 "community number\n"
7794 "Do not send outside local AS (well-known community)\n"
7795 "Do not advertise to any peer (well-known community)\n"
7796 "Do not export to next AS (well-known community)\n"
7797 "community number\n"
7798 "Do not send outside local AS (well-known community)\n"
7799 "Do not advertise to any peer (well-known community)\n"
7800 "Do not export to next AS (well-known community)\n"
7801 "community number\n"
7802 "Do not send outside local AS (well-known community)\n"
7803 "Do not advertise to any peer (well-known community)\n"
7804 "Do not export to next AS (well-known community)\n"
7805 "community number\n"
7806 "Do not send outside local AS (well-known community)\n"
7807 "Do not advertise to any peer (well-known community)\n"
7808 "Do not export to next AS (well-known community)\n"
7809 "Exact match of the communities")
7812 DEFUN (show_bgp_community
,
7813 show_bgp_community_cmd
,
7814 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
7817 "Display routes matching the communities\n"
7818 "community number\n"
7819 "Do not send outside local AS (well-known community)\n"
7820 "Do not advertise to any peer (well-known community)\n"
7821 "Do not export to next AS (well-known community)\n")
7823 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
7826 ALIAS (show_bgp_community
,
7827 show_bgp_ipv6_community_cmd
,
7828 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
7832 "Display routes matching the communities\n"
7833 "community number\n"
7834 "Do not send outside local AS (well-known community)\n"
7835 "Do not advertise to any peer (well-known community)\n"
7836 "Do not export to next AS (well-known community)\n")
7838 ALIAS (show_bgp_community
,
7839 show_bgp_community2_cmd
,
7840 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7843 "Display routes matching the communities\n"
7844 "community number\n"
7845 "Do not send outside local AS (well-known community)\n"
7846 "Do not advertise to any peer (well-known community)\n"
7847 "Do not export to next AS (well-known community)\n"
7848 "community number\n"
7849 "Do not send outside local AS (well-known community)\n"
7850 "Do not advertise to any peer (well-known community)\n"
7851 "Do not export to next AS (well-known community)\n")
7853 ALIAS (show_bgp_community
,
7854 show_bgp_ipv6_community2_cmd
,
7855 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7859 "Display routes matching the communities\n"
7860 "community number\n"
7861 "Do not send outside local AS (well-known community)\n"
7862 "Do not advertise to any peer (well-known community)\n"
7863 "Do not export to next AS (well-known community)\n"
7864 "community number\n"
7865 "Do not send outside local AS (well-known community)\n"
7866 "Do not advertise to any peer (well-known community)\n"
7867 "Do not export to next AS (well-known community)\n")
7869 ALIAS (show_bgp_community
,
7870 show_bgp_community3_cmd
,
7871 "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)",
7874 "Display routes matching the communities\n"
7875 "community number\n"
7876 "Do not send outside local AS (well-known community)\n"
7877 "Do not advertise to any peer (well-known community)\n"
7878 "Do not export to next AS (well-known community)\n"
7879 "community number\n"
7880 "Do not send outside local AS (well-known community)\n"
7881 "Do not advertise to any peer (well-known community)\n"
7882 "Do not export to next AS (well-known community)\n"
7883 "community number\n"
7884 "Do not send outside local AS (well-known community)\n"
7885 "Do not advertise to any peer (well-known community)\n"
7886 "Do not export to next AS (well-known community)\n")
7888 ALIAS (show_bgp_community
,
7889 show_bgp_ipv6_community3_cmd
,
7890 "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)",
7894 "Display routes matching the communities\n"
7895 "community number\n"
7896 "Do not send outside local AS (well-known community)\n"
7897 "Do not advertise to any peer (well-known community)\n"
7898 "Do not export to next AS (well-known community)\n"
7899 "community number\n"
7900 "Do not send outside local AS (well-known community)\n"
7901 "Do not advertise to any peer (well-known community)\n"
7902 "Do not export to next AS (well-known community)\n"
7903 "community number\n"
7904 "Do not send outside local AS (well-known community)\n"
7905 "Do not advertise to any peer (well-known community)\n"
7906 "Do not export to next AS (well-known community)\n")
7908 ALIAS (show_bgp_community
,
7909 show_bgp_community4_cmd
,
7910 "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)",
7913 "Display routes matching the communities\n"
7914 "community number\n"
7915 "Do not send outside local AS (well-known community)\n"
7916 "Do not advertise to any peer (well-known community)\n"
7917 "Do not export to next AS (well-known community)\n"
7918 "community number\n"
7919 "Do not send outside local AS (well-known community)\n"
7920 "Do not advertise to any peer (well-known community)\n"
7921 "Do not export to next AS (well-known community)\n"
7922 "community number\n"
7923 "Do not send outside local AS (well-known community)\n"
7924 "Do not advertise to any peer (well-known community)\n"
7925 "Do not export to next AS (well-known community)\n"
7926 "community number\n"
7927 "Do not send outside local AS (well-known community)\n"
7928 "Do not advertise to any peer (well-known community)\n"
7929 "Do not export to next AS (well-known community)\n")
7931 ALIAS (show_bgp_community
,
7932 show_bgp_ipv6_community4_cmd
,
7933 "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)",
7937 "Display routes matching the communities\n"
7938 "community number\n"
7939 "Do not send outside local AS (well-known community)\n"
7940 "Do not advertise to any peer (well-known community)\n"
7941 "Do not export to next AS (well-known community)\n"
7942 "community number\n"
7943 "Do not send outside local AS (well-known community)\n"
7944 "Do not advertise to any peer (well-known community)\n"
7945 "Do not export to next AS (well-known community)\n"
7946 "community number\n"
7947 "Do not send outside local AS (well-known community)\n"
7948 "Do not advertise to any peer (well-known community)\n"
7949 "Do not export to next AS (well-known community)\n"
7950 "community number\n"
7951 "Do not send outside local AS (well-known community)\n"
7952 "Do not advertise to any peer (well-known community)\n"
7953 "Do not export to next AS (well-known community)\n")
7956 DEFUN (show_ipv6_bgp_community
,
7957 show_ipv6_bgp_community_cmd
,
7958 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
7962 "Display routes matching the communities\n"
7963 "community number\n"
7964 "Do not send outside local AS (well-known community)\n"
7965 "Do not advertise to any peer (well-known community)\n"
7966 "Do not export to next AS (well-known community)\n")
7968 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
7972 ALIAS (show_ipv6_bgp_community
,
7973 show_ipv6_bgp_community2_cmd
,
7974 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7978 "Display routes matching the communities\n"
7979 "community number\n"
7980 "Do not send outside local AS (well-known community)\n"
7981 "Do not advertise to any peer (well-known community)\n"
7982 "Do not export to next AS (well-known community)\n"
7983 "community number\n"
7984 "Do not send outside local AS (well-known community)\n"
7985 "Do not advertise to any peer (well-known community)\n"
7986 "Do not export to next AS (well-known community)\n")
7989 ALIAS (show_ipv6_bgp_community
,
7990 show_ipv6_bgp_community3_cmd
,
7991 "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)",
7995 "Display routes matching the communities\n"
7996 "community number\n"
7997 "Do not send outside local AS (well-known community)\n"
7998 "Do not advertise to any peer (well-known community)\n"
7999 "Do not export to next AS (well-known community)\n"
8000 "community number\n"
8001 "Do not send outside local AS (well-known community)\n"
8002 "Do not advertise to any peer (well-known community)\n"
8003 "Do not export to next AS (well-known community)\n"
8004 "community number\n"
8005 "Do not send outside local AS (well-known community)\n"
8006 "Do not advertise to any peer (well-known community)\n"
8007 "Do not export to next AS (well-known community)\n")
8010 ALIAS (show_ipv6_bgp_community
,
8011 show_ipv6_bgp_community4_cmd
,
8012 "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)",
8016 "Display routes matching the communities\n"
8017 "community number\n"
8018 "Do not send outside local AS (well-known community)\n"
8019 "Do not advertise to any peer (well-known community)\n"
8020 "Do not export to next AS (well-known community)\n"
8021 "community number\n"
8022 "Do not send outside local AS (well-known community)\n"
8023 "Do not advertise to any peer (well-known community)\n"
8024 "Do not export to next AS (well-known community)\n"
8025 "community number\n"
8026 "Do not send outside local AS (well-known community)\n"
8027 "Do not advertise to any peer (well-known community)\n"
8028 "Do not export to next AS (well-known community)\n"
8029 "community number\n"
8030 "Do not send outside local AS (well-known community)\n"
8031 "Do not advertise to any peer (well-known community)\n"
8032 "Do not export to next AS (well-known community)\n")
8034 DEFUN (show_bgp_community_exact
,
8035 show_bgp_community_exact_cmd
,
8036 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8039 "Display routes matching the communities\n"
8040 "community number\n"
8041 "Do not send outside local AS (well-known community)\n"
8042 "Do not advertise to any peer (well-known community)\n"
8043 "Do not export to next AS (well-known community)\n"
8044 "Exact match of the communities")
8046 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
8049 ALIAS (show_bgp_community_exact
,
8050 show_bgp_ipv6_community_exact_cmd
,
8051 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8055 "Display routes matching the communities\n"
8056 "community number\n"
8057 "Do not send outside local AS (well-known community)\n"
8058 "Do not advertise to any peer (well-known community)\n"
8059 "Do not export to next AS (well-known community)\n"
8060 "Exact match of the communities")
8062 ALIAS (show_bgp_community_exact
,
8063 show_bgp_community2_exact_cmd
,
8064 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
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 "Exact match of the communities")
8078 ALIAS (show_bgp_community_exact
,
8079 show_bgp_ipv6_community2_exact_cmd
,
8080 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8084 "Display routes matching the communities\n"
8085 "community number\n"
8086 "Do not send outside local AS (well-known community)\n"
8087 "Do not advertise to any peer (well-known community)\n"
8088 "Do not export to next AS (well-known community)\n"
8089 "community number\n"
8090 "Do not send outside local AS (well-known community)\n"
8091 "Do not advertise to any peer (well-known community)\n"
8092 "Do not export to next AS (well-known community)\n"
8093 "Exact match of the communities")
8095 ALIAS (show_bgp_community_exact
,
8096 show_bgp_community3_exact_cmd
,
8097 "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",
8100 "Display routes matching the communities\n"
8101 "community number\n"
8102 "Do not send outside local AS (well-known community)\n"
8103 "Do not advertise to any peer (well-known community)\n"
8104 "Do not export to next AS (well-known community)\n"
8105 "community number\n"
8106 "Do not send outside local AS (well-known community)\n"
8107 "Do not advertise to any peer (well-known community)\n"
8108 "Do not export to next AS (well-known community)\n"
8109 "community number\n"
8110 "Do not send outside local AS (well-known community)\n"
8111 "Do not advertise to any peer (well-known community)\n"
8112 "Do not export to next AS (well-known community)\n"
8113 "Exact match of the communities")
8115 ALIAS (show_bgp_community_exact
,
8116 show_bgp_ipv6_community3_exact_cmd
,
8117 "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",
8121 "Display routes matching the communities\n"
8122 "community number\n"
8123 "Do not send outside local AS (well-known community)\n"
8124 "Do not advertise to any peer (well-known community)\n"
8125 "Do not export to next AS (well-known community)\n"
8126 "community number\n"
8127 "Do not send outside local AS (well-known community)\n"
8128 "Do not advertise to any peer (well-known community)\n"
8129 "Do not export to next AS (well-known community)\n"
8130 "community number\n"
8131 "Do not send outside local AS (well-known community)\n"
8132 "Do not advertise to any peer (well-known community)\n"
8133 "Do not export to next AS (well-known community)\n"
8134 "Exact match of the communities")
8136 ALIAS (show_bgp_community_exact
,
8137 show_bgp_community4_exact_cmd
,
8138 "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",
8141 "Display routes matching the communities\n"
8142 "community number\n"
8143 "Do not send outside local AS (well-known community)\n"
8144 "Do not advertise to any peer (well-known community)\n"
8145 "Do not export to next AS (well-known community)\n"
8146 "community number\n"
8147 "Do not send outside local AS (well-known community)\n"
8148 "Do not advertise to any peer (well-known community)\n"
8149 "Do not export to next AS (well-known community)\n"
8150 "community number\n"
8151 "Do not send outside local AS (well-known community)\n"
8152 "Do not advertise to any peer (well-known community)\n"
8153 "Do not export to next AS (well-known community)\n"
8154 "community number\n"
8155 "Do not send outside local AS (well-known community)\n"
8156 "Do not advertise to any peer (well-known community)\n"
8157 "Do not export to next AS (well-known community)\n"
8158 "Exact match of the communities")
8160 ALIAS (show_bgp_community_exact
,
8161 show_bgp_ipv6_community4_exact_cmd
,
8162 "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",
8166 "Display routes matching the communities\n"
8167 "community number\n"
8168 "Do not send outside local AS (well-known community)\n"
8169 "Do not advertise to any peer (well-known community)\n"
8170 "Do not export to next AS (well-known community)\n"
8171 "community number\n"
8172 "Do not send outside local AS (well-known community)\n"
8173 "Do not advertise to any peer (well-known community)\n"
8174 "Do not export to next AS (well-known community)\n"
8175 "community number\n"
8176 "Do not send outside local AS (well-known community)\n"
8177 "Do not advertise to any peer (well-known community)\n"
8178 "Do not export to next AS (well-known community)\n"
8179 "community number\n"
8180 "Do not send outside local AS (well-known community)\n"
8181 "Do not advertise to any peer (well-known community)\n"
8182 "Do not export to next AS (well-known community)\n"
8183 "Exact match of the communities")
8186 DEFUN (show_ipv6_bgp_community_exact
,
8187 show_ipv6_bgp_community_exact_cmd
,
8188 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8192 "Display routes matching the communities\n"
8193 "community number\n"
8194 "Do not send outside local AS (well-known community)\n"
8195 "Do not advertise to any peer (well-known community)\n"
8196 "Do not export to next AS (well-known community)\n"
8197 "Exact match of the communities")
8199 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
8203 ALIAS (show_ipv6_bgp_community_exact
,
8204 show_ipv6_bgp_community2_exact_cmd
,
8205 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8209 "Display routes matching the communities\n"
8210 "community number\n"
8211 "Do not send outside local AS (well-known community)\n"
8212 "Do not advertise to any peer (well-known community)\n"
8213 "Do not export to next AS (well-known community)\n"
8214 "community number\n"
8215 "Do not send outside local AS (well-known community)\n"
8216 "Do not advertise to any peer (well-known community)\n"
8217 "Do not export to next AS (well-known community)\n"
8218 "Exact match of the communities")
8221 ALIAS (show_ipv6_bgp_community_exact
,
8222 show_ipv6_bgp_community3_exact_cmd
,
8223 "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",
8227 "Display routes matching the communities\n"
8228 "community number\n"
8229 "Do not send outside local AS (well-known community)\n"
8230 "Do not advertise to any peer (well-known community)\n"
8231 "Do not export to next AS (well-known community)\n"
8232 "community number\n"
8233 "Do not send outside local AS (well-known community)\n"
8234 "Do not advertise to any peer (well-known community)\n"
8235 "Do not export to next AS (well-known community)\n"
8236 "community number\n"
8237 "Do not send outside local AS (well-known community)\n"
8238 "Do not advertise to any peer (well-known community)\n"
8239 "Do not export to next AS (well-known community)\n"
8240 "Exact match of the communities")
8243 ALIAS (show_ipv6_bgp_community_exact
,
8244 show_ipv6_bgp_community4_exact_cmd
,
8245 "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",
8249 "Display routes matching the communities\n"
8250 "community number\n"
8251 "Do not send outside local AS (well-known community)\n"
8252 "Do not advertise to any peer (well-known community)\n"
8253 "Do not export to next AS (well-known community)\n"
8254 "community number\n"
8255 "Do not send outside local AS (well-known community)\n"
8256 "Do not advertise to any peer (well-known community)\n"
8257 "Do not export to next AS (well-known community)\n"
8258 "community number\n"
8259 "Do not send outside local AS (well-known community)\n"
8260 "Do not advertise to any peer (well-known community)\n"
8261 "Do not export to next AS (well-known community)\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"
8266 "Exact match of the communities")
8269 DEFUN (show_ipv6_mbgp_community
,
8270 show_ipv6_mbgp_community_cmd
,
8271 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
8275 "Display routes matching the communities\n"
8276 "community number\n"
8277 "Do not send outside local AS (well-known community)\n"
8278 "Do not advertise to any peer (well-known community)\n"
8279 "Do not export to next AS (well-known community)\n")
8281 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
8285 ALIAS (show_ipv6_mbgp_community
,
8286 show_ipv6_mbgp_community2_cmd
,
8287 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8291 "Display routes matching the communities\n"
8292 "community number\n"
8293 "Do not send outside local AS (well-known community)\n"
8294 "Do not advertise to any peer (well-known community)\n"
8295 "Do not export to next AS (well-known community)\n"
8296 "community number\n"
8297 "Do not send outside local AS (well-known community)\n"
8298 "Do not advertise to any peer (well-known community)\n"
8299 "Do not export to next AS (well-known community)\n")
8302 ALIAS (show_ipv6_mbgp_community
,
8303 show_ipv6_mbgp_community3_cmd
,
8304 "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)",
8308 "Display routes matching the communities\n"
8309 "community number\n"
8310 "Do not send outside local AS (well-known community)\n"
8311 "Do not advertise to any peer (well-known community)\n"
8312 "Do not export to next AS (well-known community)\n"
8313 "community number\n"
8314 "Do not send outside local AS (well-known community)\n"
8315 "Do not advertise to any peer (well-known community)\n"
8316 "Do not export to next AS (well-known community)\n"
8317 "community number\n"
8318 "Do not send outside local AS (well-known community)\n"
8319 "Do not advertise to any peer (well-known community)\n"
8320 "Do not export to next AS (well-known community)\n")
8323 ALIAS (show_ipv6_mbgp_community
,
8324 show_ipv6_mbgp_community4_cmd
,
8325 "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)",
8329 "Display routes matching the communities\n"
8330 "community number\n"
8331 "Do not send outside local AS (well-known community)\n"
8332 "Do not advertise to any peer (well-known community)\n"
8333 "Do not export to next AS (well-known community)\n"
8334 "community number\n"
8335 "Do not send outside local AS (well-known community)\n"
8336 "Do not advertise to any peer (well-known community)\n"
8337 "Do not export to next AS (well-known community)\n"
8338 "community number\n"
8339 "Do not send outside local AS (well-known community)\n"
8340 "Do not advertise to any peer (well-known community)\n"
8341 "Do not export to next AS (well-known community)\n"
8342 "community number\n"
8343 "Do not send outside local AS (well-known community)\n"
8344 "Do not advertise to any peer (well-known community)\n"
8345 "Do not export to next AS (well-known community)\n")
8348 DEFUN (show_ipv6_mbgp_community_exact
,
8349 show_ipv6_mbgp_community_exact_cmd
,
8350 "show ipv6 mbgp 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 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
8365 ALIAS (show_ipv6_mbgp_community_exact
,
8366 show_ipv6_mbgp_community2_exact_cmd
,
8367 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8371 "Display routes matching the communities\n"
8372 "community number\n"
8373 "Do not send outside local AS (well-known community)\n"
8374 "Do not advertise to any peer (well-known community)\n"
8375 "Do not export to next AS (well-known community)\n"
8376 "community number\n"
8377 "Do not send outside local AS (well-known community)\n"
8378 "Do not advertise to any peer (well-known community)\n"
8379 "Do not export to next AS (well-known community)\n"
8380 "Exact match of the communities")
8383 ALIAS (show_ipv6_mbgp_community_exact
,
8384 show_ipv6_mbgp_community3_exact_cmd
,
8385 "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",
8389 "Display routes matching the communities\n"
8390 "community number\n"
8391 "Do not send outside local AS (well-known community)\n"
8392 "Do not advertise to any peer (well-known community)\n"
8393 "Do not export to next AS (well-known community)\n"
8394 "community number\n"
8395 "Do not send outside local AS (well-known community)\n"
8396 "Do not advertise to any peer (well-known community)\n"
8397 "Do not export to next AS (well-known community)\n"
8398 "community number\n"
8399 "Do not send outside local AS (well-known community)\n"
8400 "Do not advertise to any peer (well-known community)\n"
8401 "Do not export to next AS (well-known community)\n"
8402 "Exact match of the communities")
8405 ALIAS (show_ipv6_mbgp_community_exact
,
8406 show_ipv6_mbgp_community4_exact_cmd
,
8407 "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",
8411 "Display routes matching the communities\n"
8412 "community number\n"
8413 "Do not send outside local AS (well-known community)\n"
8414 "Do not advertise to any peer (well-known community)\n"
8415 "Do not export to next AS (well-known community)\n"
8416 "community number\n"
8417 "Do not send outside local AS (well-known community)\n"
8418 "Do not advertise to any peer (well-known community)\n"
8419 "Do not export to next AS (well-known community)\n"
8420 "community number\n"
8421 "Do not send outside local AS (well-known community)\n"
8422 "Do not advertise to any peer (well-known community)\n"
8423 "Do not export to next AS (well-known community)\n"
8424 "community number\n"
8425 "Do not send outside local AS (well-known community)\n"
8426 "Do not advertise to any peer (well-known community)\n"
8427 "Do not export to next AS (well-known community)\n"
8428 "Exact match of the communities")
8429 #endif /* HAVE_IPV6 */
8432 bgp_show_community_list (struct vty
*vty
, const char *com
, int exact
,
8433 afi_t afi
, safi_t safi
)
8435 struct community_list
*list
;
8437 list
= community_list_lookup (bgp_clist
, com
, COMMUNITY_LIST_MASTER
);
8440 vty_out (vty
, "%% %s is not a valid community-list name%s", com
,
8445 return bgp_show (vty
, NULL
, afi
, safi
,
8446 (exact
? bgp_show_type_community_list_exact
:
8447 bgp_show_type_community_list
), list
);
8450 DEFUN (show_ip_bgp_community_list
,
8451 show_ip_bgp_community_list_cmd
,
8452 "show ip bgp community-list (<1-500>|WORD)",
8456 "Display routes matching the community-list\n"
8457 "community-list number\n"
8458 "community-list name\n")
8460 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP
, SAFI_UNICAST
);
8463 DEFUN (show_ip_bgp_ipv4_community_list
,
8464 show_ip_bgp_ipv4_community_list_cmd
,
8465 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
8470 "Address Family modifier\n"
8471 "Address Family modifier\n"
8472 "Display routes matching the community-list\n"
8473 "community-list number\n"
8474 "community-list name\n")
8476 if (strncmp (argv
[0], "m", 1) == 0)
8477 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_MULTICAST
);
8479 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_UNICAST
);
8482 DEFUN (show_ip_bgp_community_list_exact
,
8483 show_ip_bgp_community_list_exact_cmd
,
8484 "show ip bgp community-list (<1-500>|WORD) exact-match",
8488 "Display routes matching the community-list\n"
8489 "community-list number\n"
8490 "community-list name\n"
8491 "Exact match of the communities\n")
8493 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP
, SAFI_UNICAST
);
8496 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
8497 show_ip_bgp_ipv4_community_list_exact_cmd
,
8498 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
8503 "Address Family modifier\n"
8504 "Address Family modifier\n"
8505 "Display routes matching the community-list\n"
8506 "community-list number\n"
8507 "community-list name\n"
8508 "Exact match of the communities\n")
8510 if (strncmp (argv
[0], "m", 1) == 0)
8511 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_MULTICAST
);
8513 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_UNICAST
);
8517 DEFUN (show_bgp_community_list
,
8518 show_bgp_community_list_cmd
,
8519 "show bgp community-list (<1-500>|WORD)",
8522 "Display routes matching the community-list\n"
8523 "community-list number\n"
8524 "community-list name\n")
8526 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
8529 ALIAS (show_bgp_community_list
,
8530 show_bgp_ipv6_community_list_cmd
,
8531 "show bgp ipv6 community-list (<1-500>|WORD)",
8535 "Display routes matching the community-list\n"
8536 "community-list number\n"
8537 "community-list name\n")
8540 DEFUN (show_ipv6_bgp_community_list
,
8541 show_ipv6_bgp_community_list_cmd
,
8542 "show ipv6 bgp community-list WORD",
8546 "Display routes matching the community-list\n"
8547 "community-list name\n")
8549 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
8553 DEFUN (show_ipv6_mbgp_community_list
,
8554 show_ipv6_mbgp_community_list_cmd
,
8555 "show ipv6 mbgp community-list WORD",
8559 "Display routes matching the community-list\n"
8560 "community-list name\n")
8562 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_MULTICAST
);
8565 DEFUN (show_bgp_community_list_exact
,
8566 show_bgp_community_list_exact_cmd
,
8567 "show bgp community-list (<1-500>|WORD) exact-match",
8570 "Display routes matching the community-list\n"
8571 "community-list number\n"
8572 "community-list name\n"
8573 "Exact match of the communities\n")
8575 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
8578 ALIAS (show_bgp_community_list_exact
,
8579 show_bgp_ipv6_community_list_exact_cmd
,
8580 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
8584 "Display routes matching the community-list\n"
8585 "community-list number\n"
8586 "community-list name\n"
8587 "Exact match of the communities\n")
8590 DEFUN (show_ipv6_bgp_community_list_exact
,
8591 show_ipv6_bgp_community_list_exact_cmd
,
8592 "show ipv6 bgp community-list WORD exact-match",
8596 "Display routes matching the community-list\n"
8597 "community-list name\n"
8598 "Exact match of the communities\n")
8600 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
8604 DEFUN (show_ipv6_mbgp_community_list_exact
,
8605 show_ipv6_mbgp_community_list_exact_cmd
,
8606 "show ipv6 mbgp community-list WORD exact-match",
8610 "Display routes matching the community-list\n"
8611 "community-list name\n"
8612 "Exact match of the communities\n")
8614 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_MULTICAST
);
8616 #endif /* HAVE_IPV6 */
8619 bgp_show_prefix_longer (struct vty
*vty
, const char *prefix
, afi_t afi
,
8620 safi_t safi
, enum bgp_show_type type
)
8627 ret
= str2prefix (prefix
, p
);
8630 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
8634 ret
= bgp_show (vty
, NULL
, afi
, safi
, type
, p
);
8639 DEFUN (show_ip_bgp_prefix_longer
,
8640 show_ip_bgp_prefix_longer_cmd
,
8641 "show ip bgp A.B.C.D/M longer-prefixes",
8645 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8646 "Display route and more specific routes\n")
8648 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8649 bgp_show_type_prefix_longer
);
8652 DEFUN (show_ip_bgp_flap_prefix_longer
,
8653 show_ip_bgp_flap_prefix_longer_cmd
,
8654 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
8658 "Display flap statistics of routes\n"
8659 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8660 "Display route and more specific routes\n")
8662 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8663 bgp_show_type_flap_prefix_longer
);
8666 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
8667 show_ip_bgp_ipv4_prefix_longer_cmd
,
8668 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
8673 "Address Family modifier\n"
8674 "Address Family modifier\n"
8675 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8676 "Display route and more specific routes\n")
8678 if (strncmp (argv
[0], "m", 1) == 0)
8679 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
8680 bgp_show_type_prefix_longer
);
8682 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
8683 bgp_show_type_prefix_longer
);
8686 DEFUN (show_ip_bgp_flap_address
,
8687 show_ip_bgp_flap_address_cmd
,
8688 "show ip bgp flap-statistics A.B.C.D",
8692 "Display flap statistics of routes\n"
8693 "Network in the BGP routing table to display\n")
8695 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8696 bgp_show_type_flap_address
);
8699 DEFUN (show_ip_bgp_flap_prefix
,
8700 show_ip_bgp_flap_prefix_cmd
,
8701 "show ip bgp flap-statistics A.B.C.D/M",
8705 "Display flap statistics of routes\n"
8706 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8708 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8709 bgp_show_type_flap_prefix
);
8712 DEFUN (show_bgp_prefix_longer
,
8713 show_bgp_prefix_longer_cmd
,
8714 "show bgp X:X::X:X/M longer-prefixes",
8717 "IPv6 prefix <network>/<length>\n"
8718 "Display route and more specific routes\n")
8720 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8721 bgp_show_type_prefix_longer
);
8724 ALIAS (show_bgp_prefix_longer
,
8725 show_bgp_ipv6_prefix_longer_cmd
,
8726 "show bgp ipv6 X:X::X:X/M longer-prefixes",
8730 "IPv6 prefix <network>/<length>\n"
8731 "Display route and more specific routes\n")
8734 DEFUN (show_ipv6_bgp_prefix_longer
,
8735 show_ipv6_bgp_prefix_longer_cmd
,
8736 "show ipv6 bgp X:X::X:X/M longer-prefixes",
8740 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8741 "Display route and more specific routes\n")
8743 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8744 bgp_show_type_prefix_longer
);
8748 DEFUN (show_ipv6_mbgp_prefix_longer
,
8749 show_ipv6_mbgp_prefix_longer_cmd
,
8750 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
8754 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8755 "Display route and more specific routes\n")
8757 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
8758 bgp_show_type_prefix_longer
);
8760 #endif /* HAVE_IPV6 */
8762 static struct peer
*
8763 peer_lookup_in_view (struct vty
*vty
, const char *view_name
,
8771 /* BGP structure lookup. */
8774 bgp
= bgp_lookup_by_name (view_name
);
8777 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
8783 bgp
= bgp_get_default ();
8786 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
8791 /* Get peer sockunion. */
8792 ret
= str2sockunion (ip_str
, &su
);
8795 vty_out (vty
, "Malformed address: %s%s", ip_str
, VTY_NEWLINE
);
8799 /* Peer structure lookup. */
8800 peer
= peer_lookup (bgp
, &su
);
8803 vty_out (vty
, "No such neighbor%s", VTY_NEWLINE
);
8812 BGP_STATS_MAXBITLEN
= 0,
8816 BGP_STATS_UNAGGREGATEABLE
,
8817 BGP_STATS_MAX_AGGREGATEABLE
,
8818 BGP_STATS_AGGREGATES
,
8820 BGP_STATS_ASPATH_COUNT
,
8821 BGP_STATS_ASPATH_MAXHOPS
,
8822 BGP_STATS_ASPATH_TOTHOPS
,
8823 BGP_STATS_ASPATH_MAXSIZE
,
8824 BGP_STATS_ASPATH_TOTSIZE
,
8825 BGP_STATS_ASN_HIGHEST
,
8829 static const char *table_stats_strs
[] =
8831 [BGP_STATS_PREFIXES
] = "Total Prefixes",
8832 [BGP_STATS_TOTPLEN
] = "Average prefix length",
8833 [BGP_STATS_RIB
] = "Total Advertisements",
8834 [BGP_STATS_UNAGGREGATEABLE
] = "Unaggregateable prefixes",
8835 [BGP_STATS_MAX_AGGREGATEABLE
] = "Maximum aggregateable prefixes",
8836 [BGP_STATS_AGGREGATES
] = "BGP Aggregate advertisements",
8837 [BGP_STATS_SPACE
] = "Address space advertised",
8838 [BGP_STATS_ASPATH_COUNT
] = "Advertisements with paths",
8839 [BGP_STATS_ASPATH_MAXHOPS
] = "Longest AS-Path (hops)",
8840 [BGP_STATS_ASPATH_MAXSIZE
] = "Largest AS-Path (bytes)",
8841 [BGP_STATS_ASPATH_TOTHOPS
] = "Average AS-Path length (hops)",
8842 [BGP_STATS_ASPATH_TOTSIZE
] = "Average AS-Path size (bytes)",
8843 [BGP_STATS_ASN_HIGHEST
] = "Highest public ASN",
8844 [BGP_STATS_MAX
] = NULL
,
8847 struct bgp_table_stats
8849 struct bgp_table
*table
;
8850 unsigned long long counts
[BGP_STATS_MAX
];
8854 #define TALLY_SIGFIG 100000
8855 static unsigned long
8856 ravg_tally (unsigned long count
, unsigned long oldavg
, unsigned long newval
)
8858 unsigned long newtot
= (count
-1) * oldavg
+ (newval
* TALLY_SIGFIG
);
8859 unsigned long res
= (newtot
* TALLY_SIGFIG
) / count
;
8860 unsigned long ret
= newtot
/ count
;
8862 if ((res
% TALLY_SIGFIG
) > (TALLY_SIGFIG
/2))
8870 bgp_table_stats_walker (struct thread
*t
)
8872 struct bgp_node
*rn
;
8873 struct bgp_node
*top
;
8874 struct bgp_table_stats
*ts
= THREAD_ARG (t
);
8875 unsigned int space
= 0;
8877 if (!(top
= bgp_table_top (ts
->table
)))
8880 switch (top
->p
.family
)
8883 space
= IPV4_MAX_BITLEN
;
8886 space
= IPV6_MAX_BITLEN
;
8890 ts
->counts
[BGP_STATS_MAXBITLEN
] = space
;
8892 for (rn
= top
; rn
; rn
= bgp_route_next (rn
))
8894 struct bgp_info
*ri
;
8895 struct bgp_node
*prn
= rn
->parent
;
8896 unsigned int rinum
= 0;
8904 ts
->counts
[BGP_STATS_PREFIXES
]++;
8905 ts
->counts
[BGP_STATS_TOTPLEN
] += rn
->p
.prefixlen
;
8908 ts
->counts
[BGP_STATS_AVGPLEN
]
8909 = ravg_tally (ts
->counts
[BGP_STATS_PREFIXES
],
8910 ts
->counts
[BGP_STATS_AVGPLEN
],
8914 /* check if the prefix is included by any other announcements */
8915 while (prn
&& !prn
->info
)
8918 if (prn
== NULL
|| prn
== top
)
8920 ts
->counts
[BGP_STATS_UNAGGREGATEABLE
]++;
8921 /* announced address space */
8923 ts
->counts
[BGP_STATS_SPACE
] += 1 << (space
- rn
->p
.prefixlen
);
8926 ts
->counts
[BGP_STATS_MAX_AGGREGATEABLE
]++;
8928 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
8931 ts
->counts
[BGP_STATS_RIB
]++;
8934 (CHECK_FLAG (ri
->attr
->flag
,
8935 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
))))
8936 ts
->counts
[BGP_STATS_AGGREGATES
]++;
8939 if (ri
->attr
&& ri
->attr
->aspath
)
8941 unsigned int hops
= aspath_count_hops (ri
->attr
->aspath
);
8942 unsigned int size
= aspath_size (ri
->attr
->aspath
);
8943 as_t highest
= aspath_highest (ri
->attr
->aspath
);
8945 ts
->counts
[BGP_STATS_ASPATH_COUNT
]++;
8947 if (hops
> ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
])
8948 ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
] = hops
;
8950 if (size
> ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
])
8951 ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
] = size
;
8953 ts
->counts
[BGP_STATS_ASPATH_TOTHOPS
] += hops
;
8954 ts
->counts
[BGP_STATS_ASPATH_TOTSIZE
] += size
;
8956 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
]
8957 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
8958 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
],
8960 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
]
8961 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
8962 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
],
8965 if (highest
> ts
->counts
[BGP_STATS_ASN_HIGHEST
])
8966 ts
->counts
[BGP_STATS_ASN_HIGHEST
] = highest
;
8974 bgp_table_stats (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
)
8976 struct bgp_table_stats ts
;
8979 if (!bgp
->rib
[afi
][safi
])
8981 vty_out (vty
, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE
);
8985 memset (&ts
, 0, sizeof (ts
));
8986 ts
.table
= bgp
->rib
[afi
][safi
];
8987 thread_execute (bm
->master
, bgp_table_stats_walker
, &ts
, 0);
8989 vty_out (vty
, "BGP %s RIB statistics%s%s",
8990 afi_safi_print (afi
, safi
), VTY_NEWLINE
, VTY_NEWLINE
);
8992 for (i
= 0; i
< BGP_STATS_MAX
; i
++)
8994 if (!table_stats_strs
[i
])
9000 case BGP_STATS_ASPATH_AVGHOPS
:
9001 case BGP_STATS_ASPATH_AVGSIZE
:
9002 case BGP_STATS_AVGPLEN
:
9003 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9004 vty_out (vty
, "%12.2f",
9005 (float)ts
.counts
[i
] / (float)TALLY_SIGFIG
);
9008 case BGP_STATS_ASPATH_TOTHOPS
:
9009 case BGP_STATS_ASPATH_TOTSIZE
:
9010 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9011 vty_out (vty
, "%12.2f",
9013 (float)ts
.counts
[i
] /
9014 (float)ts
.counts
[BGP_STATS_ASPATH_COUNT
]
9017 case BGP_STATS_TOTPLEN
:
9018 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9019 vty_out (vty
, "%12.2f",
9021 (float)ts
.counts
[i
] /
9022 (float)ts
.counts
[BGP_STATS_PREFIXES
]
9025 case BGP_STATS_SPACE
:
9026 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9027 vty_out (vty
, "%12llu%s", ts
.counts
[i
], VTY_NEWLINE
);
9028 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 9)
9030 vty_out (vty
, "%30s: ", "%% announced ");
9031 vty_out (vty
, "%12.2f%s",
9032 100 * (float)ts
.counts
[BGP_STATS_SPACE
] /
9033 (float)((uint64_t)1UL << ts
.counts
[BGP_STATS_MAXBITLEN
]),
9035 vty_out (vty
, "%30s: ", "/8 equivalent ");
9036 vty_out (vty
, "%12.2f%s",
9037 (float)ts
.counts
[BGP_STATS_SPACE
] /
9038 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 8)),
9040 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 25)
9042 vty_out (vty
, "%30s: ", "/24 equivalent ");
9043 vty_out (vty
, "%12.2f",
9044 (float)ts
.counts
[BGP_STATS_SPACE
] /
9045 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 24)));
9048 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9049 vty_out (vty
, "%12llu", ts
.counts
[i
]);
9052 vty_out (vty
, "%s", VTY_NEWLINE
);
9058 bgp_table_stats_vty (struct vty
*vty
, const char *name
,
9059 const char *afi_str
, const char *safi_str
)
9066 bgp
= bgp_lookup_by_name (name
);
9068 bgp
= bgp_get_default ();
9072 vty_out (vty
, "%% No such BGP instance exist%s", VTY_NEWLINE
);
9075 if (strncmp (afi_str
, "ipv", 3) == 0)
9077 if (strncmp (afi_str
, "ipv4", 4) == 0)
9079 else if (strncmp (afi_str
, "ipv6", 4) == 0)
9083 vty_out (vty
, "%% Invalid address family %s%s",
9084 afi_str
, VTY_NEWLINE
);
9087 if (strncmp (safi_str
, "m", 1) == 0)
9088 safi
= SAFI_MULTICAST
;
9089 else if (strncmp (safi_str
, "u", 1) == 0)
9090 safi
= SAFI_UNICAST
;
9091 else if (strncmp (safi_str
, "vpnv4", 5) == 0)
9092 safi
= BGP_SAFI_VPNV4
;
9093 else if (strncmp (safi_str
, "vpnv6", 6) == 0)
9094 safi
= BGP_SAFI_VPNV6
;
9097 vty_out (vty
, "%% Invalid subsequent address family %s%s",
9098 safi_str
, VTY_NEWLINE
);
9104 vty_out (vty
, "%% Invalid address family %s%s",
9105 afi_str
, VTY_NEWLINE
);
9109 if ((afi
== AFI_IP
&& safi
== BGP_SAFI_VPNV6
)
9110 || (afi
== AFI_IP6
&& safi
== BGP_SAFI_VPNV4
))
9112 vty_out (vty
, "%% Invalid subsequent address family %s for %s%s",
9113 afi_str
, safi_str
, VTY_NEWLINE
);
9116 return bgp_table_stats (vty
, bgp
, afi
, safi
);
9119 DEFUN (show_bgp_statistics
,
9120 show_bgp_statistics_cmd
,
9121 "show bgp (ipv4|ipv6) (unicast|multicast) statistics",
9126 "Address Family modifier\n"
9127 "Address Family modifier\n"
9128 "BGP RIB advertisement statistics\n")
9130 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
9133 ALIAS (show_bgp_statistics
,
9134 show_bgp_statistics_vpnv4_cmd
,
9135 "show bgp (ipv4) (vpnv4) statistics",
9139 "Address Family modifier\n"
9140 "BGP RIB advertisement statistics\n")
9142 DEFUN (show_bgp_statistics_view
,
9143 show_bgp_statistics_view_cmd
,
9144 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics",
9150 "Address Family modifier\n"
9151 "Address Family modifier\n"
9152 "BGP RIB advertisement statistics\n")
9154 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
9157 ALIAS (show_bgp_statistics_view
,
9158 show_bgp_statistics_view_vpnv4_cmd
,
9159 "show bgp view WORD (ipv4) (vpnv4) statistics",
9164 "Address Family modifier\n"
9165 "BGP RIB advertisement statistics\n")
9177 PCOUNT_PFCNT
, /* the figure we display to users */
9181 static const char *pcount_strs
[] =
9183 [PCOUNT_ADJ_IN
] = "Adj-in",
9184 [PCOUNT_DAMPED
] = "Damped",
9185 [PCOUNT_REMOVED
] = "Removed",
9186 [PCOUNT_HISTORY
] = "History",
9187 [PCOUNT_STALE
] = "Stale",
9188 [PCOUNT_VALID
] = "Valid",
9189 [PCOUNT_ALL
] = "All RIB",
9190 [PCOUNT_COUNTED
] = "PfxCt counted",
9191 [PCOUNT_PFCNT
] = "Useable",
9192 [PCOUNT_MAX
] = NULL
,
9197 unsigned int count
[PCOUNT_MAX
];
9198 const struct peer
*peer
;
9199 const struct bgp_table
*table
;
9203 bgp_peer_count_walker (struct thread
*t
)
9205 struct bgp_node
*rn
;
9206 struct peer_pcounts
*pc
= THREAD_ARG (t
);
9207 const struct peer
*peer
= pc
->peer
;
9209 for (rn
= bgp_table_top (pc
->table
); rn
; rn
= bgp_route_next (rn
))
9211 struct bgp_adj_in
*ain
;
9212 struct bgp_info
*ri
;
9214 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
9215 if (ain
->peer
== peer
)
9216 pc
->count
[PCOUNT_ADJ_IN
]++;
9218 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
9220 char buf
[SU_ADDRSTRLEN
];
9222 if (ri
->peer
!= peer
)
9225 pc
->count
[PCOUNT_ALL
]++;
9227 if (CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
))
9228 pc
->count
[PCOUNT_DAMPED
]++;
9229 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
9230 pc
->count
[PCOUNT_HISTORY
]++;
9231 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
9232 pc
->count
[PCOUNT_REMOVED
]++;
9233 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
9234 pc
->count
[PCOUNT_STALE
]++;
9235 if (CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
))
9236 pc
->count
[PCOUNT_VALID
]++;
9237 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9238 pc
->count
[PCOUNT_PFCNT
]++;
9240 if (CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
9242 pc
->count
[PCOUNT_COUNTED
]++;
9243 if (CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9244 plog_warn (peer
->log
,
9245 "%s [pcount] %s/%d is counted but flags 0x%x",
9247 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
9248 buf
, SU_ADDRSTRLEN
),
9254 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9255 plog_warn (peer
->log
,
9256 "%s [pcount] %s/%d not counted but flags 0x%x",
9258 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
9259 buf
, SU_ADDRSTRLEN
),
9269 bgp_peer_counts (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
)
9271 struct peer_pcounts pcounts
= { .peer
= peer
};
9274 if (!peer
|| !peer
->bgp
|| !peer
->afc
[afi
][safi
]
9275 || !peer
->bgp
->rib
[afi
][safi
])
9277 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
9281 memset (&pcounts
, 0, sizeof(pcounts
));
9282 pcounts
.peer
= peer
;
9283 pcounts
.table
= peer
->bgp
->rib
[afi
][safi
];
9285 /* in-place call via thread subsystem so as to record execution time
9286 * stats for the thread-walk (i.e. ensure this can't be blamed on
9287 * on just vty_read()).
9289 thread_execute (bm
->master
, bgp_peer_count_walker
, &pcounts
, 0);
9291 vty_out (vty
, "Prefix counts for %s, %s%s",
9292 peer
->host
, afi_safi_print (afi
, safi
), VTY_NEWLINE
);
9293 vty_out (vty
, "PfxCt: %ld%s", peer
->pcount
[afi
][safi
], VTY_NEWLINE
);
9294 vty_out (vty
, "%sCounts from RIB table walk:%s%s",
9295 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
9297 for (i
= 0; i
< PCOUNT_MAX
; i
++)
9298 vty_out (vty
, "%20s: %-10d%s",
9299 pcount_strs
[i
], pcounts
.count
[i
], VTY_NEWLINE
);
9301 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
9303 vty_out (vty
, "%s [pcount] PfxCt drift!%s",
9304 peer
->host
, VTY_NEWLINE
);
9305 vty_out (vty
, "Please report this bug, with the above command output%s",
9312 DEFUN (show_ip_bgp_neighbor_prefix_counts
,
9313 show_ip_bgp_neighbor_prefix_counts_cmd
,
9314 "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9318 "Detailed information on TCP and BGP neighbor connections\n"
9319 "Neighbor to display information about\n"
9320 "Neighbor to display information about\n"
9321 "Display detailed prefix count information\n")
9325 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9329 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
);
9332 DEFUN (show_bgp_ipv6_neighbor_prefix_counts
,
9333 show_bgp_ipv6_neighbor_prefix_counts_cmd
,
9334 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9338 "Detailed information on TCP and BGP neighbor connections\n"
9339 "Neighbor to display information about\n"
9340 "Neighbor to display information about\n"
9341 "Display detailed prefix count information\n")
9345 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9349 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
);
9352 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts
,
9353 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
,
9354 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9359 "Address Family modifier\n"
9360 "Address Family modifier\n"
9361 "Detailed information on TCP and BGP neighbor connections\n"
9362 "Neighbor to display information about\n"
9363 "Neighbor to display information about\n"
9364 "Display detailed prefix count information\n")
9368 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9372 if (strncmp (argv
[0], "m", 1) == 0)
9373 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MULTICAST
);
9375 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
);
9378 DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts
,
9379 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
,
9380 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9385 "Address Family modifier\n"
9386 "Address Family modifier\n"
9387 "Detailed information on TCP and BGP neighbor connections\n"
9388 "Neighbor to display information about\n"
9389 "Neighbor to display information about\n"
9390 "Display detailed prefix count information\n")
9394 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9398 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MPLS_VPN
);
9403 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
9406 struct bgp_table
*table
;
9407 struct bgp_adj_in
*ain
;
9408 struct bgp_adj_out
*adj
;
9409 unsigned long output_count
;
9410 struct bgp_node
*rn
;
9420 table
= bgp
->rib
[afi
][safi
];
9424 if (! in
&& CHECK_FLAG (peer
->af_sflags
[afi
][safi
],
9425 PEER_STATUS_DEFAULT_ORIGINATE
))
9427 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9428 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9429 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9431 vty_out (vty
, "Originating default network 0.0.0.0%s%s",
9432 VTY_NEWLINE
, VTY_NEWLINE
);
9436 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
9439 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
9440 if (ain
->peer
== peer
)
9444 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9445 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9446 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9451 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
9456 route_vty_out_tmp (vty
, &rn
->p
, ain
->attr
, safi
);
9463 for (adj
= rn
->adj_out
; adj
; adj
= adj
->next
)
9464 if (adj
->peer
== peer
)
9468 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9469 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9470 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9475 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
9480 route_vty_out_tmp (vty
, &rn
->p
, adj
->attr
, safi
);
9486 if (output_count
!= 0)
9487 vty_out (vty
, "%sTotal number of prefixes %ld%s",
9488 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
9492 peer_adj_routes (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
, int in
)
9494 if (! peer
|| ! peer
->afc
[afi
][safi
])
9496 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
9500 if (in
&& ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
9502 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s",
9507 show_adj_route (vty
, peer
, afi
, safi
, in
);
9512 DEFUN (show_ip_bgp_view_neighbor_advertised_route
,
9513 show_ip_bgp_view_neighbor_advertised_route_cmd
,
9514 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9520 "Detailed information on TCP and BGP neighbor connections\n"
9521 "Neighbor to display information about\n"
9522 "Neighbor to display information about\n"
9523 "Display the routes advertised to a BGP neighbor\n")
9528 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9530 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9535 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0);
9538 ALIAS (show_ip_bgp_view_neighbor_advertised_route
,
9539 show_ip_bgp_neighbor_advertised_route_cmd
,
9540 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9544 "Detailed information on TCP and BGP neighbor connections\n"
9545 "Neighbor to display information about\n"
9546 "Neighbor to display information about\n"
9547 "Display the routes advertised to a BGP neighbor\n")
9549 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
9550 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
9551 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9556 "Address Family modifier\n"
9557 "Address Family modifier\n"
9558 "Detailed information on TCP and BGP neighbor connections\n"
9559 "Neighbor to display information about\n"
9560 "Neighbor to display information about\n"
9561 "Display the routes advertised to a BGP neighbor\n")
9565 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9569 if (strncmp (argv
[0], "m", 1) == 0)
9570 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 0);
9572 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0);
9576 DEFUN (show_bgp_view_neighbor_advertised_route
,
9577 show_bgp_view_neighbor_advertised_route_cmd
,
9578 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9583 "Detailed information on TCP and BGP neighbor connections\n"
9584 "Neighbor to display information about\n"
9585 "Neighbor to display information about\n"
9586 "Display the routes advertised to a BGP neighbor\n")
9591 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9593 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9598 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0);
9601 ALIAS (show_bgp_view_neighbor_advertised_route
,
9602 show_bgp_view_ipv6_neighbor_advertised_route_cmd
,
9603 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9609 "Detailed information on TCP and BGP neighbor connections\n"
9610 "Neighbor to display information about\n"
9611 "Neighbor to display information about\n"
9612 "Display the routes advertised to a BGP neighbor\n")
9614 DEFUN (show_bgp_view_neighbor_received_routes
,
9615 show_bgp_view_neighbor_received_routes_cmd
,
9616 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
9621 "Detailed information on TCP and BGP neighbor connections\n"
9622 "Neighbor to display information about\n"
9623 "Neighbor to display information about\n"
9624 "Display the received routes from neighbor\n")
9629 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9631 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9636 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1);
9639 ALIAS (show_bgp_view_neighbor_received_routes
,
9640 show_bgp_view_ipv6_neighbor_received_routes_cmd
,
9641 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
9647 "Detailed information on TCP and BGP neighbor connections\n"
9648 "Neighbor to display information about\n"
9649 "Neighbor to display information about\n"
9650 "Display the received routes from neighbor\n")
9652 ALIAS (show_bgp_view_neighbor_advertised_route
,
9653 show_bgp_neighbor_advertised_route_cmd
,
9654 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9657 "Detailed information on TCP and BGP neighbor connections\n"
9658 "Neighbor to display information about\n"
9659 "Neighbor to display information about\n"
9660 "Display the routes advertised to a BGP neighbor\n")
9662 ALIAS (show_bgp_view_neighbor_advertised_route
,
9663 show_bgp_ipv6_neighbor_advertised_route_cmd
,
9664 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9668 "Detailed information on TCP and BGP neighbor connections\n"
9669 "Neighbor to display information about\n"
9670 "Neighbor to display information about\n"
9671 "Display the routes advertised to a BGP neighbor\n")
9674 ALIAS (show_bgp_view_neighbor_advertised_route
,
9675 ipv6_bgp_neighbor_advertised_route_cmd
,
9676 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9680 "Detailed information on TCP and BGP neighbor connections\n"
9681 "Neighbor to display information about\n"
9682 "Neighbor to display information about\n"
9683 "Display the routes advertised to a BGP neighbor\n")
9686 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
9687 ipv6_mbgp_neighbor_advertised_route_cmd
,
9688 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9692 "Detailed information on TCP and BGP neighbor connections\n"
9693 "Neighbor to display information about\n"
9694 "Neighbor to display information about\n"
9695 "Display the routes advertised to a BGP neighbor\n")
9699 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9703 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 0);
9705 #endif /* HAVE_IPV6 */
9707 DEFUN (show_ip_bgp_view_neighbor_received_routes
,
9708 show_ip_bgp_view_neighbor_received_routes_cmd
,
9709 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
9715 "Detailed information on TCP and BGP neighbor connections\n"
9716 "Neighbor to display information about\n"
9717 "Neighbor to display information about\n"
9718 "Display the received routes from neighbor\n")
9723 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9725 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9730 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1);
9733 ALIAS (show_ip_bgp_view_neighbor_received_routes
,
9734 show_ip_bgp_neighbor_received_routes_cmd
,
9735 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
9739 "Detailed information on TCP and BGP neighbor connections\n"
9740 "Neighbor to display information about\n"
9741 "Neighbor to display information about\n"
9742 "Display the received routes from neighbor\n")
9744 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
9745 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
9746 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
9751 "Address Family modifier\n"
9752 "Address Family modifier\n"
9753 "Detailed information on TCP and BGP neighbor connections\n"
9754 "Neighbor to display information about\n"
9755 "Neighbor to display information about\n"
9756 "Display the received routes from neighbor\n")
9760 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9764 if (strncmp (argv
[0], "m", 1) == 0)
9765 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 1);
9767 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1);
9770 DEFUN (show_ip_bgp_neighbor_received_prefix_filter
,
9771 show_ip_bgp_neighbor_received_prefix_filter_cmd
,
9772 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9776 "Detailed information on TCP and BGP neighbor connections\n"
9777 "Neighbor to display information about\n"
9778 "Neighbor to display information about\n"
9779 "Display information received from a BGP neighbor\n"
9780 "Display the prefixlist filter\n")
9783 union sockunion
*su
;
9787 su
= sockunion_str2su (argv
[0]);
9791 peer
= peer_lookup (NULL
, su
);
9795 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
9796 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
9799 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
9800 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
9806 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter
,
9807 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
,
9808 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9813 "Address Family modifier\n"
9814 "Address Family modifier\n"
9815 "Detailed information on TCP and BGP neighbor connections\n"
9816 "Neighbor to display information about\n"
9817 "Neighbor to display information about\n"
9818 "Display information received from a BGP neighbor\n"
9819 "Display the prefixlist filter\n")
9822 union sockunion
*su
;
9826 su
= sockunion_str2su (argv
[1]);
9830 peer
= peer_lookup (NULL
, su
);
9834 if (strncmp (argv
[0], "m", 1) == 0)
9836 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_MULTICAST
);
9837 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
9840 vty_out (vty
, "Address family: IPv4 Multicast%s", VTY_NEWLINE
);
9841 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
9846 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
9847 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
9850 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
9851 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
9860 ALIAS (show_bgp_view_neighbor_received_routes
,
9861 show_bgp_neighbor_received_routes_cmd
,
9862 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
9865 "Detailed information on TCP and BGP neighbor connections\n"
9866 "Neighbor to display information about\n"
9867 "Neighbor to display information about\n"
9868 "Display the received routes from neighbor\n")
9870 ALIAS (show_bgp_view_neighbor_received_routes
,
9871 show_bgp_ipv6_neighbor_received_routes_cmd
,
9872 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
9876 "Detailed information on TCP and BGP neighbor connections\n"
9877 "Neighbor to display information about\n"
9878 "Neighbor to display information about\n"
9879 "Display the received routes from neighbor\n")
9881 DEFUN (show_bgp_neighbor_received_prefix_filter
,
9882 show_bgp_neighbor_received_prefix_filter_cmd
,
9883 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9886 "Detailed information on TCP and BGP neighbor connections\n"
9887 "Neighbor to display information about\n"
9888 "Neighbor to display information about\n"
9889 "Display information received from a BGP neighbor\n"
9890 "Display the prefixlist filter\n")
9893 union sockunion
*su
;
9897 su
= sockunion_str2su (argv
[0]);
9901 peer
= peer_lookup (NULL
, su
);
9905 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
9906 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
);
9909 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
9910 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
);
9916 ALIAS (show_bgp_neighbor_received_prefix_filter
,
9917 show_bgp_ipv6_neighbor_received_prefix_filter_cmd
,
9918 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9922 "Detailed information on TCP and BGP neighbor connections\n"
9923 "Neighbor to display information about\n"
9924 "Neighbor to display information about\n"
9925 "Display information received from a BGP neighbor\n"
9926 "Display the prefixlist filter\n")
9929 ALIAS (show_bgp_view_neighbor_received_routes
,
9930 ipv6_bgp_neighbor_received_routes_cmd
,
9931 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
9935 "Detailed information on TCP and BGP neighbor connections\n"
9936 "Neighbor to display information about\n"
9937 "Neighbor to display information about\n"
9938 "Display the received routes from neighbor\n")
9941 DEFUN (ipv6_mbgp_neighbor_received_routes
,
9942 ipv6_mbgp_neighbor_received_routes_cmd
,
9943 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-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 received routes from neighbor\n")
9954 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9958 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 1);
9961 DEFUN (show_bgp_view_neighbor_received_prefix_filter
,
9962 show_bgp_view_neighbor_received_prefix_filter_cmd
,
9963 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9968 "Detailed information on TCP and BGP neighbor connections\n"
9969 "Neighbor to display information about\n"
9970 "Neighbor to display information about\n"
9971 "Display information received from a BGP neighbor\n"
9972 "Display the prefixlist filter\n")
9975 union sockunion
*su
;
9980 /* BGP structure lookup. */
9981 bgp
= bgp_lookup_by_name (argv
[0]);
9984 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
9988 su
= sockunion_str2su (argv
[1]);
9992 peer
= peer_lookup (bgp
, su
);
9996 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
9997 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
);
10000 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
10001 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
);
10004 return CMD_SUCCESS
;
10007 ALIAS (show_bgp_view_neighbor_received_prefix_filter
,
10008 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
,
10009 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10015 "Detailed information on TCP and BGP neighbor connections\n"
10016 "Neighbor to display information about\n"
10017 "Neighbor to display information about\n"
10018 "Display information received from a BGP neighbor\n"
10019 "Display the prefixlist filter\n")
10020 #endif /* HAVE_IPV6 */
10023 bgp_show_neighbor_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
,
10024 safi_t safi
, enum bgp_show_type type
)
10026 if (! peer
|| ! peer
->afc
[afi
][safi
])
10028 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
10029 return CMD_WARNING
;
10032 return bgp_show (vty
, peer
->bgp
, afi
, safi
, type
, &peer
->su
);
10035 DEFUN (show_ip_bgp_neighbor_routes
,
10036 show_ip_bgp_neighbor_routes_cmd
,
10037 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
10041 "Detailed information on TCP and BGP neighbor connections\n"
10042 "Neighbor to display information about\n"
10043 "Neighbor to display information about\n"
10044 "Display routes learned from neighbor\n")
10048 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10050 return CMD_WARNING
;
10052 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10053 bgp_show_type_neighbor
);
10056 DEFUN (show_ip_bgp_neighbor_flap
,
10057 show_ip_bgp_neighbor_flap_cmd
,
10058 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10062 "Detailed information on TCP and BGP neighbor connections\n"
10063 "Neighbor to display information about\n"
10064 "Neighbor to display information about\n"
10065 "Display flap statistics of the routes learned from neighbor\n")
10069 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10071 return CMD_WARNING
;
10073 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10074 bgp_show_type_flap_neighbor
);
10077 DEFUN (show_ip_bgp_neighbor_damp
,
10078 show_ip_bgp_neighbor_damp_cmd
,
10079 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10083 "Detailed information on TCP and BGP neighbor connections\n"
10084 "Neighbor to display information about\n"
10085 "Neighbor to display information about\n"
10086 "Display the dampened routes received from neighbor\n")
10090 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10092 return CMD_WARNING
;
10094 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10095 bgp_show_type_damp_neighbor
);
10098 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
10099 show_ip_bgp_ipv4_neighbor_routes_cmd
,
10100 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
10105 "Address Family modifier\n"
10106 "Address Family modifier\n"
10107 "Detailed information on TCP and BGP neighbor connections\n"
10108 "Neighbor to display information about\n"
10109 "Neighbor to display information about\n"
10110 "Display routes learned from neighbor\n")
10114 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
10116 return CMD_WARNING
;
10118 if (strncmp (argv
[0], "m", 1) == 0)
10119 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_MULTICAST
,
10120 bgp_show_type_neighbor
);
10122 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10123 bgp_show_type_neighbor
);
10126 DEFUN (show_ip_bgp_view_rsclient
,
10127 show_ip_bgp_view_rsclient_cmd
,
10128 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
10134 "Information about Route Server Client\n"
10137 struct bgp_table
*table
;
10141 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10143 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10146 return CMD_WARNING
;
10148 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
10150 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10152 return CMD_WARNING
;
10155 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
10156 PEER_FLAG_RSERVER_CLIENT
))
10158 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10160 return CMD_WARNING
;
10163 table
= peer
->rib
[AFI_IP
][SAFI_UNICAST
];
10165 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
10168 ALIAS (show_ip_bgp_view_rsclient
,
10169 show_ip_bgp_rsclient_cmd
,
10170 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
10174 "Information about Route Server Client\n"
10177 DEFUN (show_ip_bgp_view_rsclient_route
,
10178 show_ip_bgp_view_rsclient_route_cmd
,
10179 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
10185 "Information about Route Server Client\n"
10187 "Network in the BGP routing table to display\n")
10192 /* BGP structure lookup. */
10195 bgp
= bgp_lookup_by_name (argv
[0]);
10198 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10199 return CMD_WARNING
;
10204 bgp
= bgp_get_default ();
10207 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10208 return CMD_WARNING
;
10213 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10215 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10218 return CMD_WARNING
;
10220 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
10222 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10224 return CMD_WARNING
;
10227 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
10228 PEER_FLAG_RSERVER_CLIENT
))
10230 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10232 return CMD_WARNING
;
10235 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][SAFI_UNICAST
],
10236 (argc
== 3) ? argv
[2] : argv
[1],
10237 AFI_IP
, SAFI_UNICAST
, NULL
, 0);
10240 ALIAS (show_ip_bgp_view_rsclient_route
,
10241 show_ip_bgp_rsclient_route_cmd
,
10242 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
10246 "Information about Route Server Client\n"
10248 "Network in the BGP routing table to display\n")
10250 DEFUN (show_ip_bgp_view_rsclient_prefix
,
10251 show_ip_bgp_view_rsclient_prefix_cmd
,
10252 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
10258 "Information about Route Server Client\n"
10260 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10265 /* BGP structure lookup. */
10268 bgp
= bgp_lookup_by_name (argv
[0]);
10271 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10272 return CMD_WARNING
;
10277 bgp
= bgp_get_default ();
10280 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10281 return CMD_WARNING
;
10286 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10288 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10291 return CMD_WARNING
;
10293 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
10295 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10297 return CMD_WARNING
;
10300 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
10301 PEER_FLAG_RSERVER_CLIENT
))
10303 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10305 return CMD_WARNING
;
10308 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][SAFI_UNICAST
],
10309 (argc
== 3) ? argv
[2] : argv
[1],
10310 AFI_IP
, SAFI_UNICAST
, NULL
, 1);
10313 ALIAS (show_ip_bgp_view_rsclient_prefix
,
10314 show_ip_bgp_rsclient_prefix_cmd
,
10315 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
10319 "Information about Route Server Client\n"
10321 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10325 DEFUN (show_bgp_view_neighbor_routes
,
10326 show_bgp_view_neighbor_routes_cmd
,
10327 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
10332 "Detailed information on TCP and BGP neighbor connections\n"
10333 "Neighbor to display information about\n"
10334 "Neighbor to display information about\n"
10335 "Display routes learned from neighbor\n")
10340 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10342 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10345 return CMD_WARNING
;
10347 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
10348 bgp_show_type_neighbor
);
10351 ALIAS (show_bgp_view_neighbor_routes
,
10352 show_bgp_view_ipv6_neighbor_routes_cmd
,
10353 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
10359 "Detailed information on TCP and BGP neighbor connections\n"
10360 "Neighbor to display information about\n"
10361 "Neighbor to display information about\n"
10362 "Display routes learned from neighbor\n")
10364 DEFUN (show_bgp_view_neighbor_damp
,
10365 show_bgp_view_neighbor_damp_cmd
,
10366 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10371 "Detailed information on TCP and BGP neighbor connections\n"
10372 "Neighbor to display information about\n"
10373 "Neighbor to display information about\n"
10374 "Display the dampened routes received from neighbor\n")
10379 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10381 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10384 return CMD_WARNING
;
10386 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
10387 bgp_show_type_damp_neighbor
);
10390 ALIAS (show_bgp_view_neighbor_damp
,
10391 show_bgp_view_ipv6_neighbor_damp_cmd
,
10392 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10398 "Detailed information on TCP and BGP neighbor connections\n"
10399 "Neighbor to display information about\n"
10400 "Neighbor to display information about\n"
10401 "Display the dampened routes received from neighbor\n")
10403 DEFUN (show_bgp_view_neighbor_flap
,
10404 show_bgp_view_neighbor_flap_cmd
,
10405 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10410 "Detailed information on TCP and BGP neighbor connections\n"
10411 "Neighbor to display information about\n"
10412 "Neighbor to display information about\n"
10413 "Display flap statistics of the routes learned from neighbor\n")
10418 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10420 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10423 return CMD_WARNING
;
10425 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
10426 bgp_show_type_flap_neighbor
);
10429 ALIAS (show_bgp_view_neighbor_flap
,
10430 show_bgp_view_ipv6_neighbor_flap_cmd
,
10431 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10437 "Detailed information on TCP and BGP neighbor connections\n"
10438 "Neighbor to display information about\n"
10439 "Neighbor to display information about\n"
10440 "Display flap statistics of the routes learned from neighbor\n")
10442 ALIAS (show_bgp_view_neighbor_routes
,
10443 show_bgp_neighbor_routes_cmd
,
10444 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
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")
10453 ALIAS (show_bgp_view_neighbor_routes
,
10454 show_bgp_ipv6_neighbor_routes_cmd
,
10455 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
10459 "Detailed information on TCP and BGP neighbor connections\n"
10460 "Neighbor to display information about\n"
10461 "Neighbor to display information about\n"
10462 "Display routes learned from neighbor\n")
10465 ALIAS (show_bgp_view_neighbor_routes
,
10466 ipv6_bgp_neighbor_routes_cmd
,
10467 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
10471 "Detailed information on TCP and BGP neighbor connections\n"
10472 "Neighbor to display information about\n"
10473 "Neighbor to display information about\n"
10474 "Display routes learned from neighbor\n")
10477 DEFUN (ipv6_mbgp_neighbor_routes
,
10478 ipv6_mbgp_neighbor_routes_cmd
,
10479 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
10483 "Detailed information on TCP and BGP neighbor connections\n"
10484 "Neighbor to display information about\n"
10485 "Neighbor to display information about\n"
10486 "Display routes learned from neighbor\n")
10490 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10492 return CMD_WARNING
;
10494 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
,
10495 bgp_show_type_neighbor
);
10498 ALIAS (show_bgp_view_neighbor_flap
,
10499 show_bgp_neighbor_flap_cmd
,
10500 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10503 "Detailed information on TCP and BGP neighbor connections\n"
10504 "Neighbor to display information about\n"
10505 "Neighbor to display information about\n"
10506 "Display flap statistics of the routes learned from neighbor\n")
10508 ALIAS (show_bgp_view_neighbor_flap
,
10509 show_bgp_ipv6_neighbor_flap_cmd
,
10510 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10514 "Detailed information on TCP and BGP neighbor connections\n"
10515 "Neighbor to display information about\n"
10516 "Neighbor to display information about\n"
10517 "Display flap statistics of the routes learned from neighbor\n")
10519 ALIAS (show_bgp_view_neighbor_damp
,
10520 show_bgp_neighbor_damp_cmd
,
10521 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10524 "Detailed information on TCP and BGP neighbor connections\n"
10525 "Neighbor to display information about\n"
10526 "Neighbor to display information about\n"
10527 "Display the dampened routes received from neighbor\n")
10529 ALIAS (show_bgp_view_neighbor_damp
,
10530 show_bgp_ipv6_neighbor_damp_cmd
,
10531 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10535 "Detailed information on TCP and BGP neighbor connections\n"
10536 "Neighbor to display information about\n"
10537 "Neighbor to display information about\n"
10538 "Display the dampened routes received from neighbor\n")
10540 DEFUN (show_bgp_view_rsclient
,
10541 show_bgp_view_rsclient_cmd
,
10542 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
10547 "Information about Route Server Client\n"
10550 struct bgp_table
*table
;
10554 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10556 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10559 return CMD_WARNING
;
10561 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
10563 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10565 return CMD_WARNING
;
10568 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
10569 PEER_FLAG_RSERVER_CLIENT
))
10571 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10573 return CMD_WARNING
;
10576 table
= peer
->rib
[AFI_IP6
][SAFI_UNICAST
];
10578 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
10581 ALIAS (show_bgp_view_rsclient
,
10582 show_bgp_rsclient_cmd
,
10583 "show bgp rsclient (A.B.C.D|X:X::X:X)",
10586 "Information about Route Server Client\n"
10589 DEFUN (show_bgp_view_rsclient_route
,
10590 show_bgp_view_rsclient_route_cmd
,
10591 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
10596 "Information about Route Server Client\n"
10598 "Network in the BGP routing table to display\n")
10603 /* BGP structure lookup. */
10606 bgp
= bgp_lookup_by_name (argv
[0]);
10609 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10610 return CMD_WARNING
;
10615 bgp
= bgp_get_default ();
10618 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10619 return CMD_WARNING
;
10624 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10626 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10629 return CMD_WARNING
;
10631 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
10633 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10635 return CMD_WARNING
;
10638 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
10639 PEER_FLAG_RSERVER_CLIENT
))
10641 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10643 return CMD_WARNING
;
10646 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][SAFI_UNICAST
],
10647 (argc
== 3) ? argv
[2] : argv
[1],
10648 AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
10651 ALIAS (show_bgp_view_rsclient_route
,
10652 show_bgp_rsclient_route_cmd
,
10653 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
10656 "Information about Route Server Client\n"
10658 "Network in the BGP routing table to display\n")
10660 DEFUN (show_bgp_view_rsclient_prefix
,
10661 show_bgp_view_rsclient_prefix_cmd
,
10662 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
10667 "Information about Route Server Client\n"
10669 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
10674 /* BGP structure lookup. */
10677 bgp
= bgp_lookup_by_name (argv
[0]);
10680 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10681 return CMD_WARNING
;
10686 bgp
= bgp_get_default ();
10689 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10690 return CMD_WARNING
;
10695 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10697 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10700 return CMD_WARNING
;
10702 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
10704 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10706 return CMD_WARNING
;
10709 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
10710 PEER_FLAG_RSERVER_CLIENT
))
10712 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10714 return CMD_WARNING
;
10717 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][SAFI_UNICAST
],
10718 (argc
== 3) ? argv
[2] : argv
[1],
10719 AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
10722 ALIAS (show_bgp_view_rsclient_prefix
,
10723 show_bgp_rsclient_prefix_cmd
,
10724 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
10727 "Information about Route Server Client\n"
10729 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
10731 #endif /* HAVE_IPV6 */
10733 struct bgp_table
*bgp_distance_table
;
10735 struct bgp_distance
10737 /* Distance value for the IP source prefix. */
10740 /* Name of the access-list to be matched. */
10744 static struct bgp_distance
*
10745 bgp_distance_new (void)
10747 return XCALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
10751 bgp_distance_free (struct bgp_distance
*bdistance
)
10753 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
10757 bgp_distance_set (struct vty
*vty
, const char *distance_str
,
10758 const char *ip_str
, const char *access_list_str
)
10761 struct prefix_ipv4 p
;
10763 struct bgp_node
*rn
;
10764 struct bgp_distance
*bdistance
;
10766 ret
= str2prefix_ipv4 (ip_str
, &p
);
10769 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
10770 return CMD_WARNING
;
10773 distance
= atoi (distance_str
);
10775 /* Get BGP distance node. */
10776 rn
= bgp_node_get (bgp_distance_table
, (struct prefix
*) &p
);
10779 bdistance
= rn
->info
;
10780 bgp_unlock_node (rn
);
10784 bdistance
= bgp_distance_new ();
10785 rn
->info
= bdistance
;
10788 /* Set distance value. */
10789 bdistance
->distance
= distance
;
10791 /* Reset access-list configuration. */
10792 if (bdistance
->access_list
)
10794 free (bdistance
->access_list
);
10795 bdistance
->access_list
= NULL
;
10797 if (access_list_str
)
10798 bdistance
->access_list
= strdup (access_list_str
);
10800 return CMD_SUCCESS
;
10804 bgp_distance_unset (struct vty
*vty
, const char *distance_str
,
10805 const char *ip_str
, const char *access_list_str
)
10808 struct prefix_ipv4 p
;
10810 struct bgp_node
*rn
;
10811 struct bgp_distance
*bdistance
;
10813 ret
= str2prefix_ipv4 (ip_str
, &p
);
10816 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
10817 return CMD_WARNING
;
10820 distance
= atoi (distance_str
);
10822 rn
= bgp_node_lookup (bgp_distance_table
, (struct prefix
*)&p
);
10825 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
10826 return CMD_WARNING
;
10829 bdistance
= rn
->info
;
10831 if (bdistance
->access_list
)
10832 free (bdistance
->access_list
);
10833 bgp_distance_free (bdistance
);
10836 bgp_unlock_node (rn
);
10837 bgp_unlock_node (rn
);
10839 return CMD_SUCCESS
;
10842 /* Apply BGP information to distance method. */
10844 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, struct bgp
*bgp
)
10846 struct bgp_node
*rn
;
10847 struct prefix_ipv4 q
;
10849 struct bgp_distance
*bdistance
;
10850 struct access_list
*alist
;
10851 struct bgp_static
*bgp_static
;
10856 if (p
->family
!= AF_INET
)
10859 peer
= rinfo
->peer
;
10861 if (peer
->su
.sa
.sa_family
!= AF_INET
)
10864 memset (&q
, 0, sizeof (struct prefix_ipv4
));
10865 q
.family
= AF_INET
;
10866 q
.prefix
= peer
->su
.sin
.sin_addr
;
10867 q
.prefixlen
= IPV4_MAX_BITLEN
;
10869 /* Check source address. */
10870 rn
= bgp_node_match (bgp_distance_table
, (struct prefix
*) &q
);
10873 bdistance
= rn
->info
;
10874 bgp_unlock_node (rn
);
10876 if (bdistance
->access_list
)
10878 alist
= access_list_lookup (AFI_IP
, bdistance
->access_list
);
10879 if (alist
&& access_list_apply (alist
, p
) == FILTER_PERMIT
)
10880 return bdistance
->distance
;
10883 return bdistance
->distance
;
10886 /* Backdoor check. */
10887 rn
= bgp_node_lookup (bgp
->route
[AFI_IP
][SAFI_UNICAST
], p
);
10890 bgp_static
= rn
->info
;
10891 bgp_unlock_node (rn
);
10893 if (bgp_static
->backdoor
)
10895 if (bgp
->distance_local
)
10896 return bgp
->distance_local
;
10898 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
10902 if (peer_sort (peer
) == BGP_PEER_EBGP
)
10904 if (bgp
->distance_ebgp
)
10905 return bgp
->distance_ebgp
;
10906 return ZEBRA_EBGP_DISTANCE_DEFAULT
;
10910 if (bgp
->distance_ibgp
)
10911 return bgp
->distance_ibgp
;
10912 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
10916 DEFUN (bgp_distance
,
10918 "distance bgp <1-255> <1-255> <1-255>",
10919 "Define an administrative distance\n"
10921 "Distance for routes external to the AS\n"
10922 "Distance for routes internal to the AS\n"
10923 "Distance for local routes\n")
10929 bgp
->distance_ebgp
= atoi (argv
[0]);
10930 bgp
->distance_ibgp
= atoi (argv
[1]);
10931 bgp
->distance_local
= atoi (argv
[2]);
10932 return CMD_SUCCESS
;
10935 DEFUN (no_bgp_distance
,
10936 no_bgp_distance_cmd
,
10937 "no distance bgp <1-255> <1-255> <1-255>",
10939 "Define an administrative distance\n"
10941 "Distance for routes external to the AS\n"
10942 "Distance for routes internal to the AS\n"
10943 "Distance for local routes\n")
10949 bgp
->distance_ebgp
= 0;
10950 bgp
->distance_ibgp
= 0;
10951 bgp
->distance_local
= 0;
10952 return CMD_SUCCESS
;
10955 ALIAS (no_bgp_distance
,
10956 no_bgp_distance2_cmd
,
10959 "Define an administrative distance\n"
10962 DEFUN (bgp_distance_source
,
10963 bgp_distance_source_cmd
,
10964 "distance <1-255> A.B.C.D/M",
10965 "Define an administrative distance\n"
10966 "Administrative distance\n"
10967 "IP source prefix\n")
10969 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
10970 return CMD_SUCCESS
;
10973 DEFUN (no_bgp_distance_source
,
10974 no_bgp_distance_source_cmd
,
10975 "no distance <1-255> A.B.C.D/M",
10977 "Define an administrative distance\n"
10978 "Administrative distance\n"
10979 "IP source prefix\n")
10981 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
10982 return CMD_SUCCESS
;
10985 DEFUN (bgp_distance_source_access_list
,
10986 bgp_distance_source_access_list_cmd
,
10987 "distance <1-255> A.B.C.D/M WORD",
10988 "Define an administrative distance\n"
10989 "Administrative distance\n"
10990 "IP source prefix\n"
10991 "Access list name\n")
10993 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
10994 return CMD_SUCCESS
;
10997 DEFUN (no_bgp_distance_source_access_list
,
10998 no_bgp_distance_source_access_list_cmd
,
10999 "no distance <1-255> A.B.C.D/M WORD",
11001 "Define an administrative distance\n"
11002 "Administrative distance\n"
11003 "IP source prefix\n"
11004 "Access list name\n")
11006 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
11007 return CMD_SUCCESS
;
11010 DEFUN (bgp_damp_set
,
11012 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
11013 "BGP Specific commands\n"
11014 "Enable route-flap dampening\n"
11015 "Half-life time for the penalty\n"
11016 "Value to start reusing a route\n"
11017 "Value to start suppressing a route\n"
11018 "Maximum duration to suppress a stable route\n")
11021 int half
= DEFAULT_HALF_LIFE
* 60;
11022 int reuse
= DEFAULT_REUSE
;
11023 int suppress
= DEFAULT_SUPPRESS
;
11024 int max
= 4 * half
;
11028 half
= atoi (argv
[0]) * 60;
11029 reuse
= atoi (argv
[1]);
11030 suppress
= atoi (argv
[2]);
11031 max
= atoi (argv
[3]) * 60;
11033 else if (argc
== 1)
11035 half
= atoi (argv
[0]) * 60;
11040 return bgp_damp_enable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
),
11041 half
, reuse
, suppress
, max
);
11044 ALIAS (bgp_damp_set
,
11046 "bgp dampening <1-45>",
11047 "BGP Specific commands\n"
11048 "Enable route-flap dampening\n"
11049 "Half-life time for the penalty\n")
11051 ALIAS (bgp_damp_set
,
11054 "BGP Specific commands\n"
11055 "Enable route-flap dampening\n")
11057 DEFUN (bgp_damp_unset
,
11058 bgp_damp_unset_cmd
,
11059 "no bgp dampening",
11061 "BGP Specific commands\n"
11062 "Enable route-flap dampening\n")
11067 return bgp_damp_disable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
));
11070 ALIAS (bgp_damp_unset
,
11071 bgp_damp_unset2_cmd
,
11072 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
11074 "BGP Specific commands\n"
11075 "Enable route-flap dampening\n"
11076 "Half-life time for the penalty\n"
11077 "Value to start reusing a route\n"
11078 "Value to start suppressing a route\n"
11079 "Maximum duration to suppress a stable route\n")
11081 DEFUN (show_ip_bgp_dampened_paths
,
11082 show_ip_bgp_dampened_paths_cmd
,
11083 "show ip bgp dampened-paths",
11087 "Display paths suppressed due to dampening\n")
11089 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_dampend_paths
,
11093 DEFUN (show_ip_bgp_flap_statistics
,
11094 show_ip_bgp_flap_statistics_cmd
,
11095 "show ip bgp flap-statistics",
11099 "Display flap statistics of routes\n")
11101 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
11102 bgp_show_type_flap_statistics
, NULL
);
11105 /* Display specified route of BGP table. */
11107 bgp_clear_damp_route (struct vty
*vty
, const char *view_name
,
11108 const char *ip_str
, afi_t afi
, safi_t safi
,
11109 struct prefix_rd
*prd
, int prefix_check
)
11112 struct prefix match
;
11113 struct bgp_node
*rn
;
11114 struct bgp_node
*rm
;
11115 struct bgp_info
*ri
;
11116 struct bgp_info
*ri_temp
;
11118 struct bgp_table
*table
;
11120 /* BGP structure lookup. */
11123 bgp
= bgp_lookup_by_name (view_name
);
11126 vty_out (vty
, "%% Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
11127 return CMD_WARNING
;
11132 bgp
= bgp_get_default ();
11135 vty_out (vty
, "%% No BGP process is configured%s", VTY_NEWLINE
);
11136 return CMD_WARNING
;
11140 /* Check IP address argument. */
11141 ret
= str2prefix (ip_str
, &match
);
11144 vty_out (vty
, "%% address is malformed%s", VTY_NEWLINE
);
11145 return CMD_WARNING
;
11148 match
.family
= afi2family (afi
);
11150 if (safi
== SAFI_MPLS_VPN
)
11152 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][SAFI_MPLS_VPN
]); rn
; rn
= bgp_route_next (rn
))
11154 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
11157 if ((table
= rn
->info
) != NULL
)
11158 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
11159 if (! prefix_check
|| rm
->p
.prefixlen
== match
.prefixlen
)
11164 if (ri
->extra
&& ri
->extra
->damp_info
)
11166 ri_temp
= ri
->next
;
11167 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
11178 if ((rn
= bgp_node_match (bgp
->rib
[afi
][safi
], &match
)) != NULL
)
11179 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
11184 if (ri
->extra
&& ri
->extra
->damp_info
)
11186 ri_temp
= ri
->next
;
11187 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
11196 return CMD_SUCCESS
;
11199 DEFUN (clear_ip_bgp_dampening
,
11200 clear_ip_bgp_dampening_cmd
,
11201 "clear ip bgp dampening",
11205 "Clear route flap dampening information\n")
11207 bgp_damp_info_clean ();
11208 return CMD_SUCCESS
;
11211 DEFUN (clear_ip_bgp_dampening_prefix
,
11212 clear_ip_bgp_dampening_prefix_cmd
,
11213 "clear ip bgp dampening A.B.C.D/M",
11217 "Clear route flap dampening information\n"
11218 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11220 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
11221 SAFI_UNICAST
, NULL
, 1);
11224 DEFUN (clear_ip_bgp_dampening_address
,
11225 clear_ip_bgp_dampening_address_cmd
,
11226 "clear ip bgp dampening A.B.C.D",
11230 "Clear route flap dampening information\n"
11231 "Network to clear damping information\n")
11233 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
11234 SAFI_UNICAST
, NULL
, 0);
11237 DEFUN (clear_ip_bgp_dampening_address_mask
,
11238 clear_ip_bgp_dampening_address_mask_cmd
,
11239 "clear ip bgp dampening A.B.C.D A.B.C.D",
11243 "Clear route flap dampening information\n"
11244 "Network to clear damping information\n"
11248 char prefix_str
[BUFSIZ
];
11250 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
11253 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
11254 return CMD_WARNING
;
11257 return bgp_clear_damp_route (vty
, NULL
, prefix_str
, AFI_IP
,
11258 SAFI_UNICAST
, NULL
, 0);
11262 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
11263 afi_t afi
, safi_t safi
, int *write
)
11265 struct bgp_node
*prn
;
11266 struct bgp_node
*rn
;
11267 struct bgp_table
*table
;
11269 struct prefix_rd
*prd
;
11270 struct bgp_static
*bgp_static
;
11272 char buf
[SU_ADDRSTRLEN
];
11273 char rdbuf
[RD_ADDRSTRLEN
];
11275 /* Network configuration. */
11276 for (prn
= bgp_table_top (bgp
->route
[afi
][safi
]); prn
; prn
= bgp_route_next (prn
))
11277 if ((table
= prn
->info
) != NULL
)
11278 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
11279 if ((bgp_static
= rn
->info
) != NULL
)
11282 prd
= (struct prefix_rd
*) &prn
->p
;
11284 /* "address-family" display. */
11285 bgp_config_write_family_header (vty
, afi
, safi
, write
);
11287 /* "network" configuration display. */
11288 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
11289 label
= decode_label (bgp_static
->tag
);
11291 vty_out (vty
, " network %s/%d rd %s tag %d",
11292 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
11295 vty_out (vty
, "%s", VTY_NEWLINE
);
11300 /* Configuration of static route announcement and aggregate
11303 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
11304 afi_t afi
, safi_t safi
, int *write
)
11306 struct bgp_node
*rn
;
11308 struct bgp_static
*bgp_static
;
11309 struct bgp_aggregate
*bgp_aggregate
;
11310 char buf
[SU_ADDRSTRLEN
];
11312 if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
11313 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
11315 /* Network configuration. */
11316 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
11317 if ((bgp_static
= rn
->info
) != NULL
)
11321 /* "address-family" display. */
11322 bgp_config_write_family_header (vty
, afi
, safi
, write
);
11324 /* "network" configuration display. */
11325 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
11327 u_int32_t destination
;
11328 struct in_addr netmask
;
11330 destination
= ntohl (p
->u
.prefix4
.s_addr
);
11331 masklen2ip (p
->prefixlen
, &netmask
);
11332 vty_out (vty
, " network %s",
11333 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
));
11335 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
11336 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
11337 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
11338 || p
->u
.prefix4
.s_addr
== 0)
11340 /* Natural mask is not display. */
11343 vty_out (vty
, " mask %s", inet_ntoa (netmask
));
11347 vty_out (vty
, " network %s/%d",
11348 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
11352 if (bgp_static
->rmap
.name
)
11353 vty_out (vty
, " route-map %s", bgp_static
->rmap
.name
);
11356 if (bgp_static
->backdoor
)
11357 vty_out (vty
, " backdoor");
11360 vty_out (vty
, "%s", VTY_NEWLINE
);
11363 /* Aggregate-address configuration. */
11364 for (rn
= bgp_table_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
11365 if ((bgp_aggregate
= rn
->info
) != NULL
)
11369 /* "address-family" display. */
11370 bgp_config_write_family_header (vty
, afi
, safi
, write
);
11372 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
11374 struct in_addr netmask
;
11376 masklen2ip (p
->prefixlen
, &netmask
);
11377 vty_out (vty
, " aggregate-address %s %s",
11378 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
11379 inet_ntoa (netmask
));
11383 vty_out (vty
, " aggregate-address %s/%d",
11384 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
11388 if (bgp_aggregate
->as_set
)
11389 vty_out (vty
, " as-set");
11391 if (bgp_aggregate
->summary_only
)
11392 vty_out (vty
, " summary-only");
11394 vty_out (vty
, "%s", VTY_NEWLINE
);
11401 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
)
11403 struct bgp_node
*rn
;
11404 struct bgp_distance
*bdistance
;
11406 /* Distance configuration. */
11407 if (bgp
->distance_ebgp
11408 && bgp
->distance_ibgp
11409 && bgp
->distance_local
11410 && (bgp
->distance_ebgp
!= ZEBRA_EBGP_DISTANCE_DEFAULT
11411 || bgp
->distance_ibgp
!= ZEBRA_IBGP_DISTANCE_DEFAULT
11412 || bgp
->distance_local
!= ZEBRA_IBGP_DISTANCE_DEFAULT
))
11413 vty_out (vty
, " distance bgp %d %d %d%s",
11414 bgp
->distance_ebgp
, bgp
->distance_ibgp
, bgp
->distance_local
,
11417 for (rn
= bgp_table_top (bgp_distance_table
); rn
; rn
= bgp_route_next (rn
))
11418 if ((bdistance
= rn
->info
) != NULL
)
11420 vty_out (vty
, " distance %d %s/%d %s%s", bdistance
->distance
,
11421 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
11422 bdistance
->access_list
? bdistance
->access_list
: "",
11429 /* Allocate routing table structure and install commands. */
11431 bgp_route_init (void)
11433 /* Init BGP distance table. */
11434 bgp_distance_table
= bgp_table_init (AFI_IP
, SAFI_UNICAST
);
11436 /* IPv4 BGP commands. */
11437 install_element (BGP_NODE
, &bgp_network_cmd
);
11438 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
11439 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
11440 install_element (BGP_NODE
, &bgp_network_route_map_cmd
);
11441 install_element (BGP_NODE
, &bgp_network_mask_route_map_cmd
);
11442 install_element (BGP_NODE
, &bgp_network_mask_natural_route_map_cmd
);
11443 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
11444 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
11445 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
11446 install_element (BGP_NODE
, &no_bgp_network_cmd
);
11447 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
11448 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
11449 install_element (BGP_NODE
, &no_bgp_network_route_map_cmd
);
11450 install_element (BGP_NODE
, &no_bgp_network_mask_route_map_cmd
);
11451 install_element (BGP_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
11452 install_element (BGP_NODE
, &no_bgp_network_backdoor_cmd
);
11453 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_cmd
);
11454 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_cmd
);
11456 install_element (BGP_NODE
, &aggregate_address_cmd
);
11457 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
11458 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
11459 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
11460 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
11461 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
11462 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
11463 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
11464 install_element (BGP_NODE
, &aggregate_address_summary_as_set_cmd
);
11465 install_element (BGP_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
11466 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
11467 install_element (BGP_NODE
, &no_aggregate_address_summary_only_cmd
);
11468 install_element (BGP_NODE
, &no_aggregate_address_as_set_cmd
);
11469 install_element (BGP_NODE
, &no_aggregate_address_as_set_summary_cmd
);
11470 install_element (BGP_NODE
, &no_aggregate_address_summary_as_set_cmd
);
11471 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
11472 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
11473 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_cmd
);
11474 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
11475 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
11477 /* IPv4 unicast configuration. */
11478 install_element (BGP_IPV4_NODE
, &bgp_network_cmd
);
11479 install_element (BGP_IPV4_NODE
, &bgp_network_mask_cmd
);
11480 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_cmd
);
11481 install_element (BGP_IPV4_NODE
, &bgp_network_route_map_cmd
);
11482 install_element (BGP_IPV4_NODE
, &bgp_network_mask_route_map_cmd
);
11483 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_route_map_cmd
);
11484 install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
11485 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_cmd
);
11486 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_cmd
);
11487 install_element (BGP_IPV4_NODE
, &no_bgp_network_route_map_cmd
);
11488 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_route_map_cmd
);
11489 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
11491 install_element (BGP_IPV4_NODE
, &aggregate_address_cmd
);
11492 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_cmd
);
11493 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_only_cmd
);
11494 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_only_cmd
);
11495 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_cmd
);
11496 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_cmd
);
11497 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_summary_cmd
);
11498 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
11499 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_as_set_cmd
);
11500 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
11501 install_element (BGP_IPV4_NODE
, &no_aggregate_address_cmd
);
11502 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_only_cmd
);
11503 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_cmd
);
11504 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_summary_cmd
);
11505 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_as_set_cmd
);
11506 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_cmd
);
11507 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
11508 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_cmd
);
11509 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
11510 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
11512 /* IPv4 multicast configuration. */
11513 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
11514 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
11515 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
11516 install_element (BGP_IPV4M_NODE
, &bgp_network_route_map_cmd
);
11517 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_route_map_cmd
);
11518 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_route_map_cmd
);
11519 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
11520 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
11521 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
11522 install_element (BGP_IPV4M_NODE
, &no_bgp_network_route_map_cmd
);
11523 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_route_map_cmd
);
11524 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
11525 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
11526 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
11527 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
11528 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
11529 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
11530 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
11531 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
11532 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
11533 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_as_set_cmd
);
11534 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
11535 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
11536 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_only_cmd
);
11537 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_cmd
);
11538 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_summary_cmd
);
11539 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_as_set_cmd
);
11540 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
11541 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
11542 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_cmd
);
11543 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
11544 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
11546 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
11547 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
11548 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
11549 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
11550 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
11551 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
11552 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
11553 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
11554 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
11555 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
11556 install_element (VIEW_NODE
, &show_ip_bgp_view_cmd
);
11557 install_element (VIEW_NODE
, &show_ip_bgp_view_route_cmd
);
11558 install_element (VIEW_NODE
, &show_ip_bgp_view_prefix_cmd
);
11559 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
11560 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
11561 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
11562 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
11563 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
11564 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
11565 install_element (VIEW_NODE
, &show_ip_bgp_route_map_cmd
);
11566 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
11567 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
11568 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
11569 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
11570 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
11571 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
11572 install_element (VIEW_NODE
, &show_ip_bgp_community2_cmd
);
11573 install_element (VIEW_NODE
, &show_ip_bgp_community3_cmd
);
11574 install_element (VIEW_NODE
, &show_ip_bgp_community4_cmd
);
11575 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
11576 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
11577 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
11578 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
11579 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
11580 install_element (VIEW_NODE
, &show_ip_bgp_community2_exact_cmd
);
11581 install_element (VIEW_NODE
, &show_ip_bgp_community3_exact_cmd
);
11582 install_element (VIEW_NODE
, &show_ip_bgp_community4_exact_cmd
);
11583 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
11584 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
11585 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
11586 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
11587 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
11588 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
11589 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
11590 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
11591 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
11592 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
11593 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
11594 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
11595 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
11596 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
11597 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
11598 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
11599 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
11600 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
11601 install_element (VIEW_NODE
, &show_ip_bgp_dampened_paths_cmd
);
11602 install_element (VIEW_NODE
, &show_ip_bgp_flap_statistics_cmd
);
11603 install_element (VIEW_NODE
, &show_ip_bgp_flap_address_cmd
);
11604 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_cmd
);
11605 install_element (VIEW_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
11606 install_element (VIEW_NODE
, &show_ip_bgp_flap_regexp_cmd
);
11607 install_element (VIEW_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
11608 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
11609 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
11610 install_element (VIEW_NODE
, &show_ip_bgp_flap_route_map_cmd
);
11611 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
11612 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
11613 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_cmd
);
11614 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_route_cmd
);
11615 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
11616 install_element (VIEW_NODE
, &show_ip_bgp_view_neighbor_advertised_route_cmd
);
11617 install_element (VIEW_NODE
, &show_ip_bgp_view_neighbor_received_routes_cmd
);
11618 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_cmd
);
11619 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
11620 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
11622 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
11623 install_element (RESTRICTED_NODE
, &show_ip_bgp_route_cmd
);
11624 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_route_cmd
);
11625 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
11626 install_element (RESTRICTED_NODE
, &show_ip_bgp_prefix_cmd
);
11627 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
11628 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
11629 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
11630 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_route_cmd
);
11631 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_prefix_cmd
);
11632 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_cmd
);
11633 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_cmd
);
11634 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_cmd
);
11635 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_cmd
);
11636 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_cmd
);
11637 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
11638 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
11639 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
11640 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_exact_cmd
);
11641 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_exact_cmd
);
11642 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_exact_cmd
);
11643 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_exact_cmd
);
11644 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
11645 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
11646 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
11647 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
11648 install_element (RESTRICTED_NODE
, &show_ip_bgp_rsclient_route_cmd
);
11649 install_element (RESTRICTED_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
11650 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
11651 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
11653 install_element (ENABLE_NODE
, &show_ip_bgp_cmd
);
11654 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cmd
);
11655 install_element (ENABLE_NODE
, &show_ip_bgp_route_cmd
);
11656 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_cmd
);
11657 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
11658 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
11659 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_cmd
);
11660 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
11661 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
11662 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
11663 install_element (ENABLE_NODE
, &show_ip_bgp_view_cmd
);
11664 install_element (ENABLE_NODE
, &show_ip_bgp_view_route_cmd
);
11665 install_element (ENABLE_NODE
, &show_ip_bgp_view_prefix_cmd
);
11666 install_element (ENABLE_NODE
, &show_ip_bgp_regexp_cmd
);
11667 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
11668 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_list_cmd
);
11669 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
11670 install_element (ENABLE_NODE
, &show_ip_bgp_filter_list_cmd
);
11671 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
11672 install_element (ENABLE_NODE
, &show_ip_bgp_route_map_cmd
);
11673 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
11674 install_element (ENABLE_NODE
, &show_ip_bgp_cidr_only_cmd
);
11675 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
11676 install_element (ENABLE_NODE
, &show_ip_bgp_community_all_cmd
);
11677 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
11678 install_element (ENABLE_NODE
, &show_ip_bgp_community_cmd
);
11679 install_element (ENABLE_NODE
, &show_ip_bgp_community2_cmd
);
11680 install_element (ENABLE_NODE
, &show_ip_bgp_community3_cmd
);
11681 install_element (ENABLE_NODE
, &show_ip_bgp_community4_cmd
);
11682 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_cmd
);
11683 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
11684 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
11685 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
11686 install_element (ENABLE_NODE
, &show_ip_bgp_community_exact_cmd
);
11687 install_element (ENABLE_NODE
, &show_ip_bgp_community2_exact_cmd
);
11688 install_element (ENABLE_NODE
, &show_ip_bgp_community3_exact_cmd
);
11689 install_element (ENABLE_NODE
, &show_ip_bgp_community4_exact_cmd
);
11690 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
11691 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
11692 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
11693 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
11694 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_cmd
);
11695 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
11696 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_exact_cmd
);
11697 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
11698 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_longer_cmd
);
11699 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
11700 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
11701 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
11702 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
11703 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
11704 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
11705 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
11706 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
11707 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
11708 install_element (ENABLE_NODE
, &show_ip_bgp_dampened_paths_cmd
);
11709 install_element (ENABLE_NODE
, &show_ip_bgp_flap_statistics_cmd
);
11710 install_element (ENABLE_NODE
, &show_ip_bgp_flap_address_cmd
);
11711 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_cmd
);
11712 install_element (ENABLE_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
11713 install_element (ENABLE_NODE
, &show_ip_bgp_flap_regexp_cmd
);
11714 install_element (ENABLE_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
11715 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
11716 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
11717 install_element (ENABLE_NODE
, &show_ip_bgp_flap_route_map_cmd
);
11718 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
11719 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
11720 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_cmd
);
11721 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_route_cmd
);
11722 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
11723 install_element (ENABLE_NODE
, &show_ip_bgp_view_neighbor_advertised_route_cmd
);
11724 install_element (ENABLE_NODE
, &show_ip_bgp_view_neighbor_received_routes_cmd
);
11725 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_cmd
);
11726 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
11727 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
11729 /* BGP dampening clear commands */
11730 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_cmd
);
11731 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_prefix_cmd
);
11732 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_cmd
);
11733 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_mask_cmd
);
11736 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_prefix_counts_cmd
);
11737 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
);
11738 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
);
11740 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_prefix_counts_cmd
);
11742 /* New config IPv6 BGP commands. */
11743 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
11744 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_route_map_cmd
);
11745 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
11746 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_route_map_cmd
);
11748 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
11749 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
11750 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
11751 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
11753 /* Old config IPv6 BGP commands. */
11754 install_element (BGP_NODE
, &old_ipv6_bgp_network_cmd
);
11755 install_element (BGP_NODE
, &old_no_ipv6_bgp_network_cmd
);
11757 install_element (BGP_NODE
, &old_ipv6_aggregate_address_cmd
);
11758 install_element (BGP_NODE
, &old_ipv6_aggregate_address_summary_only_cmd
);
11759 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_cmd
);
11760 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_summary_only_cmd
);
11762 install_element (VIEW_NODE
, &show_bgp_cmd
);
11763 install_element (VIEW_NODE
, &show_bgp_ipv6_cmd
);
11764 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
11765 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
11766 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
11767 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
11768 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
11769 install_element (VIEW_NODE
, &show_bgp_ipv6_regexp_cmd
);
11770 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
11771 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
11772 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
11773 install_element (VIEW_NODE
, &show_bgp_ipv6_filter_list_cmd
);
11774 install_element (VIEW_NODE
, &show_bgp_route_map_cmd
);
11775 install_element (VIEW_NODE
, &show_bgp_ipv6_route_map_cmd
);
11776 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
11777 install_element (VIEW_NODE
, &show_bgp_ipv6_community_all_cmd
);
11778 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
11779 install_element (VIEW_NODE
, &show_bgp_ipv6_community_cmd
);
11780 install_element (VIEW_NODE
, &show_bgp_community2_cmd
);
11781 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_cmd
);
11782 install_element (VIEW_NODE
, &show_bgp_community3_cmd
);
11783 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_cmd
);
11784 install_element (VIEW_NODE
, &show_bgp_community4_cmd
);
11785 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_cmd
);
11786 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
11787 install_element (VIEW_NODE
, &show_bgp_ipv6_community_exact_cmd
);
11788 install_element (VIEW_NODE
, &show_bgp_community2_exact_cmd
);
11789 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
11790 install_element (VIEW_NODE
, &show_bgp_community3_exact_cmd
);
11791 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
11792 install_element (VIEW_NODE
, &show_bgp_community4_exact_cmd
);
11793 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
11794 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
11795 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_cmd
);
11796 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
11797 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
11798 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
11799 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
11800 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
11801 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
11802 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
11803 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
11804 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
11805 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
11806 install_element (VIEW_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
11807 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
11808 install_element (VIEW_NODE
, &show_bgp_neighbor_flap_cmd
);
11809 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
11810 install_element (VIEW_NODE
, &show_bgp_neighbor_damp_cmd
);
11811 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
11812 install_element (VIEW_NODE
, &show_bgp_rsclient_cmd
);
11813 install_element (VIEW_NODE
, &show_bgp_rsclient_route_cmd
);
11814 install_element (VIEW_NODE
, &show_bgp_rsclient_prefix_cmd
);
11815 install_element (VIEW_NODE
, &show_bgp_view_cmd
);
11816 install_element (VIEW_NODE
, &show_bgp_view_ipv6_cmd
);
11817 install_element (VIEW_NODE
, &show_bgp_view_route_cmd
);
11818 install_element (VIEW_NODE
, &show_bgp_view_ipv6_route_cmd
);
11819 install_element (VIEW_NODE
, &show_bgp_view_prefix_cmd
);
11820 install_element (VIEW_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
11821 install_element (VIEW_NODE
, &show_bgp_view_neighbor_advertised_route_cmd
);
11822 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_advertised_route_cmd
);
11823 install_element (VIEW_NODE
, &show_bgp_view_neighbor_received_routes_cmd
);
11824 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_received_routes_cmd
);
11825 install_element (VIEW_NODE
, &show_bgp_view_neighbor_routes_cmd
);
11826 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_routes_cmd
);
11827 install_element (VIEW_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
11828 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
11829 install_element (VIEW_NODE
, &show_bgp_view_neighbor_flap_cmd
);
11830 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_flap_cmd
);
11831 install_element (VIEW_NODE
, &show_bgp_view_neighbor_damp_cmd
);
11832 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_damp_cmd
);
11833 install_element (VIEW_NODE
, &show_bgp_view_rsclient_cmd
);
11834 install_element (VIEW_NODE
, &show_bgp_view_rsclient_route_cmd
);
11835 install_element (VIEW_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
11838 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
11840 install_element (RESTRICTED_NODE
, &show_bgp_route_cmd
);
11841 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_route_cmd
);
11842 install_element (RESTRICTED_NODE
, &show_bgp_prefix_cmd
);
11843 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_prefix_cmd
);
11844 install_element (RESTRICTED_NODE
, &show_bgp_community_cmd
);
11845 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_cmd
);
11846 install_element (RESTRICTED_NODE
, &show_bgp_community2_cmd
);
11847 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_cmd
);
11848 install_element (RESTRICTED_NODE
, &show_bgp_community3_cmd
);
11849 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_cmd
);
11850 install_element (RESTRICTED_NODE
, &show_bgp_community4_cmd
);
11851 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_cmd
);
11852 install_element (RESTRICTED_NODE
, &show_bgp_community_exact_cmd
);
11853 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_exact_cmd
);
11854 install_element (RESTRICTED_NODE
, &show_bgp_community2_exact_cmd
);
11855 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
11856 install_element (RESTRICTED_NODE
, &show_bgp_community3_exact_cmd
);
11857 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
11858 install_element (RESTRICTED_NODE
, &show_bgp_community4_exact_cmd
);
11859 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
11860 install_element (RESTRICTED_NODE
, &show_bgp_rsclient_route_cmd
);
11861 install_element (RESTRICTED_NODE
, &show_bgp_rsclient_prefix_cmd
);
11862 install_element (RESTRICTED_NODE
, &show_bgp_view_route_cmd
);
11863 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_route_cmd
);
11864 install_element (RESTRICTED_NODE
, &show_bgp_view_prefix_cmd
);
11865 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
11866 install_element (RESTRICTED_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
11867 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
11868 install_element (RESTRICTED_NODE
, &show_bgp_view_rsclient_route_cmd
);
11869 install_element (RESTRICTED_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
11871 install_element (ENABLE_NODE
, &show_bgp_cmd
);
11872 install_element (ENABLE_NODE
, &show_bgp_ipv6_cmd
);
11873 install_element (ENABLE_NODE
, &show_bgp_route_cmd
);
11874 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_cmd
);
11875 install_element (ENABLE_NODE
, &show_bgp_prefix_cmd
);
11876 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_cmd
);
11877 install_element (ENABLE_NODE
, &show_bgp_regexp_cmd
);
11878 install_element (ENABLE_NODE
, &show_bgp_ipv6_regexp_cmd
);
11879 install_element (ENABLE_NODE
, &show_bgp_prefix_list_cmd
);
11880 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
11881 install_element (ENABLE_NODE
, &show_bgp_filter_list_cmd
);
11882 install_element (ENABLE_NODE
, &show_bgp_ipv6_filter_list_cmd
);
11883 install_element (ENABLE_NODE
, &show_bgp_route_map_cmd
);
11884 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_map_cmd
);
11885 install_element (ENABLE_NODE
, &show_bgp_community_all_cmd
);
11886 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_all_cmd
);
11887 install_element (ENABLE_NODE
, &show_bgp_community_cmd
);
11888 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_cmd
);
11889 install_element (ENABLE_NODE
, &show_bgp_community2_cmd
);
11890 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_cmd
);
11891 install_element (ENABLE_NODE
, &show_bgp_community3_cmd
);
11892 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_cmd
);
11893 install_element (ENABLE_NODE
, &show_bgp_community4_cmd
);
11894 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_cmd
);
11895 install_element (ENABLE_NODE
, &show_bgp_community_exact_cmd
);
11896 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_exact_cmd
);
11897 install_element (ENABLE_NODE
, &show_bgp_community2_exact_cmd
);
11898 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
11899 install_element (ENABLE_NODE
, &show_bgp_community3_exact_cmd
);
11900 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
11901 install_element (ENABLE_NODE
, &show_bgp_community4_exact_cmd
);
11902 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
11903 install_element (ENABLE_NODE
, &show_bgp_community_list_cmd
);
11904 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_cmd
);
11905 install_element (ENABLE_NODE
, &show_bgp_community_list_exact_cmd
);
11906 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
11907 install_element (ENABLE_NODE
, &show_bgp_prefix_longer_cmd
);
11908 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
11909 install_element (ENABLE_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
11910 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
11911 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_routes_cmd
);
11912 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
11913 install_element (ENABLE_NODE
, &show_bgp_neighbor_routes_cmd
);
11914 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
11915 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
11916 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
11917 install_element (ENABLE_NODE
, &show_bgp_neighbor_flap_cmd
);
11918 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
11919 install_element (ENABLE_NODE
, &show_bgp_neighbor_damp_cmd
);
11920 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
11921 install_element (ENABLE_NODE
, &show_bgp_rsclient_cmd
);
11922 install_element (ENABLE_NODE
, &show_bgp_rsclient_route_cmd
);
11923 install_element (ENABLE_NODE
, &show_bgp_rsclient_prefix_cmd
);
11924 install_element (ENABLE_NODE
, &show_bgp_view_cmd
);
11925 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_cmd
);
11926 install_element (ENABLE_NODE
, &show_bgp_view_route_cmd
);
11927 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_route_cmd
);
11928 install_element (ENABLE_NODE
, &show_bgp_view_prefix_cmd
);
11929 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
11930 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_advertised_route_cmd
);
11931 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_advertised_route_cmd
);
11932 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_received_routes_cmd
);
11933 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_received_routes_cmd
);
11934 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_routes_cmd
);
11935 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_routes_cmd
);
11936 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
11937 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
11938 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_flap_cmd
);
11939 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_flap_cmd
);
11940 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_damp_cmd
);
11941 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_damp_cmd
);
11942 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_cmd
);
11943 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_route_cmd
);
11944 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
11947 install_element (ENABLE_NODE
, &show_bgp_statistics_cmd
);
11948 install_element (ENABLE_NODE
, &show_bgp_statistics_vpnv4_cmd
);
11949 install_element (ENABLE_NODE
, &show_bgp_statistics_view_cmd
);
11950 install_element (ENABLE_NODE
, &show_bgp_statistics_view_vpnv4_cmd
);
11953 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
11954 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
11955 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
11956 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
11957 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
11958 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
11959 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
11960 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
11961 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_cmd
);
11962 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_cmd
);
11963 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_cmd
);
11964 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
11965 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
11966 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
11967 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
11968 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
11969 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
11970 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
11971 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
11972 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
11973 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
11974 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
11975 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
11976 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
11977 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
11978 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
11979 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_cmd
);
11980 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_cmd
);
11981 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_cmd
);
11982 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
11983 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
11984 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
11985 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
11986 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
11987 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
11988 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
11991 install_element (ENABLE_NODE
, &show_ipv6_bgp_cmd
);
11992 install_element (ENABLE_NODE
, &show_ipv6_bgp_route_cmd
);
11993 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_cmd
);
11994 install_element (ENABLE_NODE
, &show_ipv6_bgp_regexp_cmd
);
11995 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
11996 install_element (ENABLE_NODE
, &show_ipv6_bgp_filter_list_cmd
);
11997 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_all_cmd
);
11998 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_cmd
);
11999 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_cmd
);
12000 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_cmd
);
12001 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_cmd
);
12002 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_exact_cmd
);
12003 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
12004 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
12005 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
12006 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_cmd
);
12007 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
12008 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
12009 install_element (ENABLE_NODE
, &show_ipv6_mbgp_cmd
);
12010 install_element (ENABLE_NODE
, &show_ipv6_mbgp_route_cmd
);
12011 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_cmd
);
12012 install_element (ENABLE_NODE
, &show_ipv6_mbgp_regexp_cmd
);
12013 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
12014 install_element (ENABLE_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
12015 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_all_cmd
);
12016 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_cmd
);
12017 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_cmd
);
12018 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_cmd
);
12019 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_cmd
);
12020 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
12021 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
12022 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
12023 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
12024 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_cmd
);
12025 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
12026 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
12029 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
12030 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
12031 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
12032 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
12035 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
12036 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
12037 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
12038 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
12041 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
12042 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
12043 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
12044 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
12045 #endif /* HAVE_IPV6 */
12047 install_element (BGP_NODE
, &bgp_distance_cmd
);
12048 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
12049 install_element (BGP_NODE
, &no_bgp_distance2_cmd
);
12050 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
12051 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
12052 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
12053 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
12055 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
12056 install_element (BGP_NODE
, &bgp_damp_set2_cmd
);
12057 install_element (BGP_NODE
, &bgp_damp_set3_cmd
);
12058 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
12059 install_element (BGP_NODE
, &bgp_damp_unset2_cmd
);
12060 install_element (BGP_IPV4_NODE
, &bgp_damp_set_cmd
);
12061 install_element (BGP_IPV4_NODE
, &bgp_damp_set2_cmd
);
12062 install_element (BGP_IPV4_NODE
, &bgp_damp_set3_cmd
);
12063 install_element (BGP_IPV4_NODE
, &bgp_damp_unset_cmd
);
12064 install_element (BGP_IPV4_NODE
, &bgp_damp_unset2_cmd
);
12066 /* Deprecated AS-Pathlimit commands */
12067 install_element (BGP_NODE
, &bgp_network_ttl_cmd
);
12068 install_element (BGP_NODE
, &bgp_network_mask_ttl_cmd
);
12069 install_element (BGP_NODE
, &bgp_network_mask_natural_ttl_cmd
);
12070 install_element (BGP_NODE
, &bgp_network_backdoor_ttl_cmd
);
12071 install_element (BGP_NODE
, &bgp_network_mask_backdoor_ttl_cmd
);
12072 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_ttl_cmd
);
12074 install_element (BGP_NODE
, &no_bgp_network_ttl_cmd
);
12075 install_element (BGP_NODE
, &no_bgp_network_mask_ttl_cmd
);
12076 install_element (BGP_NODE
, &no_bgp_network_mask_natural_ttl_cmd
);
12077 install_element (BGP_NODE
, &no_bgp_network_backdoor_ttl_cmd
);
12078 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_ttl_cmd
);
12079 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_ttl_cmd
);
12081 install_element (BGP_IPV4_NODE
, &bgp_network_ttl_cmd
);
12082 install_element (BGP_IPV4_NODE
, &bgp_network_mask_ttl_cmd
);
12083 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_ttl_cmd
);
12084 install_element (BGP_IPV4_NODE
, &bgp_network_backdoor_ttl_cmd
);
12085 install_element (BGP_IPV4_NODE
, &bgp_network_mask_backdoor_ttl_cmd
);
12086 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_backdoor_ttl_cmd
);
12088 install_element (BGP_IPV4_NODE
, &no_bgp_network_ttl_cmd
);
12089 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_ttl_cmd
);
12090 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_ttl_cmd
);
12091 install_element (BGP_IPV4_NODE
, &no_bgp_network_backdoor_ttl_cmd
);
12092 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_backdoor_ttl_cmd
);
12093 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_backdoor_ttl_cmd
);
12095 install_element (BGP_IPV4M_NODE
, &bgp_network_ttl_cmd
);
12096 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_ttl_cmd
);
12097 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_ttl_cmd
);
12098 install_element (BGP_IPV4M_NODE
, &bgp_network_backdoor_ttl_cmd
);
12099 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_backdoor_ttl_cmd
);
12100 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_backdoor_ttl_cmd
);
12102 install_element (BGP_IPV4M_NODE
, &no_bgp_network_ttl_cmd
);
12103 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_ttl_cmd
);
12104 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_ttl_cmd
);
12105 install_element (BGP_IPV4M_NODE
, &no_bgp_network_backdoor_ttl_cmd
);
12106 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_backdoor_ttl_cmd
);
12107 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_backdoor_ttl_cmd
);
12109 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_ttl_cmd
);
12110 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_ttl_cmd
);
12114 bgp_route_finish (void)
12116 bgp_table_unlock (bgp_distance_table
);
12117 bgp_distance_table
= NULL
;