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"
57 #include "bgpd/bgp_mpath.h"
59 /* Extern from bgp_dump.c */
60 extern const char *bgp_origin_str
[];
61 extern const char *bgp_origin_long_str
[];
63 static struct bgp_node
*
64 bgp_afi_node_get (struct bgp_table
*table
, afi_t afi
, safi_t safi
, struct prefix
*p
,
65 struct prefix_rd
*prd
)
68 struct bgp_node
*prn
= NULL
;
74 if (safi
== SAFI_MPLS_VPN
)
76 prn
= bgp_node_get (table
, (struct prefix
*) prd
);
78 if (prn
->info
== NULL
)
79 prn
->info
= bgp_table_init (afi
, safi
);
81 bgp_unlock_node (prn
);
85 rn
= bgp_node_get (table
, p
);
87 if (safi
== SAFI_MPLS_VPN
)
93 /* Allocate bgp_info_extra */
94 static struct bgp_info_extra
*
95 bgp_info_extra_new (void)
97 struct bgp_info_extra
*new;
98 new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA
, sizeof (struct bgp_info_extra
));
103 bgp_info_extra_free (struct bgp_info_extra
**extra
)
107 if ((*extra
)->damp_info
)
108 bgp_damp_info_free ((*extra
)->damp_info
, 0);
110 (*extra
)->damp_info
= NULL
;
112 XFREE (MTYPE_BGP_ROUTE_EXTRA
, *extra
);
118 /* Get bgp_info extra information for the given bgp_info, lazy allocated
121 struct bgp_info_extra
*
122 bgp_info_extra_get (struct bgp_info
*ri
)
125 ri
->extra
= bgp_info_extra_new();
129 /* Allocate new bgp info structure. */
130 static struct bgp_info
*
133 return XCALLOC (MTYPE_BGP_ROUTE
, sizeof (struct bgp_info
));
136 /* Free bgp route information. */
138 bgp_info_free (struct bgp_info
*binfo
)
141 bgp_attr_unintern (binfo
->attr
);
143 bgp_info_extra_free (&binfo
->extra
);
144 bgp_info_mpath_free (&binfo
->mpath
);
146 peer_unlock (binfo
->peer
); /* bgp_info peer reference */
148 XFREE (MTYPE_BGP_ROUTE
, binfo
);
152 bgp_info_lock (struct bgp_info
*binfo
)
159 bgp_info_unlock (struct bgp_info
*binfo
)
161 assert (binfo
&& binfo
->lock
> 0);
164 if (binfo
->lock
== 0)
167 zlog_debug ("%s: unlocked and freeing", __func__
);
168 zlog_backtrace (LOG_DEBUG
);
170 bgp_info_free (binfo
);
175 if (binfo
->lock
== 1)
177 zlog_debug ("%s: unlocked to 1", __func__
);
178 zlog_backtrace (LOG_DEBUG
);
186 bgp_info_add (struct bgp_node
*rn
, struct bgp_info
*ri
)
188 struct bgp_info
*top
;
200 peer_lock (ri
->peer
); /* bgp_info peer reference */
203 /* Do the actual removal of info from RIB, for use by bgp_process
204 completion callback *only* */
206 bgp_info_reap (struct bgp_node
*rn
, struct bgp_info
*ri
)
209 ri
->next
->prev
= ri
->prev
;
211 ri
->prev
->next
= ri
->next
;
215 bgp_info_mpath_dequeue (ri
);
216 bgp_info_unlock (ri
);
217 bgp_unlock_node (rn
);
221 bgp_info_delete (struct bgp_node
*rn
, struct bgp_info
*ri
)
223 bgp_info_set_flag (rn
, ri
, BGP_INFO_REMOVED
);
224 /* set of previous already took care of pcount */
225 UNSET_FLAG (ri
->flags
, BGP_INFO_VALID
);
228 /* undo the effects of a previous call to bgp_info_delete; typically
229 called when a route is deleted and then quickly re-added before the
230 deletion has been processed */
232 bgp_info_restore (struct bgp_node
*rn
, struct bgp_info
*ri
)
234 bgp_info_unset_flag (rn
, ri
, BGP_INFO_REMOVED
);
235 /* unset of previous already took care of pcount */
236 SET_FLAG (ri
->flags
, BGP_INFO_VALID
);
239 /* Adjust pcount as required */
241 bgp_pcount_adjust (struct bgp_node
*rn
, struct bgp_info
*ri
)
243 assert (rn
&& rn
->table
);
244 assert (ri
&& ri
->peer
&& ri
->peer
->bgp
);
246 /* Ignore 'pcount' for RS-client tables */
247 if (rn
->table
->type
!= BGP_TABLE_MAIN
248 || ri
->peer
== ri
->peer
->bgp
->peer_self
)
251 if (BGP_INFO_HOLDDOWN (ri
)
252 && CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
255 UNSET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
257 /* slight hack, but more robust against errors. */
258 if (ri
->peer
->pcount
[rn
->table
->afi
][rn
->table
->safi
])
259 ri
->peer
->pcount
[rn
->table
->afi
][rn
->table
->safi
]--;
262 zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s",
263 __func__
, ri
->peer
->host
);
264 zlog_backtrace (LOG_WARNING
);
265 zlog_warn ("%s: Please report to Quagga bugzilla", __func__
);
268 else if (!BGP_INFO_HOLDDOWN (ri
)
269 && !CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
271 SET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
272 ri
->peer
->pcount
[rn
->table
->afi
][rn
->table
->safi
]++;
277 /* Set/unset bgp_info flags, adjusting any other state as needed.
278 * This is here primarily to keep prefix-count in check.
281 bgp_info_set_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
283 SET_FLAG (ri
->flags
, flag
);
285 /* early bath if we know it's not a flag that changes useability state */
286 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_UNUSEABLE
))
289 bgp_pcount_adjust (rn
, ri
);
293 bgp_info_unset_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
295 UNSET_FLAG (ri
->flags
, flag
);
297 /* early bath if we know it's not a flag that changes useability state */
298 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_UNUSEABLE
))
301 bgp_pcount_adjust (rn
, ri
);
304 /* Get MED value. If MED value is missing and "bgp bestpath
305 missing-as-worst" is specified, treat it as the worst value. */
307 bgp_med_value (struct attr
*attr
, struct bgp
*bgp
)
309 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
313 if (bgp_flag_check (bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
320 /* Compare two bgp route entity. br is preferable then return 1. */
322 bgp_info_cmp (struct bgp
*bgp
, struct bgp_info
*new, struct bgp_info
*exist
,
326 u_int32_t exist_pref
;
329 u_int32_t new_weight
= 0;
330 u_int32_t exist_weight
= 0;
331 struct in_addr new_id
;
332 struct in_addr exist_id
;
335 int internal_as_route
= 0;
336 int confed_as_route
= 0;
338 uint32_t newm
, existm
;
348 /* 1. Weight check. */
349 if (new->attr
->extra
)
350 new_weight
= new->attr
->extra
->weight
;
351 if (exist
->attr
->extra
)
352 exist_weight
= exist
->attr
->extra
->weight
;
353 if (new_weight
> exist_weight
)
355 if (new_weight
< exist_weight
)
358 /* 2. Local preference check. */
359 if (new->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
360 new_pref
= new->attr
->local_pref
;
362 new_pref
= bgp
->default_local_pref
;
364 if (exist
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
365 exist_pref
= exist
->attr
->local_pref
;
367 exist_pref
= bgp
->default_local_pref
;
369 if (new_pref
> exist_pref
)
371 if (new_pref
< exist_pref
)
374 /* 3. Local route check. */
375 if (new->sub_type
== BGP_ROUTE_STATIC
)
377 if (exist
->sub_type
== BGP_ROUTE_STATIC
)
380 if (new->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
382 if (exist
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
385 if (new->sub_type
== BGP_ROUTE_AGGREGATE
)
387 if (exist
->sub_type
== BGP_ROUTE_AGGREGATE
)
390 /* 4. AS path length check. */
391 if (! bgp_flag_check (bgp
, BGP_FLAG_ASPATH_IGNORE
))
393 int exist_hops
= aspath_count_hops (exist
->attr
->aspath
);
394 int exist_confeds
= aspath_count_confeds (exist
->attr
->aspath
);
396 if (bgp_flag_check (bgp
, BGP_FLAG_ASPATH_CONFED
))
400 aspath_hops
= aspath_count_hops (new->attr
->aspath
);
401 aspath_hops
+= aspath_count_confeds (new->attr
->aspath
);
403 if ( aspath_hops
< (exist_hops
+ exist_confeds
))
405 if ( aspath_hops
> (exist_hops
+ exist_confeds
))
410 int newhops
= aspath_count_hops (new->attr
->aspath
);
412 if (newhops
< exist_hops
)
414 if (newhops
> exist_hops
)
419 /* 5. Origin check. */
420 if (new->attr
->origin
< exist
->attr
->origin
)
422 if (new->attr
->origin
> exist
->attr
->origin
)
426 internal_as_route
= (aspath_count_hops (new->attr
->aspath
) == 0
427 && aspath_count_hops (exist
->attr
->aspath
) == 0);
428 confed_as_route
= (aspath_count_confeds (new->attr
->aspath
) > 0
429 && aspath_count_confeds (exist
->attr
->aspath
) > 0
430 && aspath_count_hops (new->attr
->aspath
) == 0
431 && aspath_count_hops (exist
->attr
->aspath
) == 0);
433 if (bgp_flag_check (bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
)
434 || (bgp_flag_check (bgp
, BGP_FLAG_MED_CONFED
)
436 || aspath_cmp_left (new->attr
->aspath
, exist
->attr
->aspath
)
437 || aspath_cmp_left_confed (new->attr
->aspath
, exist
->attr
->aspath
)
438 || internal_as_route
)
440 new_med
= bgp_med_value (new->attr
, bgp
);
441 exist_med
= bgp_med_value (exist
->attr
, bgp
);
443 if (new_med
< exist_med
)
445 if (new_med
> exist_med
)
449 /* 7. Peer type check. */
450 if (peer_sort (new->peer
) == BGP_PEER_EBGP
451 && peer_sort (exist
->peer
) == BGP_PEER_IBGP
)
453 if (peer_sort (new->peer
) == BGP_PEER_EBGP
454 && peer_sort (exist
->peer
) == BGP_PEER_CONFED
)
456 if (peer_sort (new->peer
) == BGP_PEER_IBGP
457 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
459 if (peer_sort (new->peer
) == BGP_PEER_CONFED
460 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
463 /* 8. IGP metric check. */
464 newm
= (new->extra
? new->extra
->igpmetric
: 0);
465 existm
= (exist
->extra
? exist
->extra
->igpmetric
: 0);
471 /* 9. Maximum path check. */
474 if ((peer_sort (new->peer
) == BGP_PEER_IBGP
))
476 if (aspath_cmp (new->attr
->aspath
, exist
->attr
->aspath
))
479 else if (new->peer
->as
== exist
->peer
->as
)
485 * TODO: If unequal cost ibgp multipath is enabled we can
486 * mark the paths as equal here instead of returning
491 /* 10. If both paths are external, prefer the path that was received
492 first (the oldest one). This step minimizes route-flap, since a
493 newer path won't displace an older one, even if it was the
494 preferred route based on the additional decision criteria below. */
495 if (! bgp_flag_check (bgp
, BGP_FLAG_COMPARE_ROUTER_ID
)
496 && peer_sort (new->peer
) == BGP_PEER_EBGP
497 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
499 if (CHECK_FLAG (new->flags
, BGP_INFO_SELECTED
))
501 if (CHECK_FLAG (exist
->flags
, BGP_INFO_SELECTED
))
505 /* 11. Rourter-ID comparision. */
506 if (new->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
507 new_id
.s_addr
= new->attr
->extra
->originator_id
.s_addr
;
509 new_id
.s_addr
= new->peer
->remote_id
.s_addr
;
510 if (exist
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
511 exist_id
.s_addr
= exist
->attr
->extra
->originator_id
.s_addr
;
513 exist_id
.s_addr
= exist
->peer
->remote_id
.s_addr
;
515 if (ntohl (new_id
.s_addr
) < ntohl (exist_id
.s_addr
))
517 if (ntohl (new_id
.s_addr
) > ntohl (exist_id
.s_addr
))
520 /* 12. Cluster length comparision. */
521 if (new->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
522 new_cluster
= new->attr
->extra
->cluster
->length
;
525 if (exist
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
526 exist_cluster
= exist
->attr
->extra
->cluster
->length
;
530 if (new_cluster
< exist_cluster
)
532 if (new_cluster
> exist_cluster
)
535 /* 13. Neighbor address comparision. */
536 ret
= sockunion_cmp (new->peer
->su_remote
, exist
->peer
->su_remote
);
546 static enum filter_type
547 bgp_input_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
548 afi_t afi
, safi_t safi
)
550 struct bgp_filter
*filter
;
552 filter
= &peer
->filter
[afi
][safi
];
554 #define FILTER_EXIST_WARN(F,f,filter) \
555 if (BGP_DEBUG (update, UPDATE_IN) \
556 && !(F ## _IN (filter))) \
557 plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \
558 peer->host, #f, F ## _IN_NAME(filter));
560 if (DISTRIBUTE_IN_NAME (filter
)) {
561 FILTER_EXIST_WARN(DISTRIBUTE
, distribute
, filter
);
563 if (access_list_apply (DISTRIBUTE_IN (filter
), p
) == FILTER_DENY
)
567 if (PREFIX_LIST_IN_NAME (filter
)) {
568 FILTER_EXIST_WARN(PREFIX_LIST
, prefix
, filter
);
570 if (prefix_list_apply (PREFIX_LIST_IN (filter
), p
) == PREFIX_DENY
)
574 if (FILTER_LIST_IN_NAME (filter
)) {
575 FILTER_EXIST_WARN(FILTER_LIST
, as
, filter
);
577 if (as_list_apply (FILTER_LIST_IN (filter
), attr
->aspath
)== AS_FILTER_DENY
)
581 return FILTER_PERMIT
;
582 #undef FILTER_EXIST_WARN
585 static enum filter_type
586 bgp_output_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
587 afi_t afi
, safi_t safi
)
589 struct bgp_filter
*filter
;
591 filter
= &peer
->filter
[afi
][safi
];
593 #define FILTER_EXIST_WARN(F,f,filter) \
594 if (BGP_DEBUG (update, UPDATE_OUT) \
595 && !(F ## _OUT (filter))) \
596 plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \
597 peer->host, #f, F ## _OUT_NAME(filter));
599 if (DISTRIBUTE_OUT_NAME (filter
)) {
600 FILTER_EXIST_WARN(DISTRIBUTE
, distribute
, filter
);
602 if (access_list_apply (DISTRIBUTE_OUT (filter
), p
) == FILTER_DENY
)
606 if (PREFIX_LIST_OUT_NAME (filter
)) {
607 FILTER_EXIST_WARN(PREFIX_LIST
, prefix
, filter
);
609 if (prefix_list_apply (PREFIX_LIST_OUT (filter
), p
) == PREFIX_DENY
)
613 if (FILTER_LIST_OUT_NAME (filter
)) {
614 FILTER_EXIST_WARN(FILTER_LIST
, as
, filter
);
616 if (as_list_apply (FILTER_LIST_OUT (filter
), attr
->aspath
) == AS_FILTER_DENY
)
620 return FILTER_PERMIT
;
621 #undef FILTER_EXIST_WARN
624 /* If community attribute includes no_export then return 1. */
626 bgp_community_filter (struct peer
*peer
, struct attr
*attr
)
630 /* NO_ADVERTISE check. */
631 if (community_include (attr
->community
, COMMUNITY_NO_ADVERTISE
))
634 /* NO_EXPORT check. */
635 if (peer_sort (peer
) == BGP_PEER_EBGP
&&
636 community_include (attr
->community
, COMMUNITY_NO_EXPORT
))
639 /* NO_EXPORT_SUBCONFED check. */
640 if (peer_sort (peer
) == BGP_PEER_EBGP
641 || peer_sort (peer
) == BGP_PEER_CONFED
)
642 if (community_include (attr
->community
, COMMUNITY_NO_EXPORT_SUBCONFED
))
648 /* Route reflection loop check. */
650 bgp_cluster_filter (struct peer
*peer
, struct attr
*attr
)
652 struct in_addr cluster_id
;
654 if (attr
->extra
&& attr
->extra
->cluster
)
656 if (peer
->bgp
->config
& BGP_CONFIG_CLUSTER_ID
)
657 cluster_id
= peer
->bgp
->cluster_id
;
659 cluster_id
= peer
->bgp
->router_id
;
661 if (cluster_loop_check (attr
->extra
->cluster
, cluster_id
))
668 bgp_input_modifier (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
669 afi_t afi
, safi_t safi
)
671 struct bgp_filter
*filter
;
672 struct bgp_info info
;
673 route_map_result_t ret
;
675 filter
= &peer
->filter
[afi
][safi
];
677 /* Apply default weight value. */
679 (bgp_attr_extra_get (attr
))->weight
= peer
->weight
;
681 /* Route map apply. */
682 if (ROUTE_MAP_IN_NAME (filter
))
684 /* Duplicate current value to new strucutre for modification. */
688 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IN
);
690 /* Apply BGP route map to the attribute. */
691 ret
= route_map_apply (ROUTE_MAP_IN (filter
), p
, RMAP_BGP
, &info
);
695 if (ret
== RMAP_DENYMATCH
)
697 /* Free newly generated AS path and community by route-map. */
698 bgp_attr_flush (attr
);
706 bgp_export_modifier (struct peer
*rsclient
, struct peer
*peer
,
707 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
709 struct bgp_filter
*filter
;
710 struct bgp_info info
;
711 route_map_result_t ret
;
713 filter
= &peer
->filter
[afi
][safi
];
715 /* Route map apply. */
716 if (ROUTE_MAP_EXPORT_NAME (filter
))
718 /* Duplicate current value to new strucutre for modification. */
719 info
.peer
= rsclient
;
722 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_EXPORT
);
724 /* Apply BGP route map to the attribute. */
725 ret
= route_map_apply (ROUTE_MAP_EXPORT (filter
), p
, RMAP_BGP
, &info
);
727 rsclient
->rmap_type
= 0;
729 if (ret
== RMAP_DENYMATCH
)
731 /* Free newly generated AS path and community by route-map. */
732 bgp_attr_flush (attr
);
740 bgp_import_modifier (struct peer
*rsclient
, struct peer
*peer
,
741 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
743 struct bgp_filter
*filter
;
744 struct bgp_info info
;
745 route_map_result_t ret
;
747 filter
= &rsclient
->filter
[afi
][safi
];
749 /* Apply default weight value. */
751 (bgp_attr_extra_get (attr
))->weight
= peer
->weight
;
753 /* Route map apply. */
754 if (ROUTE_MAP_IMPORT_NAME (filter
))
756 /* Duplicate current value to new strucutre for modification. */
760 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
);
762 /* Apply BGP route map to the attribute. */
763 ret
= route_map_apply (ROUTE_MAP_IMPORT (filter
), p
, RMAP_BGP
, &info
);
767 if (ret
== RMAP_DENYMATCH
)
769 /* Free newly generated AS path and community by route-map. */
770 bgp_attr_flush (attr
);
778 bgp_announce_check (struct bgp_info
*ri
, struct peer
*peer
, struct prefix
*p
,
779 struct attr
*attr
, afi_t afi
, safi_t safi
)
782 char buf
[SU_ADDRSTRLEN
];
783 struct bgp_filter
*filter
;
791 filter
= &peer
->filter
[afi
][safi
];
793 riattr
= bgp_info_mpath_count (ri
) ? bgp_info_mpath_attr (ri
) : ri
->attr
;
795 if (DISABLE_BGP_ANNOUNCE
)
798 /* Do not send announces to RS-clients from the 'normal' bgp_table. */
799 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
802 /* Do not send back route to sender. */
806 /* If peer's id and route's nexthop are same. draft-ietf-idr-bgp4-23 5.1.3 */
807 if (p
->family
== AF_INET
808 && IPV4_ADDR_SAME(&peer
->remote_id
, &riattr
->nexthop
))
811 if (p
->family
== AF_INET6
812 && IPV6_ADDR_SAME(&peer
->remote_id
, &riattr
->nexthop
))
816 /* Aggregate-address suppress check. */
817 if (ri
->extra
&& ri
->extra
->suppress
)
818 if (! UNSUPPRESS_MAP_NAME (filter
))
821 /* Default route check. */
822 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
))
824 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
)
827 else if (p
->family
== AF_INET6
&& p
->prefixlen
== 0)
829 #endif /* HAVE_IPV6 */
832 /* Transparency check. */
833 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
)
834 && CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
839 /* If community is not disabled check the no-export and local. */
840 if (! transparent
&& bgp_community_filter (peer
, riattr
))
843 /* If the attribute has originator-id and it is same as remote
845 if (riattr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
))
847 if (IPV4_ADDR_SAME (&peer
->remote_id
, &riattr
->extra
->originator_id
))
849 if (BGP_DEBUG (filter
, FILTER
))
850 zlog (peer
->log
, LOG_DEBUG
,
851 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
853 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
859 /* ORF prefix-list filter check */
860 if (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_RM_ADV
)
861 && (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_RCV
)
862 || CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)))
863 if (peer
->orf_plist
[afi
][safi
])
865 if (prefix_list_apply (peer
->orf_plist
[afi
][safi
], p
) == PREFIX_DENY
)
869 /* Output filter check. */
870 if (bgp_output_filter (peer
, p
, riattr
, afi
, safi
) == FILTER_DENY
)
872 if (BGP_DEBUG (filter
, FILTER
))
873 zlog (peer
->log
, LOG_DEBUG
,
874 "%s [Update:SEND] %s/%d is filtered",
876 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
881 #ifdef BGP_SEND_ASPATH_CHECK
882 /* AS path loop check. */
883 if (aspath_loop_check (riattr
->aspath
, peer
->as
))
885 if (BGP_DEBUG (filter
, FILTER
))
886 zlog (peer
->log
, LOG_DEBUG
,
887 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
888 peer
->host
, peer
->as
);
891 #endif /* BGP_SEND_ASPATH_CHECK */
893 /* If we're a CONFED we need to loop check the CONFED ID too */
894 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
896 if (aspath_loop_check(riattr
->aspath
, bgp
->confed_id
))
898 if (BGP_DEBUG (filter
, FILTER
))
899 zlog (peer
->log
, LOG_DEBUG
,
900 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
907 /* Route-Reflect check. */
908 if (peer_sort (from
) == BGP_PEER_IBGP
&& peer_sort (peer
) == BGP_PEER_IBGP
)
913 /* IBGP reflection check. */
916 /* A route from a Client peer. */
917 if (CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
919 /* Reflect to all the Non-Client peers and also to the
920 Client peers other than the originator. Originator check
921 is already done. So there is noting to do. */
922 /* no bgp client-to-client reflection check. */
923 if (bgp_flag_check (bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
924 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
929 /* A route from a Non-client peer. Reflect to all other
931 if (! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
936 /* For modify attribute, copy it to temporary structure. */
937 bgp_attr_dup (attr
, riattr
);
939 /* If local-preference is not set. */
940 if ((peer_sort (peer
) == BGP_PEER_IBGP
941 || peer_sort (peer
) == BGP_PEER_CONFED
)
942 && (! (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))))
944 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
);
945 attr
->local_pref
= bgp
->default_local_pref
;
948 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
949 if (peer_sort (peer
) == BGP_PEER_EBGP
950 && attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
952 if (ri
->peer
!= bgp
->peer_self
&& ! transparent
953 && ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
954 attr
->flag
&= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
));
958 if (transparent
|| reflect
959 || (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_UNCHANGED
)
960 && ((p
->family
== AF_INET
&& attr
->nexthop
.s_addr
)
962 || (p
->family
== AF_INET6
&&
963 ! IN6_IS_ADDR_UNSPECIFIED(&attr
->extra
->mp_nexthop_global
))
964 #endif /* HAVE_IPV6 */
967 /* NEXT-HOP Unchanged. */
969 else if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
970 || (p
->family
== AF_INET
&& attr
->nexthop
.s_addr
== 0)
972 || (p
->family
== AF_INET6
&&
973 IN6_IS_ADDR_UNSPECIFIED(&attr
->extra
->mp_nexthop_global
))
974 #endif /* HAVE_IPV6 */
975 || (peer_sort (peer
) == BGP_PEER_EBGP
976 && bgp_multiaccess_check_v4 (attr
->nexthop
, peer
->host
) == 0))
978 /* Set IPv4 nexthop. */
979 if (p
->family
== AF_INET
)
981 if (safi
== SAFI_MPLS_VPN
)
982 memcpy (&attr
->extra
->mp_nexthop_global_in
, &peer
->nexthop
.v4
,
985 memcpy (&attr
->nexthop
, &peer
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
988 /* Set IPv6 nexthop. */
989 if (p
->family
== AF_INET6
)
991 /* IPv6 global nexthop must be included. */
992 memcpy (&attr
->extra
->mp_nexthop_global
, &peer
->nexthop
.v6_global
,
994 attr
->extra
->mp_nexthop_len
= 16;
996 #endif /* HAVE_IPV6 */
1000 if (p
->family
== AF_INET6
)
1002 /* Left nexthop_local unchanged if so configured. */
1003 if ( CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1004 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) )
1006 if ( IN6_IS_ADDR_LINKLOCAL (&attr
->extra
->mp_nexthop_local
) )
1007 attr
->extra
->mp_nexthop_len
=32;
1009 attr
->extra
->mp_nexthop_len
=16;
1012 /* Default nexthop_local treatment for non-RS-Clients */
1015 /* Link-local address should not be transit to different peer. */
1016 attr
->extra
->mp_nexthop_len
= 16;
1018 /* Set link-local address for shared network peer. */
1019 if (peer
->shared_network
1020 && ! IN6_IS_ADDR_UNSPECIFIED (&peer
->nexthop
.v6_local
))
1022 memcpy (&attr
->extra
->mp_nexthop_local
, &peer
->nexthop
.v6_local
,
1024 attr
->extra
->mp_nexthop_len
= 32;
1027 /* If bgpd act as BGP-4+ route-reflector, do not send link-local
1030 attr
->extra
->mp_nexthop_len
= 16;
1032 /* If BGP-4+ link-local nexthop is not link-local nexthop. */
1033 if (! IN6_IS_ADDR_LINKLOCAL (&peer
->nexthop
.v6_local
))
1034 attr
->extra
->mp_nexthop_len
= 16;
1038 #endif /* HAVE_IPV6 */
1040 /* If this is EBGP peer and remove-private-AS is set. */
1041 if (peer_sort (peer
) == BGP_PEER_EBGP
1042 && peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)
1043 && aspath_private_as_check (attr
->aspath
))
1044 attr
->aspath
= aspath_empty_get ();
1046 /* Route map & unsuppress-map apply. */
1047 if (ROUTE_MAP_OUT_NAME (filter
)
1048 || (ri
->extra
&& ri
->extra
->suppress
) )
1050 struct bgp_info info
;
1051 struct attr dummy_attr
= { 0 };
1056 /* The route reflector is not allowed to modify the attributes
1057 of the reflected IBGP routes. */
1058 if (peer_sort (from
) == BGP_PEER_IBGP
1059 && peer_sort (peer
) == BGP_PEER_IBGP
)
1061 bgp_attr_dup (&dummy_attr
, attr
);
1062 info
.attr
= &dummy_attr
;
1065 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1067 if (ri
->extra
&& ri
->extra
->suppress
)
1068 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
1070 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
1072 peer
->rmap_type
= 0;
1074 if (dummy_attr
.extra
)
1075 bgp_attr_extra_free (&dummy_attr
);
1077 if (ret
== RMAP_DENYMATCH
)
1079 bgp_attr_flush (attr
);
1087 bgp_announce_check_rsclient (struct bgp_info
*ri
, struct peer
*rsclient
,
1088 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
1091 char buf
[SU_ADDRSTRLEN
];
1092 struct bgp_filter
*filter
;
1093 struct bgp_info info
;
1096 struct attr
*riattr
;
1099 filter
= &rsclient
->filter
[afi
][safi
];
1100 bgp
= rsclient
->bgp
;
1101 riattr
= bgp_info_mpath_count (ri
) ? bgp_info_mpath_attr (ri
) : ri
->attr
;
1103 if (DISABLE_BGP_ANNOUNCE
)
1106 /* Do not send back route to sender. */
1107 if (from
== rsclient
)
1110 /* Aggregate-address suppress check. */
1111 if (ri
->extra
&& ri
->extra
->suppress
)
1112 if (! UNSUPPRESS_MAP_NAME (filter
))
1115 /* Default route check. */
1116 if (CHECK_FLAG (rsclient
->af_sflags
[afi
][safi
],
1117 PEER_STATUS_DEFAULT_ORIGINATE
))
1119 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
)
1122 else if (p
->family
== AF_INET6
&& p
->prefixlen
== 0)
1124 #endif /* HAVE_IPV6 */
1127 /* If the attribute has originator-id and it is same as remote
1129 if (riattr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
))
1131 if (IPV4_ADDR_SAME (&rsclient
->remote_id
,
1132 &riattr
->extra
->originator_id
))
1134 if (BGP_DEBUG (filter
, FILTER
))
1135 zlog (rsclient
->log
, LOG_DEBUG
,
1136 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
1138 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1144 /* ORF prefix-list filter check */
1145 if (CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_RM_ADV
)
1146 && (CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_RCV
)
1147 || CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)))
1148 if (rsclient
->orf_plist
[afi
][safi
])
1150 if (prefix_list_apply (rsclient
->orf_plist
[afi
][safi
], p
) == PREFIX_DENY
)
1154 /* Output filter check. */
1155 if (bgp_output_filter (rsclient
, p
, riattr
, afi
, safi
) == FILTER_DENY
)
1157 if (BGP_DEBUG (filter
, FILTER
))
1158 zlog (rsclient
->log
, LOG_DEBUG
,
1159 "%s [Update:SEND] %s/%d is filtered",
1161 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1166 #ifdef BGP_SEND_ASPATH_CHECK
1167 /* AS path loop check. */
1168 if (aspath_loop_check (riattr
->aspath
, rsclient
->as
))
1170 if (BGP_DEBUG (filter
, FILTER
))
1171 zlog (rsclient
->log
, LOG_DEBUG
,
1172 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
1173 rsclient
->host
, rsclient
->as
);
1176 #endif /* BGP_SEND_ASPATH_CHECK */
1178 /* For modify attribute, copy it to temporary structure. */
1179 bgp_attr_dup (attr
, riattr
);
1182 if ((p
->family
== AF_INET
&& attr
->nexthop
.s_addr
== 0)
1184 || (p
->family
== AF_INET6
&&
1185 IN6_IS_ADDR_UNSPECIFIED(&attr
->extra
->mp_nexthop_global
))
1186 #endif /* HAVE_IPV6 */
1189 /* Set IPv4 nexthop. */
1190 if (p
->family
== AF_INET
)
1192 if (safi
== SAFI_MPLS_VPN
)
1193 memcpy (&attr
->extra
->mp_nexthop_global_in
, &rsclient
->nexthop
.v4
,
1196 memcpy (&attr
->nexthop
, &rsclient
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
1199 /* Set IPv6 nexthop. */
1200 if (p
->family
== AF_INET6
)
1202 /* IPv6 global nexthop must be included. */
1203 memcpy (&attr
->extra
->mp_nexthop_global
, &rsclient
->nexthop
.v6_global
,
1205 attr
->extra
->mp_nexthop_len
= 16;
1207 #endif /* HAVE_IPV6 */
1211 if (p
->family
== AF_INET6
)
1213 struct attr_extra
*attre
= attr
->extra
;
1215 assert (attr
->extra
);
1217 /* Left nexthop_local unchanged if so configured. */
1218 if ( CHECK_FLAG (rsclient
->af_flags
[afi
][safi
],
1219 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) )
1221 if ( IN6_IS_ADDR_LINKLOCAL (&attre
->mp_nexthop_local
) )
1222 attre
->mp_nexthop_len
=32;
1224 attre
->mp_nexthop_len
=16;
1227 /* Default nexthop_local treatment for RS-Clients */
1230 /* Announcer and RS-Client are both in the same network */
1231 if (rsclient
->shared_network
&& from
->shared_network
&&
1232 (rsclient
->ifindex
== from
->ifindex
))
1234 if ( IN6_IS_ADDR_LINKLOCAL (&attre
->mp_nexthop_local
) )
1235 attre
->mp_nexthop_len
=32;
1237 attre
->mp_nexthop_len
=16;
1240 /* Set link-local address for shared network peer. */
1241 else if (rsclient
->shared_network
1242 && IN6_IS_ADDR_LINKLOCAL (&rsclient
->nexthop
.v6_local
))
1244 memcpy (&attre
->mp_nexthop_local
, &rsclient
->nexthop
.v6_local
,
1246 attre
->mp_nexthop_len
= 32;
1250 attre
->mp_nexthop_len
= 16;
1254 #endif /* HAVE_IPV6 */
1257 /* If this is EBGP peer and remove-private-AS is set. */
1258 if (peer_sort (rsclient
) == BGP_PEER_EBGP
1259 && peer_af_flag_check (rsclient
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)
1260 && aspath_private_as_check (attr
->aspath
))
1261 attr
->aspath
= aspath_empty_get ();
1263 /* Route map & unsuppress-map apply. */
1264 if (ROUTE_MAP_OUT_NAME (filter
) || (ri
->extra
&& ri
->extra
->suppress
) )
1266 info
.peer
= rsclient
;
1269 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1271 if (ri
->extra
&& ri
->extra
->suppress
)
1272 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
1274 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
1276 rsclient
->rmap_type
= 0;
1278 if (ret
== RMAP_DENYMATCH
)
1280 bgp_attr_flush (attr
);
1288 struct bgp_info_pair
1290 struct bgp_info
*old
;
1291 struct bgp_info
*new;
1295 bgp_best_selection (struct bgp
*bgp
, struct bgp_node
*rn
,
1296 struct bgp_maxpaths_cfg
*mpath_cfg
,
1297 struct bgp_info_pair
*result
)
1299 struct bgp_info
*new_select
;
1300 struct bgp_info
*old_select
;
1301 struct bgp_info
*ri
;
1302 struct bgp_info
*ri1
;
1303 struct bgp_info
*ri2
;
1304 struct bgp_info
*nextri
= NULL
;
1305 int paths_eq
, do_mpath
;
1306 struct list mp_list
;
1308 bgp_mp_list_init (&mp_list
);
1309 do_mpath
= (mpath_cfg
->maxpaths_ebgp
!= BGP_DEFAULT_MAXPATHS
||
1310 mpath_cfg
->maxpaths_ibgp
!= BGP_DEFAULT_MAXPATHS
);
1312 /* bgp deterministic-med */
1314 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
))
1315 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1317 if (CHECK_FLAG (ri1
->flags
, BGP_INFO_DMED_CHECK
))
1319 if (BGP_INFO_HOLDDOWN (ri1
))
1324 bgp_mp_list_add (&mp_list
, ri1
);
1325 old_select
= CHECK_FLAG (ri1
->flags
, BGP_INFO_SELECTED
) ? ri1
: NULL
;
1327 for (ri2
= ri1
->next
; ri2
; ri2
= ri2
->next
)
1329 if (CHECK_FLAG (ri2
->flags
, BGP_INFO_DMED_CHECK
))
1331 if (BGP_INFO_HOLDDOWN (ri2
))
1334 if (aspath_cmp_left (ri1
->attr
->aspath
, ri2
->attr
->aspath
)
1335 || aspath_cmp_left_confed (ri1
->attr
->aspath
,
1338 if (CHECK_FLAG (ri2
->flags
, BGP_INFO_SELECTED
))
1340 if (bgp_info_cmp (bgp
, ri2
, new_select
, &paths_eq
))
1342 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1344 if (do_mpath
&& !paths_eq
)
1346 bgp_mp_list_clear (&mp_list
);
1347 bgp_mp_list_add (&mp_list
, ri2
);
1351 if (do_mpath
&& paths_eq
)
1352 bgp_mp_list_add (&mp_list
, ri2
);
1354 bgp_info_set_flag (rn
, ri2
, BGP_INFO_DMED_CHECK
);
1357 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_CHECK
);
1358 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1360 bgp_info_mpath_update (rn
, new_select
, old_select
, &mp_list
, mpath_cfg
);
1361 bgp_mp_list_clear (&mp_list
);
1364 /* Check old selected route and new selected route. */
1367 for (ri
= rn
->info
; (ri
!= NULL
) && (nextri
= ri
->next
, 1); ri
= nextri
)
1369 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1372 if (BGP_INFO_HOLDDOWN (ri
))
1374 /* reap REMOVED routes, if needs be
1375 * selected route must stay for a while longer though
1377 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
1378 && (ri
!= old_select
))
1379 bgp_info_reap (rn
, ri
);
1384 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
)
1385 && (! CHECK_FLAG (ri
->flags
, BGP_INFO_DMED_SELECTED
)))
1387 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1390 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1391 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_SELECTED
);
1393 if (bgp_info_cmp (bgp
, ri
, new_select
, &paths_eq
))
1395 if (do_mpath
&& bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
))
1396 bgp_mp_dmed_deselect (new_select
);
1400 if (do_mpath
&& !paths_eq
)
1402 bgp_mp_list_clear (&mp_list
);
1403 bgp_mp_list_add (&mp_list
, ri
);
1406 else if (do_mpath
&& bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
))
1407 bgp_mp_dmed_deselect (ri
);
1409 if (do_mpath
&& paths_eq
)
1410 bgp_mp_list_add (&mp_list
, ri
);
1414 if (!bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
))
1415 bgp_info_mpath_update (rn
, new_select
, old_select
, &mp_list
, mpath_cfg
);
1417 bgp_info_mpath_aggregate_update (new_select
, old_select
);
1418 bgp_mp_list_clear (&mp_list
);
1420 result
->old
= old_select
;
1421 result
->new = new_select
;
1427 bgp_process_announce_selected (struct peer
*peer
, struct bgp_info
*selected
,
1428 struct bgp_node
*rn
, afi_t afi
, safi_t safi
)
1431 struct attr attr
= { 0 };
1435 /* Announce route to Established peer. */
1436 if (peer
->status
!= Established
)
1439 /* Address family configuration check. */
1440 if (! peer
->afc_nego
[afi
][safi
])
1443 /* First update is deferred until ORF or ROUTE-REFRESH is received */
1444 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
],
1445 PEER_STATUS_ORF_WAIT_REFRESH
))
1448 switch (rn
->table
->type
)
1450 case BGP_TABLE_MAIN
:
1451 /* Announcement to peer->conf. If the route is filtered,
1453 if (selected
&& bgp_announce_check (selected
, peer
, p
, &attr
, afi
, safi
))
1454 bgp_adj_out_set (rn
, peer
, p
, &attr
, afi
, safi
, selected
);
1456 bgp_adj_out_unset (rn
, peer
, p
, afi
, safi
);
1458 case BGP_TABLE_RSCLIENT
:
1459 /* Announcement to peer->conf. If the route is filtered,
1462 bgp_announce_check_rsclient (selected
, peer
, p
, &attr
, afi
, safi
))
1463 bgp_adj_out_set (rn
, peer
, p
, &attr
, afi
, safi
, selected
);
1465 bgp_adj_out_unset (rn
, peer
, p
, afi
, safi
);
1469 bgp_attr_extra_free (&attr
);
1474 struct bgp_process_queue
1477 struct bgp_node
*rn
;
1482 static wq_item_status
1483 bgp_process_rsclient (struct work_queue
*wq
, void *data
)
1485 struct bgp_process_queue
*pq
= data
;
1486 struct bgp
*bgp
= pq
->bgp
;
1487 struct bgp_node
*rn
= pq
->rn
;
1488 afi_t afi
= pq
->afi
;
1489 safi_t safi
= pq
->safi
;
1490 struct bgp_info
*new_select
;
1491 struct bgp_info
*old_select
;
1492 struct bgp_info_pair old_and_new
;
1493 struct listnode
*node
, *nnode
;
1494 struct peer
*rsclient
= rn
->table
->owner
;
1496 /* Best path selection. */
1497 bgp_best_selection (bgp
, rn
, &bgp
->maxpaths
[afi
][safi
], &old_and_new
);
1498 new_select
= old_and_new
.new;
1499 old_select
= old_and_new
.old
;
1501 if (CHECK_FLAG (rsclient
->sflags
, PEER_STATUS_GROUP
))
1503 if (rsclient
->group
)
1504 for (ALL_LIST_ELEMENTS (rsclient
->group
->peer
, node
, nnode
, rsclient
))
1506 /* Nothing to do. */
1507 if (old_select
&& old_select
== new_select
)
1508 if (!CHECK_FLAG (old_select
->flags
, BGP_INFO_ATTR_CHANGED
))
1512 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1515 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1516 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1517 UNSET_FLAG (new_select
->flags
, BGP_INFO_MULTIPATH_CHG
);
1520 bgp_process_announce_selected (rsclient
, new_select
, rn
,
1527 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1530 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1531 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1532 UNSET_FLAG (new_select
->flags
, BGP_INFO_MULTIPATH_CHG
);
1534 bgp_process_announce_selected (rsclient
, new_select
, rn
, afi
, safi
);
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
);
1544 static wq_item_status
1545 bgp_process_main (struct work_queue
*wq
, void *data
)
1547 struct bgp_process_queue
*pq
= data
;
1548 struct bgp
*bgp
= pq
->bgp
;
1549 struct bgp_node
*rn
= pq
->rn
;
1550 afi_t afi
= pq
->afi
;
1551 safi_t safi
= pq
->safi
;
1552 struct prefix
*p
= &rn
->p
;
1553 struct bgp_info
*new_select
;
1554 struct bgp_info
*old_select
;
1555 struct bgp_info_pair old_and_new
;
1556 struct listnode
*node
, *nnode
;
1559 /* Best path selection. */
1560 bgp_best_selection (bgp
, rn
, &bgp
->maxpaths
[afi
][safi
], &old_and_new
);
1561 old_select
= old_and_new
.old
;
1562 new_select
= old_and_new
.new;
1564 /* Nothing to do. */
1565 if (old_select
&& old_select
== new_select
)
1567 if (! CHECK_FLAG (old_select
->flags
, BGP_INFO_ATTR_CHANGED
))
1569 if (CHECK_FLAG (old_select
->flags
, BGP_INFO_IGP_CHANGED
) ||
1570 CHECK_FLAG (old_select
->flags
, BGP_INFO_MULTIPATH_CHG
))
1571 bgp_zebra_announce (p
, old_select
, bgp
);
1573 UNSET_FLAG (old_select
->flags
, BGP_INFO_MULTIPATH_CHG
);
1574 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1580 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1583 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1584 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1585 UNSET_FLAG (new_select
->flags
, BGP_INFO_MULTIPATH_CHG
);
1589 /* Check each BGP peer. */
1590 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
1592 bgp_process_announce_selected (peer
, new_select
, rn
, afi
, safi
);
1596 if (safi
== SAFI_UNICAST
&& ! bgp
->name
&&
1597 ! bgp_option_check (BGP_OPT_NO_FIB
))
1600 && new_select
->type
== ZEBRA_ROUTE_BGP
1601 && new_select
->sub_type
== BGP_ROUTE_NORMAL
)
1602 bgp_zebra_announce (p
, new_select
, bgp
);
1605 /* Withdraw the route from the kernel. */
1607 && old_select
->type
== ZEBRA_ROUTE_BGP
1608 && old_select
->sub_type
== BGP_ROUTE_NORMAL
)
1609 bgp_zebra_withdraw (p
, old_select
);
1613 /* Reap old select bgp_info, it it has been removed */
1614 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
1615 bgp_info_reap (rn
, old_select
);
1617 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1622 bgp_processq_del (struct work_queue
*wq
, void *data
)
1624 struct bgp_process_queue
*pq
= data
;
1625 struct bgp_table
*table
= pq
->rn
->table
;
1627 bgp_unlock (pq
->bgp
);
1628 bgp_unlock_node (pq
->rn
);
1629 bgp_table_unlock (table
);
1630 XFREE (MTYPE_BGP_PROCESS_QUEUE
, pq
);
1634 bgp_process_queue_init (void)
1636 bm
->process_main_queue
1637 = work_queue_new (bm
->master
, "process_main_queue");
1638 bm
->process_rsclient_queue
1639 = work_queue_new (bm
->master
, "process_rsclient_queue");
1641 if ( !(bm
->process_main_queue
&& bm
->process_rsclient_queue
) )
1643 zlog_err ("%s: Failed to allocate work queue", __func__
);
1647 bm
->process_main_queue
->spec
.workfunc
= &bgp_process_main
;
1648 bm
->process_main_queue
->spec
.del_item_data
= &bgp_processq_del
;
1649 bm
->process_main_queue
->spec
.max_retries
= 0;
1650 bm
->process_main_queue
->spec
.hold
= 50;
1652 memcpy (bm
->process_rsclient_queue
, bm
->process_main_queue
,
1653 sizeof (struct work_queue
*));
1654 bm
->process_rsclient_queue
->spec
.workfunc
= &bgp_process_rsclient
;
1658 bgp_process (struct bgp
*bgp
, struct bgp_node
*rn
, afi_t afi
, safi_t safi
)
1660 struct bgp_process_queue
*pqnode
;
1662 /* already scheduled for processing? */
1663 if (CHECK_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
))
1666 if ( (bm
->process_main_queue
== NULL
) ||
1667 (bm
->process_rsclient_queue
== NULL
) )
1668 bgp_process_queue_init ();
1670 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
1671 sizeof (struct bgp_process_queue
));
1675 /* all unlocked in bgp_processq_del */
1676 bgp_table_lock (rn
->table
);
1677 pqnode
->rn
= bgp_lock_node (rn
);
1681 pqnode
->safi
= safi
;
1683 switch (rn
->table
->type
)
1685 case BGP_TABLE_MAIN
:
1686 work_queue_add (bm
->process_main_queue
, pqnode
);
1688 case BGP_TABLE_RSCLIENT
:
1689 work_queue_add (bm
->process_rsclient_queue
, pqnode
);
1697 bgp_maximum_prefix_restart_timer (struct thread
*thread
)
1701 peer
= THREAD_ARG (thread
);
1702 peer
->t_pmax_restart
= NULL
;
1704 if (BGP_DEBUG (events
, EVENTS
))
1705 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
1714 bgp_maximum_prefix_overflow (struct peer
*peer
, afi_t afi
,
1715 safi_t safi
, int always
)
1717 if (!CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
))
1720 if (peer
->pcount
[afi
][safi
] > peer
->pmax
[afi
][safi
])
1722 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
)
1726 zlog (peer
->log
, LOG_INFO
,
1727 "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
1728 "limit %ld", afi_safi_print (afi
, safi
), peer
->host
,
1729 peer
->pcount
[afi
][safi
], peer
->pmax
[afi
][safi
]);
1730 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
1732 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_WARNING
))
1738 if (safi
== SAFI_MPLS_VPN
)
1739 safi
= BGP_SAFI_VPNV4
;
1741 ndata
[0] = (afi
>> 8);
1744 ndata
[3] = (peer
->pmax
[afi
][safi
] >> 24);
1745 ndata
[4] = (peer
->pmax
[afi
][safi
] >> 16);
1746 ndata
[5] = (peer
->pmax
[afi
][safi
] >> 8);
1747 ndata
[6] = (peer
->pmax
[afi
][safi
]);
1749 SET_FLAG (peer
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
);
1750 bgp_notify_send_with_data (peer
, BGP_NOTIFY_CEASE
,
1751 BGP_NOTIFY_CEASE_MAX_PREFIX
, ndata
, 7);
1754 /* restart timer start */
1755 if (peer
->pmax_restart
[afi
][safi
])
1757 peer
->v_pmax_restart
= peer
->pmax_restart
[afi
][safi
] * 60;
1759 if (BGP_DEBUG (events
, EVENTS
))
1760 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
1761 peer
->host
, peer
->v_pmax_restart
);
1763 BGP_TIMER_ON (peer
->t_pmax_restart
, bgp_maximum_prefix_restart_timer
,
1764 peer
->v_pmax_restart
);
1770 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
1772 if (peer
->pcount
[afi
][safi
] > (peer
->pmax
[afi
][safi
] * peer
->pmax_threshold
[afi
][safi
] / 100))
1774 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
)
1778 zlog (peer
->log
, LOG_INFO
,
1779 "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
1780 afi_safi_print (afi
, safi
), peer
->host
, peer
->pcount
[afi
][safi
],
1781 peer
->pmax
[afi
][safi
]);
1782 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
1785 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
1789 /* Unconditionally remove the route from the RIB, without taking
1790 * damping into consideration (eg, because the session went down)
1793 bgp_rib_remove (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
1794 afi_t afi
, safi_t safi
)
1796 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
1798 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
1799 bgp_info_delete (rn
, ri
); /* keep historical info */
1801 bgp_process (peer
->bgp
, rn
, afi
, safi
);
1805 bgp_rib_withdraw (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
1806 afi_t afi
, safi_t safi
)
1808 int status
= BGP_DAMP_NONE
;
1810 /* apply dampening, if result is suppressed, we'll be retaining
1811 * the bgp_info in the RIB for historical reference.
1813 if (CHECK_FLAG (peer
->bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
1814 && peer_sort (peer
) == BGP_PEER_EBGP
)
1815 if ( (status
= bgp_damp_withdraw (ri
, rn
, afi
, safi
, 0))
1816 == BGP_DAMP_SUPPRESSED
)
1818 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
1822 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
1826 bgp_update_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
,
1827 struct attr
*attr
, struct peer
*peer
, struct prefix
*p
, int type
,
1828 int sub_type
, struct prefix_rd
*prd
, u_char
*tag
)
1830 struct bgp_node
*rn
;
1832 struct attr new_attr
= { 0 };
1833 struct attr
*attr_new
;
1834 struct attr
*attr_new2
;
1835 struct bgp_info
*ri
;
1836 struct bgp_info
*new;
1838 char buf
[SU_ADDRSTRLEN
];
1840 /* Do not insert announces from a rsclient into its own 'bgp_table'. */
1841 if (peer
== rsclient
)
1845 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
1847 /* Check previously received route. */
1848 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1849 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
1852 /* AS path loop check. */
1853 if (aspath_loop_check (attr
->aspath
, rsclient
->as
) > peer
->allowas_in
[afi
][safi
])
1855 reason
= "as-path contains our own AS;";
1859 /* Route reflector originator ID check. */
1860 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
1861 && IPV4_ADDR_SAME (&rsclient
->remote_id
, &attr
->extra
->originator_id
))
1863 reason
= "originator is us;";
1867 bgp_attr_dup (&new_attr
, attr
);
1869 /* Apply export policy. */
1870 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
) &&
1871 bgp_export_modifier (rsclient
, peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
1873 reason
= "export-policy;";
1877 attr_new2
= bgp_attr_intern (&new_attr
);
1879 /* Apply import policy. */
1880 if (bgp_import_modifier (rsclient
, peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
1882 bgp_attr_unintern (attr_new2
);
1884 reason
= "import-policy;";
1888 attr_new
= bgp_attr_intern (&new_attr
);
1889 bgp_attr_unintern (attr_new2
);
1891 /* IPv4 unicast next hop check. */
1892 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
1894 /* Next hop must not be 0.0.0.0 nor Class E address. */
1895 if (new_attr
.nexthop
.s_addr
== 0
1896 || ntohl (new_attr
.nexthop
.s_addr
) >= 0xe0000000)
1898 bgp_attr_unintern (attr_new
);
1900 reason
= "martian next-hop;";
1905 /* new_attr isn't passed to any functions after here */
1906 bgp_attr_extra_free (&new_attr
);
1908 /* If the update is implicit withdraw. */
1911 ri
->uptime
= bgp_clock ();
1913 /* Same attribute comes in. */
1914 if (!CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
)
1915 && attrhash_cmp (ri
->attr
, attr_new
))
1918 bgp_info_unset_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
1920 if (BGP_DEBUG (update
, UPDATE_IN
))
1921 zlog (peer
->log
, LOG_DEBUG
,
1922 "%s rcvd %s/%d for RS-client %s...duplicate ignored",
1924 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1925 p
->prefixlen
, rsclient
->host
);
1927 bgp_unlock_node (rn
);
1928 bgp_attr_unintern (attr_new
);
1933 /* Withdraw/Announce before we fully processed the withdraw */
1934 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
1935 bgp_info_restore (rn
, ri
);
1937 /* Received Logging. */
1938 if (BGP_DEBUG (update
, UPDATE_IN
))
1939 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d for RS-client %s",
1941 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1942 p
->prefixlen
, rsclient
->host
);
1944 /* The attribute is changed. */
1945 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
1947 /* Update to new attribute. */
1948 bgp_attr_unintern (ri
->attr
);
1949 ri
->attr
= attr_new
;
1951 /* Update MPLS tag. */
1952 if (safi
== SAFI_MPLS_VPN
)
1953 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
1955 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
1957 /* Process change. */
1958 bgp_process (bgp
, rn
, afi
, safi
);
1959 bgp_unlock_node (rn
);
1964 /* Received Logging. */
1965 if (BGP_DEBUG (update
, UPDATE_IN
))
1967 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d for RS-client %s",
1969 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1970 p
->prefixlen
, rsclient
->host
);
1973 /* Make new BGP info. */
1974 new = bgp_info_new ();
1976 new->sub_type
= sub_type
;
1978 new->attr
= attr_new
;
1979 new->uptime
= bgp_clock ();
1981 /* Update MPLS tag. */
1982 if (safi
== SAFI_MPLS_VPN
)
1983 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
1985 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
1987 /* Register new BGP information. */
1988 bgp_info_add (rn
, new);
1990 /* route_node_get lock */
1991 bgp_unlock_node (rn
);
1993 /* Process change. */
1994 bgp_process (bgp
, rn
, afi
, safi
);
1996 bgp_attr_extra_free (&new_attr
);
2002 /* This BGP update is filtered. Log the reason then update BGP entry. */
2003 if (BGP_DEBUG (update
, UPDATE_IN
))
2004 zlog (peer
->log
, LOG_DEBUG
,
2005 "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s",
2007 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2008 p
->prefixlen
, rsclient
->host
, reason
);
2011 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2013 bgp_unlock_node (rn
);
2016 bgp_attr_extra_free (&new_attr
);
2022 bgp_withdraw_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
,
2023 struct peer
*peer
, struct prefix
*p
, int type
, int sub_type
,
2024 struct prefix_rd
*prd
, u_char
*tag
)
2026 struct bgp_node
*rn
;
2027 struct bgp_info
*ri
;
2028 char buf
[SU_ADDRSTRLEN
];
2030 if (rsclient
== peer
)
2033 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2035 /* Lookup withdrawn route. */
2036 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2037 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
2040 /* Withdraw specified route from routing table. */
2041 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2042 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
2043 else if (BGP_DEBUG (update
, UPDATE_IN
))
2044 zlog (peer
->log
, LOG_DEBUG
,
2045 "%s Can't find the route %s/%d", peer
->host
,
2046 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2049 /* Unlock bgp_node_get() lock. */
2050 bgp_unlock_node (rn
);
2054 bgp_update_main (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
2055 afi_t afi
, safi_t safi
, int type
, int sub_type
,
2056 struct prefix_rd
*prd
, u_char
*tag
, int soft_reconfig
)
2059 int aspath_loop_count
= 0;
2060 struct bgp_node
*rn
;
2062 struct attr new_attr
= { 0 };
2063 struct attr
*attr_new
;
2064 struct bgp_info
*ri
;
2065 struct bgp_info
*new;
2067 char buf
[SU_ADDRSTRLEN
];
2070 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2072 /* When peer's soft reconfiguration enabled. Record input packet in
2074 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2075 && peer
!= bgp
->peer_self
&& ! soft_reconfig
)
2076 bgp_adj_in_set (rn
, peer
, attr
);
2078 /* Check previously received route. */
2079 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2080 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
2083 /* AS path local-as loop check. */
2084 if (peer
->change_local_as
)
2086 if (! CHECK_FLAG (peer
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
2087 aspath_loop_count
= 1;
2089 if (aspath_loop_check (attr
->aspath
, peer
->change_local_as
) > aspath_loop_count
)
2091 reason
= "as-path contains our own AS;";
2096 /* AS path loop check. */
2097 if (aspath_loop_check (attr
->aspath
, bgp
->as
) > peer
->allowas_in
[afi
][safi
]
2098 || (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
2099 && aspath_loop_check(attr
->aspath
, bgp
->confed_id
)
2100 > peer
->allowas_in
[afi
][safi
]))
2102 reason
= "as-path contains our own AS;";
2106 /* Route reflector originator ID check. */
2107 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
2108 && IPV4_ADDR_SAME (&bgp
->router_id
, &attr
->extra
->originator_id
))
2110 reason
= "originator is us;";
2114 /* Route reflector cluster ID check. */
2115 if (bgp_cluster_filter (peer
, attr
))
2117 reason
= "reflected from the same cluster;";
2121 /* Apply incoming filter. */
2122 if (bgp_input_filter (peer
, p
, attr
, afi
, safi
) == FILTER_DENY
)
2128 /* Apply incoming route-map. */
2129 bgp_attr_dup (&new_attr
, attr
);
2131 if (bgp_input_modifier (peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
2133 reason
= "route-map;";
2137 /* IPv4 unicast next hop check. */
2138 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2140 /* If the peer is EBGP and nexthop is not on connected route,
2142 if (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
== 1
2143 && ! bgp_nexthop_check_ebgp (afi
, &new_attr
)
2144 && ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
2146 reason
= "non-connected next-hop;";
2150 /* Next hop must not be 0.0.0.0 nor Class E address. Next hop
2151 must not be my own address. */
2152 if (bgp_nexthop_self (afi
, &new_attr
)
2153 || new_attr
.nexthop
.s_addr
== 0
2154 || ntohl (new_attr
.nexthop
.s_addr
) >= 0xe0000000)
2156 reason
= "martian next-hop;";
2161 attr_new
= bgp_attr_intern (&new_attr
);
2163 /* If the update is implicit withdraw. */
2166 ri
->uptime
= bgp_clock ();
2168 /* Same attribute comes in. */
2169 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
2170 && attrhash_cmp (ri
->attr
, attr_new
))
2172 bgp_info_unset_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2174 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2175 && peer_sort (peer
) == BGP_PEER_EBGP
2176 && CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2178 if (BGP_DEBUG (update
, UPDATE_IN
))
2179 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2181 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2184 if (bgp_damp_update (ri
, rn
, afi
, safi
) != BGP_DAMP_SUPPRESSED
)
2186 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2187 bgp_process (bgp
, rn
, afi
, safi
);
2190 else /* Duplicate - odd */
2192 if (BGP_DEBUG (update
, UPDATE_IN
))
2193 zlog (peer
->log
, LOG_DEBUG
,
2194 "%s rcvd %s/%d...duplicate ignored",
2196 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2199 /* graceful restart STALE flag unset. */
2200 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2202 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2203 bgp_process (bgp
, rn
, afi
, safi
);
2207 bgp_unlock_node (rn
);
2208 bgp_attr_unintern (attr_new
);
2209 bgp_attr_extra_free (&new_attr
);
2214 /* Withdraw/Announce before we fully processed the withdraw */
2215 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
2217 if (BGP_DEBUG (update
, UPDATE_IN
))
2218 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d, flapped quicker than processing",
2220 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2222 bgp_info_restore (rn
, ri
);
2225 /* Received Logging. */
2226 if (BGP_DEBUG (update
, UPDATE_IN
))
2227 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2229 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2232 /* graceful restart STALE flag unset. */
2233 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2234 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2236 /* The attribute is changed. */
2237 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2239 /* implicit withdraw, decrement aggregate and pcount here.
2240 * only if update is accepted, they'll increment below.
2242 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
2244 /* Update bgp route dampening information. */
2245 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2246 && peer_sort (peer
) == BGP_PEER_EBGP
)
2248 /* This is implicit withdraw so we should update dampening
2250 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2251 bgp_damp_withdraw (ri
, rn
, afi
, safi
, 1);
2254 /* Update to new attribute. */
2255 bgp_attr_unintern (ri
->attr
);
2256 ri
->attr
= attr_new
;
2258 /* Update MPLS tag. */
2259 if (safi
== SAFI_MPLS_VPN
)
2260 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
2262 /* Update bgp route dampening information. */
2263 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2264 && peer_sort (peer
) == BGP_PEER_EBGP
)
2266 /* Now we do normal update dampening. */
2267 ret
= bgp_damp_update (ri
, rn
, afi
, safi
);
2268 if (ret
== BGP_DAMP_SUPPRESSED
)
2270 bgp_unlock_node (rn
);
2271 bgp_attr_extra_free (&new_attr
);
2276 /* Nexthop reachability check. */
2277 if ((afi
== AFI_IP
|| afi
== AFI_IP6
)
2278 && safi
== SAFI_UNICAST
2279 && (peer_sort (peer
) == BGP_PEER_IBGP
2280 || peer_sort (peer
) == BGP_PEER_CONFED
2281 || (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)
2282 || CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)))
2284 if (bgp_nexthop_lookup (afi
, peer
, ri
, NULL
, NULL
))
2285 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2287 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
2290 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2292 /* Process change. */
2293 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2295 bgp_process (bgp
, rn
, afi
, safi
);
2296 bgp_unlock_node (rn
);
2297 bgp_attr_extra_free (&new_attr
);
2302 /* Received Logging. */
2303 if (BGP_DEBUG (update
, UPDATE_IN
))
2305 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2307 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2311 /* Make new BGP info. */
2312 new = bgp_info_new ();
2314 new->sub_type
= sub_type
;
2316 new->attr
= attr_new
;
2317 new->uptime
= bgp_clock ();
2319 /* Update MPLS tag. */
2320 if (safi
== SAFI_MPLS_VPN
)
2321 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
2323 /* Nexthop reachability check. */
2324 if ((afi
== AFI_IP
|| afi
== AFI_IP6
)
2325 && safi
== SAFI_UNICAST
2326 && (peer_sort (peer
) == BGP_PEER_IBGP
2327 || peer_sort (peer
) == BGP_PEER_CONFED
2328 || (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)
2329 || CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)))
2331 if (bgp_nexthop_lookup (afi
, peer
, new, NULL
, NULL
))
2332 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2334 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
2337 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2339 /* Increment prefix */
2340 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
2342 /* Register new BGP information. */
2343 bgp_info_add (rn
, new);
2345 /* route_node_get lock */
2346 bgp_unlock_node (rn
);
2348 bgp_attr_extra_free (&new_attr
);
2350 /* If maximum prefix count is configured and current prefix
2352 if (bgp_maximum_prefix_overflow (peer
, afi
, safi
, 0))
2355 /* Process change. */
2356 bgp_process (bgp
, rn
, afi
, safi
);
2360 /* This BGP update is filtered. Log the reason then update BGP
2363 if (BGP_DEBUG (update
, UPDATE_IN
))
2364 zlog (peer
->log
, LOG_DEBUG
,
2365 "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
2367 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2368 p
->prefixlen
, reason
);
2371 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2373 bgp_unlock_node (rn
);
2375 bgp_attr_extra_free (&new_attr
);
2381 bgp_update (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
2382 afi_t afi
, safi_t safi
, int type
, int sub_type
,
2383 struct prefix_rd
*prd
, u_char
*tag
, int soft_reconfig
)
2385 struct peer
*rsclient
;
2386 struct listnode
*node
, *nnode
;
2390 ret
= bgp_update_main (peer
, p
, attr
, afi
, safi
, type
, sub_type
, prd
, tag
,
2395 /* Process the update for each RS-client. */
2396 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
2398 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2399 bgp_update_rsclient (rsclient
, afi
, safi
, attr
, peer
, p
, type
,
2400 sub_type
, prd
, tag
);
2407 bgp_withdraw (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
2408 afi_t afi
, safi_t safi
, int type
, int sub_type
,
2409 struct prefix_rd
*prd
, u_char
*tag
)
2412 char buf
[SU_ADDRSTRLEN
];
2413 struct bgp_node
*rn
;
2414 struct bgp_info
*ri
;
2415 struct peer
*rsclient
;
2416 struct listnode
*node
, *nnode
;
2420 /* Process the withdraw for each RS-client. */
2421 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
2423 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2424 bgp_withdraw_rsclient (rsclient
, afi
, safi
, peer
, p
, type
, sub_type
, prd
, tag
);
2428 if (BGP_DEBUG (update
, UPDATE_IN
))
2429 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd UPDATE about %s/%d -- withdrawn",
2431 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2435 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2437 /* If peer is soft reconfiguration enabled. Record input packet for
2438 further calculation. */
2439 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2440 && peer
!= bgp
->peer_self
)
2441 bgp_adj_in_unset (rn
, peer
);
2443 /* Lookup withdrawn route. */
2444 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2445 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
2448 /* Withdraw specified route from routing table. */
2449 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2450 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
2451 else if (BGP_DEBUG (update
, UPDATE_IN
))
2452 zlog (peer
->log
, LOG_DEBUG
,
2453 "%s Can't find the route %s/%d", peer
->host
,
2454 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2457 /* Unlock bgp_node_get() lock. */
2458 bgp_unlock_node (rn
);
2464 bgp_default_originate (struct peer
*peer
, afi_t afi
, safi_t safi
, int withdraw
)
2467 struct attr attr
= { 0 };
2468 struct aspath
*aspath
= { 0 };
2470 struct bgp_info binfo
;
2472 int ret
= RMAP_DENYMATCH
;
2474 if (!(afi
== AFI_IP
|| afi
== AFI_IP6
))
2478 from
= bgp
->peer_self
;
2480 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
2481 aspath
= attr
.aspath
;
2482 attr
.local_pref
= bgp
->default_local_pref
;
2483 memcpy (&attr
.nexthop
, &peer
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
2486 str2prefix ("0.0.0.0/0", &p
);
2488 else if (afi
== AFI_IP6
)
2490 struct attr_extra
*ae
;
2493 ae
= bgp_attr_extra_get (&attr
);
2496 str2prefix ("::/0", &p
);
2498 /* IPv6 global nexthop must be included. */
2499 memcpy (&ae
->mp_nexthop_global
, &peer
->nexthop
.v6_global
,
2501 ae
->mp_nexthop_len
= 16;
2503 /* If the peer is on shared nextwork and we have link-local
2505 if (peer
->shared_network
2506 && !IN6_IS_ADDR_UNSPECIFIED (&peer
->nexthop
.v6_local
))
2508 memcpy (&ae
->mp_nexthop_local
, &peer
->nexthop
.v6_local
,
2510 ae
->mp_nexthop_len
= 32;
2513 #endif /* HAVE_IPV6 */
2515 if (peer
->default_rmap
[afi
][safi
].name
)
2517 binfo
.peer
= bgp
->peer_self
;
2520 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_DEFAULT
);
2522 ret
= route_map_apply (peer
->default_rmap
[afi
][safi
].map
, &p
,
2525 bgp
->peer_self
->rmap_type
= 0;
2527 if (ret
== RMAP_DENYMATCH
)
2529 bgp_attr_flush (&attr
);
2536 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
))
2537 bgp_default_withdraw_send (peer
, afi
, safi
);
2538 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
);
2542 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
);
2543 bgp_default_update_send (peer
, &attr
, afi
, safi
, from
);
2546 bgp_attr_extra_free (&attr
);
2547 aspath_unintern (aspath
);
2551 bgp_announce_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2552 struct bgp_table
*table
, int rsclient
)
2554 struct bgp_node
*rn
;
2555 struct bgp_info
*ri
;
2556 struct attr attr
= { 0 };
2559 table
= (rsclient
) ? peer
->rib
[afi
][safi
] : peer
->bgp
->rib
[afi
][safi
];
2561 if (safi
!= SAFI_MPLS_VPN
2562 && CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_DEFAULT_ORIGINATE
))
2563 bgp_default_originate (peer
, afi
, safi
, 0);
2565 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next(rn
))
2566 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2567 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
) && ri
->peer
!= peer
)
2570 (bgp_announce_check_rsclient (ri
, peer
, &rn
->p
, &attr
, afi
, safi
))
2571 : (bgp_announce_check (ri
, peer
, &rn
->p
, &attr
, afi
, safi
)))
2572 bgp_adj_out_set (rn
, peer
, &rn
->p
, &attr
, afi
, safi
, ri
);
2574 bgp_adj_out_unset (rn
, peer
, &rn
->p
, afi
, safi
);
2576 bgp_attr_extra_free (&attr
);
2581 bgp_announce_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2583 struct bgp_node
*rn
;
2584 struct bgp_table
*table
;
2586 if (peer
->status
!= Established
)
2589 if (! peer
->afc_nego
[afi
][safi
])
2592 /* First update is deferred until ORF or ROUTE-REFRESH is received */
2593 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_ORF_WAIT_REFRESH
))
2596 if (safi
!= SAFI_MPLS_VPN
)
2597 bgp_announce_table (peer
, afi
, safi
, NULL
, 0);
2599 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2600 rn
= bgp_route_next(rn
))
2601 if ((table
= (rn
->info
)) != NULL
)
2602 bgp_announce_table (peer
, afi
, safi
, table
, 0);
2604 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2605 bgp_announce_table (peer
, afi
, safi
, NULL
, 1);
2609 bgp_announce_route_all (struct peer
*peer
)
2614 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2615 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2616 bgp_announce_route (peer
, afi
, safi
);
2620 bgp_soft_reconfig_table_rsclient (struct peer
*rsclient
, afi_t afi
,
2621 safi_t safi
, struct bgp_table
*table
)
2623 struct bgp_node
*rn
;
2624 struct bgp_adj_in
*ain
;
2627 table
= rsclient
->bgp
->rib
[afi
][safi
];
2629 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2630 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2632 bgp_update_rsclient (rsclient
, afi
, safi
, ain
->attr
, ain
->peer
,
2633 &rn
->p
, ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
2638 bgp_soft_reconfig_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
)
2640 struct bgp_table
*table
;
2641 struct bgp_node
*rn
;
2643 if (safi
!= SAFI_MPLS_VPN
)
2644 bgp_soft_reconfig_table_rsclient (rsclient
, afi
, safi
, NULL
);
2647 for (rn
= bgp_table_top (rsclient
->bgp
->rib
[afi
][safi
]); rn
;
2648 rn
= bgp_route_next (rn
))
2649 if ((table
= rn
->info
) != NULL
)
2650 bgp_soft_reconfig_table_rsclient (rsclient
, afi
, safi
, table
);
2654 bgp_soft_reconfig_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2655 struct bgp_table
*table
)
2658 struct bgp_node
*rn
;
2659 struct bgp_adj_in
*ain
;
2662 table
= peer
->bgp
->rib
[afi
][safi
];
2664 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2665 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2667 if (ain
->peer
== peer
)
2669 ret
= bgp_update (peer
, &rn
->p
, ain
->attr
, afi
, safi
,
2670 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
,
2674 bgp_unlock_node (rn
);
2683 bgp_soft_reconfig_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2685 struct bgp_node
*rn
;
2686 struct bgp_table
*table
;
2688 if (peer
->status
!= Established
)
2691 if (safi
!= SAFI_MPLS_VPN
)
2692 bgp_soft_reconfig_table (peer
, afi
, safi
, NULL
);
2694 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2695 rn
= bgp_route_next (rn
))
2696 if ((table
= rn
->info
) != NULL
)
2697 bgp_soft_reconfig_table (peer
, afi
, safi
, table
);
2701 struct bgp_clear_node_queue
2703 struct bgp_node
*rn
;
2704 enum bgp_clear_route_type purpose
;
2707 static wq_item_status
2708 bgp_clear_route_node (struct work_queue
*wq
, void *data
)
2710 struct bgp_clear_node_queue
*cnq
= data
;
2711 struct bgp_node
*rn
= cnq
->rn
;
2712 struct peer
*peer
= wq
->spec
.data
;
2713 struct bgp_info
*ri
;
2714 afi_t afi
= rn
->table
->afi
;
2715 safi_t safi
= rn
->table
->safi
;
2717 assert (rn
&& peer
);
2719 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2720 if (ri
->peer
== peer
|| cnq
->purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2722 /* graceful restart STALE flag set. */
2723 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_NSF_WAIT
)
2724 && peer
->nsf
[afi
][safi
]
2725 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
)
2726 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
2727 bgp_info_set_flag (rn
, ri
, BGP_INFO_STALE
);
2729 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2736 bgp_clear_node_queue_del (struct work_queue
*wq
, void *data
)
2738 struct bgp_clear_node_queue
*cnq
= data
;
2739 struct bgp_node
*rn
= cnq
->rn
;
2740 struct bgp_table
*table
= rn
->table
;
2742 bgp_unlock_node (rn
);
2743 bgp_table_unlock (table
);
2744 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE
, cnq
);
2748 bgp_clear_node_complete (struct work_queue
*wq
)
2750 struct peer
*peer
= wq
->spec
.data
;
2752 /* Tickle FSM to start moving again */
2753 BGP_EVENT_ADD (peer
, Clearing_Completed
);
2755 peer_unlock (peer
); /* bgp_clear_route */
2759 bgp_clear_node_queue_init (struct peer
*peer
)
2761 char wname
[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
2763 snprintf (wname
, sizeof(wname
), "clear %s", peer
->host
);
2764 #undef CLEAR_QUEUE_NAME_LEN
2766 if ( (peer
->clear_node_queue
= work_queue_new (bm
->master
, wname
)) == NULL
)
2768 zlog_err ("%s: Failed to allocate work queue", __func__
);
2771 peer
->clear_node_queue
->spec
.hold
= 10;
2772 peer
->clear_node_queue
->spec
.workfunc
= &bgp_clear_route_node
;
2773 peer
->clear_node_queue
->spec
.del_item_data
= &bgp_clear_node_queue_del
;
2774 peer
->clear_node_queue
->spec
.completion_func
= &bgp_clear_node_complete
;
2775 peer
->clear_node_queue
->spec
.max_retries
= 0;
2777 /* we only 'lock' this peer reference when the queue is actually active */
2778 peer
->clear_node_queue
->spec
.data
= peer
;
2782 bgp_clear_route_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2783 struct bgp_table
*table
, struct peer
*rsclient
,
2784 enum bgp_clear_route_type purpose
)
2786 struct bgp_node
*rn
;
2790 table
= (rsclient
) ? rsclient
->rib
[afi
][safi
] : peer
->bgp
->rib
[afi
][safi
];
2792 /* If still no table => afi/safi isn't configured at all or smth. */
2796 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2798 struct bgp_info
*ri
;
2799 struct bgp_adj_in
*ain
;
2800 struct bgp_adj_out
*aout
;
2802 if (rn
->info
== NULL
)
2805 /* XXX:TODO: This is suboptimal, every non-empty route_node is
2806 * queued for every clearing peer, regardless of whether it is
2807 * relevant to the peer at hand.
2809 * Overview: There are 3 different indices which need to be
2810 * scrubbed, potentially, when a peer is removed:
2812 * 1 peer's routes visible via the RIB (ie accepted routes)
2813 * 2 peer's routes visible by the (optional) peer's adj-in index
2814 * 3 other routes visible by the peer's adj-out index
2816 * 3 there is no hurry in scrubbing, once the struct peer is
2817 * removed from bgp->peer, we could just GC such deleted peer's
2818 * adj-outs at our leisure.
2820 * 1 and 2 must be 'scrubbed' in some way, at least made
2821 * invisible via RIB index before peer session is allowed to be
2822 * brought back up. So one needs to know when such a 'search' is
2827 * - there'd be a single global queue or a single RIB walker
2828 * - rather than tracking which route_nodes still need to be
2829 * examined on a peer basis, we'd track which peers still
2832 * Given that our per-peer prefix-counts now should be reliable,
2833 * this may actually be achievable. It doesn't seem to be a huge
2834 * problem at this time,
2836 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2837 if (ri
->peer
== peer
|| purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2839 struct bgp_clear_node_queue
*cnq
;
2841 /* both unlocked in bgp_clear_node_queue_del */
2842 bgp_table_lock (rn
->table
);
2844 cnq
= XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE
,
2845 sizeof (struct bgp_clear_node_queue
));
2847 cnq
->purpose
= purpose
;
2848 work_queue_add (peer
->clear_node_queue
, cnq
);
2852 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2853 if (ain
->peer
== peer
|| purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2855 bgp_adj_in_remove (rn
, ain
);
2856 bgp_unlock_node (rn
);
2859 for (aout
= rn
->adj_out
; aout
; aout
= aout
->next
)
2860 if (aout
->peer
== peer
|| purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2862 bgp_adj_out_remove (rn
, aout
, peer
, afi
, safi
);
2863 bgp_unlock_node (rn
);
2871 bgp_clear_route (struct peer
*peer
, afi_t afi
, safi_t safi
,
2872 enum bgp_clear_route_type purpose
)
2874 struct bgp_node
*rn
;
2875 struct bgp_table
*table
;
2876 struct peer
*rsclient
;
2877 struct listnode
*node
, *nnode
;
2879 if (peer
->clear_node_queue
== NULL
)
2880 bgp_clear_node_queue_init (peer
);
2882 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
2883 * Idle until it receives a Clearing_Completed event. This protects
2884 * against peers which flap faster than we can we clear, which could
2887 * a) race with routes from the new session being installed before
2888 * clear_route_node visits the node (to delete the route of that
2890 * b) resource exhaustion, clear_route_node likely leads to an entry
2891 * on the process_main queue. Fast-flapping could cause that queue
2894 if (!peer
->clear_node_queue
->thread
)
2895 peer_lock (peer
); /* bgp_clear_node_complete */
2899 case BGP_CLEAR_ROUTE_NORMAL
:
2900 if (safi
!= SAFI_MPLS_VPN
)
2901 bgp_clear_route_table (peer
, afi
, safi
, NULL
, NULL
, purpose
);
2903 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2904 rn
= bgp_route_next (rn
))
2905 if ((table
= rn
->info
) != NULL
)
2906 bgp_clear_route_table (peer
, afi
, safi
, table
, NULL
, purpose
);
2908 for (ALL_LIST_ELEMENTS (peer
->bgp
->rsclient
, node
, nnode
, rsclient
))
2909 if (CHECK_FLAG(rsclient
->af_flags
[afi
][safi
],
2910 PEER_FLAG_RSERVER_CLIENT
))
2911 bgp_clear_route_table (peer
, afi
, safi
, NULL
, rsclient
, purpose
);
2914 case BGP_CLEAR_ROUTE_MY_RSCLIENT
:
2915 bgp_clear_route_table (peer
, afi
, safi
, NULL
, peer
, purpose
);
2923 /* If no routes were cleared, nothing was added to workqueue, the
2924 * completion function won't be run by workqueue code - call it here.
2925 * XXX: Actually, this assumption doesn't hold, see
2926 * bgp_clear_route_table(), we queue all non-empty nodes.
2928 * Additionally, there is a presumption in FSM that clearing is only
2929 * really needed if peer state is Established - peers in
2930 * pre-Established states shouldn't have any route-update state
2931 * associated with them (in or out).
2933 * We still can get here in pre-Established though, through
2934 * peer_delete -> bgp_fsm_change_status, so this is a useful sanity
2935 * check to ensure the assumption above holds.
2937 * At some future point, this check could be move to the top of the
2938 * function, and do a quick early-return when state is
2939 * pre-Established, avoiding above list and table scans. Once we're
2942 if (!peer
->clear_node_queue
->thread
)
2943 bgp_clear_node_complete (peer
->clear_node_queue
);
2947 bgp_clear_route_all (struct peer
*peer
)
2952 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2953 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2954 bgp_clear_route (peer
, afi
, safi
, BGP_CLEAR_ROUTE_NORMAL
);
2958 bgp_clear_adj_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2960 struct bgp_table
*table
;
2961 struct bgp_node
*rn
;
2962 struct bgp_adj_in
*ain
;
2964 table
= peer
->bgp
->rib
[afi
][safi
];
2966 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2967 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2968 if (ain
->peer
== peer
)
2970 bgp_adj_in_remove (rn
, ain
);
2971 bgp_unlock_node (rn
);
2977 bgp_clear_stale_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2979 struct bgp_node
*rn
;
2980 struct bgp_info
*ri
;
2981 struct bgp_table
*table
;
2983 table
= peer
->bgp
->rib
[afi
][safi
];
2985 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2987 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2988 if (ri
->peer
== peer
)
2990 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2991 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2997 /* Delete all kernel routes. */
2999 bgp_cleanup_routes (void)
3002 struct listnode
*node
, *nnode
;
3003 struct bgp_node
*rn
;
3004 struct bgp_table
*table
;
3005 struct bgp_info
*ri
;
3007 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
3009 table
= bgp
->rib
[AFI_IP
][SAFI_UNICAST
];
3011 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3012 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3013 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
3014 && ri
->type
== ZEBRA_ROUTE_BGP
3015 && ri
->sub_type
== BGP_ROUTE_NORMAL
)
3016 bgp_zebra_withdraw (&rn
->p
, ri
);
3018 table
= bgp
->rib
[AFI_IP6
][SAFI_UNICAST
];
3020 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3021 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3022 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
3023 && ri
->type
== ZEBRA_ROUTE_BGP
3024 && ri
->sub_type
== BGP_ROUTE_NORMAL
)
3025 bgp_zebra_withdraw (&rn
->p
, ri
);
3033 bgp_zclient_reset ();
3034 access_list_reset ();
3035 prefix_list_reset ();
3038 /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3041 bgp_nlri_parse (struct peer
*peer
, struct attr
*attr
, struct bgp_nlri
*packet
)
3049 /* Check peer status. */
3050 if (peer
->status
!= Established
)
3054 lim
= pnt
+ packet
->length
;
3056 for (; pnt
< lim
; pnt
+= psize
)
3058 /* Clear prefix structure. */
3059 memset (&p
, 0, sizeof (struct prefix
));
3061 /* Fetch prefix length. */
3062 p
.prefixlen
= *pnt
++;
3063 p
.family
= afi2family (packet
->afi
);
3065 /* Already checked in nlri_sanity_check(). We do double check
3067 if ((packet
->afi
== AFI_IP
&& p
.prefixlen
> 32)
3068 || (packet
->afi
== AFI_IP6
&& p
.prefixlen
> 128))
3071 /* Packet size overflow check. */
3072 psize
= PSIZE (p
.prefixlen
);
3074 /* When packet overflow occur return immediately. */
3075 if (pnt
+ psize
> lim
)
3078 /* Fetch prefix from NLRI packet. */
3079 memcpy (&p
.u
.prefix
, pnt
, psize
);
3081 /* Check address. */
3082 if (packet
->afi
== AFI_IP
&& packet
->safi
== SAFI_UNICAST
)
3084 if (IN_CLASSD (ntohl (p
.u
.prefix4
.s_addr
)))
3087 * From draft-ietf-idr-bgp4-22, Section 6.3:
3088 * If a BGP router receives an UPDATE message with a
3089 * semantically incorrect NLRI field, in which a prefix is
3090 * semantically incorrect (eg. an unexpected multicast IP
3091 * address), it should ignore the prefix.
3093 zlog (peer
->log
, LOG_ERR
,
3094 "IPv4 unicast NLRI is multicast address %s",
3095 inet_ntoa (p
.u
.prefix4
));
3102 /* Check address. */
3103 if (packet
->afi
== AFI_IP6
&& packet
->safi
== SAFI_UNICAST
)
3105 if (IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3109 zlog (peer
->log
, LOG_WARNING
,
3110 "IPv6 link-local NLRI received %s ignore this NLRI",
3111 inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3116 #endif /* HAVE_IPV6 */
3118 /* Normal process. */
3120 ret
= bgp_update (peer
, &p
, attr
, packet
->afi
, packet
->safi
,
3121 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
3123 ret
= bgp_withdraw (peer
, &p
, attr
, packet
->afi
, packet
->safi
,
3124 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
3126 /* Address family configuration mismatch or maximum-prefix count
3132 /* Packet length consistency check. */
3139 /* NLRI encode syntax check routine. */
3141 bgp_nlri_sanity_check (struct peer
*peer
, int afi
, u_char
*pnt
,
3150 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
3151 syntactic validity. If the field is syntactically incorrect,
3152 then the Error Subcode is set to Invalid Network Field. */
3158 /* Prefix length check. */
3159 if ((afi
== AFI_IP
&& prefixlen
> 32)
3160 || (afi
== AFI_IP6
&& prefixlen
> 128))
3162 plog_err (peer
->log
,
3163 "%s [Error] Update packet error (wrong prefix length %d)",
3164 peer
->host
, prefixlen
);
3165 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3166 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3170 /* Packet size overflow check. */
3171 psize
= PSIZE (prefixlen
);
3173 if (pnt
+ psize
> end
)
3175 plog_err (peer
->log
,
3176 "%s [Error] Update packet error"
3177 " (prefix data overflow prefix size is %d)",
3179 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3180 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3187 /* Packet length consistency check. */
3190 plog_err (peer
->log
,
3191 "%s [Error] Update packet error"
3192 " (prefix length mismatch with total length)",
3194 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3195 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3201 static struct bgp_static
*
3202 bgp_static_new (void)
3204 return XCALLOC (MTYPE_BGP_STATIC
, sizeof (struct bgp_static
));
3208 bgp_static_free (struct bgp_static
*bgp_static
)
3210 if (bgp_static
->rmap
.name
)
3211 free (bgp_static
->rmap
.name
);
3212 XFREE (MTYPE_BGP_STATIC
, bgp_static
);
3216 bgp_static_withdraw_rsclient (struct bgp
*bgp
, struct peer
*rsclient
,
3217 struct prefix
*p
, afi_t afi
, safi_t safi
)
3219 struct bgp_node
*rn
;
3220 struct bgp_info
*ri
;
3222 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3224 /* Check selected route and self inserted route. */
3225 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3226 if (ri
->peer
== bgp
->peer_self
3227 && ri
->type
== ZEBRA_ROUTE_BGP
3228 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3231 /* Withdraw static BGP route from routing table. */
3234 bgp_info_delete (rn
, ri
);
3235 bgp_process (bgp
, rn
, afi
, safi
);
3238 /* Unlock bgp_node_lookup. */
3239 bgp_unlock_node (rn
);
3243 bgp_static_update_rsclient (struct peer
*rsclient
, struct prefix
*p
,
3244 struct bgp_static
*bgp_static
,
3245 afi_t afi
, safi_t safi
)
3247 struct bgp_node
*rn
;
3248 struct bgp_info
*ri
;
3249 struct bgp_info
*new;
3250 struct bgp_info info
;
3251 struct attr
*attr_new
;
3252 struct attr attr
= {0 };
3253 struct attr new_attr
= { .extra
= 0 };
3256 char buf
[SU_ADDRSTRLEN
];
3258 bgp
= rsclient
->bgp
;
3260 assert (bgp_static
);
3264 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3266 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3268 attr
.nexthop
= bgp_static
->igpnexthop
;
3269 attr
.med
= bgp_static
->igpmetric
;
3270 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3272 if (bgp_static
->atomic
)
3273 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3275 /* Apply network route-map for export to this rsclient. */
3276 if (bgp_static
->rmap
.name
)
3278 struct attr attr_tmp
= attr
;
3279 info
.peer
= rsclient
;
3280 info
.attr
= &attr_tmp
;
3282 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_EXPORT
);
3283 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3285 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3287 rsclient
->rmap_type
= 0;
3289 if (ret
== RMAP_DENYMATCH
)
3291 /* Free uninterned attribute. */
3292 bgp_attr_flush (&attr_tmp
);
3294 /* Unintern original. */
3295 aspath_unintern (attr
.aspath
);
3296 bgp_static_withdraw_rsclient (bgp
, rsclient
, p
, afi
, safi
);
3297 bgp_attr_extra_free (&attr
);
3301 attr_new
= bgp_attr_intern (&attr_tmp
);
3304 attr_new
= bgp_attr_intern (&attr
);
3306 bgp_attr_dup(&new_attr
, attr_new
);
3308 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3310 if (bgp_import_modifier (rsclient
, bgp
->peer_self
, p
, &new_attr
, afi
, safi
)
3313 /* This BGP update is filtered. Log the reason then update BGP entry. */
3314 if (BGP_DEBUG (update
, UPDATE_IN
))
3315 zlog (rsclient
->log
, LOG_DEBUG
,
3316 "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
3317 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
3318 p
->prefixlen
, rsclient
->host
);
3320 bgp
->peer_self
->rmap_type
= 0;
3322 bgp_attr_unintern (attr_new
);
3323 aspath_unintern (attr
.aspath
);
3324 bgp_attr_extra_free (&attr
);
3326 bgp_static_withdraw_rsclient (bgp
, rsclient
, p
, afi
, safi
);
3331 bgp
->peer_self
->rmap_type
= 0;
3333 bgp_attr_unintern (attr_new
);
3334 attr_new
= bgp_attr_intern (&new_attr
);
3335 bgp_attr_extra_free (&new_attr
);
3337 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3338 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3339 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3344 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3345 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3347 bgp_unlock_node (rn
);
3348 bgp_attr_unintern (attr_new
);
3349 aspath_unintern (attr
.aspath
);
3350 bgp_attr_extra_free (&attr
);
3355 /* The attribute is changed. */
3356 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3358 /* Rewrite BGP route information. */
3359 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3360 bgp_info_restore(rn
, ri
);
3361 bgp_attr_unintern (ri
->attr
);
3362 ri
->attr
= attr_new
;
3363 ri
->uptime
= bgp_clock ();
3365 /* Process change. */
3366 bgp_process (bgp
, rn
, afi
, safi
);
3367 bgp_unlock_node (rn
);
3368 aspath_unintern (attr
.aspath
);
3369 bgp_attr_extra_free (&attr
);
3374 /* Make new BGP info. */
3375 new = bgp_info_new ();
3376 new->type
= ZEBRA_ROUTE_BGP
;
3377 new->sub_type
= BGP_ROUTE_STATIC
;
3378 new->peer
= bgp
->peer_self
;
3379 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3380 new->attr
= attr_new
;
3381 new->uptime
= bgp_clock ();
3383 /* Register new BGP information. */
3384 bgp_info_add (rn
, new);
3386 /* route_node_get lock */
3387 bgp_unlock_node (rn
);
3389 /* Process change. */
3390 bgp_process (bgp
, rn
, afi
, safi
);
3392 /* Unintern original. */
3393 aspath_unintern (attr
.aspath
);
3394 bgp_attr_extra_free (&attr
);
3398 bgp_static_update_main (struct bgp
*bgp
, struct prefix
*p
,
3399 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3401 struct bgp_node
*rn
;
3402 struct bgp_info
*ri
;
3403 struct bgp_info
*new;
3404 struct bgp_info info
;
3405 struct attr attr
= { 0 };
3406 struct attr
*attr_new
;
3409 assert (bgp_static
);
3413 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3415 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3417 attr
.nexthop
= bgp_static
->igpnexthop
;
3418 attr
.med
= bgp_static
->igpmetric
;
3419 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3421 if (bgp_static
->atomic
)
3422 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3424 /* Apply route-map. */
3425 if (bgp_static
->rmap
.name
)
3427 struct attr attr_tmp
= attr
;
3428 info
.peer
= bgp
->peer_self
;
3429 info
.attr
= &attr_tmp
;
3431 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3433 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3435 bgp
->peer_self
->rmap_type
= 0;
3437 if (ret
== RMAP_DENYMATCH
)
3439 /* Free uninterned attribute. */
3440 bgp_attr_flush (&attr_tmp
);
3442 /* Unintern original. */
3443 aspath_unintern (attr
.aspath
);
3444 bgp_attr_extra_free (&attr
);
3445 bgp_static_withdraw (bgp
, p
, afi
, safi
);
3448 attr_new
= bgp_attr_intern (&attr_tmp
);
3451 attr_new
= bgp_attr_intern (&attr
);
3453 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3454 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3455 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3460 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3461 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3463 bgp_unlock_node (rn
);
3464 bgp_attr_unintern (attr_new
);
3465 aspath_unintern (attr
.aspath
);
3466 bgp_attr_extra_free (&attr
);
3471 /* The attribute is changed. */
3472 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3474 /* Rewrite BGP route information. */
3475 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3476 bgp_info_restore(rn
, ri
);
3478 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3479 bgp_attr_unintern (ri
->attr
);
3480 ri
->attr
= attr_new
;
3481 ri
->uptime
= bgp_clock ();
3483 /* Process change. */
3484 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3485 bgp_process (bgp
, rn
, afi
, safi
);
3486 bgp_unlock_node (rn
);
3487 aspath_unintern (attr
.aspath
);
3488 bgp_attr_extra_free (&attr
);
3493 /* Make new BGP info. */
3494 new = bgp_info_new ();
3495 new->type
= ZEBRA_ROUTE_BGP
;
3496 new->sub_type
= BGP_ROUTE_STATIC
;
3497 new->peer
= bgp
->peer_self
;
3498 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3499 new->attr
= attr_new
;
3500 new->uptime
= bgp_clock ();
3502 /* Aggregate address increment. */
3503 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3505 /* Register new BGP information. */
3506 bgp_info_add (rn
, new);
3508 /* route_node_get lock */
3509 bgp_unlock_node (rn
);
3511 /* Process change. */
3512 bgp_process (bgp
, rn
, afi
, safi
);
3514 /* Unintern original. */
3515 aspath_unintern (attr
.aspath
);
3516 bgp_attr_extra_free (&attr
);
3520 bgp_static_update (struct bgp
*bgp
, struct prefix
*p
,
3521 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3523 struct peer
*rsclient
;
3524 struct listnode
*node
, *nnode
;
3526 bgp_static_update_main (bgp
, p
, bgp_static
, afi
, safi
);
3528 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
3530 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
3531 bgp_static_update_rsclient (rsclient
, p
, bgp_static
, afi
, safi
);
3536 bgp_static_update_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3537 safi_t safi
, struct prefix_rd
*prd
, u_char
*tag
)
3539 struct bgp_node
*rn
;
3540 struct bgp_info
*new;
3542 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3544 /* Make new BGP info. */
3545 new = bgp_info_new ();
3546 new->type
= ZEBRA_ROUTE_BGP
;
3547 new->sub_type
= BGP_ROUTE_STATIC
;
3548 new->peer
= bgp
->peer_self
;
3549 new->attr
= bgp_attr_default_intern (BGP_ORIGIN_IGP
);
3550 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3551 new->uptime
= bgp_clock ();
3552 new->extra
= bgp_info_extra_new();
3553 memcpy (new->extra
->tag
, tag
, 3);
3555 /* Aggregate address increment. */
3556 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3558 /* Register new BGP information. */
3559 bgp_info_add (rn
, new);
3561 /* route_node_get lock */
3562 bgp_unlock_node (rn
);
3564 /* Process change. */
3565 bgp_process (bgp
, rn
, afi
, safi
);
3569 bgp_static_withdraw (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3572 struct bgp_node
*rn
;
3573 struct bgp_info
*ri
;
3575 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3577 /* Check selected route and self inserted route. */
3578 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3579 if (ri
->peer
== bgp
->peer_self
3580 && ri
->type
== ZEBRA_ROUTE_BGP
3581 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3584 /* Withdraw static BGP route from routing table. */
3587 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3588 bgp_info_delete (rn
, ri
);
3589 bgp_process (bgp
, rn
, afi
, safi
);
3592 /* Unlock bgp_node_lookup. */
3593 bgp_unlock_node (rn
);
3597 bgp_check_local_routes_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
)
3599 struct bgp_static
*bgp_static
;
3601 struct bgp_node
*rn
;
3604 bgp
= rsclient
->bgp
;
3606 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3607 if ((bgp_static
= rn
->info
) != NULL
)
3611 bgp_static_update_rsclient (rsclient
, p
, bgp_static
,
3617 bgp_static_withdraw_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3618 safi_t safi
, struct prefix_rd
*prd
, u_char
*tag
)
3620 struct bgp_node
*rn
;
3621 struct bgp_info
*ri
;
3623 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3625 /* Check selected route and self inserted route. */
3626 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3627 if (ri
->peer
== bgp
->peer_self
3628 && ri
->type
== ZEBRA_ROUTE_BGP
3629 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3632 /* Withdraw static BGP route from routing table. */
3635 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3636 bgp_info_delete (rn
, ri
);
3637 bgp_process (bgp
, rn
, afi
, safi
);
3640 /* Unlock bgp_node_lookup. */
3641 bgp_unlock_node (rn
);
3644 /* Configure static BGP network. When user don't run zebra, static
3645 route should be installed as valid. */
3647 bgp_static_set (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3648 afi_t afi
, safi_t safi
, const char *rmap
, int backdoor
)
3652 struct bgp_static
*bgp_static
;
3653 struct bgp_node
*rn
;
3654 u_char need_update
= 0;
3656 /* Convert IP prefix string to struct prefix. */
3657 ret
= str2prefix (ip_str
, &p
);
3660 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3664 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3666 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3670 #endif /* HAVE_IPV6 */
3674 /* Set BGP static route configuration. */
3675 rn
= bgp_node_get (bgp
->route
[afi
][safi
], &p
);
3679 /* Configuration change. */
3680 bgp_static
= rn
->info
;
3682 /* Check previous routes are installed into BGP. */
3683 if (bgp_static
->valid
&& bgp_static
->backdoor
!= backdoor
)
3686 bgp_static
->backdoor
= backdoor
;
3690 if (bgp_static
->rmap
.name
)
3691 free (bgp_static
->rmap
.name
);
3692 bgp_static
->rmap
.name
= strdup (rmap
);
3693 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3697 if (bgp_static
->rmap
.name
)
3698 free (bgp_static
->rmap
.name
);
3699 bgp_static
->rmap
.name
= NULL
;
3700 bgp_static
->rmap
.map
= NULL
;
3701 bgp_static
->valid
= 0;
3703 bgp_unlock_node (rn
);
3707 /* New configuration. */
3708 bgp_static
= bgp_static_new ();
3709 bgp_static
->backdoor
= backdoor
;
3710 bgp_static
->valid
= 0;
3711 bgp_static
->igpmetric
= 0;
3712 bgp_static
->igpnexthop
.s_addr
= 0;
3716 if (bgp_static
->rmap
.name
)
3717 free (bgp_static
->rmap
.name
);
3718 bgp_static
->rmap
.name
= strdup (rmap
);
3719 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3721 rn
->info
= bgp_static
;
3724 /* If BGP scan is not enabled, we should install this route here. */
3725 if (! bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3727 bgp_static
->valid
= 1;
3730 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3732 if (! bgp_static
->backdoor
)
3733 bgp_static_update (bgp
, &p
, bgp_static
, afi
, safi
);
3739 /* Configure static BGP network. */
3741 bgp_static_unset (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3742 afi_t afi
, safi_t safi
)
3746 struct bgp_static
*bgp_static
;
3747 struct bgp_node
*rn
;
3749 /* Convert IP prefix string to struct prefix. */
3750 ret
= str2prefix (ip_str
, &p
);
3753 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3757 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3759 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3763 #endif /* HAVE_IPV6 */
3767 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], &p
);
3770 vty_out (vty
, "%% Can't find specified static route configuration.%s",
3775 bgp_static
= rn
->info
;
3777 /* Update BGP RIB. */
3778 if (! bgp_static
->backdoor
)
3779 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3781 /* Clear configuration. */
3782 bgp_static_free (bgp_static
);
3784 bgp_unlock_node (rn
);
3785 bgp_unlock_node (rn
);
3790 /* Called from bgp_delete(). Delete all static routes from the BGP
3793 bgp_static_delete (struct bgp
*bgp
)
3797 struct bgp_node
*rn
;
3798 struct bgp_node
*rm
;
3799 struct bgp_table
*table
;
3800 struct bgp_static
*bgp_static
;
3802 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3803 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3804 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3805 if (rn
->info
!= NULL
)
3807 if (safi
== SAFI_MPLS_VPN
)
3811 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
3813 bgp_static
= rn
->info
;
3814 bgp_static_withdraw_vpnv4 (bgp
, &rm
->p
,
3815 AFI_IP
, SAFI_MPLS_VPN
,
3816 (struct prefix_rd
*)&rn
->p
,
3818 bgp_static_free (bgp_static
);
3820 bgp_unlock_node (rn
);
3825 bgp_static
= rn
->info
;
3826 bgp_static_withdraw (bgp
, &rn
->p
, afi
, safi
);
3827 bgp_static_free (bgp_static
);
3829 bgp_unlock_node (rn
);
3835 bgp_static_set_vpnv4 (struct vty
*vty
, const char *ip_str
, const char *rd_str
,
3836 const char *tag_str
)
3840 struct prefix_rd prd
;
3842 struct bgp_node
*prn
;
3843 struct bgp_node
*rn
;
3844 struct bgp_table
*table
;
3845 struct bgp_static
*bgp_static
;
3850 ret
= str2prefix (ip_str
, &p
);
3853 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3858 ret
= str2prefix_rd (rd_str
, &prd
);
3861 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3865 ret
= str2tag (tag_str
, tag
);
3868 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3872 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3873 (struct prefix
*)&prd
);
3874 if (prn
->info
== NULL
)
3875 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3877 bgp_unlock_node (prn
);
3880 rn
= bgp_node_get (table
, &p
);
3884 vty_out (vty
, "%% Same network configuration exists%s", VTY_NEWLINE
);
3885 bgp_unlock_node (rn
);
3889 /* New configuration. */
3890 bgp_static
= bgp_static_new ();
3891 bgp_static
->valid
= 1;
3892 memcpy (bgp_static
->tag
, tag
, 3);
3893 rn
->info
= bgp_static
;
3895 bgp_static_update_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3901 /* Configure static BGP network. */
3903 bgp_static_unset_vpnv4 (struct vty
*vty
, const char *ip_str
,
3904 const char *rd_str
, const char *tag_str
)
3909 struct prefix_rd prd
;
3910 struct bgp_node
*prn
;
3911 struct bgp_node
*rn
;
3912 struct bgp_table
*table
;
3913 struct bgp_static
*bgp_static
;
3918 /* Convert IP prefix string to struct prefix. */
3919 ret
= str2prefix (ip_str
, &p
);
3922 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3927 ret
= str2prefix_rd (rd_str
, &prd
);
3930 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3934 ret
= str2tag (tag_str
, tag
);
3937 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3941 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3942 (struct prefix
*)&prd
);
3943 if (prn
->info
== NULL
)
3944 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3946 bgp_unlock_node (prn
);
3949 rn
= bgp_node_lookup (table
, &p
);
3953 bgp_static_withdraw_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3955 bgp_static
= rn
->info
;
3956 bgp_static_free (bgp_static
);
3958 bgp_unlock_node (rn
);
3959 bgp_unlock_node (rn
);
3962 vty_out (vty
, "%% Can't find the route%s", VTY_NEWLINE
);
3969 "network A.B.C.D/M",
3970 "Specify a network to announce via BGP\n"
3971 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
3973 return bgp_static_set (vty
, vty
->index
, argv
[0],
3974 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
3977 DEFUN (bgp_network_route_map
,
3978 bgp_network_route_map_cmd
,
3979 "network A.B.C.D/M route-map WORD",
3980 "Specify a network to announce via BGP\n"
3981 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3982 "Route-map to modify the attributes\n"
3983 "Name of the route map\n")
3985 return bgp_static_set (vty
, vty
->index
, argv
[0],
3986 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
3989 DEFUN (bgp_network_backdoor
,
3990 bgp_network_backdoor_cmd
,
3991 "network A.B.C.D/M backdoor",
3992 "Specify a network to announce via BGP\n"
3993 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3994 "Specify a BGP backdoor route\n")
3996 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP
, SAFI_UNICAST
,
4000 DEFUN (bgp_network_mask
,
4001 bgp_network_mask_cmd
,
4002 "network A.B.C.D mask A.B.C.D",
4003 "Specify a network to announce via BGP\n"
4009 char prefix_str
[BUFSIZ
];
4011 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4014 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4018 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4019 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4022 DEFUN (bgp_network_mask_route_map
,
4023 bgp_network_mask_route_map_cmd
,
4024 "network A.B.C.D mask A.B.C.D route-map WORD",
4025 "Specify a network to announce via BGP\n"
4029 "Route-map to modify the attributes\n"
4030 "Name of the route map\n")
4033 char prefix_str
[BUFSIZ
];
4035 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4038 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4042 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4043 AFI_IP
, bgp_node_safi (vty
), argv
[2], 0);
4046 DEFUN (bgp_network_mask_backdoor
,
4047 bgp_network_mask_backdoor_cmd
,
4048 "network A.B.C.D mask A.B.C.D backdoor",
4049 "Specify a network to announce via BGP\n"
4053 "Specify a BGP backdoor route\n")
4056 char prefix_str
[BUFSIZ
];
4058 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4061 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4065 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4069 DEFUN (bgp_network_mask_natural
,
4070 bgp_network_mask_natural_cmd
,
4072 "Specify a network to announce via BGP\n"
4076 char prefix_str
[BUFSIZ
];
4078 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4081 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4085 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4086 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4089 DEFUN (bgp_network_mask_natural_route_map
,
4090 bgp_network_mask_natural_route_map_cmd
,
4091 "network A.B.C.D route-map WORD",
4092 "Specify a network to announce via BGP\n"
4094 "Route-map to modify the attributes\n"
4095 "Name of the route map\n")
4098 char prefix_str
[BUFSIZ
];
4100 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4103 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4107 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4108 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4111 DEFUN (bgp_network_mask_natural_backdoor
,
4112 bgp_network_mask_natural_backdoor_cmd
,
4113 "network A.B.C.D backdoor",
4114 "Specify a network to announce via BGP\n"
4116 "Specify a BGP backdoor route\n")
4119 char prefix_str
[BUFSIZ
];
4121 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4124 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4128 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4132 DEFUN (no_bgp_network
,
4134 "no network A.B.C.D/M",
4136 "Specify a network to announce via BGP\n"
4137 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4139 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP
,
4140 bgp_node_safi (vty
));
4143 ALIAS (no_bgp_network
,
4144 no_bgp_network_route_map_cmd
,
4145 "no network A.B.C.D/M route-map WORD",
4147 "Specify a network to announce via BGP\n"
4148 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4149 "Route-map to modify the attributes\n"
4150 "Name of the route map\n")
4152 ALIAS (no_bgp_network
,
4153 no_bgp_network_backdoor_cmd
,
4154 "no network A.B.C.D/M backdoor",
4156 "Specify a network to announce via BGP\n"
4157 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4158 "Specify a BGP backdoor route\n")
4160 DEFUN (no_bgp_network_mask
,
4161 no_bgp_network_mask_cmd
,
4162 "no network A.B.C.D mask A.B.C.D",
4164 "Specify a network to announce via BGP\n"
4170 char prefix_str
[BUFSIZ
];
4172 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4175 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4179 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4180 bgp_node_safi (vty
));
4183 ALIAS (no_bgp_network_mask
,
4184 no_bgp_network_mask_route_map_cmd
,
4185 "no network A.B.C.D mask A.B.C.D route-map WORD",
4187 "Specify a network to announce via BGP\n"
4191 "Route-map to modify the attributes\n"
4192 "Name of the route map\n")
4194 ALIAS (no_bgp_network_mask
,
4195 no_bgp_network_mask_backdoor_cmd
,
4196 "no network A.B.C.D mask A.B.C.D backdoor",
4198 "Specify a network to announce via BGP\n"
4202 "Specify a BGP backdoor route\n")
4204 DEFUN (no_bgp_network_mask_natural
,
4205 no_bgp_network_mask_natural_cmd
,
4206 "no network A.B.C.D",
4208 "Specify a network to announce via BGP\n"
4212 char prefix_str
[BUFSIZ
];
4214 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4217 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4221 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4222 bgp_node_safi (vty
));
4225 ALIAS (no_bgp_network_mask_natural
,
4226 no_bgp_network_mask_natural_route_map_cmd
,
4227 "no network A.B.C.D route-map WORD",
4229 "Specify a network to announce via BGP\n"
4231 "Route-map to modify the attributes\n"
4232 "Name of the route map\n")
4234 ALIAS (no_bgp_network_mask_natural
,
4235 no_bgp_network_mask_natural_backdoor_cmd
,
4236 "no network A.B.C.D backdoor",
4238 "Specify a network to announce via BGP\n"
4240 "Specify a BGP backdoor route\n")
4243 DEFUN (ipv6_bgp_network
,
4244 ipv6_bgp_network_cmd
,
4245 "network X:X::X:X/M",
4246 "Specify a network to announce via BGP\n"
4247 "IPv6 prefix <network>/<length>\n")
4249 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
4253 DEFUN (ipv6_bgp_network_route_map
,
4254 ipv6_bgp_network_route_map_cmd
,
4255 "network X:X::X:X/M route-map WORD",
4256 "Specify a network to announce via BGP\n"
4257 "IPv6 prefix <network>/<length>\n"
4258 "Route-map to modify the attributes\n"
4259 "Name of the route map\n")
4261 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
,
4262 bgp_node_safi (vty
), argv
[1], 0);
4265 DEFUN (no_ipv6_bgp_network
,
4266 no_ipv6_bgp_network_cmd
,
4267 "no network X:X::X:X/M",
4269 "Specify a network to announce via BGP\n"
4270 "IPv6 prefix <network>/<length>\n")
4272 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
4275 ALIAS (no_ipv6_bgp_network
,
4276 no_ipv6_bgp_network_route_map_cmd
,
4277 "no network X:X::X:X/M route-map WORD",
4279 "Specify a network to announce via BGP\n"
4280 "IPv6 prefix <network>/<length>\n"
4281 "Route-map to modify the attributes\n"
4282 "Name of the route map\n")
4284 ALIAS (ipv6_bgp_network
,
4285 old_ipv6_bgp_network_cmd
,
4286 "ipv6 bgp network X:X::X:X/M",
4289 "Specify a network to announce via BGP\n"
4290 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4292 ALIAS (no_ipv6_bgp_network
,
4293 old_no_ipv6_bgp_network_cmd
,
4294 "no ipv6 bgp network X:X::X:X/M",
4298 "Specify a network to announce via BGP\n"
4299 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4300 #endif /* HAVE_IPV6 */
4302 /* stubs for removed AS-Pathlimit commands, kept for config compatibility */
4303 ALIAS_DEPRECATED (bgp_network
,
4304 bgp_network_ttl_cmd
,
4305 "network A.B.C.D/M pathlimit <0-255>",
4306 "Specify a network to announce via BGP\n"
4307 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4308 "AS-Path hopcount limit attribute\n"
4309 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4310 ALIAS_DEPRECATED (bgp_network_backdoor
,
4311 bgp_network_backdoor_ttl_cmd
,
4312 "network A.B.C.D/M backdoor pathlimit <0-255>",
4313 "Specify a network to announce via BGP\n"
4314 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4315 "Specify a BGP backdoor route\n"
4316 "AS-Path hopcount limit attribute\n"
4317 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4318 ALIAS_DEPRECATED (bgp_network_mask
,
4319 bgp_network_mask_ttl_cmd
,
4320 "network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4321 "Specify a network to announce via BGP\n"
4325 "AS-Path hopcount limit attribute\n"
4326 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4327 ALIAS_DEPRECATED (bgp_network_mask_backdoor
,
4328 bgp_network_mask_backdoor_ttl_cmd
,
4329 "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4330 "Specify a network to announce via BGP\n"
4334 "Specify a BGP backdoor route\n"
4335 "AS-Path hopcount limit attribute\n"
4336 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4337 ALIAS_DEPRECATED (bgp_network_mask_natural
,
4338 bgp_network_mask_natural_ttl_cmd
,
4339 "network A.B.C.D pathlimit <0-255>",
4340 "Specify a network to announce via BGP\n"
4342 "AS-Path hopcount limit attribute\n"
4343 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4344 ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor
,
4345 bgp_network_mask_natural_backdoor_ttl_cmd
,
4346 "network A.B.C.D backdoor pathlimit (1-255>",
4347 "Specify a network to announce via BGP\n"
4349 "Specify a BGP backdoor route\n"
4350 "AS-Path hopcount limit attribute\n"
4351 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4352 ALIAS_DEPRECATED (no_bgp_network
,
4353 no_bgp_network_ttl_cmd
,
4354 "no network A.B.C.D/M pathlimit <0-255>",
4356 "Specify a network to announce via BGP\n"
4357 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4358 "AS-Path hopcount limit attribute\n"
4359 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4360 ALIAS_DEPRECATED (no_bgp_network
,
4361 no_bgp_network_backdoor_ttl_cmd
,
4362 "no network A.B.C.D/M backdoor pathlimit <0-255>",
4364 "Specify a network to announce via BGP\n"
4365 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4366 "Specify a BGP backdoor route\n"
4367 "AS-Path hopcount limit attribute\n"
4368 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4369 ALIAS_DEPRECATED (no_bgp_network
,
4370 no_bgp_network_mask_ttl_cmd
,
4371 "no network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4373 "Specify a network to announce via BGP\n"
4377 "AS-Path hopcount limit attribute\n"
4378 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4379 ALIAS_DEPRECATED (no_bgp_network_mask
,
4380 no_bgp_network_mask_backdoor_ttl_cmd
,
4381 "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4383 "Specify a network to announce via BGP\n"
4387 "Specify a BGP backdoor route\n"
4388 "AS-Path hopcount limit attribute\n"
4389 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4390 ALIAS_DEPRECATED (no_bgp_network_mask_natural
,
4391 no_bgp_network_mask_natural_ttl_cmd
,
4392 "no network A.B.C.D pathlimit <0-255>",
4394 "Specify a network to announce via BGP\n"
4396 "AS-Path hopcount limit attribute\n"
4397 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4398 ALIAS_DEPRECATED (no_bgp_network_mask_natural
,
4399 no_bgp_network_mask_natural_backdoor_ttl_cmd
,
4400 "no network A.B.C.D backdoor pathlimit <0-255>",
4402 "Specify a network to announce via BGP\n"
4404 "Specify a BGP backdoor route\n"
4405 "AS-Path hopcount limit attribute\n"
4406 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4408 ALIAS_DEPRECATED (ipv6_bgp_network
,
4409 ipv6_bgp_network_ttl_cmd
,
4410 "network X:X::X:X/M pathlimit <0-255>",
4411 "Specify a network to announce via BGP\n"
4412 "IPv6 prefix <network>/<length>\n"
4413 "AS-Path hopcount limit attribute\n"
4414 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4415 ALIAS_DEPRECATED (no_ipv6_bgp_network
,
4416 no_ipv6_bgp_network_ttl_cmd
,
4417 "no network X:X::X:X/M pathlimit <0-255>",
4419 "Specify a network to announce via BGP\n"
4420 "IPv6 prefix <network>/<length>\n"
4421 "AS-Path hopcount limit attribute\n"
4422 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4423 #endif /* HAVE_IPV6 */
4425 /* Aggreagete address:
4427 advertise-map Set condition to advertise attribute
4428 as-set Generate AS set path information
4429 attribute-map Set attributes of aggregate
4430 route-map Set parameters of aggregate
4431 summary-only Filter more specific routes from updates
4432 suppress-map Conditionally filter more specific routes from updates
4435 struct bgp_aggregate
4437 /* Summary-only flag. */
4438 u_char summary_only
;
4440 /* AS set generation. */
4443 /* Route-map for aggregated route. */
4444 struct route_map
*map
;
4446 /* Suppress-count. */
4447 unsigned long count
;
4449 /* SAFI configuration. */
4453 static struct bgp_aggregate
*
4454 bgp_aggregate_new (void)
4456 return XCALLOC (MTYPE_BGP_AGGREGATE
, sizeof (struct bgp_aggregate
));
4460 bgp_aggregate_free (struct bgp_aggregate
*aggregate
)
4462 XFREE (MTYPE_BGP_AGGREGATE
, aggregate
);
4466 bgp_aggregate_route (struct bgp
*bgp
, struct prefix
*p
, struct bgp_info
*rinew
,
4467 afi_t afi
, safi_t safi
, struct bgp_info
*del
,
4468 struct bgp_aggregate
*aggregate
)
4470 struct bgp_table
*table
;
4471 struct bgp_node
*top
;
4472 struct bgp_node
*rn
;
4474 struct aspath
*aspath
= NULL
;
4475 struct aspath
*asmerge
= NULL
;
4476 struct community
*community
= NULL
;
4477 struct community
*commerge
= NULL
;
4478 struct in_addr nexthop
;
4480 struct bgp_info
*ri
;
4481 struct bgp_info
*new;
4483 unsigned long match
= 0;
4485 /* Record adding route's nexthop and med. */
4488 nexthop
= rinew
->attr
->nexthop
;
4489 med
= rinew
->attr
->med
;
4492 /* ORIGIN attribute: If at least one route among routes that are
4493 aggregated has ORIGIN with the value INCOMPLETE, then the
4494 aggregated route must have the ORIGIN attribute with the value
4495 INCOMPLETE. Otherwise, if at least one route among routes that
4496 are aggregated has ORIGIN with the value EGP, then the aggregated
4497 route must have the origin attribute with the value EGP. In all
4498 other case the value of the ORIGIN attribute of the aggregated
4499 route is INTERNAL. */
4500 origin
= BGP_ORIGIN_IGP
;
4502 table
= bgp
->rib
[afi
][safi
];
4504 top
= bgp_node_get (table
, p
);
4505 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4506 if (rn
->p
.prefixlen
> p
->prefixlen
)
4510 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4512 if (BGP_INFO_HOLDDOWN (ri
))
4515 if (del
&& ri
== del
)
4518 if (! rinew
&& first
)
4520 nexthop
= ri
->attr
->nexthop
;
4521 med
= ri
->attr
->med
;
4525 #ifdef AGGREGATE_NEXTHOP_CHECK
4526 if (! IPV4_ADDR_SAME (&ri
->attr
->nexthop
, &nexthop
)
4527 || ri
->attr
->med
!= med
)
4530 aspath_free (aspath
);
4532 community_free (community
);
4533 bgp_unlock_node (rn
);
4534 bgp_unlock_node (top
);
4537 #endif /* AGGREGATE_NEXTHOP_CHECK */
4539 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4541 if (aggregate
->summary_only
)
4543 (bgp_info_extra_get (ri
))->suppress
++;
4544 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4550 if (aggregate
->as_set
)
4552 if (origin
< ri
->attr
->origin
)
4553 origin
= ri
->attr
->origin
;
4557 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4558 aspath_free (aspath
);
4562 aspath
= aspath_dup (ri
->attr
->aspath
);
4564 if (ri
->attr
->community
)
4568 commerge
= community_merge (community
,
4569 ri
->attr
->community
);
4570 community
= community_uniq_sort (commerge
);
4571 community_free (commerge
);
4574 community
= community_dup (ri
->attr
->community
);
4580 bgp_process (bgp
, rn
, afi
, safi
);
4582 bgp_unlock_node (top
);
4588 if (aggregate
->summary_only
)
4589 (bgp_info_extra_get (rinew
))->suppress
++;
4591 if (aggregate
->as_set
)
4593 if (origin
< rinew
->attr
->origin
)
4594 origin
= rinew
->attr
->origin
;
4598 asmerge
= aspath_aggregate (aspath
, rinew
->attr
->aspath
);
4599 aspath_free (aspath
);
4603 aspath
= aspath_dup (rinew
->attr
->aspath
);
4605 if (rinew
->attr
->community
)
4609 commerge
= community_merge (community
,
4610 rinew
->attr
->community
);
4611 community
= community_uniq_sort (commerge
);
4612 community_free (commerge
);
4615 community
= community_dup (rinew
->attr
->community
);
4620 if (aggregate
->count
> 0)
4622 rn
= bgp_node_get (table
, p
);
4623 new = bgp_info_new ();
4624 new->type
= ZEBRA_ROUTE_BGP
;
4625 new->sub_type
= BGP_ROUTE_AGGREGATE
;
4626 new->peer
= bgp
->peer_self
;
4627 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4628 new->attr
= bgp_attr_aggregate_intern (bgp
, origin
, aspath
, community
, aggregate
->as_set
);
4629 new->uptime
= bgp_clock ();
4631 bgp_info_add (rn
, new);
4632 bgp_unlock_node (rn
);
4633 bgp_process (bgp
, rn
, afi
, safi
);
4638 aspath_free (aspath
);
4640 community_free (community
);
4644 void bgp_aggregate_delete (struct bgp
*, struct prefix
*, afi_t
, safi_t
,
4645 struct bgp_aggregate
*);
4648 bgp_aggregate_increment (struct bgp
*bgp
, struct prefix
*p
,
4649 struct bgp_info
*ri
, afi_t afi
, safi_t safi
)
4651 struct bgp_node
*child
;
4652 struct bgp_node
*rn
;
4653 struct bgp_aggregate
*aggregate
;
4655 /* MPLS-VPN aggregation is not yet supported. */
4656 if (safi
== SAFI_MPLS_VPN
)
4659 if (p
->prefixlen
== 0)
4662 if (BGP_INFO_HOLDDOWN (ri
))
4665 child
= bgp_node_get (bgp
->aggregate
[afi
][safi
], p
);
4667 /* Aggregate address configuration check. */
4668 for (rn
= child
; rn
; rn
= rn
->parent
)
4669 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4671 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4672 bgp_aggregate_route (bgp
, &rn
->p
, ri
, afi
, safi
, NULL
, aggregate
);
4674 bgp_unlock_node (child
);
4678 bgp_aggregate_decrement (struct bgp
*bgp
, struct prefix
*p
,
4679 struct bgp_info
*del
, afi_t afi
, safi_t safi
)
4681 struct bgp_node
*child
;
4682 struct bgp_node
*rn
;
4683 struct bgp_aggregate
*aggregate
;
4685 /* MPLS-VPN aggregation is not yet supported. */
4686 if (safi
== SAFI_MPLS_VPN
)
4689 if (p
->prefixlen
== 0)
4692 child
= bgp_node_get (bgp
->aggregate
[afi
][safi
], p
);
4694 /* Aggregate address configuration check. */
4695 for (rn
= child
; rn
; rn
= rn
->parent
)
4696 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4698 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4699 bgp_aggregate_route (bgp
, &rn
->p
, NULL
, afi
, safi
, del
, aggregate
);
4701 bgp_unlock_node (child
);
4705 bgp_aggregate_add (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
, safi_t safi
,
4706 struct bgp_aggregate
*aggregate
)
4708 struct bgp_table
*table
;
4709 struct bgp_node
*top
;
4710 struct bgp_node
*rn
;
4711 struct bgp_info
*new;
4712 struct bgp_info
*ri
;
4713 unsigned long match
;
4714 u_char origin
= BGP_ORIGIN_IGP
;
4715 struct aspath
*aspath
= NULL
;
4716 struct aspath
*asmerge
= NULL
;
4717 struct community
*community
= NULL
;
4718 struct community
*commerge
= NULL
;
4720 table
= bgp
->rib
[afi
][safi
];
4723 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4725 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4728 /* If routes exists below this node, generate aggregate routes. */
4729 top
= bgp_node_get (table
, p
);
4730 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4731 if (rn
->p
.prefixlen
> p
->prefixlen
)
4735 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4737 if (BGP_INFO_HOLDDOWN (ri
))
4740 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4742 /* summary-only aggregate route suppress aggregated
4743 route announcement. */
4744 if (aggregate
->summary_only
)
4746 (bgp_info_extra_get (ri
))->suppress
++;
4747 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4750 /* as-set aggregate route generate origin, as path,
4751 community aggregation. */
4752 if (aggregate
->as_set
)
4754 if (origin
< ri
->attr
->origin
)
4755 origin
= ri
->attr
->origin
;
4759 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4760 aspath_free (aspath
);
4764 aspath
= aspath_dup (ri
->attr
->aspath
);
4766 if (ri
->attr
->community
)
4770 commerge
= community_merge (community
,
4771 ri
->attr
->community
);
4772 community
= community_uniq_sort (commerge
);
4773 community_free (commerge
);
4776 community
= community_dup (ri
->attr
->community
);
4783 /* If this node is suppressed, process the change. */
4785 bgp_process (bgp
, rn
, afi
, safi
);
4787 bgp_unlock_node (top
);
4789 /* Add aggregate route to BGP table. */
4790 if (aggregate
->count
)
4792 rn
= bgp_node_get (table
, p
);
4794 new = bgp_info_new ();
4795 new->type
= ZEBRA_ROUTE_BGP
;
4796 new->sub_type
= BGP_ROUTE_AGGREGATE
;
4797 new->peer
= bgp
->peer_self
;
4798 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4799 new->attr
= bgp_attr_aggregate_intern (bgp
, origin
, aspath
, community
, aggregate
->as_set
);
4800 new->uptime
= bgp_clock ();
4802 bgp_info_add (rn
, new);
4803 bgp_unlock_node (rn
);
4805 /* Process change. */
4806 bgp_process (bgp
, rn
, afi
, safi
);
4811 bgp_aggregate_delete (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
4812 safi_t safi
, struct bgp_aggregate
*aggregate
)
4814 struct bgp_table
*table
;
4815 struct bgp_node
*top
;
4816 struct bgp_node
*rn
;
4817 struct bgp_info
*ri
;
4818 unsigned long match
;
4820 table
= bgp
->rib
[afi
][safi
];
4822 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4824 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4827 /* If routes exists below this node, generate aggregate routes. */
4828 top
= bgp_node_get (table
, p
);
4829 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4830 if (rn
->p
.prefixlen
> p
->prefixlen
)
4834 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4836 if (BGP_INFO_HOLDDOWN (ri
))
4839 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4841 if (aggregate
->summary_only
&& ri
->extra
)
4843 ri
->extra
->suppress
--;
4845 if (ri
->extra
->suppress
== 0)
4847 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4855 /* If this node was suppressed, process the change. */
4857 bgp_process (bgp
, rn
, afi
, safi
);
4859 bgp_unlock_node (top
);
4861 /* Delete aggregate route from BGP table. */
4862 rn
= bgp_node_get (table
, p
);
4864 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4865 if (ri
->peer
== bgp
->peer_self
4866 && ri
->type
== ZEBRA_ROUTE_BGP
4867 && ri
->sub_type
== BGP_ROUTE_AGGREGATE
)
4870 /* Withdraw static BGP route from routing table. */
4873 bgp_info_delete (rn
, ri
);
4874 bgp_process (bgp
, rn
, afi
, safi
);
4877 /* Unlock bgp_node_lookup. */
4878 bgp_unlock_node (rn
);
4881 /* Aggregate route attribute. */
4882 #define AGGREGATE_SUMMARY_ONLY 1
4883 #define AGGREGATE_AS_SET 1
4886 bgp_aggregate_unset (struct vty
*vty
, const char *prefix_str
,
4887 afi_t afi
, safi_t safi
)
4891 struct bgp_node
*rn
;
4893 struct bgp_aggregate
*aggregate
;
4895 /* Convert string to prefix structure. */
4896 ret
= str2prefix (prefix_str
, &p
);
4899 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
4904 /* Get BGP structure. */
4907 /* Old configuration check. */
4908 rn
= bgp_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
4911 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
4916 aggregate
= rn
->info
;
4917 if (aggregate
->safi
& SAFI_UNICAST
)
4918 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
4919 if (aggregate
->safi
& SAFI_MULTICAST
)
4920 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
4922 /* Unlock aggregate address configuration. */
4924 bgp_aggregate_free (aggregate
);
4925 bgp_unlock_node (rn
);
4926 bgp_unlock_node (rn
);
4932 bgp_aggregate_set (struct vty
*vty
, const char *prefix_str
,
4933 afi_t afi
, safi_t safi
,
4934 u_char summary_only
, u_char as_set
)
4938 struct bgp_node
*rn
;
4940 struct bgp_aggregate
*aggregate
;
4942 /* Convert string to prefix structure. */
4943 ret
= str2prefix (prefix_str
, &p
);
4946 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
4951 /* Get BGP structure. */
4954 /* Old configuration check. */
4955 rn
= bgp_node_get (bgp
->aggregate
[afi
][safi
], &p
);
4959 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
4960 /* try to remove the old entry */
4961 ret
= bgp_aggregate_unset (vty
, prefix_str
, afi
, safi
);
4964 vty_out (vty
, "Error deleting aggregate.%s", VTY_NEWLINE
);
4965 bgp_unlock_node (rn
);
4970 /* Make aggregate address structure. */
4971 aggregate
= bgp_aggregate_new ();
4972 aggregate
->summary_only
= summary_only
;
4973 aggregate
->as_set
= as_set
;
4974 aggregate
->safi
= safi
;
4975 rn
->info
= aggregate
;
4977 /* Aggregate address insert into BGP routing table. */
4978 if (safi
& SAFI_UNICAST
)
4979 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
4980 if (safi
& SAFI_MULTICAST
)
4981 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
4986 DEFUN (aggregate_address
,
4987 aggregate_address_cmd
,
4988 "aggregate-address A.B.C.D/M",
4989 "Configure BGP aggregate entries\n"
4990 "Aggregate prefix\n")
4992 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
), 0, 0);
4995 DEFUN (aggregate_address_mask
,
4996 aggregate_address_mask_cmd
,
4997 "aggregate-address A.B.C.D A.B.C.D",
4998 "Configure BGP aggregate entries\n"
4999 "Aggregate address\n"
5003 char prefix_str
[BUFSIZ
];
5005 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5009 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5013 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5017 DEFUN (aggregate_address_summary_only
,
5018 aggregate_address_summary_only_cmd
,
5019 "aggregate-address A.B.C.D/M summary-only",
5020 "Configure BGP aggregate entries\n"
5021 "Aggregate prefix\n"
5022 "Filter more specific routes from updates\n")
5024 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5025 AGGREGATE_SUMMARY_ONLY
, 0);
5028 DEFUN (aggregate_address_mask_summary_only
,
5029 aggregate_address_mask_summary_only_cmd
,
5030 "aggregate-address A.B.C.D A.B.C.D summary-only",
5031 "Configure BGP aggregate entries\n"
5032 "Aggregate address\n"
5034 "Filter more specific routes from updates\n")
5037 char prefix_str
[BUFSIZ
];
5039 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5043 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5047 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5048 AGGREGATE_SUMMARY_ONLY
, 0);
5051 DEFUN (aggregate_address_as_set
,
5052 aggregate_address_as_set_cmd
,
5053 "aggregate-address A.B.C.D/M as-set",
5054 "Configure BGP aggregate entries\n"
5055 "Aggregate prefix\n"
5056 "Generate AS set path information\n")
5058 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5059 0, AGGREGATE_AS_SET
);
5062 DEFUN (aggregate_address_mask_as_set
,
5063 aggregate_address_mask_as_set_cmd
,
5064 "aggregate-address A.B.C.D A.B.C.D as-set",
5065 "Configure BGP aggregate entries\n"
5066 "Aggregate address\n"
5068 "Generate AS set path information\n")
5071 char prefix_str
[BUFSIZ
];
5073 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5077 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5081 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5082 0, AGGREGATE_AS_SET
);
5086 DEFUN (aggregate_address_as_set_summary
,
5087 aggregate_address_as_set_summary_cmd
,
5088 "aggregate-address A.B.C.D/M as-set summary-only",
5089 "Configure BGP aggregate entries\n"
5090 "Aggregate prefix\n"
5091 "Generate AS set path information\n"
5092 "Filter more specific routes from updates\n")
5094 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5095 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5098 ALIAS (aggregate_address_as_set_summary
,
5099 aggregate_address_summary_as_set_cmd
,
5100 "aggregate-address A.B.C.D/M summary-only as-set",
5101 "Configure BGP aggregate entries\n"
5102 "Aggregate prefix\n"
5103 "Filter more specific routes from updates\n"
5104 "Generate AS set path information\n")
5106 DEFUN (aggregate_address_mask_as_set_summary
,
5107 aggregate_address_mask_as_set_summary_cmd
,
5108 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5109 "Configure BGP aggregate entries\n"
5110 "Aggregate address\n"
5112 "Generate AS set path information\n"
5113 "Filter more specific routes from updates\n")
5116 char prefix_str
[BUFSIZ
];
5118 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5122 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5126 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5127 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5130 ALIAS (aggregate_address_mask_as_set_summary
,
5131 aggregate_address_mask_summary_as_set_cmd
,
5132 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5133 "Configure BGP aggregate entries\n"
5134 "Aggregate address\n"
5136 "Filter more specific routes from updates\n"
5137 "Generate AS set path information\n")
5139 DEFUN (no_aggregate_address
,
5140 no_aggregate_address_cmd
,
5141 "no aggregate-address A.B.C.D/M",
5143 "Configure BGP aggregate entries\n"
5144 "Aggregate prefix\n")
5146 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
));
5149 ALIAS (no_aggregate_address
,
5150 no_aggregate_address_summary_only_cmd
,
5151 "no aggregate-address A.B.C.D/M summary-only",
5153 "Configure BGP aggregate entries\n"
5154 "Aggregate prefix\n"
5155 "Filter more specific routes from updates\n")
5157 ALIAS (no_aggregate_address
,
5158 no_aggregate_address_as_set_cmd
,
5159 "no aggregate-address A.B.C.D/M as-set",
5161 "Configure BGP aggregate entries\n"
5162 "Aggregate prefix\n"
5163 "Generate AS set path information\n")
5165 ALIAS (no_aggregate_address
,
5166 no_aggregate_address_as_set_summary_cmd
,
5167 "no aggregate-address A.B.C.D/M as-set summary-only",
5169 "Configure BGP aggregate entries\n"
5170 "Aggregate prefix\n"
5171 "Generate AS set path information\n"
5172 "Filter more specific routes from updates\n")
5174 ALIAS (no_aggregate_address
,
5175 no_aggregate_address_summary_as_set_cmd
,
5176 "no aggregate-address A.B.C.D/M summary-only as-set",
5178 "Configure BGP aggregate entries\n"
5179 "Aggregate prefix\n"
5180 "Filter more specific routes from updates\n"
5181 "Generate AS set path information\n")
5183 DEFUN (no_aggregate_address_mask
,
5184 no_aggregate_address_mask_cmd
,
5185 "no aggregate-address A.B.C.D A.B.C.D",
5187 "Configure BGP aggregate entries\n"
5188 "Aggregate address\n"
5192 char prefix_str
[BUFSIZ
];
5194 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5198 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5202 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
5205 ALIAS (no_aggregate_address_mask
,
5206 no_aggregate_address_mask_summary_only_cmd
,
5207 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5209 "Configure BGP aggregate entries\n"
5210 "Aggregate address\n"
5212 "Filter more specific routes from updates\n")
5214 ALIAS (no_aggregate_address_mask
,
5215 no_aggregate_address_mask_as_set_cmd
,
5216 "no aggregate-address A.B.C.D A.B.C.D as-set",
5218 "Configure BGP aggregate entries\n"
5219 "Aggregate address\n"
5221 "Generate AS set path information\n")
5223 ALIAS (no_aggregate_address_mask
,
5224 no_aggregate_address_mask_as_set_summary_cmd
,
5225 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5227 "Configure BGP aggregate entries\n"
5228 "Aggregate address\n"
5230 "Generate AS set path information\n"
5231 "Filter more specific routes from updates\n")
5233 ALIAS (no_aggregate_address_mask
,
5234 no_aggregate_address_mask_summary_as_set_cmd
,
5235 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5237 "Configure BGP aggregate entries\n"
5238 "Aggregate address\n"
5240 "Filter more specific routes from updates\n"
5241 "Generate AS set path information\n")
5244 DEFUN (ipv6_aggregate_address
,
5245 ipv6_aggregate_address_cmd
,
5246 "aggregate-address X:X::X:X/M",
5247 "Configure BGP aggregate entries\n"
5248 "Aggregate prefix\n")
5250 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0, 0);
5253 DEFUN (ipv6_aggregate_address_summary_only
,
5254 ipv6_aggregate_address_summary_only_cmd
,
5255 "aggregate-address X:X::X:X/M summary-only",
5256 "Configure BGP aggregate entries\n"
5257 "Aggregate prefix\n"
5258 "Filter more specific routes from updates\n")
5260 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5261 AGGREGATE_SUMMARY_ONLY
, 0);
5264 DEFUN (no_ipv6_aggregate_address
,
5265 no_ipv6_aggregate_address_cmd
,
5266 "no aggregate-address X:X::X:X/M",
5268 "Configure BGP aggregate entries\n"
5269 "Aggregate prefix\n")
5271 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5274 DEFUN (no_ipv6_aggregate_address_summary_only
,
5275 no_ipv6_aggregate_address_summary_only_cmd
,
5276 "no aggregate-address X:X::X:X/M summary-only",
5278 "Configure BGP aggregate entries\n"
5279 "Aggregate prefix\n"
5280 "Filter more specific routes from updates\n")
5282 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5285 ALIAS (ipv6_aggregate_address
,
5286 old_ipv6_aggregate_address_cmd
,
5287 "ipv6 bgp aggregate-address X:X::X:X/M",
5290 "Configure BGP aggregate entries\n"
5291 "Aggregate prefix\n")
5293 ALIAS (ipv6_aggregate_address_summary_only
,
5294 old_ipv6_aggregate_address_summary_only_cmd
,
5295 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5298 "Configure BGP aggregate entries\n"
5299 "Aggregate prefix\n"
5300 "Filter more specific routes from updates\n")
5302 ALIAS (no_ipv6_aggregate_address
,
5303 old_no_ipv6_aggregate_address_cmd
,
5304 "no ipv6 bgp aggregate-address X:X::X:X/M",
5308 "Configure BGP aggregate entries\n"
5309 "Aggregate prefix\n")
5311 ALIAS (no_ipv6_aggregate_address_summary_only
,
5312 old_no_ipv6_aggregate_address_summary_only_cmd
,
5313 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5317 "Configure BGP aggregate entries\n"
5318 "Aggregate prefix\n"
5319 "Filter more specific routes from updates\n")
5320 #endif /* HAVE_IPV6 */
5322 /* Redistribute route treatment. */
5324 bgp_redistribute_add (struct prefix
*p
, struct in_addr
*nexthop
,
5325 u_int32_t metric
, u_char type
)
5328 struct listnode
*node
, *nnode
;
5329 struct bgp_info
*new;
5330 struct bgp_info
*bi
;
5331 struct bgp_info info
;
5332 struct bgp_node
*bn
;
5333 struct attr attr
= { 0 };
5334 struct attr attr_new
= { 0 };
5335 struct attr
*new_attr
;
5339 /* Make default attribute. */
5340 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
5342 attr
.nexthop
= *nexthop
;
5345 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
5347 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
5349 afi
= family2afi (p
->family
);
5351 if (bgp
->redist
[afi
][type
])
5353 /* Copy attribute for modification. */
5354 bgp_attr_dup (&attr_new
, &attr
);
5356 if (bgp
->redist_metric_flag
[afi
][type
])
5357 attr_new
.med
= bgp
->redist_metric
[afi
][type
];
5359 /* Apply route-map. */
5360 if (bgp
->rmap
[afi
][type
].map
)
5362 info
.peer
= bgp
->peer_self
;
5363 info
.attr
= &attr_new
;
5365 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
);
5367 ret
= route_map_apply (bgp
->rmap
[afi
][type
].map
, p
, RMAP_BGP
,
5370 bgp
->peer_self
->rmap_type
= 0;
5372 if (ret
== RMAP_DENYMATCH
)
5374 /* Free uninterned attribute. */
5375 bgp_attr_flush (&attr_new
);
5376 bgp_attr_extra_free (&attr_new
);
5378 /* Unintern original. */
5379 aspath_unintern (attr
.aspath
);
5380 bgp_attr_extra_free (&attr
);
5381 bgp_redistribute_delete (p
, type
);
5386 bn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
],
5387 afi
, SAFI_UNICAST
, p
, NULL
);
5389 new_attr
= bgp_attr_intern (&attr_new
);
5390 bgp_attr_extra_free (&attr_new
);
5392 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
5393 if (bi
->peer
== bgp
->peer_self
5394 && bi
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
5399 if (attrhash_cmp (bi
->attr
, new_attr
) &&
5400 !CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5402 bgp_attr_unintern (new_attr
);
5403 aspath_unintern (attr
.aspath
);
5404 bgp_attr_extra_free (&attr
);
5405 bgp_unlock_node (bn
);
5410 /* The attribute is changed. */
5411 bgp_info_set_flag (bn
, bi
, BGP_INFO_ATTR_CHANGED
);
5413 /* Rewrite BGP route information. */
5414 if (CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5415 bgp_info_restore(bn
, bi
);
5417 bgp_aggregate_decrement (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5418 bgp_attr_unintern (bi
->attr
);
5419 bi
->attr
= new_attr
;
5420 bi
->uptime
= bgp_clock ();
5422 /* Process change. */
5423 bgp_aggregate_increment (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5424 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5425 bgp_unlock_node (bn
);
5426 aspath_unintern (attr
.aspath
);
5427 bgp_attr_extra_free (&attr
);
5432 new = bgp_info_new ();
5434 new->sub_type
= BGP_ROUTE_REDISTRIBUTE
;
5435 new->peer
= bgp
->peer_self
;
5436 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5437 new->attr
= new_attr
;
5438 new->uptime
= bgp_clock ();
5440 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
5441 bgp_info_add (bn
, new);
5442 bgp_unlock_node (bn
);
5443 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5447 /* Unintern original. */
5448 aspath_unintern (attr
.aspath
);
5449 bgp_attr_extra_free (&attr
);
5453 bgp_redistribute_delete (struct prefix
*p
, u_char type
)
5456 struct listnode
*node
, *nnode
;
5458 struct bgp_node
*rn
;
5459 struct bgp_info
*ri
;
5461 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
5463 afi
= family2afi (p
->family
);
5465 if (bgp
->redist
[afi
][type
])
5467 rn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
5469 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5470 if (ri
->peer
== bgp
->peer_self
5471 && ri
->type
== type
)
5476 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
5477 bgp_info_delete (rn
, ri
);
5478 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5480 bgp_unlock_node (rn
);
5485 /* Withdraw specified route type's route. */
5487 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
)
5489 struct bgp_node
*rn
;
5490 struct bgp_info
*ri
;
5491 struct bgp_table
*table
;
5493 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
5495 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
5497 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5498 if (ri
->peer
== bgp
->peer_self
5499 && ri
->type
== type
)
5504 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
5505 bgp_info_delete (rn
, ri
);
5506 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5511 /* Static function to display route. */
5513 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
5516 u_int32_t destination
;
5519 if (p
->family
== AF_INET
)
5521 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
5522 destination
= ntohl (p
->u
.prefix4
.s_addr
);
5524 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
5525 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
5526 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
5527 || p
->u
.prefix4
.s_addr
== 0)
5529 /* When mask is natural, mask is not displayed. */
5532 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
5535 len
= vty_out (vty
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
5540 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
5542 vty_out (vty
, "%*s", len
, " ");
5545 enum bgp_display_type
5550 /* Print the short form route status for a bgp_info */
5552 route_vty_short_status_out (struct vty
*vty
, struct bgp_info
*binfo
)
5554 /* Route status display. */
5555 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5557 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5559 else if (binfo
->extra
&& binfo
->extra
->suppress
)
5561 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5567 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5569 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5571 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5576 /* Internal route. */
5577 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
5583 /* called from terminal list command */
5585 route_vty_out (struct vty
*vty
, struct prefix
*p
,
5586 struct bgp_info
*binfo
, int display
, safi_t safi
)
5590 /* short status lead text */
5591 route_vty_short_status_out (vty
, binfo
);
5593 /* print prefix and mask */
5595 route_vty_out_route (p
, vty
);
5597 vty_out (vty
, "%*s", 17, " ");
5599 /* Print attribute */
5603 if (p
->family
== AF_INET
)
5605 if (safi
== SAFI_MPLS_VPN
)
5606 vty_out (vty
, "%-16s",
5607 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5609 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5612 else if (p
->family
== AF_INET6
)
5617 len
= vty_out (vty
, "%s",
5618 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5622 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5624 vty_out (vty
, "%*s", len
, " ");
5626 #endif /* HAVE_IPV6 */
5628 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5629 vty_out (vty
, "%10u", attr
->med
);
5633 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5634 vty_out (vty
, "%7u", attr
->local_pref
);
5638 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
5642 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5645 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5647 vty_out (vty
, "%s", VTY_NEWLINE
);
5650 /* called from terminal list command */
5652 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
,
5653 struct attr
*attr
, safi_t safi
)
5655 /* Route status display. */
5660 /* print prefix and mask */
5661 route_vty_out_route (p
, vty
);
5663 /* Print attribute */
5666 if (p
->family
== AF_INET
)
5668 if (safi
== SAFI_MPLS_VPN
)
5669 vty_out (vty
, "%-16s",
5670 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5672 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5675 else if (p
->family
== AF_INET6
)
5680 assert (attr
->extra
);
5682 len
= vty_out (vty
, "%s",
5683 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5687 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5689 vty_out (vty
, "%*s", len
, " ");
5691 #endif /* HAVE_IPV6 */
5693 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5694 vty_out (vty
, "%10u", attr
->med
);
5698 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5699 vty_out (vty
, "%7u", attr
->local_pref
);
5703 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
5707 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5710 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5713 vty_out (vty
, "%s", VTY_NEWLINE
);
5717 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
5718 struct bgp_info
*binfo
, int display
, safi_t safi
)
5721 u_int32_t label
= 0;
5726 /* short status lead text */
5727 route_vty_short_status_out (vty
, binfo
);
5729 /* print prefix and mask */
5731 route_vty_out_route (p
, vty
);
5733 vty_out (vty
, "%*s", 17, " ");
5735 /* Print attribute */
5739 if (p
->family
== AF_INET
)
5741 if (safi
== SAFI_MPLS_VPN
)
5742 vty_out (vty
, "%-16s",
5743 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5745 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5748 else if (p
->family
== AF_INET6
)
5750 assert (attr
->extra
);
5753 if (attr
->extra
->mp_nexthop_len
== 16)
5755 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5757 else if (attr
->extra
->mp_nexthop_len
== 32)
5758 vty_out (vty
, "%s(%s)",
5759 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5761 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
5765 #endif /* HAVE_IPV6 */
5768 label
= decode_label (binfo
->extra
->tag
);
5770 vty_out (vty
, "notag/%d", label
);
5772 vty_out (vty
, "%s", VTY_NEWLINE
);
5775 /* dampening route */
5777 damp_route_vty_out (struct vty
*vty
, struct prefix
*p
,
5778 struct bgp_info
*binfo
, int display
, safi_t safi
)
5782 char timebuf
[BGP_UPTIME_LEN
];
5784 /* short status lead text */
5785 route_vty_short_status_out (vty
, binfo
);
5787 /* print prefix and mask */
5789 route_vty_out_route (p
, vty
);
5791 vty_out (vty
, "%*s", 17, " ");
5793 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
5796 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 34, " ");
5798 vty_out (vty
, "%*s", len
, " ");
5800 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
));
5802 /* Print attribute */
5808 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5811 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5813 vty_out (vty
, "%s", VTY_NEWLINE
);
5818 flap_route_vty_out (struct vty
*vty
, struct prefix
*p
,
5819 struct bgp_info
*binfo
, int display
, safi_t safi
)
5822 struct bgp_damp_info
*bdi
;
5823 char timebuf
[BGP_UPTIME_LEN
];
5829 bdi
= binfo
->extra
->damp_info
;
5831 /* short status lead text */
5832 route_vty_short_status_out (vty
, binfo
);
5834 /* print prefix and mask */
5836 route_vty_out_route (p
, vty
);
5838 vty_out (vty
, "%*s", 17, " ");
5840 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
5843 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 33, " ");
5845 vty_out (vty
, "%*s", len
, " ");
5847 len
= vty_out (vty
, "%d", bdi
->flap
);
5852 vty_out (vty
, "%*s ", len
, " ");
5854 vty_out (vty
, "%s ", peer_uptime (bdi
->start_time
,
5855 timebuf
, BGP_UPTIME_LEN
));
5857 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
)
5858 && ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5859 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
));
5861 vty_out (vty
, "%*s ", 8, " ");
5863 /* Print attribute */
5869 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5872 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5874 vty_out (vty
, "%s", VTY_NEWLINE
);
5878 route_vty_out_detail (struct vty
*vty
, struct bgp
*bgp
, struct prefix
*p
,
5879 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
)
5881 char buf
[INET6_ADDRSTRLEN
];
5884 int sockunion_vty_out (struct vty
*, union sockunion
*);
5885 #ifdef HAVE_CLOCK_MONOTONIC
5893 /* Line1 display AS-path, Aggregator */
5897 if (aspath_count_hops (attr
->aspath
) == 0)
5898 vty_out (vty
, "Local");
5900 aspath_print_vty (vty
, "%s", attr
->aspath
, "");
5903 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5904 vty_out (vty
, ", (removed)");
5905 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5906 vty_out (vty
, ", (stale)");
5907 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
5908 vty_out (vty
, ", (aggregated by %u %s)",
5909 attr
->extra
->aggregator_as
,
5910 inet_ntoa (attr
->extra
->aggregator_addr
));
5911 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
5912 vty_out (vty
, ", (Received from a RR-client)");
5913 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
5914 vty_out (vty
, ", (Received from a RS-client)");
5915 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5916 vty_out (vty
, ", (history entry)");
5917 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5918 vty_out (vty
, ", (suppressed due to dampening)");
5919 vty_out (vty
, "%s", VTY_NEWLINE
);
5921 /* Line2 display Next-hop, Neighbor, Router-id */
5922 if (p
->family
== AF_INET
)
5924 vty_out (vty
, " %s", safi
== SAFI_MPLS_VPN
?
5925 inet_ntoa (attr
->extra
->mp_nexthop_global_in
) :
5926 inet_ntoa (attr
->nexthop
));
5931 assert (attr
->extra
);
5932 vty_out (vty
, " %s",
5933 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5934 buf
, INET6_ADDRSTRLEN
));
5936 #endif /* HAVE_IPV6 */
5938 if (binfo
->peer
== bgp
->peer_self
)
5940 vty_out (vty
, " from %s ",
5941 p
->family
== AF_INET
? "0.0.0.0" : "::");
5942 vty_out (vty
, "(%s)", inet_ntoa(bgp
->router_id
));
5946 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
5947 vty_out (vty
, " (inaccessible)");
5948 else if (binfo
->extra
&& binfo
->extra
->igpmetric
)
5949 vty_out (vty
, " (metric %d)", binfo
->extra
->igpmetric
);
5950 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
5951 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
5952 vty_out (vty
, " (%s)", inet_ntoa (attr
->extra
->originator_id
));
5954 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
5956 vty_out (vty
, "%s", VTY_NEWLINE
);
5959 /* display nexthop local */
5960 if (attr
->extra
&& attr
->extra
->mp_nexthop_len
== 32)
5962 vty_out (vty
, " (%s)%s",
5963 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
5964 buf
, INET6_ADDRSTRLEN
),
5967 #endif /* HAVE_IPV6 */
5969 /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */
5970 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
5972 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
5973 vty_out (vty
, ", metric %u", attr
->med
);
5975 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
5976 vty_out (vty
, ", localpref %u", attr
->local_pref
);
5978 vty_out (vty
, ", localpref %u", bgp
->default_local_pref
);
5980 if (attr
->extra
&& attr
->extra
->weight
!= 0)
5981 vty_out (vty
, ", weight %u", attr
->extra
->weight
);
5983 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5984 vty_out (vty
, ", valid");
5986 if (binfo
->peer
!= bgp
->peer_self
)
5988 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
5989 vty_out (vty
, ", internal");
5991 vty_out (vty
, ", %s",
5992 (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
) ? "confed-external" : "external"));
5994 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
5995 vty_out (vty
, ", aggregated, local");
5996 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
5997 vty_out (vty
, ", sourced");
5999 vty_out (vty
, ", sourced, local");
6001 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
6002 vty_out (vty
, ", atomic-aggregate");
6004 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
) ||
6005 (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
) &&
6006 bgp_info_mpath_count (binfo
)))
6007 vty_out (vty
, ", multipath");
6009 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
6010 vty_out (vty
, ", best");
6012 vty_out (vty
, "%s", VTY_NEWLINE
);
6014 /* Line 4 display Community */
6015 if (attr
->community
)
6016 vty_out (vty
, " Community: %s%s", attr
->community
->str
,
6019 /* Line 5 display Extended-community */
6020 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
6021 vty_out (vty
, " Extended Community: %s%s",
6022 attr
->extra
->ecommunity
->str
, VTY_NEWLINE
);
6024 /* Line 6 display Originator, Cluster-id */
6025 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
6026 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
6028 assert (attr
->extra
);
6029 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
6030 vty_out (vty
, " Originator: %s",
6031 inet_ntoa (attr
->extra
->originator_id
));
6033 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
6036 vty_out (vty
, ", Cluster list: ");
6037 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
6038 vty_out (vty
, "%s ",
6039 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
6041 vty_out (vty
, "%s", VTY_NEWLINE
);
6044 if (binfo
->extra
&& binfo
->extra
->damp_info
)
6045 bgp_damp_info_vty (vty
, binfo
);
6047 /* Line 7 display Uptime */
6048 #ifdef HAVE_CLOCK_MONOTONIC
6049 tbuf
= time(NULL
) - (bgp_clock() - binfo
->uptime
);
6050 vty_out (vty
, " Last update: %s", ctime(&tbuf
));
6052 vty_out (vty
, " Last update: %s", ctime(&binfo
->uptime
));
6053 #endif /* HAVE_CLOCK_MONOTONIC */
6055 vty_out (vty
, "%s", VTY_NEWLINE
);
6058 #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"
6059 #define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
6060 #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
6061 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
6062 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
6066 bgp_show_type_normal
,
6067 bgp_show_type_regexp
,
6068 bgp_show_type_prefix_list
,
6069 bgp_show_type_filter_list
,
6070 bgp_show_type_route_map
,
6071 bgp_show_type_neighbor
,
6072 bgp_show_type_cidr_only
,
6073 bgp_show_type_prefix_longer
,
6074 bgp_show_type_community_all
,
6075 bgp_show_type_community
,
6076 bgp_show_type_community_exact
,
6077 bgp_show_type_community_list
,
6078 bgp_show_type_community_list_exact
,
6079 bgp_show_type_flap_statistics
,
6080 bgp_show_type_flap_address
,
6081 bgp_show_type_flap_prefix
,
6082 bgp_show_type_flap_cidr_only
,
6083 bgp_show_type_flap_regexp
,
6084 bgp_show_type_flap_filter_list
,
6085 bgp_show_type_flap_prefix_list
,
6086 bgp_show_type_flap_prefix_longer
,
6087 bgp_show_type_flap_route_map
,
6088 bgp_show_type_flap_neighbor
,
6089 bgp_show_type_dampend_paths
,
6090 bgp_show_type_damp_neighbor
6094 bgp_show_table (struct vty
*vty
, struct bgp_table
*table
, struct in_addr
*router_id
,
6095 enum bgp_show_type type
, void *output_arg
)
6097 struct bgp_info
*ri
;
6098 struct bgp_node
*rn
;
6101 unsigned long output_count
;
6103 /* This is first entry point, so reset total line. */
6106 /* Start processing of routes. */
6107 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
6108 if (rn
->info
!= NULL
)
6112 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6114 if (type
== bgp_show_type_flap_statistics
6115 || type
== bgp_show_type_flap_address
6116 || type
== bgp_show_type_flap_prefix
6117 || type
== bgp_show_type_flap_cidr_only
6118 || type
== bgp_show_type_flap_regexp
6119 || type
== bgp_show_type_flap_filter_list
6120 || type
== bgp_show_type_flap_prefix_list
6121 || type
== bgp_show_type_flap_prefix_longer
6122 || type
== bgp_show_type_flap_route_map
6123 || type
== bgp_show_type_flap_neighbor
6124 || type
== bgp_show_type_dampend_paths
6125 || type
== bgp_show_type_damp_neighbor
)
6127 if (!(ri
->extra
&& ri
->extra
->damp_info
))
6130 if (type
== bgp_show_type_regexp
6131 || type
== bgp_show_type_flap_regexp
)
6133 regex_t
*regex
= output_arg
;
6135 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
6138 if (type
== bgp_show_type_prefix_list
6139 || type
== bgp_show_type_flap_prefix_list
)
6141 struct prefix_list
*plist
= output_arg
;
6143 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
6146 if (type
== bgp_show_type_filter_list
6147 || type
== bgp_show_type_flap_filter_list
)
6149 struct as_list
*as_list
= output_arg
;
6151 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
6154 if (type
== bgp_show_type_route_map
6155 || type
== bgp_show_type_flap_route_map
)
6157 struct route_map
*rmap
= output_arg
;
6158 struct bgp_info binfo
;
6159 struct attr dummy_attr
= { 0 };
6162 bgp_attr_dup (&dummy_attr
, ri
->attr
);
6163 binfo
.peer
= ri
->peer
;
6164 binfo
.attr
= &dummy_attr
;
6166 ret
= route_map_apply (rmap
, &rn
->p
, RMAP_BGP
, &binfo
);
6168 bgp_attr_extra_free (&dummy_attr
);
6170 if (ret
== RMAP_DENYMATCH
)
6173 if (type
== bgp_show_type_neighbor
6174 || type
== bgp_show_type_flap_neighbor
6175 || type
== bgp_show_type_damp_neighbor
)
6177 union sockunion
*su
= output_arg
;
6179 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
6182 if (type
== bgp_show_type_cidr_only
6183 || type
== bgp_show_type_flap_cidr_only
)
6185 u_int32_t destination
;
6187 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
6188 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
6190 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
6192 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
6195 if (type
== bgp_show_type_prefix_longer
6196 || type
== bgp_show_type_flap_prefix_longer
)
6198 struct prefix
*p
= output_arg
;
6200 if (! prefix_match (p
, &rn
->p
))
6203 if (type
== bgp_show_type_community_all
)
6205 if (! ri
->attr
->community
)
6208 if (type
== bgp_show_type_community
)
6210 struct community
*com
= output_arg
;
6212 if (! ri
->attr
->community
||
6213 ! community_match (ri
->attr
->community
, com
))
6216 if (type
== bgp_show_type_community_exact
)
6218 struct community
*com
= output_arg
;
6220 if (! ri
->attr
->community
||
6221 ! community_cmp (ri
->attr
->community
, com
))
6224 if (type
== bgp_show_type_community_list
)
6226 struct community_list
*list
= output_arg
;
6228 if (! community_list_match (ri
->attr
->community
, list
))
6231 if (type
== bgp_show_type_community_list_exact
)
6233 struct community_list
*list
= output_arg
;
6235 if (! community_list_exact_match (ri
->attr
->community
, list
))
6238 if (type
== bgp_show_type_flap_address
6239 || type
== bgp_show_type_flap_prefix
)
6241 struct prefix
*p
= output_arg
;
6243 if (! prefix_match (&rn
->p
, p
))
6246 if (type
== bgp_show_type_flap_prefix
)
6247 if (p
->prefixlen
!= rn
->p
.prefixlen
)
6250 if (type
== bgp_show_type_dampend_paths
6251 || type
== bgp_show_type_damp_neighbor
)
6253 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
)
6254 || CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
6260 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id
), VTY_NEWLINE
);
6261 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
6262 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
6263 if (type
== bgp_show_type_dampend_paths
6264 || type
== bgp_show_type_damp_neighbor
)
6265 vty_out (vty
, BGP_SHOW_DAMP_HEADER
, VTY_NEWLINE
);
6266 else if (type
== bgp_show_type_flap_statistics
6267 || type
== bgp_show_type_flap_address
6268 || type
== bgp_show_type_flap_prefix
6269 || type
== bgp_show_type_flap_cidr_only
6270 || type
== bgp_show_type_flap_regexp
6271 || type
== bgp_show_type_flap_filter_list
6272 || type
== bgp_show_type_flap_prefix_list
6273 || type
== bgp_show_type_flap_prefix_longer
6274 || type
== bgp_show_type_flap_route_map
6275 || type
== bgp_show_type_flap_neighbor
)
6276 vty_out (vty
, BGP_SHOW_FLAP_HEADER
, VTY_NEWLINE
);
6278 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
6282 if (type
== bgp_show_type_dampend_paths
6283 || type
== bgp_show_type_damp_neighbor
)
6284 damp_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6285 else if (type
== bgp_show_type_flap_statistics
6286 || type
== bgp_show_type_flap_address
6287 || type
== bgp_show_type_flap_prefix
6288 || type
== bgp_show_type_flap_cidr_only
6289 || type
== bgp_show_type_flap_regexp
6290 || type
== bgp_show_type_flap_filter_list
6291 || type
== bgp_show_type_flap_prefix_list
6292 || type
== bgp_show_type_flap_prefix_longer
6293 || type
== bgp_show_type_flap_route_map
6294 || type
== bgp_show_type_flap_neighbor
)
6295 flap_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6297 route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6304 /* No route is displayed */
6305 if (output_count
== 0)
6307 if (type
== bgp_show_type_normal
)
6308 vty_out (vty
, "No BGP network exists%s", VTY_NEWLINE
);
6311 vty_out (vty
, "%sTotal number of prefixes %ld%s",
6312 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
6318 bgp_show (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
6319 enum bgp_show_type type
, void *output_arg
)
6321 struct bgp_table
*table
;
6324 bgp
= bgp_get_default ();
6329 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
6334 table
= bgp
->rib
[afi
][safi
];
6336 return bgp_show_table (vty
, table
, &bgp
->router_id
, type
, output_arg
);
6339 /* Header of detailed BGP route information */
6341 route_vty_out_detail_header (struct vty
*vty
, struct bgp
*bgp
,
6342 struct bgp_node
*rn
,
6343 struct prefix_rd
*prd
, afi_t afi
, safi_t safi
)
6345 struct bgp_info
*ri
;
6348 struct listnode
*node
, *nnode
;
6349 char buf1
[INET6_ADDRSTRLEN
];
6350 char buf2
[INET6_ADDRSTRLEN
];
6355 int no_advertise
= 0;
6360 vty_out (vty
, "BGP routing table entry for %s%s%s/%d%s",
6361 (safi
== SAFI_MPLS_VPN
?
6362 prefix_rd2str (prd
, buf1
, RD_ADDRSTRLEN
) : ""),
6363 safi
== SAFI_MPLS_VPN
? ":" : "",
6364 inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
),
6365 p
->prefixlen
, VTY_NEWLINE
);
6367 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6370 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
6373 if (ri
->extra
&& ri
->extra
->suppress
)
6375 if (ri
->attr
->community
!= NULL
)
6377 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
6379 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
6381 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
6387 vty_out (vty
, "Paths: (%d available", count
);
6390 vty_out (vty
, ", best #%d", best
);
6391 if (safi
== SAFI_UNICAST
)
6392 vty_out (vty
, ", table Default-IP-Routing-Table");
6395 vty_out (vty
, ", no best path");
6397 vty_out (vty
, ", not advertised to any peer");
6399 vty_out (vty
, ", not advertised to EBGP peer");
6401 vty_out (vty
, ", not advertised outside local AS");
6403 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
6404 vty_out (vty
, ")%s", VTY_NEWLINE
);
6406 /* advertised peer */
6407 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
6409 if (bgp_adj_out_lookup (peer
, p
, afi
, safi
, rn
))
6412 vty_out (vty
, " Advertised to non peer-group peers:%s ", VTY_NEWLINE
);
6413 vty_out (vty
, " %s", sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6418 vty_out (vty
, " Not advertised to any peer");
6419 vty_out (vty
, "%s", VTY_NEWLINE
);
6422 /* Display specified route of BGP table. */
6424 bgp_show_route_in_table (struct vty
*vty
, struct bgp
*bgp
,
6425 struct bgp_table
*rib
, const char *ip_str
,
6426 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
6432 struct prefix match
;
6433 struct bgp_node
*rn
;
6434 struct bgp_node
*rm
;
6435 struct bgp_info
*ri
;
6436 struct bgp_table
*table
;
6438 /* Check IP address argument. */
6439 ret
= str2prefix (ip_str
, &match
);
6442 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
6446 match
.family
= afi2family (afi
);
6448 if (safi
== SAFI_MPLS_VPN
)
6450 for (rn
= bgp_table_top (rib
); rn
; rn
= bgp_route_next (rn
))
6452 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
6455 if ((table
= rn
->info
) != NULL
)
6459 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
6461 if (prefix_check
&& rm
->p
.prefixlen
!= match
.prefixlen
)
6463 bgp_unlock_node (rm
);
6467 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
6471 route_vty_out_detail_header (vty
, bgp
, rm
, (struct prefix_rd
*)&rn
->p
,
6472 AFI_IP
, SAFI_MPLS_VPN
);
6477 route_vty_out_detail (vty
, bgp
, &rm
->p
, ri
, AFI_IP
, SAFI_MPLS_VPN
);
6480 bgp_unlock_node (rm
);
6489 if ((rn
= bgp_node_match (rib
, &match
)) != NULL
)
6491 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
6493 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6497 route_vty_out_detail_header (vty
, bgp
, rn
, NULL
, afi
, safi
);
6501 route_vty_out_detail (vty
, bgp
, &rn
->p
, ri
, afi
, safi
);
6505 bgp_unlock_node (rn
);
6511 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
6518 /* Display specified route of Main RIB */
6520 bgp_show_route (struct vty
*vty
, const char *view_name
, const char *ip_str
,
6521 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
6526 /* BGP structure lookup. */
6529 bgp
= bgp_lookup_by_name (view_name
);
6532 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
6538 bgp
= bgp_get_default ();
6541 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
6546 return bgp_show_route_in_table (vty
, bgp
, bgp
->rib
[afi
][safi
], ip_str
,
6547 afi
, safi
, prd
, prefix_check
);
6550 /* BGP route print out function. */
6558 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6561 DEFUN (show_ip_bgp_ipv4
,
6562 show_ip_bgp_ipv4_cmd
,
6563 "show ip bgp ipv4 (unicast|multicast)",
6568 "Address Family modifier\n"
6569 "Address Family modifier\n")
6571 if (strncmp (argv
[0], "m", 1) == 0)
6572 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
, bgp_show_type_normal
,
6575 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6578 ALIAS (show_ip_bgp_ipv4
,
6579 show_bgp_ipv4_safi_cmd
,
6580 "show bgp ipv4 (unicast|multicast)",
6584 "Address Family modifier\n"
6585 "Address Family modifier\n")
6587 DEFUN (show_ip_bgp_route
,
6588 show_ip_bgp_route_cmd
,
6589 "show ip bgp A.B.C.D",
6593 "Network in the BGP routing table to display\n")
6595 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6598 DEFUN (show_ip_bgp_ipv4_route
,
6599 show_ip_bgp_ipv4_route_cmd
,
6600 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
6605 "Address Family modifier\n"
6606 "Address Family modifier\n"
6607 "Network in the BGP routing table to display\n")
6609 if (strncmp (argv
[0], "m", 1) == 0)
6610 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0);
6612 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6615 ALIAS (show_ip_bgp_ipv4_route
,
6616 show_bgp_ipv4_safi_route_cmd
,
6617 "show bgp ipv4 (unicast|multicast) A.B.C.D",
6621 "Address Family modifier\n"
6622 "Address Family modifier\n"
6623 "Network in the BGP routing table to display\n")
6625 DEFUN (show_ip_bgp_vpnv4_all_route
,
6626 show_ip_bgp_vpnv4_all_route_cmd
,
6627 "show ip bgp vpnv4 all A.B.C.D",
6631 "Display VPNv4 NLRI specific information\n"
6632 "Display information about all VPNv4 NLRIs\n"
6633 "Network in the BGP routing table to display\n")
6635 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 0);
6638 DEFUN (show_ip_bgp_vpnv4_rd_route
,
6639 show_ip_bgp_vpnv4_rd_route_cmd
,
6640 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
6644 "Display VPNv4 NLRI specific information\n"
6645 "Display information for a route distinguisher\n"
6646 "VPN Route Distinguisher\n"
6647 "Network in the BGP routing table to display\n")
6650 struct prefix_rd prd
;
6652 ret
= str2prefix_rd (argv
[0], &prd
);
6655 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
6658 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0);
6661 DEFUN (show_ip_bgp_prefix
,
6662 show_ip_bgp_prefix_cmd
,
6663 "show ip bgp A.B.C.D/M",
6667 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6669 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6672 DEFUN (show_ip_bgp_ipv4_prefix
,
6673 show_ip_bgp_ipv4_prefix_cmd
,
6674 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
6679 "Address Family modifier\n"
6680 "Address Family modifier\n"
6681 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6683 if (strncmp (argv
[0], "m", 1) == 0)
6684 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1);
6686 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6689 ALIAS (show_ip_bgp_ipv4_prefix
,
6690 show_bgp_ipv4_safi_prefix_cmd
,
6691 "show bgp ipv4 (unicast|multicast) A.B.C.D/M",
6695 "Address Family modifier\n"
6696 "Address Family modifier\n"
6697 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6699 DEFUN (show_ip_bgp_vpnv4_all_prefix
,
6700 show_ip_bgp_vpnv4_all_prefix_cmd
,
6701 "show ip bgp vpnv4 all A.B.C.D/M",
6705 "Display VPNv4 NLRI specific information\n"
6706 "Display information about all VPNv4 NLRIs\n"
6707 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6709 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 1);
6712 DEFUN (show_ip_bgp_vpnv4_rd_prefix
,
6713 show_ip_bgp_vpnv4_rd_prefix_cmd
,
6714 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
6718 "Display VPNv4 NLRI specific information\n"
6719 "Display information for a route distinguisher\n"
6720 "VPN Route Distinguisher\n"
6721 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6724 struct prefix_rd prd
;
6726 ret
= str2prefix_rd (argv
[0], &prd
);
6729 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
6732 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 1);
6735 DEFUN (show_ip_bgp_view
,
6736 show_ip_bgp_view_cmd
,
6737 "show ip bgp view WORD",
6746 /* BGP structure lookup. */
6747 bgp
= bgp_lookup_by_name (argv
[0]);
6750 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
6754 return bgp_show (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6757 DEFUN (show_ip_bgp_view_route
,
6758 show_ip_bgp_view_route_cmd
,
6759 "show ip bgp view WORD A.B.C.D",
6765 "Network in the BGP routing table to display\n")
6767 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6770 DEFUN (show_ip_bgp_view_prefix
,
6771 show_ip_bgp_view_prefix_cmd
,
6772 "show ip bgp view WORD A.B.C.D/M",
6778 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6780 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6790 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
6801 DEFUN (show_bgp_ipv6_safi
,
6802 show_bgp_ipv6_safi_cmd
,
6803 "show bgp ipv6 (unicast|multicast)",
6807 "Address Family modifier\n"
6808 "Address Family modifier\n")
6810 if (strncmp (argv
[0], "m", 1) == 0)
6811 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
6814 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6818 DEFUN (show_ipv6_bgp
,
6825 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
6829 DEFUN (show_bgp_route
,
6831 "show bgp X:X::X:X",
6834 "Network in the BGP routing table to display\n")
6836 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6839 ALIAS (show_bgp_route
,
6840 show_bgp_ipv6_route_cmd
,
6841 "show bgp ipv6 X:X::X:X",
6845 "Network in the BGP routing table to display\n")
6847 DEFUN (show_bgp_ipv6_safi_route
,
6848 show_bgp_ipv6_safi_route_cmd
,
6849 "show bgp ipv6 (unicast|multicast) X:X::X:X",
6853 "Address Family modifier\n"
6854 "Address Family modifier\n"
6855 "Network in the BGP routing table to display\n")
6857 if (strncmp (argv
[0], "m", 1) == 0)
6858 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0);
6860 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6864 DEFUN (show_ipv6_bgp_route
,
6865 show_ipv6_bgp_route_cmd
,
6866 "show ipv6 bgp X:X::X:X",
6870 "Network in the BGP routing table to display\n")
6872 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6875 DEFUN (show_bgp_prefix
,
6876 show_bgp_prefix_cmd
,
6877 "show bgp X:X::X:X/M",
6880 "IPv6 prefix <network>/<length>\n")
6882 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6885 ALIAS (show_bgp_prefix
,
6886 show_bgp_ipv6_prefix_cmd
,
6887 "show bgp ipv6 X:X::X:X/M",
6891 "IPv6 prefix <network>/<length>\n")
6893 DEFUN (show_bgp_ipv6_safi_prefix
,
6894 show_bgp_ipv6_safi_prefix_cmd
,
6895 "show bgp ipv6 (unicast|multicast) X:X::X:X/M",
6899 "Address Family modifier\n"
6900 "Address Family modifier\n"
6901 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6903 if (strncmp (argv
[0], "m", 1) == 0)
6904 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1);
6906 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6910 DEFUN (show_ipv6_bgp_prefix
,
6911 show_ipv6_bgp_prefix_cmd
,
6912 "show ipv6 bgp X:X::X:X/M",
6916 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6918 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6921 DEFUN (show_bgp_view
,
6923 "show bgp view WORD",
6931 /* BGP structure lookup. */
6932 bgp
= bgp_lookup_by_name (argv
[0]);
6935 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
6939 return bgp_show (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6942 ALIAS (show_bgp_view
,
6943 show_bgp_view_ipv6_cmd
,
6944 "show bgp view WORD ipv6",
6951 DEFUN (show_bgp_view_route
,
6952 show_bgp_view_route_cmd
,
6953 "show bgp view WORD X:X::X:X",
6958 "Network in the BGP routing table to display\n")
6960 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6963 ALIAS (show_bgp_view_route
,
6964 show_bgp_view_ipv6_route_cmd
,
6965 "show bgp view WORD ipv6 X:X::X:X",
6971 "Network in the BGP routing table to display\n")
6973 DEFUN (show_bgp_view_prefix
,
6974 show_bgp_view_prefix_cmd
,
6975 "show bgp view WORD X:X::X:X/M",
6980 "IPv6 prefix <network>/<length>\n")
6982 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6985 ALIAS (show_bgp_view_prefix
,
6986 show_bgp_view_ipv6_prefix_cmd
,
6987 "show bgp view WORD ipv6 X:X::X:X/M",
6993 "IPv6 prefix <network>/<length>\n")
6996 DEFUN (show_ipv6_mbgp
,
7003 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
7008 DEFUN (show_ipv6_mbgp_route
,
7009 show_ipv6_mbgp_route_cmd
,
7010 "show ipv6 mbgp X:X::X:X",
7014 "Network in the MBGP routing table to display\n")
7016 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0);
7020 DEFUN (show_ipv6_mbgp_prefix
,
7021 show_ipv6_mbgp_prefix_cmd
,
7022 "show ipv6 mbgp X:X::X:X/M",
7026 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7028 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1);
7034 bgp_show_regexp (struct vty
*vty
, int argc
, const char **argv
, afi_t afi
,
7035 safi_t safi
, enum bgp_show_type type
)
7045 b
= buffer_new (1024);
7046 for (i
= 0; i
< argc
; i
++)
7049 buffer_putc (b
, ' ');
7052 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
7057 buffer_putstr (b
, argv
[i
]);
7059 buffer_putc (b
, '\0');
7061 regstr
= buffer_getstr (b
);
7064 regex
= bgp_regcomp (regstr
);
7065 XFREE(MTYPE_TMP
, regstr
);
7068 vty_out (vty
, "Can't compile regexp %s%s", argv
[0],
7073 rc
= bgp_show (vty
, NULL
, afi
, safi
, type
, regex
);
7074 bgp_regex_free (regex
);
7078 DEFUN (show_ip_bgp_regexp
,
7079 show_ip_bgp_regexp_cmd
,
7080 "show ip bgp regexp .LINE",
7084 "Display routes matching the AS path regular expression\n"
7085 "A regular-expression to match the BGP AS paths\n")
7087 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
7088 bgp_show_type_regexp
);
7091 DEFUN (show_ip_bgp_flap_regexp
,
7092 show_ip_bgp_flap_regexp_cmd
,
7093 "show ip bgp flap-statistics regexp .LINE",
7097 "Display flap statistics of routes\n"
7098 "Display routes matching the AS path regular expression\n"
7099 "A regular-expression to match the BGP AS paths\n")
7101 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
7102 bgp_show_type_flap_regexp
);
7105 DEFUN (show_ip_bgp_ipv4_regexp
,
7106 show_ip_bgp_ipv4_regexp_cmd
,
7107 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
7112 "Address Family modifier\n"
7113 "Address Family modifier\n"
7114 "Display routes matching the AS path regular expression\n"
7115 "A regular-expression to match the BGP AS paths\n")
7117 if (strncmp (argv
[0], "m", 1) == 0)
7118 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_MULTICAST
,
7119 bgp_show_type_regexp
);
7121 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
7122 bgp_show_type_regexp
);
7126 DEFUN (show_bgp_regexp
,
7127 show_bgp_regexp_cmd
,
7128 "show bgp regexp .LINE",
7131 "Display routes matching the AS path regular expression\n"
7132 "A regular-expression to match the BGP AS paths\n")
7134 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
7135 bgp_show_type_regexp
);
7138 ALIAS (show_bgp_regexp
,
7139 show_bgp_ipv6_regexp_cmd
,
7140 "show bgp ipv6 regexp .LINE",
7144 "Display routes matching the AS path regular expression\n"
7145 "A regular-expression to match the BGP AS paths\n")
7148 DEFUN (show_ipv6_bgp_regexp
,
7149 show_ipv6_bgp_regexp_cmd
,
7150 "show ipv6 bgp regexp .LINE",
7154 "Display routes matching the AS path regular expression\n"
7155 "A regular-expression to match the BGP AS paths\n")
7157 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
7158 bgp_show_type_regexp
);
7162 DEFUN (show_ipv6_mbgp_regexp
,
7163 show_ipv6_mbgp_regexp_cmd
,
7164 "show ipv6 mbgp regexp .LINE",
7168 "Display routes matching the AS path regular expression\n"
7169 "A regular-expression to match the MBGP AS paths\n")
7171 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
,
7172 bgp_show_type_regexp
);
7174 #endif /* HAVE_IPV6 */
7177 bgp_show_prefix_list (struct vty
*vty
, const char *prefix_list_str
, afi_t afi
,
7178 safi_t safi
, enum bgp_show_type type
)
7180 struct prefix_list
*plist
;
7182 plist
= prefix_list_lookup (afi
, prefix_list_str
);
7185 vty_out (vty
, "%% %s is not a valid prefix-list name%s",
7186 prefix_list_str
, VTY_NEWLINE
);
7190 return bgp_show (vty
, NULL
, afi
, safi
, type
, plist
);
7193 DEFUN (show_ip_bgp_prefix_list
,
7194 show_ip_bgp_prefix_list_cmd
,
7195 "show ip bgp prefix-list WORD",
7199 "Display routes conforming to the prefix-list\n"
7200 "IP prefix-list name\n")
7202 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7203 bgp_show_type_prefix_list
);
7206 DEFUN (show_ip_bgp_flap_prefix_list
,
7207 show_ip_bgp_flap_prefix_list_cmd
,
7208 "show ip bgp flap-statistics prefix-list WORD",
7212 "Display flap statistics of routes\n"
7213 "Display routes conforming to the prefix-list\n"
7214 "IP prefix-list name\n")
7216 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7217 bgp_show_type_flap_prefix_list
);
7220 DEFUN (show_ip_bgp_ipv4_prefix_list
,
7221 show_ip_bgp_ipv4_prefix_list_cmd
,
7222 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
7227 "Address Family modifier\n"
7228 "Address Family modifier\n"
7229 "Display routes conforming to the prefix-list\n"
7230 "IP prefix-list name\n")
7232 if (strncmp (argv
[0], "m", 1) == 0)
7233 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
7234 bgp_show_type_prefix_list
);
7236 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
7237 bgp_show_type_prefix_list
);
7241 DEFUN (show_bgp_prefix_list
,
7242 show_bgp_prefix_list_cmd
,
7243 "show bgp prefix-list WORD",
7246 "Display routes conforming to the prefix-list\n"
7247 "IPv6 prefix-list name\n")
7249 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7250 bgp_show_type_prefix_list
);
7253 ALIAS (show_bgp_prefix_list
,
7254 show_bgp_ipv6_prefix_list_cmd
,
7255 "show bgp ipv6 prefix-list WORD",
7259 "Display routes conforming to the prefix-list\n"
7260 "IPv6 prefix-list name\n")
7263 DEFUN (show_ipv6_bgp_prefix_list
,
7264 show_ipv6_bgp_prefix_list_cmd
,
7265 "show ipv6 bgp prefix-list WORD",
7269 "Display routes matching the prefix-list\n"
7270 "IPv6 prefix-list name\n")
7272 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7273 bgp_show_type_prefix_list
);
7277 DEFUN (show_ipv6_mbgp_prefix_list
,
7278 show_ipv6_mbgp_prefix_list_cmd
,
7279 "show ipv6 mbgp prefix-list WORD",
7283 "Display routes matching the prefix-list\n"
7284 "IPv6 prefix-list name\n")
7286 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
7287 bgp_show_type_prefix_list
);
7289 #endif /* HAVE_IPV6 */
7292 bgp_show_filter_list (struct vty
*vty
, const char *filter
, afi_t afi
,
7293 safi_t safi
, enum bgp_show_type type
)
7295 struct as_list
*as_list
;
7297 as_list
= as_list_lookup (filter
);
7298 if (as_list
== NULL
)
7300 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
7304 return bgp_show (vty
, NULL
, afi
, safi
, type
, as_list
);
7307 DEFUN (show_ip_bgp_filter_list
,
7308 show_ip_bgp_filter_list_cmd
,
7309 "show ip bgp filter-list WORD",
7313 "Display routes conforming to the filter-list\n"
7314 "Regular expression access list name\n")
7316 return bgp_show_filter_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7317 bgp_show_type_filter_list
);
7320 DEFUN (show_ip_bgp_flap_filter_list
,
7321 show_ip_bgp_flap_filter_list_cmd
,
7322 "show ip bgp flap-statistics filter-list WORD",
7326 "Display flap statistics of routes\n"
7327 "Display routes conforming to the filter-list\n"
7328 "Regular expression access list name\n")
7330 return bgp_show_filter_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7331 bgp_show_type_flap_filter_list
);
7334 DEFUN (show_ip_bgp_ipv4_filter_list
,
7335 show_ip_bgp_ipv4_filter_list_cmd
,
7336 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
7341 "Address Family modifier\n"
7342 "Address Family modifier\n"
7343 "Display routes conforming to the filter-list\n"
7344 "Regular expression access list name\n")
7346 if (strncmp (argv
[0], "m", 1) == 0)
7347 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
7348 bgp_show_type_filter_list
);
7350 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
7351 bgp_show_type_filter_list
);
7355 DEFUN (show_bgp_filter_list
,
7356 show_bgp_filter_list_cmd
,
7357 "show bgp filter-list WORD",
7360 "Display routes conforming to the filter-list\n"
7361 "Regular expression access list name\n")
7363 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7364 bgp_show_type_filter_list
);
7367 ALIAS (show_bgp_filter_list
,
7368 show_bgp_ipv6_filter_list_cmd
,
7369 "show bgp ipv6 filter-list WORD",
7373 "Display routes conforming to the filter-list\n"
7374 "Regular expression access list name\n")
7377 DEFUN (show_ipv6_bgp_filter_list
,
7378 show_ipv6_bgp_filter_list_cmd
,
7379 "show ipv6 bgp filter-list WORD",
7383 "Display routes conforming to the filter-list\n"
7384 "Regular expression access list name\n")
7386 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7387 bgp_show_type_filter_list
);
7391 DEFUN (show_ipv6_mbgp_filter_list
,
7392 show_ipv6_mbgp_filter_list_cmd
,
7393 "show ipv6 mbgp filter-list WORD",
7397 "Display routes conforming to the filter-list\n"
7398 "Regular expression access list name\n")
7400 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
7401 bgp_show_type_filter_list
);
7403 #endif /* HAVE_IPV6 */
7406 bgp_show_route_map (struct vty
*vty
, const char *rmap_str
, afi_t afi
,
7407 safi_t safi
, enum bgp_show_type type
)
7409 struct route_map
*rmap
;
7411 rmap
= route_map_lookup_by_name (rmap_str
);
7414 vty_out (vty
, "%% %s is not a valid route-map name%s",
7415 rmap_str
, VTY_NEWLINE
);
7419 return bgp_show (vty
, NULL
, afi
, safi
, type
, rmap
);
7422 DEFUN (show_ip_bgp_route_map
,
7423 show_ip_bgp_route_map_cmd
,
7424 "show ip bgp route-map WORD",
7428 "Display routes matching the route-map\n"
7429 "A route-map to match on\n")
7431 return bgp_show_route_map (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7432 bgp_show_type_route_map
);
7435 DEFUN (show_ip_bgp_flap_route_map
,
7436 show_ip_bgp_flap_route_map_cmd
,
7437 "show ip bgp flap-statistics route-map WORD",
7441 "Display flap statistics of routes\n"
7442 "Display routes matching the route-map\n"
7443 "A route-map to match on\n")
7445 return bgp_show_route_map (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7446 bgp_show_type_flap_route_map
);
7449 DEFUN (show_ip_bgp_ipv4_route_map
,
7450 show_ip_bgp_ipv4_route_map_cmd
,
7451 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
7456 "Address Family modifier\n"
7457 "Address Family modifier\n"
7458 "Display routes matching the route-map\n"
7459 "A route-map to match on\n")
7461 if (strncmp (argv
[0], "m", 1) == 0)
7462 return bgp_show_route_map (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
7463 bgp_show_type_route_map
);
7465 return bgp_show_route_map (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
7466 bgp_show_type_route_map
);
7469 DEFUN (show_bgp_route_map
,
7470 show_bgp_route_map_cmd
,
7471 "show bgp route-map WORD",
7474 "Display routes matching the route-map\n"
7475 "A route-map to match on\n")
7477 return bgp_show_route_map (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7478 bgp_show_type_route_map
);
7481 ALIAS (show_bgp_route_map
,
7482 show_bgp_ipv6_route_map_cmd
,
7483 "show bgp ipv6 route-map WORD",
7487 "Display routes matching the route-map\n"
7488 "A route-map to match on\n")
7490 DEFUN (show_ip_bgp_cidr_only
,
7491 show_ip_bgp_cidr_only_cmd
,
7492 "show ip bgp cidr-only",
7496 "Display only routes with non-natural netmasks\n")
7498 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7499 bgp_show_type_cidr_only
, NULL
);
7502 DEFUN (show_ip_bgp_flap_cidr_only
,
7503 show_ip_bgp_flap_cidr_only_cmd
,
7504 "show ip bgp flap-statistics cidr-only",
7508 "Display flap statistics of routes\n"
7509 "Display only routes with non-natural netmasks\n")
7511 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7512 bgp_show_type_flap_cidr_only
, NULL
);
7515 DEFUN (show_ip_bgp_ipv4_cidr_only
,
7516 show_ip_bgp_ipv4_cidr_only_cmd
,
7517 "show ip bgp ipv4 (unicast|multicast) cidr-only",
7522 "Address Family modifier\n"
7523 "Address Family modifier\n"
7524 "Display only routes with non-natural netmasks\n")
7526 if (strncmp (argv
[0], "m", 1) == 0)
7527 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
7528 bgp_show_type_cidr_only
, NULL
);
7530 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7531 bgp_show_type_cidr_only
, NULL
);
7534 DEFUN (show_ip_bgp_community_all
,
7535 show_ip_bgp_community_all_cmd
,
7536 "show ip bgp community",
7540 "Display routes matching the communities\n")
7542 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7543 bgp_show_type_community_all
, NULL
);
7546 DEFUN (show_ip_bgp_ipv4_community_all
,
7547 show_ip_bgp_ipv4_community_all_cmd
,
7548 "show ip bgp ipv4 (unicast|multicast) community",
7553 "Address Family modifier\n"
7554 "Address Family modifier\n"
7555 "Display routes matching the communities\n")
7557 if (strncmp (argv
[0], "m", 1) == 0)
7558 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
7559 bgp_show_type_community_all
, NULL
);
7561 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7562 bgp_show_type_community_all
, NULL
);
7566 DEFUN (show_bgp_community_all
,
7567 show_bgp_community_all_cmd
,
7568 "show bgp community",
7571 "Display routes matching the communities\n")
7573 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
7574 bgp_show_type_community_all
, NULL
);
7577 ALIAS (show_bgp_community_all
,
7578 show_bgp_ipv6_community_all_cmd
,
7579 "show bgp ipv6 community",
7583 "Display routes matching the communities\n")
7586 DEFUN (show_ipv6_bgp_community_all
,
7587 show_ipv6_bgp_community_all_cmd
,
7588 "show ipv6 bgp community",
7592 "Display routes matching the communities\n")
7594 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
7595 bgp_show_type_community_all
, NULL
);
7599 DEFUN (show_ipv6_mbgp_community_all
,
7600 show_ipv6_mbgp_community_all_cmd
,
7601 "show ipv6 mbgp community",
7605 "Display routes matching the communities\n")
7607 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
7608 bgp_show_type_community_all
, NULL
);
7610 #endif /* HAVE_IPV6 */
7613 bgp_show_community (struct vty
*vty
, const char *view_name
, int argc
,
7614 const char **argv
, int exact
, afi_t afi
, safi_t safi
)
7616 struct community
*com
;
7623 /* BGP structure lookup */
7626 bgp
= bgp_lookup_by_name (view_name
);
7629 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
7635 bgp
= bgp_get_default ();
7638 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
7643 b
= buffer_new (1024);
7644 for (i
= 0; i
< argc
; i
++)
7647 buffer_putc (b
, ' ');
7650 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
7655 buffer_putstr (b
, argv
[i
]);
7657 buffer_putc (b
, '\0');
7659 str
= buffer_getstr (b
);
7662 com
= community_str2com (str
);
7663 XFREE (MTYPE_TMP
, str
);
7666 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
7670 return bgp_show (vty
, bgp
, afi
, safi
,
7671 (exact
? bgp_show_type_community_exact
:
7672 bgp_show_type_community
), com
);
7675 DEFUN (show_ip_bgp_community
,
7676 show_ip_bgp_community_cmd
,
7677 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
7681 "Display routes matching the communities\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")
7687 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
7690 ALIAS (show_ip_bgp_community
,
7691 show_ip_bgp_community2_cmd
,
7692 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7696 "Display routes matching the communities\n"
7697 "community number\n"
7698 "Do not send outside local AS (well-known community)\n"
7699 "Do not advertise to any peer (well-known community)\n"
7700 "Do not export to next AS (well-known community)\n"
7701 "community number\n"
7702 "Do not send outside local AS (well-known community)\n"
7703 "Do not advertise to any peer (well-known community)\n"
7704 "Do not export to next AS (well-known community)\n")
7706 ALIAS (show_ip_bgp_community
,
7707 show_ip_bgp_community3_cmd
,
7708 "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)",
7712 "Display routes matching the communities\n"
7713 "community number\n"
7714 "Do not send outside local AS (well-known community)\n"
7715 "Do not advertise to any peer (well-known community)\n"
7716 "Do not export to next AS (well-known community)\n"
7717 "community number\n"
7718 "Do not send outside local AS (well-known community)\n"
7719 "Do not advertise to any peer (well-known community)\n"
7720 "Do not export to next AS (well-known community)\n"
7721 "community number\n"
7722 "Do not send outside local AS (well-known community)\n"
7723 "Do not advertise to any peer (well-known community)\n"
7724 "Do not export to next AS (well-known community)\n")
7726 ALIAS (show_ip_bgp_community
,
7727 show_ip_bgp_community4_cmd
,
7728 "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)",
7732 "Display routes matching the communities\n"
7733 "community number\n"
7734 "Do not send outside local AS (well-known community)\n"
7735 "Do not advertise to any peer (well-known community)\n"
7736 "Do not export to next AS (well-known community)\n"
7737 "community number\n"
7738 "Do not send outside local AS (well-known community)\n"
7739 "Do not advertise to any peer (well-known community)\n"
7740 "Do not export to next AS (well-known community)\n"
7741 "community number\n"
7742 "Do not send outside local AS (well-known community)\n"
7743 "Do not advertise to any peer (well-known community)\n"
7744 "Do not export to next AS (well-known community)\n"
7745 "community number\n"
7746 "Do not send outside local AS (well-known community)\n"
7747 "Do not advertise to any peer (well-known community)\n"
7748 "Do not export to next AS (well-known community)\n")
7750 DEFUN (show_ip_bgp_ipv4_community
,
7751 show_ip_bgp_ipv4_community_cmd
,
7752 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
7757 "Address Family modifier\n"
7758 "Address Family modifier\n"
7759 "Display routes matching the communities\n"
7760 "community number\n"
7761 "Do not send outside local AS (well-known community)\n"
7762 "Do not advertise to any peer (well-known community)\n"
7763 "Do not export to next AS (well-known community)\n")
7765 if (strncmp (argv
[0], "m", 1) == 0)
7766 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_MULTICAST
);
7768 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
7771 ALIAS (show_ip_bgp_ipv4_community
,
7772 show_ip_bgp_ipv4_community2_cmd
,
7773 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7778 "Address Family modifier\n"
7779 "Address Family modifier\n"
7780 "Display routes matching the communities\n"
7781 "community number\n"
7782 "Do not send outside local AS (well-known community)\n"
7783 "Do not advertise to any peer (well-known community)\n"
7784 "Do not export to next AS (well-known community)\n"
7785 "community number\n"
7786 "Do not send outside local AS (well-known community)\n"
7787 "Do not advertise to any peer (well-known community)\n"
7788 "Do not export to next AS (well-known community)\n")
7790 ALIAS (show_ip_bgp_ipv4_community
,
7791 show_ip_bgp_ipv4_community3_cmd
,
7792 "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)",
7797 "Address Family modifier\n"
7798 "Address Family modifier\n"
7799 "Display routes matching the communities\n"
7800 "community number\n"
7801 "Do not send outside local AS (well-known community)\n"
7802 "Do not advertise to any peer (well-known community)\n"
7803 "Do not export to next AS (well-known community)\n"
7804 "community number\n"
7805 "Do not send outside local AS (well-known community)\n"
7806 "Do not advertise to any peer (well-known community)\n"
7807 "Do not export to next AS (well-known community)\n"
7808 "community number\n"
7809 "Do not send outside local AS (well-known community)\n"
7810 "Do not advertise to any peer (well-known community)\n"
7811 "Do not export to next AS (well-known community)\n")
7813 ALIAS (show_ip_bgp_ipv4_community
,
7814 show_ip_bgp_ipv4_community4_cmd
,
7815 "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)",
7820 "Address Family modifier\n"
7821 "Address Family modifier\n"
7822 "Display routes matching the communities\n"
7823 "community number\n"
7824 "Do not send outside local AS (well-known community)\n"
7825 "Do not advertise to any peer (well-known community)\n"
7826 "Do not export to next AS (well-known community)\n"
7827 "community number\n"
7828 "Do not send outside local AS (well-known community)\n"
7829 "Do not advertise to any peer (well-known community)\n"
7830 "Do not export to next AS (well-known community)\n"
7831 "community number\n"
7832 "Do not send outside local AS (well-known community)\n"
7833 "Do not advertise to any peer (well-known community)\n"
7834 "Do not export to next AS (well-known community)\n"
7835 "community number\n"
7836 "Do not send outside local AS (well-known community)\n"
7837 "Do not advertise to any peer (well-known community)\n"
7838 "Do not export to next AS (well-known community)\n")
7840 DEFUN (show_bgp_view_afi_safi_community_all
,
7841 show_bgp_view_afi_safi_community_all_cmd
,
7843 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community",
7845 "show bgp view WORD ipv4 (unicast|multicast) community",
7855 "Address Family modifier\n"
7856 "Address Family modifier\n"
7857 "Display routes containing communities\n")
7863 /* BGP structure lookup. */
7864 bgp
= bgp_lookup_by_name (argv
[0]);
7867 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
7872 afi
= (strncmp (argv
[1], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
7873 safi
= (strncmp (argv
[2], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
7876 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
7878 return bgp_show (vty
, bgp
, afi
, safi
, bgp_show_type_community_all
, NULL
);
7881 DEFUN (show_bgp_view_afi_safi_community
,
7882 show_bgp_view_afi_safi_community_cmd
,
7884 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
7886 "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
7896 "Address family modifier\n"
7897 "Address family modifier\n"
7898 "Display routes matching the communities\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")
7908 afi
= (strncmp (argv
[1], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
7909 safi
= (strncmp (argv
[2], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
7910 return bgp_show_community (vty
, argv
[0], argc
-3, &argv
[3], 0, afi
, safi
);
7913 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
7914 return bgp_show_community (vty
, argv
[0], argc
-2, &argv
[2], 0, afi
, safi
);
7918 ALIAS (show_bgp_view_afi_safi_community
,
7919 show_bgp_view_afi_safi_community2_cmd
,
7921 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7923 "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7933 "Address family modifier\n"
7934 "Address family modifier\n"
7935 "Display routes matching the communities\n"
7936 "community number\n"
7937 "Do not send outside local AS (well-known community)\n"
7938 "Do not advertise to any peer (well-known community)\n"
7939 "Do not export to next AS (well-known community)\n"
7940 "community number\n"
7941 "Do not send outside local AS (well-known community)\n"
7942 "Do not advertise to any peer (well-known community)\n"
7943 "Do not export to next AS (well-known community)\n")
7945 ALIAS (show_bgp_view_afi_safi_community
,
7946 show_bgp_view_afi_safi_community3_cmd
,
7948 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7950 "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7960 "Address family modifier\n"
7961 "Address family modifier\n"
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"
7967 "community number\n"
7968 "Do not send outside local AS (well-known community)\n"
7969 "Do not advertise to any peer (well-known community)\n"
7970 "Do not export to next AS (well-known community)\n"
7971 "community number\n"
7972 "Do not send outside local AS (well-known community)\n"
7973 "Do not advertise to any peer (well-known community)\n"
7974 "Do not export to next AS (well-known community)\n")
7976 ALIAS (show_bgp_view_afi_safi_community
,
7977 show_bgp_view_afi_safi_community4_cmd
,
7979 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7981 "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7991 "Address family modifier\n"
7992 "Address family modifier\n"
7993 "Display routes matching the communities\n"
7994 "community number\n"
7995 "Do not send outside local AS (well-known community)\n"
7996 "Do not advertise to any peer (well-known community)\n"
7997 "Do not export to next AS (well-known community)\n"
7998 "community number\n"
7999 "Do not send outside local AS (well-known community)\n"
8000 "Do not advertise to any peer (well-known community)\n"
8001 "Do not export to next AS (well-known community)\n"
8002 "community number\n"
8003 "Do not send outside local AS (well-known community)\n"
8004 "Do not advertise to any peer (well-known community)\n"
8005 "Do not export to next AS (well-known community)\n"
8006 "community number\n"
8007 "Do not send outside local AS (well-known community)\n"
8008 "Do not advertise to any peer (well-known community)\n"
8009 "Do not export to next AS (well-known community)\n")
8011 DEFUN (show_ip_bgp_community_exact
,
8012 show_ip_bgp_community_exact_cmd
,
8013 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8017 "Display routes matching the communities\n"
8018 "community number\n"
8019 "Do not send outside local AS (well-known community)\n"
8020 "Do not advertise to any peer (well-known community)\n"
8021 "Do not export to next AS (well-known community)\n"
8022 "Exact match of the communities")
8024 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
8027 ALIAS (show_ip_bgp_community_exact
,
8028 show_ip_bgp_community2_exact_cmd
,
8029 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8033 "Display routes matching the communities\n"
8034 "community number\n"
8035 "Do not send outside local AS (well-known community)\n"
8036 "Do not advertise to any peer (well-known community)\n"
8037 "Do not export to next AS (well-known community)\n"
8038 "community number\n"
8039 "Do not send outside local AS (well-known community)\n"
8040 "Do not advertise to any peer (well-known community)\n"
8041 "Do not export to next AS (well-known community)\n"
8042 "Exact match of the communities")
8044 ALIAS (show_ip_bgp_community_exact
,
8045 show_ip_bgp_community3_exact_cmd
,
8046 "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",
8050 "Display routes matching the communities\n"
8051 "community number\n"
8052 "Do not send outside local AS (well-known community)\n"
8053 "Do not advertise to any peer (well-known community)\n"
8054 "Do not export to next AS (well-known community)\n"
8055 "community number\n"
8056 "Do not send outside local AS (well-known community)\n"
8057 "Do not advertise to any peer (well-known community)\n"
8058 "Do not export to next AS (well-known community)\n"
8059 "community number\n"
8060 "Do not send outside local AS (well-known community)\n"
8061 "Do not advertise to any peer (well-known community)\n"
8062 "Do not export to next AS (well-known community)\n"
8063 "Exact match of the communities")
8065 ALIAS (show_ip_bgp_community_exact
,
8066 show_ip_bgp_community4_exact_cmd
,
8067 "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",
8071 "Display routes matching the communities\n"
8072 "community number\n"
8073 "Do not send outside local AS (well-known community)\n"
8074 "Do not advertise to any peer (well-known community)\n"
8075 "Do not export to next AS (well-known community)\n"
8076 "community number\n"
8077 "Do not send outside local AS (well-known community)\n"
8078 "Do not advertise to any peer (well-known community)\n"
8079 "Do not export to next AS (well-known community)\n"
8080 "community number\n"
8081 "Do not send outside local AS (well-known community)\n"
8082 "Do not advertise to any peer (well-known community)\n"
8083 "Do not export to next AS (well-known community)\n"
8084 "community number\n"
8085 "Do not send outside local AS (well-known community)\n"
8086 "Do not advertise to any peer (well-known community)\n"
8087 "Do not export to next AS (well-known community)\n"
8088 "Exact match of the communities")
8090 DEFUN (show_ip_bgp_ipv4_community_exact
,
8091 show_ip_bgp_ipv4_community_exact_cmd
,
8092 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8097 "Address Family modifier\n"
8098 "Address Family modifier\n"
8099 "Display routes matching the communities\n"
8100 "community number\n"
8101 "Do not send outside local AS (well-known community)\n"
8102 "Do not advertise to any peer (well-known community)\n"
8103 "Do not export to next AS (well-known community)\n"
8104 "Exact match of the communities")
8106 if (strncmp (argv
[0], "m", 1) == 0)
8107 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_MULTICAST
);
8109 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
8112 ALIAS (show_ip_bgp_ipv4_community_exact
,
8113 show_ip_bgp_ipv4_community2_exact_cmd
,
8114 "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",
8119 "Address Family modifier\n"
8120 "Address Family modifier\n"
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 "Exact match of the communities")
8132 ALIAS (show_ip_bgp_ipv4_community_exact
,
8133 show_ip_bgp_ipv4_community3_exact_cmd
,
8134 "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",
8139 "Address Family modifier\n"
8140 "Address Family modifier\n"
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 "Exact match of the communities")
8156 ALIAS (show_ip_bgp_ipv4_community_exact
,
8157 show_ip_bgp_ipv4_community4_exact_cmd
,
8158 "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",
8163 "Address Family modifier\n"
8164 "Address Family modifier\n"
8165 "Display routes matching the communities\n"
8166 "community number\n"
8167 "Do not send outside local AS (well-known community)\n"
8168 "Do not advertise to any peer (well-known community)\n"
8169 "Do not export to next AS (well-known community)\n"
8170 "community number\n"
8171 "Do not send outside local AS (well-known community)\n"
8172 "Do not advertise to any peer (well-known community)\n"
8173 "Do not export to next AS (well-known community)\n"
8174 "community number\n"
8175 "Do not send outside local AS (well-known community)\n"
8176 "Do not advertise to any peer (well-known community)\n"
8177 "Do not export to next AS (well-known community)\n"
8178 "community number\n"
8179 "Do not send outside local AS (well-known community)\n"
8180 "Do not advertise to any peer (well-known community)\n"
8181 "Do not export to next AS (well-known community)\n"
8182 "Exact match of the communities")
8185 DEFUN (show_bgp_community
,
8186 show_bgp_community_cmd
,
8187 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
8190 "Display routes matching the communities\n"
8191 "community number\n"
8192 "Do not send outside local AS (well-known community)\n"
8193 "Do not advertise to any peer (well-known community)\n"
8194 "Do not export to next AS (well-known community)\n")
8196 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
8199 ALIAS (show_bgp_community
,
8200 show_bgp_ipv6_community_cmd
,
8201 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
8205 "Display routes matching the communities\n"
8206 "community number\n"
8207 "Do not send outside local AS (well-known community)\n"
8208 "Do not advertise to any peer (well-known community)\n"
8209 "Do not export to next AS (well-known community)\n")
8211 ALIAS (show_bgp_community
,
8212 show_bgp_community2_cmd
,
8213 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8216 "Display routes matching the communities\n"
8217 "community number\n"
8218 "Do not send outside local AS (well-known community)\n"
8219 "Do not advertise to any peer (well-known community)\n"
8220 "Do not export to next AS (well-known community)\n"
8221 "community number\n"
8222 "Do not send outside local AS (well-known community)\n"
8223 "Do not advertise to any peer (well-known community)\n"
8224 "Do not export to next AS (well-known community)\n")
8226 ALIAS (show_bgp_community
,
8227 show_bgp_ipv6_community2_cmd
,
8228 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8232 "Display routes matching the communities\n"
8233 "community number\n"
8234 "Do not send outside local AS (well-known community)\n"
8235 "Do not advertise to any peer (well-known community)\n"
8236 "Do not export to next AS (well-known community)\n"
8237 "community number\n"
8238 "Do not send outside local AS (well-known community)\n"
8239 "Do not advertise to any peer (well-known community)\n"
8240 "Do not export to next AS (well-known community)\n")
8242 ALIAS (show_bgp_community
,
8243 show_bgp_community3_cmd
,
8244 "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)",
8247 "Display routes matching the communities\n"
8248 "community number\n"
8249 "Do not send outside local AS (well-known community)\n"
8250 "Do not advertise to any peer (well-known community)\n"
8251 "Do not export to next AS (well-known community)\n"
8252 "community number\n"
8253 "Do not send outside local AS (well-known community)\n"
8254 "Do not advertise to any peer (well-known community)\n"
8255 "Do not export to next AS (well-known community)\n"
8256 "community number\n"
8257 "Do not send outside local AS (well-known community)\n"
8258 "Do not advertise to any peer (well-known community)\n"
8259 "Do not export to next AS (well-known community)\n")
8261 ALIAS (show_bgp_community
,
8262 show_bgp_ipv6_community3_cmd
,
8263 "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)",
8267 "Display routes matching the communities\n"
8268 "community number\n"
8269 "Do not send outside local AS (well-known community)\n"
8270 "Do not advertise to any peer (well-known community)\n"
8271 "Do not export to next AS (well-known community)\n"
8272 "community number\n"
8273 "Do not send outside local AS (well-known community)\n"
8274 "Do not advertise to any peer (well-known community)\n"
8275 "Do not export to next AS (well-known community)\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 ALIAS (show_bgp_community
,
8282 show_bgp_community4_cmd
,
8283 "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)",
8286 "Display routes matching the communities\n"
8287 "community number\n"
8288 "Do not send outside local AS (well-known community)\n"
8289 "Do not advertise to any peer (well-known community)\n"
8290 "Do not export to next AS (well-known community)\n"
8291 "community number\n"
8292 "Do not send outside local AS (well-known community)\n"
8293 "Do not advertise to any peer (well-known community)\n"
8294 "Do not export to next AS (well-known community)\n"
8295 "community number\n"
8296 "Do not send outside local AS (well-known community)\n"
8297 "Do not advertise to any peer (well-known community)\n"
8298 "Do not export to next AS (well-known community)\n"
8299 "community number\n"
8300 "Do not send outside local AS (well-known community)\n"
8301 "Do not advertise to any peer (well-known community)\n"
8302 "Do not export to next AS (well-known community)\n")
8304 ALIAS (show_bgp_community
,
8305 show_bgp_ipv6_community4_cmd
,
8306 "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)",
8310 "Display routes matching the communities\n"
8311 "community number\n"
8312 "Do not send outside local AS (well-known community)\n"
8313 "Do not advertise to any peer (well-known community)\n"
8314 "Do not export to next AS (well-known community)\n"
8315 "community number\n"
8316 "Do not send outside local AS (well-known community)\n"
8317 "Do not advertise to any peer (well-known community)\n"
8318 "Do not export to next AS (well-known community)\n"
8319 "community number\n"
8320 "Do not send outside local AS (well-known community)\n"
8321 "Do not advertise to any peer (well-known community)\n"
8322 "Do not export to next AS (well-known community)\n"
8323 "community number\n"
8324 "Do not send outside local AS (well-known community)\n"
8325 "Do not advertise to any peer (well-known community)\n"
8326 "Do not export to next AS (well-known community)\n")
8329 DEFUN (show_ipv6_bgp_community
,
8330 show_ipv6_bgp_community_cmd
,
8331 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
8335 "Display routes matching the communities\n"
8336 "community number\n"
8337 "Do not send outside local AS (well-known community)\n"
8338 "Do not advertise to any peer (well-known community)\n"
8339 "Do not export to next AS (well-known community)\n")
8341 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
8345 ALIAS (show_ipv6_bgp_community
,
8346 show_ipv6_bgp_community2_cmd
,
8347 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8351 "Display routes matching the communities\n"
8352 "community number\n"
8353 "Do not send outside local AS (well-known community)\n"
8354 "Do not advertise to any peer (well-known community)\n"
8355 "Do not export to next AS (well-known community)\n"
8356 "community number\n"
8357 "Do not send outside local AS (well-known community)\n"
8358 "Do not advertise to any peer (well-known community)\n"
8359 "Do not export to next AS (well-known community)\n")
8362 ALIAS (show_ipv6_bgp_community
,
8363 show_ipv6_bgp_community3_cmd
,
8364 "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)",
8368 "Display routes matching the communities\n"
8369 "community number\n"
8370 "Do not send outside local AS (well-known community)\n"
8371 "Do not advertise to any peer (well-known community)\n"
8372 "Do not export to next AS (well-known community)\n"
8373 "community number\n"
8374 "Do not send outside local AS (well-known community)\n"
8375 "Do not advertise to any peer (well-known community)\n"
8376 "Do not export to next AS (well-known community)\n"
8377 "community number\n"
8378 "Do not send outside local AS (well-known community)\n"
8379 "Do not advertise to any peer (well-known community)\n"
8380 "Do not export to next AS (well-known community)\n")
8383 ALIAS (show_ipv6_bgp_community
,
8384 show_ipv6_bgp_community4_cmd
,
8385 "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)",
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 "community number\n"
8403 "Do not send outside local AS (well-known community)\n"
8404 "Do not advertise to any peer (well-known community)\n"
8405 "Do not export to next AS (well-known community)\n")
8407 DEFUN (show_bgp_community_exact
,
8408 show_bgp_community_exact_cmd
,
8409 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8412 "Display routes matching the communities\n"
8413 "community number\n"
8414 "Do not send outside local AS (well-known community)\n"
8415 "Do not advertise to any peer (well-known community)\n"
8416 "Do not export to next AS (well-known community)\n"
8417 "Exact match of the communities")
8419 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
8422 ALIAS (show_bgp_community_exact
,
8423 show_bgp_ipv6_community_exact_cmd
,
8424 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8428 "Display routes matching the communities\n"
8429 "community number\n"
8430 "Do not send outside local AS (well-known community)\n"
8431 "Do not advertise to any peer (well-known community)\n"
8432 "Do not export to next AS (well-known community)\n"
8433 "Exact match of the communities")
8435 ALIAS (show_bgp_community_exact
,
8436 show_bgp_community2_exact_cmd
,
8437 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8440 "Display routes matching the communities\n"
8441 "community number\n"
8442 "Do not send outside local AS (well-known community)\n"
8443 "Do not advertise to any peer (well-known community)\n"
8444 "Do not export to next AS (well-known community)\n"
8445 "community number\n"
8446 "Do not send outside local AS (well-known community)\n"
8447 "Do not advertise to any peer (well-known community)\n"
8448 "Do not export to next AS (well-known community)\n"
8449 "Exact match of the communities")
8451 ALIAS (show_bgp_community_exact
,
8452 show_bgp_ipv6_community2_exact_cmd
,
8453 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8457 "Display routes matching the communities\n"
8458 "community number\n"
8459 "Do not send outside local AS (well-known community)\n"
8460 "Do not advertise to any peer (well-known community)\n"
8461 "Do not export to next AS (well-known community)\n"
8462 "community number\n"
8463 "Do not send outside local AS (well-known community)\n"
8464 "Do not advertise to any peer (well-known community)\n"
8465 "Do not export to next AS (well-known community)\n"
8466 "Exact match of the communities")
8468 ALIAS (show_bgp_community_exact
,
8469 show_bgp_community3_exact_cmd
,
8470 "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",
8473 "Display routes matching the communities\n"
8474 "community number\n"
8475 "Do not send outside local AS (well-known community)\n"
8476 "Do not advertise to any peer (well-known community)\n"
8477 "Do not export to next AS (well-known community)\n"
8478 "community number\n"
8479 "Do not send outside local AS (well-known community)\n"
8480 "Do not advertise to any peer (well-known community)\n"
8481 "Do not export to next AS (well-known community)\n"
8482 "community number\n"
8483 "Do not send outside local AS (well-known community)\n"
8484 "Do not advertise to any peer (well-known community)\n"
8485 "Do not export to next AS (well-known community)\n"
8486 "Exact match of the communities")
8488 ALIAS (show_bgp_community_exact
,
8489 show_bgp_ipv6_community3_exact_cmd
,
8490 "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",
8494 "Display routes matching the communities\n"
8495 "community number\n"
8496 "Do not send outside local AS (well-known community)\n"
8497 "Do not advertise to any peer (well-known community)\n"
8498 "Do not export to next AS (well-known community)\n"
8499 "community number\n"
8500 "Do not send outside local AS (well-known community)\n"
8501 "Do not advertise to any peer (well-known community)\n"
8502 "Do not export to next AS (well-known community)\n"
8503 "community number\n"
8504 "Do not send outside local AS (well-known community)\n"
8505 "Do not advertise to any peer (well-known community)\n"
8506 "Do not export to next AS (well-known community)\n"
8507 "Exact match of the communities")
8509 ALIAS (show_bgp_community_exact
,
8510 show_bgp_community4_exact_cmd
,
8511 "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",
8514 "Display routes matching the communities\n"
8515 "community number\n"
8516 "Do not send outside local AS (well-known community)\n"
8517 "Do not advertise to any peer (well-known community)\n"
8518 "Do not export to next AS (well-known community)\n"
8519 "community number\n"
8520 "Do not send outside local AS (well-known community)\n"
8521 "Do not advertise to any peer (well-known community)\n"
8522 "Do not export to next AS (well-known community)\n"
8523 "community number\n"
8524 "Do not send outside local AS (well-known community)\n"
8525 "Do not advertise to any peer (well-known community)\n"
8526 "Do not export to next AS (well-known community)\n"
8527 "community number\n"
8528 "Do not send outside local AS (well-known community)\n"
8529 "Do not advertise to any peer (well-known community)\n"
8530 "Do not export to next AS (well-known community)\n"
8531 "Exact match of the communities")
8533 ALIAS (show_bgp_community_exact
,
8534 show_bgp_ipv6_community4_exact_cmd
,
8535 "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",
8539 "Display routes matching the communities\n"
8540 "community number\n"
8541 "Do not send outside local AS (well-known community)\n"
8542 "Do not advertise to any peer (well-known community)\n"
8543 "Do not export to next AS (well-known community)\n"
8544 "community number\n"
8545 "Do not send outside local AS (well-known community)\n"
8546 "Do not advertise to any peer (well-known community)\n"
8547 "Do not export to next AS (well-known community)\n"
8548 "community number\n"
8549 "Do not send outside local AS (well-known community)\n"
8550 "Do not advertise to any peer (well-known community)\n"
8551 "Do not export to next AS (well-known community)\n"
8552 "community number\n"
8553 "Do not send outside local AS (well-known community)\n"
8554 "Do not advertise to any peer (well-known community)\n"
8555 "Do not export to next AS (well-known community)\n"
8556 "Exact match of the communities")
8559 DEFUN (show_ipv6_bgp_community_exact
,
8560 show_ipv6_bgp_community_exact_cmd
,
8561 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8565 "Display routes matching the communities\n"
8566 "community number\n"
8567 "Do not send outside local AS (well-known community)\n"
8568 "Do not advertise to any peer (well-known community)\n"
8569 "Do not export to next AS (well-known community)\n"
8570 "Exact match of the communities")
8572 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
8576 ALIAS (show_ipv6_bgp_community_exact
,
8577 show_ipv6_bgp_community2_exact_cmd
,
8578 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8582 "Display routes matching the communities\n"
8583 "community number\n"
8584 "Do not send outside local AS (well-known community)\n"
8585 "Do not advertise to any peer (well-known community)\n"
8586 "Do not export to next AS (well-known community)\n"
8587 "community number\n"
8588 "Do not send outside local AS (well-known community)\n"
8589 "Do not advertise to any peer (well-known community)\n"
8590 "Do not export to next AS (well-known community)\n"
8591 "Exact match of the communities")
8594 ALIAS (show_ipv6_bgp_community_exact
,
8595 show_ipv6_bgp_community3_exact_cmd
,
8596 "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",
8600 "Display routes matching the communities\n"
8601 "community number\n"
8602 "Do not send outside local AS (well-known community)\n"
8603 "Do not advertise to any peer (well-known community)\n"
8604 "Do not export to next AS (well-known community)\n"
8605 "community number\n"
8606 "Do not send outside local AS (well-known community)\n"
8607 "Do not advertise to any peer (well-known community)\n"
8608 "Do not export to next AS (well-known community)\n"
8609 "community number\n"
8610 "Do not send outside local AS (well-known community)\n"
8611 "Do not advertise to any peer (well-known community)\n"
8612 "Do not export to next AS (well-known community)\n"
8613 "Exact match of the communities")
8616 ALIAS (show_ipv6_bgp_community_exact
,
8617 show_ipv6_bgp_community4_exact_cmd
,
8618 "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",
8622 "Display routes matching the communities\n"
8623 "community number\n"
8624 "Do not send outside local AS (well-known community)\n"
8625 "Do not advertise to any peer (well-known community)\n"
8626 "Do not export to next AS (well-known community)\n"
8627 "community number\n"
8628 "Do not send outside local AS (well-known community)\n"
8629 "Do not advertise to any peer (well-known community)\n"
8630 "Do not export to next AS (well-known community)\n"
8631 "community number\n"
8632 "Do not send outside local AS (well-known community)\n"
8633 "Do not advertise to any peer (well-known community)\n"
8634 "Do not export to next AS (well-known community)\n"
8635 "community number\n"
8636 "Do not send outside local AS (well-known community)\n"
8637 "Do not advertise to any peer (well-known community)\n"
8638 "Do not export to next AS (well-known community)\n"
8639 "Exact match of the communities")
8642 DEFUN (show_ipv6_mbgp_community
,
8643 show_ipv6_mbgp_community_cmd
,
8644 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
8648 "Display routes matching the communities\n"
8649 "community number\n"
8650 "Do not send outside local AS (well-known community)\n"
8651 "Do not advertise to any peer (well-known community)\n"
8652 "Do not export to next AS (well-known community)\n")
8654 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
8658 ALIAS (show_ipv6_mbgp_community
,
8659 show_ipv6_mbgp_community2_cmd
,
8660 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8664 "Display routes matching the communities\n"
8665 "community number\n"
8666 "Do not send outside local AS (well-known community)\n"
8667 "Do not advertise to any peer (well-known community)\n"
8668 "Do not export to next AS (well-known community)\n"
8669 "community number\n"
8670 "Do not send outside local AS (well-known community)\n"
8671 "Do not advertise to any peer (well-known community)\n"
8672 "Do not export to next AS (well-known community)\n")
8675 ALIAS (show_ipv6_mbgp_community
,
8676 show_ipv6_mbgp_community3_cmd
,
8677 "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)",
8681 "Display routes matching the communities\n"
8682 "community number\n"
8683 "Do not send outside local AS (well-known community)\n"
8684 "Do not advertise to any peer (well-known community)\n"
8685 "Do not export to next AS (well-known community)\n"
8686 "community number\n"
8687 "Do not send outside local AS (well-known community)\n"
8688 "Do not advertise to any peer (well-known community)\n"
8689 "Do not export to next AS (well-known community)\n"
8690 "community number\n"
8691 "Do not send outside local AS (well-known community)\n"
8692 "Do not advertise to any peer (well-known community)\n"
8693 "Do not export to next AS (well-known community)\n")
8696 ALIAS (show_ipv6_mbgp_community
,
8697 show_ipv6_mbgp_community4_cmd
,
8698 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8702 "Display routes matching the communities\n"
8703 "community number\n"
8704 "Do not send outside local AS (well-known community)\n"
8705 "Do not advertise to any peer (well-known community)\n"
8706 "Do not export to next AS (well-known community)\n"
8707 "community number\n"
8708 "Do not send outside local AS (well-known community)\n"
8709 "Do not advertise to any peer (well-known community)\n"
8710 "Do not export to next AS (well-known community)\n"
8711 "community number\n"
8712 "Do not send outside local AS (well-known community)\n"
8713 "Do not advertise to any peer (well-known community)\n"
8714 "Do not export to next AS (well-known community)\n"
8715 "community number\n"
8716 "Do not send outside local AS (well-known community)\n"
8717 "Do not advertise to any peer (well-known community)\n"
8718 "Do not export to next AS (well-known community)\n")
8721 DEFUN (show_ipv6_mbgp_community_exact
,
8722 show_ipv6_mbgp_community_exact_cmd
,
8723 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8727 "Display routes matching the communities\n"
8728 "community number\n"
8729 "Do not send outside local AS (well-known community)\n"
8730 "Do not advertise to any peer (well-known community)\n"
8731 "Do not export to next AS (well-known community)\n"
8732 "Exact match of the communities")
8734 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
8738 ALIAS (show_ipv6_mbgp_community_exact
,
8739 show_ipv6_mbgp_community2_exact_cmd
,
8740 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8744 "Display routes matching the communities\n"
8745 "community number\n"
8746 "Do not send outside local AS (well-known community)\n"
8747 "Do not advertise to any peer (well-known community)\n"
8748 "Do not export to next AS (well-known community)\n"
8749 "community number\n"
8750 "Do not send outside local AS (well-known community)\n"
8751 "Do not advertise to any peer (well-known community)\n"
8752 "Do not export to next AS (well-known community)\n"
8753 "Exact match of the communities")
8756 ALIAS (show_ipv6_mbgp_community_exact
,
8757 show_ipv6_mbgp_community3_exact_cmd
,
8758 "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",
8762 "Display routes matching the communities\n"
8763 "community number\n"
8764 "Do not send outside local AS (well-known community)\n"
8765 "Do not advertise to any peer (well-known community)\n"
8766 "Do not export to next AS (well-known community)\n"
8767 "community number\n"
8768 "Do not send outside local AS (well-known community)\n"
8769 "Do not advertise to any peer (well-known community)\n"
8770 "Do not export to next AS (well-known community)\n"
8771 "community number\n"
8772 "Do not send outside local AS (well-known community)\n"
8773 "Do not advertise to any peer (well-known community)\n"
8774 "Do not export to next AS (well-known community)\n"
8775 "Exact match of the communities")
8778 ALIAS (show_ipv6_mbgp_community_exact
,
8779 show_ipv6_mbgp_community4_exact_cmd
,
8780 "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",
8784 "Display routes matching the communities\n"
8785 "community number\n"
8786 "Do not send outside local AS (well-known community)\n"
8787 "Do not advertise to any peer (well-known community)\n"
8788 "Do not export to next AS (well-known community)\n"
8789 "community number\n"
8790 "Do not send outside local AS (well-known community)\n"
8791 "Do not advertise to any peer (well-known community)\n"
8792 "Do not export to next AS (well-known community)\n"
8793 "community number\n"
8794 "Do not send outside local AS (well-known community)\n"
8795 "Do not advertise to any peer (well-known community)\n"
8796 "Do not export to next AS (well-known community)\n"
8797 "community number\n"
8798 "Do not send outside local AS (well-known community)\n"
8799 "Do not advertise to any peer (well-known community)\n"
8800 "Do not export to next AS (well-known community)\n"
8801 "Exact match of the communities")
8802 #endif /* HAVE_IPV6 */
8805 bgp_show_community_list (struct vty
*vty
, const char *com
, int exact
,
8806 afi_t afi
, safi_t safi
)
8808 struct community_list
*list
;
8810 list
= community_list_lookup (bgp_clist
, com
, COMMUNITY_LIST_MASTER
);
8813 vty_out (vty
, "%% %s is not a valid community-list name%s", com
,
8818 return bgp_show (vty
, NULL
, afi
, safi
,
8819 (exact
? bgp_show_type_community_list_exact
:
8820 bgp_show_type_community_list
), list
);
8823 DEFUN (show_ip_bgp_community_list
,
8824 show_ip_bgp_community_list_cmd
,
8825 "show ip bgp community-list (<1-500>|WORD)",
8829 "Display routes matching the community-list\n"
8830 "community-list number\n"
8831 "community-list name\n")
8833 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP
, SAFI_UNICAST
);
8836 DEFUN (show_ip_bgp_ipv4_community_list
,
8837 show_ip_bgp_ipv4_community_list_cmd
,
8838 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
8843 "Address Family modifier\n"
8844 "Address Family modifier\n"
8845 "Display routes matching the community-list\n"
8846 "community-list number\n"
8847 "community-list name\n")
8849 if (strncmp (argv
[0], "m", 1) == 0)
8850 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_MULTICAST
);
8852 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_UNICAST
);
8855 DEFUN (show_ip_bgp_community_list_exact
,
8856 show_ip_bgp_community_list_exact_cmd
,
8857 "show ip bgp community-list (<1-500>|WORD) exact-match",
8861 "Display routes matching the community-list\n"
8862 "community-list number\n"
8863 "community-list name\n"
8864 "Exact match of the communities\n")
8866 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP
, SAFI_UNICAST
);
8869 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
8870 show_ip_bgp_ipv4_community_list_exact_cmd
,
8871 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
8876 "Address Family modifier\n"
8877 "Address Family modifier\n"
8878 "Display routes matching the community-list\n"
8879 "community-list number\n"
8880 "community-list name\n"
8881 "Exact match of the communities\n")
8883 if (strncmp (argv
[0], "m", 1) == 0)
8884 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_MULTICAST
);
8886 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_UNICAST
);
8890 DEFUN (show_bgp_community_list
,
8891 show_bgp_community_list_cmd
,
8892 "show bgp community-list (<1-500>|WORD)",
8895 "Display routes matching the community-list\n"
8896 "community-list number\n"
8897 "community-list name\n")
8899 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
8902 ALIAS (show_bgp_community_list
,
8903 show_bgp_ipv6_community_list_cmd
,
8904 "show bgp ipv6 community-list (<1-500>|WORD)",
8908 "Display routes matching the community-list\n"
8909 "community-list number\n"
8910 "community-list name\n")
8913 DEFUN (show_ipv6_bgp_community_list
,
8914 show_ipv6_bgp_community_list_cmd
,
8915 "show ipv6 bgp community-list WORD",
8919 "Display routes matching the community-list\n"
8920 "community-list name\n")
8922 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
8926 DEFUN (show_ipv6_mbgp_community_list
,
8927 show_ipv6_mbgp_community_list_cmd
,
8928 "show ipv6 mbgp community-list WORD",
8932 "Display routes matching the community-list\n"
8933 "community-list name\n")
8935 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_MULTICAST
);
8938 DEFUN (show_bgp_community_list_exact
,
8939 show_bgp_community_list_exact_cmd
,
8940 "show bgp community-list (<1-500>|WORD) exact-match",
8943 "Display routes matching the community-list\n"
8944 "community-list number\n"
8945 "community-list name\n"
8946 "Exact match of the communities\n")
8948 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
8951 ALIAS (show_bgp_community_list_exact
,
8952 show_bgp_ipv6_community_list_exact_cmd
,
8953 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
8957 "Display routes matching the community-list\n"
8958 "community-list number\n"
8959 "community-list name\n"
8960 "Exact match of the communities\n")
8963 DEFUN (show_ipv6_bgp_community_list_exact
,
8964 show_ipv6_bgp_community_list_exact_cmd
,
8965 "show ipv6 bgp community-list WORD exact-match",
8969 "Display routes matching the community-list\n"
8970 "community-list name\n"
8971 "Exact match of the communities\n")
8973 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
8977 DEFUN (show_ipv6_mbgp_community_list_exact
,
8978 show_ipv6_mbgp_community_list_exact_cmd
,
8979 "show ipv6 mbgp community-list WORD exact-match",
8983 "Display routes matching the community-list\n"
8984 "community-list name\n"
8985 "Exact match of the communities\n")
8987 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_MULTICAST
);
8989 #endif /* HAVE_IPV6 */
8992 bgp_show_prefix_longer (struct vty
*vty
, const char *prefix
, afi_t afi
,
8993 safi_t safi
, enum bgp_show_type type
)
9000 ret
= str2prefix (prefix
, p
);
9003 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
9007 ret
= bgp_show (vty
, NULL
, afi
, safi
, type
, p
);
9012 DEFUN (show_ip_bgp_prefix_longer
,
9013 show_ip_bgp_prefix_longer_cmd
,
9014 "show ip bgp A.B.C.D/M longer-prefixes",
9018 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
9019 "Display route and more specific routes\n")
9021 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9022 bgp_show_type_prefix_longer
);
9025 DEFUN (show_ip_bgp_flap_prefix_longer
,
9026 show_ip_bgp_flap_prefix_longer_cmd
,
9027 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
9031 "Display flap statistics of routes\n"
9032 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
9033 "Display route and more specific routes\n")
9035 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9036 bgp_show_type_flap_prefix_longer
);
9039 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
9040 show_ip_bgp_ipv4_prefix_longer_cmd
,
9041 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
9046 "Address Family modifier\n"
9047 "Address Family modifier\n"
9048 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
9049 "Display route and more specific routes\n")
9051 if (strncmp (argv
[0], "m", 1) == 0)
9052 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
9053 bgp_show_type_prefix_longer
);
9055 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
9056 bgp_show_type_prefix_longer
);
9059 DEFUN (show_ip_bgp_flap_address
,
9060 show_ip_bgp_flap_address_cmd
,
9061 "show ip bgp flap-statistics A.B.C.D",
9065 "Display flap statistics of routes\n"
9066 "Network in the BGP routing table to display\n")
9068 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9069 bgp_show_type_flap_address
);
9072 DEFUN (show_ip_bgp_flap_prefix
,
9073 show_ip_bgp_flap_prefix_cmd
,
9074 "show ip bgp flap-statistics A.B.C.D/M",
9078 "Display flap statistics of routes\n"
9079 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
9081 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9082 bgp_show_type_flap_prefix
);
9085 DEFUN (show_bgp_prefix_longer
,
9086 show_bgp_prefix_longer_cmd
,
9087 "show bgp X:X::X:X/M longer-prefixes",
9090 "IPv6 prefix <network>/<length>\n"
9091 "Display route and more specific routes\n")
9093 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9094 bgp_show_type_prefix_longer
);
9097 ALIAS (show_bgp_prefix_longer
,
9098 show_bgp_ipv6_prefix_longer_cmd
,
9099 "show bgp ipv6 X:X::X:X/M longer-prefixes",
9103 "IPv6 prefix <network>/<length>\n"
9104 "Display route and more specific routes\n")
9107 DEFUN (show_ipv6_bgp_prefix_longer
,
9108 show_ipv6_bgp_prefix_longer_cmd
,
9109 "show ipv6 bgp X:X::X:X/M longer-prefixes",
9113 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
9114 "Display route and more specific routes\n")
9116 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9117 bgp_show_type_prefix_longer
);
9121 DEFUN (show_ipv6_mbgp_prefix_longer
,
9122 show_ipv6_mbgp_prefix_longer_cmd
,
9123 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
9127 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
9128 "Display route and more specific routes\n")
9130 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
9131 bgp_show_type_prefix_longer
);
9133 #endif /* HAVE_IPV6 */
9135 static struct peer
*
9136 peer_lookup_in_view (struct vty
*vty
, const char *view_name
,
9144 /* BGP structure lookup. */
9147 bgp
= bgp_lookup_by_name (view_name
);
9150 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
9156 bgp
= bgp_get_default ();
9159 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
9164 /* Get peer sockunion. */
9165 ret
= str2sockunion (ip_str
, &su
);
9168 vty_out (vty
, "Malformed address: %s%s", ip_str
, VTY_NEWLINE
);
9172 /* Peer structure lookup. */
9173 peer
= peer_lookup (bgp
, &su
);
9176 vty_out (vty
, "No such neighbor%s", VTY_NEWLINE
);
9185 BGP_STATS_MAXBITLEN
= 0,
9189 BGP_STATS_UNAGGREGATEABLE
,
9190 BGP_STATS_MAX_AGGREGATEABLE
,
9191 BGP_STATS_AGGREGATES
,
9193 BGP_STATS_ASPATH_COUNT
,
9194 BGP_STATS_ASPATH_MAXHOPS
,
9195 BGP_STATS_ASPATH_TOTHOPS
,
9196 BGP_STATS_ASPATH_MAXSIZE
,
9197 BGP_STATS_ASPATH_TOTSIZE
,
9198 BGP_STATS_ASN_HIGHEST
,
9202 static const char *table_stats_strs
[] =
9204 [BGP_STATS_PREFIXES
] = "Total Prefixes",
9205 [BGP_STATS_TOTPLEN
] = "Average prefix length",
9206 [BGP_STATS_RIB
] = "Total Advertisements",
9207 [BGP_STATS_UNAGGREGATEABLE
] = "Unaggregateable prefixes",
9208 [BGP_STATS_MAX_AGGREGATEABLE
] = "Maximum aggregateable prefixes",
9209 [BGP_STATS_AGGREGATES
] = "BGP Aggregate advertisements",
9210 [BGP_STATS_SPACE
] = "Address space advertised",
9211 [BGP_STATS_ASPATH_COUNT
] = "Advertisements with paths",
9212 [BGP_STATS_ASPATH_MAXHOPS
] = "Longest AS-Path (hops)",
9213 [BGP_STATS_ASPATH_MAXSIZE
] = "Largest AS-Path (bytes)",
9214 [BGP_STATS_ASPATH_TOTHOPS
] = "Average AS-Path length (hops)",
9215 [BGP_STATS_ASPATH_TOTSIZE
] = "Average AS-Path size (bytes)",
9216 [BGP_STATS_ASN_HIGHEST
] = "Highest public ASN",
9217 [BGP_STATS_MAX
] = NULL
,
9220 struct bgp_table_stats
9222 struct bgp_table
*table
;
9223 unsigned long long counts
[BGP_STATS_MAX
];
9227 #define TALLY_SIGFIG 100000
9228 static unsigned long
9229 ravg_tally (unsigned long count
, unsigned long oldavg
, unsigned long newval
)
9231 unsigned long newtot
= (count
-1) * oldavg
+ (newval
* TALLY_SIGFIG
);
9232 unsigned long res
= (newtot
* TALLY_SIGFIG
) / count
;
9233 unsigned long ret
= newtot
/ count
;
9235 if ((res
% TALLY_SIGFIG
) > (TALLY_SIGFIG
/2))
9243 bgp_table_stats_walker (struct thread
*t
)
9245 struct bgp_node
*rn
;
9246 struct bgp_node
*top
;
9247 struct bgp_table_stats
*ts
= THREAD_ARG (t
);
9248 unsigned int space
= 0;
9250 if (!(top
= bgp_table_top (ts
->table
)))
9253 switch (top
->p
.family
)
9256 space
= IPV4_MAX_BITLEN
;
9259 space
= IPV6_MAX_BITLEN
;
9263 ts
->counts
[BGP_STATS_MAXBITLEN
] = space
;
9265 for (rn
= top
; rn
; rn
= bgp_route_next (rn
))
9267 struct bgp_info
*ri
;
9268 struct bgp_node
*prn
= rn
->parent
;
9269 unsigned int rinum
= 0;
9277 ts
->counts
[BGP_STATS_PREFIXES
]++;
9278 ts
->counts
[BGP_STATS_TOTPLEN
] += rn
->p
.prefixlen
;
9281 ts
->counts
[BGP_STATS_AVGPLEN
]
9282 = ravg_tally (ts
->counts
[BGP_STATS_PREFIXES
],
9283 ts
->counts
[BGP_STATS_AVGPLEN
],
9287 /* check if the prefix is included by any other announcements */
9288 while (prn
&& !prn
->info
)
9291 if (prn
== NULL
|| prn
== top
)
9293 ts
->counts
[BGP_STATS_UNAGGREGATEABLE
]++;
9294 /* announced address space */
9296 ts
->counts
[BGP_STATS_SPACE
] += 1 << (space
- rn
->p
.prefixlen
);
9299 ts
->counts
[BGP_STATS_MAX_AGGREGATEABLE
]++;
9301 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
9304 ts
->counts
[BGP_STATS_RIB
]++;
9307 (CHECK_FLAG (ri
->attr
->flag
,
9308 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
))))
9309 ts
->counts
[BGP_STATS_AGGREGATES
]++;
9312 if (ri
->attr
&& ri
->attr
->aspath
)
9314 unsigned int hops
= aspath_count_hops (ri
->attr
->aspath
);
9315 unsigned int size
= aspath_size (ri
->attr
->aspath
);
9316 as_t highest
= aspath_highest (ri
->attr
->aspath
);
9318 ts
->counts
[BGP_STATS_ASPATH_COUNT
]++;
9320 if (hops
> ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
])
9321 ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
] = hops
;
9323 if (size
> ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
])
9324 ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
] = size
;
9326 ts
->counts
[BGP_STATS_ASPATH_TOTHOPS
] += hops
;
9327 ts
->counts
[BGP_STATS_ASPATH_TOTSIZE
] += size
;
9329 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
]
9330 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
9331 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
],
9333 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
]
9334 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
9335 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
],
9338 if (highest
> ts
->counts
[BGP_STATS_ASN_HIGHEST
])
9339 ts
->counts
[BGP_STATS_ASN_HIGHEST
] = highest
;
9347 bgp_table_stats (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
)
9349 struct bgp_table_stats ts
;
9352 if (!bgp
->rib
[afi
][safi
])
9354 vty_out (vty
, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE
);
9358 memset (&ts
, 0, sizeof (ts
));
9359 ts
.table
= bgp
->rib
[afi
][safi
];
9360 thread_execute (bm
->master
, bgp_table_stats_walker
, &ts
, 0);
9362 vty_out (vty
, "BGP %s RIB statistics%s%s",
9363 afi_safi_print (afi
, safi
), VTY_NEWLINE
, VTY_NEWLINE
);
9365 for (i
= 0; i
< BGP_STATS_MAX
; i
++)
9367 if (!table_stats_strs
[i
])
9373 case BGP_STATS_ASPATH_AVGHOPS
:
9374 case BGP_STATS_ASPATH_AVGSIZE
:
9375 case BGP_STATS_AVGPLEN
:
9376 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9377 vty_out (vty
, "%12.2f",
9378 (float)ts
.counts
[i
] / (float)TALLY_SIGFIG
);
9381 case BGP_STATS_ASPATH_TOTHOPS
:
9382 case BGP_STATS_ASPATH_TOTSIZE
:
9383 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9384 vty_out (vty
, "%12.2f",
9386 (float)ts
.counts
[i
] /
9387 (float)ts
.counts
[BGP_STATS_ASPATH_COUNT
]
9390 case BGP_STATS_TOTPLEN
:
9391 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9392 vty_out (vty
, "%12.2f",
9394 (float)ts
.counts
[i
] /
9395 (float)ts
.counts
[BGP_STATS_PREFIXES
]
9398 case BGP_STATS_SPACE
:
9399 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9400 vty_out (vty
, "%12llu%s", ts
.counts
[i
], VTY_NEWLINE
);
9401 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 9)
9403 vty_out (vty
, "%30s: ", "%% announced ");
9404 vty_out (vty
, "%12.2f%s",
9405 100 * (float)ts
.counts
[BGP_STATS_SPACE
] /
9406 (float)((uint64_t)1UL << ts
.counts
[BGP_STATS_MAXBITLEN
]),
9408 vty_out (vty
, "%30s: ", "/8 equivalent ");
9409 vty_out (vty
, "%12.2f%s",
9410 (float)ts
.counts
[BGP_STATS_SPACE
] /
9411 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 8)),
9413 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 25)
9415 vty_out (vty
, "%30s: ", "/24 equivalent ");
9416 vty_out (vty
, "%12.2f",
9417 (float)ts
.counts
[BGP_STATS_SPACE
] /
9418 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 24)));
9421 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9422 vty_out (vty
, "%12llu", ts
.counts
[i
]);
9425 vty_out (vty
, "%s", VTY_NEWLINE
);
9431 bgp_table_stats_vty (struct vty
*vty
, const char *name
,
9432 const char *afi_str
, const char *safi_str
)
9439 bgp
= bgp_lookup_by_name (name
);
9441 bgp
= bgp_get_default ();
9445 vty_out (vty
, "%% No such BGP instance exist%s", VTY_NEWLINE
);
9448 if (strncmp (afi_str
, "ipv", 3) == 0)
9450 if (strncmp (afi_str
, "ipv4", 4) == 0)
9452 else if (strncmp (afi_str
, "ipv6", 4) == 0)
9456 vty_out (vty
, "%% Invalid address family %s%s",
9457 afi_str
, VTY_NEWLINE
);
9460 if (strncmp (safi_str
, "m", 1) == 0)
9461 safi
= SAFI_MULTICAST
;
9462 else if (strncmp (safi_str
, "u", 1) == 0)
9463 safi
= SAFI_UNICAST
;
9464 else if (strncmp (safi_str
, "vpnv4", 5) == 0)
9465 safi
= BGP_SAFI_VPNV4
;
9466 else if (strncmp (safi_str
, "vpnv6", 6) == 0)
9467 safi
= BGP_SAFI_VPNV6
;
9470 vty_out (vty
, "%% Invalid subsequent address family %s%s",
9471 safi_str
, VTY_NEWLINE
);
9477 vty_out (vty
, "%% Invalid address family %s%s",
9478 afi_str
, VTY_NEWLINE
);
9482 if ((afi
== AFI_IP
&& safi
== BGP_SAFI_VPNV6
)
9483 || (afi
== AFI_IP6
&& safi
== BGP_SAFI_VPNV4
))
9485 vty_out (vty
, "%% Invalid subsequent address family %s for %s%s",
9486 afi_str
, safi_str
, VTY_NEWLINE
);
9489 return bgp_table_stats (vty
, bgp
, afi
, safi
);
9492 DEFUN (show_bgp_statistics
,
9493 show_bgp_statistics_cmd
,
9494 "show bgp (ipv4|ipv6) (unicast|multicast) statistics",
9499 "Address Family modifier\n"
9500 "Address Family modifier\n"
9501 "BGP RIB advertisement statistics\n")
9503 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
9506 ALIAS (show_bgp_statistics
,
9507 show_bgp_statistics_vpnv4_cmd
,
9508 "show bgp (ipv4) (vpnv4) statistics",
9512 "Address Family modifier\n"
9513 "BGP RIB advertisement statistics\n")
9515 DEFUN (show_bgp_statistics_view
,
9516 show_bgp_statistics_view_cmd
,
9517 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics",
9523 "Address Family modifier\n"
9524 "Address Family modifier\n"
9525 "BGP RIB advertisement statistics\n")
9527 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
9530 ALIAS (show_bgp_statistics_view
,
9531 show_bgp_statistics_view_vpnv4_cmd
,
9532 "show bgp view WORD (ipv4) (vpnv4) statistics",
9537 "Address Family modifier\n"
9538 "BGP RIB advertisement statistics\n")
9550 PCOUNT_PFCNT
, /* the figure we display to users */
9554 static const char *pcount_strs
[] =
9556 [PCOUNT_ADJ_IN
] = "Adj-in",
9557 [PCOUNT_DAMPED
] = "Damped",
9558 [PCOUNT_REMOVED
] = "Removed",
9559 [PCOUNT_HISTORY
] = "History",
9560 [PCOUNT_STALE
] = "Stale",
9561 [PCOUNT_VALID
] = "Valid",
9562 [PCOUNT_ALL
] = "All RIB",
9563 [PCOUNT_COUNTED
] = "PfxCt counted",
9564 [PCOUNT_PFCNT
] = "Useable",
9565 [PCOUNT_MAX
] = NULL
,
9570 unsigned int count
[PCOUNT_MAX
];
9571 const struct peer
*peer
;
9572 const struct bgp_table
*table
;
9576 bgp_peer_count_walker (struct thread
*t
)
9578 struct bgp_node
*rn
;
9579 struct peer_pcounts
*pc
= THREAD_ARG (t
);
9580 const struct peer
*peer
= pc
->peer
;
9582 for (rn
= bgp_table_top (pc
->table
); rn
; rn
= bgp_route_next (rn
))
9584 struct bgp_adj_in
*ain
;
9585 struct bgp_info
*ri
;
9587 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
9588 if (ain
->peer
== peer
)
9589 pc
->count
[PCOUNT_ADJ_IN
]++;
9591 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
9593 char buf
[SU_ADDRSTRLEN
];
9595 if (ri
->peer
!= peer
)
9598 pc
->count
[PCOUNT_ALL
]++;
9600 if (CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
))
9601 pc
->count
[PCOUNT_DAMPED
]++;
9602 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
9603 pc
->count
[PCOUNT_HISTORY
]++;
9604 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
9605 pc
->count
[PCOUNT_REMOVED
]++;
9606 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
9607 pc
->count
[PCOUNT_STALE
]++;
9608 if (CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
))
9609 pc
->count
[PCOUNT_VALID
]++;
9610 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9611 pc
->count
[PCOUNT_PFCNT
]++;
9613 if (CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
9615 pc
->count
[PCOUNT_COUNTED
]++;
9616 if (CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9617 plog_warn (peer
->log
,
9618 "%s [pcount] %s/%d is counted but flags 0x%x",
9620 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
9621 buf
, SU_ADDRSTRLEN
),
9627 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9628 plog_warn (peer
->log
,
9629 "%s [pcount] %s/%d not counted but flags 0x%x",
9631 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
9632 buf
, SU_ADDRSTRLEN
),
9642 bgp_peer_counts (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
)
9644 struct peer_pcounts pcounts
= { .peer
= peer
};
9647 if (!peer
|| !peer
->bgp
|| !peer
->afc
[afi
][safi
]
9648 || !peer
->bgp
->rib
[afi
][safi
])
9650 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
9654 memset (&pcounts
, 0, sizeof(pcounts
));
9655 pcounts
.peer
= peer
;
9656 pcounts
.table
= peer
->bgp
->rib
[afi
][safi
];
9658 /* in-place call via thread subsystem so as to record execution time
9659 * stats for the thread-walk (i.e. ensure this can't be blamed on
9660 * on just vty_read()).
9662 thread_execute (bm
->master
, bgp_peer_count_walker
, &pcounts
, 0);
9664 vty_out (vty
, "Prefix counts for %s, %s%s",
9665 peer
->host
, afi_safi_print (afi
, safi
), VTY_NEWLINE
);
9666 vty_out (vty
, "PfxCt: %ld%s", peer
->pcount
[afi
][safi
], VTY_NEWLINE
);
9667 vty_out (vty
, "%sCounts from RIB table walk:%s%s",
9668 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
9670 for (i
= 0; i
< PCOUNT_MAX
; i
++)
9671 vty_out (vty
, "%20s: %-10d%s",
9672 pcount_strs
[i
], pcounts
.count
[i
], VTY_NEWLINE
);
9674 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
9676 vty_out (vty
, "%s [pcount] PfxCt drift!%s",
9677 peer
->host
, VTY_NEWLINE
);
9678 vty_out (vty
, "Please report this bug, with the above command output%s",
9685 DEFUN (show_ip_bgp_neighbor_prefix_counts
,
9686 show_ip_bgp_neighbor_prefix_counts_cmd
,
9687 "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9691 "Detailed information on TCP and BGP neighbor connections\n"
9692 "Neighbor to display information about\n"
9693 "Neighbor to display information about\n"
9694 "Display detailed prefix count information\n")
9698 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9702 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
);
9705 DEFUN (show_bgp_ipv6_neighbor_prefix_counts
,
9706 show_bgp_ipv6_neighbor_prefix_counts_cmd
,
9707 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9711 "Detailed information on TCP and BGP neighbor connections\n"
9712 "Neighbor to display information about\n"
9713 "Neighbor to display information about\n"
9714 "Display detailed prefix count information\n")
9718 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9722 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
);
9725 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts
,
9726 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
,
9727 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9732 "Address Family modifier\n"
9733 "Address Family modifier\n"
9734 "Detailed information on TCP and BGP neighbor connections\n"
9735 "Neighbor to display information about\n"
9736 "Neighbor to display information about\n"
9737 "Display detailed prefix count information\n")
9741 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9745 if (strncmp (argv
[0], "m", 1) == 0)
9746 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MULTICAST
);
9748 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
);
9751 DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts
,
9752 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
,
9753 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9758 "Address Family modifier\n"
9759 "Address Family modifier\n"
9760 "Detailed information on TCP and BGP neighbor connections\n"
9761 "Neighbor to display information about\n"
9762 "Neighbor to display information about\n"
9763 "Display detailed prefix count information\n")
9767 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9771 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MPLS_VPN
);
9776 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
9779 struct bgp_table
*table
;
9780 struct bgp_adj_in
*ain
;
9781 struct bgp_adj_out
*adj
;
9782 unsigned long output_count
;
9783 struct bgp_node
*rn
;
9793 table
= bgp
->rib
[afi
][safi
];
9797 if (! in
&& CHECK_FLAG (peer
->af_sflags
[afi
][safi
],
9798 PEER_STATUS_DEFAULT_ORIGINATE
))
9800 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9801 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9802 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9804 vty_out (vty
, "Originating default network 0.0.0.0%s%s",
9805 VTY_NEWLINE
, VTY_NEWLINE
);
9809 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
9812 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
9813 if (ain
->peer
== peer
)
9817 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9818 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9819 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9824 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
9829 route_vty_out_tmp (vty
, &rn
->p
, ain
->attr
, safi
);
9836 for (adj
= rn
->adj_out
; adj
; adj
= adj
->next
)
9837 if (adj
->peer
== peer
)
9841 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9842 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9843 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9848 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
9853 route_vty_out_tmp (vty
, &rn
->p
, adj
->attr
, safi
);
9859 if (output_count
!= 0)
9860 vty_out (vty
, "%sTotal number of prefixes %ld%s",
9861 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
9865 peer_adj_routes (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
, int in
)
9867 if (! peer
|| ! peer
->afc
[afi
][safi
])
9869 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
9873 if (in
&& ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
9875 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s",
9880 show_adj_route (vty
, peer
, afi
, safi
, in
);
9885 DEFUN (show_ip_bgp_view_neighbor_advertised_route
,
9886 show_ip_bgp_view_neighbor_advertised_route_cmd
,
9887 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9893 "Detailed information on TCP and BGP neighbor connections\n"
9894 "Neighbor to display information about\n"
9895 "Neighbor to display information about\n"
9896 "Display the routes advertised to a BGP neighbor\n")
9901 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9903 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9908 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0);
9911 ALIAS (show_ip_bgp_view_neighbor_advertised_route
,
9912 show_ip_bgp_neighbor_advertised_route_cmd
,
9913 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9917 "Detailed information on TCP and BGP neighbor connections\n"
9918 "Neighbor to display information about\n"
9919 "Neighbor to display information about\n"
9920 "Display the routes advertised to a BGP neighbor\n")
9922 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
9923 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
9924 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9929 "Address Family modifier\n"
9930 "Address Family modifier\n"
9931 "Detailed information on TCP and BGP neighbor connections\n"
9932 "Neighbor to display information about\n"
9933 "Neighbor to display information about\n"
9934 "Display the routes advertised to a BGP neighbor\n")
9938 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9942 if (strncmp (argv
[0], "m", 1) == 0)
9943 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 0);
9945 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0);
9949 DEFUN (show_bgp_view_neighbor_advertised_route
,
9950 show_bgp_view_neighbor_advertised_route_cmd
,
9951 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9956 "Detailed information on TCP and BGP neighbor connections\n"
9957 "Neighbor to display information about\n"
9958 "Neighbor to display information about\n"
9959 "Display the routes advertised to a BGP neighbor\n")
9964 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9966 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9971 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0);
9974 ALIAS (show_bgp_view_neighbor_advertised_route
,
9975 show_bgp_view_ipv6_neighbor_advertised_route_cmd
,
9976 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9982 "Detailed information on TCP and BGP neighbor connections\n"
9983 "Neighbor to display information about\n"
9984 "Neighbor to display information about\n"
9985 "Display the routes advertised to a BGP neighbor\n")
9987 DEFUN (show_bgp_view_neighbor_received_routes
,
9988 show_bgp_view_neighbor_received_routes_cmd
,
9989 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
9994 "Detailed information on TCP and BGP neighbor connections\n"
9995 "Neighbor to display information about\n"
9996 "Neighbor to display information about\n"
9997 "Display the received routes from neighbor\n")
10002 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10004 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10007 return CMD_WARNING
;
10009 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1);
10012 ALIAS (show_bgp_view_neighbor_received_routes
,
10013 show_bgp_view_ipv6_neighbor_received_routes_cmd
,
10014 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
10020 "Detailed information on TCP and BGP neighbor connections\n"
10021 "Neighbor to display information about\n"
10022 "Neighbor to display information about\n"
10023 "Display the received routes from neighbor\n")
10025 ALIAS (show_bgp_view_neighbor_advertised_route
,
10026 show_bgp_neighbor_advertised_route_cmd
,
10027 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
10030 "Detailed information on TCP and BGP neighbor connections\n"
10031 "Neighbor to display information about\n"
10032 "Neighbor to display information about\n"
10033 "Display the routes advertised to a BGP neighbor\n")
10035 ALIAS (show_bgp_view_neighbor_advertised_route
,
10036 show_bgp_ipv6_neighbor_advertised_route_cmd
,
10037 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-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 the routes advertised to a BGP neighbor\n")
10047 ALIAS (show_bgp_view_neighbor_advertised_route
,
10048 ipv6_bgp_neighbor_advertised_route_cmd
,
10049 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
10053 "Detailed information on TCP and BGP neighbor connections\n"
10054 "Neighbor to display information about\n"
10055 "Neighbor to display information about\n"
10056 "Display the routes advertised to a BGP neighbor\n")
10059 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
10060 ipv6_mbgp_neighbor_advertised_route_cmd
,
10061 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
10065 "Detailed information on TCP and BGP neighbor connections\n"
10066 "Neighbor to display information about\n"
10067 "Neighbor to display information about\n"
10068 "Display the routes advertised to a BGP neighbor\n")
10072 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10074 return CMD_WARNING
;
10076 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 0);
10078 #endif /* HAVE_IPV6 */
10080 DEFUN (show_ip_bgp_view_neighbor_received_routes
,
10081 show_ip_bgp_view_neighbor_received_routes_cmd
,
10082 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
10088 "Detailed information on TCP and BGP neighbor connections\n"
10089 "Neighbor to display information about\n"
10090 "Neighbor to display information about\n"
10091 "Display the received routes from neighbor\n")
10096 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10098 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10101 return CMD_WARNING
;
10103 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1);
10106 ALIAS (show_ip_bgp_view_neighbor_received_routes
,
10107 show_ip_bgp_neighbor_received_routes_cmd
,
10108 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
10112 "Detailed information on TCP and BGP neighbor connections\n"
10113 "Neighbor to display information about\n"
10114 "Neighbor to display information about\n"
10115 "Display the received routes from neighbor\n")
10117 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
10118 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
10119 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
10124 "Address Family modifier\n"
10125 "Address Family modifier\n"
10126 "Detailed information on TCP and BGP neighbor connections\n"
10127 "Neighbor to display information about\n"
10128 "Neighbor to display information about\n"
10129 "Display the received routes from neighbor\n")
10133 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
10135 return CMD_WARNING
;
10137 if (strncmp (argv
[0], "m", 1) == 0)
10138 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 1);
10140 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1);
10143 DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes
,
10144 show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd
,
10146 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)",
10148 "show bgp view WORD ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)",
10158 "Address family modifier\n"
10159 "Address family modifier\n"
10160 "Detailed information on TCP and BGP neighbor connections\n"
10161 "Neighbor to display information about\n"
10162 "Neighbor to display information about\n"
10163 "Display the advertised routes to neighbor\n"
10164 "Display the received routes from neighbor\n")
10172 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[3]);
10174 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[2]);
10178 return CMD_WARNING
;
10181 afi
= (strncmp (argv
[1], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
10182 safi
= (strncmp (argv
[2], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10183 in
= (strncmp (argv
[4], "r", 1) == 0) ? 1 : 0;
10186 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10187 in
= (strncmp (argv
[3], "r", 1) == 0) ? 1 : 0;
10190 return peer_adj_routes (vty
, peer
, afi
, safi
, in
);
10193 DEFUN (show_ip_bgp_neighbor_received_prefix_filter
,
10194 show_ip_bgp_neighbor_received_prefix_filter_cmd
,
10195 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10199 "Detailed information on TCP and BGP neighbor connections\n"
10200 "Neighbor to display information about\n"
10201 "Neighbor to display information about\n"
10202 "Display information received from a BGP neighbor\n"
10203 "Display the prefixlist filter\n")
10206 union sockunion
*su
;
10210 su
= sockunion_str2su (argv
[0]);
10212 return CMD_WARNING
;
10214 peer
= peer_lookup (NULL
, su
);
10216 return CMD_WARNING
;
10218 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
10219 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
10222 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
10223 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
10226 return CMD_SUCCESS
;
10229 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter
,
10230 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
,
10231 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10236 "Address Family modifier\n"
10237 "Address Family modifier\n"
10238 "Detailed information on TCP and BGP neighbor connections\n"
10239 "Neighbor to display information about\n"
10240 "Neighbor to display information about\n"
10241 "Display information received from a BGP neighbor\n"
10242 "Display the prefixlist filter\n")
10245 union sockunion
*su
;
10249 su
= sockunion_str2su (argv
[1]);
10251 return CMD_WARNING
;
10253 peer
= peer_lookup (NULL
, su
);
10255 return CMD_WARNING
;
10257 if (strncmp (argv
[0], "m", 1) == 0)
10259 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_MULTICAST
);
10260 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
10263 vty_out (vty
, "Address family: IPv4 Multicast%s", VTY_NEWLINE
);
10264 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
10269 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
10270 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
10273 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
10274 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
10278 return CMD_SUCCESS
;
10283 ALIAS (show_bgp_view_neighbor_received_routes
,
10284 show_bgp_neighbor_received_routes_cmd
,
10285 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
10288 "Detailed information on TCP and BGP neighbor connections\n"
10289 "Neighbor to display information about\n"
10290 "Neighbor to display information about\n"
10291 "Display the received routes from neighbor\n")
10293 ALIAS (show_bgp_view_neighbor_received_routes
,
10294 show_bgp_ipv6_neighbor_received_routes_cmd
,
10295 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
10299 "Detailed information on TCP and BGP neighbor connections\n"
10300 "Neighbor to display information about\n"
10301 "Neighbor to display information about\n"
10302 "Display the received routes from neighbor\n")
10304 DEFUN (show_bgp_neighbor_received_prefix_filter
,
10305 show_bgp_neighbor_received_prefix_filter_cmd
,
10306 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10309 "Detailed information on TCP and BGP neighbor connections\n"
10310 "Neighbor to display information about\n"
10311 "Neighbor to display information about\n"
10312 "Display information received from a BGP neighbor\n"
10313 "Display the prefixlist filter\n")
10316 union sockunion
*su
;
10320 su
= sockunion_str2su (argv
[0]);
10322 return CMD_WARNING
;
10324 peer
= peer_lookup (NULL
, su
);
10326 return CMD_WARNING
;
10328 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
10329 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
);
10332 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
10333 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
);
10336 return CMD_SUCCESS
;
10339 ALIAS (show_bgp_neighbor_received_prefix_filter
,
10340 show_bgp_ipv6_neighbor_received_prefix_filter_cmd
,
10341 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10345 "Detailed information on TCP and BGP neighbor connections\n"
10346 "Neighbor to display information about\n"
10347 "Neighbor to display information about\n"
10348 "Display information received from a BGP neighbor\n"
10349 "Display the prefixlist filter\n")
10352 ALIAS (show_bgp_view_neighbor_received_routes
,
10353 ipv6_bgp_neighbor_received_routes_cmd
,
10354 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
10358 "Detailed information on TCP and BGP neighbor connections\n"
10359 "Neighbor to display information about\n"
10360 "Neighbor to display information about\n"
10361 "Display the received routes from neighbor\n")
10364 DEFUN (ipv6_mbgp_neighbor_received_routes
,
10365 ipv6_mbgp_neighbor_received_routes_cmd
,
10366 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
10370 "Detailed information on TCP and BGP neighbor connections\n"
10371 "Neighbor to display information about\n"
10372 "Neighbor to display information about\n"
10373 "Display the received routes from neighbor\n")
10377 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10379 return CMD_WARNING
;
10381 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 1);
10384 DEFUN (show_bgp_view_neighbor_received_prefix_filter
,
10385 show_bgp_view_neighbor_received_prefix_filter_cmd
,
10386 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10391 "Detailed information on TCP and BGP neighbor connections\n"
10392 "Neighbor to display information about\n"
10393 "Neighbor to display information about\n"
10394 "Display information received from a BGP neighbor\n"
10395 "Display the prefixlist filter\n")
10398 union sockunion
*su
;
10403 /* BGP structure lookup. */
10404 bgp
= bgp_lookup_by_name (argv
[0]);
10407 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10408 return CMD_WARNING
;
10411 su
= sockunion_str2su (argv
[1]);
10413 return CMD_WARNING
;
10415 peer
= peer_lookup (bgp
, su
);
10417 return CMD_WARNING
;
10419 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
10420 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
);
10423 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
10424 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
);
10427 return CMD_SUCCESS
;
10430 ALIAS (show_bgp_view_neighbor_received_prefix_filter
,
10431 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
,
10432 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10438 "Detailed information on TCP and BGP neighbor connections\n"
10439 "Neighbor to display information about\n"
10440 "Neighbor to display information about\n"
10441 "Display information received from a BGP neighbor\n"
10442 "Display the prefixlist filter\n")
10443 #endif /* HAVE_IPV6 */
10446 bgp_show_neighbor_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
,
10447 safi_t safi
, enum bgp_show_type type
)
10449 if (! peer
|| ! peer
->afc
[afi
][safi
])
10451 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
10452 return CMD_WARNING
;
10455 return bgp_show (vty
, peer
->bgp
, afi
, safi
, type
, &peer
->su
);
10458 DEFUN (show_ip_bgp_neighbor_routes
,
10459 show_ip_bgp_neighbor_routes_cmd
,
10460 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
10464 "Detailed information on TCP and BGP neighbor connections\n"
10465 "Neighbor to display information about\n"
10466 "Neighbor to display information about\n"
10467 "Display routes learned from neighbor\n")
10471 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10473 return CMD_WARNING
;
10475 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10476 bgp_show_type_neighbor
);
10479 DEFUN (show_ip_bgp_neighbor_flap
,
10480 show_ip_bgp_neighbor_flap_cmd
,
10481 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10485 "Detailed information on TCP and BGP neighbor connections\n"
10486 "Neighbor to display information about\n"
10487 "Neighbor to display information about\n"
10488 "Display flap statistics of the routes learned from neighbor\n")
10492 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10494 return CMD_WARNING
;
10496 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10497 bgp_show_type_flap_neighbor
);
10500 DEFUN (show_ip_bgp_neighbor_damp
,
10501 show_ip_bgp_neighbor_damp_cmd
,
10502 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10506 "Detailed information on TCP and BGP neighbor connections\n"
10507 "Neighbor to display information about\n"
10508 "Neighbor to display information about\n"
10509 "Display the dampened routes received from neighbor\n")
10513 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10515 return CMD_WARNING
;
10517 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10518 bgp_show_type_damp_neighbor
);
10521 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
10522 show_ip_bgp_ipv4_neighbor_routes_cmd
,
10523 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
10528 "Address Family modifier\n"
10529 "Address Family modifier\n"
10530 "Detailed information on TCP and BGP neighbor connections\n"
10531 "Neighbor to display information about\n"
10532 "Neighbor to display information about\n"
10533 "Display routes learned from neighbor\n")
10537 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
10539 return CMD_WARNING
;
10541 if (strncmp (argv
[0], "m", 1) == 0)
10542 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_MULTICAST
,
10543 bgp_show_type_neighbor
);
10545 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10546 bgp_show_type_neighbor
);
10549 DEFUN (show_ip_bgp_view_rsclient
,
10550 show_ip_bgp_view_rsclient_cmd
,
10551 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
10557 "Information about Route Server Client\n"
10560 struct bgp_table
*table
;
10564 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10566 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10569 return CMD_WARNING
;
10571 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
10573 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10575 return CMD_WARNING
;
10578 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
10579 PEER_FLAG_RSERVER_CLIENT
))
10581 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10583 return CMD_WARNING
;
10586 table
= peer
->rib
[AFI_IP
][SAFI_UNICAST
];
10588 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
10591 ALIAS (show_ip_bgp_view_rsclient
,
10592 show_ip_bgp_rsclient_cmd
,
10593 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
10597 "Information about Route Server Client\n"
10600 DEFUN (show_bgp_view_ipv4_safi_rsclient
,
10601 show_bgp_view_ipv4_safi_rsclient_cmd
,
10602 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
10608 "Address Family modifier\n"
10609 "Address Family modifier\n"
10610 "Information about Route Server Client\n"
10613 struct bgp_table
*table
;
10618 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[2]);
10619 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10621 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
10622 safi
= (strncmp (argv
[0], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10626 return CMD_WARNING
;
10628 if (! peer
->afc
[AFI_IP
][safi
])
10630 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10632 return CMD_WARNING
;
10635 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][safi
],
10636 PEER_FLAG_RSERVER_CLIENT
))
10638 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10640 return CMD_WARNING
;
10643 table
= peer
->rib
[AFI_IP
][safi
];
10645 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
10648 ALIAS (show_bgp_view_ipv4_safi_rsclient
,
10649 show_bgp_ipv4_safi_rsclient_cmd
,
10650 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
10654 "Address Family modifier\n"
10655 "Address Family modifier\n"
10656 "Information about Route Server Client\n"
10659 DEFUN (show_ip_bgp_view_rsclient_route
,
10660 show_ip_bgp_view_rsclient_route_cmd
,
10661 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
10667 "Information about Route Server Client\n"
10669 "Network in the BGP routing table to display\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_IP
][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_IP
][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_IP
][SAFI_UNICAST
],
10718 (argc
== 3) ? argv
[2] : argv
[1],
10719 AFI_IP
, SAFI_UNICAST
, NULL
, 0);
10722 ALIAS (show_ip_bgp_view_rsclient_route
,
10723 show_ip_bgp_rsclient_route_cmd
,
10724 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
10728 "Information about Route Server Client\n"
10730 "Network in the BGP routing table to display\n")
10732 DEFUN (show_bgp_view_ipv4_safi_rsclient_route
,
10733 show_bgp_view_ipv4_safi_rsclient_route_cmd
,
10734 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
10740 "Address Family modifier\n"
10741 "Address Family modifier\n"
10742 "Information about Route Server Client\n"
10744 "Network in the BGP routing table to display\n")
10750 /* BGP structure lookup. */
10753 bgp
= bgp_lookup_by_name (argv
[0]);
10756 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10757 return CMD_WARNING
;
10762 bgp
= bgp_get_default ();
10765 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10766 return CMD_WARNING
;
10771 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[2]);
10772 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10774 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
10775 safi
= (strncmp (argv
[0], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10779 return CMD_WARNING
;
10781 if (! peer
->afc
[AFI_IP
][safi
])
10783 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10785 return CMD_WARNING
;
10788 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][safi
],
10789 PEER_FLAG_RSERVER_CLIENT
))
10791 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10793 return CMD_WARNING
;
10796 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][safi
],
10797 (argc
== 4) ? argv
[3] : argv
[2],
10798 AFI_IP
, safi
, NULL
, 0);
10801 ALIAS (show_bgp_view_ipv4_safi_rsclient_route
,
10802 show_bgp_ipv4_safi_rsclient_route_cmd
,
10803 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
10807 "Address Family modifier\n"
10808 "Address Family modifier\n"
10809 "Information about Route Server Client\n"
10811 "Network in the BGP routing table to display\n")
10813 DEFUN (show_ip_bgp_view_rsclient_prefix
,
10814 show_ip_bgp_view_rsclient_prefix_cmd
,
10815 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
10821 "Information about Route Server Client\n"
10823 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10828 /* BGP structure lookup. */
10831 bgp
= bgp_lookup_by_name (argv
[0]);
10834 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10835 return CMD_WARNING
;
10840 bgp
= bgp_get_default ();
10843 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10844 return CMD_WARNING
;
10849 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10851 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10854 return CMD_WARNING
;
10856 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
10858 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10860 return CMD_WARNING
;
10863 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
10864 PEER_FLAG_RSERVER_CLIENT
))
10866 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10868 return CMD_WARNING
;
10871 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][SAFI_UNICAST
],
10872 (argc
== 3) ? argv
[2] : argv
[1],
10873 AFI_IP
, SAFI_UNICAST
, NULL
, 1);
10876 ALIAS (show_ip_bgp_view_rsclient_prefix
,
10877 show_ip_bgp_rsclient_prefix_cmd
,
10878 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
10882 "Information about Route Server Client\n"
10884 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10886 DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix
,
10887 show_bgp_view_ipv4_safi_rsclient_prefix_cmd
,
10888 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
10894 "Address Family modifier\n"
10895 "Address Family modifier\n"
10896 "Information about Route Server Client\n"
10898 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10904 /* BGP structure lookup. */
10907 bgp
= bgp_lookup_by_name (argv
[0]);
10910 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10911 return CMD_WARNING
;
10916 bgp
= bgp_get_default ();
10919 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10920 return CMD_WARNING
;
10925 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[2]);
10926 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10928 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
10929 safi
= (strncmp (argv
[0], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10933 return CMD_WARNING
;
10935 if (! peer
->afc
[AFI_IP
][safi
])
10937 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10939 return CMD_WARNING
;
10942 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][safi
],
10943 PEER_FLAG_RSERVER_CLIENT
))
10945 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10947 return CMD_WARNING
;
10950 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][safi
],
10951 (argc
== 4) ? argv
[3] : argv
[2],
10952 AFI_IP
, safi
, NULL
, 1);
10955 ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix
,
10956 show_bgp_ipv4_safi_rsclient_prefix_cmd
,
10957 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
10961 "Address Family modifier\n"
10962 "Address Family modifier\n"
10963 "Information about Route Server Client\n"
10965 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10968 DEFUN (show_bgp_view_neighbor_routes
,
10969 show_bgp_view_neighbor_routes_cmd
,
10970 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
10975 "Detailed information on TCP and BGP neighbor connections\n"
10976 "Neighbor to display information about\n"
10977 "Neighbor to display information about\n"
10978 "Display routes learned from neighbor\n")
10983 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10985 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10988 return CMD_WARNING
;
10990 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
10991 bgp_show_type_neighbor
);
10994 ALIAS (show_bgp_view_neighbor_routes
,
10995 show_bgp_view_ipv6_neighbor_routes_cmd
,
10996 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
11002 "Detailed information on TCP and BGP neighbor connections\n"
11003 "Neighbor to display information about\n"
11004 "Neighbor to display information about\n"
11005 "Display routes learned from neighbor\n")
11007 DEFUN (show_bgp_view_neighbor_damp
,
11008 show_bgp_view_neighbor_damp_cmd
,
11009 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
11014 "Detailed information on TCP and BGP neighbor connections\n"
11015 "Neighbor to display information about\n"
11016 "Neighbor to display information about\n"
11017 "Display the dampened routes received from neighbor\n")
11022 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
11024 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
11027 return CMD_WARNING
;
11029 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
11030 bgp_show_type_damp_neighbor
);
11033 ALIAS (show_bgp_view_neighbor_damp
,
11034 show_bgp_view_ipv6_neighbor_damp_cmd
,
11035 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
11041 "Detailed information on TCP and BGP neighbor connections\n"
11042 "Neighbor to display information about\n"
11043 "Neighbor to display information about\n"
11044 "Display the dampened routes received from neighbor\n")
11046 DEFUN (show_bgp_view_neighbor_flap
,
11047 show_bgp_view_neighbor_flap_cmd
,
11048 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
11053 "Detailed information on TCP and BGP neighbor connections\n"
11054 "Neighbor to display information about\n"
11055 "Neighbor to display information about\n"
11056 "Display flap statistics of the routes learned from neighbor\n")
11061 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
11063 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
11066 return CMD_WARNING
;
11068 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
11069 bgp_show_type_flap_neighbor
);
11072 ALIAS (show_bgp_view_neighbor_flap
,
11073 show_bgp_view_ipv6_neighbor_flap_cmd
,
11074 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
11080 "Detailed information on TCP and BGP neighbor connections\n"
11081 "Neighbor to display information about\n"
11082 "Neighbor to display information about\n"
11083 "Display flap statistics of the routes learned from neighbor\n")
11085 ALIAS (show_bgp_view_neighbor_routes
,
11086 show_bgp_neighbor_routes_cmd
,
11087 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
11090 "Detailed information on TCP and BGP neighbor connections\n"
11091 "Neighbor to display information about\n"
11092 "Neighbor to display information about\n"
11093 "Display routes learned from neighbor\n")
11096 ALIAS (show_bgp_view_neighbor_routes
,
11097 show_bgp_ipv6_neighbor_routes_cmd
,
11098 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
11102 "Detailed information on TCP and BGP neighbor connections\n"
11103 "Neighbor to display information about\n"
11104 "Neighbor to display information about\n"
11105 "Display routes learned from neighbor\n")
11108 ALIAS (show_bgp_view_neighbor_routes
,
11109 ipv6_bgp_neighbor_routes_cmd
,
11110 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
11114 "Detailed information on TCP and BGP neighbor connections\n"
11115 "Neighbor to display information about\n"
11116 "Neighbor to display information about\n"
11117 "Display routes learned from neighbor\n")
11120 DEFUN (ipv6_mbgp_neighbor_routes
,
11121 ipv6_mbgp_neighbor_routes_cmd
,
11122 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
11126 "Detailed information on TCP and BGP neighbor connections\n"
11127 "Neighbor to display information about\n"
11128 "Neighbor to display information about\n"
11129 "Display routes learned from neighbor\n")
11133 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
11135 return CMD_WARNING
;
11137 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
,
11138 bgp_show_type_neighbor
);
11141 ALIAS (show_bgp_view_neighbor_flap
,
11142 show_bgp_neighbor_flap_cmd
,
11143 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
11146 "Detailed information on TCP and BGP neighbor connections\n"
11147 "Neighbor to display information about\n"
11148 "Neighbor to display information about\n"
11149 "Display flap statistics of the routes learned from neighbor\n")
11151 ALIAS (show_bgp_view_neighbor_flap
,
11152 show_bgp_ipv6_neighbor_flap_cmd
,
11153 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
11157 "Detailed information on TCP and BGP neighbor connections\n"
11158 "Neighbor to display information about\n"
11159 "Neighbor to display information about\n"
11160 "Display flap statistics of the routes learned from neighbor\n")
11162 ALIAS (show_bgp_view_neighbor_damp
,
11163 show_bgp_neighbor_damp_cmd
,
11164 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
11167 "Detailed information on TCP and BGP neighbor connections\n"
11168 "Neighbor to display information about\n"
11169 "Neighbor to display information about\n"
11170 "Display the dampened routes received from neighbor\n")
11172 ALIAS (show_bgp_view_neighbor_damp
,
11173 show_bgp_ipv6_neighbor_damp_cmd
,
11174 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
11178 "Detailed information on TCP and BGP neighbor connections\n"
11179 "Neighbor to display information about\n"
11180 "Neighbor to display information about\n"
11181 "Display the dampened routes received from neighbor\n")
11183 DEFUN (show_bgp_view_rsclient
,
11184 show_bgp_view_rsclient_cmd
,
11185 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
11190 "Information about Route Server Client\n"
11193 struct bgp_table
*table
;
11197 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
11199 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
11202 return CMD_WARNING
;
11204 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
11206 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
11208 return CMD_WARNING
;
11211 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
11212 PEER_FLAG_RSERVER_CLIENT
))
11214 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
11216 return CMD_WARNING
;
11219 table
= peer
->rib
[AFI_IP6
][SAFI_UNICAST
];
11221 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
11224 ALIAS (show_bgp_view_rsclient
,
11225 show_bgp_rsclient_cmd
,
11226 "show bgp rsclient (A.B.C.D|X:X::X:X)",
11229 "Information about Route Server Client\n"
11232 DEFUN (show_bgp_view_ipv6_safi_rsclient
,
11233 show_bgp_view_ipv6_safi_rsclient_cmd
,
11234 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
11240 "Address Family modifier\n"
11241 "Address Family modifier\n"
11242 "Information about Route Server Client\n"
11245 struct bgp_table
*table
;
11250 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[2]);
11251 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
11253 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
11254 safi
= (strncmp (argv
[0], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
11258 return CMD_WARNING
;
11260 if (! peer
->afc
[AFI_IP6
][safi
])
11262 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
11264 return CMD_WARNING
;
11267 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][safi
],
11268 PEER_FLAG_RSERVER_CLIENT
))
11270 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
11272 return CMD_WARNING
;
11275 table
= peer
->rib
[AFI_IP6
][safi
];
11277 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
11280 ALIAS (show_bgp_view_ipv6_safi_rsclient
,
11281 show_bgp_ipv6_safi_rsclient_cmd
,
11282 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
11286 "Address Family modifier\n"
11287 "Address Family modifier\n"
11288 "Information about Route Server Client\n"
11291 DEFUN (show_bgp_view_rsclient_route
,
11292 show_bgp_view_rsclient_route_cmd
,
11293 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
11298 "Information about Route Server Client\n"
11300 "Network in the BGP routing table to display\n")
11305 /* BGP structure lookup. */
11308 bgp
= bgp_lookup_by_name (argv
[0]);
11311 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
11312 return CMD_WARNING
;
11317 bgp
= bgp_get_default ();
11320 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
11321 return CMD_WARNING
;
11326 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
11328 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
11331 return CMD_WARNING
;
11333 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
11335 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
11337 return CMD_WARNING
;
11340 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
11341 PEER_FLAG_RSERVER_CLIENT
))
11343 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
11345 return CMD_WARNING
;
11348 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][SAFI_UNICAST
],
11349 (argc
== 3) ? argv
[2] : argv
[1],
11350 AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
11353 ALIAS (show_bgp_view_rsclient_route
,
11354 show_bgp_rsclient_route_cmd
,
11355 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
11358 "Information about Route Server Client\n"
11360 "Network in the BGP routing table to display\n")
11362 DEFUN (show_bgp_view_ipv6_safi_rsclient_route
,
11363 show_bgp_view_ipv6_safi_rsclient_route_cmd
,
11364 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
11370 "Address Family modifier\n"
11371 "Address Family modifier\n"
11372 "Information about Route Server Client\n"
11374 "Network in the BGP routing table to display\n")
11380 /* BGP structure lookup. */
11383 bgp
= bgp_lookup_by_name (argv
[0]);
11386 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
11387 return CMD_WARNING
;
11392 bgp
= bgp_get_default ();
11395 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
11396 return CMD_WARNING
;
11401 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[2]);
11402 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
11404 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
11405 safi
= (strncmp (argv
[0], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
11409 return CMD_WARNING
;
11411 if (! peer
->afc
[AFI_IP6
][safi
])
11413 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
11415 return CMD_WARNING
;
11418 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][safi
],
11419 PEER_FLAG_RSERVER_CLIENT
))
11421 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
11423 return CMD_WARNING
;
11426 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][safi
],
11427 (argc
== 4) ? argv
[3] : argv
[2],
11428 AFI_IP6
, safi
, NULL
, 0);
11431 ALIAS (show_bgp_view_ipv6_safi_rsclient_route
,
11432 show_bgp_ipv6_safi_rsclient_route_cmd
,
11433 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
11437 "Address Family modifier\n"
11438 "Address Family modifier\n"
11439 "Information about Route Server Client\n"
11441 "Network in the BGP routing table to display\n")
11443 DEFUN (show_bgp_view_rsclient_prefix
,
11444 show_bgp_view_rsclient_prefix_cmd
,
11445 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
11450 "Information about Route Server Client\n"
11452 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
11457 /* BGP structure lookup. */
11460 bgp
= bgp_lookup_by_name (argv
[0]);
11463 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
11464 return CMD_WARNING
;
11469 bgp
= bgp_get_default ();
11472 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
11473 return CMD_WARNING
;
11478 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
11480 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
11483 return CMD_WARNING
;
11485 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
11487 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
11489 return CMD_WARNING
;
11492 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
11493 PEER_FLAG_RSERVER_CLIENT
))
11495 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
11497 return CMD_WARNING
;
11500 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][SAFI_UNICAST
],
11501 (argc
== 3) ? argv
[2] : argv
[1],
11502 AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
11505 ALIAS (show_bgp_view_rsclient_prefix
,
11506 show_bgp_rsclient_prefix_cmd
,
11507 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
11510 "Information about Route Server Client\n"
11512 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
11514 DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix
,
11515 show_bgp_view_ipv6_safi_rsclient_prefix_cmd
,
11516 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
11522 "Address Family modifier\n"
11523 "Address Family modifier\n"
11524 "Information about Route Server Client\n"
11526 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
11532 /* BGP structure lookup. */
11535 bgp
= bgp_lookup_by_name (argv
[0]);
11538 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
11539 return CMD_WARNING
;
11544 bgp
= bgp_get_default ();
11547 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
11548 return CMD_WARNING
;
11553 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[2]);
11554 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
11556 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
11557 safi
= (strncmp (argv
[0], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
11561 return CMD_WARNING
;
11563 if (! peer
->afc
[AFI_IP6
][safi
])
11565 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
11567 return CMD_WARNING
;
11570 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][safi
],
11571 PEER_FLAG_RSERVER_CLIENT
))
11573 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
11575 return CMD_WARNING
;
11578 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][safi
],
11579 (argc
== 4) ? argv
[3] : argv
[2],
11580 AFI_IP6
, safi
, NULL
, 1);
11583 ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix
,
11584 show_bgp_ipv6_safi_rsclient_prefix_cmd
,
11585 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
11589 "Address Family modifier\n"
11590 "Address Family modifier\n"
11591 "Information about Route Server Client\n"
11593 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
11595 #endif /* HAVE_IPV6 */
11597 struct bgp_table
*bgp_distance_table
;
11599 struct bgp_distance
11601 /* Distance value for the IP source prefix. */
11604 /* Name of the access-list to be matched. */
11608 static struct bgp_distance
*
11609 bgp_distance_new (void)
11611 return XCALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
11615 bgp_distance_free (struct bgp_distance
*bdistance
)
11617 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
11621 bgp_distance_set (struct vty
*vty
, const char *distance_str
,
11622 const char *ip_str
, const char *access_list_str
)
11625 struct prefix_ipv4 p
;
11627 struct bgp_node
*rn
;
11628 struct bgp_distance
*bdistance
;
11630 ret
= str2prefix_ipv4 (ip_str
, &p
);
11633 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
11634 return CMD_WARNING
;
11637 distance
= atoi (distance_str
);
11639 /* Get BGP distance node. */
11640 rn
= bgp_node_get (bgp_distance_table
, (struct prefix
*) &p
);
11643 bdistance
= rn
->info
;
11644 bgp_unlock_node (rn
);
11648 bdistance
= bgp_distance_new ();
11649 rn
->info
= bdistance
;
11652 /* Set distance value. */
11653 bdistance
->distance
= distance
;
11655 /* Reset access-list configuration. */
11656 if (bdistance
->access_list
)
11658 free (bdistance
->access_list
);
11659 bdistance
->access_list
= NULL
;
11661 if (access_list_str
)
11662 bdistance
->access_list
= strdup (access_list_str
);
11664 return CMD_SUCCESS
;
11668 bgp_distance_unset (struct vty
*vty
, const char *distance_str
,
11669 const char *ip_str
, const char *access_list_str
)
11672 struct prefix_ipv4 p
;
11674 struct bgp_node
*rn
;
11675 struct bgp_distance
*bdistance
;
11677 ret
= str2prefix_ipv4 (ip_str
, &p
);
11680 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
11681 return CMD_WARNING
;
11684 distance
= atoi (distance_str
);
11686 rn
= bgp_node_lookup (bgp_distance_table
, (struct prefix
*)&p
);
11689 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
11690 return CMD_WARNING
;
11693 bdistance
= rn
->info
;
11695 if (bdistance
->access_list
)
11696 free (bdistance
->access_list
);
11697 bgp_distance_free (bdistance
);
11700 bgp_unlock_node (rn
);
11701 bgp_unlock_node (rn
);
11703 return CMD_SUCCESS
;
11706 /* Apply BGP information to distance method. */
11708 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, struct bgp
*bgp
)
11710 struct bgp_node
*rn
;
11711 struct prefix_ipv4 q
;
11713 struct bgp_distance
*bdistance
;
11714 struct access_list
*alist
;
11715 struct bgp_static
*bgp_static
;
11720 if (p
->family
!= AF_INET
)
11723 peer
= rinfo
->peer
;
11725 if (peer
->su
.sa
.sa_family
!= AF_INET
)
11728 memset (&q
, 0, sizeof (struct prefix_ipv4
));
11729 q
.family
= AF_INET
;
11730 q
.prefix
= peer
->su
.sin
.sin_addr
;
11731 q
.prefixlen
= IPV4_MAX_BITLEN
;
11733 /* Check source address. */
11734 rn
= bgp_node_match (bgp_distance_table
, (struct prefix
*) &q
);
11737 bdistance
= rn
->info
;
11738 bgp_unlock_node (rn
);
11740 if (bdistance
->access_list
)
11742 alist
= access_list_lookup (AFI_IP
, bdistance
->access_list
);
11743 if (alist
&& access_list_apply (alist
, p
) == FILTER_PERMIT
)
11744 return bdistance
->distance
;
11747 return bdistance
->distance
;
11750 /* Backdoor check. */
11751 rn
= bgp_node_lookup (bgp
->route
[AFI_IP
][SAFI_UNICAST
], p
);
11754 bgp_static
= rn
->info
;
11755 bgp_unlock_node (rn
);
11757 if (bgp_static
->backdoor
)
11759 if (bgp
->distance_local
)
11760 return bgp
->distance_local
;
11762 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
11766 if (peer_sort (peer
) == BGP_PEER_EBGP
)
11768 if (bgp
->distance_ebgp
)
11769 return bgp
->distance_ebgp
;
11770 return ZEBRA_EBGP_DISTANCE_DEFAULT
;
11774 if (bgp
->distance_ibgp
)
11775 return bgp
->distance_ibgp
;
11776 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
11780 DEFUN (bgp_distance
,
11782 "distance bgp <1-255> <1-255> <1-255>",
11783 "Define an administrative distance\n"
11785 "Distance for routes external to the AS\n"
11786 "Distance for routes internal to the AS\n"
11787 "Distance for local routes\n")
11793 bgp
->distance_ebgp
= atoi (argv
[0]);
11794 bgp
->distance_ibgp
= atoi (argv
[1]);
11795 bgp
->distance_local
= atoi (argv
[2]);
11796 return CMD_SUCCESS
;
11799 DEFUN (no_bgp_distance
,
11800 no_bgp_distance_cmd
,
11801 "no distance bgp <1-255> <1-255> <1-255>",
11803 "Define an administrative distance\n"
11805 "Distance for routes external to the AS\n"
11806 "Distance for routes internal to the AS\n"
11807 "Distance for local routes\n")
11813 bgp
->distance_ebgp
= 0;
11814 bgp
->distance_ibgp
= 0;
11815 bgp
->distance_local
= 0;
11816 return CMD_SUCCESS
;
11819 ALIAS (no_bgp_distance
,
11820 no_bgp_distance2_cmd
,
11823 "Define an administrative distance\n"
11826 DEFUN (bgp_distance_source
,
11827 bgp_distance_source_cmd
,
11828 "distance <1-255> A.B.C.D/M",
11829 "Define an administrative distance\n"
11830 "Administrative distance\n"
11831 "IP source prefix\n")
11833 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
11834 return CMD_SUCCESS
;
11837 DEFUN (no_bgp_distance_source
,
11838 no_bgp_distance_source_cmd
,
11839 "no distance <1-255> A.B.C.D/M",
11841 "Define an administrative distance\n"
11842 "Administrative distance\n"
11843 "IP source prefix\n")
11845 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
11846 return CMD_SUCCESS
;
11849 DEFUN (bgp_distance_source_access_list
,
11850 bgp_distance_source_access_list_cmd
,
11851 "distance <1-255> A.B.C.D/M WORD",
11852 "Define an administrative distance\n"
11853 "Administrative distance\n"
11854 "IP source prefix\n"
11855 "Access list name\n")
11857 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
11858 return CMD_SUCCESS
;
11861 DEFUN (no_bgp_distance_source_access_list
,
11862 no_bgp_distance_source_access_list_cmd
,
11863 "no distance <1-255> A.B.C.D/M WORD",
11865 "Define an administrative distance\n"
11866 "Administrative distance\n"
11867 "IP source prefix\n"
11868 "Access list name\n")
11870 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
11871 return CMD_SUCCESS
;
11874 DEFUN (bgp_damp_set
,
11876 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
11877 "BGP Specific commands\n"
11878 "Enable route-flap dampening\n"
11879 "Half-life time for the penalty\n"
11880 "Value to start reusing a route\n"
11881 "Value to start suppressing a route\n"
11882 "Maximum duration to suppress a stable route\n")
11885 int half
= DEFAULT_HALF_LIFE
* 60;
11886 int reuse
= DEFAULT_REUSE
;
11887 int suppress
= DEFAULT_SUPPRESS
;
11888 int max
= 4 * half
;
11892 half
= atoi (argv
[0]) * 60;
11893 reuse
= atoi (argv
[1]);
11894 suppress
= atoi (argv
[2]);
11895 max
= atoi (argv
[3]) * 60;
11897 else if (argc
== 1)
11899 half
= atoi (argv
[0]) * 60;
11904 return bgp_damp_enable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
),
11905 half
, reuse
, suppress
, max
);
11908 ALIAS (bgp_damp_set
,
11910 "bgp dampening <1-45>",
11911 "BGP Specific commands\n"
11912 "Enable route-flap dampening\n"
11913 "Half-life time for the penalty\n")
11915 ALIAS (bgp_damp_set
,
11918 "BGP Specific commands\n"
11919 "Enable route-flap dampening\n")
11921 DEFUN (bgp_damp_unset
,
11922 bgp_damp_unset_cmd
,
11923 "no bgp dampening",
11925 "BGP Specific commands\n"
11926 "Enable route-flap dampening\n")
11931 return bgp_damp_disable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
));
11934 ALIAS (bgp_damp_unset
,
11935 bgp_damp_unset2_cmd
,
11936 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
11938 "BGP Specific commands\n"
11939 "Enable route-flap dampening\n"
11940 "Half-life time for the penalty\n"
11941 "Value to start reusing a route\n"
11942 "Value to start suppressing a route\n"
11943 "Maximum duration to suppress a stable route\n")
11945 DEFUN (show_ip_bgp_dampened_paths
,
11946 show_ip_bgp_dampened_paths_cmd
,
11947 "show ip bgp dampened-paths",
11951 "Display paths suppressed due to dampening\n")
11953 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_dampend_paths
,
11957 DEFUN (show_ip_bgp_flap_statistics
,
11958 show_ip_bgp_flap_statistics_cmd
,
11959 "show ip bgp flap-statistics",
11963 "Display flap statistics of routes\n")
11965 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
11966 bgp_show_type_flap_statistics
, NULL
);
11969 /* Display specified route of BGP table. */
11971 bgp_clear_damp_route (struct vty
*vty
, const char *view_name
,
11972 const char *ip_str
, afi_t afi
, safi_t safi
,
11973 struct prefix_rd
*prd
, int prefix_check
)
11976 struct prefix match
;
11977 struct bgp_node
*rn
;
11978 struct bgp_node
*rm
;
11979 struct bgp_info
*ri
;
11980 struct bgp_info
*ri_temp
;
11982 struct bgp_table
*table
;
11984 /* BGP structure lookup. */
11987 bgp
= bgp_lookup_by_name (view_name
);
11990 vty_out (vty
, "%% Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
11991 return CMD_WARNING
;
11996 bgp
= bgp_get_default ();
11999 vty_out (vty
, "%% No BGP process is configured%s", VTY_NEWLINE
);
12000 return CMD_WARNING
;
12004 /* Check IP address argument. */
12005 ret
= str2prefix (ip_str
, &match
);
12008 vty_out (vty
, "%% address is malformed%s", VTY_NEWLINE
);
12009 return CMD_WARNING
;
12012 match
.family
= afi2family (afi
);
12014 if (safi
== SAFI_MPLS_VPN
)
12016 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][SAFI_MPLS_VPN
]); rn
; rn
= bgp_route_next (rn
))
12018 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
12021 if ((table
= rn
->info
) != NULL
)
12022 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
12024 if (! prefix_check
|| rm
->p
.prefixlen
== match
.prefixlen
)
12029 if (ri
->extra
&& ri
->extra
->damp_info
)
12031 ri_temp
= ri
->next
;
12032 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
12040 bgp_unlock_node (rm
);
12046 if ((rn
= bgp_node_match (bgp
->rib
[afi
][safi
], &match
)) != NULL
)
12048 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
12053 if (ri
->extra
&& ri
->extra
->damp_info
)
12055 ri_temp
= ri
->next
;
12056 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
12064 bgp_unlock_node (rn
);
12068 return CMD_SUCCESS
;
12071 DEFUN (clear_ip_bgp_dampening
,
12072 clear_ip_bgp_dampening_cmd
,
12073 "clear ip bgp dampening",
12077 "Clear route flap dampening information\n")
12079 bgp_damp_info_clean ();
12080 return CMD_SUCCESS
;
12083 DEFUN (clear_ip_bgp_dampening_prefix
,
12084 clear_ip_bgp_dampening_prefix_cmd
,
12085 "clear ip bgp dampening A.B.C.D/M",
12089 "Clear route flap dampening information\n"
12090 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
12092 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
12093 SAFI_UNICAST
, NULL
, 1);
12096 DEFUN (clear_ip_bgp_dampening_address
,
12097 clear_ip_bgp_dampening_address_cmd
,
12098 "clear ip bgp dampening A.B.C.D",
12102 "Clear route flap dampening information\n"
12103 "Network to clear damping information\n")
12105 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
12106 SAFI_UNICAST
, NULL
, 0);
12109 DEFUN (clear_ip_bgp_dampening_address_mask
,
12110 clear_ip_bgp_dampening_address_mask_cmd
,
12111 "clear ip bgp dampening A.B.C.D A.B.C.D",
12115 "Clear route flap dampening information\n"
12116 "Network to clear damping information\n"
12120 char prefix_str
[BUFSIZ
];
12122 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
12125 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
12126 return CMD_WARNING
;
12129 return bgp_clear_damp_route (vty
, NULL
, prefix_str
, AFI_IP
,
12130 SAFI_UNICAST
, NULL
, 0);
12134 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
12135 afi_t afi
, safi_t safi
, int *write
)
12137 struct bgp_node
*prn
;
12138 struct bgp_node
*rn
;
12139 struct bgp_table
*table
;
12141 struct prefix_rd
*prd
;
12142 struct bgp_static
*bgp_static
;
12144 char buf
[SU_ADDRSTRLEN
];
12145 char rdbuf
[RD_ADDRSTRLEN
];
12147 /* Network configuration. */
12148 for (prn
= bgp_table_top (bgp
->route
[afi
][safi
]); prn
; prn
= bgp_route_next (prn
))
12149 if ((table
= prn
->info
) != NULL
)
12150 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
12151 if ((bgp_static
= rn
->info
) != NULL
)
12154 prd
= (struct prefix_rd
*) &prn
->p
;
12156 /* "address-family" display. */
12157 bgp_config_write_family_header (vty
, afi
, safi
, write
);
12159 /* "network" configuration display. */
12160 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
12161 label
= decode_label (bgp_static
->tag
);
12163 vty_out (vty
, " network %s/%d rd %s tag %d",
12164 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
12167 vty_out (vty
, "%s", VTY_NEWLINE
);
12172 /* Configuration of static route announcement and aggregate
12175 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
12176 afi_t afi
, safi_t safi
, int *write
)
12178 struct bgp_node
*rn
;
12180 struct bgp_static
*bgp_static
;
12181 struct bgp_aggregate
*bgp_aggregate
;
12182 char buf
[SU_ADDRSTRLEN
];
12184 if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
12185 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
12187 /* Network configuration. */
12188 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
12189 if ((bgp_static
= rn
->info
) != NULL
)
12193 /* "address-family" display. */
12194 bgp_config_write_family_header (vty
, afi
, safi
, write
);
12196 /* "network" configuration display. */
12197 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
12199 u_int32_t destination
;
12200 struct in_addr netmask
;
12202 destination
= ntohl (p
->u
.prefix4
.s_addr
);
12203 masklen2ip (p
->prefixlen
, &netmask
);
12204 vty_out (vty
, " network %s",
12205 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
));
12207 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
12208 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
12209 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
12210 || p
->u
.prefix4
.s_addr
== 0)
12212 /* Natural mask is not display. */
12215 vty_out (vty
, " mask %s", inet_ntoa (netmask
));
12219 vty_out (vty
, " network %s/%d",
12220 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
12224 if (bgp_static
->rmap
.name
)
12225 vty_out (vty
, " route-map %s", bgp_static
->rmap
.name
);
12228 if (bgp_static
->backdoor
)
12229 vty_out (vty
, " backdoor");
12232 vty_out (vty
, "%s", VTY_NEWLINE
);
12235 /* Aggregate-address configuration. */
12236 for (rn
= bgp_table_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
12237 if ((bgp_aggregate
= rn
->info
) != NULL
)
12241 /* "address-family" display. */
12242 bgp_config_write_family_header (vty
, afi
, safi
, write
);
12244 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
12246 struct in_addr netmask
;
12248 masklen2ip (p
->prefixlen
, &netmask
);
12249 vty_out (vty
, " aggregate-address %s %s",
12250 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
12251 inet_ntoa (netmask
));
12255 vty_out (vty
, " aggregate-address %s/%d",
12256 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
12260 if (bgp_aggregate
->as_set
)
12261 vty_out (vty
, " as-set");
12263 if (bgp_aggregate
->summary_only
)
12264 vty_out (vty
, " summary-only");
12266 vty_out (vty
, "%s", VTY_NEWLINE
);
12273 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
)
12275 struct bgp_node
*rn
;
12276 struct bgp_distance
*bdistance
;
12278 /* Distance configuration. */
12279 if (bgp
->distance_ebgp
12280 && bgp
->distance_ibgp
12281 && bgp
->distance_local
12282 && (bgp
->distance_ebgp
!= ZEBRA_EBGP_DISTANCE_DEFAULT
12283 || bgp
->distance_ibgp
!= ZEBRA_IBGP_DISTANCE_DEFAULT
12284 || bgp
->distance_local
!= ZEBRA_IBGP_DISTANCE_DEFAULT
))
12285 vty_out (vty
, " distance bgp %d %d %d%s",
12286 bgp
->distance_ebgp
, bgp
->distance_ibgp
, bgp
->distance_local
,
12289 for (rn
= bgp_table_top (bgp_distance_table
); rn
; rn
= bgp_route_next (rn
))
12290 if ((bdistance
= rn
->info
) != NULL
)
12292 vty_out (vty
, " distance %d %s/%d %s%s", bdistance
->distance
,
12293 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
12294 bdistance
->access_list
? bdistance
->access_list
: "",
12301 /* Allocate routing table structure and install commands. */
12303 bgp_route_init (void)
12305 /* Init BGP distance table. */
12306 bgp_distance_table
= bgp_table_init (AFI_IP
, SAFI_UNICAST
);
12308 /* IPv4 BGP commands. */
12309 install_element (BGP_NODE
, &bgp_network_cmd
);
12310 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
12311 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
12312 install_element (BGP_NODE
, &bgp_network_route_map_cmd
);
12313 install_element (BGP_NODE
, &bgp_network_mask_route_map_cmd
);
12314 install_element (BGP_NODE
, &bgp_network_mask_natural_route_map_cmd
);
12315 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
12316 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
12317 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
12318 install_element (BGP_NODE
, &no_bgp_network_cmd
);
12319 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
12320 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
12321 install_element (BGP_NODE
, &no_bgp_network_route_map_cmd
);
12322 install_element (BGP_NODE
, &no_bgp_network_mask_route_map_cmd
);
12323 install_element (BGP_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
12324 install_element (BGP_NODE
, &no_bgp_network_backdoor_cmd
);
12325 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_cmd
);
12326 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_cmd
);
12328 install_element (BGP_NODE
, &aggregate_address_cmd
);
12329 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
12330 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
12331 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
12332 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
12333 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
12334 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
12335 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
12336 install_element (BGP_NODE
, &aggregate_address_summary_as_set_cmd
);
12337 install_element (BGP_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
12338 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
12339 install_element (BGP_NODE
, &no_aggregate_address_summary_only_cmd
);
12340 install_element (BGP_NODE
, &no_aggregate_address_as_set_cmd
);
12341 install_element (BGP_NODE
, &no_aggregate_address_as_set_summary_cmd
);
12342 install_element (BGP_NODE
, &no_aggregate_address_summary_as_set_cmd
);
12343 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
12344 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
12345 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_cmd
);
12346 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
12347 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
12349 /* IPv4 unicast configuration. */
12350 install_element (BGP_IPV4_NODE
, &bgp_network_cmd
);
12351 install_element (BGP_IPV4_NODE
, &bgp_network_mask_cmd
);
12352 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_cmd
);
12353 install_element (BGP_IPV4_NODE
, &bgp_network_route_map_cmd
);
12354 install_element (BGP_IPV4_NODE
, &bgp_network_mask_route_map_cmd
);
12355 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_route_map_cmd
);
12356 install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
12357 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_cmd
);
12358 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_cmd
);
12359 install_element (BGP_IPV4_NODE
, &no_bgp_network_route_map_cmd
);
12360 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_route_map_cmd
);
12361 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
12363 install_element (BGP_IPV4_NODE
, &aggregate_address_cmd
);
12364 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_cmd
);
12365 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_only_cmd
);
12366 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_only_cmd
);
12367 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_cmd
);
12368 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_cmd
);
12369 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_summary_cmd
);
12370 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
12371 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_as_set_cmd
);
12372 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
12373 install_element (BGP_IPV4_NODE
, &no_aggregate_address_cmd
);
12374 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_only_cmd
);
12375 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_cmd
);
12376 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_summary_cmd
);
12377 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_as_set_cmd
);
12378 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_cmd
);
12379 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
12380 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_cmd
);
12381 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
12382 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
12384 /* IPv4 multicast configuration. */
12385 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
12386 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
12387 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
12388 install_element (BGP_IPV4M_NODE
, &bgp_network_route_map_cmd
);
12389 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_route_map_cmd
);
12390 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_route_map_cmd
);
12391 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
12392 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
12393 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
12394 install_element (BGP_IPV4M_NODE
, &no_bgp_network_route_map_cmd
);
12395 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_route_map_cmd
);
12396 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
12397 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
12398 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
12399 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
12400 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
12401 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
12402 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
12403 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
12404 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
12405 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_as_set_cmd
);
12406 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
12407 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
12408 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_only_cmd
);
12409 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_cmd
);
12410 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_summary_cmd
);
12411 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_as_set_cmd
);
12412 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
12413 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
12414 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_cmd
);
12415 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
12416 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
12418 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
12419 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
12420 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_cmd
);
12421 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
12422 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
12423 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_cmd
);
12424 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
12425 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
12426 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
12427 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
12428 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
12429 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
12430 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
12431 install_element (VIEW_NODE
, &show_ip_bgp_view_cmd
);
12432 install_element (VIEW_NODE
, &show_ip_bgp_view_route_cmd
);
12433 install_element (VIEW_NODE
, &show_ip_bgp_view_prefix_cmd
);
12434 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
12435 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
12436 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
12437 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
12438 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
12439 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
12440 install_element (VIEW_NODE
, &show_ip_bgp_route_map_cmd
);
12441 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
12442 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
12443 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
12444 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
12445 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
12446 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
12447 install_element (VIEW_NODE
, &show_ip_bgp_community2_cmd
);
12448 install_element (VIEW_NODE
, &show_ip_bgp_community3_cmd
);
12449 install_element (VIEW_NODE
, &show_ip_bgp_community4_cmd
);
12450 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
12451 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
12452 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
12453 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
12454 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_community_all_cmd
);
12455 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_community_cmd
);
12456 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_community2_cmd
);
12457 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_community3_cmd
);
12458 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_community4_cmd
);
12459 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
12460 install_element (VIEW_NODE
, &show_ip_bgp_community2_exact_cmd
);
12461 install_element (VIEW_NODE
, &show_ip_bgp_community3_exact_cmd
);
12462 install_element (VIEW_NODE
, &show_ip_bgp_community4_exact_cmd
);
12463 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
12464 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
12465 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
12466 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
12467 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
12468 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
12469 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
12470 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
12471 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
12472 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
12473 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
12474 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
12475 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
12476 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
12477 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd
);
12478 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
12479 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
12480 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
12481 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
12482 install_element (VIEW_NODE
, &show_ip_bgp_dampened_paths_cmd
);
12483 install_element (VIEW_NODE
, &show_ip_bgp_flap_statistics_cmd
);
12484 install_element (VIEW_NODE
, &show_ip_bgp_flap_address_cmd
);
12485 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_cmd
);
12486 install_element (VIEW_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
12487 install_element (VIEW_NODE
, &show_ip_bgp_flap_regexp_cmd
);
12488 install_element (VIEW_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
12489 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
12490 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
12491 install_element (VIEW_NODE
, &show_ip_bgp_flap_route_map_cmd
);
12492 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
12493 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
12494 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_cmd
);
12495 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_rsclient_cmd
);
12496 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_route_cmd
);
12497 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_rsclient_route_cmd
);
12498 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
12499 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_rsclient_prefix_cmd
);
12500 install_element (VIEW_NODE
, &show_ip_bgp_view_neighbor_advertised_route_cmd
);
12501 install_element (VIEW_NODE
, &show_ip_bgp_view_neighbor_received_routes_cmd
);
12502 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_cmd
);
12503 install_element (VIEW_NODE
, &show_bgp_view_ipv4_safi_rsclient_cmd
);
12504 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
12505 install_element (VIEW_NODE
, &show_bgp_view_ipv4_safi_rsclient_route_cmd
);
12506 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
12507 install_element (VIEW_NODE
, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd
);
12509 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
12510 install_element (RESTRICTED_NODE
, &show_ip_bgp_route_cmd
);
12511 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_route_cmd
);
12512 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_route_cmd
);
12513 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
12514 install_element (RESTRICTED_NODE
, &show_ip_bgp_prefix_cmd
);
12515 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
12516 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
12517 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
12518 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
12519 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_route_cmd
);
12520 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_prefix_cmd
);
12521 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_cmd
);
12522 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_cmd
);
12523 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_cmd
);
12524 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_cmd
);
12525 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_cmd
);
12526 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
12527 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
12528 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
12529 install_element (RESTRICTED_NODE
, &show_bgp_view_afi_safi_community_all_cmd
);
12530 install_element (RESTRICTED_NODE
, &show_bgp_view_afi_safi_community_cmd
);
12531 install_element (RESTRICTED_NODE
, &show_bgp_view_afi_safi_community2_cmd
);
12532 install_element (RESTRICTED_NODE
, &show_bgp_view_afi_safi_community3_cmd
);
12533 install_element (RESTRICTED_NODE
, &show_bgp_view_afi_safi_community4_cmd
);
12534 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_exact_cmd
);
12535 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_exact_cmd
);
12536 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_exact_cmd
);
12537 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_exact_cmd
);
12538 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
12539 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
12540 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
12541 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
12542 install_element (RESTRICTED_NODE
, &show_ip_bgp_rsclient_route_cmd
);
12543 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_rsclient_route_cmd
);
12544 install_element (RESTRICTED_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
12545 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_rsclient_prefix_cmd
);
12546 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
12547 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv4_safi_rsclient_route_cmd
);
12548 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
12549 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd
);
12551 install_element (ENABLE_NODE
, &show_ip_bgp_cmd
);
12552 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cmd
);
12553 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_cmd
);
12554 install_element (ENABLE_NODE
, &show_ip_bgp_route_cmd
);
12555 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_cmd
);
12556 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_route_cmd
);
12557 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
12558 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
12559 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_cmd
);
12560 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
12561 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
12562 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
12563 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
12564 install_element (ENABLE_NODE
, &show_ip_bgp_view_cmd
);
12565 install_element (ENABLE_NODE
, &show_ip_bgp_view_route_cmd
);
12566 install_element (ENABLE_NODE
, &show_ip_bgp_view_prefix_cmd
);
12567 install_element (ENABLE_NODE
, &show_ip_bgp_regexp_cmd
);
12568 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
12569 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_list_cmd
);
12570 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
12571 install_element (ENABLE_NODE
, &show_ip_bgp_filter_list_cmd
);
12572 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
12573 install_element (ENABLE_NODE
, &show_ip_bgp_route_map_cmd
);
12574 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
12575 install_element (ENABLE_NODE
, &show_ip_bgp_cidr_only_cmd
);
12576 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
12577 install_element (ENABLE_NODE
, &show_ip_bgp_community_all_cmd
);
12578 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
12579 install_element (ENABLE_NODE
, &show_ip_bgp_community_cmd
);
12580 install_element (ENABLE_NODE
, &show_ip_bgp_community2_cmd
);
12581 install_element (ENABLE_NODE
, &show_ip_bgp_community3_cmd
);
12582 install_element (ENABLE_NODE
, &show_ip_bgp_community4_cmd
);
12583 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_cmd
);
12584 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
12585 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
12586 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
12587 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_community_all_cmd
);
12588 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_community_cmd
);
12589 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_community2_cmd
);
12590 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_community3_cmd
);
12591 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_community4_cmd
);
12592 install_element (ENABLE_NODE
, &show_ip_bgp_community_exact_cmd
);
12593 install_element (ENABLE_NODE
, &show_ip_bgp_community2_exact_cmd
);
12594 install_element (ENABLE_NODE
, &show_ip_bgp_community3_exact_cmd
);
12595 install_element (ENABLE_NODE
, &show_ip_bgp_community4_exact_cmd
);
12596 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
12597 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
12598 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
12599 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
12600 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_cmd
);
12601 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
12602 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_exact_cmd
);
12603 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
12604 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_longer_cmd
);
12605 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
12606 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
12607 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
12608 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
12609 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
12610 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd
);
12611 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
12612 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
12613 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
12614 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
12615 install_element (ENABLE_NODE
, &show_ip_bgp_dampened_paths_cmd
);
12616 install_element (ENABLE_NODE
, &show_ip_bgp_flap_statistics_cmd
);
12617 install_element (ENABLE_NODE
, &show_ip_bgp_flap_address_cmd
);
12618 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_cmd
);
12619 install_element (ENABLE_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
12620 install_element (ENABLE_NODE
, &show_ip_bgp_flap_regexp_cmd
);
12621 install_element (ENABLE_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
12622 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
12623 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
12624 install_element (ENABLE_NODE
, &show_ip_bgp_flap_route_map_cmd
);
12625 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
12626 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
12627 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_cmd
);
12628 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_rsclient_cmd
);
12629 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_route_cmd
);
12630 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_rsclient_route_cmd
);
12631 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
12632 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_rsclient_prefix_cmd
);
12633 install_element (ENABLE_NODE
, &show_ip_bgp_view_neighbor_advertised_route_cmd
);
12634 install_element (ENABLE_NODE
, &show_ip_bgp_view_neighbor_received_routes_cmd
);
12635 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_cmd
);
12636 install_element (ENABLE_NODE
, &show_bgp_view_ipv4_safi_rsclient_cmd
);
12637 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
12638 install_element (ENABLE_NODE
, &show_bgp_view_ipv4_safi_rsclient_route_cmd
);
12639 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
12640 install_element (ENABLE_NODE
, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd
);
12642 /* BGP dampening clear commands */
12643 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_cmd
);
12644 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_prefix_cmd
);
12645 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_cmd
);
12646 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_mask_cmd
);
12649 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_prefix_counts_cmd
);
12650 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
);
12651 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
);
12653 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_prefix_counts_cmd
);
12655 /* New config IPv6 BGP commands. */
12656 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
12657 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_route_map_cmd
);
12658 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
12659 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_route_map_cmd
);
12661 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
12662 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
12663 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
12664 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
12666 /* Old config IPv6 BGP commands. */
12667 install_element (BGP_NODE
, &old_ipv6_bgp_network_cmd
);
12668 install_element (BGP_NODE
, &old_no_ipv6_bgp_network_cmd
);
12670 install_element (BGP_NODE
, &old_ipv6_aggregate_address_cmd
);
12671 install_element (BGP_NODE
, &old_ipv6_aggregate_address_summary_only_cmd
);
12672 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_cmd
);
12673 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_summary_only_cmd
);
12675 install_element (VIEW_NODE
, &show_bgp_cmd
);
12676 install_element (VIEW_NODE
, &show_bgp_ipv6_cmd
);
12677 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_cmd
);
12678 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
12679 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
12680 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_cmd
);
12681 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
12682 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
12683 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
12684 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
12685 install_element (VIEW_NODE
, &show_bgp_ipv6_regexp_cmd
);
12686 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
12687 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
12688 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
12689 install_element (VIEW_NODE
, &show_bgp_ipv6_filter_list_cmd
);
12690 install_element (VIEW_NODE
, &show_bgp_route_map_cmd
);
12691 install_element (VIEW_NODE
, &show_bgp_ipv6_route_map_cmd
);
12692 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
12693 install_element (VIEW_NODE
, &show_bgp_ipv6_community_all_cmd
);
12694 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
12695 install_element (VIEW_NODE
, &show_bgp_ipv6_community_cmd
);
12696 install_element (VIEW_NODE
, &show_bgp_community2_cmd
);
12697 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_cmd
);
12698 install_element (VIEW_NODE
, &show_bgp_community3_cmd
);
12699 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_cmd
);
12700 install_element (VIEW_NODE
, &show_bgp_community4_cmd
);
12701 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_cmd
);
12702 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
12703 install_element (VIEW_NODE
, &show_bgp_ipv6_community_exact_cmd
);
12704 install_element (VIEW_NODE
, &show_bgp_community2_exact_cmd
);
12705 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
12706 install_element (VIEW_NODE
, &show_bgp_community3_exact_cmd
);
12707 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
12708 install_element (VIEW_NODE
, &show_bgp_community4_exact_cmd
);
12709 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
12710 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
12711 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_cmd
);
12712 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
12713 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
12714 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
12715 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
12716 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
12717 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
12718 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
12719 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
12720 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
12721 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
12722 install_element (VIEW_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
12723 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
12724 install_element (VIEW_NODE
, &show_bgp_neighbor_flap_cmd
);
12725 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
12726 install_element (VIEW_NODE
, &show_bgp_neighbor_damp_cmd
);
12727 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
12728 install_element (VIEW_NODE
, &show_bgp_rsclient_cmd
);
12729 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_rsclient_cmd
);
12730 install_element (VIEW_NODE
, &show_bgp_rsclient_route_cmd
);
12731 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_rsclient_route_cmd
);
12732 install_element (VIEW_NODE
, &show_bgp_rsclient_prefix_cmd
);
12733 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_rsclient_prefix_cmd
);
12734 install_element (VIEW_NODE
, &show_bgp_view_cmd
);
12735 install_element (VIEW_NODE
, &show_bgp_view_ipv6_cmd
);
12736 install_element (VIEW_NODE
, &show_bgp_view_route_cmd
);
12737 install_element (VIEW_NODE
, &show_bgp_view_ipv6_route_cmd
);
12738 install_element (VIEW_NODE
, &show_bgp_view_prefix_cmd
);
12739 install_element (VIEW_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
12740 install_element (VIEW_NODE
, &show_bgp_view_neighbor_advertised_route_cmd
);
12741 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_advertised_route_cmd
);
12742 install_element (VIEW_NODE
, &show_bgp_view_neighbor_received_routes_cmd
);
12743 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_received_routes_cmd
);
12744 install_element (VIEW_NODE
, &show_bgp_view_neighbor_routes_cmd
);
12745 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_routes_cmd
);
12746 install_element (VIEW_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
12747 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
12748 install_element (VIEW_NODE
, &show_bgp_view_neighbor_flap_cmd
);
12749 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_flap_cmd
);
12750 install_element (VIEW_NODE
, &show_bgp_view_neighbor_damp_cmd
);
12751 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_damp_cmd
);
12752 install_element (VIEW_NODE
, &show_bgp_view_rsclient_cmd
);
12753 install_element (VIEW_NODE
, &show_bgp_view_ipv6_safi_rsclient_cmd
);
12754 install_element (VIEW_NODE
, &show_bgp_view_rsclient_route_cmd
);
12755 install_element (VIEW_NODE
, &show_bgp_view_ipv6_safi_rsclient_route_cmd
);
12756 install_element (VIEW_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
12757 install_element (VIEW_NODE
, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd
);
12760 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
12762 install_element (RESTRICTED_NODE
, &show_bgp_route_cmd
);
12763 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_route_cmd
);
12764 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_route_cmd
);
12765 install_element (RESTRICTED_NODE
, &show_bgp_prefix_cmd
);
12766 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_prefix_cmd
);
12767 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
12768 install_element (RESTRICTED_NODE
, &show_bgp_community_cmd
);
12769 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_cmd
);
12770 install_element (RESTRICTED_NODE
, &show_bgp_community2_cmd
);
12771 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_cmd
);
12772 install_element (RESTRICTED_NODE
, &show_bgp_community3_cmd
);
12773 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_cmd
);
12774 install_element (RESTRICTED_NODE
, &show_bgp_community4_cmd
);
12775 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_cmd
);
12776 install_element (RESTRICTED_NODE
, &show_bgp_community_exact_cmd
);
12777 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_exact_cmd
);
12778 install_element (RESTRICTED_NODE
, &show_bgp_community2_exact_cmd
);
12779 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
12780 install_element (RESTRICTED_NODE
, &show_bgp_community3_exact_cmd
);
12781 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
12782 install_element (RESTRICTED_NODE
, &show_bgp_community4_exact_cmd
);
12783 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
12784 install_element (RESTRICTED_NODE
, &show_bgp_rsclient_route_cmd
);
12785 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_rsclient_route_cmd
);
12786 install_element (RESTRICTED_NODE
, &show_bgp_rsclient_prefix_cmd
);
12787 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_rsclient_prefix_cmd
);
12788 install_element (RESTRICTED_NODE
, &show_bgp_view_route_cmd
);
12789 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_route_cmd
);
12790 install_element (RESTRICTED_NODE
, &show_bgp_view_prefix_cmd
);
12791 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
12792 install_element (RESTRICTED_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
12793 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
12794 install_element (RESTRICTED_NODE
, &show_bgp_view_rsclient_route_cmd
);
12795 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_safi_rsclient_route_cmd
);
12796 install_element (RESTRICTED_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
12797 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd
);
12799 install_element (ENABLE_NODE
, &show_bgp_cmd
);
12800 install_element (ENABLE_NODE
, &show_bgp_ipv6_cmd
);
12801 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_cmd
);
12802 install_element (ENABLE_NODE
, &show_bgp_route_cmd
);
12803 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_cmd
);
12804 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_route_cmd
);
12805 install_element (ENABLE_NODE
, &show_bgp_prefix_cmd
);
12806 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_cmd
);
12807 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
12808 install_element (ENABLE_NODE
, &show_bgp_regexp_cmd
);
12809 install_element (ENABLE_NODE
, &show_bgp_ipv6_regexp_cmd
);
12810 install_element (ENABLE_NODE
, &show_bgp_prefix_list_cmd
);
12811 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
12812 install_element (ENABLE_NODE
, &show_bgp_filter_list_cmd
);
12813 install_element (ENABLE_NODE
, &show_bgp_ipv6_filter_list_cmd
);
12814 install_element (ENABLE_NODE
, &show_bgp_route_map_cmd
);
12815 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_map_cmd
);
12816 install_element (ENABLE_NODE
, &show_bgp_community_all_cmd
);
12817 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_all_cmd
);
12818 install_element (ENABLE_NODE
, &show_bgp_community_cmd
);
12819 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_cmd
);
12820 install_element (ENABLE_NODE
, &show_bgp_community2_cmd
);
12821 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_cmd
);
12822 install_element (ENABLE_NODE
, &show_bgp_community3_cmd
);
12823 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_cmd
);
12824 install_element (ENABLE_NODE
, &show_bgp_community4_cmd
);
12825 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_cmd
);
12826 install_element (ENABLE_NODE
, &show_bgp_community_exact_cmd
);
12827 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_exact_cmd
);
12828 install_element (ENABLE_NODE
, &show_bgp_community2_exact_cmd
);
12829 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
12830 install_element (ENABLE_NODE
, &show_bgp_community3_exact_cmd
);
12831 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
12832 install_element (ENABLE_NODE
, &show_bgp_community4_exact_cmd
);
12833 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
12834 install_element (ENABLE_NODE
, &show_bgp_community_list_cmd
);
12835 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_cmd
);
12836 install_element (ENABLE_NODE
, &show_bgp_community_list_exact_cmd
);
12837 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
12838 install_element (ENABLE_NODE
, &show_bgp_prefix_longer_cmd
);
12839 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
12840 install_element (ENABLE_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
12841 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
12842 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_routes_cmd
);
12843 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
12844 install_element (ENABLE_NODE
, &show_bgp_neighbor_routes_cmd
);
12845 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
12846 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
12847 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
12848 install_element (ENABLE_NODE
, &show_bgp_neighbor_flap_cmd
);
12849 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
12850 install_element (ENABLE_NODE
, &show_bgp_neighbor_damp_cmd
);
12851 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
12852 install_element (ENABLE_NODE
, &show_bgp_rsclient_cmd
);
12853 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_rsclient_cmd
);
12854 install_element (ENABLE_NODE
, &show_bgp_rsclient_route_cmd
);
12855 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_rsclient_route_cmd
);
12856 install_element (ENABLE_NODE
, &show_bgp_rsclient_prefix_cmd
);
12857 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_rsclient_prefix_cmd
);
12858 install_element (ENABLE_NODE
, &show_bgp_view_cmd
);
12859 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_cmd
);
12860 install_element (ENABLE_NODE
, &show_bgp_view_route_cmd
);
12861 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_route_cmd
);
12862 install_element (ENABLE_NODE
, &show_bgp_view_prefix_cmd
);
12863 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
12864 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_advertised_route_cmd
);
12865 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_advertised_route_cmd
);
12866 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_received_routes_cmd
);
12867 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_received_routes_cmd
);
12868 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_routes_cmd
);
12869 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_routes_cmd
);
12870 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
12871 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
12872 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_flap_cmd
);
12873 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_flap_cmd
);
12874 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_damp_cmd
);
12875 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_damp_cmd
);
12876 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_cmd
);
12877 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_safi_rsclient_cmd
);
12878 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_route_cmd
);
12879 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_safi_rsclient_route_cmd
);
12880 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
12881 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd
);
12884 install_element (ENABLE_NODE
, &show_bgp_statistics_cmd
);
12885 install_element (ENABLE_NODE
, &show_bgp_statistics_vpnv4_cmd
);
12886 install_element (ENABLE_NODE
, &show_bgp_statistics_view_cmd
);
12887 install_element (ENABLE_NODE
, &show_bgp_statistics_view_vpnv4_cmd
);
12890 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
12891 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
12892 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
12893 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
12894 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
12895 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
12896 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
12897 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
12898 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_cmd
);
12899 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_cmd
);
12900 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_cmd
);
12901 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
12902 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
12903 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
12904 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
12905 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
12906 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
12907 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
12908 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
12909 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
12910 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
12911 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
12912 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
12913 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
12914 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
12915 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
12916 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_cmd
);
12917 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_cmd
);
12918 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_cmd
);
12919 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
12920 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
12921 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
12922 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
12923 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
12924 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
12925 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
12928 install_element (ENABLE_NODE
, &show_ipv6_bgp_cmd
);
12929 install_element (ENABLE_NODE
, &show_ipv6_bgp_route_cmd
);
12930 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_cmd
);
12931 install_element (ENABLE_NODE
, &show_ipv6_bgp_regexp_cmd
);
12932 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
12933 install_element (ENABLE_NODE
, &show_ipv6_bgp_filter_list_cmd
);
12934 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_all_cmd
);
12935 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_cmd
);
12936 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_cmd
);
12937 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_cmd
);
12938 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_cmd
);
12939 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_exact_cmd
);
12940 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
12941 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
12942 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
12943 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_cmd
);
12944 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
12945 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
12946 install_element (ENABLE_NODE
, &show_ipv6_mbgp_cmd
);
12947 install_element (ENABLE_NODE
, &show_ipv6_mbgp_route_cmd
);
12948 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_cmd
);
12949 install_element (ENABLE_NODE
, &show_ipv6_mbgp_regexp_cmd
);
12950 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
12951 install_element (ENABLE_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
12952 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_all_cmd
);
12953 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_cmd
);
12954 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_cmd
);
12955 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_cmd
);
12956 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_cmd
);
12957 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
12958 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
12959 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
12960 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
12961 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_cmd
);
12962 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
12963 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
12966 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
12967 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
12968 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
12969 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
12972 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
12973 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
12974 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
12975 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
12978 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
12979 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
12980 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
12981 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
12982 #endif /* HAVE_IPV6 */
12984 install_element (BGP_NODE
, &bgp_distance_cmd
);
12985 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
12986 install_element (BGP_NODE
, &no_bgp_distance2_cmd
);
12987 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
12988 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
12989 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
12990 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
12992 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
12993 install_element (BGP_NODE
, &bgp_damp_set2_cmd
);
12994 install_element (BGP_NODE
, &bgp_damp_set3_cmd
);
12995 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
12996 install_element (BGP_NODE
, &bgp_damp_unset2_cmd
);
12997 install_element (BGP_IPV4_NODE
, &bgp_damp_set_cmd
);
12998 install_element (BGP_IPV4_NODE
, &bgp_damp_set2_cmd
);
12999 install_element (BGP_IPV4_NODE
, &bgp_damp_set3_cmd
);
13000 install_element (BGP_IPV4_NODE
, &bgp_damp_unset_cmd
);
13001 install_element (BGP_IPV4_NODE
, &bgp_damp_unset2_cmd
);
13003 /* Deprecated AS-Pathlimit commands */
13004 install_element (BGP_NODE
, &bgp_network_ttl_cmd
);
13005 install_element (BGP_NODE
, &bgp_network_mask_ttl_cmd
);
13006 install_element (BGP_NODE
, &bgp_network_mask_natural_ttl_cmd
);
13007 install_element (BGP_NODE
, &bgp_network_backdoor_ttl_cmd
);
13008 install_element (BGP_NODE
, &bgp_network_mask_backdoor_ttl_cmd
);
13009 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_ttl_cmd
);
13011 install_element (BGP_NODE
, &no_bgp_network_ttl_cmd
);
13012 install_element (BGP_NODE
, &no_bgp_network_mask_ttl_cmd
);
13013 install_element (BGP_NODE
, &no_bgp_network_mask_natural_ttl_cmd
);
13014 install_element (BGP_NODE
, &no_bgp_network_backdoor_ttl_cmd
);
13015 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_ttl_cmd
);
13016 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_ttl_cmd
);
13018 install_element (BGP_IPV4_NODE
, &bgp_network_ttl_cmd
);
13019 install_element (BGP_IPV4_NODE
, &bgp_network_mask_ttl_cmd
);
13020 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_ttl_cmd
);
13021 install_element (BGP_IPV4_NODE
, &bgp_network_backdoor_ttl_cmd
);
13022 install_element (BGP_IPV4_NODE
, &bgp_network_mask_backdoor_ttl_cmd
);
13023 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_backdoor_ttl_cmd
);
13025 install_element (BGP_IPV4_NODE
, &no_bgp_network_ttl_cmd
);
13026 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_ttl_cmd
);
13027 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_ttl_cmd
);
13028 install_element (BGP_IPV4_NODE
, &no_bgp_network_backdoor_ttl_cmd
);
13029 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_backdoor_ttl_cmd
);
13030 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_backdoor_ttl_cmd
);
13032 install_element (BGP_IPV4M_NODE
, &bgp_network_ttl_cmd
);
13033 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_ttl_cmd
);
13034 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_ttl_cmd
);
13035 install_element (BGP_IPV4M_NODE
, &bgp_network_backdoor_ttl_cmd
);
13036 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_backdoor_ttl_cmd
);
13037 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_backdoor_ttl_cmd
);
13039 install_element (BGP_IPV4M_NODE
, &no_bgp_network_ttl_cmd
);
13040 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_ttl_cmd
);
13041 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_ttl_cmd
);
13042 install_element (BGP_IPV4M_NODE
, &no_bgp_network_backdoor_ttl_cmd
);
13043 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_backdoor_ttl_cmd
);
13044 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_backdoor_ttl_cmd
);
13047 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_ttl_cmd
);
13048 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_ttl_cmd
);
13053 bgp_route_finish (void)
13055 bgp_table_unlock (bgp_distance_table
);
13056 bgp_distance_table
= NULL
;