1 /* BGP routing information
2 Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro
4 This file is part of GNU Zebra.
6 GNU Zebra is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 GNU Zebra is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Zebra; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
33 #include "sockunion.h"
36 #include "workqueue.h"
38 #include "bgpd/bgpd.h"
39 #include "bgpd/bgp_table.h"
40 #include "bgpd/bgp_route.h"
41 #include "bgpd/bgp_attr.h"
42 #include "bgpd/bgp_debug.h"
43 #include "bgpd/bgp_aspath.h"
44 #include "bgpd/bgp_regex.h"
45 #include "bgpd/bgp_community.h"
46 #include "bgpd/bgp_ecommunity.h"
47 #include "bgpd/bgp_clist.h"
48 #include "bgpd/bgp_packet.h"
49 #include "bgpd/bgp_filter.h"
50 #include "bgpd/bgp_fsm.h"
51 #include "bgpd/bgp_mplsvpn.h"
52 #include "bgpd/bgp_nexthop.h"
53 #include "bgpd/bgp_damp.h"
54 #include "bgpd/bgp_advertise.h"
55 #include "bgpd/bgp_zebra.h"
56 #include "bgpd/bgp_vty.h"
58 /* Extern from bgp_dump.c */
59 extern const char *bgp_origin_str
[];
60 extern const char *bgp_origin_long_str
[];
62 static struct bgp_node
*
63 bgp_afi_node_get (struct bgp_table
*table
, afi_t afi
, safi_t safi
, struct prefix
*p
,
64 struct prefix_rd
*prd
)
67 struct bgp_node
*prn
= NULL
;
73 if (safi
== SAFI_MPLS_VPN
)
75 prn
= bgp_node_get (table
, (struct prefix
*) prd
);
77 if (prn
->info
== NULL
)
78 prn
->info
= bgp_table_init (afi
, safi
);
80 bgp_unlock_node (prn
);
84 rn
= bgp_node_get (table
, p
);
86 if (safi
== SAFI_MPLS_VPN
)
92 /* Allocate bgp_info_extra */
93 static struct bgp_info_extra
*
94 bgp_info_extra_new (void)
96 struct bgp_info_extra
*new;
97 new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA
, sizeof (struct bgp_info_extra
));
102 bgp_info_extra_free (struct bgp_info_extra
**extra
)
106 if ((*extra
)->damp_info
)
107 bgp_damp_info_free ((*extra
)->damp_info
, 0);
109 (*extra
)->damp_info
= NULL
;
111 XFREE (MTYPE_BGP_ROUTE_EXTRA
, *extra
);
117 /* Get bgp_info extra information for the given bgp_info, lazy allocated
120 struct bgp_info_extra
*
121 bgp_info_extra_get (struct bgp_info
*ri
)
124 ri
->extra
= bgp_info_extra_new();
128 /* Allocate new bgp info structure. */
129 static struct bgp_info
*
132 return XCALLOC (MTYPE_BGP_ROUTE
, sizeof (struct bgp_info
));
135 /* Free bgp route information. */
137 bgp_info_free (struct bgp_info
*binfo
)
140 bgp_attr_unintern (binfo
->attr
);
142 bgp_info_extra_free (&binfo
->extra
);
144 peer_unlock (binfo
->peer
); /* bgp_info peer reference */
146 XFREE (MTYPE_BGP_ROUTE
, binfo
);
150 bgp_info_lock (struct bgp_info
*binfo
)
157 bgp_info_unlock (struct bgp_info
*binfo
)
159 assert (binfo
&& binfo
->lock
> 0);
162 if (binfo
->lock
== 0)
165 zlog_debug ("%s: unlocked and freeing", __func__
);
166 zlog_backtrace (LOG_DEBUG
);
168 bgp_info_free (binfo
);
173 if (binfo
->lock
== 1)
175 zlog_debug ("%s: unlocked to 1", __func__
);
176 zlog_backtrace (LOG_DEBUG
);
184 bgp_info_add (struct bgp_node
*rn
, struct bgp_info
*ri
)
186 struct bgp_info
*top
;
198 peer_lock (ri
->peer
); /* bgp_info peer reference */
201 /* Do the actual removal of info from RIB, for use by bgp_process
202 completion callback *only* */
204 bgp_info_reap (struct bgp_node
*rn
, struct bgp_info
*ri
)
207 ri
->next
->prev
= ri
->prev
;
209 ri
->prev
->next
= ri
->next
;
213 bgp_info_unlock (ri
);
214 bgp_unlock_node (rn
);
218 bgp_info_delete (struct bgp_node
*rn
, struct bgp_info
*ri
)
220 bgp_info_set_flag (rn
, ri
, BGP_INFO_REMOVED
);
221 /* set of previous already took care of pcount */
222 UNSET_FLAG (ri
->flags
, BGP_INFO_VALID
);
225 /* undo the effects of a previous call to bgp_info_delete; typically
226 called when a route is deleted and then quickly re-added before the
227 deletion has been processed */
229 bgp_info_restore (struct bgp_node
*rn
, struct bgp_info
*ri
)
231 bgp_info_unset_flag (rn
, ri
, BGP_INFO_REMOVED
);
232 /* unset of previous already took care of pcount */
233 SET_FLAG (ri
->flags
, BGP_INFO_VALID
);
236 /* Adjust pcount as required */
238 bgp_pcount_adjust (struct bgp_node
*rn
, struct bgp_info
*ri
)
240 assert (rn
&& rn
->table
);
241 assert (ri
&& ri
->peer
&& ri
->peer
->bgp
);
243 /* Ignore 'pcount' for RS-client tables */
244 if (rn
->table
->type
!= BGP_TABLE_MAIN
245 || ri
->peer
== ri
->peer
->bgp
->peer_self
)
248 if (BGP_INFO_HOLDDOWN (ri
)
249 && CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
252 UNSET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
254 /* slight hack, but more robust against errors. */
255 if (ri
->peer
->pcount
[rn
->table
->afi
][rn
->table
->safi
])
256 ri
->peer
->pcount
[rn
->table
->afi
][rn
->table
->safi
]--;
259 zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s",
260 __func__
, ri
->peer
->host
);
261 zlog_backtrace (LOG_WARNING
);
262 zlog_warn ("%s: Please report to Quagga bugzilla", __func__
);
265 else if (!BGP_INFO_HOLDDOWN (ri
)
266 && !CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
268 SET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
269 ri
->peer
->pcount
[rn
->table
->afi
][rn
->table
->safi
]++;
274 /* Set/unset bgp_info flags, adjusting any other state as needed.
275 * This is here primarily to keep prefix-count in check.
278 bgp_info_set_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
280 SET_FLAG (ri
->flags
, flag
);
282 /* early bath if we know it's not a flag that changes useability state */
283 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_UNUSEABLE
))
286 bgp_pcount_adjust (rn
, ri
);
290 bgp_info_unset_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
292 UNSET_FLAG (ri
->flags
, flag
);
294 /* early bath if we know it's not a flag that changes useability state */
295 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_UNUSEABLE
))
298 bgp_pcount_adjust (rn
, ri
);
301 /* Get MED value. If MED value is missing and "bgp bestpath
302 missing-as-worst" is specified, treat it as the worst value. */
304 bgp_med_value (struct attr
*attr
, struct bgp
*bgp
)
306 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
310 if (bgp_flag_check (bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
317 /* Compare two bgp route entity. br is preferable then return 1. */
319 bgp_info_cmp (struct bgp
*bgp
, struct bgp_info
*new, struct bgp_info
*exist
)
322 u_int32_t exist_pref
;
325 u_int32_t new_weight
= 0;
326 u_int32_t exist_weight
= 0;
327 struct in_addr new_id
;
328 struct in_addr exist_id
;
331 int internal_as_route
= 0;
332 int confed_as_route
= 0;
341 /* 1. Weight check. */
342 if (new->attr
->extra
)
343 new_weight
= new->attr
->extra
->weight
;
344 if (exist
->attr
->extra
)
345 exist_weight
= exist
->attr
->extra
->weight
;
346 if (new_weight
> exist_weight
)
348 if (new_weight
< exist_weight
)
351 /* 2. Local preference check. */
352 if (new->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
353 new_pref
= new->attr
->local_pref
;
355 new_pref
= bgp
->default_local_pref
;
357 if (exist
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
358 exist_pref
= exist
->attr
->local_pref
;
360 exist_pref
= bgp
->default_local_pref
;
362 if (new_pref
> exist_pref
)
364 if (new_pref
< exist_pref
)
367 /* 3. Local route check. */
368 if (new->sub_type
== BGP_ROUTE_STATIC
)
370 if (exist
->sub_type
== BGP_ROUTE_STATIC
)
373 if (new->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
375 if (exist
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
378 if (new->sub_type
== BGP_ROUTE_AGGREGATE
)
380 if (exist
->sub_type
== BGP_ROUTE_AGGREGATE
)
383 /* 4. AS path length check. */
384 if (! bgp_flag_check (bgp
, BGP_FLAG_ASPATH_IGNORE
))
386 int exist_hops
= aspath_count_hops (exist
->attr
->aspath
);
387 int exist_confeds
= aspath_count_confeds (exist
->attr
->aspath
);
389 if (bgp_flag_check (bgp
, BGP_FLAG_ASPATH_CONFED
))
393 aspath_hops
= aspath_count_hops (new->attr
->aspath
);
394 aspath_hops
+= aspath_count_confeds (new->attr
->aspath
);
396 if ( aspath_hops
< (exist_hops
+ exist_confeds
))
398 if ( aspath_hops
> (exist_hops
+ exist_confeds
))
403 int newhops
= aspath_count_hops (new->attr
->aspath
);
405 if (newhops
< exist_hops
)
407 if (newhops
> exist_hops
)
412 /* 5. Origin check. */
413 if (new->attr
->origin
< exist
->attr
->origin
)
415 if (new->attr
->origin
> exist
->attr
->origin
)
419 internal_as_route
= (aspath_count_hops (new->attr
->aspath
) == 0
420 && aspath_count_hops (exist
->attr
->aspath
) == 0);
421 confed_as_route
= (aspath_count_confeds (new->attr
->aspath
) > 0
422 && aspath_count_confeds (exist
->attr
->aspath
) > 0
423 && aspath_count_hops (new->attr
->aspath
) == 0
424 && aspath_count_hops (exist
->attr
->aspath
) == 0);
426 if (bgp_flag_check (bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
)
427 || (bgp_flag_check (bgp
, BGP_FLAG_MED_CONFED
)
429 || aspath_cmp_left (new->attr
->aspath
, exist
->attr
->aspath
)
430 || aspath_cmp_left_confed (new->attr
->aspath
, exist
->attr
->aspath
)
431 || internal_as_route
)
433 new_med
= bgp_med_value (new->attr
, bgp
);
434 exist_med
= bgp_med_value (exist
->attr
, bgp
);
436 if (new_med
< exist_med
)
438 if (new_med
> exist_med
)
442 /* 7. Peer type check. */
443 if (peer_sort (new->peer
) == BGP_PEER_EBGP
444 && peer_sort (exist
->peer
) == BGP_PEER_IBGP
)
446 if (peer_sort (new->peer
) == BGP_PEER_EBGP
447 && peer_sort (exist
->peer
) == BGP_PEER_CONFED
)
449 if (peer_sort (new->peer
) == BGP_PEER_IBGP
450 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
452 if (peer_sort (new->peer
) == BGP_PEER_CONFED
453 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
456 /* 8. IGP metric check. */
457 if (new->extra
|| exist
->extra
)
459 uint32_t newm
= (new->extra
? new->extra
->igpmetric
: 0);
460 uint32_t existm
= (exist
->extra
? exist
->extra
->igpmetric
: 0);
468 /* 9. Maximum path check. */
470 /* 10. If both paths are external, prefer the path that was received
471 first (the oldest one). This step minimizes route-flap, since a
472 newer path won't displace an older one, even if it was the
473 preferred route based on the additional decision criteria below. */
474 if (! bgp_flag_check (bgp
, BGP_FLAG_COMPARE_ROUTER_ID
)
475 && peer_sort (new->peer
) == BGP_PEER_EBGP
476 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
478 if (CHECK_FLAG (new->flags
, BGP_INFO_SELECTED
))
480 if (CHECK_FLAG (exist
->flags
, BGP_INFO_SELECTED
))
484 /* 11. Rourter-ID comparision. */
485 if (new->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
486 new_id
.s_addr
= new->attr
->extra
->originator_id
.s_addr
;
488 new_id
.s_addr
= new->peer
->remote_id
.s_addr
;
489 if (exist
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
490 exist_id
.s_addr
= exist
->attr
->extra
->originator_id
.s_addr
;
492 exist_id
.s_addr
= exist
->peer
->remote_id
.s_addr
;
494 if (ntohl (new_id
.s_addr
) < ntohl (exist_id
.s_addr
))
496 if (ntohl (new_id
.s_addr
) > ntohl (exist_id
.s_addr
))
499 /* 12. Cluster length comparision. */
500 if (new->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
501 new_cluster
= new->attr
->extra
->cluster
->length
;
504 if (exist
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
505 exist_cluster
= exist
->attr
->extra
->cluster
->length
;
509 if (new_cluster
< exist_cluster
)
511 if (new_cluster
> exist_cluster
)
514 /* 13. Neighbor address comparision. */
515 ret
= sockunion_cmp (new->peer
->su_remote
, exist
->peer
->su_remote
);
525 static enum filter_type
526 bgp_input_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
527 afi_t afi
, safi_t safi
)
529 struct bgp_filter
*filter
;
531 filter
= &peer
->filter
[afi
][safi
];
533 #define FILTER_EXIST_WARN(F,f,filter) \
534 if (BGP_DEBUG (update, UPDATE_IN) \
535 && !(F ## _IN (filter))) \
536 plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \
537 peer->host, #f, F ## _IN_NAME(filter));
539 if (DISTRIBUTE_IN_NAME (filter
)) {
540 FILTER_EXIST_WARN(DISTRIBUTE
, distribute
, filter
);
542 if (access_list_apply (DISTRIBUTE_IN (filter
), p
) == FILTER_DENY
)
546 if (PREFIX_LIST_IN_NAME (filter
)) {
547 FILTER_EXIST_WARN(PREFIX_LIST
, prefix
, filter
);
549 if (prefix_list_apply (PREFIX_LIST_IN (filter
), p
) == PREFIX_DENY
)
553 if (FILTER_LIST_IN_NAME (filter
)) {
554 FILTER_EXIST_WARN(FILTER_LIST
, as
, filter
);
556 if (as_list_apply (FILTER_LIST_IN (filter
), attr
->aspath
)== AS_FILTER_DENY
)
560 return FILTER_PERMIT
;
561 #undef FILTER_EXIST_WARN
564 static enum filter_type
565 bgp_output_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
566 afi_t afi
, safi_t safi
)
568 struct bgp_filter
*filter
;
570 filter
= &peer
->filter
[afi
][safi
];
572 #define FILTER_EXIST_WARN(F,f,filter) \
573 if (BGP_DEBUG (update, UPDATE_OUT) \
574 && !(F ## _OUT (filter))) \
575 plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \
576 peer->host, #f, F ## _OUT_NAME(filter));
578 if (DISTRIBUTE_OUT_NAME (filter
)) {
579 FILTER_EXIST_WARN(DISTRIBUTE
, distribute
, filter
);
581 if (access_list_apply (DISTRIBUTE_OUT (filter
), p
) == FILTER_DENY
)
585 if (PREFIX_LIST_OUT_NAME (filter
)) {
586 FILTER_EXIST_WARN(PREFIX_LIST
, prefix
, filter
);
588 if (prefix_list_apply (PREFIX_LIST_OUT (filter
), p
) == PREFIX_DENY
)
592 if (FILTER_LIST_OUT_NAME (filter
)) {
593 FILTER_EXIST_WARN(FILTER_LIST
, as
, filter
);
595 if (as_list_apply (FILTER_LIST_OUT (filter
), attr
->aspath
) == AS_FILTER_DENY
)
599 return FILTER_PERMIT
;
600 #undef FILTER_EXIST_WARN
603 /* If community attribute includes no_export then return 1. */
605 bgp_community_filter (struct peer
*peer
, struct attr
*attr
)
609 /* NO_ADVERTISE check. */
610 if (community_include (attr
->community
, COMMUNITY_NO_ADVERTISE
))
613 /* NO_EXPORT check. */
614 if (peer_sort (peer
) == BGP_PEER_EBGP
&&
615 community_include (attr
->community
, COMMUNITY_NO_EXPORT
))
618 /* NO_EXPORT_SUBCONFED check. */
619 if (peer_sort (peer
) == BGP_PEER_EBGP
620 || peer_sort (peer
) == BGP_PEER_CONFED
)
621 if (community_include (attr
->community
, COMMUNITY_NO_EXPORT_SUBCONFED
))
627 /* Route reflection loop check. */
629 bgp_cluster_filter (struct peer
*peer
, struct attr
*attr
)
631 struct in_addr cluster_id
;
633 if (attr
->extra
&& attr
->extra
->cluster
)
635 if (peer
->bgp
->config
& BGP_CONFIG_CLUSTER_ID
)
636 cluster_id
= peer
->bgp
->cluster_id
;
638 cluster_id
= peer
->bgp
->router_id
;
640 if (cluster_loop_check (attr
->extra
->cluster
, cluster_id
))
647 bgp_input_modifier (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
648 afi_t afi
, safi_t safi
)
650 struct bgp_filter
*filter
;
651 struct bgp_info info
;
652 route_map_result_t ret
;
654 filter
= &peer
->filter
[afi
][safi
];
656 /* Apply default weight value. */
658 (bgp_attr_extra_get (attr
))->weight
= peer
->weight
;
660 /* Route map apply. */
661 if (ROUTE_MAP_IN_NAME (filter
))
663 /* Duplicate current value to new strucutre for modification. */
667 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IN
);
669 /* Apply BGP route map to the attribute. */
670 ret
= route_map_apply (ROUTE_MAP_IN (filter
), p
, RMAP_BGP
, &info
);
674 if (ret
== RMAP_DENYMATCH
)
676 /* Free newly generated AS path and community by route-map. */
677 bgp_attr_flush (attr
);
685 bgp_export_modifier (struct peer
*rsclient
, struct peer
*peer
,
686 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
688 struct bgp_filter
*filter
;
689 struct bgp_info info
;
690 route_map_result_t ret
;
692 filter
= &peer
->filter
[afi
][safi
];
694 /* Route map apply. */
695 if (ROUTE_MAP_EXPORT_NAME (filter
))
697 /* Duplicate current value to new strucutre for modification. */
698 info
.peer
= rsclient
;
701 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_EXPORT
);
703 /* Apply BGP route map to the attribute. */
704 ret
= route_map_apply (ROUTE_MAP_EXPORT (filter
), p
, RMAP_BGP
, &info
);
706 rsclient
->rmap_type
= 0;
708 if (ret
== RMAP_DENYMATCH
)
710 /* Free newly generated AS path and community by route-map. */
711 bgp_attr_flush (attr
);
719 bgp_import_modifier (struct peer
*rsclient
, struct peer
*peer
,
720 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
722 struct bgp_filter
*filter
;
723 struct bgp_info info
;
724 route_map_result_t ret
;
726 filter
= &rsclient
->filter
[afi
][safi
];
728 /* Apply default weight value. */
730 (bgp_attr_extra_get (attr
))->weight
= peer
->weight
;
732 /* Route map apply. */
733 if (ROUTE_MAP_IMPORT_NAME (filter
))
735 /* Duplicate current value to new strucutre for modification. */
739 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
);
741 /* Apply BGP route map to the attribute. */
742 ret
= route_map_apply (ROUTE_MAP_IMPORT (filter
), p
, RMAP_BGP
, &info
);
746 if (ret
== RMAP_DENYMATCH
)
748 /* Free newly generated AS path and community by route-map. */
749 bgp_attr_flush (attr
);
757 bgp_announce_check (struct bgp_info
*ri
, struct peer
*peer
, struct prefix
*p
,
758 struct attr
*attr
, afi_t afi
, safi_t safi
)
761 char buf
[SU_ADDRSTRLEN
];
762 struct bgp_filter
*filter
;
769 filter
= &peer
->filter
[afi
][safi
];
772 if (DISABLE_BGP_ANNOUNCE
)
775 /* Do not send announces to RS-clients from the 'normal' bgp_table. */
776 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
779 /* Do not send back route to sender. */
783 /* If peer's id and route's nexthop are same. draft-ietf-idr-bgp4-23 5.1.3 */
784 if (p
->family
== AF_INET
785 && IPV4_ADDR_SAME(&peer
->remote_id
, &ri
->attr
->nexthop
))
788 if (p
->family
== AF_INET6
789 && IPV6_ADDR_SAME(&peer
->remote_id
, &ri
->attr
->nexthop
))
793 /* Aggregate-address suppress check. */
794 if (ri
->extra
&& ri
->extra
->suppress
)
795 if (! UNSUPPRESS_MAP_NAME (filter
))
798 /* Default route check. */
799 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
))
801 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
)
804 else if (p
->family
== AF_INET6
&& p
->prefixlen
== 0)
806 #endif /* HAVE_IPV6 */
809 /* Transparency check. */
810 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
)
811 && CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
816 /* If community is not disabled check the no-export and local. */
817 if (! transparent
&& bgp_community_filter (peer
, ri
->attr
))
820 /* If the attribute has originator-id and it is same as remote
822 if (ri
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
))
824 if (IPV4_ADDR_SAME (&peer
->remote_id
, &ri
->attr
->extra
->originator_id
))
826 if (BGP_DEBUG (filter
, FILTER
))
827 zlog (peer
->log
, LOG_DEBUG
,
828 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
830 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
836 /* ORF prefix-list filter check */
837 if (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_RM_ADV
)
838 && (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_RCV
)
839 || CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)))
840 if (peer
->orf_plist
[afi
][safi
])
842 if (prefix_list_apply (peer
->orf_plist
[afi
][safi
], p
) == PREFIX_DENY
)
846 /* Output filter check. */
847 if (bgp_output_filter (peer
, p
, ri
->attr
, afi
, safi
) == FILTER_DENY
)
849 if (BGP_DEBUG (filter
, FILTER
))
850 zlog (peer
->log
, LOG_DEBUG
,
851 "%s [Update:SEND] %s/%d is filtered",
853 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
858 #ifdef BGP_SEND_ASPATH_CHECK
859 /* AS path loop check. */
860 if (aspath_loop_check (ri
->attr
->aspath
, peer
->as
))
862 if (BGP_DEBUG (filter
, FILTER
))
863 zlog (peer
->log
, LOG_DEBUG
,
864 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
865 peer
->host
, peer
->as
);
868 #endif /* BGP_SEND_ASPATH_CHECK */
870 /* If we're a CONFED we need to loop check the CONFED ID too */
871 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
873 if (aspath_loop_check(ri
->attr
->aspath
, bgp
->confed_id
))
875 if (BGP_DEBUG (filter
, FILTER
))
876 zlog (peer
->log
, LOG_DEBUG
,
877 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
884 /* Route-Reflect check. */
885 if (peer_sort (from
) == BGP_PEER_IBGP
&& peer_sort (peer
) == BGP_PEER_IBGP
)
890 /* IBGP reflection check. */
893 /* A route from a Client peer. */
894 if (CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
896 /* Reflect to all the Non-Client peers and also to the
897 Client peers other than the originator. Originator check
898 is already done. So there is noting to do. */
899 /* no bgp client-to-client reflection check. */
900 if (bgp_flag_check (bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
901 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
906 /* A route from a Non-client peer. Reflect to all other
908 if (! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
913 /* AS-Pathlimit check */
914 if (ri
->attr
->pathlimit
.ttl
&& peer_sort (peer
) == BGP_PEER_EBGP
)
915 /* Our ASN has not yet been pre-pended, that's done in packet_attribute
916 * on output. Hence the test here is for >=.
918 if (aspath_count_hops (ri
->attr
->aspath
) >= ri
->attr
->pathlimit
.ttl
)
920 if (BGP_DEBUG (filter
, FILTER
))
921 zlog_info ("%s [Update:SEND] suppressed, AS-Pathlimit TTL %u exceeded",
922 peer
->host
, ri
->attr
->pathlimit
.ttl
);
926 /* For modify attribute, copy it to temporary structure. */
927 bgp_attr_dup (attr
, ri
->attr
);
929 /* If local-preference is not set. */
930 if ((peer_sort (peer
) == BGP_PEER_IBGP
931 || peer_sort (peer
) == BGP_PEER_CONFED
)
932 && (! (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))))
934 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
);
935 attr
->local_pref
= bgp
->default_local_pref
;
938 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
939 if (peer_sort (peer
) == BGP_PEER_EBGP
940 && attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
942 if (ri
->peer
!= bgp
->peer_self
&& ! transparent
943 && ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
944 attr
->flag
&= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
));
948 if (transparent
|| reflect
949 || (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_UNCHANGED
)
950 && ((p
->family
== AF_INET
&& attr
->nexthop
.s_addr
)
952 || (p
->family
== AF_INET6
&&
953 ! IN6_IS_ADDR_UNSPECIFIED(&attr
->extra
->mp_nexthop_global
))
954 #endif /* HAVE_IPV6 */
957 /* NEXT-HOP Unchanged. */
959 else if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
960 || (p
->family
== AF_INET
&& attr
->nexthop
.s_addr
== 0)
962 || (p
->family
== AF_INET6
&&
963 IN6_IS_ADDR_UNSPECIFIED(&attr
->extra
->mp_nexthop_global
))
964 #endif /* HAVE_IPV6 */
965 || (peer_sort (peer
) == BGP_PEER_EBGP
966 && bgp_multiaccess_check_v4 (attr
->nexthop
, peer
->host
) == 0))
968 /* Set IPv4 nexthop. */
969 if (p
->family
== AF_INET
)
971 if (safi
== SAFI_MPLS_VPN
)
972 memcpy (&attr
->extra
->mp_nexthop_global_in
, &peer
->nexthop
.v4
,
975 memcpy (&attr
->nexthop
, &peer
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
978 /* Set IPv6 nexthop. */
979 if (p
->family
== AF_INET6
)
981 /* IPv6 global nexthop must be included. */
982 memcpy (&attr
->extra
->mp_nexthop_global
, &peer
->nexthop
.v6_global
,
984 attr
->extra
->mp_nexthop_len
= 16;
986 #endif /* HAVE_IPV6 */
990 if (p
->family
== AF_INET6
)
992 /* Left nexthop_local unchanged if so configured. */
993 if ( CHECK_FLAG (peer
->af_flags
[afi
][safi
],
994 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) )
996 if ( IN6_IS_ADDR_LINKLOCAL (&attr
->extra
->mp_nexthop_local
) )
997 attr
->extra
->mp_nexthop_len
=32;
999 attr
->extra
->mp_nexthop_len
=16;
1002 /* Default nexthop_local treatment for non-RS-Clients */
1005 /* Link-local address should not be transit to different peer. */
1006 attr
->extra
->mp_nexthop_len
= 16;
1008 /* Set link-local address for shared network peer. */
1009 if (peer
->shared_network
1010 && ! IN6_IS_ADDR_UNSPECIFIED (&peer
->nexthop
.v6_local
))
1012 memcpy (&attr
->extra
->mp_nexthop_local
, &peer
->nexthop
.v6_local
,
1014 attr
->extra
->mp_nexthop_len
= 32;
1017 /* If bgpd act as BGP-4+ route-reflector, do not send link-local
1020 attr
->extra
->mp_nexthop_len
= 16;
1022 /* If BGP-4+ link-local nexthop is not link-local nexthop. */
1023 if (! IN6_IS_ADDR_LINKLOCAL (&peer
->nexthop
.v6_local
))
1024 attr
->extra
->mp_nexthop_len
= 16;
1028 #endif /* HAVE_IPV6 */
1030 /* AS-Pathlimit: Check ASN for private/confed */
1031 if (attr
->pathlimit
.ttl
)
1033 /* locally originated update */
1034 if (!attr
->pathlimit
.as
)
1035 attr
->pathlimit
.as
= peer
->local_as
;
1037 /* if the AS_PATHLIMIT attribute is attached to a prefix by a
1038 member of a confederation, then when the prefix is advertised outside
1039 of the confederation boundary, then the AS number of the
1040 confederation member inside of the AS_PATHLIMIT attribute should be
1041 replaced by the confederation's AS number. */
1042 if (peer_sort (from
) == BGP_PEER_CONFED
1043 && peer_sort (peer
) != BGP_PEER_CONFED
)
1044 attr
->pathlimit
.as
= peer
->local_as
;
1046 /* Private ASN should be updated whenever announcement leaves
1047 * private space. This is deliberately done after simple confed
1050 if (attr
->pathlimit
.as
>= BGP_PRIVATE_AS_MIN
1051 && attr
->pathlimit
.as
<= BGP_PRIVATE_AS_MAX
)
1053 if (peer
->local_as
< BGP_PRIVATE_AS_MIN
1054 || peer
->local_as
> BGP_PRIVATE_AS_MAX
)
1055 attr
->pathlimit
.as
= peer
->local_as
;
1056 /* Ours is private, try using theirs.. */
1057 else if (peer
->as
< BGP_PRIVATE_AS_MIN
1058 || peer
->local_as
> BGP_PRIVATE_AS_MAX
)
1059 attr
->pathlimit
.as
= peer
->as
;
1063 /* If this is EBGP peer and remove-private-AS is set. */
1064 if (peer_sort (peer
) == BGP_PEER_EBGP
1065 && peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)
1066 && aspath_private_as_check (attr
->aspath
))
1067 attr
->aspath
= aspath_empty_get ();
1069 /* Route map & unsuppress-map apply. */
1070 if (ROUTE_MAP_OUT_NAME (filter
)
1071 || (ri
->extra
&& ri
->extra
->suppress
) )
1073 struct bgp_info info
;
1074 struct attr dummy_attr
= { 0 };
1079 /* The route reflector is not allowed to modify the attributes
1080 of the reflected IBGP routes. */
1081 if (peer_sort (from
) == BGP_PEER_IBGP
1082 && peer_sort (peer
) == BGP_PEER_IBGP
)
1084 bgp_attr_dup (&dummy_attr
, attr
);
1085 info
.attr
= &dummy_attr
;
1088 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1090 if (ri
->extra
&& ri
->extra
->suppress
)
1091 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
1093 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
1095 peer
->rmap_type
= 0;
1097 if (dummy_attr
.extra
)
1098 bgp_attr_extra_free (&dummy_attr
);
1100 if (ret
== RMAP_DENYMATCH
)
1102 bgp_attr_flush (attr
);
1110 bgp_announce_check_rsclient (struct bgp_info
*ri
, struct peer
*rsclient
,
1111 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
1114 char buf
[SU_ADDRSTRLEN
];
1115 struct bgp_filter
*filter
;
1116 struct bgp_info info
;
1121 filter
= &rsclient
->filter
[afi
][safi
];
1122 bgp
= rsclient
->bgp
;
1124 if (DISABLE_BGP_ANNOUNCE
)
1127 /* Do not send back route to sender. */
1128 if (from
== rsclient
)
1131 /* Aggregate-address suppress check. */
1132 if (ri
->extra
&& ri
->extra
->suppress
)
1133 if (! UNSUPPRESS_MAP_NAME (filter
))
1136 /* Default route check. */
1137 if (CHECK_FLAG (rsclient
->af_sflags
[afi
][safi
],
1138 PEER_STATUS_DEFAULT_ORIGINATE
))
1140 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
)
1143 else if (p
->family
== AF_INET6
&& p
->prefixlen
== 0)
1145 #endif /* HAVE_IPV6 */
1148 /* If the attribute has originator-id and it is same as remote
1150 if (ri
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
))
1152 if (IPV4_ADDR_SAME (&rsclient
->remote_id
,
1153 &ri
->attr
->extra
->originator_id
))
1155 if (BGP_DEBUG (filter
, FILTER
))
1156 zlog (rsclient
->log
, LOG_DEBUG
,
1157 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
1159 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1165 /* ORF prefix-list filter check */
1166 if (CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_RM_ADV
)
1167 && (CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_RCV
)
1168 || CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)))
1169 if (rsclient
->orf_plist
[afi
][safi
])
1171 if (prefix_list_apply (rsclient
->orf_plist
[afi
][safi
], p
) == PREFIX_DENY
)
1175 /* Output filter check. */
1176 if (bgp_output_filter (rsclient
, p
, ri
->attr
, afi
, safi
) == FILTER_DENY
)
1178 if (BGP_DEBUG (filter
, FILTER
))
1179 zlog (rsclient
->log
, LOG_DEBUG
,
1180 "%s [Update:SEND] %s/%d is filtered",
1182 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1187 #ifdef BGP_SEND_ASPATH_CHECK
1188 /* AS path loop check. */
1189 if (aspath_loop_check (ri
->attr
->aspath
, rsclient
->as
))
1191 if (BGP_DEBUG (filter
, FILTER
))
1192 zlog (rsclient
->log
, LOG_DEBUG
,
1193 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
1194 rsclient
->host
, rsclient
->as
);
1197 #endif /* BGP_SEND_ASPATH_CHECK */
1199 /* For modify attribute, copy it to temporary structure. */
1200 bgp_attr_dup (attr
, ri
->attr
);
1203 if ((p
->family
== AF_INET
&& attr
->nexthop
.s_addr
== 0)
1205 || (p
->family
== AF_INET6
&&
1206 IN6_IS_ADDR_UNSPECIFIED(&attr
->extra
->mp_nexthop_global
))
1207 #endif /* HAVE_IPV6 */
1210 /* Set IPv4 nexthop. */
1211 if (p
->family
== AF_INET
)
1213 if (safi
== SAFI_MPLS_VPN
)
1214 memcpy (&attr
->extra
->mp_nexthop_global_in
, &rsclient
->nexthop
.v4
,
1217 memcpy (&attr
->nexthop
, &rsclient
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
1220 /* Set IPv6 nexthop. */
1221 if (p
->family
== AF_INET6
)
1223 /* IPv6 global nexthop must be included. */
1224 memcpy (&attr
->extra
->mp_nexthop_global
, &rsclient
->nexthop
.v6_global
,
1226 attr
->extra
->mp_nexthop_len
= 16;
1228 #endif /* HAVE_IPV6 */
1232 if (p
->family
== AF_INET6
)
1234 struct attr_extra
*attre
= attr
->extra
;
1236 assert (attr
->extra
);
1238 /* Left nexthop_local unchanged if so configured. */
1239 if ( CHECK_FLAG (rsclient
->af_flags
[afi
][safi
],
1240 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) )
1242 if ( IN6_IS_ADDR_LINKLOCAL (&attre
->mp_nexthop_local
) )
1243 attre
->mp_nexthop_len
=32;
1245 attre
->mp_nexthop_len
=16;
1248 /* Default nexthop_local treatment for RS-Clients */
1251 /* Announcer and RS-Client are both in the same network */
1252 if (rsclient
->shared_network
&& from
->shared_network
&&
1253 (rsclient
->ifindex
== from
->ifindex
))
1255 if ( IN6_IS_ADDR_LINKLOCAL (&attre
->mp_nexthop_local
) )
1256 attre
->mp_nexthop_len
=32;
1258 attre
->mp_nexthop_len
=16;
1261 /* Set link-local address for shared network peer. */
1262 else if (rsclient
->shared_network
1263 && IN6_IS_ADDR_LINKLOCAL (&rsclient
->nexthop
.v6_local
))
1265 memcpy (&attre
->mp_nexthop_local
, &rsclient
->nexthop
.v6_local
,
1267 attre
->mp_nexthop_len
= 32;
1271 attre
->mp_nexthop_len
= 16;
1275 #endif /* HAVE_IPV6 */
1278 /* If this is EBGP peer and remove-private-AS is set. */
1279 if (peer_sort (rsclient
) == BGP_PEER_EBGP
1280 && peer_af_flag_check (rsclient
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)
1281 && aspath_private_as_check (attr
->aspath
))
1282 attr
->aspath
= aspath_empty_get ();
1284 /* Route map & unsuppress-map apply. */
1285 if (ROUTE_MAP_OUT_NAME (filter
) || (ri
->extra
&& ri
->extra
->suppress
) )
1287 info
.peer
= rsclient
;
1290 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1292 if (ri
->extra
&& ri
->extra
->suppress
)
1293 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
1295 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
1297 rsclient
->rmap_type
= 0;
1299 if (ret
== RMAP_DENYMATCH
)
1301 bgp_attr_flush (attr
);
1309 struct bgp_info_pair
1311 struct bgp_info
*old
;
1312 struct bgp_info
*new;
1316 bgp_best_selection (struct bgp
*bgp
, struct bgp_node
*rn
, struct bgp_info_pair
*result
)
1318 struct bgp_info
*new_select
;
1319 struct bgp_info
*old_select
;
1320 struct bgp_info
*ri
;
1321 struct bgp_info
*ri1
;
1322 struct bgp_info
*ri2
;
1323 struct bgp_info
*nextri
= NULL
;
1325 /* bgp deterministic-med */
1327 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
))
1328 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1330 if (CHECK_FLAG (ri1
->flags
, BGP_INFO_DMED_CHECK
))
1332 if (BGP_INFO_HOLDDOWN (ri1
))
1337 for (ri2
= ri1
->next
; ri2
; ri2
= ri2
->next
)
1339 if (CHECK_FLAG (ri2
->flags
, BGP_INFO_DMED_CHECK
))
1341 if (BGP_INFO_HOLDDOWN (ri2
))
1344 if (aspath_cmp_left (ri1
->attr
->aspath
, ri2
->attr
->aspath
)
1345 || aspath_cmp_left_confed (ri1
->attr
->aspath
,
1348 if (bgp_info_cmp (bgp
, ri2
, new_select
))
1350 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
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
);
1361 /* Check old selected route and new selected route. */
1364 for (ri
= rn
->info
; (ri
!= NULL
) && (nextri
= ri
->next
, 1); ri
= nextri
)
1366 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1369 if (BGP_INFO_HOLDDOWN (ri
))
1371 /* reap REMOVED routes, if needs be
1372 * selected route must stay for a while longer though
1374 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
1375 && (ri
!= old_select
))
1376 bgp_info_reap (rn
, ri
);
1381 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
)
1382 && (! CHECK_FLAG (ri
->flags
, BGP_INFO_DMED_SELECTED
)))
1384 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1387 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1388 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_SELECTED
);
1390 if (bgp_info_cmp (bgp
, ri
, new_select
))
1394 result
->old
= old_select
;
1395 result
->new = new_select
;
1401 bgp_process_announce_selected (struct peer
*peer
, struct bgp_info
*selected
,
1402 struct bgp_node
*rn
, afi_t afi
, safi_t safi
)
1405 struct attr attr
= { 0 };
1409 /* Announce route to Established peer. */
1410 if (peer
->status
!= Established
)
1413 /* Address family configuration check. */
1414 if (! peer
->afc_nego
[afi
][safi
])
1417 /* First update is deferred until ORF or ROUTE-REFRESH is received */
1418 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
],
1419 PEER_STATUS_ORF_WAIT_REFRESH
))
1422 switch (rn
->table
->type
)
1424 case BGP_TABLE_MAIN
:
1425 /* Announcement to peer->conf. If the route is filtered,
1427 if (selected
&& bgp_announce_check (selected
, peer
, p
, &attr
, afi
, safi
))
1428 bgp_adj_out_set (rn
, peer
, p
, &attr
, afi
, safi
, selected
);
1430 bgp_adj_out_unset (rn
, peer
, p
, afi
, safi
);
1432 case BGP_TABLE_RSCLIENT
:
1433 /* Announcement to peer->conf. If the route is filtered,
1436 bgp_announce_check_rsclient (selected
, peer
, p
, &attr
, afi
, safi
))
1437 bgp_adj_out_set (rn
, peer
, p
, &attr
, afi
, safi
, selected
);
1439 bgp_adj_out_unset (rn
, peer
, p
, afi
, safi
);
1443 bgp_attr_extra_free (&attr
);
1448 struct bgp_process_queue
1451 struct bgp_node
*rn
;
1456 static wq_item_status
1457 bgp_process_rsclient (struct work_queue
*wq
, void *data
)
1459 struct bgp_process_queue
*pq
= data
;
1460 struct bgp
*bgp
= pq
->bgp
;
1461 struct bgp_node
*rn
= pq
->rn
;
1462 afi_t afi
= pq
->afi
;
1463 safi_t safi
= pq
->safi
;
1464 struct bgp_info
*new_select
;
1465 struct bgp_info
*old_select
;
1466 struct bgp_info_pair old_and_new
;
1467 struct listnode
*node
, *nnode
;
1468 struct peer
*rsclient
= rn
->table
->owner
;
1470 /* Best path selection. */
1471 bgp_best_selection (bgp
, rn
, &old_and_new
);
1472 new_select
= old_and_new
.new;
1473 old_select
= old_and_new
.old
;
1475 if (CHECK_FLAG (rsclient
->sflags
, PEER_STATUS_GROUP
))
1477 if (rsclient
->group
)
1478 for (ALL_LIST_ELEMENTS (rsclient
->group
->peer
, node
, nnode
, rsclient
))
1480 /* Nothing to do. */
1481 if (old_select
&& old_select
== new_select
)
1482 if (!CHECK_FLAG (old_select
->flags
, BGP_INFO_ATTR_CHANGED
))
1486 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1489 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1490 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1493 bgp_process_announce_selected (rsclient
, new_select
, rn
,
1500 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1503 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1504 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1506 bgp_process_announce_selected (rsclient
, new_select
, rn
, afi
, safi
);
1509 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
1510 bgp_info_reap (rn
, old_select
);
1512 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1516 static wq_item_status
1517 bgp_process_main (struct work_queue
*wq
, void *data
)
1519 struct bgp_process_queue
*pq
= data
;
1520 struct bgp
*bgp
= pq
->bgp
;
1521 struct bgp_node
*rn
= pq
->rn
;
1522 afi_t afi
= pq
->afi
;
1523 safi_t safi
= pq
->safi
;
1524 struct prefix
*p
= &rn
->p
;
1525 struct bgp_info
*new_select
;
1526 struct bgp_info
*old_select
;
1527 struct bgp_info_pair old_and_new
;
1528 struct listnode
*node
, *nnode
;
1531 /* Best path selection. */
1532 bgp_best_selection (bgp
, rn
, &old_and_new
);
1533 old_select
= old_and_new
.old
;
1534 new_select
= old_and_new
.new;
1536 /* Nothing to do. */
1537 if (old_select
&& old_select
== new_select
)
1539 if (! CHECK_FLAG (old_select
->flags
, BGP_INFO_ATTR_CHANGED
))
1541 if (CHECK_FLAG (old_select
->flags
, BGP_INFO_IGP_CHANGED
))
1542 bgp_zebra_announce (p
, old_select
, bgp
);
1544 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1550 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1553 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1554 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1558 /* Check each BGP peer. */
1559 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
1561 bgp_process_announce_selected (peer
, new_select
, rn
, afi
, safi
);
1565 if (safi
== SAFI_UNICAST
&& ! bgp
->name
&&
1566 ! bgp_option_check (BGP_OPT_NO_FIB
))
1569 && new_select
->type
== ZEBRA_ROUTE_BGP
1570 && new_select
->sub_type
== BGP_ROUTE_NORMAL
)
1571 bgp_zebra_announce (p
, new_select
, bgp
);
1574 /* Withdraw the route from the kernel. */
1576 && old_select
->type
== ZEBRA_ROUTE_BGP
1577 && old_select
->sub_type
== BGP_ROUTE_NORMAL
)
1578 bgp_zebra_withdraw (p
, old_select
);
1582 /* Reap old select bgp_info, it it has been removed */
1583 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
1584 bgp_info_reap (rn
, old_select
);
1586 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1591 bgp_processq_del (struct work_queue
*wq
, void *data
)
1593 struct bgp_process_queue
*pq
= data
;
1594 struct bgp_table
*table
= pq
->rn
->table
;
1596 bgp_unlock (pq
->bgp
);
1597 bgp_unlock_node (pq
->rn
);
1598 bgp_table_unlock (table
);
1599 XFREE (MTYPE_BGP_PROCESS_QUEUE
, pq
);
1603 bgp_process_queue_init (void)
1605 bm
->process_main_queue
1606 = work_queue_new (bm
->master
, "process_main_queue");
1607 bm
->process_rsclient_queue
1608 = work_queue_new (bm
->master
, "process_rsclient_queue");
1610 if ( !(bm
->process_main_queue
&& bm
->process_rsclient_queue
) )
1612 zlog_err ("%s: Failed to allocate work queue", __func__
);
1616 bm
->process_main_queue
->spec
.workfunc
= &bgp_process_main
;
1617 bm
->process_rsclient_queue
->spec
.workfunc
= &bgp_process_rsclient
;
1618 bm
->process_main_queue
->spec
.del_item_data
= &bgp_processq_del
;
1619 bm
->process_rsclient_queue
->spec
.del_item_data
1620 = bm
->process_main_queue
->spec
.del_item_data
;
1621 bm
->process_main_queue
->spec
.max_retries
1622 = bm
->process_main_queue
->spec
.max_retries
= 0;
1623 bm
->process_rsclient_queue
->spec
.hold
1624 = bm
->process_main_queue
->spec
.hold
= 50;
1628 bgp_process (struct bgp
*bgp
, struct bgp_node
*rn
, afi_t afi
, safi_t safi
)
1630 struct bgp_process_queue
*pqnode
;
1632 /* already scheduled for processing? */
1633 if (CHECK_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
))
1636 if ( (bm
->process_main_queue
== NULL
) ||
1637 (bm
->process_rsclient_queue
== NULL
) )
1638 bgp_process_queue_init ();
1640 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
1641 sizeof (struct bgp_process_queue
));
1645 /* all unlocked in bgp_processq_del */
1646 bgp_table_lock (rn
->table
);
1647 pqnode
->rn
= bgp_lock_node (rn
);
1651 pqnode
->safi
= safi
;
1653 switch (rn
->table
->type
)
1655 case BGP_TABLE_MAIN
:
1656 work_queue_add (bm
->process_main_queue
, pqnode
);
1658 case BGP_TABLE_RSCLIENT
:
1659 work_queue_add (bm
->process_rsclient_queue
, pqnode
);
1667 bgp_maximum_prefix_restart_timer (struct thread
*thread
)
1671 peer
= THREAD_ARG (thread
);
1672 peer
->t_pmax_restart
= NULL
;
1674 if (BGP_DEBUG (events
, EVENTS
))
1675 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
1684 bgp_maximum_prefix_overflow (struct peer
*peer
, afi_t afi
,
1685 safi_t safi
, int always
)
1687 if (!CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
))
1690 if (peer
->pcount
[afi
][safi
] > peer
->pmax
[afi
][safi
])
1692 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
)
1696 zlog (peer
->log
, LOG_INFO
,
1697 "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
1698 "limit %ld", afi_safi_print (afi
, safi
), peer
->host
,
1699 peer
->pcount
[afi
][safi
], peer
->pmax
[afi
][safi
]);
1700 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
1702 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_WARNING
))
1708 if (safi
== SAFI_MPLS_VPN
)
1709 safi
= BGP_SAFI_VPNV4
;
1711 ndata
[0] = (afi
>> 8);
1714 ndata
[3] = (peer
->pmax
[afi
][safi
] >> 24);
1715 ndata
[4] = (peer
->pmax
[afi
][safi
] >> 16);
1716 ndata
[5] = (peer
->pmax
[afi
][safi
] >> 8);
1717 ndata
[6] = (peer
->pmax
[afi
][safi
]);
1719 SET_FLAG (peer
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
);
1720 bgp_notify_send_with_data (peer
, BGP_NOTIFY_CEASE
,
1721 BGP_NOTIFY_CEASE_MAX_PREFIX
, ndata
, 7);
1724 /* restart timer start */
1725 if (peer
->pmax_restart
[afi
][safi
])
1727 peer
->v_pmax_restart
= peer
->pmax_restart
[afi
][safi
] * 60;
1729 if (BGP_DEBUG (events
, EVENTS
))
1730 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
1731 peer
->host
, peer
->v_pmax_restart
);
1733 BGP_TIMER_ON (peer
->t_pmax_restart
, bgp_maximum_prefix_restart_timer
,
1734 peer
->v_pmax_restart
);
1740 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
1742 if (peer
->pcount
[afi
][safi
] > (peer
->pmax
[afi
][safi
] * peer
->pmax_threshold
[afi
][safi
] / 100))
1744 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
)
1748 zlog (peer
->log
, LOG_INFO
,
1749 "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
1750 afi_safi_print (afi
, safi
), peer
->host
, peer
->pcount
[afi
][safi
],
1751 peer
->pmax
[afi
][safi
]);
1752 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
1755 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
1759 /* Unconditionally remove the route from the RIB, without taking
1760 * damping into consideration (eg, because the session went down)
1763 bgp_rib_remove (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
1764 afi_t afi
, safi_t safi
)
1766 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
1768 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
1769 bgp_info_delete (rn
, ri
); /* keep historical info */
1771 bgp_process (peer
->bgp
, rn
, afi
, safi
);
1775 bgp_rib_withdraw (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
1776 afi_t afi
, safi_t safi
)
1778 int status
= BGP_DAMP_NONE
;
1780 /* apply dampening, if result is suppressed, we'll be retaining
1781 * the bgp_info in the RIB for historical reference.
1783 if (CHECK_FLAG (peer
->bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
1784 && peer_sort (peer
) == BGP_PEER_EBGP
)
1785 if ( (status
= bgp_damp_withdraw (ri
, rn
, afi
, safi
, 0))
1786 == BGP_DAMP_SUPPRESSED
)
1788 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
1792 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
1796 bgp_update_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
,
1797 struct attr
*attr
, struct peer
*peer
, struct prefix
*p
, int type
,
1798 int sub_type
, struct prefix_rd
*prd
, u_char
*tag
)
1800 struct bgp_node
*rn
;
1802 struct attr new_attr
= { 0 };
1803 struct attr
*attr_new
;
1804 struct attr
*attr_new2
;
1805 struct bgp_info
*ri
;
1806 struct bgp_info
*new;
1808 char buf
[SU_ADDRSTRLEN
];
1810 /* Do not insert announces from a rsclient into its own 'bgp_table'. */
1811 if (peer
== rsclient
)
1815 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
1817 /* Check previously received route. */
1818 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1819 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
1822 /* AS path loop check. */
1823 if (aspath_loop_check (attr
->aspath
, rsclient
->as
) > peer
->allowas_in
[afi
][safi
])
1825 reason
= "as-path contains our own AS;";
1829 /* Route reflector originator ID check. */
1830 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
1831 && IPV4_ADDR_SAME (&rsclient
->remote_id
, &attr
->extra
->originator_id
))
1833 reason
= "originator is us;";
1837 bgp_attr_dup (&new_attr
, attr
);
1839 /* Apply export policy. */
1840 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
) &&
1841 bgp_export_modifier (rsclient
, peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
1843 reason
= "export-policy;";
1847 attr_new2
= bgp_attr_intern (&new_attr
);
1849 /* Apply import policy. */
1850 if (bgp_import_modifier (rsclient
, peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
1852 bgp_attr_unintern (attr_new2
);
1854 reason
= "import-policy;";
1858 attr_new
= bgp_attr_intern (&new_attr
);
1859 bgp_attr_unintern (attr_new2
);
1861 /* IPv4 unicast next hop check. */
1862 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
1864 /* Next hop must not be 0.0.0.0 nor Class E address. */
1865 if (new_attr
.nexthop
.s_addr
== 0
1866 || ntohl (new_attr
.nexthop
.s_addr
) >= 0xe0000000)
1868 bgp_attr_unintern (attr_new
);
1870 reason
= "martian next-hop;";
1875 /* new_attr isn't passed to any functions after here */
1876 bgp_attr_extra_free (&new_attr
);
1878 /* If the update is implicit withdraw. */
1881 ri
->uptime
= time (NULL
);
1883 /* Same attribute comes in. */
1884 if (!CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
)
1885 && attrhash_cmp (ri
->attr
, attr_new
))
1888 bgp_info_unset_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
1890 if (BGP_DEBUG (update
, UPDATE_IN
))
1891 zlog (peer
->log
, LOG_DEBUG
,
1892 "%s rcvd %s/%d for RS-client %s...duplicate ignored",
1894 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1895 p
->prefixlen
, rsclient
->host
);
1897 bgp_unlock_node (rn
);
1898 bgp_attr_unintern (attr_new
);
1903 /* Withdraw/Announce before we fully processed the withdraw */
1904 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
1905 bgp_info_restore (rn
, ri
);
1907 /* Received Logging. */
1908 if (BGP_DEBUG (update
, UPDATE_IN
))
1909 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d for RS-client %s",
1911 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1912 p
->prefixlen
, rsclient
->host
);
1914 /* The attribute is changed. */
1915 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
1917 /* Update to new attribute. */
1918 bgp_attr_unintern (ri
->attr
);
1919 ri
->attr
= attr_new
;
1921 /* Update MPLS tag. */
1922 if (safi
== SAFI_MPLS_VPN
)
1923 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
1925 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
1927 /* Process change. */
1928 bgp_process (bgp
, rn
, afi
, safi
);
1929 bgp_unlock_node (rn
);
1934 /* Received Logging. */
1935 if (BGP_DEBUG (update
, UPDATE_IN
))
1937 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d for RS-client %s",
1939 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1940 p
->prefixlen
, rsclient
->host
);
1943 /* Make new BGP info. */
1944 new = bgp_info_new ();
1946 new->sub_type
= sub_type
;
1948 new->attr
= attr_new
;
1949 new->uptime
= time (NULL
);
1951 /* Update MPLS tag. */
1952 if (safi
== SAFI_MPLS_VPN
)
1953 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
1955 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
1957 /* Register new BGP information. */
1958 bgp_info_add (rn
, new);
1960 /* route_node_get lock */
1961 bgp_unlock_node (rn
);
1963 /* Process change. */
1964 bgp_process (bgp
, rn
, afi
, safi
);
1966 bgp_attr_extra_free (&new_attr
);
1972 /* This BGP update is filtered. Log the reason then update BGP entry. */
1973 if (BGP_DEBUG (update
, UPDATE_IN
))
1974 zlog (peer
->log
, LOG_DEBUG
,
1975 "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s",
1977 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1978 p
->prefixlen
, rsclient
->host
, reason
);
1981 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
1983 bgp_unlock_node (rn
);
1986 bgp_attr_extra_free (&new_attr
);
1992 bgp_withdraw_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
,
1993 struct peer
*peer
, struct prefix
*p
, int type
, int sub_type
,
1994 struct prefix_rd
*prd
, u_char
*tag
)
1996 struct bgp_node
*rn
;
1997 struct bgp_info
*ri
;
1998 char buf
[SU_ADDRSTRLEN
];
2000 if (rsclient
== peer
)
2003 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2005 /* Lookup withdrawn route. */
2006 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2007 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
2010 /* Withdraw specified route from routing table. */
2011 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2012 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
2013 else if (BGP_DEBUG (update
, UPDATE_IN
))
2014 zlog (peer
->log
, LOG_DEBUG
,
2015 "%s Can't find the route %s/%d", peer
->host
,
2016 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2019 /* Unlock bgp_node_get() lock. */
2020 bgp_unlock_node (rn
);
2024 bgp_update_main (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
2025 afi_t afi
, safi_t safi
, int type
, int sub_type
,
2026 struct prefix_rd
*prd
, u_char
*tag
, int soft_reconfig
)
2029 int aspath_loop_count
= 0;
2030 struct bgp_node
*rn
;
2032 struct attr new_attr
= { 0 };
2033 struct attr
*attr_new
;
2034 struct bgp_info
*ri
;
2035 struct bgp_info
*new;
2037 char buf
[SU_ADDRSTRLEN
];
2040 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2042 /* When peer's soft reconfiguration enabled. Record input packet in
2044 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2045 && peer
!= bgp
->peer_self
&& ! soft_reconfig
)
2046 bgp_adj_in_set (rn
, peer
, attr
);
2048 /* Check previously received route. */
2049 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2050 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
2053 /* AS path local-as loop check. */
2054 if (peer
->change_local_as
)
2056 if (! CHECK_FLAG (peer
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
2057 aspath_loop_count
= 1;
2059 if (aspath_loop_check (attr
->aspath
, peer
->change_local_as
) > aspath_loop_count
)
2061 reason
= "as-path contains our own AS;";
2066 /* AS path loop check. */
2067 if (aspath_loop_check (attr
->aspath
, bgp
->as
) > peer
->allowas_in
[afi
][safi
]
2068 || (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
2069 && aspath_loop_check(attr
->aspath
, bgp
->confed_id
)
2070 > peer
->allowas_in
[afi
][safi
]))
2072 reason
= "as-path contains our own AS;";
2076 /* Route reflector originator ID check. */
2077 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
2078 && IPV4_ADDR_SAME (&bgp
->router_id
, &attr
->extra
->originator_id
))
2080 reason
= "originator is us;";
2084 /* Route reflector cluster ID check. */
2085 if (bgp_cluster_filter (peer
, attr
))
2087 reason
= "reflected from the same cluster;";
2091 /* Apply incoming filter. */
2092 if (bgp_input_filter (peer
, p
, attr
, afi
, safi
) == FILTER_DENY
)
2098 /* Apply incoming route-map. */
2099 bgp_attr_dup (&new_attr
, attr
);
2101 if (bgp_input_modifier (peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
2103 reason
= "route-map;";
2107 /* IPv4 unicast next hop check. */
2108 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2110 /* If the peer is EBGP and nexthop is not on connected route,
2112 if (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
== 1
2113 && ! bgp_nexthop_check_ebgp (afi
, &new_attr
)
2114 && ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
2116 reason
= "non-connected next-hop;";
2120 /* Next hop must not be 0.0.0.0 nor Class E address. Next hop
2121 must not be my own address. */
2122 if (bgp_nexthop_self (afi
, &new_attr
)
2123 || new_attr
.nexthop
.s_addr
== 0
2124 || ntohl (new_attr
.nexthop
.s_addr
) >= 0xe0000000)
2126 reason
= "martian next-hop;";
2131 attr_new
= bgp_attr_intern (&new_attr
);
2133 /* If the update is implicit withdraw. */
2136 ri
->uptime
= time (NULL
);
2138 /* Same attribute comes in. */
2139 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
2140 && attrhash_cmp (ri
->attr
, attr_new
))
2142 bgp_info_unset_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2144 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2145 && peer_sort (peer
) == BGP_PEER_EBGP
2146 && CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2148 if (BGP_DEBUG (update
, UPDATE_IN
))
2149 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2151 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2154 if (bgp_damp_update (ri
, rn
, afi
, safi
) != BGP_DAMP_SUPPRESSED
)
2156 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2157 bgp_process (bgp
, rn
, afi
, safi
);
2160 else /* Duplicate - odd */
2162 if (BGP_DEBUG (update
, UPDATE_IN
))
2163 zlog (peer
->log
, LOG_DEBUG
,
2164 "%s rcvd %s/%d...duplicate ignored",
2166 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2169 /* graceful restart STALE flag unset. */
2170 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2172 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2173 bgp_process (bgp
, rn
, afi
, safi
);
2177 bgp_unlock_node (rn
);
2178 bgp_attr_unintern (attr_new
);
2179 bgp_attr_extra_free (&new_attr
);
2184 /* Withdraw/Announce before we fully processed the withdraw */
2185 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
2187 if (BGP_DEBUG (update
, UPDATE_IN
))
2188 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d, flapped quicker than processing",
2190 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2192 bgp_info_restore (rn
, ri
);
2195 /* Received Logging. */
2196 if (BGP_DEBUG (update
, UPDATE_IN
))
2197 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2199 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2202 /* graceful restart STALE flag unset. */
2203 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2204 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2206 /* The attribute is changed. */
2207 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2209 /* implicit withdraw, decrement aggregate and pcount here.
2210 * only if update is accepted, they'll increment below.
2212 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
2214 /* Update bgp route dampening information. */
2215 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2216 && peer_sort (peer
) == BGP_PEER_EBGP
)
2218 /* This is implicit withdraw so we should update dampening
2220 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2221 bgp_damp_withdraw (ri
, rn
, afi
, safi
, 1);
2224 /* Update to new attribute. */
2225 bgp_attr_unintern (ri
->attr
);
2226 ri
->attr
= attr_new
;
2228 /* Update MPLS tag. */
2229 if (safi
== SAFI_MPLS_VPN
)
2230 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
2232 /* Update bgp route dampening information. */
2233 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2234 && peer_sort (peer
) == BGP_PEER_EBGP
)
2236 /* Now we do normal update dampening. */
2237 ret
= bgp_damp_update (ri
, rn
, afi
, safi
);
2238 if (ret
== BGP_DAMP_SUPPRESSED
)
2240 bgp_unlock_node (rn
);
2241 bgp_attr_extra_free (&new_attr
);
2246 /* Nexthop reachability check. */
2247 if ((afi
== AFI_IP
|| afi
== AFI_IP6
)
2248 && safi
== SAFI_UNICAST
2249 && (peer_sort (peer
) == BGP_PEER_IBGP
2250 || (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)
2251 || CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)))
2253 if (bgp_nexthop_lookup (afi
, peer
, ri
, NULL
, NULL
))
2254 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2256 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
2259 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2261 /* Process change. */
2262 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2264 bgp_process (bgp
, rn
, afi
, safi
);
2265 bgp_unlock_node (rn
);
2266 bgp_attr_extra_free (&new_attr
);
2271 /* Received Logging. */
2272 if (BGP_DEBUG (update
, UPDATE_IN
))
2274 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2276 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2280 /* Make new BGP info. */
2281 new = bgp_info_new ();
2283 new->sub_type
= sub_type
;
2285 new->attr
= attr_new
;
2286 new->uptime
= time (NULL
);
2288 /* Update MPLS tag. */
2289 if (safi
== SAFI_MPLS_VPN
)
2290 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
2292 /* Nexthop reachability check. */
2293 if ((afi
== AFI_IP
|| afi
== AFI_IP6
)
2294 && safi
== SAFI_UNICAST
2295 && (peer_sort (peer
) == BGP_PEER_IBGP
2296 || (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)
2297 || CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)))
2299 if (bgp_nexthop_lookup (afi
, peer
, new, NULL
, NULL
))
2300 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2302 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
2305 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2307 /* Increment prefix */
2308 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
2310 /* Register new BGP information. */
2311 bgp_info_add (rn
, new);
2313 /* route_node_get lock */
2314 bgp_unlock_node (rn
);
2316 bgp_attr_extra_free (&new_attr
);
2318 /* If maximum prefix count is configured and current prefix
2320 if (bgp_maximum_prefix_overflow (peer
, afi
, safi
, 0))
2323 /* Process change. */
2324 bgp_process (bgp
, rn
, afi
, safi
);
2328 /* This BGP update is filtered. Log the reason then update BGP
2331 if (BGP_DEBUG (update
, UPDATE_IN
))
2332 zlog (peer
->log
, LOG_DEBUG
,
2333 "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
2335 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2336 p
->prefixlen
, reason
);
2339 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2341 bgp_unlock_node (rn
);
2343 bgp_attr_extra_free (&new_attr
);
2349 bgp_update (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
2350 afi_t afi
, safi_t safi
, int type
, int sub_type
,
2351 struct prefix_rd
*prd
, u_char
*tag
, int soft_reconfig
)
2353 struct peer
*rsclient
;
2354 struct listnode
*node
, *nnode
;
2358 ret
= bgp_update_main (peer
, p
, attr
, afi
, safi
, type
, sub_type
, prd
, tag
,
2363 /* Process the update for each RS-client. */
2364 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
2366 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2367 bgp_update_rsclient (rsclient
, afi
, safi
, attr
, peer
, p
, type
,
2368 sub_type
, prd
, tag
);
2375 bgp_withdraw (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
2376 afi_t afi
, safi_t safi
, int type
, int sub_type
,
2377 struct prefix_rd
*prd
, u_char
*tag
)
2380 char buf
[SU_ADDRSTRLEN
];
2381 struct bgp_node
*rn
;
2382 struct bgp_info
*ri
;
2383 struct peer
*rsclient
;
2384 struct listnode
*node
, *nnode
;
2388 /* Process the withdraw for each RS-client. */
2389 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
2391 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2392 bgp_withdraw_rsclient (rsclient
, afi
, safi
, peer
, p
, type
, sub_type
, prd
, tag
);
2396 if (BGP_DEBUG (update
, UPDATE_IN
))
2397 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd UPDATE about %s/%d -- withdrawn",
2399 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2403 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2405 /* If peer is soft reconfiguration enabled. Record input packet for
2406 further calculation. */
2407 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2408 && peer
!= bgp
->peer_self
)
2409 bgp_adj_in_unset (rn
, peer
);
2411 /* Lookup withdrawn route. */
2412 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2413 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
2416 /* Withdraw specified route from routing table. */
2417 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2418 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
2419 else if (BGP_DEBUG (update
, UPDATE_IN
))
2420 zlog (peer
->log
, LOG_DEBUG
,
2421 "%s Can't find the route %s/%d", peer
->host
,
2422 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2425 /* Unlock bgp_node_get() lock. */
2426 bgp_unlock_node (rn
);
2432 bgp_default_originate (struct peer
*peer
, afi_t afi
, safi_t safi
, int withdraw
)
2435 struct attr attr
= { 0 };
2436 struct aspath
*aspath
= { 0 };
2438 struct bgp_info binfo
;
2440 int ret
= RMAP_DENYMATCH
;
2442 if (!(afi
== AFI_IP
|| afi
== AFI_IP6
))
2446 from
= bgp
->peer_self
;
2448 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
2449 aspath
= attr
.aspath
;
2450 attr
.local_pref
= bgp
->default_local_pref
;
2451 memcpy (&attr
.nexthop
, &peer
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
2454 str2prefix ("0.0.0.0/0", &p
);
2456 else if (afi
== AFI_IP6
)
2458 struct attr_extra
*ae
;
2461 ae
= bgp_attr_extra_get (&attr
);
2464 str2prefix ("::/0", &p
);
2466 /* IPv6 global nexthop must be included. */
2467 memcpy (&ae
->mp_nexthop_global
, &peer
->nexthop
.v6_global
,
2469 ae
->mp_nexthop_len
= 16;
2471 /* If the peer is on shared nextwork and we have link-local
2473 if (peer
->shared_network
2474 && !IN6_IS_ADDR_UNSPECIFIED (&peer
->nexthop
.v6_local
))
2476 memcpy (&ae
->mp_nexthop_local
, &peer
->nexthop
.v6_local
,
2478 ae
->mp_nexthop_len
= 32;
2481 #endif /* HAVE_IPV6 */
2483 if (peer
->default_rmap
[afi
][safi
].name
)
2485 binfo
.peer
= bgp
->peer_self
;
2488 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_DEFAULT
);
2490 ret
= route_map_apply (peer
->default_rmap
[afi
][safi
].map
, &p
,
2493 bgp
->peer_self
->rmap_type
= 0;
2495 if (ret
== RMAP_DENYMATCH
)
2497 bgp_attr_flush (&attr
);
2504 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
))
2505 bgp_default_withdraw_send (peer
, afi
, safi
);
2506 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
);
2510 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
);
2511 bgp_default_update_send (peer
, &attr
, afi
, safi
, from
);
2514 bgp_attr_extra_free (&attr
);
2515 aspath_unintern (aspath
);
2519 bgp_announce_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2520 struct bgp_table
*table
, int rsclient
)
2522 struct bgp_node
*rn
;
2523 struct bgp_info
*ri
;
2524 struct attr attr
= { 0 };
2527 table
= (rsclient
) ? peer
->rib
[afi
][safi
] : peer
->bgp
->rib
[afi
][safi
];
2529 if (safi
!= SAFI_MPLS_VPN
2530 && CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_DEFAULT_ORIGINATE
))
2531 bgp_default_originate (peer
, afi
, safi
, 0);
2533 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next(rn
))
2534 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2535 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
) && ri
->peer
!= peer
)
2538 (bgp_announce_check_rsclient (ri
, peer
, &rn
->p
, &attr
, afi
, safi
))
2539 : (bgp_announce_check (ri
, peer
, &rn
->p
, &attr
, afi
, safi
)))
2540 bgp_adj_out_set (rn
, peer
, &rn
->p
, &attr
, afi
, safi
, ri
);
2542 bgp_adj_out_unset (rn
, peer
, &rn
->p
, afi
, safi
);
2544 bgp_attr_extra_free (&attr
);
2549 bgp_announce_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2551 struct bgp_node
*rn
;
2552 struct bgp_table
*table
;
2554 if (peer
->status
!= Established
)
2557 if (! peer
->afc_nego
[afi
][safi
])
2560 /* First update is deferred until ORF or ROUTE-REFRESH is received */
2561 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_ORF_WAIT_REFRESH
))
2564 if (safi
!= SAFI_MPLS_VPN
)
2565 bgp_announce_table (peer
, afi
, safi
, NULL
, 0);
2567 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2568 rn
= bgp_route_next(rn
))
2569 if ((table
= (rn
->info
)) != NULL
)
2570 bgp_announce_table (peer
, afi
, safi
, table
, 0);
2572 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2573 bgp_announce_table (peer
, afi
, safi
, NULL
, 1);
2577 bgp_announce_route_all (struct peer
*peer
)
2582 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2583 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2584 bgp_announce_route (peer
, afi
, safi
);
2588 bgp_soft_reconfig_table_rsclient (struct peer
*rsclient
, afi_t afi
,
2589 safi_t safi
, struct bgp_table
*table
)
2591 struct bgp_node
*rn
;
2592 struct bgp_adj_in
*ain
;
2595 table
= rsclient
->bgp
->rib
[afi
][safi
];
2597 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2598 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2600 bgp_update_rsclient (rsclient
, afi
, safi
, ain
->attr
, ain
->peer
,
2601 &rn
->p
, ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
2606 bgp_soft_reconfig_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
)
2608 struct bgp_table
*table
;
2609 struct bgp_node
*rn
;
2611 if (safi
!= SAFI_MPLS_VPN
)
2612 bgp_soft_reconfig_table_rsclient (rsclient
, afi
, safi
, NULL
);
2615 for (rn
= bgp_table_top (rsclient
->bgp
->rib
[afi
][safi
]); rn
;
2616 rn
= bgp_route_next (rn
))
2617 if ((table
= rn
->info
) != NULL
)
2618 bgp_soft_reconfig_table_rsclient (rsclient
, afi
, safi
, table
);
2622 bgp_soft_reconfig_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2623 struct bgp_table
*table
)
2626 struct bgp_node
*rn
;
2627 struct bgp_adj_in
*ain
;
2630 table
= peer
->bgp
->rib
[afi
][safi
];
2632 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2633 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2635 if (ain
->peer
== peer
)
2637 ret
= bgp_update (peer
, &rn
->p
, ain
->attr
, afi
, safi
,
2638 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
,
2642 bgp_unlock_node (rn
);
2651 bgp_soft_reconfig_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2653 struct bgp_node
*rn
;
2654 struct bgp_table
*table
;
2656 if (peer
->status
!= Established
)
2659 if (safi
!= SAFI_MPLS_VPN
)
2660 bgp_soft_reconfig_table (peer
, afi
, safi
, NULL
);
2662 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2663 rn
= bgp_route_next (rn
))
2664 if ((table
= rn
->info
) != NULL
)
2665 bgp_soft_reconfig_table (peer
, afi
, safi
, table
);
2669 struct bgp_clear_node_queue
2671 struct bgp_node
*rn
;
2672 enum bgp_clear_route_type purpose
;
2675 static wq_item_status
2676 bgp_clear_route_node (struct work_queue
*wq
, void *data
)
2678 struct bgp_clear_node_queue
*cnq
= data
;
2679 struct bgp_node
*rn
= cnq
->rn
;
2680 struct peer
*peer
= wq
->spec
.data
;
2681 struct bgp_info
*ri
;
2682 afi_t afi
= rn
->table
->afi
;
2683 safi_t safi
= rn
->table
->safi
;
2685 assert (rn
&& peer
);
2687 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2688 if (ri
->peer
== peer
|| cnq
->purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2690 /* graceful restart STALE flag set. */
2691 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_NSF_WAIT
)
2692 && peer
->nsf
[afi
][safi
]
2693 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
)
2694 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
2695 bgp_info_set_flag (rn
, ri
, BGP_INFO_STALE
);
2697 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2704 bgp_clear_node_queue_del (struct work_queue
*wq
, void *data
)
2706 struct bgp_clear_node_queue
*cnq
= data
;
2707 struct bgp_node
*rn
= cnq
->rn
;
2708 struct bgp_table
*table
= rn
->table
;
2710 bgp_unlock_node (rn
);
2711 bgp_table_unlock (table
);
2712 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE
, cnq
);
2716 bgp_clear_node_complete (struct work_queue
*wq
)
2718 struct peer
*peer
= wq
->spec
.data
;
2720 /* Tickle FSM to start moving again */
2721 BGP_EVENT_ADD (peer
, Clearing_Completed
);
2723 peer_unlock (peer
); /* bgp_clear_route */
2727 bgp_clear_node_queue_init (struct peer
*peer
)
2729 char wname
[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx"];
2731 snprintf (wname
, CLEAR_QUEUE_NAME_LEN
, "clear %s", peer
->host
);
2732 #undef CLEAR_QUEUE_NAME_LEN
2734 if ( (peer
->clear_node_queue
= work_queue_new (bm
->master
, wname
)) == NULL
)
2736 zlog_err ("%s: Failed to allocate work queue", __func__
);
2739 peer
->clear_node_queue
->spec
.hold
= 10;
2740 peer
->clear_node_queue
->spec
.workfunc
= &bgp_clear_route_node
;
2741 peer
->clear_node_queue
->spec
.del_item_data
= &bgp_clear_node_queue_del
;
2742 peer
->clear_node_queue
->spec
.completion_func
= &bgp_clear_node_complete
;
2743 peer
->clear_node_queue
->spec
.max_retries
= 0;
2745 /* we only 'lock' this peer reference when the queue is actually active */
2746 peer
->clear_node_queue
->spec
.data
= peer
;
2750 bgp_clear_route_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2751 struct bgp_table
*table
, struct peer
*rsclient
,
2752 enum bgp_clear_route_type purpose
)
2754 struct bgp_node
*rn
;
2758 table
= (rsclient
) ? rsclient
->rib
[afi
][safi
] : peer
->bgp
->rib
[afi
][safi
];
2760 /* If still no table => afi/safi isn't configured at all or smth. */
2764 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2766 struct bgp_info
*ri
;
2767 struct bgp_adj_in
*ain
;
2768 struct bgp_adj_out
*aout
;
2770 if (rn
->info
== NULL
)
2773 /* XXX:TODO: This is suboptimal, every non-empty route_node is
2774 * queued for every clearing peer, regardless of whether it is
2775 * relevant to the peer at hand.
2777 * Overview: There are 3 different indices which need to be
2778 * scrubbed, potentially, when a peer is removed:
2780 * 1 peer's routes visible via the RIB (ie accepted routes)
2781 * 2 peer's routes visible by the (optional) peer's adj-in index
2782 * 3 other routes visible by the peer's adj-out index
2784 * 3 there is no hurry in scrubbing, once the struct peer is
2785 * removed from bgp->peer, we could just GC such deleted peer's
2786 * adj-outs at our leisure.
2788 * 1 and 2 must be 'scrubbed' in some way, at least made
2789 * invisible via RIB index before peer session is allowed to be
2790 * brought back up. So one needs to know when such a 'search' is
2795 * - there'd be a single global queue or a single RIB walker
2796 * - rather than tracking which route_nodes still need to be
2797 * examined on a peer basis, we'd track which peers still
2800 * Given that our per-peer prefix-counts now should be reliable,
2801 * this may actually be achievable. It doesn't seem to be a huge
2802 * problem at this time,
2804 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2805 if (ri
->peer
== peer
|| purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2807 struct bgp_clear_node_queue
*cnq
;
2809 /* both unlocked in bgp_clear_node_queue_del */
2810 bgp_table_lock (rn
->table
);
2812 cnq
= XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE
,
2813 sizeof (struct bgp_clear_node_queue
));
2815 cnq
->purpose
= purpose
;
2816 work_queue_add (peer
->clear_node_queue
, cnq
);
2820 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2821 if (ain
->peer
== peer
|| purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2823 bgp_adj_in_remove (rn
, ain
);
2824 bgp_unlock_node (rn
);
2827 for (aout
= rn
->adj_out
; aout
; aout
= aout
->next
)
2828 if (aout
->peer
== peer
|| purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2830 bgp_adj_out_remove (rn
, aout
, peer
, afi
, safi
);
2831 bgp_unlock_node (rn
);
2839 bgp_clear_route (struct peer
*peer
, afi_t afi
, safi_t safi
,
2840 enum bgp_clear_route_type purpose
)
2842 struct bgp_node
*rn
;
2843 struct bgp_table
*table
;
2844 struct peer
*rsclient
;
2845 struct listnode
*node
, *nnode
;
2847 if (peer
->clear_node_queue
== NULL
)
2848 bgp_clear_node_queue_init (peer
);
2850 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
2851 * Idle until it receives a Clearing_Completed event. This protects
2852 * against peers which flap faster than we can we clear, which could
2855 * a) race with routes from the new session being installed before
2856 * clear_route_node visits the node (to delete the route of that
2858 * b) resource exhaustion, clear_route_node likely leads to an entry
2859 * on the process_main queue. Fast-flapping could cause that queue
2862 if (!peer
->clear_node_queue
->thread
)
2863 peer_lock (peer
); /* bgp_clear_node_complete */
2867 case BGP_CLEAR_ROUTE_NORMAL
:
2868 if (safi
!= SAFI_MPLS_VPN
)
2869 bgp_clear_route_table (peer
, afi
, safi
, NULL
, NULL
, purpose
);
2871 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2872 rn
= bgp_route_next (rn
))
2873 if ((table
= rn
->info
) != NULL
)
2874 bgp_clear_route_table (peer
, afi
, safi
, table
, NULL
, purpose
);
2876 for (ALL_LIST_ELEMENTS (peer
->bgp
->rsclient
, node
, nnode
, rsclient
))
2877 if (CHECK_FLAG(rsclient
->af_flags
[afi
][safi
],
2878 PEER_FLAG_RSERVER_CLIENT
))
2879 bgp_clear_route_table (peer
, afi
, safi
, NULL
, rsclient
, purpose
);
2882 case BGP_CLEAR_ROUTE_MY_RSCLIENT
:
2883 bgp_clear_route_table (peer
, afi
, safi
, NULL
, peer
, purpose
);
2891 /* If no routes were cleared, nothing was added to workqueue, the
2892 * completion function won't be run by workqueue code - call it here.
2893 * XXX: Actually, this assumption doesn't hold, see
2894 * bgp_clear_route_table(), we queue all non-empty nodes.
2896 * Additionally, there is a presumption in FSM that clearing is only
2897 * really needed if peer state is Established - peers in
2898 * pre-Established states shouldn't have any route-update state
2899 * associated with them (in or out).
2901 * We still can get here in pre-Established though, through
2902 * peer_delete -> bgp_fsm_change_status, so this is a useful sanity
2903 * check to ensure the assumption above holds.
2905 * At some future point, this check could be move to the top of the
2906 * function, and do a quick early-return when state is
2907 * pre-Established, avoiding above list and table scans. Once we're
2910 if (!peer
->clear_node_queue
->thread
)
2911 bgp_clear_node_complete (peer
->clear_node_queue
);
2915 bgp_clear_route_all (struct peer
*peer
)
2920 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2921 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2922 bgp_clear_route (peer
, afi
, safi
, BGP_CLEAR_ROUTE_NORMAL
);
2926 bgp_clear_adj_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2928 struct bgp_table
*table
;
2929 struct bgp_node
*rn
;
2930 struct bgp_adj_in
*ain
;
2932 table
= peer
->bgp
->rib
[afi
][safi
];
2934 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2935 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2936 if (ain
->peer
== peer
)
2938 bgp_adj_in_remove (rn
, ain
);
2939 bgp_unlock_node (rn
);
2945 bgp_clear_stale_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2947 struct bgp_node
*rn
;
2948 struct bgp_info
*ri
;
2949 struct bgp_table
*table
;
2951 table
= peer
->bgp
->rib
[afi
][safi
];
2953 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2955 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2956 if (ri
->peer
== peer
)
2958 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2959 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2965 /* Delete all kernel routes. */
2967 bgp_cleanup_routes (void)
2970 struct listnode
*node
, *nnode
;
2971 struct bgp_node
*rn
;
2972 struct bgp_table
*table
;
2973 struct bgp_info
*ri
;
2975 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
2977 table
= bgp
->rib
[AFI_IP
][SAFI_UNICAST
];
2979 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2980 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2981 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
2982 && ri
->type
== ZEBRA_ROUTE_BGP
2983 && ri
->sub_type
== BGP_ROUTE_NORMAL
)
2984 bgp_zebra_withdraw (&rn
->p
, ri
);
2986 table
= bgp
->rib
[AFI_IP6
][SAFI_UNICAST
];
2988 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2989 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2990 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
2991 && ri
->type
== ZEBRA_ROUTE_BGP
2992 && ri
->sub_type
== BGP_ROUTE_NORMAL
)
2993 bgp_zebra_withdraw (&rn
->p
, ri
);
3001 bgp_zclient_reset ();
3002 access_list_reset ();
3003 prefix_list_reset ();
3006 /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3009 bgp_nlri_parse (struct peer
*peer
, struct attr
*attr
, struct bgp_nlri
*packet
)
3017 /* Check peer status. */
3018 if (peer
->status
!= Established
)
3022 lim
= pnt
+ packet
->length
;
3024 for (; pnt
< lim
; pnt
+= psize
)
3026 /* Clear prefix structure. */
3027 memset (&p
, 0, sizeof (struct prefix
));
3029 /* Fetch prefix length. */
3030 p
.prefixlen
= *pnt
++;
3031 p
.family
= afi2family (packet
->afi
);
3033 /* Already checked in nlri_sanity_check(). We do double check
3035 if ((packet
->afi
== AFI_IP
&& p
.prefixlen
> 32)
3036 || (packet
->afi
== AFI_IP6
&& p
.prefixlen
> 128))
3039 /* Packet size overflow check. */
3040 psize
= PSIZE (p
.prefixlen
);
3042 /* When packet overflow occur return immediately. */
3043 if (pnt
+ psize
> lim
)
3046 /* Fetch prefix from NLRI packet. */
3047 memcpy (&p
.u
.prefix
, pnt
, psize
);
3049 /* Check address. */
3050 if (packet
->afi
== AFI_IP
&& packet
->safi
== SAFI_UNICAST
)
3052 if (IN_CLASSD (ntohl (p
.u
.prefix4
.s_addr
)))
3055 * From draft-ietf-idr-bgp4-22, Section 6.3:
3056 * If a BGP router receives an UPDATE message with a
3057 * semantically incorrect NLRI field, in which a prefix is
3058 * semantically incorrect (eg. an unexpected multicast IP
3059 * address), it should ignore the prefix.
3061 zlog (peer
->log
, LOG_ERR
,
3062 "IPv4 unicast NLRI is multicast address %s",
3063 inet_ntoa (p
.u
.prefix4
));
3070 /* Check address. */
3071 if (packet
->afi
== AFI_IP6
&& packet
->safi
== SAFI_UNICAST
)
3073 if (IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3077 zlog (peer
->log
, LOG_WARNING
,
3078 "IPv6 link-local NLRI received %s ignore this NLRI",
3079 inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3084 #endif /* HAVE_IPV6 */
3086 /* Normal process. */
3088 ret
= bgp_update (peer
, &p
, attr
, packet
->afi
, packet
->safi
,
3089 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
3091 ret
= bgp_withdraw (peer
, &p
, attr
, packet
->afi
, packet
->safi
,
3092 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
3094 /* Address family configuration mismatch or maximum-prefix count
3100 /* Packet length consistency check. */
3107 /* NLRI encode syntax check routine. */
3109 bgp_nlri_sanity_check (struct peer
*peer
, int afi
, u_char
*pnt
,
3118 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
3119 syntactic validity. If the field is syntactically incorrect,
3120 then the Error Subcode is set to Invalid Network Field. */
3126 /* Prefix length check. */
3127 if ((afi
== AFI_IP
&& prefixlen
> 32)
3128 || (afi
== AFI_IP6
&& prefixlen
> 128))
3130 plog_err (peer
->log
,
3131 "%s [Error] Update packet error (wrong prefix length %d)",
3132 peer
->host
, prefixlen
);
3133 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3134 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3138 /* Packet size overflow check. */
3139 psize
= PSIZE (prefixlen
);
3141 if (pnt
+ psize
> end
)
3143 plog_err (peer
->log
,
3144 "%s [Error] Update packet error"
3145 " (prefix data overflow prefix size is %d)",
3147 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3148 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3155 /* Packet length consistency check. */
3158 plog_err (peer
->log
,
3159 "%s [Error] Update packet error"
3160 " (prefix length mismatch with total length)",
3162 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3163 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3169 static struct bgp_static
*
3170 bgp_static_new (void)
3172 return XCALLOC (MTYPE_BGP_STATIC
, sizeof (struct bgp_static
));
3176 bgp_static_free (struct bgp_static
*bgp_static
)
3178 if (bgp_static
->rmap
.name
)
3179 free (bgp_static
->rmap
.name
);
3180 XFREE (MTYPE_BGP_STATIC
, bgp_static
);
3184 bgp_static_withdraw_rsclient (struct bgp
*bgp
, struct peer
*rsclient
,
3185 struct prefix
*p
, afi_t afi
, safi_t safi
)
3187 struct bgp_node
*rn
;
3188 struct bgp_info
*ri
;
3190 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3192 /* Check selected route and self inserted route. */
3193 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3194 if (ri
->peer
== bgp
->peer_self
3195 && ri
->type
== ZEBRA_ROUTE_BGP
3196 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3199 /* Withdraw static BGP route from routing table. */
3202 bgp_info_delete (rn
, ri
);
3203 bgp_process (bgp
, rn
, afi
, safi
);
3206 /* Unlock bgp_node_lookup. */
3207 bgp_unlock_node (rn
);
3211 bgp_static_update_rsclient (struct peer
*rsclient
, struct prefix
*p
,
3212 struct bgp_static
*bgp_static
,
3213 afi_t afi
, safi_t safi
)
3215 struct bgp_node
*rn
;
3216 struct bgp_info
*ri
;
3217 struct bgp_info
*new;
3218 struct bgp_info info
;
3219 struct attr
*attr_new
;
3220 struct attr attr
= {0 };
3221 struct attr new_attr
= { .extra
= 0 };
3224 char buf
[SU_ADDRSTRLEN
];
3226 bgp
= rsclient
->bgp
;
3228 assert (bgp_static
);
3232 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3234 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3236 attr
.nexthop
= bgp_static
->igpnexthop
;
3237 attr
.med
= bgp_static
->igpmetric
;
3238 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3240 if (bgp_static
->ttl
)
3242 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_AS_PATHLIMIT
);
3243 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3244 attr
.pathlimit
.as
= 0;
3245 attr
.pathlimit
.ttl
= bgp_static
->ttl
;
3248 if (bgp_static
->atomic
)
3249 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3251 /* Apply network route-map for export to this rsclient. */
3252 if (bgp_static
->rmap
.name
)
3254 struct attr attr_tmp
= attr
;
3255 info
.peer
= rsclient
;
3256 info
.attr
= &attr_tmp
;
3258 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_EXPORT
);
3259 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3261 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3263 rsclient
->rmap_type
= 0;
3265 if (ret
== RMAP_DENYMATCH
)
3267 /* Free uninterned attribute. */
3268 bgp_attr_flush (&attr_tmp
);
3270 /* Unintern original. */
3271 aspath_unintern (attr
.aspath
);
3272 bgp_static_withdraw_rsclient (bgp
, rsclient
, p
, afi
, safi
);
3273 bgp_attr_extra_free (&attr
);
3277 attr_new
= bgp_attr_intern (&attr_tmp
);
3280 attr_new
= bgp_attr_intern (&attr
);
3282 new_attr
= *attr_new
;
3284 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3286 if (bgp_import_modifier (rsclient
, bgp
->peer_self
, p
, &new_attr
, afi
, safi
)
3289 /* This BGP update is filtered. Log the reason then update BGP entry. */
3290 if (BGP_DEBUG (update
, UPDATE_IN
))
3291 zlog (rsclient
->log
, LOG_DEBUG
,
3292 "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
3293 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
3294 p
->prefixlen
, rsclient
->host
);
3296 bgp
->peer_self
->rmap_type
= 0;
3298 bgp_attr_unintern (attr_new
);
3299 aspath_unintern (attr
.aspath
);
3300 bgp_attr_extra_free (&attr
);
3302 bgp_static_withdraw_rsclient (bgp
, rsclient
, p
, afi
, safi
);
3307 bgp
->peer_self
->rmap_type
= 0;
3309 bgp_attr_unintern (attr_new
);
3310 attr_new
= bgp_attr_intern (&new_attr
);
3312 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3313 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3314 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3319 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3320 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3322 bgp_unlock_node (rn
);
3323 bgp_attr_unintern (attr_new
);
3324 aspath_unintern (attr
.aspath
);
3325 bgp_attr_extra_free (&attr
);
3330 /* The attribute is changed. */
3331 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3333 /* Rewrite BGP route information. */
3334 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3335 bgp_info_restore(rn
, ri
);
3336 bgp_attr_unintern (ri
->attr
);
3337 ri
->attr
= attr_new
;
3338 ri
->uptime
= time (NULL
);
3340 /* Process change. */
3341 bgp_process (bgp
, rn
, afi
, safi
);
3342 bgp_unlock_node (rn
);
3343 aspath_unintern (attr
.aspath
);
3344 bgp_attr_extra_free (&attr
);
3349 /* Make new BGP info. */
3350 new = bgp_info_new ();
3351 new->type
= ZEBRA_ROUTE_BGP
;
3352 new->sub_type
= BGP_ROUTE_STATIC
;
3353 new->peer
= bgp
->peer_self
;
3354 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3355 new->attr
= attr_new
;
3356 new->uptime
= time (NULL
);
3358 /* Register new BGP information. */
3359 bgp_info_add (rn
, new);
3361 /* route_node_get lock */
3362 bgp_unlock_node (rn
);
3364 /* Process change. */
3365 bgp_process (bgp
, rn
, afi
, safi
);
3367 /* Unintern original. */
3368 aspath_unintern (attr
.aspath
);
3369 bgp_attr_extra_free (&attr
);
3373 bgp_static_update_main (struct bgp
*bgp
, struct prefix
*p
,
3374 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3376 struct bgp_node
*rn
;
3377 struct bgp_info
*ri
;
3378 struct bgp_info
*new;
3379 struct bgp_info info
;
3380 struct attr attr
= { 0 };
3381 struct attr
*attr_new
;
3384 assert (bgp_static
);
3388 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3390 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3392 attr
.nexthop
= bgp_static
->igpnexthop
;
3393 attr
.med
= bgp_static
->igpmetric
;
3394 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3396 if (bgp_static
->ttl
)
3398 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_AS_PATHLIMIT
);
3399 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3400 attr
.pathlimit
.as
= 0;
3401 attr
.pathlimit
.ttl
= bgp_static
->ttl
;
3404 if (bgp_static
->atomic
)
3405 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3407 /* Apply route-map. */
3408 if (bgp_static
->rmap
.name
)
3410 struct attr attr_tmp
= attr
;
3411 info
.peer
= bgp
->peer_self
;
3412 info
.attr
= &attr_tmp
;
3414 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3416 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3418 bgp
->peer_self
->rmap_type
= 0;
3420 if (ret
== RMAP_DENYMATCH
)
3422 /* Free uninterned attribute. */
3423 bgp_attr_flush (&attr_tmp
);
3425 /* Unintern original. */
3426 aspath_unintern (attr
.aspath
);
3427 bgp_attr_extra_free (&attr
);
3428 bgp_static_withdraw (bgp
, p
, afi
, safi
);
3431 attr_new
= bgp_attr_intern (&attr_tmp
);
3434 attr_new
= bgp_attr_intern (&attr
);
3436 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3437 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3438 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3443 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3444 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3446 bgp_unlock_node (rn
);
3447 bgp_attr_unintern (attr_new
);
3448 aspath_unintern (attr
.aspath
);
3449 bgp_attr_extra_free (&attr
);
3454 /* The attribute is changed. */
3455 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3457 /* Rewrite BGP route information. */
3458 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3459 bgp_info_restore(rn
, ri
);
3461 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3462 bgp_attr_unintern (ri
->attr
);
3463 ri
->attr
= attr_new
;
3464 ri
->uptime
= time (NULL
);
3466 /* Process change. */
3467 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3468 bgp_process (bgp
, rn
, afi
, safi
);
3469 bgp_unlock_node (rn
);
3470 aspath_unintern (attr
.aspath
);
3471 bgp_attr_extra_free (&attr
);
3476 /* Make new BGP info. */
3477 new = bgp_info_new ();
3478 new->type
= ZEBRA_ROUTE_BGP
;
3479 new->sub_type
= BGP_ROUTE_STATIC
;
3480 new->peer
= bgp
->peer_self
;
3481 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3482 new->attr
= attr_new
;
3483 new->uptime
= time (NULL
);
3485 /* Aggregate address increment. */
3486 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3488 /* Register new BGP information. */
3489 bgp_info_add (rn
, new);
3491 /* route_node_get lock */
3492 bgp_unlock_node (rn
);
3494 /* Process change. */
3495 bgp_process (bgp
, rn
, afi
, safi
);
3497 /* Unintern original. */
3498 aspath_unintern (attr
.aspath
);
3499 bgp_attr_extra_free (&attr
);
3503 bgp_static_update (struct bgp
*bgp
, struct prefix
*p
,
3504 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3506 struct peer
*rsclient
;
3507 struct listnode
*node
, *nnode
;
3509 bgp_static_update_main (bgp
, p
, bgp_static
, afi
, safi
);
3511 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
3513 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
3514 bgp_static_update_rsclient (rsclient
, p
, bgp_static
, afi
, safi
);
3519 bgp_static_update_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, u_int16_t afi
,
3520 u_char safi
, struct prefix_rd
*prd
, u_char
*tag
)
3522 struct bgp_node
*rn
;
3523 struct bgp_info
*new;
3525 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3527 /* Make new BGP info. */
3528 new = bgp_info_new ();
3529 new->type
= ZEBRA_ROUTE_BGP
;
3530 new->sub_type
= BGP_ROUTE_STATIC
;
3531 new->peer
= bgp
->peer_self
;
3532 new->attr
= bgp_attr_default_intern (BGP_ORIGIN_IGP
);
3533 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3534 new->uptime
= time (NULL
);
3535 new->extra
= bgp_info_extra_new();
3536 memcpy (new->extra
->tag
, tag
, 3);
3538 /* Aggregate address increment. */
3539 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3541 /* Register new BGP information. */
3542 bgp_info_add (rn
, new);
3544 /* route_node_get lock */
3545 bgp_unlock_node (rn
);
3547 /* Process change. */
3548 bgp_process (bgp
, rn
, afi
, safi
);
3552 bgp_static_withdraw (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3555 struct bgp_node
*rn
;
3556 struct bgp_info
*ri
;
3558 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3560 /* Check selected route and self inserted route. */
3561 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3562 if (ri
->peer
== bgp
->peer_self
3563 && ri
->type
== ZEBRA_ROUTE_BGP
3564 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3567 /* Withdraw static BGP route from routing table. */
3570 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3571 bgp_info_delete (rn
, ri
);
3572 bgp_process (bgp
, rn
, afi
, safi
);
3575 /* Unlock bgp_node_lookup. */
3576 bgp_unlock_node (rn
);
3580 bgp_check_local_routes_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
)
3582 struct bgp_static
*bgp_static
;
3584 struct bgp_node
*rn
;
3587 bgp
= rsclient
->bgp
;
3589 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3590 if ((bgp_static
= rn
->info
) != NULL
)
3594 bgp_static_update_rsclient (rsclient
, p
, bgp_static
,
3600 bgp_static_withdraw_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, u_int16_t afi
,
3601 u_char safi
, struct prefix_rd
*prd
, u_char
*tag
)
3603 struct bgp_node
*rn
;
3604 struct bgp_info
*ri
;
3606 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3608 /* Check selected route and self inserted route. */
3609 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3610 if (ri
->peer
== bgp
->peer_self
3611 && ri
->type
== ZEBRA_ROUTE_BGP
3612 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3615 /* Withdraw static BGP route from routing table. */
3618 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3619 bgp_info_delete (rn
, ri
);
3620 bgp_process (bgp
, rn
, afi
, safi
);
3623 /* Unlock bgp_node_lookup. */
3624 bgp_unlock_node (rn
);
3628 bgp_pathlimit_update_parents (struct bgp
*bgp
, struct bgp_node
*rn
,
3631 struct bgp_node
*parent
= rn
;
3632 struct bgp_static
*sp
;
3634 /* Existing static changed TTL, search parents and adjust their atomic */
3635 while ((parent
= parent
->parent
))
3636 if ((sp
= parent
->info
))
3638 int sp_level
= (sp
->atomic
? 1 : 0);
3639 ttl_edge
? sp
->atomic
++ : sp
->atomic
--;
3641 /* did we change state of parent whether atomic is set or not? */
3642 if (sp_level
!= (sp
->atomic
? 1 : 0))
3644 bgp_static_update (bgp
, &parent
->p
, sp
,
3645 rn
->table
->afi
, rn
->table
->safi
);
3650 /* Configure static BGP network. When user don't run zebra, static
3651 route should be installed as valid. */
3653 bgp_static_set (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3654 u_int16_t afi
, u_char safi
, const char *rmap
, int backdoor
,
3659 struct bgp_static
*bgp_static
;
3660 struct bgp_node
*rn
;
3661 u_char need_update
= 0;
3662 u_char ttl_change
= 0;
3663 u_char ttl_edge
= (ttl
? 1 : 0);
3666 /* Convert IP prefix string to struct prefix. */
3667 ret
= str2prefix (ip_str
, &p
);
3670 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3674 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3676 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3680 #endif /* HAVE_IPV6 */
3684 /* Set BGP static route configuration. */
3685 rn
= bgp_node_get (bgp
->route
[afi
][safi
], &p
);
3689 /* Configuration change. */
3690 bgp_static
= rn
->info
;
3692 /* Check previous routes are installed into BGP. */
3693 if (bgp_static
->valid
)
3695 if (bgp_static
->backdoor
!= backdoor
3696 || bgp_static
->ttl
!= ttl
)
3700 /* need to catch TTL set/unset transitions for handling of
3703 if ((bgp_static
->ttl
? 1 : 0) != ttl_edge
)
3706 bgp_static
->backdoor
= backdoor
;
3707 bgp_static
->ttl
= ttl
;
3711 if (bgp_static
->rmap
.name
)
3712 free (bgp_static
->rmap
.name
);
3713 bgp_static
->rmap
.name
= strdup (rmap
);
3714 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3718 if (bgp_static
->rmap
.name
)
3719 free (bgp_static
->rmap
.name
);
3720 bgp_static
->rmap
.name
= NULL
;
3721 bgp_static
->rmap
.map
= NULL
;
3722 bgp_static
->valid
= 0;
3724 bgp_unlock_node (rn
);
3728 /* New configuration. */
3729 bgp_static
= bgp_static_new ();
3730 bgp_static
->backdoor
= backdoor
;
3731 bgp_static
->valid
= 0;
3732 bgp_static
->igpmetric
= 0;
3733 bgp_static
->igpnexthop
.s_addr
= 0;
3734 bgp_static
->ttl
= ttl
;
3735 ttl_change
= ttl_edge
;
3740 if (bgp_static
->rmap
.name
)
3741 free (bgp_static
->rmap
.name
);
3742 bgp_static
->rmap
.name
= strdup (rmap
);
3743 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3745 rn
->info
= bgp_static
;
3748 /* ".. sites that choose to advertise the
3749 * AS_PATHLIMIT path attribute SHOULD advertise the ATOMIC_AGGREGATE on
3750 * all less specific covering prefixes as well as the more specific
3754 * Prefix that has just had pathlimit set/unset:
3755 * - Must bump ATOMIC refcount on all parents.
3757 * To catch less specific prefixes:
3758 * - Must search children for ones with TTL, bump atomic refcount
3759 * (we dont care if we're deleting a less specific prefix..)
3763 /* Existing static changed TTL, search parents and adjust their atomic */
3764 bgp_pathlimit_update_parents (bgp
, rn
, ttl_edge
);
3769 struct bgp_node
*child
;
3770 struct bgp_static
*sc
;
3772 /* New static, search children and bump this statics atomic.. */
3773 child
= bgp_lock_node (rn
); /* route_next_until unlocks it.. */
3774 while ((child
= bgp_route_next_until (child
, rn
)))
3776 if ((sc
= child
->info
) && sc
->ttl
)
3777 bgp_static
->atomic
++;
3781 /* If BGP scan is not enabled, we should install this route here. */
3782 if (! bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3784 bgp_static
->valid
= 1;
3787 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3789 if (! bgp_static
->backdoor
)
3790 bgp_static_update (bgp
, &p
, bgp_static
, afi
, safi
);
3796 /* Configure static BGP network. */
3798 bgp_static_unset (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3799 u_int16_t afi
, u_char safi
)
3803 struct bgp_static
*bgp_static
;
3804 struct bgp_node
*rn
;
3806 /* Convert IP prefix string to struct prefix. */
3807 ret
= str2prefix (ip_str
, &p
);
3810 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3814 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3816 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3820 #endif /* HAVE_IPV6 */
3824 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], &p
);
3827 vty_out (vty
, "%% Can't find specified static route configuration.%s",
3832 bgp_static
= rn
->info
;
3834 /* decrement atomic in parents, see bgp_static_set */
3835 bgp_pathlimit_update_parents (bgp
, rn
, 0);
3837 /* Update BGP RIB. */
3838 if (! bgp_static
->backdoor
)
3839 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3841 /* Clear configuration. */
3842 bgp_static_free (bgp_static
);
3844 bgp_unlock_node (rn
);
3845 bgp_unlock_node (rn
);
3850 /* Called from bgp_delete(). Delete all static routes from the BGP
3853 bgp_static_delete (struct bgp
*bgp
)
3857 struct bgp_node
*rn
;
3858 struct bgp_node
*rm
;
3859 struct bgp_table
*table
;
3860 struct bgp_static
*bgp_static
;
3862 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3863 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3864 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3865 if (rn
->info
!= NULL
)
3867 if (safi
== SAFI_MPLS_VPN
)
3871 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
3873 bgp_static
= rn
->info
;
3874 bgp_static_withdraw_vpnv4 (bgp
, &rm
->p
,
3875 AFI_IP
, SAFI_MPLS_VPN
,
3876 (struct prefix_rd
*)&rn
->p
,
3878 bgp_static_free (bgp_static
);
3880 bgp_unlock_node (rn
);
3885 bgp_static
= rn
->info
;
3886 bgp_static_withdraw (bgp
, &rn
->p
, afi
, safi
);
3887 bgp_static_free (bgp_static
);
3889 bgp_unlock_node (rn
);
3895 bgp_static_set_vpnv4 (struct vty
*vty
, const char *ip_str
, const char *rd_str
,
3896 const char *tag_str
)
3900 struct prefix_rd prd
;
3902 struct bgp_node
*prn
;
3903 struct bgp_node
*rn
;
3904 struct bgp_table
*table
;
3905 struct bgp_static
*bgp_static
;
3910 ret
= str2prefix (ip_str
, &p
);
3913 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3918 ret
= str2prefix_rd (rd_str
, &prd
);
3921 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3925 ret
= str2tag (tag_str
, tag
);
3928 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3932 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3933 (struct prefix
*)&prd
);
3934 if (prn
->info
== NULL
)
3935 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3937 bgp_unlock_node (prn
);
3940 rn
= bgp_node_get (table
, &p
);
3944 vty_out (vty
, "%% Same network configuration exists%s", VTY_NEWLINE
);
3945 bgp_unlock_node (rn
);
3949 /* New configuration. */
3950 bgp_static
= bgp_static_new ();
3951 bgp_static
->valid
= 1;
3952 memcpy (bgp_static
->tag
, tag
, 3);
3953 rn
->info
= bgp_static
;
3955 bgp_static_update_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3961 /* Configure static BGP network. */
3963 bgp_static_unset_vpnv4 (struct vty
*vty
, const char *ip_str
,
3964 const char *rd_str
, const char *tag_str
)
3969 struct prefix_rd prd
;
3970 struct bgp_node
*prn
;
3971 struct bgp_node
*rn
;
3972 struct bgp_table
*table
;
3973 struct bgp_static
*bgp_static
;
3978 /* Convert IP prefix string to struct prefix. */
3979 ret
= str2prefix (ip_str
, &p
);
3982 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3987 ret
= str2prefix_rd (rd_str
, &prd
);
3990 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3994 ret
= str2tag (tag_str
, tag
);
3997 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
4001 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
4002 (struct prefix
*)&prd
);
4003 if (prn
->info
== NULL
)
4004 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
4006 bgp_unlock_node (prn
);
4009 rn
= bgp_node_lookup (table
, &p
);
4013 bgp_static_withdraw_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
4015 bgp_static
= rn
->info
;
4016 bgp_static_free (bgp_static
);
4018 bgp_unlock_node (rn
);
4019 bgp_unlock_node (rn
);
4022 vty_out (vty
, "%% Can't find the route%s", VTY_NEWLINE
);
4029 "network A.B.C.D/M",
4030 "Specify a network to announce via BGP\n"
4031 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4036 VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl
, argv
[1], 1, 255);
4038 return bgp_static_set (vty
, vty
->index
, argv
[0],
4039 AFI_IP
, bgp_node_safi (vty
), NULL
, 0, ttl
);
4043 bgp_network_ttl_cmd
,
4044 "network A.B.C.D/M pathlimit <0-255>",
4045 "Specify a network to announce via BGP\n"
4046 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4047 "AS-Path hopcount limit attribute\n"
4048 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4050 DEFUN (bgp_network_route_map
,
4051 bgp_network_route_map_cmd
,
4052 "network A.B.C.D/M route-map WORD",
4053 "Specify a network to announce via BGP\n"
4054 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4055 "Route-map to modify the attributes\n"
4056 "Name of the route map\n")
4058 return bgp_static_set (vty
, vty
->index
, argv
[0],
4059 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0, 0);
4062 DEFUN (bgp_network_backdoor
,
4063 bgp_network_backdoor_cmd
,
4064 "network A.B.C.D/M backdoor",
4065 "Specify a network to announce via BGP\n"
4066 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4067 "Specify a BGP backdoor route\n")
4072 VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl
, argv
[1], 1, 255);
4074 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP
, SAFI_UNICAST
,
4078 ALIAS (bgp_network_backdoor
,
4079 bgp_network_backdoor_ttl_cmd
,
4080 "network A.B.C.D/M backdoor pathlimit <0-255>",
4081 "Specify a network to announce via BGP\n"
4082 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4083 "Specify a BGP backdoor route\n"
4084 "AS-Path hopcount limit attribute\n"
4085 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4087 DEFUN (bgp_network_mask
,
4088 bgp_network_mask_cmd
,
4089 "network A.B.C.D mask A.B.C.D",
4090 "Specify a network to announce via BGP\n"
4096 char prefix_str
[BUFSIZ
];
4100 VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl
, argv
[2], 1, 255);
4102 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4105 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4109 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4110 AFI_IP
, bgp_node_safi (vty
), NULL
, 0, ttl
);
4113 ALIAS (bgp_network_mask
,
4114 bgp_network_mask_ttl_cmd
,
4115 "network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4116 "Specify a network to announce via BGP\n"
4120 "AS-Path hopcount limit attribute\n"
4121 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4123 DEFUN (bgp_network_mask_route_map
,
4124 bgp_network_mask_route_map_cmd
,
4125 "network A.B.C.D mask A.B.C.D route-map WORD",
4126 "Specify a network to announce via BGP\n"
4130 "Route-map to modify the attributes\n"
4131 "Name of the route map\n")
4134 char prefix_str
[BUFSIZ
];
4136 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4139 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4143 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4144 AFI_IP
, bgp_node_safi (vty
), argv
[2], 0, 0);
4147 DEFUN (bgp_network_mask_backdoor
,
4148 bgp_network_mask_backdoor_cmd
,
4149 "network A.B.C.D mask A.B.C.D backdoor",
4150 "Specify a network to announce via BGP\n"
4154 "Specify a BGP backdoor route\n")
4157 char prefix_str
[BUFSIZ
];
4161 VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl
, argv
[2], 1, 255);
4163 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4166 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4170 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4174 ALIAS (bgp_network_mask_backdoor
,
4175 bgp_network_mask_backdoor_ttl_cmd
,
4176 "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4177 "Specify a network to announce via BGP\n"
4181 "Specify a BGP backdoor route\n"
4182 "AS-Path hopcount limit attribute\n"
4183 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4185 DEFUN (bgp_network_mask_natural
,
4186 bgp_network_mask_natural_cmd
,
4188 "Specify a network to announce via BGP\n"
4192 char prefix_str
[BUFSIZ
];
4196 VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl
, argv
[1], 1, 255);
4198 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4201 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4205 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4206 AFI_IP
, bgp_node_safi (vty
), NULL
, 0, ttl
);
4209 ALIAS (bgp_network_mask_natural
,
4210 bgp_network_mask_natural_ttl_cmd
,
4211 "network A.B.C.D pathlimit <0-255>",
4212 "Specify a network to announce via BGP\n"
4214 "AS-Path hopcount limit attribute\n"
4215 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4217 DEFUN (bgp_network_mask_natural_route_map
,
4218 bgp_network_mask_natural_route_map_cmd
,
4219 "network A.B.C.D route-map WORD",
4220 "Specify a network to announce via BGP\n"
4222 "Route-map to modify the attributes\n"
4223 "Name of the route map\n")
4226 char prefix_str
[BUFSIZ
];
4228 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4231 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4235 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4236 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0, 0);
4239 DEFUN (bgp_network_mask_natural_backdoor
,
4240 bgp_network_mask_natural_backdoor_cmd
,
4241 "network A.B.C.D backdoor",
4242 "Specify a network to announce via BGP\n"
4244 "Specify a BGP backdoor route\n")
4247 char prefix_str
[BUFSIZ
];
4251 VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl
, argv
[1], 1, 255);
4253 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4256 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4260 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4264 ALIAS (bgp_network_mask_natural_backdoor
,
4265 bgp_network_mask_natural_backdoor_ttl_cmd
,
4266 "network A.B.C.D backdoor pathlimit (1-255>",
4267 "Specify a network to announce via BGP\n"
4269 "Specify a BGP backdoor route\n"
4270 "AS-Path hopcount limit attribute\n"
4271 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4273 DEFUN (no_bgp_network
,
4275 "no network A.B.C.D/M",
4277 "Specify a network to announce via BGP\n"
4278 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4280 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP
,
4281 bgp_node_safi (vty
));
4284 ALIAS (no_bgp_network
,
4285 no_bgp_network_ttl_cmd
,
4286 "no network A.B.C.D/M pathlimit <0-255>",
4288 "Specify a network to announce via BGP\n"
4289 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4290 "AS-Path hopcount limit attribute\n"
4291 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4293 ALIAS (no_bgp_network
,
4294 no_bgp_network_route_map_cmd
,
4295 "no network A.B.C.D/M route-map WORD",
4297 "Specify a network to announce via BGP\n"
4298 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4299 "Route-map to modify the attributes\n"
4300 "Name of the route map\n")
4302 ALIAS (no_bgp_network
,
4303 no_bgp_network_backdoor_cmd
,
4304 "no network A.B.C.D/M backdoor",
4306 "Specify a network to announce via BGP\n"
4307 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4308 "Specify a BGP backdoor route\n")
4310 ALIAS (no_bgp_network
,
4311 no_bgp_network_backdoor_ttl_cmd
,
4312 "no network A.B.C.D/M backdoor pathlimit <0-255>",
4314 "Specify a network to announce via BGP\n"
4315 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4316 "Specify a BGP backdoor route\n"
4317 "AS-Path hopcount limit attribute\n"
4318 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4320 DEFUN (no_bgp_network_mask
,
4321 no_bgp_network_mask_cmd
,
4322 "no network A.B.C.D mask A.B.C.D",
4324 "Specify a network to announce via BGP\n"
4330 char prefix_str
[BUFSIZ
];
4332 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4335 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4339 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4340 bgp_node_safi (vty
));
4343 ALIAS (no_bgp_network
,
4344 no_bgp_network_mask_ttl_cmd
,
4345 "no network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4347 "Specify a network to announce via BGP\n"
4351 "AS-Path hopcount limit attribute\n"
4352 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4354 ALIAS (no_bgp_network_mask
,
4355 no_bgp_network_mask_route_map_cmd
,
4356 "no network A.B.C.D mask A.B.C.D route-map WORD",
4358 "Specify a network to announce via BGP\n"
4362 "Route-map to modify the attributes\n"
4363 "Name of the route map\n")
4365 ALIAS (no_bgp_network_mask
,
4366 no_bgp_network_mask_backdoor_cmd
,
4367 "no network A.B.C.D mask A.B.C.D backdoor",
4369 "Specify a network to announce via BGP\n"
4373 "Specify a BGP backdoor route\n")
4375 ALIAS (no_bgp_network_mask
,
4376 no_bgp_network_mask_backdoor_ttl_cmd
,
4377 "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4379 "Specify a network to announce via BGP\n"
4383 "Specify a BGP backdoor route\n"
4384 "AS-Path hopcount limit attribute\n"
4385 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4387 DEFUN (no_bgp_network_mask_natural
,
4388 no_bgp_network_mask_natural_cmd
,
4389 "no network A.B.C.D",
4391 "Specify a network to announce via BGP\n"
4395 char prefix_str
[BUFSIZ
];
4397 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4400 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4404 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4405 bgp_node_safi (vty
));
4408 ALIAS (no_bgp_network_mask_natural
,
4409 no_bgp_network_mask_natural_route_map_cmd
,
4410 "no network A.B.C.D route-map WORD",
4412 "Specify a network to announce via BGP\n"
4414 "Route-map to modify the attributes\n"
4415 "Name of the route map\n")
4417 ALIAS (no_bgp_network_mask_natural
,
4418 no_bgp_network_mask_natural_backdoor_cmd
,
4419 "no network A.B.C.D backdoor",
4421 "Specify a network to announce via BGP\n"
4423 "Specify a BGP backdoor route\n")
4425 ALIAS (no_bgp_network_mask_natural
,
4426 no_bgp_network_mask_natural_ttl_cmd
,
4427 "no network A.B.C.D pathlimit <0-255>",
4429 "Specify a network to announce via BGP\n"
4431 "AS-Path hopcount limit attribute\n"
4432 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4434 ALIAS (no_bgp_network_mask_natural
,
4435 no_bgp_network_mask_natural_backdoor_ttl_cmd
,
4436 "no network A.B.C.D backdoor pathlimit <0-255>",
4438 "Specify a network to announce via BGP\n"
4440 "Specify a BGP backdoor route\n"
4441 "AS-Path hopcount limit attribute\n"
4442 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4445 DEFUN (ipv6_bgp_network
,
4446 ipv6_bgp_network_cmd
,
4447 "network X:X::X:X/M",
4448 "Specify a network to announce via BGP\n"
4449 "IPv6 prefix <network>/<length>\n")
4454 VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl
, argv
[1], 1, 255);
4456 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
4460 ALIAS (ipv6_bgp_network
,
4461 ipv6_bgp_network_ttl_cmd
,
4462 "network X:X::X:X/M pathlimit <0-255>",
4463 "Specify a network to announce via BGP\n"
4464 "IPv6 prefix <network>/<length>\n"
4465 "AS-Path hopcount limit attribute\n"
4466 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4468 DEFUN (ipv6_bgp_network_route_map
,
4469 ipv6_bgp_network_route_map_cmd
,
4470 "network X:X::X:X/M route-map WORD",
4471 "Specify a network to announce via BGP\n"
4472 "IPv6 prefix <network>/<length>\n"
4473 "Route-map to modify the attributes\n"
4474 "Name of the route map\n")
4476 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
,
4477 bgp_node_safi (vty
), argv
[1], 0, 0);
4480 DEFUN (no_ipv6_bgp_network
,
4481 no_ipv6_bgp_network_cmd
,
4482 "no network X:X::X:X/M",
4484 "Specify a network to announce via BGP\n"
4485 "IPv6 prefix <network>/<length>\n")
4487 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
4490 ALIAS (no_ipv6_bgp_network
,
4491 no_ipv6_bgp_network_route_map_cmd
,
4492 "no network X:X::X:X/M route-map WORD",
4494 "Specify a network to announce via BGP\n"
4495 "IPv6 prefix <network>/<length>\n"
4496 "Route-map to modify the attributes\n"
4497 "Name of the route map\n")
4499 ALIAS (no_ipv6_bgp_network
,
4500 no_ipv6_bgp_network_ttl_cmd
,
4501 "no network X:X::X:X/M pathlimit <0-255>",
4503 "Specify a network to announce via BGP\n"
4504 "IPv6 prefix <network>/<length>\n"
4505 "AS-Path hopcount limit attribute\n"
4506 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4508 ALIAS (ipv6_bgp_network
,
4509 old_ipv6_bgp_network_cmd
,
4510 "ipv6 bgp network X:X::X:X/M",
4513 "Specify a network to announce via BGP\n"
4514 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4516 ALIAS (no_ipv6_bgp_network
,
4517 old_no_ipv6_bgp_network_cmd
,
4518 "no ipv6 bgp network X:X::X:X/M",
4522 "Specify a network to announce via BGP\n"
4523 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4524 #endif /* HAVE_IPV6 */
4526 /* Aggreagete address:
4528 advertise-map Set condition to advertise attribute
4529 as-set Generate AS set path information
4530 attribute-map Set attributes of aggregate
4531 route-map Set parameters of aggregate
4532 summary-only Filter more specific routes from updates
4533 suppress-map Conditionally filter more specific routes from updates
4536 struct bgp_aggregate
4538 /* Summary-only flag. */
4539 u_char summary_only
;
4541 /* AS set generation. */
4544 /* Route-map for aggregated route. */
4545 struct route_map
*map
;
4547 /* Suppress-count. */
4548 unsigned long count
;
4550 /* SAFI configuration. */
4554 static struct bgp_aggregate
*
4555 bgp_aggregate_new (void)
4557 return XCALLOC (MTYPE_BGP_AGGREGATE
, sizeof (struct bgp_aggregate
));
4561 bgp_aggregate_free (struct bgp_aggregate
*aggregate
)
4563 XFREE (MTYPE_BGP_AGGREGATE
, aggregate
);
4567 bgp_aggregate_route (struct bgp
*bgp
, struct prefix
*p
, struct bgp_info
*rinew
,
4568 afi_t afi
, safi_t safi
, struct bgp_info
*del
,
4569 struct bgp_aggregate
*aggregate
)
4571 struct bgp_table
*table
;
4572 struct bgp_node
*top
;
4573 struct bgp_node
*rn
;
4575 struct aspath
*aspath
= NULL
;
4576 struct aspath
*asmerge
= NULL
;
4577 struct community
*community
= NULL
;
4578 struct community
*commerge
= NULL
;
4579 struct in_addr nexthop
;
4581 struct bgp_info
*ri
;
4582 struct bgp_info
*new;
4584 unsigned long match
= 0;
4586 /* Record adding route's nexthop and med. */
4589 nexthop
= rinew
->attr
->nexthop
;
4590 med
= rinew
->attr
->med
;
4593 /* ORIGIN attribute: If at least one route among routes that are
4594 aggregated has ORIGIN with the value INCOMPLETE, then the
4595 aggregated route must have the ORIGIN attribute with the value
4596 INCOMPLETE. Otherwise, if at least one route among routes that
4597 are aggregated has ORIGIN with the value EGP, then the aggregated
4598 route must have the origin attribute with the value EGP. In all
4599 other case the value of the ORIGIN attribute of the aggregated
4600 route is INTERNAL. */
4601 origin
= BGP_ORIGIN_IGP
;
4603 table
= bgp
->rib
[afi
][safi
];
4605 top
= bgp_node_get (table
, p
);
4606 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4607 if (rn
->p
.prefixlen
> p
->prefixlen
)
4611 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4613 if (BGP_INFO_HOLDDOWN (ri
))
4616 if (del
&& ri
== del
)
4619 if (! rinew
&& first
)
4621 nexthop
= ri
->attr
->nexthop
;
4622 med
= ri
->attr
->med
;
4626 #ifdef AGGREGATE_NEXTHOP_CHECK
4627 if (! IPV4_ADDR_SAME (&ri
->attr
->nexthop
, &nexthop
)
4628 || ri
->attr
->med
!= med
)
4631 aspath_free (aspath
);
4633 community_free (community
);
4634 bgp_unlock_node (rn
);
4635 bgp_unlock_node (top
);
4638 #endif /* AGGREGATE_NEXTHOP_CHECK */
4640 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4642 if (aggregate
->summary_only
)
4644 (bgp_info_extra_get (ri
))->suppress
++;
4645 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4651 if (aggregate
->as_set
)
4653 if (origin
< ri
->attr
->origin
)
4654 origin
= ri
->attr
->origin
;
4658 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4659 aspath_free (aspath
);
4663 aspath
= aspath_dup (ri
->attr
->aspath
);
4665 if (ri
->attr
->community
)
4669 commerge
= community_merge (community
,
4670 ri
->attr
->community
);
4671 community
= community_uniq_sort (commerge
);
4672 community_free (commerge
);
4675 community
= community_dup (ri
->attr
->community
);
4681 bgp_process (bgp
, rn
, afi
, safi
);
4683 bgp_unlock_node (top
);
4689 if (aggregate
->summary_only
)
4690 (bgp_info_extra_get (rinew
))->suppress
++;
4692 if (aggregate
->as_set
)
4694 if (origin
< rinew
->attr
->origin
)
4695 origin
= rinew
->attr
->origin
;
4699 asmerge
= aspath_aggregate (aspath
, rinew
->attr
->aspath
);
4700 aspath_free (aspath
);
4704 aspath
= aspath_dup (rinew
->attr
->aspath
);
4706 if (rinew
->attr
->community
)
4710 commerge
= community_merge (community
,
4711 rinew
->attr
->community
);
4712 community
= community_uniq_sort (commerge
);
4713 community_free (commerge
);
4716 community
= community_dup (rinew
->attr
->community
);
4721 if (aggregate
->count
> 0)
4723 rn
= bgp_node_get (table
, p
);
4724 new = bgp_info_new ();
4725 new->type
= ZEBRA_ROUTE_BGP
;
4726 new->sub_type
= BGP_ROUTE_AGGREGATE
;
4727 new->peer
= bgp
->peer_self
;
4728 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4729 new->attr
= bgp_attr_aggregate_intern (bgp
, origin
, aspath
, community
, aggregate
->as_set
);
4730 new->uptime
= time (NULL
);
4732 bgp_info_add (rn
, new);
4733 bgp_unlock_node (rn
);
4734 bgp_process (bgp
, rn
, afi
, safi
);
4739 aspath_free (aspath
);
4741 community_free (community
);
4745 void bgp_aggregate_delete (struct bgp
*, struct prefix
*, afi_t
, safi_t
,
4746 struct bgp_aggregate
*);
4749 bgp_aggregate_increment (struct bgp
*bgp
, struct prefix
*p
,
4750 struct bgp_info
*ri
, afi_t afi
, safi_t safi
)
4752 struct bgp_node
*child
;
4753 struct bgp_node
*rn
;
4754 struct bgp_aggregate
*aggregate
;
4756 /* MPLS-VPN aggregation is not yet supported. */
4757 if (safi
== SAFI_MPLS_VPN
)
4760 if (p
->prefixlen
== 0)
4763 if (BGP_INFO_HOLDDOWN (ri
))
4766 child
= bgp_node_get (bgp
->aggregate
[afi
][safi
], p
);
4768 /* Aggregate address configuration check. */
4769 for (rn
= child
; rn
; rn
= rn
->parent
)
4770 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4772 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4773 bgp_aggregate_route (bgp
, &rn
->p
, ri
, afi
, safi
, NULL
, aggregate
);
4775 bgp_unlock_node (child
);
4779 bgp_aggregate_decrement (struct bgp
*bgp
, struct prefix
*p
,
4780 struct bgp_info
*del
, afi_t afi
, safi_t safi
)
4782 struct bgp_node
*child
;
4783 struct bgp_node
*rn
;
4784 struct bgp_aggregate
*aggregate
;
4786 /* MPLS-VPN aggregation is not yet supported. */
4787 if (safi
== SAFI_MPLS_VPN
)
4790 if (p
->prefixlen
== 0)
4793 child
= bgp_node_get (bgp
->aggregate
[afi
][safi
], p
);
4795 /* Aggregate address configuration check. */
4796 for (rn
= child
; rn
; rn
= rn
->parent
)
4797 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4799 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4800 bgp_aggregate_route (bgp
, &rn
->p
, NULL
, afi
, safi
, del
, aggregate
);
4802 bgp_unlock_node (child
);
4806 bgp_aggregate_add (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
, safi_t safi
,
4807 struct bgp_aggregate
*aggregate
)
4809 struct bgp_table
*table
;
4810 struct bgp_node
*top
;
4811 struct bgp_node
*rn
;
4812 struct bgp_info
*new;
4813 struct bgp_info
*ri
;
4814 unsigned long match
;
4815 u_char origin
= BGP_ORIGIN_IGP
;
4816 struct aspath
*aspath
= NULL
;
4817 struct aspath
*asmerge
= NULL
;
4818 struct community
*community
= NULL
;
4819 struct community
*commerge
= NULL
;
4821 table
= bgp
->rib
[afi
][safi
];
4824 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4826 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4829 /* If routes exists below this node, generate aggregate routes. */
4830 top
= bgp_node_get (table
, p
);
4831 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4832 if (rn
->p
.prefixlen
> p
->prefixlen
)
4836 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4838 if (BGP_INFO_HOLDDOWN (ri
))
4841 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4843 /* summary-only aggregate route suppress aggregated
4844 route announcement. */
4845 if (aggregate
->summary_only
)
4847 (bgp_info_extra_get (ri
))->suppress
++;
4848 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4851 /* as-set aggregate route generate origin, as path,
4852 community aggregation. */
4853 if (aggregate
->as_set
)
4855 if (origin
< ri
->attr
->origin
)
4856 origin
= ri
->attr
->origin
;
4860 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4861 aspath_free (aspath
);
4865 aspath
= aspath_dup (ri
->attr
->aspath
);
4867 if (ri
->attr
->community
)
4871 commerge
= community_merge (community
,
4872 ri
->attr
->community
);
4873 community
= community_uniq_sort (commerge
);
4874 community_free (commerge
);
4877 community
= community_dup (ri
->attr
->community
);
4884 /* If this node is suppressed, process the change. */
4886 bgp_process (bgp
, rn
, afi
, safi
);
4888 bgp_unlock_node (top
);
4890 /* Add aggregate route to BGP table. */
4891 if (aggregate
->count
)
4893 rn
= bgp_node_get (table
, p
);
4895 new = bgp_info_new ();
4896 new->type
= ZEBRA_ROUTE_BGP
;
4897 new->sub_type
= BGP_ROUTE_AGGREGATE
;
4898 new->peer
= bgp
->peer_self
;
4899 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4900 new->attr
= bgp_attr_aggregate_intern (bgp
, origin
, aspath
, community
, aggregate
->as_set
);
4901 new->uptime
= time (NULL
);
4903 bgp_info_add (rn
, new);
4904 bgp_unlock_node (rn
);
4906 /* Process change. */
4907 bgp_process (bgp
, rn
, afi
, safi
);
4912 bgp_aggregate_delete (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
4913 safi_t safi
, struct bgp_aggregate
*aggregate
)
4915 struct bgp_table
*table
;
4916 struct bgp_node
*top
;
4917 struct bgp_node
*rn
;
4918 struct bgp_info
*ri
;
4919 unsigned long match
;
4921 table
= bgp
->rib
[afi
][safi
];
4923 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4925 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4928 /* If routes exists below this node, generate aggregate routes. */
4929 top
= bgp_node_get (table
, p
);
4930 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4931 if (rn
->p
.prefixlen
> p
->prefixlen
)
4935 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4937 if (BGP_INFO_HOLDDOWN (ri
))
4940 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4942 if (aggregate
->summary_only
&& ri
->extra
)
4944 ri
->extra
->suppress
--;
4946 if (ri
->extra
->suppress
== 0)
4948 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4956 /* If this node was suppressed, process the change. */
4958 bgp_process (bgp
, rn
, afi
, safi
);
4960 bgp_unlock_node (top
);
4962 /* Delete aggregate route from BGP table. */
4963 rn
= bgp_node_get (table
, p
);
4965 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4966 if (ri
->peer
== bgp
->peer_self
4967 && ri
->type
== ZEBRA_ROUTE_BGP
4968 && ri
->sub_type
== BGP_ROUTE_AGGREGATE
)
4971 /* Withdraw static BGP route from routing table. */
4974 bgp_info_delete (rn
, ri
);
4975 bgp_process (bgp
, rn
, afi
, safi
);
4978 /* Unlock bgp_node_lookup. */
4979 bgp_unlock_node (rn
);
4982 /* Aggregate route attribute. */
4983 #define AGGREGATE_SUMMARY_ONLY 1
4984 #define AGGREGATE_AS_SET 1
4987 bgp_aggregate_set (struct vty
*vty
, const char *prefix_str
,
4988 afi_t afi
, safi_t safi
,
4989 u_char summary_only
, u_char as_set
)
4993 struct bgp_node
*rn
;
4995 struct bgp_aggregate
*aggregate
;
4997 /* Convert string to prefix structure. */
4998 ret
= str2prefix (prefix_str
, &p
);
5001 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5006 /* Get BGP structure. */
5009 /* Old configuration check. */
5010 rn
= bgp_node_get (bgp
->aggregate
[afi
][safi
], &p
);
5014 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
5015 bgp_unlock_node (rn
);
5019 /* Make aggregate address structure. */
5020 aggregate
= bgp_aggregate_new ();
5021 aggregate
->summary_only
= summary_only
;
5022 aggregate
->as_set
= as_set
;
5023 aggregate
->safi
= safi
;
5024 rn
->info
= aggregate
;
5026 /* Aggregate address insert into BGP routing table. */
5027 if (safi
& SAFI_UNICAST
)
5028 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5029 if (safi
& SAFI_MULTICAST
)
5030 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5036 bgp_aggregate_unset (struct vty
*vty
, const char *prefix_str
,
5037 afi_t afi
, safi_t safi
)
5041 struct bgp_node
*rn
;
5043 struct bgp_aggregate
*aggregate
;
5045 /* Convert string to prefix structure. */
5046 ret
= str2prefix (prefix_str
, &p
);
5049 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5054 /* Get BGP structure. */
5057 /* Old configuration check. */
5058 rn
= bgp_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
5061 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
5066 aggregate
= rn
->info
;
5067 if (aggregate
->safi
& SAFI_UNICAST
)
5068 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5069 if (aggregate
->safi
& SAFI_MULTICAST
)
5070 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5072 /* Unlock aggregate address configuration. */
5074 bgp_aggregate_free (aggregate
);
5075 bgp_unlock_node (rn
);
5076 bgp_unlock_node (rn
);
5081 DEFUN (aggregate_address
,
5082 aggregate_address_cmd
,
5083 "aggregate-address A.B.C.D/M",
5084 "Configure BGP aggregate entries\n"
5085 "Aggregate prefix\n")
5087 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
), 0, 0);
5090 DEFUN (aggregate_address_mask
,
5091 aggregate_address_mask_cmd
,
5092 "aggregate-address A.B.C.D A.B.C.D",
5093 "Configure BGP aggregate entries\n"
5094 "Aggregate address\n"
5098 char prefix_str
[BUFSIZ
];
5100 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5104 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5108 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5112 DEFUN (aggregate_address_summary_only
,
5113 aggregate_address_summary_only_cmd
,
5114 "aggregate-address A.B.C.D/M summary-only",
5115 "Configure BGP aggregate entries\n"
5116 "Aggregate prefix\n"
5117 "Filter more specific routes from updates\n")
5119 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5120 AGGREGATE_SUMMARY_ONLY
, 0);
5123 DEFUN (aggregate_address_mask_summary_only
,
5124 aggregate_address_mask_summary_only_cmd
,
5125 "aggregate-address A.B.C.D A.B.C.D summary-only",
5126 "Configure BGP aggregate entries\n"
5127 "Aggregate address\n"
5129 "Filter more specific routes from updates\n")
5132 char prefix_str
[BUFSIZ
];
5134 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5138 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5142 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5143 AGGREGATE_SUMMARY_ONLY
, 0);
5146 DEFUN (aggregate_address_as_set
,
5147 aggregate_address_as_set_cmd
,
5148 "aggregate-address A.B.C.D/M as-set",
5149 "Configure BGP aggregate entries\n"
5150 "Aggregate prefix\n"
5151 "Generate AS set path information\n")
5153 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5154 0, AGGREGATE_AS_SET
);
5157 DEFUN (aggregate_address_mask_as_set
,
5158 aggregate_address_mask_as_set_cmd
,
5159 "aggregate-address A.B.C.D A.B.C.D as-set",
5160 "Configure BGP aggregate entries\n"
5161 "Aggregate address\n"
5163 "Generate AS set path information\n")
5166 char prefix_str
[BUFSIZ
];
5168 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5172 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5176 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5177 0, AGGREGATE_AS_SET
);
5181 DEFUN (aggregate_address_as_set_summary
,
5182 aggregate_address_as_set_summary_cmd
,
5183 "aggregate-address A.B.C.D/M as-set summary-only",
5184 "Configure BGP aggregate entries\n"
5185 "Aggregate prefix\n"
5186 "Generate AS set path information\n"
5187 "Filter more specific routes from updates\n")
5189 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5190 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5193 ALIAS (aggregate_address_as_set_summary
,
5194 aggregate_address_summary_as_set_cmd
,
5195 "aggregate-address A.B.C.D/M summary-only as-set",
5196 "Configure BGP aggregate entries\n"
5197 "Aggregate prefix\n"
5198 "Filter more specific routes from updates\n"
5199 "Generate AS set path information\n")
5201 DEFUN (aggregate_address_mask_as_set_summary
,
5202 aggregate_address_mask_as_set_summary_cmd
,
5203 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5204 "Configure BGP aggregate entries\n"
5205 "Aggregate address\n"
5207 "Generate AS set path information\n"
5208 "Filter more specific routes from updates\n")
5211 char prefix_str
[BUFSIZ
];
5213 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5217 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5221 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5222 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5225 ALIAS (aggregate_address_mask_as_set_summary
,
5226 aggregate_address_mask_summary_as_set_cmd
,
5227 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5228 "Configure BGP aggregate entries\n"
5229 "Aggregate address\n"
5231 "Filter more specific routes from updates\n"
5232 "Generate AS set path information\n")
5234 DEFUN (no_aggregate_address
,
5235 no_aggregate_address_cmd
,
5236 "no aggregate-address A.B.C.D/M",
5238 "Configure BGP aggregate entries\n"
5239 "Aggregate prefix\n")
5241 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
));
5244 ALIAS (no_aggregate_address
,
5245 no_aggregate_address_summary_only_cmd
,
5246 "no aggregate-address A.B.C.D/M summary-only",
5248 "Configure BGP aggregate entries\n"
5249 "Aggregate prefix\n"
5250 "Filter more specific routes from updates\n")
5252 ALIAS (no_aggregate_address
,
5253 no_aggregate_address_as_set_cmd
,
5254 "no aggregate-address A.B.C.D/M as-set",
5256 "Configure BGP aggregate entries\n"
5257 "Aggregate prefix\n"
5258 "Generate AS set path information\n")
5260 ALIAS (no_aggregate_address
,
5261 no_aggregate_address_as_set_summary_cmd
,
5262 "no aggregate-address A.B.C.D/M as-set summary-only",
5264 "Configure BGP aggregate entries\n"
5265 "Aggregate prefix\n"
5266 "Generate AS set path information\n"
5267 "Filter more specific routes from updates\n")
5269 ALIAS (no_aggregate_address
,
5270 no_aggregate_address_summary_as_set_cmd
,
5271 "no aggregate-address A.B.C.D/M summary-only as-set",
5273 "Configure BGP aggregate entries\n"
5274 "Aggregate prefix\n"
5275 "Filter more specific routes from updates\n"
5276 "Generate AS set path information\n")
5278 DEFUN (no_aggregate_address_mask
,
5279 no_aggregate_address_mask_cmd
,
5280 "no aggregate-address A.B.C.D A.B.C.D",
5282 "Configure BGP aggregate entries\n"
5283 "Aggregate address\n"
5287 char prefix_str
[BUFSIZ
];
5289 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5293 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5297 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
5300 ALIAS (no_aggregate_address_mask
,
5301 no_aggregate_address_mask_summary_only_cmd
,
5302 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5304 "Configure BGP aggregate entries\n"
5305 "Aggregate address\n"
5307 "Filter more specific routes from updates\n")
5309 ALIAS (no_aggregate_address_mask
,
5310 no_aggregate_address_mask_as_set_cmd
,
5311 "no aggregate-address A.B.C.D A.B.C.D as-set",
5313 "Configure BGP aggregate entries\n"
5314 "Aggregate address\n"
5316 "Generate AS set path information\n")
5318 ALIAS (no_aggregate_address_mask
,
5319 no_aggregate_address_mask_as_set_summary_cmd
,
5320 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5322 "Configure BGP aggregate entries\n"
5323 "Aggregate address\n"
5325 "Generate AS set path information\n"
5326 "Filter more specific routes from updates\n")
5328 ALIAS (no_aggregate_address_mask
,
5329 no_aggregate_address_mask_summary_as_set_cmd
,
5330 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5332 "Configure BGP aggregate entries\n"
5333 "Aggregate address\n"
5335 "Filter more specific routes from updates\n"
5336 "Generate AS set path information\n")
5339 DEFUN (ipv6_aggregate_address
,
5340 ipv6_aggregate_address_cmd
,
5341 "aggregate-address X:X::X:X/M",
5342 "Configure BGP aggregate entries\n"
5343 "Aggregate prefix\n")
5345 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0, 0);
5348 DEFUN (ipv6_aggregate_address_summary_only
,
5349 ipv6_aggregate_address_summary_only_cmd
,
5350 "aggregate-address X:X::X:X/M summary-only",
5351 "Configure BGP aggregate entries\n"
5352 "Aggregate prefix\n"
5353 "Filter more specific routes from updates\n")
5355 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5356 AGGREGATE_SUMMARY_ONLY
, 0);
5359 DEFUN (no_ipv6_aggregate_address
,
5360 no_ipv6_aggregate_address_cmd
,
5361 "no aggregate-address X:X::X:X/M",
5363 "Configure BGP aggregate entries\n"
5364 "Aggregate prefix\n")
5366 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5369 DEFUN (no_ipv6_aggregate_address_summary_only
,
5370 no_ipv6_aggregate_address_summary_only_cmd
,
5371 "no aggregate-address X:X::X:X/M summary-only",
5373 "Configure BGP aggregate entries\n"
5374 "Aggregate prefix\n"
5375 "Filter more specific routes from updates\n")
5377 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5380 ALIAS (ipv6_aggregate_address
,
5381 old_ipv6_aggregate_address_cmd
,
5382 "ipv6 bgp aggregate-address X:X::X:X/M",
5385 "Configure BGP aggregate entries\n"
5386 "Aggregate prefix\n")
5388 ALIAS (ipv6_aggregate_address_summary_only
,
5389 old_ipv6_aggregate_address_summary_only_cmd
,
5390 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5393 "Configure BGP aggregate entries\n"
5394 "Aggregate prefix\n"
5395 "Filter more specific routes from updates\n")
5397 ALIAS (no_ipv6_aggregate_address
,
5398 old_no_ipv6_aggregate_address_cmd
,
5399 "no ipv6 bgp aggregate-address X:X::X:X/M",
5403 "Configure BGP aggregate entries\n"
5404 "Aggregate prefix\n")
5406 ALIAS (no_ipv6_aggregate_address_summary_only
,
5407 old_no_ipv6_aggregate_address_summary_only_cmd
,
5408 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5412 "Configure BGP aggregate entries\n"
5413 "Aggregate prefix\n"
5414 "Filter more specific routes from updates\n")
5415 #endif /* HAVE_IPV6 */
5417 /* Redistribute route treatment. */
5419 bgp_redistribute_add (struct prefix
*p
, struct in_addr
*nexthop
,
5420 u_int32_t metric
, u_char type
)
5423 struct listnode
*node
, *nnode
;
5424 struct bgp_info
*new;
5425 struct bgp_info
*bi
;
5426 struct bgp_info info
;
5427 struct bgp_node
*bn
;
5428 struct attr attr
= { 0 };
5429 struct attr attr_new
= { 0 };
5430 struct attr
*new_attr
;
5434 /* Make default attribute. */
5435 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
5437 attr
.nexthop
= *nexthop
;
5440 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
5442 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
5444 afi
= family2afi (p
->family
);
5446 if (bgp
->redist
[afi
][type
])
5448 /* Copy attribute for modification. */
5449 bgp_attr_dup (&attr_new
, &attr
);
5451 if (bgp
->redist_metric_flag
[afi
][type
])
5452 attr_new
.med
= bgp
->redist_metric
[afi
][type
];
5454 /* Apply route-map. */
5455 if (bgp
->rmap
[afi
][type
].map
)
5457 info
.peer
= bgp
->peer_self
;
5458 info
.attr
= &attr_new
;
5460 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
);
5462 ret
= route_map_apply (bgp
->rmap
[afi
][type
].map
, p
, RMAP_BGP
,
5465 bgp
->peer_self
->rmap_type
= 0;
5467 if (ret
== RMAP_DENYMATCH
)
5469 /* Free uninterned attribute. */
5470 bgp_attr_flush (&attr_new
);
5471 bgp_attr_extra_free (&attr_new
);
5473 /* Unintern original. */
5474 aspath_unintern (attr
.aspath
);
5475 bgp_attr_extra_free (&attr
);
5476 bgp_redistribute_delete (p
, type
);
5481 bn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
],
5482 afi
, SAFI_UNICAST
, p
, NULL
);
5484 new_attr
= bgp_attr_intern (&attr_new
);
5485 bgp_attr_extra_free (&attr_new
);
5487 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
5488 if (bi
->peer
== bgp
->peer_self
5489 && bi
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
5494 if (attrhash_cmp (bi
->attr
, new_attr
) &&
5495 !CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5497 bgp_attr_unintern (new_attr
);
5498 aspath_unintern (attr
.aspath
);
5499 bgp_attr_extra_free (&attr
);
5500 bgp_unlock_node (bn
);
5505 /* The attribute is changed. */
5506 bgp_info_set_flag (bn
, bi
, BGP_INFO_ATTR_CHANGED
);
5508 /* Rewrite BGP route information. */
5509 if (CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5510 bgp_info_restore(bn
, bi
);
5512 bgp_aggregate_decrement (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5513 bgp_attr_unintern (bi
->attr
);
5514 bi
->attr
= new_attr
;
5515 bi
->uptime
= time (NULL
);
5517 /* Process change. */
5518 bgp_aggregate_increment (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5519 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5520 bgp_unlock_node (bn
);
5521 aspath_unintern (attr
.aspath
);
5522 bgp_attr_extra_free (&attr
);
5527 new = bgp_info_new ();
5529 new->sub_type
= BGP_ROUTE_REDISTRIBUTE
;
5530 new->peer
= bgp
->peer_self
;
5531 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5532 new->attr
= new_attr
;
5533 new->uptime
= time (NULL
);
5535 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
5536 bgp_info_add (bn
, new);
5537 bgp_unlock_node (bn
);
5538 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5542 /* Unintern original. */
5543 aspath_unintern (attr
.aspath
);
5544 bgp_attr_extra_free (&attr
);
5548 bgp_redistribute_delete (struct prefix
*p
, u_char type
)
5551 struct listnode
*node
, *nnode
;
5553 struct bgp_node
*rn
;
5554 struct bgp_info
*ri
;
5556 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
5558 afi
= family2afi (p
->family
);
5560 if (bgp
->redist
[afi
][type
])
5562 rn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
5564 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5565 if (ri
->peer
== bgp
->peer_self
5566 && ri
->type
== type
)
5571 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
5572 bgp_info_delete (rn
, ri
);
5573 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5575 bgp_unlock_node (rn
);
5580 /* Withdraw specified route type's route. */
5582 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
)
5584 struct bgp_node
*rn
;
5585 struct bgp_info
*ri
;
5586 struct bgp_table
*table
;
5588 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
5590 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
5592 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5593 if (ri
->peer
== bgp
->peer_self
5594 && ri
->type
== type
)
5599 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
5600 bgp_info_delete (rn
, ri
);
5601 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5606 /* Static function to display route. */
5608 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
5611 u_int32_t destination
;
5614 if (p
->family
== AF_INET
)
5616 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
5617 destination
= ntohl (p
->u
.prefix4
.s_addr
);
5619 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
5620 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
5621 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
5622 || p
->u
.prefix4
.s_addr
== 0)
5624 /* When mask is natural, mask is not displayed. */
5627 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
5630 len
= vty_out (vty
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
5635 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
5637 vty_out (vty
, "%*s", len
, " ");
5640 enum bgp_display_type
5645 /* Print the short form route status for a bgp_info */
5647 route_vty_short_status_out (struct vty
*vty
, struct bgp_info
*binfo
)
5649 /* Route status display. */
5650 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5652 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5654 else if (binfo
->extra
&& binfo
->extra
->suppress
)
5656 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5662 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5664 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5666 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5671 /* Internal route. */
5672 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
5678 /* called from terminal list command */
5680 route_vty_out (struct vty
*vty
, struct prefix
*p
,
5681 struct bgp_info
*binfo
, int display
, safi_t safi
)
5685 /* short status lead text */
5686 route_vty_short_status_out (vty
, binfo
);
5688 /* print prefix and mask */
5690 route_vty_out_route (p
, vty
);
5692 vty_out (vty
, "%*s", 17, " ");
5694 /* Print attribute */
5698 if (p
->family
== AF_INET
)
5700 if (safi
== SAFI_MPLS_VPN
)
5701 vty_out (vty
, "%-16s",
5702 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5704 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5707 else if (p
->family
== AF_INET6
)
5712 len
= vty_out (vty
, "%s",
5713 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5717 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5719 vty_out (vty
, "%*s", len
, " ");
5721 #endif /* HAVE_IPV6 */
5723 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5724 vty_out (vty
, "%10d", attr
->med
);
5728 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5729 vty_out (vty
, "%7d", attr
->local_pref
);
5733 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
5737 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5740 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5742 vty_out (vty
, "%s", VTY_NEWLINE
);
5745 /* called from terminal list command */
5747 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
,
5748 struct attr
*attr
, safi_t safi
)
5750 /* Route status display. */
5755 /* print prefix and mask */
5756 route_vty_out_route (p
, vty
);
5758 /* Print attribute */
5761 if (p
->family
== AF_INET
)
5763 if (safi
== SAFI_MPLS_VPN
)
5764 vty_out (vty
, "%-16s",
5765 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5767 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5770 else if (p
->family
== AF_INET6
)
5775 assert (attr
->extra
);
5777 len
= vty_out (vty
, "%s",
5778 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5782 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5784 vty_out (vty
, "%*s", len
, " ");
5786 #endif /* HAVE_IPV6 */
5788 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5789 vty_out (vty
, "%10d", attr
->med
);
5793 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5794 vty_out (vty
, "%7d", attr
->local_pref
);
5798 vty_out (vty
, "%7d ", (attr
->extra
? attr
->extra
->weight
: 0));
5802 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5805 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5808 vty_out (vty
, "%s", VTY_NEWLINE
);
5812 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
5813 struct bgp_info
*binfo
, int display
, safi_t safi
)
5816 u_int32_t label
= 0;
5821 /* short status lead text */
5822 route_vty_short_status_out (vty
, binfo
);
5824 /* print prefix and mask */
5826 route_vty_out_route (p
, vty
);
5828 vty_out (vty
, "%*s", 17, " ");
5830 /* Print attribute */
5834 if (p
->family
== AF_INET
)
5836 if (safi
== SAFI_MPLS_VPN
)
5837 vty_out (vty
, "%-16s",
5838 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5840 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5843 else if (p
->family
== AF_INET6
)
5845 assert (attr
->extra
);
5848 if (attr
->extra
->mp_nexthop_len
== 16)
5850 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5852 else if (attr
->extra
->mp_nexthop_len
== 32)
5853 vty_out (vty
, "%s(%s)",
5854 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5856 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
5860 #endif /* HAVE_IPV6 */
5863 label
= decode_label (binfo
->extra
->tag
);
5865 vty_out (vty
, "notag/%d", label
);
5867 vty_out (vty
, "%s", VTY_NEWLINE
);
5870 /* dampening route */
5872 damp_route_vty_out (struct vty
*vty
, struct prefix
*p
,
5873 struct bgp_info
*binfo
, int display
, safi_t safi
)
5877 char timebuf
[BGP_UPTIME_LEN
];
5879 /* short status lead text */
5880 route_vty_short_status_out (vty
, binfo
);
5882 /* print prefix and mask */
5884 route_vty_out_route (p
, vty
);
5886 vty_out (vty
, "%*s", 17, " ");
5888 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
5891 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 34, " ");
5893 vty_out (vty
, "%*s", len
, " ");
5895 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
));
5897 /* Print attribute */
5903 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5906 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5908 vty_out (vty
, "%s", VTY_NEWLINE
);
5913 flap_route_vty_out (struct vty
*vty
, struct prefix
*p
,
5914 struct bgp_info
*binfo
, int display
, safi_t safi
)
5917 struct bgp_damp_info
*bdi
;
5918 char timebuf
[BGP_UPTIME_LEN
];
5924 bdi
= binfo
->extra
->damp_info
;
5926 /* short status lead text */
5927 route_vty_short_status_out (vty
, binfo
);
5929 /* print prefix and mask */
5931 route_vty_out_route (p
, vty
);
5933 vty_out (vty
, "%*s", 17, " ");
5935 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
5938 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 33, " ");
5940 vty_out (vty
, "%*s", len
, " ");
5942 len
= vty_out (vty
, "%d", bdi
->flap
);
5947 vty_out (vty
, "%*s ", len
, " ");
5949 vty_out (vty
, "%s ", peer_uptime (bdi
->start_time
,
5950 timebuf
, BGP_UPTIME_LEN
));
5952 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
)
5953 && ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5954 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
));
5956 vty_out (vty
, "%*s ", 8, " ");
5958 /* Print attribute */
5964 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5967 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5969 vty_out (vty
, "%s", VTY_NEWLINE
);
5973 route_vty_out_detail (struct vty
*vty
, struct bgp
*bgp
, struct prefix
*p
,
5974 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
)
5976 char buf
[INET6_ADDRSTRLEN
];
5979 int sockunion_vty_out (struct vty
*, union sockunion
*);
5985 /* Line1 display AS-path, Aggregator */
5989 if (aspath_count_hops (attr
->aspath
) == 0)
5990 vty_out (vty
, "Local");
5992 aspath_print_vty (vty
, "%s", attr
->aspath
, "");
5995 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5996 vty_out (vty
, ", (removed)");
5997 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5998 vty_out (vty
, ", (stale)");
5999 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
6000 vty_out (vty
, ", (aggregated by %u %s)",
6001 attr
->extra
->aggregator_as
,
6002 inet_ntoa (attr
->extra
->aggregator_addr
));
6003 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
6004 vty_out (vty
, ", (Received from a RR-client)");
6005 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
6006 vty_out (vty
, ", (Received from a RS-client)");
6007 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6008 vty_out (vty
, ", (history entry)");
6009 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6010 vty_out (vty
, ", (suppressed due to dampening)");
6011 vty_out (vty
, "%s", VTY_NEWLINE
);
6013 /* Line2 display Next-hop, Neighbor, Router-id */
6014 if (p
->family
== AF_INET
)
6016 vty_out (vty
, " %s", safi
== SAFI_MPLS_VPN
?
6017 inet_ntoa (attr
->extra
->mp_nexthop_global_in
) :
6018 inet_ntoa (attr
->nexthop
));
6023 assert (attr
->extra
);
6024 vty_out (vty
, " %s",
6025 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6026 buf
, INET6_ADDRSTRLEN
));
6028 #endif /* HAVE_IPV6 */
6030 if (binfo
->peer
== bgp
->peer_self
)
6032 vty_out (vty
, " from %s ",
6033 p
->family
== AF_INET
? "0.0.0.0" : "::");
6034 vty_out (vty
, "(%s)", inet_ntoa(bgp
->router_id
));
6038 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
6039 vty_out (vty
, " (inaccessible)");
6040 else if (binfo
->extra
&& binfo
->extra
->igpmetric
)
6041 vty_out (vty
, " (metric %d)", binfo
->extra
->igpmetric
);
6042 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6043 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
6044 vty_out (vty
, " (%s)", inet_ntoa (attr
->extra
->originator_id
));
6046 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
6048 vty_out (vty
, "%s", VTY_NEWLINE
);
6051 /* display nexthop local */
6052 if (attr
->extra
&& attr
->extra
->mp_nexthop_len
== 32)
6054 vty_out (vty
, " (%s)%s",
6055 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6056 buf
, INET6_ADDRSTRLEN
),
6059 #endif /* HAVE_IPV6 */
6061 /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */
6062 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
6064 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
6065 vty_out (vty
, ", metric %d", attr
->med
);
6067 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
6068 vty_out (vty
, ", localpref %d", attr
->local_pref
);
6070 vty_out (vty
, ", localpref %d", bgp
->default_local_pref
);
6072 if (attr
->extra
&& attr
->extra
->weight
!= 0)
6073 vty_out (vty
, ", weight %d", attr
->extra
->weight
);
6075 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6076 vty_out (vty
, ", valid");
6078 if (binfo
->peer
!= bgp
->peer_self
)
6080 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
6081 vty_out (vty
, ", internal");
6083 vty_out (vty
, ", %s",
6084 (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
) ? "confed-external" : "external"));
6086 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
6087 vty_out (vty
, ", aggregated, local");
6088 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
6089 vty_out (vty
, ", sourced");
6091 vty_out (vty
, ", sourced, local");
6093 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
6094 vty_out (vty
, ", atomic-aggregate");
6096 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
6097 vty_out (vty
, ", best");
6099 vty_out (vty
, "%s", VTY_NEWLINE
);
6101 /* Line 4 display Community */
6102 if (attr
->community
)
6103 vty_out (vty
, " Community: %s%s", attr
->community
->str
,
6106 /* Line 5 display Extended-community */
6107 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
6108 vty_out (vty
, " Extended Community: %s%s",
6109 attr
->extra
->ecommunity
->str
, VTY_NEWLINE
);
6111 /* Line 6 display Originator, Cluster-id */
6112 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
6113 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
6115 assert (attr
->extra
);
6116 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
6117 vty_out (vty
, " Originator: %s",
6118 inet_ntoa (attr
->extra
->originator_id
));
6120 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
6123 vty_out (vty
, ", Cluster list: ");
6124 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
6125 vty_out (vty
, "%s ",
6126 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
6128 vty_out (vty
, "%s", VTY_NEWLINE
);
6131 /* 7: AS Pathlimit */
6132 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_AS_PATHLIMIT
))
6135 vty_out (vty
, " AS-Pathlimit: %u",
6136 attr
->pathlimit
.ttl
);
6137 if (attr
->pathlimit
.as
)
6138 vty_out (vty
, " (%u)", attr
->pathlimit
.as
);
6139 vty_out (vty
, "%s", VTY_NEWLINE
);
6142 if (binfo
->extra
&& binfo
->extra
->damp_info
)
6143 bgp_damp_info_vty (vty
, binfo
);
6145 /* Line 7 display Uptime */
6146 vty_out (vty
, " Last update: %s", ctime (&binfo
->uptime
));
6148 vty_out (vty
, "%s", VTY_NEWLINE
);
6151 #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"
6152 #define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
6153 #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
6154 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
6155 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
6159 bgp_show_type_normal
,
6160 bgp_show_type_regexp
,
6161 bgp_show_type_prefix_list
,
6162 bgp_show_type_filter_list
,
6163 bgp_show_type_route_map
,
6164 bgp_show_type_neighbor
,
6165 bgp_show_type_cidr_only
,
6166 bgp_show_type_prefix_longer
,
6167 bgp_show_type_community_all
,
6168 bgp_show_type_community
,
6169 bgp_show_type_community_exact
,
6170 bgp_show_type_community_list
,
6171 bgp_show_type_community_list_exact
,
6172 bgp_show_type_flap_statistics
,
6173 bgp_show_type_flap_address
,
6174 bgp_show_type_flap_prefix
,
6175 bgp_show_type_flap_cidr_only
,
6176 bgp_show_type_flap_regexp
,
6177 bgp_show_type_flap_filter_list
,
6178 bgp_show_type_flap_prefix_list
,
6179 bgp_show_type_flap_prefix_longer
,
6180 bgp_show_type_flap_route_map
,
6181 bgp_show_type_flap_neighbor
,
6182 bgp_show_type_dampend_paths
,
6183 bgp_show_type_damp_neighbor
6187 bgp_show_table (struct vty
*vty
, struct bgp_table
*table
, struct in_addr
*router_id
,
6188 enum bgp_show_type type
, void *output_arg
)
6190 struct bgp_info
*ri
;
6191 struct bgp_node
*rn
;
6194 unsigned long output_count
;
6196 /* This is first entry point, so reset total line. */
6199 /* Start processing of routes. */
6200 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
6201 if (rn
->info
!= NULL
)
6205 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6207 if (type
== bgp_show_type_flap_statistics
6208 || type
== bgp_show_type_flap_address
6209 || type
== bgp_show_type_flap_prefix
6210 || type
== bgp_show_type_flap_cidr_only
6211 || type
== bgp_show_type_flap_regexp
6212 || type
== bgp_show_type_flap_filter_list
6213 || type
== bgp_show_type_flap_prefix_list
6214 || type
== bgp_show_type_flap_prefix_longer
6215 || type
== bgp_show_type_flap_route_map
6216 || type
== bgp_show_type_flap_neighbor
6217 || type
== bgp_show_type_dampend_paths
6218 || type
== bgp_show_type_damp_neighbor
)
6220 if (!(ri
->extra
&& ri
->extra
->damp_info
))
6223 if (type
== bgp_show_type_regexp
6224 || type
== bgp_show_type_flap_regexp
)
6226 regex_t
*regex
= output_arg
;
6228 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
6231 if (type
== bgp_show_type_prefix_list
6232 || type
== bgp_show_type_flap_prefix_list
)
6234 struct prefix_list
*plist
= output_arg
;
6236 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
6239 if (type
== bgp_show_type_filter_list
6240 || type
== bgp_show_type_flap_filter_list
)
6242 struct as_list
*as_list
= output_arg
;
6244 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
6247 if (type
== bgp_show_type_route_map
6248 || type
== bgp_show_type_flap_route_map
)
6250 struct route_map
*rmap
= output_arg
;
6251 struct bgp_info binfo
;
6252 struct attr dummy_attr
= { 0 };
6255 bgp_attr_dup (&dummy_attr
, ri
->attr
);
6256 binfo
.peer
= ri
->peer
;
6257 binfo
.attr
= &dummy_attr
;
6259 ret
= route_map_apply (rmap
, &rn
->p
, RMAP_BGP
, &binfo
);
6261 bgp_attr_extra_free (&dummy_attr
);
6263 if (ret
== RMAP_DENYMATCH
)
6266 if (type
== bgp_show_type_neighbor
6267 || type
== bgp_show_type_flap_neighbor
6268 || type
== bgp_show_type_damp_neighbor
)
6270 union sockunion
*su
= output_arg
;
6272 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
6275 if (type
== bgp_show_type_cidr_only
6276 || type
== bgp_show_type_flap_cidr_only
)
6278 u_int32_t destination
;
6280 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
6281 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
6283 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
6285 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
6288 if (type
== bgp_show_type_prefix_longer
6289 || type
== bgp_show_type_flap_prefix_longer
)
6291 struct prefix
*p
= output_arg
;
6293 if (! prefix_match (p
, &rn
->p
))
6296 if (type
== bgp_show_type_community_all
)
6298 if (! ri
->attr
->community
)
6301 if (type
== bgp_show_type_community
)
6303 struct community
*com
= output_arg
;
6305 if (! ri
->attr
->community
||
6306 ! community_match (ri
->attr
->community
, com
))
6309 if (type
== bgp_show_type_community_exact
)
6311 struct community
*com
= output_arg
;
6313 if (! ri
->attr
->community
||
6314 ! community_cmp (ri
->attr
->community
, com
))
6317 if (type
== bgp_show_type_community_list
)
6319 struct community_list
*list
= output_arg
;
6321 if (! community_list_match (ri
->attr
->community
, list
))
6324 if (type
== bgp_show_type_community_list_exact
)
6326 struct community_list
*list
= output_arg
;
6328 if (! community_list_exact_match (ri
->attr
->community
, list
))
6331 if (type
== bgp_show_type_flap_address
6332 || type
== bgp_show_type_flap_prefix
)
6334 struct prefix
*p
= output_arg
;
6336 if (! prefix_match (&rn
->p
, p
))
6339 if (type
== bgp_show_type_flap_prefix
)
6340 if (p
->prefixlen
!= rn
->p
.prefixlen
)
6343 if (type
== bgp_show_type_dampend_paths
6344 || type
== bgp_show_type_damp_neighbor
)
6346 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
)
6347 || CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
6353 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id
), VTY_NEWLINE
);
6354 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
6355 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
6356 if (type
== bgp_show_type_dampend_paths
6357 || type
== bgp_show_type_damp_neighbor
)
6358 vty_out (vty
, BGP_SHOW_DAMP_HEADER
, VTY_NEWLINE
);
6359 else if (type
== bgp_show_type_flap_statistics
6360 || type
== bgp_show_type_flap_address
6361 || type
== bgp_show_type_flap_prefix
6362 || type
== bgp_show_type_flap_cidr_only
6363 || type
== bgp_show_type_flap_regexp
6364 || type
== bgp_show_type_flap_filter_list
6365 || type
== bgp_show_type_flap_prefix_list
6366 || type
== bgp_show_type_flap_prefix_longer
6367 || type
== bgp_show_type_flap_route_map
6368 || type
== bgp_show_type_flap_neighbor
)
6369 vty_out (vty
, BGP_SHOW_FLAP_HEADER
, VTY_NEWLINE
);
6371 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
6375 if (type
== bgp_show_type_dampend_paths
6376 || type
== bgp_show_type_damp_neighbor
)
6377 damp_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6378 else if (type
== bgp_show_type_flap_statistics
6379 || type
== bgp_show_type_flap_address
6380 || type
== bgp_show_type_flap_prefix
6381 || type
== bgp_show_type_flap_cidr_only
6382 || type
== bgp_show_type_flap_regexp
6383 || type
== bgp_show_type_flap_filter_list
6384 || type
== bgp_show_type_flap_prefix_list
6385 || type
== bgp_show_type_flap_prefix_longer
6386 || type
== bgp_show_type_flap_route_map
6387 || type
== bgp_show_type_flap_neighbor
)
6388 flap_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6390 route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6397 /* No route is displayed */
6398 if (output_count
== 0)
6400 if (type
== bgp_show_type_normal
)
6401 vty_out (vty
, "No BGP network exists%s", VTY_NEWLINE
);
6404 vty_out (vty
, "%sTotal number of prefixes %ld%s",
6405 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
6411 bgp_show (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
6412 enum bgp_show_type type
, void *output_arg
)
6414 struct bgp_table
*table
;
6417 bgp
= bgp_get_default ();
6422 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
6427 table
= bgp
->rib
[afi
][safi
];
6429 return bgp_show_table (vty
, table
, &bgp
->router_id
, type
, output_arg
);
6432 /* Header of detailed BGP route information */
6434 route_vty_out_detail_header (struct vty
*vty
, struct bgp
*bgp
,
6435 struct bgp_node
*rn
,
6436 struct prefix_rd
*prd
, afi_t afi
, safi_t safi
)
6438 struct bgp_info
*ri
;
6441 struct listnode
*node
, *nnode
;
6442 char buf1
[INET6_ADDRSTRLEN
];
6443 char buf2
[INET6_ADDRSTRLEN
];
6448 int no_advertise
= 0;
6453 vty_out (vty
, "BGP routing table entry for %s%s%s/%d%s",
6454 (safi
== SAFI_MPLS_VPN
?
6455 prefix_rd2str (prd
, buf1
, RD_ADDRSTRLEN
) : ""),
6456 safi
== SAFI_MPLS_VPN
? ":" : "",
6457 inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
),
6458 p
->prefixlen
, VTY_NEWLINE
);
6460 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6463 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
6466 if (ri
->extra
&& ri
->extra
->suppress
)
6468 if (ri
->attr
->community
!= NULL
)
6470 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
6472 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
6474 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
6480 vty_out (vty
, "Paths: (%d available", count
);
6483 vty_out (vty
, ", best #%d", best
);
6484 if (safi
== SAFI_UNICAST
)
6485 vty_out (vty
, ", table Default-IP-Routing-Table");
6488 vty_out (vty
, ", no best path");
6490 vty_out (vty
, ", not advertised to any peer");
6492 vty_out (vty
, ", not advertised to EBGP peer");
6494 vty_out (vty
, ", not advertised outside local AS");
6496 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
6497 vty_out (vty
, ")%s", VTY_NEWLINE
);
6499 /* advertised peer */
6500 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
6502 if (bgp_adj_out_lookup (peer
, p
, afi
, safi
, rn
))
6505 vty_out (vty
, " Advertised to non peer-group peers:%s ", VTY_NEWLINE
);
6506 vty_out (vty
, " %s", sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6511 vty_out (vty
, " Not advertised to any peer");
6512 vty_out (vty
, "%s", VTY_NEWLINE
);
6515 /* Display specified route of BGP table. */
6517 bgp_show_route_in_table (struct vty
*vty
, struct bgp
*bgp
,
6518 struct bgp_table
*rib
, const char *ip_str
,
6519 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
6525 struct prefix match
;
6526 struct bgp_node
*rn
;
6527 struct bgp_node
*rm
;
6528 struct bgp_info
*ri
;
6529 struct bgp_table
*table
;
6531 /* Check IP address argument. */
6532 ret
= str2prefix (ip_str
, &match
);
6535 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
6539 match
.family
= afi2family (afi
);
6541 if (safi
== SAFI_MPLS_VPN
)
6543 for (rn
= bgp_table_top (rib
); rn
; rn
= bgp_route_next (rn
))
6545 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
6548 if ((table
= rn
->info
) != NULL
)
6552 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
6554 if (prefix_check
&& rm
->p
.prefixlen
!= match
.prefixlen
)
6557 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
6561 route_vty_out_detail_header (vty
, bgp
, rm
, (struct prefix_rd
*)&rn
->p
,
6562 AFI_IP
, SAFI_MPLS_VPN
);
6567 route_vty_out_detail (vty
, bgp
, &rm
->p
, ri
, AFI_IP
, SAFI_MPLS_VPN
);
6577 if ((rn
= bgp_node_match (rib
, &match
)) != NULL
)
6579 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
6581 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6585 route_vty_out_detail_header (vty
, bgp
, rn
, NULL
, afi
, safi
);
6589 route_vty_out_detail (vty
, bgp
, &rn
->p
, ri
, afi
, safi
);
6597 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
6604 /* Display specified route of Main RIB */
6606 bgp_show_route (struct vty
*vty
, const char *view_name
, const char *ip_str
,
6607 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
6612 /* BGP structure lookup. */
6615 bgp
= bgp_lookup_by_name (view_name
);
6618 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
6624 bgp
= bgp_get_default ();
6627 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
6632 return bgp_show_route_in_table (vty
, bgp
, bgp
->rib
[afi
][safi
], ip_str
,
6633 afi
, safi
, prd
, prefix_check
);
6636 /* BGP route print out function. */
6644 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6647 DEFUN (show_ip_bgp_ipv4
,
6648 show_ip_bgp_ipv4_cmd
,
6649 "show ip bgp ipv4 (unicast|multicast)",
6654 "Address Family modifier\n"
6655 "Address Family modifier\n")
6657 if (strncmp (argv
[0], "m", 1) == 0)
6658 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
, bgp_show_type_normal
,
6661 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6664 DEFUN (show_ip_bgp_route
,
6665 show_ip_bgp_route_cmd
,
6666 "show ip bgp A.B.C.D",
6670 "Network in the BGP routing table to display\n")
6672 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6675 DEFUN (show_ip_bgp_ipv4_route
,
6676 show_ip_bgp_ipv4_route_cmd
,
6677 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
6682 "Address Family modifier\n"
6683 "Address Family modifier\n"
6684 "Network in the BGP routing table to display\n")
6686 if (strncmp (argv
[0], "m", 1) == 0)
6687 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0);
6689 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6692 DEFUN (show_ip_bgp_vpnv4_all_route
,
6693 show_ip_bgp_vpnv4_all_route_cmd
,
6694 "show ip bgp vpnv4 all A.B.C.D",
6698 "Display VPNv4 NLRI specific information\n"
6699 "Display information about all VPNv4 NLRIs\n"
6700 "Network in the BGP routing table to display\n")
6702 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 0);
6705 DEFUN (show_ip_bgp_vpnv4_rd_route
,
6706 show_ip_bgp_vpnv4_rd_route_cmd
,
6707 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
6711 "Display VPNv4 NLRI specific information\n"
6712 "Display information for a route distinguisher\n"
6713 "VPN Route Distinguisher\n"
6714 "Network in the BGP routing table to display\n")
6717 struct prefix_rd prd
;
6719 ret
= str2prefix_rd (argv
[0], &prd
);
6722 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
6725 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0);
6728 DEFUN (show_ip_bgp_prefix
,
6729 show_ip_bgp_prefix_cmd
,
6730 "show ip bgp A.B.C.D/M",
6734 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6736 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6739 DEFUN (show_ip_bgp_ipv4_prefix
,
6740 show_ip_bgp_ipv4_prefix_cmd
,
6741 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
6746 "Address Family modifier\n"
6747 "Address Family modifier\n"
6748 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6750 if (strncmp (argv
[0], "m", 1) == 0)
6751 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1);
6753 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6756 DEFUN (show_ip_bgp_vpnv4_all_prefix
,
6757 show_ip_bgp_vpnv4_all_prefix_cmd
,
6758 "show ip bgp vpnv4 all A.B.C.D/M",
6762 "Display VPNv4 NLRI specific information\n"
6763 "Display information about all VPNv4 NLRIs\n"
6764 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6766 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 1);
6769 DEFUN (show_ip_bgp_vpnv4_rd_prefix
,
6770 show_ip_bgp_vpnv4_rd_prefix_cmd
,
6771 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
6775 "Display VPNv4 NLRI specific information\n"
6776 "Display information for a route distinguisher\n"
6777 "VPN Route Distinguisher\n"
6778 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6781 struct prefix_rd prd
;
6783 ret
= str2prefix_rd (argv
[0], &prd
);
6786 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
6789 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 1);
6792 DEFUN (show_ip_bgp_view
,
6793 show_ip_bgp_view_cmd
,
6794 "show ip bgp view WORD",
6803 /* BGP structure lookup. */
6804 bgp
= bgp_lookup_by_name (argv
[0]);
6807 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
6811 return bgp_show (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6814 DEFUN (show_ip_bgp_view_route
,
6815 show_ip_bgp_view_route_cmd
,
6816 "show ip bgp view WORD A.B.C.D",
6822 "Network in the BGP routing table to display\n")
6824 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6827 DEFUN (show_ip_bgp_view_prefix
,
6828 show_ip_bgp_view_prefix_cmd
,
6829 "show ip bgp view WORD A.B.C.D/M",
6835 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6837 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6847 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
6859 DEFUN (show_ipv6_bgp
,
6866 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
6870 DEFUN (show_bgp_route
,
6872 "show bgp X:X::X:X",
6875 "Network in the BGP routing table to display\n")
6877 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6880 ALIAS (show_bgp_route
,
6881 show_bgp_ipv6_route_cmd
,
6882 "show bgp ipv6 X:X::X:X",
6886 "Network in the BGP routing table to display\n")
6889 DEFUN (show_ipv6_bgp_route
,
6890 show_ipv6_bgp_route_cmd
,
6891 "show ipv6 bgp X:X::X:X",
6895 "Network in the BGP routing table to display\n")
6897 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6900 DEFUN (show_bgp_prefix
,
6901 show_bgp_prefix_cmd
,
6902 "show bgp X:X::X:X/M",
6905 "IPv6 prefix <network>/<length>\n")
6907 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6910 ALIAS (show_bgp_prefix
,
6911 show_bgp_ipv6_prefix_cmd
,
6912 "show bgp ipv6 X:X::X:X/M",
6916 "IPv6 prefix <network>/<length>\n")
6919 DEFUN (show_ipv6_bgp_prefix
,
6920 show_ipv6_bgp_prefix_cmd
,
6921 "show ipv6 bgp X:X::X:X/M",
6925 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6927 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6930 DEFUN (show_bgp_view
,
6932 "show bgp view WORD",
6940 /* BGP structure lookup. */
6941 bgp
= bgp_lookup_by_name (argv
[0]);
6944 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
6948 return bgp_show (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6951 ALIAS (show_bgp_view
,
6952 show_bgp_view_ipv6_cmd
,
6953 "show bgp view WORD ipv6",
6960 DEFUN (show_bgp_view_route
,
6961 show_bgp_view_route_cmd
,
6962 "show bgp view WORD X:X::X:X",
6967 "Network in the BGP routing table to display\n")
6969 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6972 ALIAS (show_bgp_view_route
,
6973 show_bgp_view_ipv6_route_cmd
,
6974 "show bgp view WORD ipv6 X:X::X:X",
6980 "Network in the BGP routing table to display\n")
6982 DEFUN (show_bgp_view_prefix
,
6983 show_bgp_view_prefix_cmd
,
6984 "show bgp view WORD X:X::X:X/M",
6989 "IPv6 prefix <network>/<length>\n")
6991 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6994 ALIAS (show_bgp_view_prefix
,
6995 show_bgp_view_ipv6_prefix_cmd
,
6996 "show bgp view WORD ipv6 X:X::X:X/M",
7002 "IPv6 prefix <network>/<length>\n")
7005 DEFUN (show_ipv6_mbgp
,
7012 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
7017 DEFUN (show_ipv6_mbgp_route
,
7018 show_ipv6_mbgp_route_cmd
,
7019 "show ipv6 mbgp X:X::X:X",
7023 "Network in the MBGP routing table to display\n")
7025 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0);
7029 DEFUN (show_ipv6_mbgp_prefix
,
7030 show_ipv6_mbgp_prefix_cmd
,
7031 "show ipv6 mbgp X:X::X:X/M",
7035 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7037 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1);
7043 bgp_show_regexp (struct vty
*vty
, int argc
, const char **argv
, afi_t afi
,
7044 safi_t safi
, enum bgp_show_type type
)
7054 b
= buffer_new (1024);
7055 for (i
= 0; i
< argc
; i
++)
7058 buffer_putc (b
, ' ');
7061 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
7066 buffer_putstr (b
, argv
[i
]);
7068 buffer_putc (b
, '\0');
7070 regstr
= buffer_getstr (b
);
7073 regex
= bgp_regcomp (regstr
);
7074 XFREE(MTYPE_TMP
, regstr
);
7077 vty_out (vty
, "Can't compile regexp %s%s", argv
[0],
7082 rc
= bgp_show (vty
, NULL
, afi
, safi
, type
, regex
);
7083 bgp_regex_free (regex
);
7087 DEFUN (show_ip_bgp_regexp
,
7088 show_ip_bgp_regexp_cmd
,
7089 "show ip bgp regexp .LINE",
7093 "Display routes matching the AS path regular expression\n"
7094 "A regular-expression to match the BGP AS paths\n")
7096 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
7097 bgp_show_type_regexp
);
7100 DEFUN (show_ip_bgp_flap_regexp
,
7101 show_ip_bgp_flap_regexp_cmd
,
7102 "show ip bgp flap-statistics regexp .LINE",
7106 "Display flap statistics of routes\n"
7107 "Display routes matching the AS path regular expression\n"
7108 "A regular-expression to match the BGP AS paths\n")
7110 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
7111 bgp_show_type_flap_regexp
);
7114 DEFUN (show_ip_bgp_ipv4_regexp
,
7115 show_ip_bgp_ipv4_regexp_cmd
,
7116 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
7121 "Address Family modifier\n"
7122 "Address Family modifier\n"
7123 "Display routes matching the AS path regular expression\n"
7124 "A regular-expression to match the BGP AS paths\n")
7126 if (strncmp (argv
[0], "m", 1) == 0)
7127 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_MULTICAST
,
7128 bgp_show_type_regexp
);
7130 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
7131 bgp_show_type_regexp
);
7135 DEFUN (show_bgp_regexp
,
7136 show_bgp_regexp_cmd
,
7137 "show bgp regexp .LINE",
7140 "Display routes matching the AS path regular expression\n"
7141 "A regular-expression to match the BGP AS paths\n")
7143 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
7144 bgp_show_type_regexp
);
7147 ALIAS (show_bgp_regexp
,
7148 show_bgp_ipv6_regexp_cmd
,
7149 "show bgp ipv6 regexp .LINE",
7153 "Display routes matching the AS path regular expression\n"
7154 "A regular-expression to match the BGP AS paths\n")
7157 DEFUN (show_ipv6_bgp_regexp
,
7158 show_ipv6_bgp_regexp_cmd
,
7159 "show ipv6 bgp regexp .LINE",
7163 "Display routes matching the AS path regular expression\n"
7164 "A regular-expression to match the BGP AS paths\n")
7166 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
7167 bgp_show_type_regexp
);
7171 DEFUN (show_ipv6_mbgp_regexp
,
7172 show_ipv6_mbgp_regexp_cmd
,
7173 "show ipv6 mbgp regexp .LINE",
7177 "Display routes matching the AS path regular expression\n"
7178 "A regular-expression to match the MBGP AS paths\n")
7180 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
,
7181 bgp_show_type_regexp
);
7183 #endif /* HAVE_IPV6 */
7186 bgp_show_prefix_list (struct vty
*vty
, const char *prefix_list_str
, afi_t afi
,
7187 safi_t safi
, enum bgp_show_type type
)
7189 struct prefix_list
*plist
;
7191 plist
= prefix_list_lookup (afi
, prefix_list_str
);
7194 vty_out (vty
, "%% %s is not a valid prefix-list name%s",
7195 prefix_list_str
, VTY_NEWLINE
);
7199 return bgp_show (vty
, NULL
, afi
, safi
, type
, plist
);
7202 DEFUN (show_ip_bgp_prefix_list
,
7203 show_ip_bgp_prefix_list_cmd
,
7204 "show ip bgp prefix-list WORD",
7208 "Display routes conforming to the prefix-list\n"
7209 "IP prefix-list name\n")
7211 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7212 bgp_show_type_prefix_list
);
7215 DEFUN (show_ip_bgp_flap_prefix_list
,
7216 show_ip_bgp_flap_prefix_list_cmd
,
7217 "show ip bgp flap-statistics prefix-list WORD",
7221 "Display flap statistics of routes\n"
7222 "Display routes conforming to the prefix-list\n"
7223 "IP prefix-list name\n")
7225 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7226 bgp_show_type_flap_prefix_list
);
7229 DEFUN (show_ip_bgp_ipv4_prefix_list
,
7230 show_ip_bgp_ipv4_prefix_list_cmd
,
7231 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
7236 "Address Family modifier\n"
7237 "Address Family modifier\n"
7238 "Display routes conforming to the prefix-list\n"
7239 "IP prefix-list name\n")
7241 if (strncmp (argv
[0], "m", 1) == 0)
7242 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
7243 bgp_show_type_prefix_list
);
7245 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
7246 bgp_show_type_prefix_list
);
7250 DEFUN (show_bgp_prefix_list
,
7251 show_bgp_prefix_list_cmd
,
7252 "show bgp prefix-list WORD",
7255 "Display routes conforming to the prefix-list\n"
7256 "IPv6 prefix-list name\n")
7258 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7259 bgp_show_type_prefix_list
);
7262 ALIAS (show_bgp_prefix_list
,
7263 show_bgp_ipv6_prefix_list_cmd
,
7264 "show bgp ipv6 prefix-list WORD",
7268 "Display routes conforming to the prefix-list\n"
7269 "IPv6 prefix-list name\n")
7272 DEFUN (show_ipv6_bgp_prefix_list
,
7273 show_ipv6_bgp_prefix_list_cmd
,
7274 "show ipv6 bgp prefix-list WORD",
7278 "Display routes matching the prefix-list\n"
7279 "IPv6 prefix-list name\n")
7281 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7282 bgp_show_type_prefix_list
);
7286 DEFUN (show_ipv6_mbgp_prefix_list
,
7287 show_ipv6_mbgp_prefix_list_cmd
,
7288 "show ipv6 mbgp prefix-list WORD",
7292 "Display routes matching the prefix-list\n"
7293 "IPv6 prefix-list name\n")
7295 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
7296 bgp_show_type_prefix_list
);
7298 #endif /* HAVE_IPV6 */
7301 bgp_show_filter_list (struct vty
*vty
, const char *filter
, afi_t afi
,
7302 safi_t safi
, enum bgp_show_type type
)
7304 struct as_list
*as_list
;
7306 as_list
= as_list_lookup (filter
);
7307 if (as_list
== NULL
)
7309 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
7313 return bgp_show (vty
, NULL
, afi
, safi
, type
, as_list
);
7316 DEFUN (show_ip_bgp_filter_list
,
7317 show_ip_bgp_filter_list_cmd
,
7318 "show ip bgp filter-list WORD",
7322 "Display routes conforming to the filter-list\n"
7323 "Regular expression access list name\n")
7325 return bgp_show_filter_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7326 bgp_show_type_filter_list
);
7329 DEFUN (show_ip_bgp_flap_filter_list
,
7330 show_ip_bgp_flap_filter_list_cmd
,
7331 "show ip bgp flap-statistics filter-list WORD",
7335 "Display flap statistics of routes\n"
7336 "Display routes conforming to the filter-list\n"
7337 "Regular expression access list name\n")
7339 return bgp_show_filter_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7340 bgp_show_type_flap_filter_list
);
7343 DEFUN (show_ip_bgp_ipv4_filter_list
,
7344 show_ip_bgp_ipv4_filter_list_cmd
,
7345 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
7350 "Address Family modifier\n"
7351 "Address Family modifier\n"
7352 "Display routes conforming to the filter-list\n"
7353 "Regular expression access list name\n")
7355 if (strncmp (argv
[0], "m", 1) == 0)
7356 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
7357 bgp_show_type_filter_list
);
7359 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
7360 bgp_show_type_filter_list
);
7364 DEFUN (show_bgp_filter_list
,
7365 show_bgp_filter_list_cmd
,
7366 "show bgp filter-list WORD",
7369 "Display routes conforming to the filter-list\n"
7370 "Regular expression access list name\n")
7372 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7373 bgp_show_type_filter_list
);
7376 ALIAS (show_bgp_filter_list
,
7377 show_bgp_ipv6_filter_list_cmd
,
7378 "show bgp ipv6 filter-list WORD",
7382 "Display routes conforming to the filter-list\n"
7383 "Regular expression access list name\n")
7386 DEFUN (show_ipv6_bgp_filter_list
,
7387 show_ipv6_bgp_filter_list_cmd
,
7388 "show ipv6 bgp filter-list WORD",
7392 "Display routes conforming to the filter-list\n"
7393 "Regular expression access list name\n")
7395 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7396 bgp_show_type_filter_list
);
7400 DEFUN (show_ipv6_mbgp_filter_list
,
7401 show_ipv6_mbgp_filter_list_cmd
,
7402 "show ipv6 mbgp filter-list WORD",
7406 "Display routes conforming to the filter-list\n"
7407 "Regular expression access list name\n")
7409 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
7410 bgp_show_type_filter_list
);
7412 #endif /* HAVE_IPV6 */
7415 bgp_show_route_map (struct vty
*vty
, const char *rmap_str
, afi_t afi
,
7416 safi_t safi
, enum bgp_show_type type
)
7418 struct route_map
*rmap
;
7420 rmap
= route_map_lookup_by_name (rmap_str
);
7423 vty_out (vty
, "%% %s is not a valid route-map name%s",
7424 rmap_str
, VTY_NEWLINE
);
7428 return bgp_show (vty
, NULL
, afi
, safi
, type
, rmap
);
7431 DEFUN (show_ip_bgp_route_map
,
7432 show_ip_bgp_route_map_cmd
,
7433 "show ip bgp route-map WORD",
7437 "Display routes matching the route-map\n"
7438 "A route-map to match on\n")
7440 return bgp_show_route_map (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7441 bgp_show_type_route_map
);
7444 DEFUN (show_ip_bgp_flap_route_map
,
7445 show_ip_bgp_flap_route_map_cmd
,
7446 "show ip bgp flap-statistics route-map WORD",
7450 "Display flap statistics of routes\n"
7451 "Display routes matching the route-map\n"
7452 "A route-map to match on\n")
7454 return bgp_show_route_map (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7455 bgp_show_type_flap_route_map
);
7458 DEFUN (show_ip_bgp_ipv4_route_map
,
7459 show_ip_bgp_ipv4_route_map_cmd
,
7460 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
7465 "Address Family modifier\n"
7466 "Address Family modifier\n"
7467 "Display routes matching the route-map\n"
7468 "A route-map to match on\n")
7470 if (strncmp (argv
[0], "m", 1) == 0)
7471 return bgp_show_route_map (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
7472 bgp_show_type_route_map
);
7474 return bgp_show_route_map (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
7475 bgp_show_type_route_map
);
7478 DEFUN (show_bgp_route_map
,
7479 show_bgp_route_map_cmd
,
7480 "show bgp route-map WORD",
7483 "Display routes matching the route-map\n"
7484 "A route-map to match on\n")
7486 return bgp_show_route_map (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7487 bgp_show_type_route_map
);
7490 ALIAS (show_bgp_route_map
,
7491 show_bgp_ipv6_route_map_cmd
,
7492 "show bgp ipv6 route-map WORD",
7496 "Display routes matching the route-map\n"
7497 "A route-map to match on\n")
7499 DEFUN (show_ip_bgp_cidr_only
,
7500 show_ip_bgp_cidr_only_cmd
,
7501 "show ip bgp cidr-only",
7505 "Display only routes with non-natural netmasks\n")
7507 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7508 bgp_show_type_cidr_only
, NULL
);
7511 DEFUN (show_ip_bgp_flap_cidr_only
,
7512 show_ip_bgp_flap_cidr_only_cmd
,
7513 "show ip bgp flap-statistics cidr-only",
7517 "Display flap statistics of routes\n"
7518 "Display only routes with non-natural netmasks\n")
7520 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7521 bgp_show_type_flap_cidr_only
, NULL
);
7524 DEFUN (show_ip_bgp_ipv4_cidr_only
,
7525 show_ip_bgp_ipv4_cidr_only_cmd
,
7526 "show ip bgp ipv4 (unicast|multicast) cidr-only",
7531 "Address Family modifier\n"
7532 "Address Family modifier\n"
7533 "Display only routes with non-natural netmasks\n")
7535 if (strncmp (argv
[0], "m", 1) == 0)
7536 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
7537 bgp_show_type_cidr_only
, NULL
);
7539 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7540 bgp_show_type_cidr_only
, NULL
);
7543 DEFUN (show_ip_bgp_community_all
,
7544 show_ip_bgp_community_all_cmd
,
7545 "show ip bgp community",
7549 "Display routes matching the communities\n")
7551 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7552 bgp_show_type_community_all
, NULL
);
7555 DEFUN (show_ip_bgp_ipv4_community_all
,
7556 show_ip_bgp_ipv4_community_all_cmd
,
7557 "show ip bgp ipv4 (unicast|multicast) community",
7562 "Address Family modifier\n"
7563 "Address Family modifier\n"
7564 "Display routes matching the communities\n")
7566 if (strncmp (argv
[0], "m", 1) == 0)
7567 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
7568 bgp_show_type_community_all
, NULL
);
7570 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7571 bgp_show_type_community_all
, NULL
);
7575 DEFUN (show_bgp_community_all
,
7576 show_bgp_community_all_cmd
,
7577 "show bgp community",
7580 "Display routes matching the communities\n")
7582 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
7583 bgp_show_type_community_all
, NULL
);
7586 ALIAS (show_bgp_community_all
,
7587 show_bgp_ipv6_community_all_cmd
,
7588 "show bgp ipv6 community",
7592 "Display routes matching the communities\n")
7595 DEFUN (show_ipv6_bgp_community_all
,
7596 show_ipv6_bgp_community_all_cmd
,
7597 "show ipv6 bgp community",
7601 "Display routes matching the communities\n")
7603 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
7604 bgp_show_type_community_all
, NULL
);
7608 DEFUN (show_ipv6_mbgp_community_all
,
7609 show_ipv6_mbgp_community_all_cmd
,
7610 "show ipv6 mbgp community",
7614 "Display routes matching the communities\n")
7616 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
7617 bgp_show_type_community_all
, NULL
);
7619 #endif /* HAVE_IPV6 */
7622 bgp_show_community (struct vty
*vty
, int argc
, const char **argv
, int exact
,
7623 u_int16_t afi
, u_char safi
)
7625 struct community
*com
;
7631 b
= buffer_new (1024);
7632 for (i
= 0; i
< argc
; i
++)
7635 buffer_putc (b
, ' ');
7638 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
7643 buffer_putstr (b
, argv
[i
]);
7645 buffer_putc (b
, '\0');
7647 str
= buffer_getstr (b
);
7650 com
= community_str2com (str
);
7651 XFREE (MTYPE_TMP
, str
);
7654 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
7658 return bgp_show (vty
, NULL
, afi
, safi
,
7659 (exact
? bgp_show_type_community_exact
:
7660 bgp_show_type_community
), com
);
7663 DEFUN (show_ip_bgp_community
,
7664 show_ip_bgp_community_cmd
,
7665 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
7669 "Display routes matching the communities\n"
7670 "community number\n"
7671 "Do not send outside local AS (well-known community)\n"
7672 "Do not advertise to any peer (well-known community)\n"
7673 "Do not export to next AS (well-known community)\n")
7675 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
7678 ALIAS (show_ip_bgp_community
,
7679 show_ip_bgp_community2_cmd
,
7680 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7684 "Display routes matching the communities\n"
7685 "community number\n"
7686 "Do not send outside local AS (well-known community)\n"
7687 "Do not advertise to any peer (well-known community)\n"
7688 "Do not export to next AS (well-known community)\n"
7689 "community number\n"
7690 "Do not send outside local AS (well-known community)\n"
7691 "Do not advertise to any peer (well-known community)\n"
7692 "Do not export to next AS (well-known community)\n")
7694 ALIAS (show_ip_bgp_community
,
7695 show_ip_bgp_community3_cmd
,
7696 "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)",
7700 "Display routes matching the communities\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"
7705 "community number\n"
7706 "Do not send outside local AS (well-known community)\n"
7707 "Do not advertise to any peer (well-known community)\n"
7708 "Do not export to next AS (well-known community)\n"
7709 "community number\n"
7710 "Do not send outside local AS (well-known community)\n"
7711 "Do not advertise to any peer (well-known community)\n"
7712 "Do not export to next AS (well-known community)\n")
7714 ALIAS (show_ip_bgp_community
,
7715 show_ip_bgp_community4_cmd
,
7716 "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)",
7720 "Display routes matching the communities\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"
7725 "community number\n"
7726 "Do not send outside local AS (well-known community)\n"
7727 "Do not advertise to any peer (well-known community)\n"
7728 "Do not export to next AS (well-known community)\n"
7729 "community number\n"
7730 "Do not send outside local AS (well-known community)\n"
7731 "Do not advertise to any peer (well-known community)\n"
7732 "Do not export to next AS (well-known community)\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")
7738 DEFUN (show_ip_bgp_ipv4_community
,
7739 show_ip_bgp_ipv4_community_cmd
,
7740 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
7745 "Address Family modifier\n"
7746 "Address Family modifier\n"
7747 "Display routes matching the communities\n"
7748 "community number\n"
7749 "Do not send outside local AS (well-known community)\n"
7750 "Do not advertise to any peer (well-known community)\n"
7751 "Do not export to next AS (well-known community)\n")
7753 if (strncmp (argv
[0], "m", 1) == 0)
7754 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_MULTICAST
);
7756 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
7759 ALIAS (show_ip_bgp_ipv4_community
,
7760 show_ip_bgp_ipv4_community2_cmd
,
7761 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7766 "Address Family modifier\n"
7767 "Address Family modifier\n"
7768 "Display routes matching the communities\n"
7769 "community number\n"
7770 "Do not send outside local AS (well-known community)\n"
7771 "Do not advertise to any peer (well-known community)\n"
7772 "Do not export to next AS (well-known community)\n"
7773 "community number\n"
7774 "Do not send outside local AS (well-known community)\n"
7775 "Do not advertise to any peer (well-known community)\n"
7776 "Do not export to next AS (well-known community)\n")
7778 ALIAS (show_ip_bgp_ipv4_community
,
7779 show_ip_bgp_ipv4_community3_cmd
,
7780 "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)",
7785 "Address Family modifier\n"
7786 "Address Family modifier\n"
7787 "Display routes matching the communities\n"
7788 "community number\n"
7789 "Do not send outside local AS (well-known community)\n"
7790 "Do not advertise to any peer (well-known community)\n"
7791 "Do not export to next AS (well-known community)\n"
7792 "community number\n"
7793 "Do not send outside local AS (well-known community)\n"
7794 "Do not advertise to any peer (well-known community)\n"
7795 "Do not export to next AS (well-known community)\n"
7796 "community number\n"
7797 "Do not send outside local AS (well-known community)\n"
7798 "Do not advertise to any peer (well-known community)\n"
7799 "Do not export to next AS (well-known community)\n")
7801 ALIAS (show_ip_bgp_ipv4_community
,
7802 show_ip_bgp_ipv4_community4_cmd
,
7803 "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)",
7808 "Address Family modifier\n"
7809 "Address Family modifier\n"
7810 "Display routes matching the communities\n"
7811 "community number\n"
7812 "Do not send outside local AS (well-known community)\n"
7813 "Do not advertise to any peer (well-known community)\n"
7814 "Do not export to next AS (well-known community)\n"
7815 "community number\n"
7816 "Do not send outside local AS (well-known community)\n"
7817 "Do not advertise to any peer (well-known community)\n"
7818 "Do not export to next AS (well-known community)\n"
7819 "community number\n"
7820 "Do not send outside local AS (well-known community)\n"
7821 "Do not advertise to any peer (well-known community)\n"
7822 "Do not export to next AS (well-known community)\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")
7828 DEFUN (show_ip_bgp_community_exact
,
7829 show_ip_bgp_community_exact_cmd
,
7830 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7834 "Display routes matching the communities\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"
7839 "Exact match of the communities")
7841 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
7844 ALIAS (show_ip_bgp_community_exact
,
7845 show_ip_bgp_community2_exact_cmd
,
7846 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7850 "Display routes matching the communities\n"
7851 "community number\n"
7852 "Do not send outside local AS (well-known community)\n"
7853 "Do not advertise to any peer (well-known community)\n"
7854 "Do not export to next AS (well-known community)\n"
7855 "community number\n"
7856 "Do not send outside local AS (well-known community)\n"
7857 "Do not advertise to any peer (well-known community)\n"
7858 "Do not export to next AS (well-known community)\n"
7859 "Exact match of the communities")
7861 ALIAS (show_ip_bgp_community_exact
,
7862 show_ip_bgp_community3_exact_cmd
,
7863 "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",
7867 "Display routes matching the communities\n"
7868 "community number\n"
7869 "Do not send outside local AS (well-known community)\n"
7870 "Do not advertise to any peer (well-known community)\n"
7871 "Do not export to next AS (well-known community)\n"
7872 "community number\n"
7873 "Do not send outside local AS (well-known community)\n"
7874 "Do not advertise to any peer (well-known community)\n"
7875 "Do not export to next AS (well-known community)\n"
7876 "community number\n"
7877 "Do not send outside local AS (well-known community)\n"
7878 "Do not advertise to any peer (well-known community)\n"
7879 "Do not export to next AS (well-known community)\n"
7880 "Exact match of the communities")
7882 ALIAS (show_ip_bgp_community_exact
,
7883 show_ip_bgp_community4_exact_cmd
,
7884 "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",
7888 "Display routes matching the communities\n"
7889 "community number\n"
7890 "Do not send outside local AS (well-known community)\n"
7891 "Do not advertise to any peer (well-known community)\n"
7892 "Do not export to next AS (well-known community)\n"
7893 "community number\n"
7894 "Do not send outside local AS (well-known community)\n"
7895 "Do not advertise to any peer (well-known community)\n"
7896 "Do not export to next AS (well-known community)\n"
7897 "community number\n"
7898 "Do not send outside local AS (well-known community)\n"
7899 "Do not advertise to any peer (well-known community)\n"
7900 "Do not export to next AS (well-known community)\n"
7901 "community number\n"
7902 "Do not send outside local AS (well-known community)\n"
7903 "Do not advertise to any peer (well-known community)\n"
7904 "Do not export to next AS (well-known community)\n"
7905 "Exact match of the communities")
7907 DEFUN (show_ip_bgp_ipv4_community_exact
,
7908 show_ip_bgp_ipv4_community_exact_cmd
,
7909 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7914 "Address Family modifier\n"
7915 "Address Family modifier\n"
7916 "Display routes matching the communities\n"
7917 "community number\n"
7918 "Do not send outside local AS (well-known community)\n"
7919 "Do not advertise to any peer (well-known community)\n"
7920 "Do not export to next AS (well-known community)\n"
7921 "Exact match of the communities")
7923 if (strncmp (argv
[0], "m", 1) == 0)
7924 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_MULTICAST
);
7926 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
7929 ALIAS (show_ip_bgp_ipv4_community_exact
,
7930 show_ip_bgp_ipv4_community2_exact_cmd
,
7931 "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",
7936 "Address Family modifier\n"
7937 "Address Family modifier\n"
7938 "Display routes matching the communities\n"
7939 "community number\n"
7940 "Do not send outside local AS (well-known community)\n"
7941 "Do not advertise to any peer (well-known community)\n"
7942 "Do not export to next AS (well-known community)\n"
7943 "community number\n"
7944 "Do not send outside local AS (well-known community)\n"
7945 "Do not advertise to any peer (well-known community)\n"
7946 "Do not export to next AS (well-known community)\n"
7947 "Exact match of the communities")
7949 ALIAS (show_ip_bgp_ipv4_community_exact
,
7950 show_ip_bgp_ipv4_community3_exact_cmd
,
7951 "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",
7956 "Address Family modifier\n"
7957 "Address Family modifier\n"
7958 "Display routes matching the communities\n"
7959 "community number\n"
7960 "Do not send outside local AS (well-known community)\n"
7961 "Do not advertise to any peer (well-known community)\n"
7962 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
7973 ALIAS (show_ip_bgp_ipv4_community_exact
,
7974 show_ip_bgp_ipv4_community4_exact_cmd
,
7975 "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",
7980 "Address Family modifier\n"
7981 "Address Family modifier\n"
7982 "Display routes matching the communities\n"
7983 "community number\n"
7984 "Do not send outside local AS (well-known community)\n"
7985 "Do not advertise to any peer (well-known community)\n"
7986 "Do not export to next AS (well-known community)\n"
7987 "community number\n"
7988 "Do not send outside local AS (well-known community)\n"
7989 "Do not advertise to any peer (well-known community)\n"
7990 "Do not export to next AS (well-known community)\n"
7991 "community number\n"
7992 "Do not send outside local AS (well-known community)\n"
7993 "Do not advertise to any peer (well-known community)\n"
7994 "Do not export to next AS (well-known community)\n"
7995 "community number\n"
7996 "Do not send outside local AS (well-known community)\n"
7997 "Do not advertise to any peer (well-known community)\n"
7998 "Do not export to next AS (well-known community)\n"
7999 "Exact match of the communities")
8002 DEFUN (show_bgp_community
,
8003 show_bgp_community_cmd
,
8004 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
8007 "Display routes matching the communities\n"
8008 "community number\n"
8009 "Do not send outside local AS (well-known community)\n"
8010 "Do not advertise to any peer (well-known community)\n"
8011 "Do not export to next AS (well-known community)\n")
8013 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
8016 ALIAS (show_bgp_community
,
8017 show_bgp_ipv6_community_cmd
,
8018 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
8022 "Display routes matching the communities\n"
8023 "community number\n"
8024 "Do not send outside local AS (well-known community)\n"
8025 "Do not advertise to any peer (well-known community)\n"
8026 "Do not export to next AS (well-known community)\n")
8028 ALIAS (show_bgp_community
,
8029 show_bgp_community2_cmd
,
8030 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
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")
8043 ALIAS (show_bgp_community
,
8044 show_bgp_ipv6_community2_cmd
,
8045 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8049 "Display routes matching the communities\n"
8050 "community number\n"
8051 "Do not send outside local AS (well-known community)\n"
8052 "Do not advertise to any peer (well-known community)\n"
8053 "Do not export to next AS (well-known community)\n"
8054 "community number\n"
8055 "Do not send outside local AS (well-known community)\n"
8056 "Do not advertise to any peer (well-known community)\n"
8057 "Do not export to next AS (well-known community)\n")
8059 ALIAS (show_bgp_community
,
8060 show_bgp_community3_cmd
,
8061 "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)",
8064 "Display routes matching the communities\n"
8065 "community number\n"
8066 "Do not send outside local AS (well-known community)\n"
8067 "Do not advertise to any peer (well-known community)\n"
8068 "Do not export to next AS (well-known community)\n"
8069 "community number\n"
8070 "Do not send outside local AS (well-known community)\n"
8071 "Do not advertise to any peer (well-known community)\n"
8072 "Do not export to next AS (well-known community)\n"
8073 "community number\n"
8074 "Do not send outside local AS (well-known community)\n"
8075 "Do not advertise to any peer (well-known community)\n"
8076 "Do not export to next AS (well-known community)\n")
8078 ALIAS (show_bgp_community
,
8079 show_bgp_ipv6_community3_cmd
,
8080 "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)",
8084 "Display routes matching the communities\n"
8085 "community number\n"
8086 "Do not send outside local AS (well-known community)\n"
8087 "Do not advertise to any peer (well-known community)\n"
8088 "Do not export to next AS (well-known community)\n"
8089 "community number\n"
8090 "Do not send outside local AS (well-known community)\n"
8091 "Do not advertise to any peer (well-known community)\n"
8092 "Do not export to next AS (well-known community)\n"
8093 "community number\n"
8094 "Do not send outside local AS (well-known community)\n"
8095 "Do not advertise to any peer (well-known community)\n"
8096 "Do not export to next AS (well-known community)\n")
8098 ALIAS (show_bgp_community
,
8099 show_bgp_community4_cmd
,
8100 "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)",
8103 "Display routes matching the communities\n"
8104 "community number\n"
8105 "Do not send outside local AS (well-known community)\n"
8106 "Do not advertise to any peer (well-known community)\n"
8107 "Do not export to next AS (well-known community)\n"
8108 "community number\n"
8109 "Do not send outside local AS (well-known community)\n"
8110 "Do not advertise to any peer (well-known community)\n"
8111 "Do not export to next AS (well-known community)\n"
8112 "community number\n"
8113 "Do not send outside local AS (well-known community)\n"
8114 "Do not advertise to any peer (well-known community)\n"
8115 "Do not export to next AS (well-known community)\n"
8116 "community number\n"
8117 "Do not send outside local AS (well-known community)\n"
8118 "Do not advertise to any peer (well-known community)\n"
8119 "Do not export to next AS (well-known community)\n")
8121 ALIAS (show_bgp_community
,
8122 show_bgp_ipv6_community4_cmd
,
8123 "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)",
8127 "Display routes matching the communities\n"
8128 "community number\n"
8129 "Do not send outside local AS (well-known community)\n"
8130 "Do not advertise to any peer (well-known community)\n"
8131 "Do not export to next AS (well-known community)\n"
8132 "community number\n"
8133 "Do not send outside local AS (well-known community)\n"
8134 "Do not advertise to any peer (well-known community)\n"
8135 "Do not export to next AS (well-known community)\n"
8136 "community number\n"
8137 "Do not send outside local AS (well-known community)\n"
8138 "Do not advertise to any peer (well-known community)\n"
8139 "Do not export to next AS (well-known community)\n"
8140 "community number\n"
8141 "Do not send outside local AS (well-known community)\n"
8142 "Do not advertise to any peer (well-known community)\n"
8143 "Do not export to next AS (well-known community)\n")
8146 DEFUN (show_ipv6_bgp_community
,
8147 show_ipv6_bgp_community_cmd
,
8148 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
8152 "Display routes matching the communities\n"
8153 "community number\n"
8154 "Do not send outside local AS (well-known community)\n"
8155 "Do not advertise to any peer (well-known community)\n"
8156 "Do not export to next AS (well-known community)\n")
8158 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
8162 ALIAS (show_ipv6_bgp_community
,
8163 show_ipv6_bgp_community2_cmd
,
8164 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8168 "Display routes matching the communities\n"
8169 "community number\n"
8170 "Do not send outside local AS (well-known community)\n"
8171 "Do not advertise to any peer (well-known community)\n"
8172 "Do not export to next AS (well-known community)\n"
8173 "community number\n"
8174 "Do not send outside local AS (well-known community)\n"
8175 "Do not advertise to any peer (well-known community)\n"
8176 "Do not export to next AS (well-known community)\n")
8179 ALIAS (show_ipv6_bgp_community
,
8180 show_ipv6_bgp_community3_cmd
,
8181 "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)",
8185 "Display routes matching the communities\n"
8186 "community number\n"
8187 "Do not send outside local AS (well-known community)\n"
8188 "Do not advertise to any peer (well-known community)\n"
8189 "Do not export to next AS (well-known community)\n"
8190 "community number\n"
8191 "Do not send outside local AS (well-known community)\n"
8192 "Do not advertise to any peer (well-known community)\n"
8193 "Do not export to next AS (well-known community)\n"
8194 "community number\n"
8195 "Do not send outside local AS (well-known community)\n"
8196 "Do not advertise to any peer (well-known community)\n"
8197 "Do not export to next AS (well-known community)\n")
8200 ALIAS (show_ipv6_bgp_community
,
8201 show_ipv6_bgp_community4_cmd
,
8202 "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)",
8206 "Display routes matching the communities\n"
8207 "community number\n"
8208 "Do not send outside local AS (well-known community)\n"
8209 "Do not advertise to any peer (well-known community)\n"
8210 "Do not export to next AS (well-known community)\n"
8211 "community number\n"
8212 "Do not send outside local AS (well-known community)\n"
8213 "Do not advertise to any peer (well-known community)\n"
8214 "Do not export to next AS (well-known community)\n"
8215 "community number\n"
8216 "Do not send outside local AS (well-known community)\n"
8217 "Do not advertise to any peer (well-known community)\n"
8218 "Do not export to next AS (well-known community)\n"
8219 "community number\n"
8220 "Do not send outside local AS (well-known community)\n"
8221 "Do not advertise to any peer (well-known community)\n"
8222 "Do not export to next AS (well-known community)\n")
8224 DEFUN (show_bgp_community_exact
,
8225 show_bgp_community_exact_cmd
,
8226 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8229 "Display routes matching the communities\n"
8230 "community number\n"
8231 "Do not send outside local AS (well-known community)\n"
8232 "Do not advertise to any peer (well-known community)\n"
8233 "Do not export to next AS (well-known community)\n"
8234 "Exact match of the communities")
8236 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
8239 ALIAS (show_bgp_community_exact
,
8240 show_bgp_ipv6_community_exact_cmd
,
8241 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8245 "Display routes matching the communities\n"
8246 "community number\n"
8247 "Do not send outside local AS (well-known community)\n"
8248 "Do not advertise to any peer (well-known community)\n"
8249 "Do not export to next AS (well-known community)\n"
8250 "Exact match of the communities")
8252 ALIAS (show_bgp_community_exact
,
8253 show_bgp_community2_exact_cmd
,
8254 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8257 "Display routes matching the communities\n"
8258 "community number\n"
8259 "Do not send outside local AS (well-known community)\n"
8260 "Do not advertise to any peer (well-known community)\n"
8261 "Do not export to next AS (well-known community)\n"
8262 "community number\n"
8263 "Do not send outside local AS (well-known community)\n"
8264 "Do not advertise to any peer (well-known community)\n"
8265 "Do not export to next AS (well-known community)\n"
8266 "Exact match of the communities")
8268 ALIAS (show_bgp_community_exact
,
8269 show_bgp_ipv6_community2_exact_cmd
,
8270 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8274 "Display routes matching the communities\n"
8275 "community number\n"
8276 "Do not send outside local AS (well-known community)\n"
8277 "Do not advertise to any peer (well-known community)\n"
8278 "Do not export to next AS (well-known community)\n"
8279 "community number\n"
8280 "Do not send outside local AS (well-known community)\n"
8281 "Do not advertise to any peer (well-known community)\n"
8282 "Do not export to next AS (well-known community)\n"
8283 "Exact match of the communities")
8285 ALIAS (show_bgp_community_exact
,
8286 show_bgp_community3_exact_cmd
,
8287 "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",
8290 "Display routes matching the communities\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"
8303 "Exact match of the communities")
8305 ALIAS (show_bgp_community_exact
,
8306 show_bgp_ipv6_community3_exact_cmd
,
8307 "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",
8311 "Display routes matching the communities\n"
8312 "community number\n"
8313 "Do not send outside local AS (well-known community)\n"
8314 "Do not advertise to any peer (well-known community)\n"
8315 "Do not export to next AS (well-known community)\n"
8316 "community number\n"
8317 "Do not send outside local AS (well-known community)\n"
8318 "Do not advertise to any peer (well-known community)\n"
8319 "Do not export to next AS (well-known community)\n"
8320 "community number\n"
8321 "Do not send outside local AS (well-known community)\n"
8322 "Do not advertise to any peer (well-known community)\n"
8323 "Do not export to next AS (well-known community)\n"
8324 "Exact match of the communities")
8326 ALIAS (show_bgp_community_exact
,
8327 show_bgp_community4_exact_cmd
,
8328 "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",
8331 "Display routes matching the communities\n"
8332 "community number\n"
8333 "Do not send outside local AS (well-known community)\n"
8334 "Do not advertise to any peer (well-known community)\n"
8335 "Do not export to next AS (well-known community)\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"
8340 "community number\n"
8341 "Do not send outside local AS (well-known community)\n"
8342 "Do not advertise to any peer (well-known community)\n"
8343 "Do not export to next AS (well-known community)\n"
8344 "community number\n"
8345 "Do not send outside local AS (well-known community)\n"
8346 "Do not advertise to any peer (well-known community)\n"
8347 "Do not export to next AS (well-known community)\n"
8348 "Exact match of the communities")
8350 ALIAS (show_bgp_community_exact
,
8351 show_bgp_ipv6_community4_exact_cmd
,
8352 "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",
8356 "Display routes matching the communities\n"
8357 "community number\n"
8358 "Do not send outside local AS (well-known community)\n"
8359 "Do not advertise to any peer (well-known community)\n"
8360 "Do not export to next AS (well-known community)\n"
8361 "community number\n"
8362 "Do not send outside local AS (well-known community)\n"
8363 "Do not advertise to any peer (well-known community)\n"
8364 "Do not export to next AS (well-known community)\n"
8365 "community number\n"
8366 "Do not send outside local AS (well-known community)\n"
8367 "Do not advertise to any peer (well-known community)\n"
8368 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
8376 DEFUN (show_ipv6_bgp_community_exact
,
8377 show_ipv6_bgp_community_exact_cmd
,
8378 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8382 "Display routes matching the communities\n"
8383 "community number\n"
8384 "Do not send outside local AS (well-known community)\n"
8385 "Do not advertise to any peer (well-known community)\n"
8386 "Do not export to next AS (well-known community)\n"
8387 "Exact match of the communities")
8389 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
8393 ALIAS (show_ipv6_bgp_community_exact
,
8394 show_ipv6_bgp_community2_exact_cmd
,
8395 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8399 "Display routes matching the communities\n"
8400 "community number\n"
8401 "Do not send outside local AS (well-known community)\n"
8402 "Do not advertise to any peer (well-known community)\n"
8403 "Do not export to next AS (well-known community)\n"
8404 "community number\n"
8405 "Do not send outside local AS (well-known community)\n"
8406 "Do not advertise to any peer (well-known community)\n"
8407 "Do not export to next AS (well-known community)\n"
8408 "Exact match of the communities")
8411 ALIAS (show_ipv6_bgp_community_exact
,
8412 show_ipv6_bgp_community3_exact_cmd
,
8413 "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",
8417 "Display routes matching the communities\n"
8418 "community number\n"
8419 "Do not send outside local AS (well-known community)\n"
8420 "Do not advertise to any peer (well-known community)\n"
8421 "Do not export to next AS (well-known community)\n"
8422 "community number\n"
8423 "Do not send outside local AS (well-known community)\n"
8424 "Do not advertise to any peer (well-known community)\n"
8425 "Do not export to next AS (well-known community)\n"
8426 "community number\n"
8427 "Do not send outside local AS (well-known community)\n"
8428 "Do not advertise to any peer (well-known community)\n"
8429 "Do not export to next AS (well-known community)\n"
8430 "Exact match of the communities")
8433 ALIAS (show_ipv6_bgp_community_exact
,
8434 show_ipv6_bgp_community4_exact_cmd
,
8435 "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",
8439 "Display routes matching the communities\n"
8440 "community number\n"
8441 "Do not send outside local AS (well-known community)\n"
8442 "Do not advertise to any peer (well-known community)\n"
8443 "Do not export to next AS (well-known community)\n"
8444 "community number\n"
8445 "Do not send outside local AS (well-known community)\n"
8446 "Do not advertise to any peer (well-known community)\n"
8447 "Do not export to next AS (well-known community)\n"
8448 "community number\n"
8449 "Do not send outside local AS (well-known community)\n"
8450 "Do not advertise to any peer (well-known community)\n"
8451 "Do not export to next AS (well-known community)\n"
8452 "community number\n"
8453 "Do not send outside local AS (well-known community)\n"
8454 "Do not advertise to any peer (well-known community)\n"
8455 "Do not export to next AS (well-known community)\n"
8456 "Exact match of the communities")
8459 DEFUN (show_ipv6_mbgp_community
,
8460 show_ipv6_mbgp_community_cmd
,
8461 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
8465 "Display routes matching the communities\n"
8466 "community number\n"
8467 "Do not send outside local AS (well-known community)\n"
8468 "Do not advertise to any peer (well-known community)\n"
8469 "Do not export to next AS (well-known community)\n")
8471 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
8475 ALIAS (show_ipv6_mbgp_community
,
8476 show_ipv6_mbgp_community2_cmd
,
8477 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8481 "Display routes matching the communities\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 "community number\n"
8487 "Do not send outside local AS (well-known community)\n"
8488 "Do not advertise to any peer (well-known community)\n"
8489 "Do not export to next AS (well-known community)\n")
8492 ALIAS (show_ipv6_mbgp_community
,
8493 show_ipv6_mbgp_community3_cmd
,
8494 "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)",
8498 "Display routes matching the communities\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 "community number\n"
8508 "Do not send outside local AS (well-known community)\n"
8509 "Do not advertise to any peer (well-known community)\n"
8510 "Do not export to next AS (well-known community)\n")
8513 ALIAS (show_ipv6_mbgp_community
,
8514 show_ipv6_mbgp_community4_cmd
,
8515 "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)",
8519 "Display routes matching the communities\n"
8520 "community number\n"
8521 "Do not send outside local AS (well-known community)\n"
8522 "Do not advertise to any peer (well-known community)\n"
8523 "Do not export to next AS (well-known community)\n"
8524 "community number\n"
8525 "Do not send outside local AS (well-known community)\n"
8526 "Do not advertise to any peer (well-known community)\n"
8527 "Do not export to next AS (well-known community)\n"
8528 "community number\n"
8529 "Do not send outside local AS (well-known community)\n"
8530 "Do not advertise to any peer (well-known community)\n"
8531 "Do not export to next AS (well-known community)\n"
8532 "community number\n"
8533 "Do not send outside local AS (well-known community)\n"
8534 "Do not advertise to any peer (well-known community)\n"
8535 "Do not export to next AS (well-known community)\n")
8538 DEFUN (show_ipv6_mbgp_community_exact
,
8539 show_ipv6_mbgp_community_exact_cmd
,
8540 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8544 "Display routes matching the communities\n"
8545 "community number\n"
8546 "Do not send outside local AS (well-known community)\n"
8547 "Do not advertise to any peer (well-known community)\n"
8548 "Do not export to next AS (well-known community)\n"
8549 "Exact match of the communities")
8551 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
8555 ALIAS (show_ipv6_mbgp_community_exact
,
8556 show_ipv6_mbgp_community2_exact_cmd
,
8557 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8561 "Display routes matching the communities\n"
8562 "community number\n"
8563 "Do not send outside local AS (well-known community)\n"
8564 "Do not advertise to any peer (well-known community)\n"
8565 "Do not export to next AS (well-known community)\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")
8573 ALIAS (show_ipv6_mbgp_community_exact
,
8574 show_ipv6_mbgp_community3_exact_cmd
,
8575 "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",
8579 "Display routes matching the communities\n"
8580 "community number\n"
8581 "Do not send outside local AS (well-known community)\n"
8582 "Do not advertise to any peer (well-known community)\n"
8583 "Do not export to next AS (well-known community)\n"
8584 "community number\n"
8585 "Do not send outside local AS (well-known community)\n"
8586 "Do not advertise to any peer (well-known community)\n"
8587 "Do not export to next AS (well-known community)\n"
8588 "community number\n"
8589 "Do not send outside local AS (well-known community)\n"
8590 "Do not advertise to any peer (well-known community)\n"
8591 "Do not export to next AS (well-known community)\n"
8592 "Exact match of the communities")
8595 ALIAS (show_ipv6_mbgp_community_exact
,
8596 show_ipv6_mbgp_community4_exact_cmd
,
8597 "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",
8601 "Display routes matching the communities\n"
8602 "community number\n"
8603 "Do not send outside local AS (well-known community)\n"
8604 "Do not advertise to any peer (well-known community)\n"
8605 "Do not export to next AS (well-known community)\n"
8606 "community number\n"
8607 "Do not send outside local AS (well-known community)\n"
8608 "Do not advertise to any peer (well-known community)\n"
8609 "Do not export to next AS (well-known community)\n"
8610 "community number\n"
8611 "Do not send outside local AS (well-known community)\n"
8612 "Do not advertise to any peer (well-known community)\n"
8613 "Do not export to next AS (well-known community)\n"
8614 "community number\n"
8615 "Do not send outside local AS (well-known community)\n"
8616 "Do not advertise to any peer (well-known community)\n"
8617 "Do not export to next AS (well-known community)\n"
8618 "Exact match of the communities")
8619 #endif /* HAVE_IPV6 */
8622 bgp_show_community_list (struct vty
*vty
, const char *com
, int exact
,
8623 u_int16_t afi
, u_char safi
)
8625 struct community_list
*list
;
8627 list
= community_list_lookup (bgp_clist
, com
, COMMUNITY_LIST_MASTER
);
8630 vty_out (vty
, "%% %s is not a valid community-list name%s", com
,
8635 return bgp_show (vty
, NULL
, afi
, safi
,
8636 (exact
? bgp_show_type_community_list_exact
:
8637 bgp_show_type_community_list
), list
);
8640 DEFUN (show_ip_bgp_community_list
,
8641 show_ip_bgp_community_list_cmd
,
8642 "show ip bgp community-list (<1-500>|WORD)",
8646 "Display routes matching the community-list\n"
8647 "community-list number\n"
8648 "community-list name\n")
8650 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP
, SAFI_UNICAST
);
8653 DEFUN (show_ip_bgp_ipv4_community_list
,
8654 show_ip_bgp_ipv4_community_list_cmd
,
8655 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
8660 "Address Family modifier\n"
8661 "Address Family modifier\n"
8662 "Display routes matching the community-list\n"
8663 "community-list number\n"
8664 "community-list name\n")
8666 if (strncmp (argv
[0], "m", 1) == 0)
8667 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_MULTICAST
);
8669 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_UNICAST
);
8672 DEFUN (show_ip_bgp_community_list_exact
,
8673 show_ip_bgp_community_list_exact_cmd
,
8674 "show ip bgp community-list (<1-500>|WORD) exact-match",
8678 "Display routes matching the community-list\n"
8679 "community-list number\n"
8680 "community-list name\n"
8681 "Exact match of the communities\n")
8683 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP
, SAFI_UNICAST
);
8686 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
8687 show_ip_bgp_ipv4_community_list_exact_cmd
,
8688 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
8693 "Address Family modifier\n"
8694 "Address Family modifier\n"
8695 "Display routes matching the community-list\n"
8696 "community-list number\n"
8697 "community-list name\n"
8698 "Exact match of the communities\n")
8700 if (strncmp (argv
[0], "m", 1) == 0)
8701 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_MULTICAST
);
8703 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_UNICAST
);
8707 DEFUN (show_bgp_community_list
,
8708 show_bgp_community_list_cmd
,
8709 "show bgp community-list (<1-500>|WORD)",
8712 "Display routes matching the community-list\n"
8713 "community-list number\n"
8714 "community-list name\n")
8716 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
8719 ALIAS (show_bgp_community_list
,
8720 show_bgp_ipv6_community_list_cmd
,
8721 "show bgp ipv6 community-list (<1-500>|WORD)",
8725 "Display routes matching the community-list\n"
8726 "community-list number\n"
8727 "community-list name\n")
8730 DEFUN (show_ipv6_bgp_community_list
,
8731 show_ipv6_bgp_community_list_cmd
,
8732 "show ipv6 bgp community-list WORD",
8736 "Display routes matching the community-list\n"
8737 "community-list name\n")
8739 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
8743 DEFUN (show_ipv6_mbgp_community_list
,
8744 show_ipv6_mbgp_community_list_cmd
,
8745 "show ipv6 mbgp community-list WORD",
8749 "Display routes matching the community-list\n"
8750 "community-list name\n")
8752 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_MULTICAST
);
8755 DEFUN (show_bgp_community_list_exact
,
8756 show_bgp_community_list_exact_cmd
,
8757 "show bgp community-list (<1-500>|WORD) exact-match",
8760 "Display routes matching the community-list\n"
8761 "community-list number\n"
8762 "community-list name\n"
8763 "Exact match of the communities\n")
8765 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
8768 ALIAS (show_bgp_community_list_exact
,
8769 show_bgp_ipv6_community_list_exact_cmd
,
8770 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
8774 "Display routes matching the community-list\n"
8775 "community-list number\n"
8776 "community-list name\n"
8777 "Exact match of the communities\n")
8780 DEFUN (show_ipv6_bgp_community_list_exact
,
8781 show_ipv6_bgp_community_list_exact_cmd
,
8782 "show ipv6 bgp community-list WORD exact-match",
8786 "Display routes matching the community-list\n"
8787 "community-list name\n"
8788 "Exact match of the communities\n")
8790 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
8794 DEFUN (show_ipv6_mbgp_community_list_exact
,
8795 show_ipv6_mbgp_community_list_exact_cmd
,
8796 "show ipv6 mbgp community-list WORD exact-match",
8800 "Display routes matching the community-list\n"
8801 "community-list name\n"
8802 "Exact match of the communities\n")
8804 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_MULTICAST
);
8806 #endif /* HAVE_IPV6 */
8809 bgp_show_prefix_longer (struct vty
*vty
, const char *prefix
, afi_t afi
,
8810 safi_t safi
, enum bgp_show_type type
)
8817 ret
= str2prefix (prefix
, p
);
8820 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
8824 ret
= bgp_show (vty
, NULL
, afi
, safi
, type
, p
);
8829 DEFUN (show_ip_bgp_prefix_longer
,
8830 show_ip_bgp_prefix_longer_cmd
,
8831 "show ip bgp A.B.C.D/M longer-prefixes",
8835 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8836 "Display route and more specific routes\n")
8838 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8839 bgp_show_type_prefix_longer
);
8842 DEFUN (show_ip_bgp_flap_prefix_longer
,
8843 show_ip_bgp_flap_prefix_longer_cmd
,
8844 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
8848 "Display flap statistics of routes\n"
8849 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8850 "Display route and more specific routes\n")
8852 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8853 bgp_show_type_flap_prefix_longer
);
8856 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
8857 show_ip_bgp_ipv4_prefix_longer_cmd
,
8858 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
8863 "Address Family modifier\n"
8864 "Address Family modifier\n"
8865 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8866 "Display route and more specific routes\n")
8868 if (strncmp (argv
[0], "m", 1) == 0)
8869 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
8870 bgp_show_type_prefix_longer
);
8872 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
8873 bgp_show_type_prefix_longer
);
8876 DEFUN (show_ip_bgp_flap_address
,
8877 show_ip_bgp_flap_address_cmd
,
8878 "show ip bgp flap-statistics A.B.C.D",
8882 "Display flap statistics of routes\n"
8883 "Network in the BGP routing table to display\n")
8885 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8886 bgp_show_type_flap_address
);
8889 DEFUN (show_ip_bgp_flap_prefix
,
8890 show_ip_bgp_flap_prefix_cmd
,
8891 "show ip bgp flap-statistics A.B.C.D/M",
8895 "Display flap statistics of routes\n"
8896 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8898 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8899 bgp_show_type_flap_prefix
);
8902 DEFUN (show_bgp_prefix_longer
,
8903 show_bgp_prefix_longer_cmd
,
8904 "show bgp X:X::X:X/M longer-prefixes",
8907 "IPv6 prefix <network>/<length>\n"
8908 "Display route and more specific routes\n")
8910 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8911 bgp_show_type_prefix_longer
);
8914 ALIAS (show_bgp_prefix_longer
,
8915 show_bgp_ipv6_prefix_longer_cmd
,
8916 "show bgp ipv6 X:X::X:X/M longer-prefixes",
8920 "IPv6 prefix <network>/<length>\n"
8921 "Display route and more specific routes\n")
8924 DEFUN (show_ipv6_bgp_prefix_longer
,
8925 show_ipv6_bgp_prefix_longer_cmd
,
8926 "show ipv6 bgp X:X::X:X/M longer-prefixes",
8930 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8931 "Display route and more specific routes\n")
8933 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8934 bgp_show_type_prefix_longer
);
8938 DEFUN (show_ipv6_mbgp_prefix_longer
,
8939 show_ipv6_mbgp_prefix_longer_cmd
,
8940 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
8944 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8945 "Display route and more specific routes\n")
8947 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
8948 bgp_show_type_prefix_longer
);
8950 #endif /* HAVE_IPV6 */
8952 static struct peer
*
8953 peer_lookup_in_view (struct vty
*vty
, const char *view_name
,
8961 /* BGP structure lookup. */
8964 bgp
= bgp_lookup_by_name (view_name
);
8967 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
8973 bgp
= bgp_get_default ();
8976 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
8981 /* Get peer sockunion. */
8982 ret
= str2sockunion (ip_str
, &su
);
8985 vty_out (vty
, "Malformed address: %s%s", ip_str
, VTY_NEWLINE
);
8989 /* Peer structure lookup. */
8990 peer
= peer_lookup (bgp
, &su
);
8993 vty_out (vty
, "No such neighbor%s", VTY_NEWLINE
);
9002 BGP_STATS_MAXBITLEN
= 0,
9006 BGP_STATS_UNAGGREGATEABLE
,
9007 BGP_STATS_MAX_AGGREGATEABLE
,
9008 BGP_STATS_AGGREGATES
,
9010 BGP_STATS_ASPATH_COUNT
,
9011 BGP_STATS_ASPATH_MAXHOPS
,
9012 BGP_STATS_ASPATH_TOTHOPS
,
9013 BGP_STATS_ASPATH_MAXSIZE
,
9014 BGP_STATS_ASPATH_TOTSIZE
,
9015 BGP_STATS_ASN_HIGHEST
,
9019 static const char *table_stats_strs
[] =
9021 [BGP_STATS_PREFIXES
] = "Total Prefixes",
9022 [BGP_STATS_TOTPLEN
] = "Average prefix length",
9023 [BGP_STATS_RIB
] = "Total Advertisements",
9024 [BGP_STATS_UNAGGREGATEABLE
] = "Unaggregateable prefixes",
9025 [BGP_STATS_MAX_AGGREGATEABLE
] = "Maximum aggregateable prefixes",
9026 [BGP_STATS_AGGREGATES
] = "BGP Aggregate advertisements",
9027 [BGP_STATS_SPACE
] = "Address space advertised",
9028 [BGP_STATS_ASPATH_COUNT
] = "Advertisements with paths",
9029 [BGP_STATS_ASPATH_MAXHOPS
] = "Longest AS-Path (hops)",
9030 [BGP_STATS_ASPATH_MAXSIZE
] = "Largest AS-Path (bytes)",
9031 [BGP_STATS_ASPATH_TOTHOPS
] = "Average AS-Path length (hops)",
9032 [BGP_STATS_ASPATH_TOTSIZE
] = "Average AS-Path size (bytes)",
9033 [BGP_STATS_ASN_HIGHEST
] = "Highest public ASN",
9034 [BGP_STATS_MAX
] = NULL
,
9037 struct bgp_table_stats
9039 struct bgp_table
*table
;
9040 unsigned long long counts
[BGP_STATS_MAX
];
9044 #define TALLY_SIGFIG 100000
9045 static unsigned long
9046 ravg_tally (unsigned long count
, unsigned long oldavg
, unsigned long newval
)
9048 unsigned long newtot
= (count
-1) * oldavg
+ (newval
* TALLY_SIGFIG
);
9049 unsigned long res
= (newtot
* TALLY_SIGFIG
) / count
;
9050 unsigned long ret
= newtot
/ count
;
9052 if ((res
% TALLY_SIGFIG
) > (TALLY_SIGFIG
/2))
9060 bgp_table_stats_walker (struct thread
*t
)
9062 struct bgp_node
*rn
;
9063 struct bgp_node
*top
;
9064 struct bgp_table_stats
*ts
= THREAD_ARG (t
);
9065 unsigned int space
= 0;
9067 if (!(top
= bgp_table_top (ts
->table
)))
9070 switch (top
->p
.family
)
9073 space
= IPV4_MAX_BITLEN
;
9076 space
= IPV6_MAX_BITLEN
;
9080 ts
->counts
[BGP_STATS_MAXBITLEN
] = space
;
9082 for (rn
= top
; rn
; rn
= bgp_route_next (rn
))
9084 struct bgp_info
*ri
;
9085 struct bgp_node
*prn
= rn
->parent
;
9086 unsigned int rinum
= 0;
9094 ts
->counts
[BGP_STATS_PREFIXES
]++;
9095 ts
->counts
[BGP_STATS_TOTPLEN
] += rn
->p
.prefixlen
;
9098 ts
->counts
[BGP_STATS_AVGPLEN
]
9099 = ravg_tally (ts
->counts
[BGP_STATS_PREFIXES
],
9100 ts
->counts
[BGP_STATS_AVGPLEN
],
9104 /* check if the prefix is included by any other announcements */
9105 while (prn
&& !prn
->info
)
9108 if (prn
== NULL
|| prn
== top
)
9110 ts
->counts
[BGP_STATS_UNAGGREGATEABLE
]++;
9111 /* announced address space */
9113 ts
->counts
[BGP_STATS_SPACE
] += 1 << (space
- rn
->p
.prefixlen
);
9116 ts
->counts
[BGP_STATS_MAX_AGGREGATEABLE
]++;
9118 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
9121 ts
->counts
[BGP_STATS_RIB
]++;
9124 (CHECK_FLAG (ri
->attr
->flag
,
9125 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
))))
9126 ts
->counts
[BGP_STATS_AGGREGATES
]++;
9129 if (ri
->attr
&& ri
->attr
->aspath
)
9131 unsigned int hops
= aspath_count_hops (ri
->attr
->aspath
);
9132 unsigned int size
= aspath_size (ri
->attr
->aspath
);
9133 as_t highest
= aspath_highest (ri
->attr
->aspath
);
9135 ts
->counts
[BGP_STATS_ASPATH_COUNT
]++;
9137 if (hops
> ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
])
9138 ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
] = hops
;
9140 if (size
> ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
])
9141 ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
] = size
;
9143 ts
->counts
[BGP_STATS_ASPATH_TOTHOPS
] += hops
;
9144 ts
->counts
[BGP_STATS_ASPATH_TOTSIZE
] += size
;
9146 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
]
9147 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
9148 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
],
9150 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
]
9151 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
9152 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
],
9155 if (highest
> ts
->counts
[BGP_STATS_ASN_HIGHEST
])
9156 ts
->counts
[BGP_STATS_ASN_HIGHEST
] = highest
;
9164 bgp_table_stats (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
)
9166 struct bgp_table_stats ts
;
9169 if (!bgp
->rib
[afi
][safi
])
9171 vty_out (vty
, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE
);
9175 memset (&ts
, 0, sizeof (ts
));
9176 ts
.table
= bgp
->rib
[afi
][safi
];
9177 thread_execute (bm
->master
, bgp_table_stats_walker
, &ts
, 0);
9179 vty_out (vty
, "BGP %s RIB statistics%s%s",
9180 afi_safi_print (afi
, safi
), VTY_NEWLINE
, VTY_NEWLINE
);
9182 for (i
= 0; i
< BGP_STATS_MAX
; i
++)
9184 if (!table_stats_strs
[i
])
9190 case BGP_STATS_ASPATH_AVGHOPS
:
9191 case BGP_STATS_ASPATH_AVGSIZE
:
9192 case BGP_STATS_AVGPLEN
:
9193 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9194 vty_out (vty
, "%12.2f",
9195 (float)ts
.counts
[i
] / (float)TALLY_SIGFIG
);
9198 case BGP_STATS_ASPATH_TOTHOPS
:
9199 case BGP_STATS_ASPATH_TOTSIZE
:
9200 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9201 vty_out (vty
, "%12.2f",
9203 (float)ts
.counts
[i
] /
9204 (float)ts
.counts
[BGP_STATS_ASPATH_COUNT
]
9207 case BGP_STATS_TOTPLEN
:
9208 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9209 vty_out (vty
, "%12.2f",
9211 (float)ts
.counts
[i
] /
9212 (float)ts
.counts
[BGP_STATS_PREFIXES
]
9215 case BGP_STATS_SPACE
:
9216 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9217 vty_out (vty
, "%12llu%s", ts
.counts
[i
], VTY_NEWLINE
);
9218 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 9)
9220 vty_out (vty
, "%30s: ", "%% announced ");
9221 vty_out (vty
, "%12.2f%s",
9222 100 * (float)ts
.counts
[BGP_STATS_SPACE
] /
9223 (float)((uint64_t)1UL << ts
.counts
[BGP_STATS_MAXBITLEN
]),
9225 vty_out (vty
, "%30s: ", "/8 equivalent ");
9226 vty_out (vty
, "%12.2f%s",
9227 (float)ts
.counts
[BGP_STATS_SPACE
] /
9228 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 8)),
9230 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 25)
9232 vty_out (vty
, "%30s: ", "/24 equivalent ");
9233 vty_out (vty
, "%12.2f",
9234 (float)ts
.counts
[BGP_STATS_SPACE
] /
9235 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 24)));
9238 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9239 vty_out (vty
, "%12llu", ts
.counts
[i
]);
9242 vty_out (vty
, "%s", VTY_NEWLINE
);
9248 bgp_table_stats_vty (struct vty
*vty
, const char *name
,
9249 const char *afi_str
, const char *safi_str
)
9256 bgp
= bgp_lookup_by_name (name
);
9258 bgp
= bgp_get_default ();
9262 vty_out (vty
, "%% No such BGP instance exist%s", VTY_NEWLINE
);
9265 if (strncmp (afi_str
, "ipv", 3) == 0)
9267 if (strncmp (afi_str
, "ipv4", 4) == 0)
9269 else if (strncmp (afi_str
, "ipv6", 4) == 0)
9273 vty_out (vty
, "%% Invalid address family %s%s",
9274 afi_str
, VTY_NEWLINE
);
9277 if (strncmp (safi_str
, "m", 1) == 0)
9278 safi
= SAFI_MULTICAST
;
9279 else if (strncmp (safi_str
, "u", 1) == 0)
9280 safi
= SAFI_UNICAST
;
9281 else if (strncmp (safi_str
, "vpnv4", 5) == 0)
9282 safi
= BGP_SAFI_VPNV4
;
9283 else if (strncmp (safi_str
, "vpnv6", 6) == 0)
9284 safi
= BGP_SAFI_VPNV6
;
9287 vty_out (vty
, "%% Invalid subsequent address family %s%s",
9288 safi_str
, VTY_NEWLINE
);
9294 vty_out (vty
, "%% Invalid address family %s%s",
9295 afi_str
, VTY_NEWLINE
);
9299 if ((afi
== AFI_IP
&& safi
== BGP_SAFI_VPNV6
)
9300 || (afi
== AFI_IP6
&& safi
== BGP_SAFI_VPNV4
))
9302 vty_out (vty
, "%% Invalid subsequent address family %s for %s%s",
9303 afi_str
, safi_str
, VTY_NEWLINE
);
9306 return bgp_table_stats (vty
, bgp
, afi
, safi
);
9309 DEFUN (show_bgp_statistics
,
9310 show_bgp_statistics_cmd
,
9311 "show bgp (ipv4|ipv6) (unicast|multicast) statistics",
9316 "Address Family modifier\n"
9317 "Address Family modifier\n"
9318 "BGP RIB advertisement statistics\n")
9320 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
9323 ALIAS (show_bgp_statistics
,
9324 show_bgp_statistics_vpnv4_cmd
,
9325 "show bgp (ipv4) (vpnv4) statistics",
9329 "Address Family modifier\n"
9330 "BGP RIB advertisement statistics\n")
9332 DEFUN (show_bgp_statistics_view
,
9333 show_bgp_statistics_view_cmd
,
9334 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics",
9340 "Address Family modifier\n"
9341 "Address Family modifier\n"
9342 "BGP RIB advertisement statistics\n")
9344 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
9347 ALIAS (show_bgp_statistics_view
,
9348 show_bgp_statistics_view_vpnv4_cmd
,
9349 "show bgp view WORD (ipv4) (vpnv4) statistics",
9354 "Address Family modifier\n"
9355 "BGP RIB advertisement statistics\n")
9367 PCOUNT_PFCNT
, /* the figure we display to users */
9371 static const char *pcount_strs
[] =
9373 [PCOUNT_ADJ_IN
] = "Adj-in",
9374 [PCOUNT_DAMPED
] = "Damped",
9375 [PCOUNT_REMOVED
] = "Removed",
9376 [PCOUNT_HISTORY
] = "History",
9377 [PCOUNT_STALE
] = "Stale",
9378 [PCOUNT_VALID
] = "Valid",
9379 [PCOUNT_ALL
] = "All RIB",
9380 [PCOUNT_COUNTED
] = "PfxCt counted",
9381 [PCOUNT_PFCNT
] = "Useable",
9382 [PCOUNT_MAX
] = NULL
,
9387 unsigned int count
[PCOUNT_MAX
];
9388 const struct peer
*peer
;
9389 const struct bgp_table
*table
;
9393 bgp_peer_count_walker (struct thread
*t
)
9395 struct bgp_node
*rn
;
9396 struct peer_pcounts
*pc
= THREAD_ARG (t
);
9397 const struct peer
*peer
= pc
->peer
;
9399 for (rn
= bgp_table_top (pc
->table
); rn
; rn
= bgp_route_next (rn
))
9401 struct bgp_adj_in
*ain
;
9402 struct bgp_info
*ri
;
9404 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
9405 if (ain
->peer
== peer
)
9406 pc
->count
[PCOUNT_ADJ_IN
]++;
9408 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
9410 char buf
[SU_ADDRSTRLEN
];
9412 if (ri
->peer
!= peer
)
9415 pc
->count
[PCOUNT_ALL
]++;
9417 if (CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
))
9418 pc
->count
[PCOUNT_DAMPED
]++;
9419 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
9420 pc
->count
[PCOUNT_HISTORY
]++;
9421 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
9422 pc
->count
[PCOUNT_REMOVED
]++;
9423 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
9424 pc
->count
[PCOUNT_STALE
]++;
9425 if (CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
))
9426 pc
->count
[PCOUNT_VALID
]++;
9427 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9428 pc
->count
[PCOUNT_PFCNT
]++;
9430 if (CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
9432 pc
->count
[PCOUNT_COUNTED
]++;
9433 if (CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9434 plog_warn (peer
->log
,
9435 "%s [pcount] %s/%d is counted but flags 0x%x",
9437 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
9438 buf
, SU_ADDRSTRLEN
),
9444 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9445 plog_warn (peer
->log
,
9446 "%s [pcount] %s/%d not counted but flags 0x%x",
9448 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
9449 buf
, SU_ADDRSTRLEN
),
9459 bgp_peer_counts (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
)
9461 struct peer_pcounts pcounts
= { .peer
= peer
};
9464 if (!peer
|| !peer
->bgp
|| !peer
->afc
[afi
][safi
]
9465 || !peer
->bgp
->rib
[afi
][safi
])
9467 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
9471 memset (&pcounts
, 0, sizeof(pcounts
));
9472 pcounts
.peer
= peer
;
9473 pcounts
.table
= peer
->bgp
->rib
[afi
][safi
];
9475 /* in-place call via thread subsystem so as to record execution time
9476 * stats for the thread-walk (i.e. ensure this can't be blamed on
9477 * on just vty_read()).
9479 thread_execute (bm
->master
, bgp_peer_count_walker
, &pcounts
, 0);
9481 vty_out (vty
, "Prefix counts for %s, %s%s",
9482 peer
->host
, afi_safi_print (afi
, safi
), VTY_NEWLINE
);
9483 vty_out (vty
, "PfxCt: %ld%s", peer
->pcount
[afi
][safi
], VTY_NEWLINE
);
9484 vty_out (vty
, "%sCounts from RIB table walk:%s%s",
9485 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
9487 for (i
= 0; i
< PCOUNT_MAX
; i
++)
9488 vty_out (vty
, "%20s: %-10d%s",
9489 pcount_strs
[i
], pcounts
.count
[i
], VTY_NEWLINE
);
9491 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
9493 vty_out (vty
, "%s [pcount] PfxCt drift!%s",
9494 peer
->host
, VTY_NEWLINE
);
9495 vty_out (vty
, "Please report this bug, with the above command output%s",
9502 DEFUN (show_ip_bgp_neighbor_prefix_counts
,
9503 show_ip_bgp_neighbor_prefix_counts_cmd
,
9504 "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9508 "Detailed information on TCP and BGP neighbor connections\n"
9509 "Neighbor to display information about\n"
9510 "Neighbor to display information about\n"
9511 "Display detailed prefix count information\n")
9515 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9519 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
);
9522 DEFUN (show_bgp_ipv6_neighbor_prefix_counts
,
9523 show_bgp_ipv6_neighbor_prefix_counts_cmd
,
9524 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9528 "Detailed information on TCP and BGP neighbor connections\n"
9529 "Neighbor to display information about\n"
9530 "Neighbor to display information about\n"
9531 "Display detailed prefix count information\n")
9535 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9539 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
);
9542 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts
,
9543 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
,
9544 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9549 "Address Family modifier\n"
9550 "Address Family modifier\n"
9551 "Detailed information on TCP and BGP neighbor connections\n"
9552 "Neighbor to display information about\n"
9553 "Neighbor to display information about\n"
9554 "Display detailed prefix count information\n")
9558 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9562 if (strncmp (argv
[0], "m", 1) == 0)
9563 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MULTICAST
);
9565 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
);
9568 DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts
,
9569 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
,
9570 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9575 "Address Family modifier\n"
9576 "Address Family modifier\n"
9577 "Detailed information on TCP and BGP neighbor connections\n"
9578 "Neighbor to display information about\n"
9579 "Neighbor to display information about\n"
9580 "Display detailed prefix count information\n")
9584 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9588 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MPLS_VPN
);
9593 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
9596 struct bgp_table
*table
;
9597 struct bgp_adj_in
*ain
;
9598 struct bgp_adj_out
*adj
;
9599 unsigned long output_count
;
9600 struct bgp_node
*rn
;
9610 table
= bgp
->rib
[afi
][safi
];
9614 if (! in
&& CHECK_FLAG (peer
->af_sflags
[afi
][safi
],
9615 PEER_STATUS_DEFAULT_ORIGINATE
))
9617 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9618 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9619 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9621 vty_out (vty
, "Originating default network 0.0.0.0%s%s",
9622 VTY_NEWLINE
, VTY_NEWLINE
);
9626 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
9629 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
9630 if (ain
->peer
== peer
)
9634 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9635 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9636 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9641 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
9646 route_vty_out_tmp (vty
, &rn
->p
, ain
->attr
, safi
);
9653 for (adj
= rn
->adj_out
; adj
; adj
= adj
->next
)
9654 if (adj
->peer
== peer
)
9658 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9659 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9660 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9665 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
9670 route_vty_out_tmp (vty
, &rn
->p
, adj
->attr
, safi
);
9676 if (output_count
!= 0)
9677 vty_out (vty
, "%sTotal number of prefixes %ld%s",
9678 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
9682 peer_adj_routes (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
, int in
)
9684 if (! peer
|| ! peer
->afc
[afi
][safi
])
9686 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
9690 if (in
&& ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
9692 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s",
9697 show_adj_route (vty
, peer
, afi
, safi
, in
);
9702 DEFUN (show_ip_bgp_view_neighbor_advertised_route
,
9703 show_ip_bgp_view_neighbor_advertised_route_cmd
,
9704 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9710 "Detailed information on TCP and BGP neighbor connections\n"
9711 "Neighbor to display information about\n"
9712 "Neighbor to display information about\n"
9713 "Display the routes advertised to a BGP neighbor\n")
9718 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9720 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9725 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0);
9728 ALIAS (show_ip_bgp_view_neighbor_advertised_route
,
9729 show_ip_bgp_neighbor_advertised_route_cmd
,
9730 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
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 the routes advertised to a BGP neighbor\n")
9739 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
9740 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
9741 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9746 "Address Family modifier\n"
9747 "Address Family modifier\n"
9748 "Detailed information on TCP and BGP neighbor connections\n"
9749 "Neighbor to display information about\n"
9750 "Neighbor to display information about\n"
9751 "Display the routes advertised to a BGP neighbor\n")
9755 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9759 if (strncmp (argv
[0], "m", 1) == 0)
9760 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 0);
9762 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0);
9766 DEFUN (show_bgp_view_neighbor_advertised_route
,
9767 show_bgp_view_neighbor_advertised_route_cmd
,
9768 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9773 "Detailed information on TCP and BGP neighbor connections\n"
9774 "Neighbor to display information about\n"
9775 "Neighbor to display information about\n"
9776 "Display the routes advertised to a BGP neighbor\n")
9781 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9783 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9788 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0);
9791 ALIAS (show_bgp_view_neighbor_advertised_route
,
9792 show_bgp_view_ipv6_neighbor_advertised_route_cmd
,
9793 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9799 "Detailed information on TCP and BGP neighbor connections\n"
9800 "Neighbor to display information about\n"
9801 "Neighbor to display information about\n"
9802 "Display the routes advertised to a BGP neighbor\n")
9804 DEFUN (show_bgp_view_neighbor_received_routes
,
9805 show_bgp_view_neighbor_received_routes_cmd
,
9806 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
9811 "Detailed information on TCP and BGP neighbor connections\n"
9812 "Neighbor to display information about\n"
9813 "Neighbor to display information about\n"
9814 "Display the received routes from neighbor\n")
9819 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9821 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9826 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1);
9829 ALIAS (show_bgp_view_neighbor_received_routes
,
9830 show_bgp_view_ipv6_neighbor_received_routes_cmd
,
9831 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
9837 "Detailed information on TCP and BGP neighbor connections\n"
9838 "Neighbor to display information about\n"
9839 "Neighbor to display information about\n"
9840 "Display the received routes from neighbor\n")
9842 ALIAS (show_bgp_view_neighbor_advertised_route
,
9843 show_bgp_neighbor_advertised_route_cmd
,
9844 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9847 "Detailed information on TCP and BGP neighbor connections\n"
9848 "Neighbor to display information about\n"
9849 "Neighbor to display information about\n"
9850 "Display the routes advertised to a BGP neighbor\n")
9852 ALIAS (show_bgp_view_neighbor_advertised_route
,
9853 show_bgp_ipv6_neighbor_advertised_route_cmd
,
9854 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9858 "Detailed information on TCP and BGP neighbor connections\n"
9859 "Neighbor to display information about\n"
9860 "Neighbor to display information about\n"
9861 "Display the routes advertised to a BGP neighbor\n")
9864 ALIAS (show_bgp_view_neighbor_advertised_route
,
9865 ipv6_bgp_neighbor_advertised_route_cmd
,
9866 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9870 "Detailed information on TCP and BGP neighbor connections\n"
9871 "Neighbor to display information about\n"
9872 "Neighbor to display information about\n"
9873 "Display the routes advertised to a BGP neighbor\n")
9876 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
9877 ipv6_mbgp_neighbor_advertised_route_cmd
,
9878 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9882 "Detailed information on TCP and BGP neighbor connections\n"
9883 "Neighbor to display information about\n"
9884 "Neighbor to display information about\n"
9885 "Display the routes advertised to a BGP neighbor\n")
9889 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9893 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 0);
9895 #endif /* HAVE_IPV6 */
9897 DEFUN (show_ip_bgp_view_neighbor_received_routes
,
9898 show_ip_bgp_view_neighbor_received_routes_cmd
,
9899 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
9905 "Detailed information on TCP and BGP neighbor connections\n"
9906 "Neighbor to display information about\n"
9907 "Neighbor to display information about\n"
9908 "Display the received routes from neighbor\n")
9913 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9915 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9920 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1);
9923 ALIAS (show_ip_bgp_view_neighbor_received_routes
,
9924 show_ip_bgp_neighbor_received_routes_cmd
,
9925 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
9929 "Detailed information on TCP and BGP neighbor connections\n"
9930 "Neighbor to display information about\n"
9931 "Neighbor to display information about\n"
9932 "Display the received routes from neighbor\n")
9934 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
9935 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
9936 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
9941 "Address Family modifier\n"
9942 "Address Family modifier\n"
9943 "Detailed information on TCP and BGP neighbor connections\n"
9944 "Neighbor to display information about\n"
9945 "Neighbor to display information about\n"
9946 "Display the received routes from neighbor\n")
9950 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9954 if (strncmp (argv
[0], "m", 1) == 0)
9955 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 1);
9957 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1);
9960 DEFUN (show_ip_bgp_neighbor_received_prefix_filter
,
9961 show_ip_bgp_neighbor_received_prefix_filter_cmd
,
9962 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9966 "Detailed information on TCP and BGP neighbor connections\n"
9967 "Neighbor to display information about\n"
9968 "Neighbor to display information about\n"
9969 "Display information received from a BGP neighbor\n"
9970 "Display the prefixlist filter\n")
9973 union sockunion
*su
;
9977 su
= sockunion_str2su (argv
[0]);
9981 peer
= peer_lookup (NULL
, su
);
9985 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
9986 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
9989 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
9990 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
9996 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter
,
9997 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
,
9998 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10003 "Address Family modifier\n"
10004 "Address Family modifier\n"
10005 "Detailed information on TCP and BGP neighbor connections\n"
10006 "Neighbor to display information about\n"
10007 "Neighbor to display information about\n"
10008 "Display information received from a BGP neighbor\n"
10009 "Display the prefixlist filter\n")
10012 union sockunion
*su
;
10016 su
= sockunion_str2su (argv
[1]);
10018 return CMD_WARNING
;
10020 peer
= peer_lookup (NULL
, su
);
10022 return CMD_WARNING
;
10024 if (strncmp (argv
[0], "m", 1) == 0)
10026 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_MULTICAST
);
10027 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
10030 vty_out (vty
, "Address family: IPv4 Multicast%s", VTY_NEWLINE
);
10031 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
10036 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
10037 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
10040 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
10041 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
10045 return CMD_SUCCESS
;
10050 ALIAS (show_bgp_view_neighbor_received_routes
,
10051 show_bgp_neighbor_received_routes_cmd
,
10052 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
10055 "Detailed information on TCP and BGP neighbor connections\n"
10056 "Neighbor to display information about\n"
10057 "Neighbor to display information about\n"
10058 "Display the received routes from neighbor\n")
10060 ALIAS (show_bgp_view_neighbor_received_routes
,
10061 show_bgp_ipv6_neighbor_received_routes_cmd
,
10062 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
10066 "Detailed information on TCP and BGP neighbor connections\n"
10067 "Neighbor to display information about\n"
10068 "Neighbor to display information about\n"
10069 "Display the received routes from neighbor\n")
10071 DEFUN (show_bgp_neighbor_received_prefix_filter
,
10072 show_bgp_neighbor_received_prefix_filter_cmd
,
10073 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10076 "Detailed information on TCP and BGP neighbor connections\n"
10077 "Neighbor to display information about\n"
10078 "Neighbor to display information about\n"
10079 "Display information received from a BGP neighbor\n"
10080 "Display the prefixlist filter\n")
10083 union sockunion
*su
;
10087 su
= sockunion_str2su (argv
[0]);
10089 return CMD_WARNING
;
10091 peer
= peer_lookup (NULL
, su
);
10093 return CMD_WARNING
;
10095 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
10096 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
);
10099 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
10100 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
);
10103 return CMD_SUCCESS
;
10106 ALIAS (show_bgp_neighbor_received_prefix_filter
,
10107 show_bgp_ipv6_neighbor_received_prefix_filter_cmd
,
10108 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
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 information received from a BGP neighbor\n"
10116 "Display the prefixlist filter\n")
10119 ALIAS (show_bgp_view_neighbor_received_routes
,
10120 ipv6_bgp_neighbor_received_routes_cmd
,
10121 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
10125 "Detailed information on TCP and BGP neighbor connections\n"
10126 "Neighbor to display information about\n"
10127 "Neighbor to display information about\n"
10128 "Display the received routes from neighbor\n")
10131 DEFUN (ipv6_mbgp_neighbor_received_routes
,
10132 ipv6_mbgp_neighbor_received_routes_cmd
,
10133 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
10137 "Detailed information on TCP and BGP neighbor connections\n"
10138 "Neighbor to display information about\n"
10139 "Neighbor to display information about\n"
10140 "Display the received routes from neighbor\n")
10144 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10146 return CMD_WARNING
;
10148 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 1);
10151 DEFUN (show_bgp_view_neighbor_received_prefix_filter
,
10152 show_bgp_view_neighbor_received_prefix_filter_cmd
,
10153 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10158 "Detailed information on TCP and BGP neighbor connections\n"
10159 "Neighbor to display information about\n"
10160 "Neighbor to display information about\n"
10161 "Display information received from a BGP neighbor\n"
10162 "Display the prefixlist filter\n")
10165 union sockunion
*su
;
10170 /* BGP structure lookup. */
10171 bgp
= bgp_lookup_by_name (argv
[0]);
10174 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10175 return CMD_WARNING
;
10178 su
= sockunion_str2su (argv
[1]);
10180 return CMD_WARNING
;
10182 peer
= peer_lookup (bgp
, su
);
10184 return CMD_WARNING
;
10186 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
10187 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
);
10190 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
10191 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
);
10194 return CMD_SUCCESS
;
10197 ALIAS (show_bgp_view_neighbor_received_prefix_filter
,
10198 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
,
10199 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10205 "Detailed information on TCP and BGP neighbor connections\n"
10206 "Neighbor to display information about\n"
10207 "Neighbor to display information about\n"
10208 "Display information received from a BGP neighbor\n"
10209 "Display the prefixlist filter\n")
10210 #endif /* HAVE_IPV6 */
10213 bgp_show_neighbor_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
,
10214 safi_t safi
, enum bgp_show_type type
)
10216 if (! peer
|| ! peer
->afc
[afi
][safi
])
10218 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
10219 return CMD_WARNING
;
10222 return bgp_show (vty
, peer
->bgp
, afi
, safi
, type
, &peer
->su
);
10225 DEFUN (show_ip_bgp_neighbor_routes
,
10226 show_ip_bgp_neighbor_routes_cmd
,
10227 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
10231 "Detailed information on TCP and BGP neighbor connections\n"
10232 "Neighbor to display information about\n"
10233 "Neighbor to display information about\n"
10234 "Display routes learned from neighbor\n")
10238 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10240 return CMD_WARNING
;
10242 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10243 bgp_show_type_neighbor
);
10246 DEFUN (show_ip_bgp_neighbor_flap
,
10247 show_ip_bgp_neighbor_flap_cmd
,
10248 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10252 "Detailed information on TCP and BGP neighbor connections\n"
10253 "Neighbor to display information about\n"
10254 "Neighbor to display information about\n"
10255 "Display flap statistics of the routes learned from neighbor\n")
10259 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10261 return CMD_WARNING
;
10263 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10264 bgp_show_type_flap_neighbor
);
10267 DEFUN (show_ip_bgp_neighbor_damp
,
10268 show_ip_bgp_neighbor_damp_cmd
,
10269 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10273 "Detailed information on TCP and BGP neighbor connections\n"
10274 "Neighbor to display information about\n"
10275 "Neighbor to display information about\n"
10276 "Display the dampened routes received from neighbor\n")
10280 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10282 return CMD_WARNING
;
10284 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10285 bgp_show_type_damp_neighbor
);
10288 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
10289 show_ip_bgp_ipv4_neighbor_routes_cmd
,
10290 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
10295 "Address Family modifier\n"
10296 "Address Family modifier\n"
10297 "Detailed information on TCP and BGP neighbor connections\n"
10298 "Neighbor to display information about\n"
10299 "Neighbor to display information about\n"
10300 "Display routes learned from neighbor\n")
10304 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
10306 return CMD_WARNING
;
10308 if (strncmp (argv
[0], "m", 1) == 0)
10309 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_MULTICAST
,
10310 bgp_show_type_neighbor
);
10312 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10313 bgp_show_type_neighbor
);
10316 DEFUN (show_ip_bgp_view_rsclient
,
10317 show_ip_bgp_view_rsclient_cmd
,
10318 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
10324 "Information about Route Server Client\n"
10327 struct bgp_table
*table
;
10331 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10333 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10336 return CMD_WARNING
;
10338 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
10340 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10342 return CMD_WARNING
;
10345 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
10346 PEER_FLAG_RSERVER_CLIENT
))
10348 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10350 return CMD_WARNING
;
10353 table
= peer
->rib
[AFI_IP
][SAFI_UNICAST
];
10355 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
10358 ALIAS (show_ip_bgp_view_rsclient
,
10359 show_ip_bgp_rsclient_cmd
,
10360 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
10364 "Information about Route Server Client\n"
10367 DEFUN (show_ip_bgp_view_rsclient_route
,
10368 show_ip_bgp_view_rsclient_route_cmd
,
10369 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
10375 "Information about Route Server Client\n"
10377 "Network in the BGP routing table to display\n")
10382 /* BGP structure lookup. */
10385 bgp
= bgp_lookup_by_name (argv
[0]);
10388 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10389 return CMD_WARNING
;
10394 bgp
= bgp_get_default ();
10397 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10398 return CMD_WARNING
;
10403 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10405 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10408 return CMD_WARNING
;
10410 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
10412 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10414 return CMD_WARNING
;
10417 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
10418 PEER_FLAG_RSERVER_CLIENT
))
10420 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10422 return CMD_WARNING
;
10425 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][SAFI_UNICAST
],
10426 (argc
== 3) ? argv
[2] : argv
[1],
10427 AFI_IP
, SAFI_UNICAST
, NULL
, 0);
10430 ALIAS (show_ip_bgp_view_rsclient_route
,
10431 show_ip_bgp_rsclient_route_cmd
,
10432 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
10436 "Information about Route Server Client\n"
10438 "Network in the BGP routing table to display\n")
10440 DEFUN (show_ip_bgp_view_rsclient_prefix
,
10441 show_ip_bgp_view_rsclient_prefix_cmd
,
10442 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
10448 "Information about Route Server Client\n"
10450 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10455 /* BGP structure lookup. */
10458 bgp
= bgp_lookup_by_name (argv
[0]);
10461 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10462 return CMD_WARNING
;
10467 bgp
= bgp_get_default ();
10470 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10471 return CMD_WARNING
;
10476 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10478 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10481 return CMD_WARNING
;
10483 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
10485 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10487 return CMD_WARNING
;
10490 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
10491 PEER_FLAG_RSERVER_CLIENT
))
10493 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10495 return CMD_WARNING
;
10498 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][SAFI_UNICAST
],
10499 (argc
== 3) ? argv
[2] : argv
[1],
10500 AFI_IP
, SAFI_UNICAST
, NULL
, 1);
10503 ALIAS (show_ip_bgp_view_rsclient_prefix
,
10504 show_ip_bgp_rsclient_prefix_cmd
,
10505 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
10509 "Information about Route Server Client\n"
10511 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10515 DEFUN (show_bgp_view_neighbor_routes
,
10516 show_bgp_view_neighbor_routes_cmd
,
10517 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
10522 "Detailed information on TCP and BGP neighbor connections\n"
10523 "Neighbor to display information about\n"
10524 "Neighbor to display information about\n"
10525 "Display routes learned from neighbor\n")
10530 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10532 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10535 return CMD_WARNING
;
10537 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
10538 bgp_show_type_neighbor
);
10541 ALIAS (show_bgp_view_neighbor_routes
,
10542 show_bgp_view_ipv6_neighbor_routes_cmd
,
10543 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
10549 "Detailed information on TCP and BGP neighbor connections\n"
10550 "Neighbor to display information about\n"
10551 "Neighbor to display information about\n"
10552 "Display routes learned from neighbor\n")
10554 DEFUN (show_bgp_view_neighbor_damp
,
10555 show_bgp_view_neighbor_damp_cmd
,
10556 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10561 "Detailed information on TCP and BGP neighbor connections\n"
10562 "Neighbor to display information about\n"
10563 "Neighbor to display information about\n"
10564 "Display the dampened routes received from neighbor\n")
10569 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10571 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10574 return CMD_WARNING
;
10576 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
10577 bgp_show_type_damp_neighbor
);
10580 ALIAS (show_bgp_view_neighbor_damp
,
10581 show_bgp_view_ipv6_neighbor_damp_cmd
,
10582 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10588 "Detailed information on TCP and BGP neighbor connections\n"
10589 "Neighbor to display information about\n"
10590 "Neighbor to display information about\n"
10591 "Display the dampened routes received from neighbor\n")
10593 DEFUN (show_bgp_view_neighbor_flap
,
10594 show_bgp_view_neighbor_flap_cmd
,
10595 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10600 "Detailed information on TCP and BGP neighbor connections\n"
10601 "Neighbor to display information about\n"
10602 "Neighbor to display information about\n"
10603 "Display flap statistics of the routes learned from neighbor\n")
10608 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10610 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10613 return CMD_WARNING
;
10615 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
10616 bgp_show_type_flap_neighbor
);
10619 ALIAS (show_bgp_view_neighbor_flap
,
10620 show_bgp_view_ipv6_neighbor_flap_cmd
,
10621 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10627 "Detailed information on TCP and BGP neighbor connections\n"
10628 "Neighbor to display information about\n"
10629 "Neighbor to display information about\n"
10630 "Display flap statistics of the routes learned from neighbor\n")
10632 ALIAS (show_bgp_view_neighbor_routes
,
10633 show_bgp_neighbor_routes_cmd
,
10634 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
10637 "Detailed information on TCP and BGP neighbor connections\n"
10638 "Neighbor to display information about\n"
10639 "Neighbor to display information about\n"
10640 "Display routes learned from neighbor\n")
10643 ALIAS (show_bgp_view_neighbor_routes
,
10644 show_bgp_ipv6_neighbor_routes_cmd
,
10645 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
10649 "Detailed information on TCP and BGP neighbor connections\n"
10650 "Neighbor to display information about\n"
10651 "Neighbor to display information about\n"
10652 "Display routes learned from neighbor\n")
10655 ALIAS (show_bgp_view_neighbor_routes
,
10656 ipv6_bgp_neighbor_routes_cmd
,
10657 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
10661 "Detailed information on TCP and BGP neighbor connections\n"
10662 "Neighbor to display information about\n"
10663 "Neighbor to display information about\n"
10664 "Display routes learned from neighbor\n")
10667 DEFUN (ipv6_mbgp_neighbor_routes
,
10668 ipv6_mbgp_neighbor_routes_cmd
,
10669 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
10673 "Detailed information on TCP and BGP neighbor connections\n"
10674 "Neighbor to display information about\n"
10675 "Neighbor to display information about\n"
10676 "Display routes learned from neighbor\n")
10680 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10682 return CMD_WARNING
;
10684 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
,
10685 bgp_show_type_neighbor
);
10688 ALIAS (show_bgp_view_neighbor_flap
,
10689 show_bgp_neighbor_flap_cmd
,
10690 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10693 "Detailed information on TCP and BGP neighbor connections\n"
10694 "Neighbor to display information about\n"
10695 "Neighbor to display information about\n"
10696 "Display flap statistics of the routes learned from neighbor\n")
10698 ALIAS (show_bgp_view_neighbor_flap
,
10699 show_bgp_ipv6_neighbor_flap_cmd
,
10700 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10704 "Detailed information on TCP and BGP neighbor connections\n"
10705 "Neighbor to display information about\n"
10706 "Neighbor to display information about\n"
10707 "Display flap statistics of the routes learned from neighbor\n")
10709 ALIAS (show_bgp_view_neighbor_damp
,
10710 show_bgp_neighbor_damp_cmd
,
10711 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10714 "Detailed information on TCP and BGP neighbor connections\n"
10715 "Neighbor to display information about\n"
10716 "Neighbor to display information about\n"
10717 "Display the dampened routes received from neighbor\n")
10719 ALIAS (show_bgp_view_neighbor_damp
,
10720 show_bgp_ipv6_neighbor_damp_cmd
,
10721 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10725 "Detailed information on TCP and BGP neighbor connections\n"
10726 "Neighbor to display information about\n"
10727 "Neighbor to display information about\n"
10728 "Display the dampened routes received from neighbor\n")
10730 DEFUN (show_bgp_view_rsclient
,
10731 show_bgp_view_rsclient_cmd
,
10732 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
10737 "Information about Route Server Client\n"
10740 struct bgp_table
*table
;
10744 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10746 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10749 return CMD_WARNING
;
10751 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
10753 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10755 return CMD_WARNING
;
10758 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
10759 PEER_FLAG_RSERVER_CLIENT
))
10761 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10763 return CMD_WARNING
;
10766 table
= peer
->rib
[AFI_IP6
][SAFI_UNICAST
];
10768 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
10771 ALIAS (show_bgp_view_rsclient
,
10772 show_bgp_rsclient_cmd
,
10773 "show bgp rsclient (A.B.C.D|X:X::X:X)",
10776 "Information about Route Server Client\n"
10779 DEFUN (show_bgp_view_rsclient_route
,
10780 show_bgp_view_rsclient_route_cmd
,
10781 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
10786 "Information about Route Server Client\n"
10788 "Network in the BGP routing table to display\n")
10793 /* BGP structure lookup. */
10796 bgp
= bgp_lookup_by_name (argv
[0]);
10799 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10800 return CMD_WARNING
;
10805 bgp
= bgp_get_default ();
10808 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10809 return CMD_WARNING
;
10814 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10816 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10819 return CMD_WARNING
;
10821 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
10823 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10825 return CMD_WARNING
;
10828 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
10829 PEER_FLAG_RSERVER_CLIENT
))
10831 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10833 return CMD_WARNING
;
10836 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][SAFI_UNICAST
],
10837 (argc
== 3) ? argv
[2] : argv
[1],
10838 AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
10841 ALIAS (show_bgp_view_rsclient_route
,
10842 show_bgp_rsclient_route_cmd
,
10843 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
10846 "Information about Route Server Client\n"
10848 "Network in the BGP routing table to display\n")
10850 DEFUN (show_bgp_view_rsclient_prefix
,
10851 show_bgp_view_rsclient_prefix_cmd
,
10852 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
10857 "Information about Route Server Client\n"
10859 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
10864 /* BGP structure lookup. */
10867 bgp
= bgp_lookup_by_name (argv
[0]);
10870 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10871 return CMD_WARNING
;
10876 bgp
= bgp_get_default ();
10879 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10880 return CMD_WARNING
;
10885 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10887 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10890 return CMD_WARNING
;
10892 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
10894 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10896 return CMD_WARNING
;
10899 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
10900 PEER_FLAG_RSERVER_CLIENT
))
10902 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10904 return CMD_WARNING
;
10907 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][SAFI_UNICAST
],
10908 (argc
== 3) ? argv
[2] : argv
[1],
10909 AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
10912 ALIAS (show_bgp_view_rsclient_prefix
,
10913 show_bgp_rsclient_prefix_cmd
,
10914 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
10917 "Information about Route Server Client\n"
10919 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
10921 #endif /* HAVE_IPV6 */
10923 struct bgp_table
*bgp_distance_table
;
10925 struct bgp_distance
10927 /* Distance value for the IP source prefix. */
10930 /* Name of the access-list to be matched. */
10934 static struct bgp_distance
*
10935 bgp_distance_new (void)
10937 return XCALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
10941 bgp_distance_free (struct bgp_distance
*bdistance
)
10943 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
10947 bgp_distance_set (struct vty
*vty
, const char *distance_str
,
10948 const char *ip_str
, const char *access_list_str
)
10951 struct prefix_ipv4 p
;
10953 struct bgp_node
*rn
;
10954 struct bgp_distance
*bdistance
;
10956 ret
= str2prefix_ipv4 (ip_str
, &p
);
10959 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
10960 return CMD_WARNING
;
10963 distance
= atoi (distance_str
);
10965 /* Get BGP distance node. */
10966 rn
= bgp_node_get (bgp_distance_table
, (struct prefix
*) &p
);
10969 bdistance
= rn
->info
;
10970 bgp_unlock_node (rn
);
10974 bdistance
= bgp_distance_new ();
10975 rn
->info
= bdistance
;
10978 /* Set distance value. */
10979 bdistance
->distance
= distance
;
10981 /* Reset access-list configuration. */
10982 if (bdistance
->access_list
)
10984 free (bdistance
->access_list
);
10985 bdistance
->access_list
= NULL
;
10987 if (access_list_str
)
10988 bdistance
->access_list
= strdup (access_list_str
);
10990 return CMD_SUCCESS
;
10994 bgp_distance_unset (struct vty
*vty
, const char *distance_str
,
10995 const char *ip_str
, const char *access_list_str
)
10998 struct prefix_ipv4 p
;
11000 struct bgp_node
*rn
;
11001 struct bgp_distance
*bdistance
;
11003 ret
= str2prefix_ipv4 (ip_str
, &p
);
11006 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
11007 return CMD_WARNING
;
11010 distance
= atoi (distance_str
);
11012 rn
= bgp_node_lookup (bgp_distance_table
, (struct prefix
*)&p
);
11015 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
11016 return CMD_WARNING
;
11019 bdistance
= rn
->info
;
11021 if (bdistance
->access_list
)
11022 free (bdistance
->access_list
);
11023 bgp_distance_free (bdistance
);
11026 bgp_unlock_node (rn
);
11027 bgp_unlock_node (rn
);
11029 return CMD_SUCCESS
;
11033 bgp_distance_reset (void)
11035 struct bgp_node
*rn
;
11036 struct bgp_distance
*bdistance
;
11038 for (rn
= bgp_table_top (bgp_distance_table
); rn
; rn
= bgp_route_next (rn
))
11039 if ((bdistance
= rn
->info
) != NULL
)
11041 if (bdistance
->access_list
)
11042 free (bdistance
->access_list
);
11043 bgp_distance_free (bdistance
);
11045 bgp_unlock_node (rn
);
11049 /* Apply BGP information to distance method. */
11051 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, struct bgp
*bgp
)
11053 struct bgp_node
*rn
;
11054 struct prefix_ipv4 q
;
11056 struct bgp_distance
*bdistance
;
11057 struct access_list
*alist
;
11058 struct bgp_static
*bgp_static
;
11063 if (p
->family
!= AF_INET
)
11066 peer
= rinfo
->peer
;
11068 if (peer
->su
.sa
.sa_family
!= AF_INET
)
11071 memset (&q
, 0, sizeof (struct prefix_ipv4
));
11072 q
.family
= AF_INET
;
11073 q
.prefix
= peer
->su
.sin
.sin_addr
;
11074 q
.prefixlen
= IPV4_MAX_BITLEN
;
11076 /* Check source address. */
11077 rn
= bgp_node_match (bgp_distance_table
, (struct prefix
*) &q
);
11080 bdistance
= rn
->info
;
11081 bgp_unlock_node (rn
);
11083 if (bdistance
->access_list
)
11085 alist
= access_list_lookup (AFI_IP
, bdistance
->access_list
);
11086 if (alist
&& access_list_apply (alist
, p
) == FILTER_PERMIT
)
11087 return bdistance
->distance
;
11090 return bdistance
->distance
;
11093 /* Backdoor check. */
11094 rn
= bgp_node_lookup (bgp
->route
[AFI_IP
][SAFI_UNICAST
], p
);
11097 bgp_static
= rn
->info
;
11098 bgp_unlock_node (rn
);
11100 if (bgp_static
->backdoor
)
11102 if (bgp
->distance_local
)
11103 return bgp
->distance_local
;
11105 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
11109 if (peer_sort (peer
) == BGP_PEER_EBGP
)
11111 if (bgp
->distance_ebgp
)
11112 return bgp
->distance_ebgp
;
11113 return ZEBRA_EBGP_DISTANCE_DEFAULT
;
11117 if (bgp
->distance_ibgp
)
11118 return bgp
->distance_ibgp
;
11119 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
11123 DEFUN (bgp_distance
,
11125 "distance bgp <1-255> <1-255> <1-255>",
11126 "Define an administrative distance\n"
11128 "Distance for routes external to the AS\n"
11129 "Distance for routes internal to the AS\n"
11130 "Distance for local routes\n")
11136 bgp
->distance_ebgp
= atoi (argv
[0]);
11137 bgp
->distance_ibgp
= atoi (argv
[1]);
11138 bgp
->distance_local
= atoi (argv
[2]);
11139 return CMD_SUCCESS
;
11142 DEFUN (no_bgp_distance
,
11143 no_bgp_distance_cmd
,
11144 "no distance bgp <1-255> <1-255> <1-255>",
11146 "Define an administrative distance\n"
11148 "Distance for routes external to the AS\n"
11149 "Distance for routes internal to the AS\n"
11150 "Distance for local routes\n")
11156 bgp
->distance_ebgp
= 0;
11157 bgp
->distance_ibgp
= 0;
11158 bgp
->distance_local
= 0;
11159 return CMD_SUCCESS
;
11162 ALIAS (no_bgp_distance
,
11163 no_bgp_distance2_cmd
,
11166 "Define an administrative distance\n"
11169 DEFUN (bgp_distance_source
,
11170 bgp_distance_source_cmd
,
11171 "distance <1-255> A.B.C.D/M",
11172 "Define an administrative distance\n"
11173 "Administrative distance\n"
11174 "IP source prefix\n")
11176 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
11177 return CMD_SUCCESS
;
11180 DEFUN (no_bgp_distance_source
,
11181 no_bgp_distance_source_cmd
,
11182 "no distance <1-255> A.B.C.D/M",
11184 "Define an administrative distance\n"
11185 "Administrative distance\n"
11186 "IP source prefix\n")
11188 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
11189 return CMD_SUCCESS
;
11192 DEFUN (bgp_distance_source_access_list
,
11193 bgp_distance_source_access_list_cmd
,
11194 "distance <1-255> A.B.C.D/M WORD",
11195 "Define an administrative distance\n"
11196 "Administrative distance\n"
11197 "IP source prefix\n"
11198 "Access list name\n")
11200 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
11201 return CMD_SUCCESS
;
11204 DEFUN (no_bgp_distance_source_access_list
,
11205 no_bgp_distance_source_access_list_cmd
,
11206 "no distance <1-255> A.B.C.D/M WORD",
11208 "Define an administrative distance\n"
11209 "Administrative distance\n"
11210 "IP source prefix\n"
11211 "Access list name\n")
11213 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
11214 return CMD_SUCCESS
;
11217 DEFUN (bgp_damp_set
,
11219 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
11220 "BGP Specific commands\n"
11221 "Enable route-flap dampening\n"
11222 "Half-life time for the penalty\n"
11223 "Value to start reusing a route\n"
11224 "Value to start suppressing a route\n"
11225 "Maximum duration to suppress a stable route\n")
11228 int half
= DEFAULT_HALF_LIFE
* 60;
11229 int reuse
= DEFAULT_REUSE
;
11230 int suppress
= DEFAULT_SUPPRESS
;
11231 int max
= 4 * half
;
11235 half
= atoi (argv
[0]) * 60;
11236 reuse
= atoi (argv
[1]);
11237 suppress
= atoi (argv
[2]);
11238 max
= atoi (argv
[3]) * 60;
11240 else if (argc
== 1)
11242 half
= atoi (argv
[0]) * 60;
11247 return bgp_damp_enable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
),
11248 half
, reuse
, suppress
, max
);
11251 ALIAS (bgp_damp_set
,
11253 "bgp dampening <1-45>",
11254 "BGP Specific commands\n"
11255 "Enable route-flap dampening\n"
11256 "Half-life time for the penalty\n")
11258 ALIAS (bgp_damp_set
,
11261 "BGP Specific commands\n"
11262 "Enable route-flap dampening\n")
11264 DEFUN (bgp_damp_unset
,
11265 bgp_damp_unset_cmd
,
11266 "no bgp dampening",
11268 "BGP Specific commands\n"
11269 "Enable route-flap dampening\n")
11274 return bgp_damp_disable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
));
11277 ALIAS (bgp_damp_unset
,
11278 bgp_damp_unset2_cmd
,
11279 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
11281 "BGP Specific commands\n"
11282 "Enable route-flap dampening\n"
11283 "Half-life time for the penalty\n"
11284 "Value to start reusing a route\n"
11285 "Value to start suppressing a route\n"
11286 "Maximum duration to suppress a stable route\n")
11288 DEFUN (show_ip_bgp_dampened_paths
,
11289 show_ip_bgp_dampened_paths_cmd
,
11290 "show ip bgp dampened-paths",
11294 "Display paths suppressed due to dampening\n")
11296 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_dampend_paths
,
11300 DEFUN (show_ip_bgp_flap_statistics
,
11301 show_ip_bgp_flap_statistics_cmd
,
11302 "show ip bgp flap-statistics",
11306 "Display flap statistics of routes\n")
11308 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
11309 bgp_show_type_flap_statistics
, NULL
);
11312 /* Display specified route of BGP table. */
11314 bgp_clear_damp_route (struct vty
*vty
, const char *view_name
,
11315 const char *ip_str
, afi_t afi
, safi_t safi
,
11316 struct prefix_rd
*prd
, int prefix_check
)
11319 struct prefix match
;
11320 struct bgp_node
*rn
;
11321 struct bgp_node
*rm
;
11322 struct bgp_info
*ri
;
11323 struct bgp_info
*ri_temp
;
11325 struct bgp_table
*table
;
11327 /* BGP structure lookup. */
11330 bgp
= bgp_lookup_by_name (view_name
);
11333 vty_out (vty
, "%% Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
11334 return CMD_WARNING
;
11339 bgp
= bgp_get_default ();
11342 vty_out (vty
, "%% No BGP process is configured%s", VTY_NEWLINE
);
11343 return CMD_WARNING
;
11347 /* Check IP address argument. */
11348 ret
= str2prefix (ip_str
, &match
);
11351 vty_out (vty
, "%% address is malformed%s", VTY_NEWLINE
);
11352 return CMD_WARNING
;
11355 match
.family
= afi2family (afi
);
11357 if (safi
== SAFI_MPLS_VPN
)
11359 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][SAFI_MPLS_VPN
]); rn
; rn
= bgp_route_next (rn
))
11361 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
11364 if ((table
= rn
->info
) != NULL
)
11365 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
11366 if (! prefix_check
|| rm
->p
.prefixlen
== match
.prefixlen
)
11371 if (ri
->extra
&& ri
->extra
->damp_info
)
11373 ri_temp
= ri
->next
;
11374 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
11385 if ((rn
= bgp_node_match (bgp
->rib
[afi
][safi
], &match
)) != NULL
)
11386 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
11391 if (ri
->extra
&& ri
->extra
->damp_info
)
11393 ri_temp
= ri
->next
;
11394 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
11403 return CMD_SUCCESS
;
11406 DEFUN (clear_ip_bgp_dampening
,
11407 clear_ip_bgp_dampening_cmd
,
11408 "clear ip bgp dampening",
11412 "Clear route flap dampening information\n")
11414 bgp_damp_info_clean ();
11415 return CMD_SUCCESS
;
11418 DEFUN (clear_ip_bgp_dampening_prefix
,
11419 clear_ip_bgp_dampening_prefix_cmd
,
11420 "clear ip bgp dampening A.B.C.D/M",
11424 "Clear route flap dampening information\n"
11425 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11427 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
11428 SAFI_UNICAST
, NULL
, 1);
11431 DEFUN (clear_ip_bgp_dampening_address
,
11432 clear_ip_bgp_dampening_address_cmd
,
11433 "clear ip bgp dampening A.B.C.D",
11437 "Clear route flap dampening information\n"
11438 "Network to clear damping information\n")
11440 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
11441 SAFI_UNICAST
, NULL
, 0);
11444 DEFUN (clear_ip_bgp_dampening_address_mask
,
11445 clear_ip_bgp_dampening_address_mask_cmd
,
11446 "clear ip bgp dampening A.B.C.D A.B.C.D",
11450 "Clear route flap dampening information\n"
11451 "Network to clear damping information\n"
11455 char prefix_str
[BUFSIZ
];
11457 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
11460 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
11461 return CMD_WARNING
;
11464 return bgp_clear_damp_route (vty
, NULL
, prefix_str
, AFI_IP
,
11465 SAFI_UNICAST
, NULL
, 0);
11469 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
11470 afi_t afi
, safi_t safi
, int *write
)
11472 struct bgp_node
*prn
;
11473 struct bgp_node
*rn
;
11474 struct bgp_table
*table
;
11476 struct prefix_rd
*prd
;
11477 struct bgp_static
*bgp_static
;
11479 char buf
[SU_ADDRSTRLEN
];
11480 char rdbuf
[RD_ADDRSTRLEN
];
11482 /* Network configuration. */
11483 for (prn
= bgp_table_top (bgp
->route
[afi
][safi
]); prn
; prn
= bgp_route_next (prn
))
11484 if ((table
= prn
->info
) != NULL
)
11485 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
11486 if ((bgp_static
= rn
->info
) != NULL
)
11489 prd
= (struct prefix_rd
*) &prn
->p
;
11491 /* "address-family" display. */
11492 bgp_config_write_family_header (vty
, afi
, safi
, write
);
11494 /* "network" configuration display. */
11495 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
11496 label
= decode_label (bgp_static
->tag
);
11498 vty_out (vty
, " network %s/%d rd %s tag %d",
11499 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
11502 vty_out (vty
, "%s", VTY_NEWLINE
);
11507 /* Configuration of static route announcement and aggregate
11510 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
11511 afi_t afi
, safi_t safi
, int *write
)
11513 struct bgp_node
*rn
;
11515 struct bgp_static
*bgp_static
;
11516 struct bgp_aggregate
*bgp_aggregate
;
11517 char buf
[SU_ADDRSTRLEN
];
11519 if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
11520 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
11522 /* Network configuration. */
11523 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
11524 if ((bgp_static
= rn
->info
) != NULL
)
11528 /* "address-family" display. */
11529 bgp_config_write_family_header (vty
, afi
, safi
, write
);
11531 /* "network" configuration display. */
11532 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
11534 u_int32_t destination
;
11535 struct in_addr netmask
;
11537 destination
= ntohl (p
->u
.prefix4
.s_addr
);
11538 masklen2ip (p
->prefixlen
, &netmask
);
11539 vty_out (vty
, " network %s",
11540 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
));
11542 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
11543 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
11544 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
11545 || p
->u
.prefix4
.s_addr
== 0)
11547 /* Natural mask is not display. */
11550 vty_out (vty
, " mask %s", inet_ntoa (netmask
));
11554 vty_out (vty
, " network %s/%d",
11555 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
11559 if (bgp_static
->rmap
.name
)
11560 vty_out (vty
, " route-map %s", bgp_static
->rmap
.name
);
11563 if (bgp_static
->backdoor
)
11564 vty_out (vty
, " backdoor");
11565 if (bgp_static
->ttl
)
11566 vty_out (vty
, " pathlimit %u", bgp_static
->ttl
);
11569 vty_out (vty
, "%s", VTY_NEWLINE
);
11572 /* Aggregate-address configuration. */
11573 for (rn
= bgp_table_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
11574 if ((bgp_aggregate
= rn
->info
) != NULL
)
11578 /* "address-family" display. */
11579 bgp_config_write_family_header (vty
, afi
, safi
, write
);
11581 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
11583 struct in_addr netmask
;
11585 masklen2ip (p
->prefixlen
, &netmask
);
11586 vty_out (vty
, " aggregate-address %s %s",
11587 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
11588 inet_ntoa (netmask
));
11592 vty_out (vty
, " aggregate-address %s/%d",
11593 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
11597 if (bgp_aggregate
->as_set
)
11598 vty_out (vty
, " as-set");
11600 if (bgp_aggregate
->summary_only
)
11601 vty_out (vty
, " summary-only");
11603 vty_out (vty
, "%s", VTY_NEWLINE
);
11610 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
)
11612 struct bgp_node
*rn
;
11613 struct bgp_distance
*bdistance
;
11615 /* Distance configuration. */
11616 if (bgp
->distance_ebgp
11617 && bgp
->distance_ibgp
11618 && bgp
->distance_local
11619 && (bgp
->distance_ebgp
!= ZEBRA_EBGP_DISTANCE_DEFAULT
11620 || bgp
->distance_ibgp
!= ZEBRA_IBGP_DISTANCE_DEFAULT
11621 || bgp
->distance_local
!= ZEBRA_IBGP_DISTANCE_DEFAULT
))
11622 vty_out (vty
, " distance bgp %d %d %d%s",
11623 bgp
->distance_ebgp
, bgp
->distance_ibgp
, bgp
->distance_local
,
11626 for (rn
= bgp_table_top (bgp_distance_table
); rn
; rn
= bgp_route_next (rn
))
11627 if ((bdistance
= rn
->info
) != NULL
)
11629 vty_out (vty
, " distance %d %s/%d %s%s", bdistance
->distance
,
11630 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
11631 bdistance
->access_list
? bdistance
->access_list
: "",
11638 /* Allocate routing table structure and install commands. */
11640 bgp_route_init (void)
11642 /* Init BGP distance table. */
11643 bgp_distance_table
= bgp_table_init (AFI_IP
, SAFI_UNICAST
);
11645 /* IPv4 BGP commands. */
11646 install_element (BGP_NODE
, &bgp_network_cmd
);
11647 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
11648 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
11649 install_element (BGP_NODE
, &bgp_network_route_map_cmd
);
11650 install_element (BGP_NODE
, &bgp_network_mask_route_map_cmd
);
11651 install_element (BGP_NODE
, &bgp_network_mask_natural_route_map_cmd
);
11652 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
11653 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
11654 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
11655 install_element (BGP_NODE
, &bgp_network_ttl_cmd
);
11656 install_element (BGP_NODE
, &bgp_network_mask_ttl_cmd
);
11657 install_element (BGP_NODE
, &bgp_network_mask_natural_ttl_cmd
);
11658 install_element (BGP_NODE
, &bgp_network_backdoor_ttl_cmd
);
11659 install_element (BGP_NODE
, &bgp_network_mask_backdoor_ttl_cmd
);
11660 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_ttl_cmd
);
11661 install_element (BGP_NODE
, &no_bgp_network_cmd
);
11662 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
11663 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
11664 install_element (BGP_NODE
, &no_bgp_network_route_map_cmd
);
11665 install_element (BGP_NODE
, &no_bgp_network_mask_route_map_cmd
);
11666 install_element (BGP_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
11667 install_element (BGP_NODE
, &no_bgp_network_backdoor_cmd
);
11668 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_cmd
);
11669 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_cmd
);
11670 install_element (BGP_NODE
, &no_bgp_network_ttl_cmd
);
11671 install_element (BGP_NODE
, &no_bgp_network_mask_ttl_cmd
);
11672 install_element (BGP_NODE
, &no_bgp_network_mask_natural_ttl_cmd
);
11673 install_element (BGP_NODE
, &no_bgp_network_backdoor_ttl_cmd
);
11674 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_ttl_cmd
);
11675 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_ttl_cmd
);
11677 install_element (BGP_NODE
, &aggregate_address_cmd
);
11678 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
11679 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
11680 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
11681 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
11682 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
11683 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
11684 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
11685 install_element (BGP_NODE
, &aggregate_address_summary_as_set_cmd
);
11686 install_element (BGP_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
11687 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
11688 install_element (BGP_NODE
, &no_aggregate_address_summary_only_cmd
);
11689 install_element (BGP_NODE
, &no_aggregate_address_as_set_cmd
);
11690 install_element (BGP_NODE
, &no_aggregate_address_as_set_summary_cmd
);
11691 install_element (BGP_NODE
, &no_aggregate_address_summary_as_set_cmd
);
11692 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
11693 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
11694 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_cmd
);
11695 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
11696 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
11698 /* IPv4 unicast configuration. */
11699 install_element (BGP_IPV4_NODE
, &bgp_network_cmd
);
11700 install_element (BGP_IPV4_NODE
, &bgp_network_mask_cmd
);
11701 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_cmd
);
11702 install_element (BGP_IPV4_NODE
, &bgp_network_route_map_cmd
);
11703 install_element (BGP_IPV4_NODE
, &bgp_network_mask_route_map_cmd
);
11704 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_route_map_cmd
);
11705 install_element (BGP_IPV4_NODE
, &bgp_network_ttl_cmd
);
11706 install_element (BGP_IPV4_NODE
, &bgp_network_mask_ttl_cmd
);
11707 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_ttl_cmd
);
11708 install_element (BGP_IPV4_NODE
, &bgp_network_backdoor_ttl_cmd
);
11709 install_element (BGP_IPV4_NODE
, &bgp_network_mask_backdoor_ttl_cmd
);
11710 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_backdoor_ttl_cmd
); install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
11711 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_cmd
);
11712 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_cmd
);
11713 install_element (BGP_IPV4_NODE
, &no_bgp_network_route_map_cmd
);
11714 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_route_map_cmd
);
11715 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
11716 install_element (BGP_IPV4_NODE
, &no_bgp_network_ttl_cmd
);
11717 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_ttl_cmd
);
11718 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_ttl_cmd
);
11719 install_element (BGP_IPV4_NODE
, &no_bgp_network_backdoor_ttl_cmd
);
11720 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_backdoor_ttl_cmd
);
11721 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_backdoor_ttl_cmd
); install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
11722 install_element (BGP_IPV4_NODE
, &aggregate_address_cmd
);
11723 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_cmd
);
11724 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_only_cmd
);
11725 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_only_cmd
);
11726 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_cmd
);
11727 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_cmd
);
11728 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_summary_cmd
);
11729 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
11730 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_as_set_cmd
);
11731 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
11732 install_element (BGP_IPV4_NODE
, &no_aggregate_address_cmd
);
11733 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_only_cmd
);
11734 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_cmd
);
11735 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_summary_cmd
);
11736 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_as_set_cmd
);
11737 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_cmd
);
11738 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
11739 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_cmd
);
11740 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
11741 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
11743 /* IPv4 multicast configuration. */
11744 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
11745 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
11746 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
11747 install_element (BGP_IPV4M_NODE
, &bgp_network_route_map_cmd
);
11748 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_route_map_cmd
);
11749 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_route_map_cmd
);
11750 install_element (BGP_IPV4M_NODE
, &bgp_network_ttl_cmd
);
11751 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_ttl_cmd
);
11752 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_ttl_cmd
);
11753 install_element (BGP_IPV4M_NODE
, &bgp_network_backdoor_ttl_cmd
);
11754 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_backdoor_ttl_cmd
);
11755 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_backdoor_ttl_cmd
); install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
11756 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
11757 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
11758 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
11759 install_element (BGP_IPV4M_NODE
, &no_bgp_network_route_map_cmd
);
11760 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_route_map_cmd
);
11761 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
11762 install_element (BGP_IPV4M_NODE
, &no_bgp_network_ttl_cmd
);
11763 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_ttl_cmd
);
11764 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_ttl_cmd
);
11765 install_element (BGP_IPV4M_NODE
, &no_bgp_network_backdoor_ttl_cmd
);
11766 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_backdoor_ttl_cmd
);
11767 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_backdoor_ttl_cmd
); install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
11768 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
11769 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
11770 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
11771 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
11772 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
11773 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
11774 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
11775 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
11776 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_as_set_cmd
);
11777 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
11778 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
11779 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_only_cmd
);
11780 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_cmd
);
11781 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_summary_cmd
);
11782 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_as_set_cmd
);
11783 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
11784 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
11785 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_cmd
);
11786 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
11787 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
11789 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
11790 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
11791 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
11792 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
11793 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
11794 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
11795 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
11796 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
11797 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
11798 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
11799 install_element (VIEW_NODE
, &show_ip_bgp_view_cmd
);
11800 install_element (VIEW_NODE
, &show_ip_bgp_view_route_cmd
);
11801 install_element (VIEW_NODE
, &show_ip_bgp_view_prefix_cmd
);
11802 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
11803 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
11804 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
11805 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
11806 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
11807 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
11808 install_element (VIEW_NODE
, &show_ip_bgp_route_map_cmd
);
11809 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
11810 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
11811 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
11812 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
11813 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
11814 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
11815 install_element (VIEW_NODE
, &show_ip_bgp_community2_cmd
);
11816 install_element (VIEW_NODE
, &show_ip_bgp_community3_cmd
);
11817 install_element (VIEW_NODE
, &show_ip_bgp_community4_cmd
);
11818 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
11819 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
11820 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
11821 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
11822 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
11823 install_element (VIEW_NODE
, &show_ip_bgp_community2_exact_cmd
);
11824 install_element (VIEW_NODE
, &show_ip_bgp_community3_exact_cmd
);
11825 install_element (VIEW_NODE
, &show_ip_bgp_community4_exact_cmd
);
11826 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
11827 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
11828 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
11829 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
11830 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
11831 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
11832 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
11833 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
11834 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
11835 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
11836 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
11837 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
11838 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
11839 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
11840 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
11841 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
11842 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
11843 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
11844 install_element (VIEW_NODE
, &show_ip_bgp_dampened_paths_cmd
);
11845 install_element (VIEW_NODE
, &show_ip_bgp_flap_statistics_cmd
);
11846 install_element (VIEW_NODE
, &show_ip_bgp_flap_address_cmd
);
11847 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_cmd
);
11848 install_element (VIEW_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
11849 install_element (VIEW_NODE
, &show_ip_bgp_flap_regexp_cmd
);
11850 install_element (VIEW_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
11851 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
11852 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
11853 install_element (VIEW_NODE
, &show_ip_bgp_flap_route_map_cmd
);
11854 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
11855 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
11856 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_cmd
);
11857 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_route_cmd
);
11858 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
11859 install_element (VIEW_NODE
, &show_ip_bgp_view_neighbor_advertised_route_cmd
);
11860 install_element (VIEW_NODE
, &show_ip_bgp_view_neighbor_received_routes_cmd
);
11861 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_cmd
);
11862 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
11863 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
11865 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
11866 install_element (RESTRICTED_NODE
, &show_ip_bgp_route_cmd
);
11867 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_route_cmd
);
11868 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
11869 install_element (RESTRICTED_NODE
, &show_ip_bgp_prefix_cmd
);
11870 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
11871 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
11872 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
11873 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_route_cmd
);
11874 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_prefix_cmd
);
11875 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_cmd
);
11876 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_cmd
);
11877 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_cmd
);
11878 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_cmd
);
11879 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_cmd
);
11880 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
11881 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
11882 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
11883 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_exact_cmd
);
11884 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_exact_cmd
);
11885 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_exact_cmd
);
11886 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_exact_cmd
);
11887 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
11888 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
11889 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
11890 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
11891 install_element (RESTRICTED_NODE
, &show_ip_bgp_rsclient_route_cmd
);
11892 install_element (RESTRICTED_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
11893 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
11894 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
11896 install_element (ENABLE_NODE
, &show_ip_bgp_cmd
);
11897 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cmd
);
11898 install_element (ENABLE_NODE
, &show_ip_bgp_route_cmd
);
11899 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_cmd
);
11900 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
11901 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
11902 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_cmd
);
11903 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
11904 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
11905 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
11906 install_element (ENABLE_NODE
, &show_ip_bgp_view_cmd
);
11907 install_element (ENABLE_NODE
, &show_ip_bgp_view_route_cmd
);
11908 install_element (ENABLE_NODE
, &show_ip_bgp_view_prefix_cmd
);
11909 install_element (ENABLE_NODE
, &show_ip_bgp_regexp_cmd
);
11910 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
11911 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_list_cmd
);
11912 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
11913 install_element (ENABLE_NODE
, &show_ip_bgp_filter_list_cmd
);
11914 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
11915 install_element (ENABLE_NODE
, &show_ip_bgp_route_map_cmd
);
11916 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
11917 install_element (ENABLE_NODE
, &show_ip_bgp_cidr_only_cmd
);
11918 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
11919 install_element (ENABLE_NODE
, &show_ip_bgp_community_all_cmd
);
11920 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
11921 install_element (ENABLE_NODE
, &show_ip_bgp_community_cmd
);
11922 install_element (ENABLE_NODE
, &show_ip_bgp_community2_cmd
);
11923 install_element (ENABLE_NODE
, &show_ip_bgp_community3_cmd
);
11924 install_element (ENABLE_NODE
, &show_ip_bgp_community4_cmd
);
11925 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_cmd
);
11926 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
11927 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
11928 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
11929 install_element (ENABLE_NODE
, &show_ip_bgp_community_exact_cmd
);
11930 install_element (ENABLE_NODE
, &show_ip_bgp_community2_exact_cmd
);
11931 install_element (ENABLE_NODE
, &show_ip_bgp_community3_exact_cmd
);
11932 install_element (ENABLE_NODE
, &show_ip_bgp_community4_exact_cmd
);
11933 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
11934 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
11935 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
11936 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
11937 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_cmd
);
11938 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
11939 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_exact_cmd
);
11940 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
11941 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_longer_cmd
);
11942 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
11943 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
11944 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
11945 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
11946 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
11947 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
11948 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
11949 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
11950 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
11951 install_element (ENABLE_NODE
, &show_ip_bgp_dampened_paths_cmd
);
11952 install_element (ENABLE_NODE
, &show_ip_bgp_flap_statistics_cmd
);
11953 install_element (ENABLE_NODE
, &show_ip_bgp_flap_address_cmd
);
11954 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_cmd
);
11955 install_element (ENABLE_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
11956 install_element (ENABLE_NODE
, &show_ip_bgp_flap_regexp_cmd
);
11957 install_element (ENABLE_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
11958 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
11959 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
11960 install_element (ENABLE_NODE
, &show_ip_bgp_flap_route_map_cmd
);
11961 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
11962 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
11963 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_cmd
);
11964 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_route_cmd
);
11965 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
11966 install_element (ENABLE_NODE
, &show_ip_bgp_view_neighbor_advertised_route_cmd
);
11967 install_element (ENABLE_NODE
, &show_ip_bgp_view_neighbor_received_routes_cmd
);
11968 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_cmd
);
11969 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
11970 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
11972 /* BGP dampening clear commands */
11973 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_cmd
);
11974 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_prefix_cmd
);
11975 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_cmd
);
11976 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_mask_cmd
);
11979 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_prefix_counts_cmd
);
11980 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
);
11981 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
);
11983 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_prefix_counts_cmd
);
11985 /* New config IPv6 BGP commands. */
11986 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
11987 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_route_map_cmd
);
11988 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_ttl_cmd
);
11989 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
11990 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_route_map_cmd
);
11991 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_ttl_cmd
);
11993 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
11994 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
11995 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
11996 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
11998 /* Old config IPv6 BGP commands. */
11999 install_element (BGP_NODE
, &old_ipv6_bgp_network_cmd
);
12000 install_element (BGP_NODE
, &old_no_ipv6_bgp_network_cmd
);
12002 install_element (BGP_NODE
, &old_ipv6_aggregate_address_cmd
);
12003 install_element (BGP_NODE
, &old_ipv6_aggregate_address_summary_only_cmd
);
12004 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_cmd
);
12005 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_summary_only_cmd
);
12007 install_element (VIEW_NODE
, &show_bgp_cmd
);
12008 install_element (VIEW_NODE
, &show_bgp_ipv6_cmd
);
12009 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
12010 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
12011 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
12012 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
12013 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
12014 install_element (VIEW_NODE
, &show_bgp_ipv6_regexp_cmd
);
12015 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
12016 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
12017 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
12018 install_element (VIEW_NODE
, &show_bgp_ipv6_filter_list_cmd
);
12019 install_element (VIEW_NODE
, &show_bgp_route_map_cmd
);
12020 install_element (VIEW_NODE
, &show_bgp_ipv6_route_map_cmd
);
12021 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
12022 install_element (VIEW_NODE
, &show_bgp_ipv6_community_all_cmd
);
12023 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
12024 install_element (VIEW_NODE
, &show_bgp_ipv6_community_cmd
);
12025 install_element (VIEW_NODE
, &show_bgp_community2_cmd
);
12026 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_cmd
);
12027 install_element (VIEW_NODE
, &show_bgp_community3_cmd
);
12028 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_cmd
);
12029 install_element (VIEW_NODE
, &show_bgp_community4_cmd
);
12030 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_cmd
);
12031 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
12032 install_element (VIEW_NODE
, &show_bgp_ipv6_community_exact_cmd
);
12033 install_element (VIEW_NODE
, &show_bgp_community2_exact_cmd
);
12034 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
12035 install_element (VIEW_NODE
, &show_bgp_community3_exact_cmd
);
12036 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
12037 install_element (VIEW_NODE
, &show_bgp_community4_exact_cmd
);
12038 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
12039 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
12040 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_cmd
);
12041 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
12042 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
12043 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
12044 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
12045 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
12046 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
12047 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
12048 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
12049 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
12050 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
12051 install_element (VIEW_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
12052 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
12053 install_element (VIEW_NODE
, &show_bgp_neighbor_flap_cmd
);
12054 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
12055 install_element (VIEW_NODE
, &show_bgp_neighbor_damp_cmd
);
12056 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
12057 install_element (VIEW_NODE
, &show_bgp_rsclient_cmd
);
12058 install_element (VIEW_NODE
, &show_bgp_rsclient_route_cmd
);
12059 install_element (VIEW_NODE
, &show_bgp_rsclient_prefix_cmd
);
12060 install_element (VIEW_NODE
, &show_bgp_view_cmd
);
12061 install_element (VIEW_NODE
, &show_bgp_view_ipv6_cmd
);
12062 install_element (VIEW_NODE
, &show_bgp_view_route_cmd
);
12063 install_element (VIEW_NODE
, &show_bgp_view_ipv6_route_cmd
);
12064 install_element (VIEW_NODE
, &show_bgp_view_prefix_cmd
);
12065 install_element (VIEW_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
12066 install_element (VIEW_NODE
, &show_bgp_view_neighbor_advertised_route_cmd
);
12067 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_advertised_route_cmd
);
12068 install_element (VIEW_NODE
, &show_bgp_view_neighbor_received_routes_cmd
);
12069 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_received_routes_cmd
);
12070 install_element (VIEW_NODE
, &show_bgp_view_neighbor_routes_cmd
);
12071 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_routes_cmd
);
12072 install_element (VIEW_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
12073 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
12074 install_element (VIEW_NODE
, &show_bgp_view_neighbor_flap_cmd
);
12075 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_flap_cmd
);
12076 install_element (VIEW_NODE
, &show_bgp_view_neighbor_damp_cmd
);
12077 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_damp_cmd
);
12078 install_element (VIEW_NODE
, &show_bgp_view_rsclient_cmd
);
12079 install_element (VIEW_NODE
, &show_bgp_view_rsclient_route_cmd
);
12080 install_element (VIEW_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
12083 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
12085 install_element (RESTRICTED_NODE
, &show_bgp_route_cmd
);
12086 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_route_cmd
);
12087 install_element (RESTRICTED_NODE
, &show_bgp_prefix_cmd
);
12088 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_prefix_cmd
);
12089 install_element (RESTRICTED_NODE
, &show_bgp_community_cmd
);
12090 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_cmd
);
12091 install_element (RESTRICTED_NODE
, &show_bgp_community2_cmd
);
12092 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_cmd
);
12093 install_element (RESTRICTED_NODE
, &show_bgp_community3_cmd
);
12094 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_cmd
);
12095 install_element (RESTRICTED_NODE
, &show_bgp_community4_cmd
);
12096 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_cmd
);
12097 install_element (RESTRICTED_NODE
, &show_bgp_community_exact_cmd
);
12098 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_exact_cmd
);
12099 install_element (RESTRICTED_NODE
, &show_bgp_community2_exact_cmd
);
12100 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
12101 install_element (RESTRICTED_NODE
, &show_bgp_community3_exact_cmd
);
12102 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
12103 install_element (RESTRICTED_NODE
, &show_bgp_community4_exact_cmd
);
12104 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
12105 install_element (RESTRICTED_NODE
, &show_bgp_rsclient_route_cmd
);
12106 install_element (RESTRICTED_NODE
, &show_bgp_rsclient_prefix_cmd
);
12107 install_element (RESTRICTED_NODE
, &show_bgp_view_route_cmd
);
12108 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_route_cmd
);
12109 install_element (RESTRICTED_NODE
, &show_bgp_view_prefix_cmd
);
12110 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
12111 install_element (RESTRICTED_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
12112 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
12113 install_element (RESTRICTED_NODE
, &show_bgp_view_rsclient_route_cmd
);
12114 install_element (RESTRICTED_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
12116 install_element (ENABLE_NODE
, &show_bgp_cmd
);
12117 install_element (ENABLE_NODE
, &show_bgp_ipv6_cmd
);
12118 install_element (ENABLE_NODE
, &show_bgp_route_cmd
);
12119 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_cmd
);
12120 install_element (ENABLE_NODE
, &show_bgp_prefix_cmd
);
12121 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_cmd
);
12122 install_element (ENABLE_NODE
, &show_bgp_regexp_cmd
);
12123 install_element (ENABLE_NODE
, &show_bgp_ipv6_regexp_cmd
);
12124 install_element (ENABLE_NODE
, &show_bgp_prefix_list_cmd
);
12125 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
12126 install_element (ENABLE_NODE
, &show_bgp_filter_list_cmd
);
12127 install_element (ENABLE_NODE
, &show_bgp_ipv6_filter_list_cmd
);
12128 install_element (ENABLE_NODE
, &show_bgp_route_map_cmd
);
12129 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_map_cmd
);
12130 install_element (ENABLE_NODE
, &show_bgp_community_all_cmd
);
12131 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_all_cmd
);
12132 install_element (ENABLE_NODE
, &show_bgp_community_cmd
);
12133 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_cmd
);
12134 install_element (ENABLE_NODE
, &show_bgp_community2_cmd
);
12135 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_cmd
);
12136 install_element (ENABLE_NODE
, &show_bgp_community3_cmd
);
12137 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_cmd
);
12138 install_element (ENABLE_NODE
, &show_bgp_community4_cmd
);
12139 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_cmd
);
12140 install_element (ENABLE_NODE
, &show_bgp_community_exact_cmd
);
12141 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_exact_cmd
);
12142 install_element (ENABLE_NODE
, &show_bgp_community2_exact_cmd
);
12143 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
12144 install_element (ENABLE_NODE
, &show_bgp_community3_exact_cmd
);
12145 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
12146 install_element (ENABLE_NODE
, &show_bgp_community4_exact_cmd
);
12147 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
12148 install_element (ENABLE_NODE
, &show_bgp_community_list_cmd
);
12149 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_cmd
);
12150 install_element (ENABLE_NODE
, &show_bgp_community_list_exact_cmd
);
12151 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
12152 install_element (ENABLE_NODE
, &show_bgp_prefix_longer_cmd
);
12153 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
12154 install_element (ENABLE_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
12155 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
12156 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_routes_cmd
);
12157 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
12158 install_element (ENABLE_NODE
, &show_bgp_neighbor_routes_cmd
);
12159 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
12160 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
12161 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
12162 install_element (ENABLE_NODE
, &show_bgp_neighbor_flap_cmd
);
12163 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
12164 install_element (ENABLE_NODE
, &show_bgp_neighbor_damp_cmd
);
12165 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
12166 install_element (ENABLE_NODE
, &show_bgp_rsclient_cmd
);
12167 install_element (ENABLE_NODE
, &show_bgp_rsclient_route_cmd
);
12168 install_element (ENABLE_NODE
, &show_bgp_rsclient_prefix_cmd
);
12169 install_element (ENABLE_NODE
, &show_bgp_view_cmd
);
12170 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_cmd
);
12171 install_element (ENABLE_NODE
, &show_bgp_view_route_cmd
);
12172 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_route_cmd
);
12173 install_element (ENABLE_NODE
, &show_bgp_view_prefix_cmd
);
12174 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
12175 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_advertised_route_cmd
);
12176 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_advertised_route_cmd
);
12177 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_received_routes_cmd
);
12178 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_received_routes_cmd
);
12179 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_routes_cmd
);
12180 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_routes_cmd
);
12181 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
12182 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
12183 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_flap_cmd
);
12184 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_flap_cmd
);
12185 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_damp_cmd
);
12186 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_damp_cmd
);
12187 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_cmd
);
12188 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_route_cmd
);
12189 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
12192 install_element (ENABLE_NODE
, &show_bgp_statistics_cmd
);
12193 install_element (ENABLE_NODE
, &show_bgp_statistics_vpnv4_cmd
);
12194 install_element (ENABLE_NODE
, &show_bgp_statistics_view_cmd
);
12195 install_element (ENABLE_NODE
, &show_bgp_statistics_view_vpnv4_cmd
);
12198 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
12199 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
12200 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
12201 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
12202 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
12203 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
12204 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
12205 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
12206 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_cmd
);
12207 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_cmd
);
12208 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_cmd
);
12209 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
12210 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
12211 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
12212 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
12213 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
12214 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
12215 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
12216 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
12217 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
12218 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
12219 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
12220 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
12221 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
12222 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
12223 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
12224 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_cmd
);
12225 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_cmd
);
12226 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_cmd
);
12227 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
12228 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
12229 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
12230 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
12231 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
12232 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
12233 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
12236 install_element (ENABLE_NODE
, &show_ipv6_bgp_cmd
);
12237 install_element (ENABLE_NODE
, &show_ipv6_bgp_route_cmd
);
12238 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_cmd
);
12239 install_element (ENABLE_NODE
, &show_ipv6_bgp_regexp_cmd
);
12240 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
12241 install_element (ENABLE_NODE
, &show_ipv6_bgp_filter_list_cmd
);
12242 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_all_cmd
);
12243 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_cmd
);
12244 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_cmd
);
12245 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_cmd
);
12246 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_cmd
);
12247 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_exact_cmd
);
12248 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
12249 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
12250 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
12251 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_cmd
);
12252 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
12253 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
12254 install_element (ENABLE_NODE
, &show_ipv6_mbgp_cmd
);
12255 install_element (ENABLE_NODE
, &show_ipv6_mbgp_route_cmd
);
12256 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_cmd
);
12257 install_element (ENABLE_NODE
, &show_ipv6_mbgp_regexp_cmd
);
12258 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
12259 install_element (ENABLE_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
12260 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_all_cmd
);
12261 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_cmd
);
12262 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_cmd
);
12263 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_cmd
);
12264 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_cmd
);
12265 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
12266 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
12267 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
12268 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
12269 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_cmd
);
12270 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
12271 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
12274 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
12275 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
12276 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
12277 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
12280 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
12281 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
12282 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
12283 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
12286 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
12287 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
12288 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
12289 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
12290 #endif /* HAVE_IPV6 */
12292 install_element (BGP_NODE
, &bgp_distance_cmd
);
12293 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
12294 install_element (BGP_NODE
, &no_bgp_distance2_cmd
);
12295 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
12296 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
12297 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
12298 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
12300 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
12301 install_element (BGP_NODE
, &bgp_damp_set2_cmd
);
12302 install_element (BGP_NODE
, &bgp_damp_set3_cmd
);
12303 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
12304 install_element (BGP_NODE
, &bgp_damp_unset2_cmd
);
12305 install_element (BGP_IPV4_NODE
, &bgp_damp_set_cmd
);
12306 install_element (BGP_IPV4_NODE
, &bgp_damp_set2_cmd
);
12307 install_element (BGP_IPV4_NODE
, &bgp_damp_set3_cmd
);
12308 install_element (BGP_IPV4_NODE
, &bgp_damp_unset_cmd
);
12309 install_element (BGP_IPV4_NODE
, &bgp_damp_unset2_cmd
);
12313 bgp_route_finish (void)
12315 bgp_table_unlock (bgp_distance_table
);
12316 bgp_distance_table
= NULL
;