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
= bgp_clock ();
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
= bgp_clock ();
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
= bgp_clock ();
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_CONFED
2251 || (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)
2252 || CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)))
2254 if (bgp_nexthop_lookup (afi
, peer
, ri
, NULL
, NULL
))
2255 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2257 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
2260 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2262 /* Process change. */
2263 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2265 bgp_process (bgp
, rn
, afi
, safi
);
2266 bgp_unlock_node (rn
);
2267 bgp_attr_extra_free (&new_attr
);
2272 /* Received Logging. */
2273 if (BGP_DEBUG (update
, UPDATE_IN
))
2275 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2277 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2281 /* Make new BGP info. */
2282 new = bgp_info_new ();
2284 new->sub_type
= sub_type
;
2286 new->attr
= attr_new
;
2287 new->uptime
= bgp_clock ();
2289 /* Update MPLS tag. */
2290 if (safi
== SAFI_MPLS_VPN
)
2291 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
2293 /* Nexthop reachability check. */
2294 if ((afi
== AFI_IP
|| afi
== AFI_IP6
)
2295 && safi
== SAFI_UNICAST
2296 && (peer_sort (peer
) == BGP_PEER_IBGP
2297 || peer_sort (peer
) == BGP_PEER_CONFED
2298 || (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)
2299 || CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)))
2301 if (bgp_nexthop_lookup (afi
, peer
, new, NULL
, NULL
))
2302 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2304 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
2307 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2309 /* Increment prefix */
2310 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
2312 /* Register new BGP information. */
2313 bgp_info_add (rn
, new);
2315 /* route_node_get lock */
2316 bgp_unlock_node (rn
);
2318 bgp_attr_extra_free (&new_attr
);
2320 /* If maximum prefix count is configured and current prefix
2322 if (bgp_maximum_prefix_overflow (peer
, afi
, safi
, 0))
2325 /* Process change. */
2326 bgp_process (bgp
, rn
, afi
, safi
);
2330 /* This BGP update is filtered. Log the reason then update BGP
2333 if (BGP_DEBUG (update
, UPDATE_IN
))
2334 zlog (peer
->log
, LOG_DEBUG
,
2335 "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
2337 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2338 p
->prefixlen
, reason
);
2341 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2343 bgp_unlock_node (rn
);
2345 bgp_attr_extra_free (&new_attr
);
2351 bgp_update (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
2352 afi_t afi
, safi_t safi
, int type
, int sub_type
,
2353 struct prefix_rd
*prd
, u_char
*tag
, int soft_reconfig
)
2355 struct peer
*rsclient
;
2356 struct listnode
*node
, *nnode
;
2360 ret
= bgp_update_main (peer
, p
, attr
, afi
, safi
, type
, sub_type
, prd
, tag
,
2365 /* Process the update for each RS-client. */
2366 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
2368 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2369 bgp_update_rsclient (rsclient
, afi
, safi
, attr
, peer
, p
, type
,
2370 sub_type
, prd
, tag
);
2377 bgp_withdraw (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
2378 afi_t afi
, safi_t safi
, int type
, int sub_type
,
2379 struct prefix_rd
*prd
, u_char
*tag
)
2382 char buf
[SU_ADDRSTRLEN
];
2383 struct bgp_node
*rn
;
2384 struct bgp_info
*ri
;
2385 struct peer
*rsclient
;
2386 struct listnode
*node
, *nnode
;
2390 /* Process the withdraw for each RS-client. */
2391 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
2393 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2394 bgp_withdraw_rsclient (rsclient
, afi
, safi
, peer
, p
, type
, sub_type
, prd
, tag
);
2398 if (BGP_DEBUG (update
, UPDATE_IN
))
2399 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd UPDATE about %s/%d -- withdrawn",
2401 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2405 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2407 /* If peer is soft reconfiguration enabled. Record input packet for
2408 further calculation. */
2409 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2410 && peer
!= bgp
->peer_self
)
2411 bgp_adj_in_unset (rn
, peer
);
2413 /* Lookup withdrawn route. */
2414 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2415 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
2418 /* Withdraw specified route from routing table. */
2419 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2420 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
2421 else if (BGP_DEBUG (update
, UPDATE_IN
))
2422 zlog (peer
->log
, LOG_DEBUG
,
2423 "%s Can't find the route %s/%d", peer
->host
,
2424 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2427 /* Unlock bgp_node_get() lock. */
2428 bgp_unlock_node (rn
);
2434 bgp_default_originate (struct peer
*peer
, afi_t afi
, safi_t safi
, int withdraw
)
2437 struct attr attr
= { 0 };
2438 struct aspath
*aspath
= { 0 };
2440 struct bgp_info binfo
;
2442 int ret
= RMAP_DENYMATCH
;
2444 if (!(afi
== AFI_IP
|| afi
== AFI_IP6
))
2448 from
= bgp
->peer_self
;
2450 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
2451 aspath
= attr
.aspath
;
2452 attr
.local_pref
= bgp
->default_local_pref
;
2453 memcpy (&attr
.nexthop
, &peer
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
2456 str2prefix ("0.0.0.0/0", &p
);
2458 else if (afi
== AFI_IP6
)
2460 struct attr_extra
*ae
;
2463 ae
= bgp_attr_extra_get (&attr
);
2466 str2prefix ("::/0", &p
);
2468 /* IPv6 global nexthop must be included. */
2469 memcpy (&ae
->mp_nexthop_global
, &peer
->nexthop
.v6_global
,
2471 ae
->mp_nexthop_len
= 16;
2473 /* If the peer is on shared nextwork and we have link-local
2475 if (peer
->shared_network
2476 && !IN6_IS_ADDR_UNSPECIFIED (&peer
->nexthop
.v6_local
))
2478 memcpy (&ae
->mp_nexthop_local
, &peer
->nexthop
.v6_local
,
2480 ae
->mp_nexthop_len
= 32;
2483 #endif /* HAVE_IPV6 */
2485 if (peer
->default_rmap
[afi
][safi
].name
)
2487 binfo
.peer
= bgp
->peer_self
;
2490 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_DEFAULT
);
2492 ret
= route_map_apply (peer
->default_rmap
[afi
][safi
].map
, &p
,
2495 bgp
->peer_self
->rmap_type
= 0;
2497 if (ret
== RMAP_DENYMATCH
)
2499 bgp_attr_flush (&attr
);
2506 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
))
2507 bgp_default_withdraw_send (peer
, afi
, safi
);
2508 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
);
2512 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
);
2513 bgp_default_update_send (peer
, &attr
, afi
, safi
, from
);
2516 bgp_attr_extra_free (&attr
);
2517 aspath_unintern (aspath
);
2521 bgp_announce_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2522 struct bgp_table
*table
, int rsclient
)
2524 struct bgp_node
*rn
;
2525 struct bgp_info
*ri
;
2526 struct attr attr
= { 0 };
2529 table
= (rsclient
) ? peer
->rib
[afi
][safi
] : peer
->bgp
->rib
[afi
][safi
];
2531 if (safi
!= SAFI_MPLS_VPN
2532 && CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_DEFAULT_ORIGINATE
))
2533 bgp_default_originate (peer
, afi
, safi
, 0);
2535 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next(rn
))
2536 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2537 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
) && ri
->peer
!= peer
)
2540 (bgp_announce_check_rsclient (ri
, peer
, &rn
->p
, &attr
, afi
, safi
))
2541 : (bgp_announce_check (ri
, peer
, &rn
->p
, &attr
, afi
, safi
)))
2542 bgp_adj_out_set (rn
, peer
, &rn
->p
, &attr
, afi
, safi
, ri
);
2544 bgp_adj_out_unset (rn
, peer
, &rn
->p
, afi
, safi
);
2546 bgp_attr_extra_free (&attr
);
2551 bgp_announce_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2553 struct bgp_node
*rn
;
2554 struct bgp_table
*table
;
2556 if (peer
->status
!= Established
)
2559 if (! peer
->afc_nego
[afi
][safi
])
2562 /* First update is deferred until ORF or ROUTE-REFRESH is received */
2563 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_ORF_WAIT_REFRESH
))
2566 if (safi
!= SAFI_MPLS_VPN
)
2567 bgp_announce_table (peer
, afi
, safi
, NULL
, 0);
2569 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2570 rn
= bgp_route_next(rn
))
2571 if ((table
= (rn
->info
)) != NULL
)
2572 bgp_announce_table (peer
, afi
, safi
, table
, 0);
2574 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2575 bgp_announce_table (peer
, afi
, safi
, NULL
, 1);
2579 bgp_announce_route_all (struct peer
*peer
)
2584 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2585 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2586 bgp_announce_route (peer
, afi
, safi
);
2590 bgp_soft_reconfig_table_rsclient (struct peer
*rsclient
, afi_t afi
,
2591 safi_t safi
, struct bgp_table
*table
)
2593 struct bgp_node
*rn
;
2594 struct bgp_adj_in
*ain
;
2597 table
= rsclient
->bgp
->rib
[afi
][safi
];
2599 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2600 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2602 bgp_update_rsclient (rsclient
, afi
, safi
, ain
->attr
, ain
->peer
,
2603 &rn
->p
, ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
2608 bgp_soft_reconfig_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
)
2610 struct bgp_table
*table
;
2611 struct bgp_node
*rn
;
2613 if (safi
!= SAFI_MPLS_VPN
)
2614 bgp_soft_reconfig_table_rsclient (rsclient
, afi
, safi
, NULL
);
2617 for (rn
= bgp_table_top (rsclient
->bgp
->rib
[afi
][safi
]); rn
;
2618 rn
= bgp_route_next (rn
))
2619 if ((table
= rn
->info
) != NULL
)
2620 bgp_soft_reconfig_table_rsclient (rsclient
, afi
, safi
, table
);
2624 bgp_soft_reconfig_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2625 struct bgp_table
*table
)
2628 struct bgp_node
*rn
;
2629 struct bgp_adj_in
*ain
;
2632 table
= peer
->bgp
->rib
[afi
][safi
];
2634 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2635 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2637 if (ain
->peer
== peer
)
2639 ret
= bgp_update (peer
, &rn
->p
, ain
->attr
, afi
, safi
,
2640 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
,
2644 bgp_unlock_node (rn
);
2653 bgp_soft_reconfig_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2655 struct bgp_node
*rn
;
2656 struct bgp_table
*table
;
2658 if (peer
->status
!= Established
)
2661 if (safi
!= SAFI_MPLS_VPN
)
2662 bgp_soft_reconfig_table (peer
, afi
, safi
, NULL
);
2664 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2665 rn
= bgp_route_next (rn
))
2666 if ((table
= rn
->info
) != NULL
)
2667 bgp_soft_reconfig_table (peer
, afi
, safi
, table
);
2671 struct bgp_clear_node_queue
2673 struct bgp_node
*rn
;
2674 enum bgp_clear_route_type purpose
;
2677 static wq_item_status
2678 bgp_clear_route_node (struct work_queue
*wq
, void *data
)
2680 struct bgp_clear_node_queue
*cnq
= data
;
2681 struct bgp_node
*rn
= cnq
->rn
;
2682 struct peer
*peer
= wq
->spec
.data
;
2683 struct bgp_info
*ri
;
2684 afi_t afi
= rn
->table
->afi
;
2685 safi_t safi
= rn
->table
->safi
;
2687 assert (rn
&& peer
);
2689 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2690 if (ri
->peer
== peer
|| cnq
->purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2692 /* graceful restart STALE flag set. */
2693 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_NSF_WAIT
)
2694 && peer
->nsf
[afi
][safi
]
2695 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
)
2696 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
2697 bgp_info_set_flag (rn
, ri
, BGP_INFO_STALE
);
2699 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2706 bgp_clear_node_queue_del (struct work_queue
*wq
, void *data
)
2708 struct bgp_clear_node_queue
*cnq
= data
;
2709 struct bgp_node
*rn
= cnq
->rn
;
2710 struct bgp_table
*table
= rn
->table
;
2712 bgp_unlock_node (rn
);
2713 bgp_table_unlock (table
);
2714 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE
, cnq
);
2718 bgp_clear_node_complete (struct work_queue
*wq
)
2720 struct peer
*peer
= wq
->spec
.data
;
2722 /* Tickle FSM to start moving again */
2723 BGP_EVENT_ADD (peer
, Clearing_Completed
);
2725 peer_unlock (peer
); /* bgp_clear_route */
2729 bgp_clear_node_queue_init (struct peer
*peer
)
2731 char wname
[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
2733 snprintf (wname
, sizeof(wname
), "clear %s", peer
->host
);
2734 #undef CLEAR_QUEUE_NAME_LEN
2736 if ( (peer
->clear_node_queue
= work_queue_new (bm
->master
, wname
)) == NULL
)
2738 zlog_err ("%s: Failed to allocate work queue", __func__
);
2741 peer
->clear_node_queue
->spec
.hold
= 10;
2742 peer
->clear_node_queue
->spec
.workfunc
= &bgp_clear_route_node
;
2743 peer
->clear_node_queue
->spec
.del_item_data
= &bgp_clear_node_queue_del
;
2744 peer
->clear_node_queue
->spec
.completion_func
= &bgp_clear_node_complete
;
2745 peer
->clear_node_queue
->spec
.max_retries
= 0;
2747 /* we only 'lock' this peer reference when the queue is actually active */
2748 peer
->clear_node_queue
->spec
.data
= peer
;
2752 bgp_clear_route_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2753 struct bgp_table
*table
, struct peer
*rsclient
,
2754 enum bgp_clear_route_type purpose
)
2756 struct bgp_node
*rn
;
2760 table
= (rsclient
) ? rsclient
->rib
[afi
][safi
] : peer
->bgp
->rib
[afi
][safi
];
2762 /* If still no table => afi/safi isn't configured at all or smth. */
2766 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2768 struct bgp_info
*ri
;
2769 struct bgp_adj_in
*ain
;
2770 struct bgp_adj_out
*aout
;
2772 if (rn
->info
== NULL
)
2775 /* XXX:TODO: This is suboptimal, every non-empty route_node is
2776 * queued for every clearing peer, regardless of whether it is
2777 * relevant to the peer at hand.
2779 * Overview: There are 3 different indices which need to be
2780 * scrubbed, potentially, when a peer is removed:
2782 * 1 peer's routes visible via the RIB (ie accepted routes)
2783 * 2 peer's routes visible by the (optional) peer's adj-in index
2784 * 3 other routes visible by the peer's adj-out index
2786 * 3 there is no hurry in scrubbing, once the struct peer is
2787 * removed from bgp->peer, we could just GC such deleted peer's
2788 * adj-outs at our leisure.
2790 * 1 and 2 must be 'scrubbed' in some way, at least made
2791 * invisible via RIB index before peer session is allowed to be
2792 * brought back up. So one needs to know when such a 'search' is
2797 * - there'd be a single global queue or a single RIB walker
2798 * - rather than tracking which route_nodes still need to be
2799 * examined on a peer basis, we'd track which peers still
2802 * Given that our per-peer prefix-counts now should be reliable,
2803 * this may actually be achievable. It doesn't seem to be a huge
2804 * problem at this time,
2806 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2807 if (ri
->peer
== peer
|| purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2809 struct bgp_clear_node_queue
*cnq
;
2811 /* both unlocked in bgp_clear_node_queue_del */
2812 bgp_table_lock (rn
->table
);
2814 cnq
= XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE
,
2815 sizeof (struct bgp_clear_node_queue
));
2817 cnq
->purpose
= purpose
;
2818 work_queue_add (peer
->clear_node_queue
, cnq
);
2822 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2823 if (ain
->peer
== peer
|| purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2825 bgp_adj_in_remove (rn
, ain
);
2826 bgp_unlock_node (rn
);
2829 for (aout
= rn
->adj_out
; aout
; aout
= aout
->next
)
2830 if (aout
->peer
== peer
|| purpose
== BGP_CLEAR_ROUTE_MY_RSCLIENT
)
2832 bgp_adj_out_remove (rn
, aout
, peer
, afi
, safi
);
2833 bgp_unlock_node (rn
);
2841 bgp_clear_route (struct peer
*peer
, afi_t afi
, safi_t safi
,
2842 enum bgp_clear_route_type purpose
)
2844 struct bgp_node
*rn
;
2845 struct bgp_table
*table
;
2846 struct peer
*rsclient
;
2847 struct listnode
*node
, *nnode
;
2849 if (peer
->clear_node_queue
== NULL
)
2850 bgp_clear_node_queue_init (peer
);
2852 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
2853 * Idle until it receives a Clearing_Completed event. This protects
2854 * against peers which flap faster than we can we clear, which could
2857 * a) race with routes from the new session being installed before
2858 * clear_route_node visits the node (to delete the route of that
2860 * b) resource exhaustion, clear_route_node likely leads to an entry
2861 * on the process_main queue. Fast-flapping could cause that queue
2864 if (!peer
->clear_node_queue
->thread
)
2865 peer_lock (peer
); /* bgp_clear_node_complete */
2869 case BGP_CLEAR_ROUTE_NORMAL
:
2870 if (safi
!= SAFI_MPLS_VPN
)
2871 bgp_clear_route_table (peer
, afi
, safi
, NULL
, NULL
, purpose
);
2873 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2874 rn
= bgp_route_next (rn
))
2875 if ((table
= rn
->info
) != NULL
)
2876 bgp_clear_route_table (peer
, afi
, safi
, table
, NULL
, purpose
);
2878 for (ALL_LIST_ELEMENTS (peer
->bgp
->rsclient
, node
, nnode
, rsclient
))
2879 if (CHECK_FLAG(rsclient
->af_flags
[afi
][safi
],
2880 PEER_FLAG_RSERVER_CLIENT
))
2881 bgp_clear_route_table (peer
, afi
, safi
, NULL
, rsclient
, purpose
);
2884 case BGP_CLEAR_ROUTE_MY_RSCLIENT
:
2885 bgp_clear_route_table (peer
, afi
, safi
, NULL
, peer
, purpose
);
2893 /* If no routes were cleared, nothing was added to workqueue, the
2894 * completion function won't be run by workqueue code - call it here.
2895 * XXX: Actually, this assumption doesn't hold, see
2896 * bgp_clear_route_table(), we queue all non-empty nodes.
2898 * Additionally, there is a presumption in FSM that clearing is only
2899 * really needed if peer state is Established - peers in
2900 * pre-Established states shouldn't have any route-update state
2901 * associated with them (in or out).
2903 * We still can get here in pre-Established though, through
2904 * peer_delete -> bgp_fsm_change_status, so this is a useful sanity
2905 * check to ensure the assumption above holds.
2907 * At some future point, this check could be move to the top of the
2908 * function, and do a quick early-return when state is
2909 * pre-Established, avoiding above list and table scans. Once we're
2912 if (!peer
->clear_node_queue
->thread
)
2913 bgp_clear_node_complete (peer
->clear_node_queue
);
2917 bgp_clear_route_all (struct peer
*peer
)
2922 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2923 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2924 bgp_clear_route (peer
, afi
, safi
, BGP_CLEAR_ROUTE_NORMAL
);
2928 bgp_clear_adj_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2930 struct bgp_table
*table
;
2931 struct bgp_node
*rn
;
2932 struct bgp_adj_in
*ain
;
2934 table
= peer
->bgp
->rib
[afi
][safi
];
2936 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2937 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2938 if (ain
->peer
== peer
)
2940 bgp_adj_in_remove (rn
, ain
);
2941 bgp_unlock_node (rn
);
2947 bgp_clear_stale_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2949 struct bgp_node
*rn
;
2950 struct bgp_info
*ri
;
2951 struct bgp_table
*table
;
2953 table
= peer
->bgp
->rib
[afi
][safi
];
2955 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2957 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2958 if (ri
->peer
== peer
)
2960 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2961 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2967 /* Delete all kernel routes. */
2969 bgp_cleanup_routes (void)
2972 struct listnode
*node
, *nnode
;
2973 struct bgp_node
*rn
;
2974 struct bgp_table
*table
;
2975 struct bgp_info
*ri
;
2977 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
2979 table
= bgp
->rib
[AFI_IP
][SAFI_UNICAST
];
2981 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2982 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2983 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
2984 && ri
->type
== ZEBRA_ROUTE_BGP
2985 && ri
->sub_type
== BGP_ROUTE_NORMAL
)
2986 bgp_zebra_withdraw (&rn
->p
, ri
);
2988 table
= bgp
->rib
[AFI_IP6
][SAFI_UNICAST
];
2990 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2991 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2992 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
2993 && ri
->type
== ZEBRA_ROUTE_BGP
2994 && ri
->sub_type
== BGP_ROUTE_NORMAL
)
2995 bgp_zebra_withdraw (&rn
->p
, ri
);
3003 bgp_zclient_reset ();
3004 access_list_reset ();
3005 prefix_list_reset ();
3008 /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3011 bgp_nlri_parse (struct peer
*peer
, struct attr
*attr
, struct bgp_nlri
*packet
)
3019 /* Check peer status. */
3020 if (peer
->status
!= Established
)
3024 lim
= pnt
+ packet
->length
;
3026 for (; pnt
< lim
; pnt
+= psize
)
3028 /* Clear prefix structure. */
3029 memset (&p
, 0, sizeof (struct prefix
));
3031 /* Fetch prefix length. */
3032 p
.prefixlen
= *pnt
++;
3033 p
.family
= afi2family (packet
->afi
);
3035 /* Already checked in nlri_sanity_check(). We do double check
3037 if ((packet
->afi
== AFI_IP
&& p
.prefixlen
> 32)
3038 || (packet
->afi
== AFI_IP6
&& p
.prefixlen
> 128))
3041 /* Packet size overflow check. */
3042 psize
= PSIZE (p
.prefixlen
);
3044 /* When packet overflow occur return immediately. */
3045 if (pnt
+ psize
> lim
)
3048 /* Fetch prefix from NLRI packet. */
3049 memcpy (&p
.u
.prefix
, pnt
, psize
);
3051 /* Check address. */
3052 if (packet
->afi
== AFI_IP
&& packet
->safi
== SAFI_UNICAST
)
3054 if (IN_CLASSD (ntohl (p
.u
.prefix4
.s_addr
)))
3057 * From draft-ietf-idr-bgp4-22, Section 6.3:
3058 * If a BGP router receives an UPDATE message with a
3059 * semantically incorrect NLRI field, in which a prefix is
3060 * semantically incorrect (eg. an unexpected multicast IP
3061 * address), it should ignore the prefix.
3063 zlog (peer
->log
, LOG_ERR
,
3064 "IPv4 unicast NLRI is multicast address %s",
3065 inet_ntoa (p
.u
.prefix4
));
3072 /* Check address. */
3073 if (packet
->afi
== AFI_IP6
&& packet
->safi
== SAFI_UNICAST
)
3075 if (IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3079 zlog (peer
->log
, LOG_WARNING
,
3080 "IPv6 link-local NLRI received %s ignore this NLRI",
3081 inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3086 #endif /* HAVE_IPV6 */
3088 /* Normal process. */
3090 ret
= bgp_update (peer
, &p
, attr
, packet
->afi
, packet
->safi
,
3091 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
3093 ret
= bgp_withdraw (peer
, &p
, attr
, packet
->afi
, packet
->safi
,
3094 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
3096 /* Address family configuration mismatch or maximum-prefix count
3102 /* Packet length consistency check. */
3109 /* NLRI encode syntax check routine. */
3111 bgp_nlri_sanity_check (struct peer
*peer
, int afi
, u_char
*pnt
,
3120 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
3121 syntactic validity. If the field is syntactically incorrect,
3122 then the Error Subcode is set to Invalid Network Field. */
3128 /* Prefix length check. */
3129 if ((afi
== AFI_IP
&& prefixlen
> 32)
3130 || (afi
== AFI_IP6
&& prefixlen
> 128))
3132 plog_err (peer
->log
,
3133 "%s [Error] Update packet error (wrong prefix length %d)",
3134 peer
->host
, prefixlen
);
3135 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3136 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3140 /* Packet size overflow check. */
3141 psize
= PSIZE (prefixlen
);
3143 if (pnt
+ psize
> end
)
3145 plog_err (peer
->log
,
3146 "%s [Error] Update packet error"
3147 " (prefix data overflow prefix size is %d)",
3149 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3150 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3157 /* Packet length consistency check. */
3160 plog_err (peer
->log
,
3161 "%s [Error] Update packet error"
3162 " (prefix length mismatch with total length)",
3164 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3165 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3171 static struct bgp_static
*
3172 bgp_static_new (void)
3174 return XCALLOC (MTYPE_BGP_STATIC
, sizeof (struct bgp_static
));
3178 bgp_static_free (struct bgp_static
*bgp_static
)
3180 if (bgp_static
->rmap
.name
)
3181 free (bgp_static
->rmap
.name
);
3182 XFREE (MTYPE_BGP_STATIC
, bgp_static
);
3186 bgp_static_withdraw_rsclient (struct bgp
*bgp
, struct peer
*rsclient
,
3187 struct prefix
*p
, afi_t afi
, safi_t safi
)
3189 struct bgp_node
*rn
;
3190 struct bgp_info
*ri
;
3192 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3194 /* Check selected route and self inserted route. */
3195 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3196 if (ri
->peer
== bgp
->peer_self
3197 && ri
->type
== ZEBRA_ROUTE_BGP
3198 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3201 /* Withdraw static BGP route from routing table. */
3204 bgp_info_delete (rn
, ri
);
3205 bgp_process (bgp
, rn
, afi
, safi
);
3208 /* Unlock bgp_node_lookup. */
3209 bgp_unlock_node (rn
);
3213 bgp_static_update_rsclient (struct peer
*rsclient
, struct prefix
*p
,
3214 struct bgp_static
*bgp_static
,
3215 afi_t afi
, safi_t safi
)
3217 struct bgp_node
*rn
;
3218 struct bgp_info
*ri
;
3219 struct bgp_info
*new;
3220 struct bgp_info info
;
3221 struct attr
*attr_new
;
3222 struct attr attr
= {0 };
3223 struct attr new_attr
= { .extra
= 0 };
3226 char buf
[SU_ADDRSTRLEN
];
3228 bgp
= rsclient
->bgp
;
3230 assert (bgp_static
);
3234 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3236 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3238 attr
.nexthop
= bgp_static
->igpnexthop
;
3239 attr
.med
= bgp_static
->igpmetric
;
3240 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3242 if (bgp_static
->ttl
)
3244 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_AS_PATHLIMIT
);
3245 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3246 attr
.pathlimit
.as
= 0;
3247 attr
.pathlimit
.ttl
= bgp_static
->ttl
;
3250 if (bgp_static
->atomic
)
3251 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3253 /* Apply network route-map for export to this rsclient. */
3254 if (bgp_static
->rmap
.name
)
3256 struct attr attr_tmp
= attr
;
3257 info
.peer
= rsclient
;
3258 info
.attr
= &attr_tmp
;
3260 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_EXPORT
);
3261 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3263 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3265 rsclient
->rmap_type
= 0;
3267 if (ret
== RMAP_DENYMATCH
)
3269 /* Free uninterned attribute. */
3270 bgp_attr_flush (&attr_tmp
);
3272 /* Unintern original. */
3273 aspath_unintern (attr
.aspath
);
3274 bgp_static_withdraw_rsclient (bgp
, rsclient
, p
, afi
, safi
);
3275 bgp_attr_extra_free (&attr
);
3279 attr_new
= bgp_attr_intern (&attr_tmp
);
3282 attr_new
= bgp_attr_intern (&attr
);
3284 new_attr
= *attr_new
;
3286 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3288 if (bgp_import_modifier (rsclient
, bgp
->peer_self
, p
, &new_attr
, afi
, safi
)
3291 /* This BGP update is filtered. Log the reason then update BGP entry. */
3292 if (BGP_DEBUG (update
, UPDATE_IN
))
3293 zlog (rsclient
->log
, LOG_DEBUG
,
3294 "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
3295 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
3296 p
->prefixlen
, rsclient
->host
);
3298 bgp
->peer_self
->rmap_type
= 0;
3300 bgp_attr_unintern (attr_new
);
3301 aspath_unintern (attr
.aspath
);
3302 bgp_attr_extra_free (&attr
);
3304 bgp_static_withdraw_rsclient (bgp
, rsclient
, p
, afi
, safi
);
3309 bgp
->peer_self
->rmap_type
= 0;
3311 bgp_attr_unintern (attr_new
);
3312 attr_new
= bgp_attr_intern (&new_attr
);
3314 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3315 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3316 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3321 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3322 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3324 bgp_unlock_node (rn
);
3325 bgp_attr_unintern (attr_new
);
3326 aspath_unintern (attr
.aspath
);
3327 bgp_attr_extra_free (&attr
);
3332 /* The attribute is changed. */
3333 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3335 /* Rewrite BGP route information. */
3336 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3337 bgp_info_restore(rn
, ri
);
3338 bgp_attr_unintern (ri
->attr
);
3339 ri
->attr
= attr_new
;
3340 ri
->uptime
= bgp_clock ();
3342 /* Process change. */
3343 bgp_process (bgp
, rn
, afi
, safi
);
3344 bgp_unlock_node (rn
);
3345 aspath_unintern (attr
.aspath
);
3346 bgp_attr_extra_free (&attr
);
3351 /* Make new BGP info. */
3352 new = bgp_info_new ();
3353 new->type
= ZEBRA_ROUTE_BGP
;
3354 new->sub_type
= BGP_ROUTE_STATIC
;
3355 new->peer
= bgp
->peer_self
;
3356 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3357 new->attr
= attr_new
;
3358 new->uptime
= bgp_clock ();
3360 /* Register new BGP information. */
3361 bgp_info_add (rn
, new);
3363 /* route_node_get lock */
3364 bgp_unlock_node (rn
);
3366 /* Process change. */
3367 bgp_process (bgp
, rn
, afi
, safi
);
3369 /* Unintern original. */
3370 aspath_unintern (attr
.aspath
);
3371 bgp_attr_extra_free (&attr
);
3375 bgp_static_update_main (struct bgp
*bgp
, struct prefix
*p
,
3376 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3378 struct bgp_node
*rn
;
3379 struct bgp_info
*ri
;
3380 struct bgp_info
*new;
3381 struct bgp_info info
;
3382 struct attr attr
= { 0 };
3383 struct attr
*attr_new
;
3386 assert (bgp_static
);
3390 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3392 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3394 attr
.nexthop
= bgp_static
->igpnexthop
;
3395 attr
.med
= bgp_static
->igpmetric
;
3396 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3398 if (bgp_static
->ttl
)
3400 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_AS_PATHLIMIT
);
3401 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3402 attr
.pathlimit
.as
= 0;
3403 attr
.pathlimit
.ttl
= bgp_static
->ttl
;
3406 if (bgp_static
->atomic
)
3407 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3409 /* Apply route-map. */
3410 if (bgp_static
->rmap
.name
)
3412 struct attr attr_tmp
= attr
;
3413 info
.peer
= bgp
->peer_self
;
3414 info
.attr
= &attr_tmp
;
3416 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3418 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3420 bgp
->peer_self
->rmap_type
= 0;
3422 if (ret
== RMAP_DENYMATCH
)
3424 /* Free uninterned attribute. */
3425 bgp_attr_flush (&attr_tmp
);
3427 /* Unintern original. */
3428 aspath_unintern (attr
.aspath
);
3429 bgp_attr_extra_free (&attr
);
3430 bgp_static_withdraw (bgp
, p
, afi
, safi
);
3433 attr_new
= bgp_attr_intern (&attr_tmp
);
3436 attr_new
= bgp_attr_intern (&attr
);
3438 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3439 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3440 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3445 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3446 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3448 bgp_unlock_node (rn
);
3449 bgp_attr_unintern (attr_new
);
3450 aspath_unintern (attr
.aspath
);
3451 bgp_attr_extra_free (&attr
);
3456 /* The attribute is changed. */
3457 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3459 /* Rewrite BGP route information. */
3460 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3461 bgp_info_restore(rn
, ri
);
3463 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3464 bgp_attr_unintern (ri
->attr
);
3465 ri
->attr
= attr_new
;
3466 ri
->uptime
= bgp_clock ();
3468 /* Process change. */
3469 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3470 bgp_process (bgp
, rn
, afi
, safi
);
3471 bgp_unlock_node (rn
);
3472 aspath_unintern (attr
.aspath
);
3473 bgp_attr_extra_free (&attr
);
3478 /* Make new BGP info. */
3479 new = bgp_info_new ();
3480 new->type
= ZEBRA_ROUTE_BGP
;
3481 new->sub_type
= BGP_ROUTE_STATIC
;
3482 new->peer
= bgp
->peer_self
;
3483 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3484 new->attr
= attr_new
;
3485 new->uptime
= bgp_clock ();
3487 /* Aggregate address increment. */
3488 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3490 /* Register new BGP information. */
3491 bgp_info_add (rn
, new);
3493 /* route_node_get lock */
3494 bgp_unlock_node (rn
);
3496 /* Process change. */
3497 bgp_process (bgp
, rn
, afi
, safi
);
3499 /* Unintern original. */
3500 aspath_unintern (attr
.aspath
);
3501 bgp_attr_extra_free (&attr
);
3505 bgp_static_update (struct bgp
*bgp
, struct prefix
*p
,
3506 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3508 struct peer
*rsclient
;
3509 struct listnode
*node
, *nnode
;
3511 bgp_static_update_main (bgp
, p
, bgp_static
, afi
, safi
);
3513 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
3515 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
3516 bgp_static_update_rsclient (rsclient
, p
, bgp_static
, afi
, safi
);
3521 bgp_static_update_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, u_int16_t afi
,
3522 u_char safi
, struct prefix_rd
*prd
, u_char
*tag
)
3524 struct bgp_node
*rn
;
3525 struct bgp_info
*new;
3527 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3529 /* Make new BGP info. */
3530 new = bgp_info_new ();
3531 new->type
= ZEBRA_ROUTE_BGP
;
3532 new->sub_type
= BGP_ROUTE_STATIC
;
3533 new->peer
= bgp
->peer_self
;
3534 new->attr
= bgp_attr_default_intern (BGP_ORIGIN_IGP
);
3535 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3536 new->uptime
= bgp_clock ();
3537 new->extra
= bgp_info_extra_new();
3538 memcpy (new->extra
->tag
, tag
, 3);
3540 /* Aggregate address increment. */
3541 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3543 /* Register new BGP information. */
3544 bgp_info_add (rn
, new);
3546 /* route_node_get lock */
3547 bgp_unlock_node (rn
);
3549 /* Process change. */
3550 bgp_process (bgp
, rn
, afi
, safi
);
3554 bgp_static_withdraw (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3557 struct bgp_node
*rn
;
3558 struct bgp_info
*ri
;
3560 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3562 /* Check selected route and self inserted route. */
3563 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3564 if (ri
->peer
== bgp
->peer_self
3565 && ri
->type
== ZEBRA_ROUTE_BGP
3566 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3569 /* Withdraw static BGP route from routing table. */
3572 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3573 bgp_info_delete (rn
, ri
);
3574 bgp_process (bgp
, rn
, afi
, safi
);
3577 /* Unlock bgp_node_lookup. */
3578 bgp_unlock_node (rn
);
3582 bgp_check_local_routes_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
)
3584 struct bgp_static
*bgp_static
;
3586 struct bgp_node
*rn
;
3589 bgp
= rsclient
->bgp
;
3591 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3592 if ((bgp_static
= rn
->info
) != NULL
)
3596 bgp_static_update_rsclient (rsclient
, p
, bgp_static
,
3602 bgp_static_withdraw_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, u_int16_t afi
,
3603 u_char safi
, struct prefix_rd
*prd
, u_char
*tag
)
3605 struct bgp_node
*rn
;
3606 struct bgp_info
*ri
;
3608 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3610 /* Check selected route and self inserted route. */
3611 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3612 if (ri
->peer
== bgp
->peer_self
3613 && ri
->type
== ZEBRA_ROUTE_BGP
3614 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3617 /* Withdraw static BGP route from routing table. */
3620 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3621 bgp_info_delete (rn
, ri
);
3622 bgp_process (bgp
, rn
, afi
, safi
);
3625 /* Unlock bgp_node_lookup. */
3626 bgp_unlock_node (rn
);
3630 bgp_pathlimit_update_parents (struct bgp
*bgp
, struct bgp_node
*rn
,
3633 struct bgp_node
*parent
= rn
;
3634 struct bgp_static
*sp
;
3636 /* Existing static changed TTL, search parents and adjust their atomic */
3637 while ((parent
= parent
->parent
))
3638 if ((sp
= parent
->info
))
3640 int sp_level
= (sp
->atomic
? 1 : 0);
3641 ttl_edge
? sp
->atomic
++ : sp
->atomic
--;
3643 /* did we change state of parent whether atomic is set or not? */
3644 if (sp_level
!= (sp
->atomic
? 1 : 0))
3646 bgp_static_update (bgp
, &parent
->p
, sp
,
3647 rn
->table
->afi
, rn
->table
->safi
);
3652 /* Configure static BGP network. When user don't run zebra, static
3653 route should be installed as valid. */
3655 bgp_static_set (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3656 u_int16_t afi
, u_char safi
, const char *rmap
, int backdoor
,
3661 struct bgp_static
*bgp_static
;
3662 struct bgp_node
*rn
;
3663 u_char need_update
= 0;
3664 u_char ttl_change
= 0;
3665 u_char ttl_edge
= (ttl
? 1 : 0);
3668 /* Convert IP prefix string to struct prefix. */
3669 ret
= str2prefix (ip_str
, &p
);
3672 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3676 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3678 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3682 #endif /* HAVE_IPV6 */
3686 /* Set BGP static route configuration. */
3687 rn
= bgp_node_get (bgp
->route
[afi
][safi
], &p
);
3691 /* Configuration change. */
3692 bgp_static
= rn
->info
;
3694 /* Check previous routes are installed into BGP. */
3695 if (bgp_static
->valid
)
3697 if (bgp_static
->backdoor
!= backdoor
3698 || bgp_static
->ttl
!= ttl
)
3702 /* need to catch TTL set/unset transitions for handling of
3705 if ((bgp_static
->ttl
? 1 : 0) != ttl_edge
)
3708 bgp_static
->backdoor
= backdoor
;
3709 bgp_static
->ttl
= ttl
;
3713 if (bgp_static
->rmap
.name
)
3714 free (bgp_static
->rmap
.name
);
3715 bgp_static
->rmap
.name
= strdup (rmap
);
3716 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3720 if (bgp_static
->rmap
.name
)
3721 free (bgp_static
->rmap
.name
);
3722 bgp_static
->rmap
.name
= NULL
;
3723 bgp_static
->rmap
.map
= NULL
;
3724 bgp_static
->valid
= 0;
3726 bgp_unlock_node (rn
);
3730 /* New configuration. */
3731 bgp_static
= bgp_static_new ();
3732 bgp_static
->backdoor
= backdoor
;
3733 bgp_static
->valid
= 0;
3734 bgp_static
->igpmetric
= 0;
3735 bgp_static
->igpnexthop
.s_addr
= 0;
3736 bgp_static
->ttl
= ttl
;
3737 ttl_change
= ttl_edge
;
3742 if (bgp_static
->rmap
.name
)
3743 free (bgp_static
->rmap
.name
);
3744 bgp_static
->rmap
.name
= strdup (rmap
);
3745 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3747 rn
->info
= bgp_static
;
3750 /* ".. sites that choose to advertise the
3751 * AS_PATHLIMIT path attribute SHOULD advertise the ATOMIC_AGGREGATE on
3752 * all less specific covering prefixes as well as the more specific
3756 * Prefix that has just had pathlimit set/unset:
3757 * - Must bump ATOMIC refcount on all parents.
3759 * To catch less specific prefixes:
3760 * - Must search children for ones with TTL, bump atomic refcount
3761 * (we dont care if we're deleting a less specific prefix..)
3765 /* Existing static changed TTL, search parents and adjust their atomic */
3766 bgp_pathlimit_update_parents (bgp
, rn
, ttl_edge
);
3771 struct bgp_node
*child
;
3772 struct bgp_static
*sc
;
3774 /* New static, search children and bump this statics atomic.. */
3775 child
= bgp_lock_node (rn
); /* route_next_until unlocks it.. */
3776 while ((child
= bgp_route_next_until (child
, rn
)))
3778 if ((sc
= child
->info
) && sc
->ttl
)
3779 bgp_static
->atomic
++;
3783 /* If BGP scan is not enabled, we should install this route here. */
3784 if (! bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3786 bgp_static
->valid
= 1;
3789 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3791 if (! bgp_static
->backdoor
)
3792 bgp_static_update (bgp
, &p
, bgp_static
, afi
, safi
);
3798 /* Configure static BGP network. */
3800 bgp_static_unset (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3801 u_int16_t afi
, u_char safi
)
3805 struct bgp_static
*bgp_static
;
3806 struct bgp_node
*rn
;
3808 /* Convert IP prefix string to struct prefix. */
3809 ret
= str2prefix (ip_str
, &p
);
3812 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3816 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3818 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3822 #endif /* HAVE_IPV6 */
3826 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], &p
);
3829 vty_out (vty
, "%% Can't find specified static route configuration.%s",
3834 bgp_static
= rn
->info
;
3836 /* decrement atomic in parents, see bgp_static_set */
3837 bgp_pathlimit_update_parents (bgp
, rn
, 0);
3839 /* Update BGP RIB. */
3840 if (! bgp_static
->backdoor
)
3841 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3843 /* Clear configuration. */
3844 bgp_static_free (bgp_static
);
3846 bgp_unlock_node (rn
);
3847 bgp_unlock_node (rn
);
3852 /* Called from bgp_delete(). Delete all static routes from the BGP
3855 bgp_static_delete (struct bgp
*bgp
)
3859 struct bgp_node
*rn
;
3860 struct bgp_node
*rm
;
3861 struct bgp_table
*table
;
3862 struct bgp_static
*bgp_static
;
3864 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3865 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3866 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3867 if (rn
->info
!= NULL
)
3869 if (safi
== SAFI_MPLS_VPN
)
3873 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
3875 bgp_static
= rn
->info
;
3876 bgp_static_withdraw_vpnv4 (bgp
, &rm
->p
,
3877 AFI_IP
, SAFI_MPLS_VPN
,
3878 (struct prefix_rd
*)&rn
->p
,
3880 bgp_static_free (bgp_static
);
3882 bgp_unlock_node (rn
);
3887 bgp_static
= rn
->info
;
3888 bgp_static_withdraw (bgp
, &rn
->p
, afi
, safi
);
3889 bgp_static_free (bgp_static
);
3891 bgp_unlock_node (rn
);
3897 bgp_static_set_vpnv4 (struct vty
*vty
, const char *ip_str
, const char *rd_str
,
3898 const char *tag_str
)
3902 struct prefix_rd prd
;
3904 struct bgp_node
*prn
;
3905 struct bgp_node
*rn
;
3906 struct bgp_table
*table
;
3907 struct bgp_static
*bgp_static
;
3912 ret
= str2prefix (ip_str
, &p
);
3915 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3920 ret
= str2prefix_rd (rd_str
, &prd
);
3923 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3927 ret
= str2tag (tag_str
, tag
);
3930 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3934 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3935 (struct prefix
*)&prd
);
3936 if (prn
->info
== NULL
)
3937 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3939 bgp_unlock_node (prn
);
3942 rn
= bgp_node_get (table
, &p
);
3946 vty_out (vty
, "%% Same network configuration exists%s", VTY_NEWLINE
);
3947 bgp_unlock_node (rn
);
3951 /* New configuration. */
3952 bgp_static
= bgp_static_new ();
3953 bgp_static
->valid
= 1;
3954 memcpy (bgp_static
->tag
, tag
, 3);
3955 rn
->info
= bgp_static
;
3957 bgp_static_update_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3963 /* Configure static BGP network. */
3965 bgp_static_unset_vpnv4 (struct vty
*vty
, const char *ip_str
,
3966 const char *rd_str
, const char *tag_str
)
3971 struct prefix_rd prd
;
3972 struct bgp_node
*prn
;
3973 struct bgp_node
*rn
;
3974 struct bgp_table
*table
;
3975 struct bgp_static
*bgp_static
;
3980 /* Convert IP prefix string to struct prefix. */
3981 ret
= str2prefix (ip_str
, &p
);
3984 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3989 ret
= str2prefix_rd (rd_str
, &prd
);
3992 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3996 ret
= str2tag (tag_str
, tag
);
3999 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
4003 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
4004 (struct prefix
*)&prd
);
4005 if (prn
->info
== NULL
)
4006 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
4008 bgp_unlock_node (prn
);
4011 rn
= bgp_node_lookup (table
, &p
);
4015 bgp_static_withdraw_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
4017 bgp_static
= rn
->info
;
4018 bgp_static_free (bgp_static
);
4020 bgp_unlock_node (rn
);
4021 bgp_unlock_node (rn
);
4024 vty_out (vty
, "%% Can't find the route%s", VTY_NEWLINE
);
4031 "network A.B.C.D/M",
4032 "Specify a network to announce via BGP\n"
4033 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4038 VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl
, argv
[1], 1, 255);
4040 return bgp_static_set (vty
, vty
->index
, argv
[0],
4041 AFI_IP
, bgp_node_safi (vty
), NULL
, 0, ttl
);
4045 bgp_network_ttl_cmd
,
4046 "network A.B.C.D/M pathlimit <0-255>",
4047 "Specify a network to announce via BGP\n"
4048 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4049 "AS-Path hopcount limit attribute\n"
4050 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4052 DEFUN (bgp_network_route_map
,
4053 bgp_network_route_map_cmd
,
4054 "network A.B.C.D/M route-map WORD",
4055 "Specify a network to announce via BGP\n"
4056 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4057 "Route-map to modify the attributes\n"
4058 "Name of the route map\n")
4060 return bgp_static_set (vty
, vty
->index
, argv
[0],
4061 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0, 0);
4064 DEFUN (bgp_network_backdoor
,
4065 bgp_network_backdoor_cmd
,
4066 "network A.B.C.D/M backdoor",
4067 "Specify a network to announce via BGP\n"
4068 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4069 "Specify a BGP backdoor route\n")
4074 VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl
, argv
[1], 1, 255);
4076 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP
, SAFI_UNICAST
,
4080 ALIAS (bgp_network_backdoor
,
4081 bgp_network_backdoor_ttl_cmd
,
4082 "network A.B.C.D/M backdoor pathlimit <0-255>",
4083 "Specify a network to announce via BGP\n"
4084 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4085 "Specify a BGP backdoor route\n"
4086 "AS-Path hopcount limit attribute\n"
4087 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4089 DEFUN (bgp_network_mask
,
4090 bgp_network_mask_cmd
,
4091 "network A.B.C.D mask A.B.C.D",
4092 "Specify a network to announce via BGP\n"
4098 char prefix_str
[BUFSIZ
];
4102 VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl
, argv
[2], 1, 255);
4104 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4107 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4111 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4112 AFI_IP
, bgp_node_safi (vty
), NULL
, 0, ttl
);
4115 ALIAS (bgp_network_mask
,
4116 bgp_network_mask_ttl_cmd
,
4117 "network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4118 "Specify a network to announce via BGP\n"
4122 "AS-Path hopcount limit attribute\n"
4123 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4125 DEFUN (bgp_network_mask_route_map
,
4126 bgp_network_mask_route_map_cmd
,
4127 "network A.B.C.D mask A.B.C.D route-map WORD",
4128 "Specify a network to announce via BGP\n"
4132 "Route-map to modify the attributes\n"
4133 "Name of the route map\n")
4136 char prefix_str
[BUFSIZ
];
4138 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4141 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4145 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4146 AFI_IP
, bgp_node_safi (vty
), argv
[2], 0, 0);
4149 DEFUN (bgp_network_mask_backdoor
,
4150 bgp_network_mask_backdoor_cmd
,
4151 "network A.B.C.D mask A.B.C.D backdoor",
4152 "Specify a network to announce via BGP\n"
4156 "Specify a BGP backdoor route\n")
4159 char prefix_str
[BUFSIZ
];
4163 VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl
, argv
[2], 1, 255);
4165 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4168 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4172 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4176 ALIAS (bgp_network_mask_backdoor
,
4177 bgp_network_mask_backdoor_ttl_cmd
,
4178 "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4179 "Specify a network to announce via BGP\n"
4183 "Specify a BGP backdoor route\n"
4184 "AS-Path hopcount limit attribute\n"
4185 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4187 DEFUN (bgp_network_mask_natural
,
4188 bgp_network_mask_natural_cmd
,
4190 "Specify a network to announce via BGP\n"
4194 char prefix_str
[BUFSIZ
];
4198 VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl
, argv
[1], 1, 255);
4200 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4203 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4207 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4208 AFI_IP
, bgp_node_safi (vty
), NULL
, 0, ttl
);
4211 ALIAS (bgp_network_mask_natural
,
4212 bgp_network_mask_natural_ttl_cmd
,
4213 "network A.B.C.D pathlimit <0-255>",
4214 "Specify a network to announce via BGP\n"
4216 "AS-Path hopcount limit attribute\n"
4217 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4219 DEFUN (bgp_network_mask_natural_route_map
,
4220 bgp_network_mask_natural_route_map_cmd
,
4221 "network A.B.C.D route-map WORD",
4222 "Specify a network to announce via BGP\n"
4224 "Route-map to modify the attributes\n"
4225 "Name of the route map\n")
4228 char prefix_str
[BUFSIZ
];
4230 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4233 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4237 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4238 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0, 0);
4241 DEFUN (bgp_network_mask_natural_backdoor
,
4242 bgp_network_mask_natural_backdoor_cmd
,
4243 "network A.B.C.D backdoor",
4244 "Specify a network to announce via BGP\n"
4246 "Specify a BGP backdoor route\n")
4249 char prefix_str
[BUFSIZ
];
4253 VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl
, argv
[1], 1, 255);
4255 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4258 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4262 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4266 ALIAS (bgp_network_mask_natural_backdoor
,
4267 bgp_network_mask_natural_backdoor_ttl_cmd
,
4268 "network A.B.C.D backdoor pathlimit (1-255>",
4269 "Specify a network to announce via BGP\n"
4271 "Specify a BGP backdoor route\n"
4272 "AS-Path hopcount limit attribute\n"
4273 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4275 DEFUN (no_bgp_network
,
4277 "no network A.B.C.D/M",
4279 "Specify a network to announce via BGP\n"
4280 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4282 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP
,
4283 bgp_node_safi (vty
));
4286 ALIAS (no_bgp_network
,
4287 no_bgp_network_ttl_cmd
,
4288 "no network A.B.C.D/M pathlimit <0-255>",
4290 "Specify a network to announce via BGP\n"
4291 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4292 "AS-Path hopcount limit attribute\n"
4293 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4295 ALIAS (no_bgp_network
,
4296 no_bgp_network_route_map_cmd
,
4297 "no network A.B.C.D/M route-map WORD",
4299 "Specify a network to announce via BGP\n"
4300 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4301 "Route-map to modify the attributes\n"
4302 "Name of the route map\n")
4304 ALIAS (no_bgp_network
,
4305 no_bgp_network_backdoor_cmd
,
4306 "no network A.B.C.D/M backdoor",
4308 "Specify a network to announce via BGP\n"
4309 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4310 "Specify a BGP backdoor route\n")
4312 ALIAS (no_bgp_network
,
4313 no_bgp_network_backdoor_ttl_cmd
,
4314 "no network A.B.C.D/M backdoor pathlimit <0-255>",
4316 "Specify a network to announce via BGP\n"
4317 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4318 "Specify a BGP backdoor route\n"
4319 "AS-Path hopcount limit attribute\n"
4320 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4322 DEFUN (no_bgp_network_mask
,
4323 no_bgp_network_mask_cmd
,
4324 "no network A.B.C.D mask A.B.C.D",
4326 "Specify a network to announce via BGP\n"
4332 char prefix_str
[BUFSIZ
];
4334 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4337 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4341 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4342 bgp_node_safi (vty
));
4345 ALIAS (no_bgp_network
,
4346 no_bgp_network_mask_ttl_cmd
,
4347 "no network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4349 "Specify a network to announce via BGP\n"
4353 "AS-Path hopcount limit attribute\n"
4354 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4356 ALIAS (no_bgp_network_mask
,
4357 no_bgp_network_mask_route_map_cmd
,
4358 "no network A.B.C.D mask A.B.C.D route-map WORD",
4360 "Specify a network to announce via BGP\n"
4364 "Route-map to modify the attributes\n"
4365 "Name of the route map\n")
4367 ALIAS (no_bgp_network_mask
,
4368 no_bgp_network_mask_backdoor_cmd
,
4369 "no network A.B.C.D mask A.B.C.D backdoor",
4371 "Specify a network to announce via BGP\n"
4375 "Specify a BGP backdoor route\n")
4377 ALIAS (no_bgp_network_mask
,
4378 no_bgp_network_mask_backdoor_ttl_cmd
,
4379 "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4381 "Specify a network to announce via BGP\n"
4385 "Specify a BGP backdoor route\n"
4386 "AS-Path hopcount limit attribute\n"
4387 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4389 DEFUN (no_bgp_network_mask_natural
,
4390 no_bgp_network_mask_natural_cmd
,
4391 "no network A.B.C.D",
4393 "Specify a network to announce via BGP\n"
4397 char prefix_str
[BUFSIZ
];
4399 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4402 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4406 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4407 bgp_node_safi (vty
));
4410 ALIAS (no_bgp_network_mask_natural
,
4411 no_bgp_network_mask_natural_route_map_cmd
,
4412 "no network A.B.C.D route-map WORD",
4414 "Specify a network to announce via BGP\n"
4416 "Route-map to modify the attributes\n"
4417 "Name of the route map\n")
4419 ALIAS (no_bgp_network_mask_natural
,
4420 no_bgp_network_mask_natural_backdoor_cmd
,
4421 "no network A.B.C.D backdoor",
4423 "Specify a network to announce via BGP\n"
4425 "Specify a BGP backdoor route\n")
4427 ALIAS (no_bgp_network_mask_natural
,
4428 no_bgp_network_mask_natural_ttl_cmd
,
4429 "no network A.B.C.D pathlimit <0-255>",
4431 "Specify a network to announce via BGP\n"
4433 "AS-Path hopcount limit attribute\n"
4434 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4436 ALIAS (no_bgp_network_mask_natural
,
4437 no_bgp_network_mask_natural_backdoor_ttl_cmd
,
4438 "no network A.B.C.D backdoor pathlimit <0-255>",
4440 "Specify a network to announce via BGP\n"
4442 "Specify a BGP backdoor route\n"
4443 "AS-Path hopcount limit attribute\n"
4444 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4447 DEFUN (ipv6_bgp_network
,
4448 ipv6_bgp_network_cmd
,
4449 "network X:X::X:X/M",
4450 "Specify a network to announce via BGP\n"
4451 "IPv6 prefix <network>/<length>\n")
4456 VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl
, argv
[1], 1, 255);
4458 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
4462 ALIAS (ipv6_bgp_network
,
4463 ipv6_bgp_network_ttl_cmd
,
4464 "network X:X::X:X/M pathlimit <0-255>",
4465 "Specify a network to announce via BGP\n"
4466 "IPv6 prefix <network>/<length>\n"
4467 "AS-Path hopcount limit attribute\n"
4468 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4470 DEFUN (ipv6_bgp_network_route_map
,
4471 ipv6_bgp_network_route_map_cmd
,
4472 "network X:X::X:X/M route-map WORD",
4473 "Specify a network to announce via BGP\n"
4474 "IPv6 prefix <network>/<length>\n"
4475 "Route-map to modify the attributes\n"
4476 "Name of the route map\n")
4478 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
,
4479 bgp_node_safi (vty
), argv
[1], 0, 0);
4482 DEFUN (no_ipv6_bgp_network
,
4483 no_ipv6_bgp_network_cmd
,
4484 "no network X:X::X:X/M",
4486 "Specify a network to announce via BGP\n"
4487 "IPv6 prefix <network>/<length>\n")
4489 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
4492 ALIAS (no_ipv6_bgp_network
,
4493 no_ipv6_bgp_network_route_map_cmd
,
4494 "no network X:X::X:X/M route-map WORD",
4496 "Specify a network to announce via BGP\n"
4497 "IPv6 prefix <network>/<length>\n"
4498 "Route-map to modify the attributes\n"
4499 "Name of the route map\n")
4501 ALIAS (no_ipv6_bgp_network
,
4502 no_ipv6_bgp_network_ttl_cmd
,
4503 "no network X:X::X:X/M pathlimit <0-255>",
4505 "Specify a network to announce via BGP\n"
4506 "IPv6 prefix <network>/<length>\n"
4507 "AS-Path hopcount limit attribute\n"
4508 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4510 ALIAS (ipv6_bgp_network
,
4511 old_ipv6_bgp_network_cmd
,
4512 "ipv6 bgp network X:X::X:X/M",
4515 "Specify a network to announce via BGP\n"
4516 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4518 ALIAS (no_ipv6_bgp_network
,
4519 old_no_ipv6_bgp_network_cmd
,
4520 "no ipv6 bgp network X:X::X:X/M",
4524 "Specify a network to announce via BGP\n"
4525 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4526 #endif /* HAVE_IPV6 */
4528 /* Aggreagete address:
4530 advertise-map Set condition to advertise attribute
4531 as-set Generate AS set path information
4532 attribute-map Set attributes of aggregate
4533 route-map Set parameters of aggregate
4534 summary-only Filter more specific routes from updates
4535 suppress-map Conditionally filter more specific routes from updates
4538 struct bgp_aggregate
4540 /* Summary-only flag. */
4541 u_char summary_only
;
4543 /* AS set generation. */
4546 /* Route-map for aggregated route. */
4547 struct route_map
*map
;
4549 /* Suppress-count. */
4550 unsigned long count
;
4552 /* SAFI configuration. */
4556 static struct bgp_aggregate
*
4557 bgp_aggregate_new (void)
4559 return XCALLOC (MTYPE_BGP_AGGREGATE
, sizeof (struct bgp_aggregate
));
4563 bgp_aggregate_free (struct bgp_aggregate
*aggregate
)
4565 XFREE (MTYPE_BGP_AGGREGATE
, aggregate
);
4569 bgp_aggregate_route (struct bgp
*bgp
, struct prefix
*p
, struct bgp_info
*rinew
,
4570 afi_t afi
, safi_t safi
, struct bgp_info
*del
,
4571 struct bgp_aggregate
*aggregate
)
4573 struct bgp_table
*table
;
4574 struct bgp_node
*top
;
4575 struct bgp_node
*rn
;
4577 struct aspath
*aspath
= NULL
;
4578 struct aspath
*asmerge
= NULL
;
4579 struct community
*community
= NULL
;
4580 struct community
*commerge
= NULL
;
4581 struct in_addr nexthop
;
4583 struct bgp_info
*ri
;
4584 struct bgp_info
*new;
4586 unsigned long match
= 0;
4588 /* Record adding route's nexthop and med. */
4591 nexthop
= rinew
->attr
->nexthop
;
4592 med
= rinew
->attr
->med
;
4595 /* ORIGIN attribute: If at least one route among routes that are
4596 aggregated has ORIGIN with the value INCOMPLETE, then the
4597 aggregated route must have the ORIGIN attribute with the value
4598 INCOMPLETE. Otherwise, if at least one route among routes that
4599 are aggregated has ORIGIN with the value EGP, then the aggregated
4600 route must have the origin attribute with the value EGP. In all
4601 other case the value of the ORIGIN attribute of the aggregated
4602 route is INTERNAL. */
4603 origin
= BGP_ORIGIN_IGP
;
4605 table
= bgp
->rib
[afi
][safi
];
4607 top
= bgp_node_get (table
, p
);
4608 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4609 if (rn
->p
.prefixlen
> p
->prefixlen
)
4613 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4615 if (BGP_INFO_HOLDDOWN (ri
))
4618 if (del
&& ri
== del
)
4621 if (! rinew
&& first
)
4623 nexthop
= ri
->attr
->nexthop
;
4624 med
= ri
->attr
->med
;
4628 #ifdef AGGREGATE_NEXTHOP_CHECK
4629 if (! IPV4_ADDR_SAME (&ri
->attr
->nexthop
, &nexthop
)
4630 || ri
->attr
->med
!= med
)
4633 aspath_free (aspath
);
4635 community_free (community
);
4636 bgp_unlock_node (rn
);
4637 bgp_unlock_node (top
);
4640 #endif /* AGGREGATE_NEXTHOP_CHECK */
4642 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4644 if (aggregate
->summary_only
)
4646 (bgp_info_extra_get (ri
))->suppress
++;
4647 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4653 if (aggregate
->as_set
)
4655 if (origin
< ri
->attr
->origin
)
4656 origin
= ri
->attr
->origin
;
4660 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4661 aspath_free (aspath
);
4665 aspath
= aspath_dup (ri
->attr
->aspath
);
4667 if (ri
->attr
->community
)
4671 commerge
= community_merge (community
,
4672 ri
->attr
->community
);
4673 community
= community_uniq_sort (commerge
);
4674 community_free (commerge
);
4677 community
= community_dup (ri
->attr
->community
);
4683 bgp_process (bgp
, rn
, afi
, safi
);
4685 bgp_unlock_node (top
);
4691 if (aggregate
->summary_only
)
4692 (bgp_info_extra_get (rinew
))->suppress
++;
4694 if (aggregate
->as_set
)
4696 if (origin
< rinew
->attr
->origin
)
4697 origin
= rinew
->attr
->origin
;
4701 asmerge
= aspath_aggregate (aspath
, rinew
->attr
->aspath
);
4702 aspath_free (aspath
);
4706 aspath
= aspath_dup (rinew
->attr
->aspath
);
4708 if (rinew
->attr
->community
)
4712 commerge
= community_merge (community
,
4713 rinew
->attr
->community
);
4714 community
= community_uniq_sort (commerge
);
4715 community_free (commerge
);
4718 community
= community_dup (rinew
->attr
->community
);
4723 if (aggregate
->count
> 0)
4725 rn
= bgp_node_get (table
, p
);
4726 new = bgp_info_new ();
4727 new->type
= ZEBRA_ROUTE_BGP
;
4728 new->sub_type
= BGP_ROUTE_AGGREGATE
;
4729 new->peer
= bgp
->peer_self
;
4730 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4731 new->attr
= bgp_attr_aggregate_intern (bgp
, origin
, aspath
, community
, aggregate
->as_set
);
4732 new->uptime
= bgp_clock ();
4734 bgp_info_add (rn
, new);
4735 bgp_unlock_node (rn
);
4736 bgp_process (bgp
, rn
, afi
, safi
);
4741 aspath_free (aspath
);
4743 community_free (community
);
4747 void bgp_aggregate_delete (struct bgp
*, struct prefix
*, afi_t
, safi_t
,
4748 struct bgp_aggregate
*);
4751 bgp_aggregate_increment (struct bgp
*bgp
, struct prefix
*p
,
4752 struct bgp_info
*ri
, afi_t afi
, safi_t safi
)
4754 struct bgp_node
*child
;
4755 struct bgp_node
*rn
;
4756 struct bgp_aggregate
*aggregate
;
4758 /* MPLS-VPN aggregation is not yet supported. */
4759 if (safi
== SAFI_MPLS_VPN
)
4762 if (p
->prefixlen
== 0)
4765 if (BGP_INFO_HOLDDOWN (ri
))
4768 child
= bgp_node_get (bgp
->aggregate
[afi
][safi
], p
);
4770 /* Aggregate address configuration check. */
4771 for (rn
= child
; rn
; rn
= rn
->parent
)
4772 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4774 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4775 bgp_aggregate_route (bgp
, &rn
->p
, ri
, afi
, safi
, NULL
, aggregate
);
4777 bgp_unlock_node (child
);
4781 bgp_aggregate_decrement (struct bgp
*bgp
, struct prefix
*p
,
4782 struct bgp_info
*del
, afi_t afi
, safi_t safi
)
4784 struct bgp_node
*child
;
4785 struct bgp_node
*rn
;
4786 struct bgp_aggregate
*aggregate
;
4788 /* MPLS-VPN aggregation is not yet supported. */
4789 if (safi
== SAFI_MPLS_VPN
)
4792 if (p
->prefixlen
== 0)
4795 child
= bgp_node_get (bgp
->aggregate
[afi
][safi
], p
);
4797 /* Aggregate address configuration check. */
4798 for (rn
= child
; rn
; rn
= rn
->parent
)
4799 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4801 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4802 bgp_aggregate_route (bgp
, &rn
->p
, NULL
, afi
, safi
, del
, aggregate
);
4804 bgp_unlock_node (child
);
4808 bgp_aggregate_add (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
, safi_t safi
,
4809 struct bgp_aggregate
*aggregate
)
4811 struct bgp_table
*table
;
4812 struct bgp_node
*top
;
4813 struct bgp_node
*rn
;
4814 struct bgp_info
*new;
4815 struct bgp_info
*ri
;
4816 unsigned long match
;
4817 u_char origin
= BGP_ORIGIN_IGP
;
4818 struct aspath
*aspath
= NULL
;
4819 struct aspath
*asmerge
= NULL
;
4820 struct community
*community
= NULL
;
4821 struct community
*commerge
= NULL
;
4823 table
= bgp
->rib
[afi
][safi
];
4826 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4828 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4831 /* If routes exists below this node, generate aggregate routes. */
4832 top
= bgp_node_get (table
, p
);
4833 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4834 if (rn
->p
.prefixlen
> p
->prefixlen
)
4838 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4840 if (BGP_INFO_HOLDDOWN (ri
))
4843 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4845 /* summary-only aggregate route suppress aggregated
4846 route announcement. */
4847 if (aggregate
->summary_only
)
4849 (bgp_info_extra_get (ri
))->suppress
++;
4850 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4853 /* as-set aggregate route generate origin, as path,
4854 community aggregation. */
4855 if (aggregate
->as_set
)
4857 if (origin
< ri
->attr
->origin
)
4858 origin
= ri
->attr
->origin
;
4862 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4863 aspath_free (aspath
);
4867 aspath
= aspath_dup (ri
->attr
->aspath
);
4869 if (ri
->attr
->community
)
4873 commerge
= community_merge (community
,
4874 ri
->attr
->community
);
4875 community
= community_uniq_sort (commerge
);
4876 community_free (commerge
);
4879 community
= community_dup (ri
->attr
->community
);
4886 /* If this node is suppressed, process the change. */
4888 bgp_process (bgp
, rn
, afi
, safi
);
4890 bgp_unlock_node (top
);
4892 /* Add aggregate route to BGP table. */
4893 if (aggregate
->count
)
4895 rn
= bgp_node_get (table
, p
);
4897 new = bgp_info_new ();
4898 new->type
= ZEBRA_ROUTE_BGP
;
4899 new->sub_type
= BGP_ROUTE_AGGREGATE
;
4900 new->peer
= bgp
->peer_self
;
4901 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4902 new->attr
= bgp_attr_aggregate_intern (bgp
, origin
, aspath
, community
, aggregate
->as_set
);
4903 new->uptime
= bgp_clock ();
4905 bgp_info_add (rn
, new);
4906 bgp_unlock_node (rn
);
4908 /* Process change. */
4909 bgp_process (bgp
, rn
, afi
, safi
);
4914 bgp_aggregate_delete (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
4915 safi_t safi
, struct bgp_aggregate
*aggregate
)
4917 struct bgp_table
*table
;
4918 struct bgp_node
*top
;
4919 struct bgp_node
*rn
;
4920 struct bgp_info
*ri
;
4921 unsigned long match
;
4923 table
= bgp
->rib
[afi
][safi
];
4925 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4927 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4930 /* If routes exists below this node, generate aggregate routes. */
4931 top
= bgp_node_get (table
, p
);
4932 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4933 if (rn
->p
.prefixlen
> p
->prefixlen
)
4937 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4939 if (BGP_INFO_HOLDDOWN (ri
))
4942 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4944 if (aggregate
->summary_only
&& ri
->extra
)
4946 ri
->extra
->suppress
--;
4948 if (ri
->extra
->suppress
== 0)
4950 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4958 /* If this node was suppressed, process the change. */
4960 bgp_process (bgp
, rn
, afi
, safi
);
4962 bgp_unlock_node (top
);
4964 /* Delete aggregate route from BGP table. */
4965 rn
= bgp_node_get (table
, p
);
4967 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4968 if (ri
->peer
== bgp
->peer_self
4969 && ri
->type
== ZEBRA_ROUTE_BGP
4970 && ri
->sub_type
== BGP_ROUTE_AGGREGATE
)
4973 /* Withdraw static BGP route from routing table. */
4976 bgp_info_delete (rn
, ri
);
4977 bgp_process (bgp
, rn
, afi
, safi
);
4980 /* Unlock bgp_node_lookup. */
4981 bgp_unlock_node (rn
);
4984 /* Aggregate route attribute. */
4985 #define AGGREGATE_SUMMARY_ONLY 1
4986 #define AGGREGATE_AS_SET 1
4989 bgp_aggregate_set (struct vty
*vty
, const char *prefix_str
,
4990 afi_t afi
, safi_t safi
,
4991 u_char summary_only
, u_char as_set
)
4995 struct bgp_node
*rn
;
4997 struct bgp_aggregate
*aggregate
;
4999 /* Convert string to prefix structure. */
5000 ret
= str2prefix (prefix_str
, &p
);
5003 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5008 /* Get BGP structure. */
5011 /* Old configuration check. */
5012 rn
= bgp_node_get (bgp
->aggregate
[afi
][safi
], &p
);
5016 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
5017 bgp_unlock_node (rn
);
5021 /* Make aggregate address structure. */
5022 aggregate
= bgp_aggregate_new ();
5023 aggregate
->summary_only
= summary_only
;
5024 aggregate
->as_set
= as_set
;
5025 aggregate
->safi
= safi
;
5026 rn
->info
= aggregate
;
5028 /* Aggregate address insert into BGP routing table. */
5029 if (safi
& SAFI_UNICAST
)
5030 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5031 if (safi
& SAFI_MULTICAST
)
5032 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5038 bgp_aggregate_unset (struct vty
*vty
, const char *prefix_str
,
5039 afi_t afi
, safi_t safi
)
5043 struct bgp_node
*rn
;
5045 struct bgp_aggregate
*aggregate
;
5047 /* Convert string to prefix structure. */
5048 ret
= str2prefix (prefix_str
, &p
);
5051 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5056 /* Get BGP structure. */
5059 /* Old configuration check. */
5060 rn
= bgp_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
5063 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
5068 aggregate
= rn
->info
;
5069 if (aggregate
->safi
& SAFI_UNICAST
)
5070 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5071 if (aggregate
->safi
& SAFI_MULTICAST
)
5072 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5074 /* Unlock aggregate address configuration. */
5076 bgp_aggregate_free (aggregate
);
5077 bgp_unlock_node (rn
);
5078 bgp_unlock_node (rn
);
5083 DEFUN (aggregate_address
,
5084 aggregate_address_cmd
,
5085 "aggregate-address A.B.C.D/M",
5086 "Configure BGP aggregate entries\n"
5087 "Aggregate prefix\n")
5089 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
), 0, 0);
5092 DEFUN (aggregate_address_mask
,
5093 aggregate_address_mask_cmd
,
5094 "aggregate-address A.B.C.D A.B.C.D",
5095 "Configure BGP aggregate entries\n"
5096 "Aggregate address\n"
5100 char prefix_str
[BUFSIZ
];
5102 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5106 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5110 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5114 DEFUN (aggregate_address_summary_only
,
5115 aggregate_address_summary_only_cmd
,
5116 "aggregate-address A.B.C.D/M summary-only",
5117 "Configure BGP aggregate entries\n"
5118 "Aggregate prefix\n"
5119 "Filter more specific routes from updates\n")
5121 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5122 AGGREGATE_SUMMARY_ONLY
, 0);
5125 DEFUN (aggregate_address_mask_summary_only
,
5126 aggregate_address_mask_summary_only_cmd
,
5127 "aggregate-address A.B.C.D A.B.C.D summary-only",
5128 "Configure BGP aggregate entries\n"
5129 "Aggregate address\n"
5131 "Filter more specific routes from updates\n")
5134 char prefix_str
[BUFSIZ
];
5136 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5140 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5144 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5145 AGGREGATE_SUMMARY_ONLY
, 0);
5148 DEFUN (aggregate_address_as_set
,
5149 aggregate_address_as_set_cmd
,
5150 "aggregate-address A.B.C.D/M as-set",
5151 "Configure BGP aggregate entries\n"
5152 "Aggregate prefix\n"
5153 "Generate AS set path information\n")
5155 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5156 0, AGGREGATE_AS_SET
);
5159 DEFUN (aggregate_address_mask_as_set
,
5160 aggregate_address_mask_as_set_cmd
,
5161 "aggregate-address A.B.C.D A.B.C.D as-set",
5162 "Configure BGP aggregate entries\n"
5163 "Aggregate address\n"
5165 "Generate AS set path information\n")
5168 char prefix_str
[BUFSIZ
];
5170 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5174 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5178 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5179 0, AGGREGATE_AS_SET
);
5183 DEFUN (aggregate_address_as_set_summary
,
5184 aggregate_address_as_set_summary_cmd
,
5185 "aggregate-address A.B.C.D/M as-set summary-only",
5186 "Configure BGP aggregate entries\n"
5187 "Aggregate prefix\n"
5188 "Generate AS set path information\n"
5189 "Filter more specific routes from updates\n")
5191 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5192 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5195 ALIAS (aggregate_address_as_set_summary
,
5196 aggregate_address_summary_as_set_cmd
,
5197 "aggregate-address A.B.C.D/M summary-only as-set",
5198 "Configure BGP aggregate entries\n"
5199 "Aggregate prefix\n"
5200 "Filter more specific routes from updates\n"
5201 "Generate AS set path information\n")
5203 DEFUN (aggregate_address_mask_as_set_summary
,
5204 aggregate_address_mask_as_set_summary_cmd
,
5205 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5206 "Configure BGP aggregate entries\n"
5207 "Aggregate address\n"
5209 "Generate AS set path information\n"
5210 "Filter more specific routes from updates\n")
5213 char prefix_str
[BUFSIZ
];
5215 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5219 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5223 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5224 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5227 ALIAS (aggregate_address_mask_as_set_summary
,
5228 aggregate_address_mask_summary_as_set_cmd
,
5229 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5230 "Configure BGP aggregate entries\n"
5231 "Aggregate address\n"
5233 "Filter more specific routes from updates\n"
5234 "Generate AS set path information\n")
5236 DEFUN (no_aggregate_address
,
5237 no_aggregate_address_cmd
,
5238 "no aggregate-address A.B.C.D/M",
5240 "Configure BGP aggregate entries\n"
5241 "Aggregate prefix\n")
5243 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
));
5246 ALIAS (no_aggregate_address
,
5247 no_aggregate_address_summary_only_cmd
,
5248 "no aggregate-address A.B.C.D/M summary-only",
5250 "Configure BGP aggregate entries\n"
5251 "Aggregate prefix\n"
5252 "Filter more specific routes from updates\n")
5254 ALIAS (no_aggregate_address
,
5255 no_aggregate_address_as_set_cmd
,
5256 "no aggregate-address A.B.C.D/M as-set",
5258 "Configure BGP aggregate entries\n"
5259 "Aggregate prefix\n"
5260 "Generate AS set path information\n")
5262 ALIAS (no_aggregate_address
,
5263 no_aggregate_address_as_set_summary_cmd
,
5264 "no aggregate-address A.B.C.D/M as-set summary-only",
5266 "Configure BGP aggregate entries\n"
5267 "Aggregate prefix\n"
5268 "Generate AS set path information\n"
5269 "Filter more specific routes from updates\n")
5271 ALIAS (no_aggregate_address
,
5272 no_aggregate_address_summary_as_set_cmd
,
5273 "no aggregate-address A.B.C.D/M summary-only as-set",
5275 "Configure BGP aggregate entries\n"
5276 "Aggregate prefix\n"
5277 "Filter more specific routes from updates\n"
5278 "Generate AS set path information\n")
5280 DEFUN (no_aggregate_address_mask
,
5281 no_aggregate_address_mask_cmd
,
5282 "no aggregate-address A.B.C.D A.B.C.D",
5284 "Configure BGP aggregate entries\n"
5285 "Aggregate address\n"
5289 char prefix_str
[BUFSIZ
];
5291 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5295 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5299 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
5302 ALIAS (no_aggregate_address_mask
,
5303 no_aggregate_address_mask_summary_only_cmd
,
5304 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5306 "Configure BGP aggregate entries\n"
5307 "Aggregate address\n"
5309 "Filter more specific routes from updates\n")
5311 ALIAS (no_aggregate_address_mask
,
5312 no_aggregate_address_mask_as_set_cmd
,
5313 "no aggregate-address A.B.C.D A.B.C.D as-set",
5315 "Configure BGP aggregate entries\n"
5316 "Aggregate address\n"
5318 "Generate AS set path information\n")
5320 ALIAS (no_aggregate_address_mask
,
5321 no_aggregate_address_mask_as_set_summary_cmd
,
5322 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5324 "Configure BGP aggregate entries\n"
5325 "Aggregate address\n"
5327 "Generate AS set path information\n"
5328 "Filter more specific routes from updates\n")
5330 ALIAS (no_aggregate_address_mask
,
5331 no_aggregate_address_mask_summary_as_set_cmd
,
5332 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5334 "Configure BGP aggregate entries\n"
5335 "Aggregate address\n"
5337 "Filter more specific routes from updates\n"
5338 "Generate AS set path information\n")
5341 DEFUN (ipv6_aggregate_address
,
5342 ipv6_aggregate_address_cmd
,
5343 "aggregate-address X:X::X:X/M",
5344 "Configure BGP aggregate entries\n"
5345 "Aggregate prefix\n")
5347 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0, 0);
5350 DEFUN (ipv6_aggregate_address_summary_only
,
5351 ipv6_aggregate_address_summary_only_cmd
,
5352 "aggregate-address X:X::X:X/M summary-only",
5353 "Configure BGP aggregate entries\n"
5354 "Aggregate prefix\n"
5355 "Filter more specific routes from updates\n")
5357 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5358 AGGREGATE_SUMMARY_ONLY
, 0);
5361 DEFUN (no_ipv6_aggregate_address
,
5362 no_ipv6_aggregate_address_cmd
,
5363 "no aggregate-address X:X::X:X/M",
5365 "Configure BGP aggregate entries\n"
5366 "Aggregate prefix\n")
5368 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5371 DEFUN (no_ipv6_aggregate_address_summary_only
,
5372 no_ipv6_aggregate_address_summary_only_cmd
,
5373 "no aggregate-address X:X::X:X/M summary-only",
5375 "Configure BGP aggregate entries\n"
5376 "Aggregate prefix\n"
5377 "Filter more specific routes from updates\n")
5379 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5382 ALIAS (ipv6_aggregate_address
,
5383 old_ipv6_aggregate_address_cmd
,
5384 "ipv6 bgp aggregate-address X:X::X:X/M",
5387 "Configure BGP aggregate entries\n"
5388 "Aggregate prefix\n")
5390 ALIAS (ipv6_aggregate_address_summary_only
,
5391 old_ipv6_aggregate_address_summary_only_cmd
,
5392 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5395 "Configure BGP aggregate entries\n"
5396 "Aggregate prefix\n"
5397 "Filter more specific routes from updates\n")
5399 ALIAS (no_ipv6_aggregate_address
,
5400 old_no_ipv6_aggregate_address_cmd
,
5401 "no ipv6 bgp aggregate-address X:X::X:X/M",
5405 "Configure BGP aggregate entries\n"
5406 "Aggregate prefix\n")
5408 ALIAS (no_ipv6_aggregate_address_summary_only
,
5409 old_no_ipv6_aggregate_address_summary_only_cmd
,
5410 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5414 "Configure BGP aggregate entries\n"
5415 "Aggregate prefix\n"
5416 "Filter more specific routes from updates\n")
5417 #endif /* HAVE_IPV6 */
5419 /* Redistribute route treatment. */
5421 bgp_redistribute_add (struct prefix
*p
, struct in_addr
*nexthop
,
5422 u_int32_t metric
, u_char type
)
5425 struct listnode
*node
, *nnode
;
5426 struct bgp_info
*new;
5427 struct bgp_info
*bi
;
5428 struct bgp_info info
;
5429 struct bgp_node
*bn
;
5430 struct attr attr
= { 0 };
5431 struct attr attr_new
= { 0 };
5432 struct attr
*new_attr
;
5436 /* Make default attribute. */
5437 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
5439 attr
.nexthop
= *nexthop
;
5442 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
5444 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
5446 afi
= family2afi (p
->family
);
5448 if (bgp
->redist
[afi
][type
])
5450 /* Copy attribute for modification. */
5451 bgp_attr_dup (&attr_new
, &attr
);
5453 if (bgp
->redist_metric_flag
[afi
][type
])
5454 attr_new
.med
= bgp
->redist_metric
[afi
][type
];
5456 /* Apply route-map. */
5457 if (bgp
->rmap
[afi
][type
].map
)
5459 info
.peer
= bgp
->peer_self
;
5460 info
.attr
= &attr_new
;
5462 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
);
5464 ret
= route_map_apply (bgp
->rmap
[afi
][type
].map
, p
, RMAP_BGP
,
5467 bgp
->peer_self
->rmap_type
= 0;
5469 if (ret
== RMAP_DENYMATCH
)
5471 /* Free uninterned attribute. */
5472 bgp_attr_flush (&attr_new
);
5473 bgp_attr_extra_free (&attr_new
);
5475 /* Unintern original. */
5476 aspath_unintern (attr
.aspath
);
5477 bgp_attr_extra_free (&attr
);
5478 bgp_redistribute_delete (p
, type
);
5483 bn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
],
5484 afi
, SAFI_UNICAST
, p
, NULL
);
5486 new_attr
= bgp_attr_intern (&attr_new
);
5487 bgp_attr_extra_free (&attr_new
);
5489 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
5490 if (bi
->peer
== bgp
->peer_self
5491 && bi
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
5496 if (attrhash_cmp (bi
->attr
, new_attr
) &&
5497 !CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5499 bgp_attr_unintern (new_attr
);
5500 aspath_unintern (attr
.aspath
);
5501 bgp_attr_extra_free (&attr
);
5502 bgp_unlock_node (bn
);
5507 /* The attribute is changed. */
5508 bgp_info_set_flag (bn
, bi
, BGP_INFO_ATTR_CHANGED
);
5510 /* Rewrite BGP route information. */
5511 if (CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5512 bgp_info_restore(bn
, bi
);
5514 bgp_aggregate_decrement (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5515 bgp_attr_unintern (bi
->attr
);
5516 bi
->attr
= new_attr
;
5517 bi
->uptime
= bgp_clock ();
5519 /* Process change. */
5520 bgp_aggregate_increment (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5521 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5522 bgp_unlock_node (bn
);
5523 aspath_unintern (attr
.aspath
);
5524 bgp_attr_extra_free (&attr
);
5529 new = bgp_info_new ();
5531 new->sub_type
= BGP_ROUTE_REDISTRIBUTE
;
5532 new->peer
= bgp
->peer_self
;
5533 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5534 new->attr
= new_attr
;
5535 new->uptime
= bgp_clock ();
5537 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
5538 bgp_info_add (bn
, new);
5539 bgp_unlock_node (bn
);
5540 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5544 /* Unintern original. */
5545 aspath_unintern (attr
.aspath
);
5546 bgp_attr_extra_free (&attr
);
5550 bgp_redistribute_delete (struct prefix
*p
, u_char type
)
5553 struct listnode
*node
, *nnode
;
5555 struct bgp_node
*rn
;
5556 struct bgp_info
*ri
;
5558 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
5560 afi
= family2afi (p
->family
);
5562 if (bgp
->redist
[afi
][type
])
5564 rn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
5566 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5567 if (ri
->peer
== bgp
->peer_self
5568 && ri
->type
== type
)
5573 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
5574 bgp_info_delete (rn
, ri
);
5575 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5577 bgp_unlock_node (rn
);
5582 /* Withdraw specified route type's route. */
5584 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
)
5586 struct bgp_node
*rn
;
5587 struct bgp_info
*ri
;
5588 struct bgp_table
*table
;
5590 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
5592 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
5594 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5595 if (ri
->peer
== bgp
->peer_self
5596 && ri
->type
== type
)
5601 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
5602 bgp_info_delete (rn
, ri
);
5603 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5608 /* Static function to display route. */
5610 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
5613 u_int32_t destination
;
5616 if (p
->family
== AF_INET
)
5618 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
5619 destination
= ntohl (p
->u
.prefix4
.s_addr
);
5621 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
5622 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
5623 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
5624 || p
->u
.prefix4
.s_addr
== 0)
5626 /* When mask is natural, mask is not displayed. */
5629 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
5632 len
= vty_out (vty
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
5637 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
5639 vty_out (vty
, "%*s", len
, " ");
5642 enum bgp_display_type
5647 /* Print the short form route status for a bgp_info */
5649 route_vty_short_status_out (struct vty
*vty
, struct bgp_info
*binfo
)
5651 /* Route status display. */
5652 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5654 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5656 else if (binfo
->extra
&& binfo
->extra
->suppress
)
5658 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5664 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5666 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5668 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5673 /* Internal route. */
5674 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
5680 /* called from terminal list command */
5682 route_vty_out (struct vty
*vty
, struct prefix
*p
,
5683 struct bgp_info
*binfo
, int display
, safi_t safi
)
5687 /* short status lead text */
5688 route_vty_short_status_out (vty
, binfo
);
5690 /* print prefix and mask */
5692 route_vty_out_route (p
, vty
);
5694 vty_out (vty
, "%*s", 17, " ");
5696 /* Print attribute */
5700 if (p
->family
== AF_INET
)
5702 if (safi
== SAFI_MPLS_VPN
)
5703 vty_out (vty
, "%-16s",
5704 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5706 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5709 else if (p
->family
== AF_INET6
)
5714 len
= vty_out (vty
, "%s",
5715 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5719 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5721 vty_out (vty
, "%*s", len
, " ");
5723 #endif /* HAVE_IPV6 */
5725 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5726 vty_out (vty
, "%10d", attr
->med
);
5730 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5731 vty_out (vty
, "%7d", attr
->local_pref
);
5735 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
5739 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5742 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5744 vty_out (vty
, "%s", VTY_NEWLINE
);
5747 /* called from terminal list command */
5749 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
,
5750 struct attr
*attr
, safi_t safi
)
5752 /* Route status display. */
5757 /* print prefix and mask */
5758 route_vty_out_route (p
, vty
);
5760 /* Print attribute */
5763 if (p
->family
== AF_INET
)
5765 if (safi
== SAFI_MPLS_VPN
)
5766 vty_out (vty
, "%-16s",
5767 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5769 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5772 else if (p
->family
== AF_INET6
)
5777 assert (attr
->extra
);
5779 len
= vty_out (vty
, "%s",
5780 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5784 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5786 vty_out (vty
, "%*s", len
, " ");
5788 #endif /* HAVE_IPV6 */
5790 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5791 vty_out (vty
, "%10d", attr
->med
);
5795 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5796 vty_out (vty
, "%7d", attr
->local_pref
);
5800 vty_out (vty
, "%7d ", (attr
->extra
? attr
->extra
->weight
: 0));
5804 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5807 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5810 vty_out (vty
, "%s", VTY_NEWLINE
);
5814 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
5815 struct bgp_info
*binfo
, int display
, safi_t safi
)
5818 u_int32_t label
= 0;
5823 /* short status lead text */
5824 route_vty_short_status_out (vty
, binfo
);
5826 /* print prefix and mask */
5828 route_vty_out_route (p
, vty
);
5830 vty_out (vty
, "%*s", 17, " ");
5832 /* Print attribute */
5836 if (p
->family
== AF_INET
)
5838 if (safi
== SAFI_MPLS_VPN
)
5839 vty_out (vty
, "%-16s",
5840 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5842 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5845 else if (p
->family
== AF_INET6
)
5847 assert (attr
->extra
);
5850 if (attr
->extra
->mp_nexthop_len
== 16)
5852 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5854 else if (attr
->extra
->mp_nexthop_len
== 32)
5855 vty_out (vty
, "%s(%s)",
5856 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5858 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
5862 #endif /* HAVE_IPV6 */
5865 label
= decode_label (binfo
->extra
->tag
);
5867 vty_out (vty
, "notag/%d", label
);
5869 vty_out (vty
, "%s", VTY_NEWLINE
);
5872 /* dampening route */
5874 damp_route_vty_out (struct vty
*vty
, struct prefix
*p
,
5875 struct bgp_info
*binfo
, int display
, safi_t safi
)
5879 char timebuf
[BGP_UPTIME_LEN
];
5881 /* short status lead text */
5882 route_vty_short_status_out (vty
, binfo
);
5884 /* print prefix and mask */
5886 route_vty_out_route (p
, vty
);
5888 vty_out (vty
, "%*s", 17, " ");
5890 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
5893 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 34, " ");
5895 vty_out (vty
, "%*s", len
, " ");
5897 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
));
5899 /* Print attribute */
5905 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5908 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5910 vty_out (vty
, "%s", VTY_NEWLINE
);
5915 flap_route_vty_out (struct vty
*vty
, struct prefix
*p
,
5916 struct bgp_info
*binfo
, int display
, safi_t safi
)
5919 struct bgp_damp_info
*bdi
;
5920 char timebuf
[BGP_UPTIME_LEN
];
5926 bdi
= binfo
->extra
->damp_info
;
5928 /* short status lead text */
5929 route_vty_short_status_out (vty
, binfo
);
5931 /* print prefix and mask */
5933 route_vty_out_route (p
, vty
);
5935 vty_out (vty
, "%*s", 17, " ");
5937 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
5940 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 33, " ");
5942 vty_out (vty
, "%*s", len
, " ");
5944 len
= vty_out (vty
, "%d", bdi
->flap
);
5949 vty_out (vty
, "%*s ", len
, " ");
5951 vty_out (vty
, "%s ", peer_uptime (bdi
->start_time
,
5952 timebuf
, BGP_UPTIME_LEN
));
5954 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
)
5955 && ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5956 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
));
5958 vty_out (vty
, "%*s ", 8, " ");
5960 /* Print attribute */
5966 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5969 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5971 vty_out (vty
, "%s", VTY_NEWLINE
);
5975 route_vty_out_detail (struct vty
*vty
, struct bgp
*bgp
, struct prefix
*p
,
5976 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
)
5978 char buf
[INET6_ADDRSTRLEN
];
5981 int sockunion_vty_out (struct vty
*, union sockunion
*);
5987 /* Line1 display AS-path, Aggregator */
5991 if (aspath_count_hops (attr
->aspath
) == 0)
5992 vty_out (vty
, "Local");
5994 aspath_print_vty (vty
, "%s", attr
->aspath
, "");
5997 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5998 vty_out (vty
, ", (removed)");
5999 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6000 vty_out (vty
, ", (stale)");
6001 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
6002 vty_out (vty
, ", (aggregated by %u %s)",
6003 attr
->extra
->aggregator_as
,
6004 inet_ntoa (attr
->extra
->aggregator_addr
));
6005 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
6006 vty_out (vty
, ", (Received from a RR-client)");
6007 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
6008 vty_out (vty
, ", (Received from a RS-client)");
6009 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6010 vty_out (vty
, ", (history entry)");
6011 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6012 vty_out (vty
, ", (suppressed due to dampening)");
6013 vty_out (vty
, "%s", VTY_NEWLINE
);
6015 /* Line2 display Next-hop, Neighbor, Router-id */
6016 if (p
->family
== AF_INET
)
6018 vty_out (vty
, " %s", safi
== SAFI_MPLS_VPN
?
6019 inet_ntoa (attr
->extra
->mp_nexthop_global_in
) :
6020 inet_ntoa (attr
->nexthop
));
6025 assert (attr
->extra
);
6026 vty_out (vty
, " %s",
6027 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6028 buf
, INET6_ADDRSTRLEN
));
6030 #endif /* HAVE_IPV6 */
6032 if (binfo
->peer
== bgp
->peer_self
)
6034 vty_out (vty
, " from %s ",
6035 p
->family
== AF_INET
? "0.0.0.0" : "::");
6036 vty_out (vty
, "(%s)", inet_ntoa(bgp
->router_id
));
6040 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
6041 vty_out (vty
, " (inaccessible)");
6042 else if (binfo
->extra
&& binfo
->extra
->igpmetric
)
6043 vty_out (vty
, " (metric %d)", binfo
->extra
->igpmetric
);
6044 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6045 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
6046 vty_out (vty
, " (%s)", inet_ntoa (attr
->extra
->originator_id
));
6048 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
6050 vty_out (vty
, "%s", VTY_NEWLINE
);
6053 /* display nexthop local */
6054 if (attr
->extra
&& attr
->extra
->mp_nexthop_len
== 32)
6056 vty_out (vty
, " (%s)%s",
6057 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6058 buf
, INET6_ADDRSTRLEN
),
6061 #endif /* HAVE_IPV6 */
6063 /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */
6064 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
6066 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
6067 vty_out (vty
, ", metric %d", attr
->med
);
6069 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
6070 vty_out (vty
, ", localpref %d", attr
->local_pref
);
6072 vty_out (vty
, ", localpref %d", bgp
->default_local_pref
);
6074 if (attr
->extra
&& attr
->extra
->weight
!= 0)
6075 vty_out (vty
, ", weight %d", attr
->extra
->weight
);
6077 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6078 vty_out (vty
, ", valid");
6080 if (binfo
->peer
!= bgp
->peer_self
)
6082 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
6083 vty_out (vty
, ", internal");
6085 vty_out (vty
, ", %s",
6086 (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
) ? "confed-external" : "external"));
6088 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
6089 vty_out (vty
, ", aggregated, local");
6090 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
6091 vty_out (vty
, ", sourced");
6093 vty_out (vty
, ", sourced, local");
6095 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
6096 vty_out (vty
, ", atomic-aggregate");
6098 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
6099 vty_out (vty
, ", best");
6101 vty_out (vty
, "%s", VTY_NEWLINE
);
6103 /* Line 4 display Community */
6104 if (attr
->community
)
6105 vty_out (vty
, " Community: %s%s", attr
->community
->str
,
6108 /* Line 5 display Extended-community */
6109 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
6110 vty_out (vty
, " Extended Community: %s%s",
6111 attr
->extra
->ecommunity
->str
, VTY_NEWLINE
);
6113 /* Line 6 display Originator, Cluster-id */
6114 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
6115 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
6117 assert (attr
->extra
);
6118 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
6119 vty_out (vty
, " Originator: %s",
6120 inet_ntoa (attr
->extra
->originator_id
));
6122 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
6125 vty_out (vty
, ", Cluster list: ");
6126 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
6127 vty_out (vty
, "%s ",
6128 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
6130 vty_out (vty
, "%s", VTY_NEWLINE
);
6133 /* 7: AS Pathlimit */
6134 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_AS_PATHLIMIT
))
6137 vty_out (vty
, " AS-Pathlimit: %u",
6138 attr
->pathlimit
.ttl
);
6139 if (attr
->pathlimit
.as
)
6140 vty_out (vty
, " (%u)", attr
->pathlimit
.as
);
6141 vty_out (vty
, "%s", VTY_NEWLINE
);
6144 if (binfo
->extra
&& binfo
->extra
->damp_info
)
6145 bgp_damp_info_vty (vty
, binfo
);
6147 /* Line 7 display Uptime */
6148 vty_out (vty
, " Last update: %s", ctime (&binfo
->uptime
));
6150 vty_out (vty
, "%s", VTY_NEWLINE
);
6153 #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"
6154 #define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
6155 #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
6156 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
6157 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
6161 bgp_show_type_normal
,
6162 bgp_show_type_regexp
,
6163 bgp_show_type_prefix_list
,
6164 bgp_show_type_filter_list
,
6165 bgp_show_type_route_map
,
6166 bgp_show_type_neighbor
,
6167 bgp_show_type_cidr_only
,
6168 bgp_show_type_prefix_longer
,
6169 bgp_show_type_community_all
,
6170 bgp_show_type_community
,
6171 bgp_show_type_community_exact
,
6172 bgp_show_type_community_list
,
6173 bgp_show_type_community_list_exact
,
6174 bgp_show_type_flap_statistics
,
6175 bgp_show_type_flap_address
,
6176 bgp_show_type_flap_prefix
,
6177 bgp_show_type_flap_cidr_only
,
6178 bgp_show_type_flap_regexp
,
6179 bgp_show_type_flap_filter_list
,
6180 bgp_show_type_flap_prefix_list
,
6181 bgp_show_type_flap_prefix_longer
,
6182 bgp_show_type_flap_route_map
,
6183 bgp_show_type_flap_neighbor
,
6184 bgp_show_type_dampend_paths
,
6185 bgp_show_type_damp_neighbor
6189 bgp_show_table (struct vty
*vty
, struct bgp_table
*table
, struct in_addr
*router_id
,
6190 enum bgp_show_type type
, void *output_arg
)
6192 struct bgp_info
*ri
;
6193 struct bgp_node
*rn
;
6196 unsigned long output_count
;
6198 /* This is first entry point, so reset total line. */
6201 /* Start processing of routes. */
6202 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
6203 if (rn
->info
!= NULL
)
6207 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6209 if (type
== bgp_show_type_flap_statistics
6210 || type
== bgp_show_type_flap_address
6211 || type
== bgp_show_type_flap_prefix
6212 || type
== bgp_show_type_flap_cidr_only
6213 || type
== bgp_show_type_flap_regexp
6214 || type
== bgp_show_type_flap_filter_list
6215 || type
== bgp_show_type_flap_prefix_list
6216 || type
== bgp_show_type_flap_prefix_longer
6217 || type
== bgp_show_type_flap_route_map
6218 || type
== bgp_show_type_flap_neighbor
6219 || type
== bgp_show_type_dampend_paths
6220 || type
== bgp_show_type_damp_neighbor
)
6222 if (!(ri
->extra
&& ri
->extra
->damp_info
))
6225 if (type
== bgp_show_type_regexp
6226 || type
== bgp_show_type_flap_regexp
)
6228 regex_t
*regex
= output_arg
;
6230 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
6233 if (type
== bgp_show_type_prefix_list
6234 || type
== bgp_show_type_flap_prefix_list
)
6236 struct prefix_list
*plist
= output_arg
;
6238 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
6241 if (type
== bgp_show_type_filter_list
6242 || type
== bgp_show_type_flap_filter_list
)
6244 struct as_list
*as_list
= output_arg
;
6246 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
6249 if (type
== bgp_show_type_route_map
6250 || type
== bgp_show_type_flap_route_map
)
6252 struct route_map
*rmap
= output_arg
;
6253 struct bgp_info binfo
;
6254 struct attr dummy_attr
= { 0 };
6257 bgp_attr_dup (&dummy_attr
, ri
->attr
);
6258 binfo
.peer
= ri
->peer
;
6259 binfo
.attr
= &dummy_attr
;
6261 ret
= route_map_apply (rmap
, &rn
->p
, RMAP_BGP
, &binfo
);
6263 bgp_attr_extra_free (&dummy_attr
);
6265 if (ret
== RMAP_DENYMATCH
)
6268 if (type
== bgp_show_type_neighbor
6269 || type
== bgp_show_type_flap_neighbor
6270 || type
== bgp_show_type_damp_neighbor
)
6272 union sockunion
*su
= output_arg
;
6274 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
6277 if (type
== bgp_show_type_cidr_only
6278 || type
== bgp_show_type_flap_cidr_only
)
6280 u_int32_t destination
;
6282 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
6283 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
6285 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
6287 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
6290 if (type
== bgp_show_type_prefix_longer
6291 || type
== bgp_show_type_flap_prefix_longer
)
6293 struct prefix
*p
= output_arg
;
6295 if (! prefix_match (p
, &rn
->p
))
6298 if (type
== bgp_show_type_community_all
)
6300 if (! ri
->attr
->community
)
6303 if (type
== bgp_show_type_community
)
6305 struct community
*com
= output_arg
;
6307 if (! ri
->attr
->community
||
6308 ! community_match (ri
->attr
->community
, com
))
6311 if (type
== bgp_show_type_community_exact
)
6313 struct community
*com
= output_arg
;
6315 if (! ri
->attr
->community
||
6316 ! community_cmp (ri
->attr
->community
, com
))
6319 if (type
== bgp_show_type_community_list
)
6321 struct community_list
*list
= output_arg
;
6323 if (! community_list_match (ri
->attr
->community
, list
))
6326 if (type
== bgp_show_type_community_list_exact
)
6328 struct community_list
*list
= output_arg
;
6330 if (! community_list_exact_match (ri
->attr
->community
, list
))
6333 if (type
== bgp_show_type_flap_address
6334 || type
== bgp_show_type_flap_prefix
)
6336 struct prefix
*p
= output_arg
;
6338 if (! prefix_match (&rn
->p
, p
))
6341 if (type
== bgp_show_type_flap_prefix
)
6342 if (p
->prefixlen
!= rn
->p
.prefixlen
)
6345 if (type
== bgp_show_type_dampend_paths
6346 || type
== bgp_show_type_damp_neighbor
)
6348 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
)
6349 || CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
6355 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id
), VTY_NEWLINE
);
6356 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
6357 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
6358 if (type
== bgp_show_type_dampend_paths
6359 || type
== bgp_show_type_damp_neighbor
)
6360 vty_out (vty
, BGP_SHOW_DAMP_HEADER
, VTY_NEWLINE
);
6361 else if (type
== bgp_show_type_flap_statistics
6362 || type
== bgp_show_type_flap_address
6363 || type
== bgp_show_type_flap_prefix
6364 || type
== bgp_show_type_flap_cidr_only
6365 || type
== bgp_show_type_flap_regexp
6366 || type
== bgp_show_type_flap_filter_list
6367 || type
== bgp_show_type_flap_prefix_list
6368 || type
== bgp_show_type_flap_prefix_longer
6369 || type
== bgp_show_type_flap_route_map
6370 || type
== bgp_show_type_flap_neighbor
)
6371 vty_out (vty
, BGP_SHOW_FLAP_HEADER
, VTY_NEWLINE
);
6373 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
6377 if (type
== bgp_show_type_dampend_paths
6378 || type
== bgp_show_type_damp_neighbor
)
6379 damp_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6380 else if (type
== bgp_show_type_flap_statistics
6381 || type
== bgp_show_type_flap_address
6382 || type
== bgp_show_type_flap_prefix
6383 || type
== bgp_show_type_flap_cidr_only
6384 || type
== bgp_show_type_flap_regexp
6385 || type
== bgp_show_type_flap_filter_list
6386 || type
== bgp_show_type_flap_prefix_list
6387 || type
== bgp_show_type_flap_prefix_longer
6388 || type
== bgp_show_type_flap_route_map
6389 || type
== bgp_show_type_flap_neighbor
)
6390 flap_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6392 route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6399 /* No route is displayed */
6400 if (output_count
== 0)
6402 if (type
== bgp_show_type_normal
)
6403 vty_out (vty
, "No BGP network exists%s", VTY_NEWLINE
);
6406 vty_out (vty
, "%sTotal number of prefixes %ld%s",
6407 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
6413 bgp_show (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
6414 enum bgp_show_type type
, void *output_arg
)
6416 struct bgp_table
*table
;
6419 bgp
= bgp_get_default ();
6424 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
6429 table
= bgp
->rib
[afi
][safi
];
6431 return bgp_show_table (vty
, table
, &bgp
->router_id
, type
, output_arg
);
6434 /* Header of detailed BGP route information */
6436 route_vty_out_detail_header (struct vty
*vty
, struct bgp
*bgp
,
6437 struct bgp_node
*rn
,
6438 struct prefix_rd
*prd
, afi_t afi
, safi_t safi
)
6440 struct bgp_info
*ri
;
6443 struct listnode
*node
, *nnode
;
6444 char buf1
[INET6_ADDRSTRLEN
];
6445 char buf2
[INET6_ADDRSTRLEN
];
6450 int no_advertise
= 0;
6455 vty_out (vty
, "BGP routing table entry for %s%s%s/%d%s",
6456 (safi
== SAFI_MPLS_VPN
?
6457 prefix_rd2str (prd
, buf1
, RD_ADDRSTRLEN
) : ""),
6458 safi
== SAFI_MPLS_VPN
? ":" : "",
6459 inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
),
6460 p
->prefixlen
, VTY_NEWLINE
);
6462 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6465 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
6468 if (ri
->extra
&& ri
->extra
->suppress
)
6470 if (ri
->attr
->community
!= NULL
)
6472 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
6474 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
6476 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
6482 vty_out (vty
, "Paths: (%d available", count
);
6485 vty_out (vty
, ", best #%d", best
);
6486 if (safi
== SAFI_UNICAST
)
6487 vty_out (vty
, ", table Default-IP-Routing-Table");
6490 vty_out (vty
, ", no best path");
6492 vty_out (vty
, ", not advertised to any peer");
6494 vty_out (vty
, ", not advertised to EBGP peer");
6496 vty_out (vty
, ", not advertised outside local AS");
6498 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
6499 vty_out (vty
, ")%s", VTY_NEWLINE
);
6501 /* advertised peer */
6502 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
6504 if (bgp_adj_out_lookup (peer
, p
, afi
, safi
, rn
))
6507 vty_out (vty
, " Advertised to non peer-group peers:%s ", VTY_NEWLINE
);
6508 vty_out (vty
, " %s", sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6513 vty_out (vty
, " Not advertised to any peer");
6514 vty_out (vty
, "%s", VTY_NEWLINE
);
6517 /* Display specified route of BGP table. */
6519 bgp_show_route_in_table (struct vty
*vty
, struct bgp
*bgp
,
6520 struct bgp_table
*rib
, const char *ip_str
,
6521 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
6527 struct prefix match
;
6528 struct bgp_node
*rn
;
6529 struct bgp_node
*rm
;
6530 struct bgp_info
*ri
;
6531 struct bgp_table
*table
;
6533 /* Check IP address argument. */
6534 ret
= str2prefix (ip_str
, &match
);
6537 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
6541 match
.family
= afi2family (afi
);
6543 if (safi
== SAFI_MPLS_VPN
)
6545 for (rn
= bgp_table_top (rib
); rn
; rn
= bgp_route_next (rn
))
6547 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
6550 if ((table
= rn
->info
) != NULL
)
6554 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
6556 if (prefix_check
&& rm
->p
.prefixlen
!= match
.prefixlen
)
6559 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
6563 route_vty_out_detail_header (vty
, bgp
, rm
, (struct prefix_rd
*)&rn
->p
,
6564 AFI_IP
, SAFI_MPLS_VPN
);
6569 route_vty_out_detail (vty
, bgp
, &rm
->p
, ri
, AFI_IP
, SAFI_MPLS_VPN
);
6579 if ((rn
= bgp_node_match (rib
, &match
)) != NULL
)
6581 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
6583 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6587 route_vty_out_detail_header (vty
, bgp
, rn
, NULL
, afi
, safi
);
6591 route_vty_out_detail (vty
, bgp
, &rn
->p
, ri
, afi
, safi
);
6599 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
6606 /* Display specified route of Main RIB */
6608 bgp_show_route (struct vty
*vty
, const char *view_name
, const char *ip_str
,
6609 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
6614 /* BGP structure lookup. */
6617 bgp
= bgp_lookup_by_name (view_name
);
6620 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
6626 bgp
= bgp_get_default ();
6629 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
6634 return bgp_show_route_in_table (vty
, bgp
, bgp
->rib
[afi
][safi
], ip_str
,
6635 afi
, safi
, prd
, prefix_check
);
6638 /* BGP route print out function. */
6646 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6649 DEFUN (show_ip_bgp_ipv4
,
6650 show_ip_bgp_ipv4_cmd
,
6651 "show ip bgp ipv4 (unicast|multicast)",
6656 "Address Family modifier\n"
6657 "Address Family modifier\n")
6659 if (strncmp (argv
[0], "m", 1) == 0)
6660 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
, bgp_show_type_normal
,
6663 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6666 DEFUN (show_ip_bgp_route
,
6667 show_ip_bgp_route_cmd
,
6668 "show ip bgp A.B.C.D",
6672 "Network in the BGP routing table to display\n")
6674 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6677 DEFUN (show_ip_bgp_ipv4_route
,
6678 show_ip_bgp_ipv4_route_cmd
,
6679 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
6684 "Address Family modifier\n"
6685 "Address Family modifier\n"
6686 "Network in the BGP routing table to display\n")
6688 if (strncmp (argv
[0], "m", 1) == 0)
6689 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0);
6691 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6694 DEFUN (show_ip_bgp_vpnv4_all_route
,
6695 show_ip_bgp_vpnv4_all_route_cmd
,
6696 "show ip bgp vpnv4 all A.B.C.D",
6700 "Display VPNv4 NLRI specific information\n"
6701 "Display information about all VPNv4 NLRIs\n"
6702 "Network in the BGP routing table to display\n")
6704 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 0);
6707 DEFUN (show_ip_bgp_vpnv4_rd_route
,
6708 show_ip_bgp_vpnv4_rd_route_cmd
,
6709 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
6713 "Display VPNv4 NLRI specific information\n"
6714 "Display information for a route distinguisher\n"
6715 "VPN Route Distinguisher\n"
6716 "Network in the BGP routing table to display\n")
6719 struct prefix_rd prd
;
6721 ret
= str2prefix_rd (argv
[0], &prd
);
6724 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
6727 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0);
6730 DEFUN (show_ip_bgp_prefix
,
6731 show_ip_bgp_prefix_cmd
,
6732 "show ip bgp A.B.C.D/M",
6736 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6738 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6741 DEFUN (show_ip_bgp_ipv4_prefix
,
6742 show_ip_bgp_ipv4_prefix_cmd
,
6743 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
6748 "Address Family modifier\n"
6749 "Address Family modifier\n"
6750 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6752 if (strncmp (argv
[0], "m", 1) == 0)
6753 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1);
6755 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6758 DEFUN (show_ip_bgp_vpnv4_all_prefix
,
6759 show_ip_bgp_vpnv4_all_prefix_cmd
,
6760 "show ip bgp vpnv4 all A.B.C.D/M",
6764 "Display VPNv4 NLRI specific information\n"
6765 "Display information about all VPNv4 NLRIs\n"
6766 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6768 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 1);
6771 DEFUN (show_ip_bgp_vpnv4_rd_prefix
,
6772 show_ip_bgp_vpnv4_rd_prefix_cmd
,
6773 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
6777 "Display VPNv4 NLRI specific information\n"
6778 "Display information for a route distinguisher\n"
6779 "VPN Route Distinguisher\n"
6780 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6783 struct prefix_rd prd
;
6785 ret
= str2prefix_rd (argv
[0], &prd
);
6788 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
6791 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 1);
6794 DEFUN (show_ip_bgp_view
,
6795 show_ip_bgp_view_cmd
,
6796 "show ip bgp view WORD",
6805 /* BGP structure lookup. */
6806 bgp
= bgp_lookup_by_name (argv
[0]);
6809 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
6813 return bgp_show (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6816 DEFUN (show_ip_bgp_view_route
,
6817 show_ip_bgp_view_route_cmd
,
6818 "show ip bgp view WORD A.B.C.D",
6824 "Network in the BGP routing table to display\n")
6826 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6829 DEFUN (show_ip_bgp_view_prefix
,
6830 show_ip_bgp_view_prefix_cmd
,
6831 "show ip bgp view WORD A.B.C.D/M",
6837 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6839 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6849 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
6861 DEFUN (show_ipv6_bgp
,
6868 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
6872 DEFUN (show_bgp_route
,
6874 "show bgp X:X::X:X",
6877 "Network in the BGP routing table to display\n")
6879 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6882 ALIAS (show_bgp_route
,
6883 show_bgp_ipv6_route_cmd
,
6884 "show bgp ipv6 X:X::X:X",
6888 "Network in the BGP routing table to display\n")
6891 DEFUN (show_ipv6_bgp_route
,
6892 show_ipv6_bgp_route_cmd
,
6893 "show ipv6 bgp X:X::X:X",
6897 "Network in the BGP routing table to display\n")
6899 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6902 DEFUN (show_bgp_prefix
,
6903 show_bgp_prefix_cmd
,
6904 "show bgp X:X::X:X/M",
6907 "IPv6 prefix <network>/<length>\n")
6909 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6912 ALIAS (show_bgp_prefix
,
6913 show_bgp_ipv6_prefix_cmd
,
6914 "show bgp ipv6 X:X::X:X/M",
6918 "IPv6 prefix <network>/<length>\n")
6921 DEFUN (show_ipv6_bgp_prefix
,
6922 show_ipv6_bgp_prefix_cmd
,
6923 "show ipv6 bgp X:X::X:X/M",
6927 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6929 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6932 DEFUN (show_bgp_view
,
6934 "show bgp view WORD",
6942 /* BGP structure lookup. */
6943 bgp
= bgp_lookup_by_name (argv
[0]);
6946 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
6950 return bgp_show (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6953 ALIAS (show_bgp_view
,
6954 show_bgp_view_ipv6_cmd
,
6955 "show bgp view WORD ipv6",
6962 DEFUN (show_bgp_view_route
,
6963 show_bgp_view_route_cmd
,
6964 "show bgp view WORD X:X::X:X",
6969 "Network in the BGP routing table to display\n")
6971 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6974 ALIAS (show_bgp_view_route
,
6975 show_bgp_view_ipv6_route_cmd
,
6976 "show bgp view WORD ipv6 X:X::X:X",
6982 "Network in the BGP routing table to display\n")
6984 DEFUN (show_bgp_view_prefix
,
6985 show_bgp_view_prefix_cmd
,
6986 "show bgp view WORD X:X::X:X/M",
6991 "IPv6 prefix <network>/<length>\n")
6993 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6996 ALIAS (show_bgp_view_prefix
,
6997 show_bgp_view_ipv6_prefix_cmd
,
6998 "show bgp view WORD ipv6 X:X::X:X/M",
7004 "IPv6 prefix <network>/<length>\n")
7007 DEFUN (show_ipv6_mbgp
,
7014 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
7019 DEFUN (show_ipv6_mbgp_route
,
7020 show_ipv6_mbgp_route_cmd
,
7021 "show ipv6 mbgp X:X::X:X",
7025 "Network in the MBGP routing table to display\n")
7027 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0);
7031 DEFUN (show_ipv6_mbgp_prefix
,
7032 show_ipv6_mbgp_prefix_cmd
,
7033 "show ipv6 mbgp X:X::X:X/M",
7037 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7039 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1);
7045 bgp_show_regexp (struct vty
*vty
, int argc
, const char **argv
, afi_t afi
,
7046 safi_t safi
, enum bgp_show_type type
)
7056 b
= buffer_new (1024);
7057 for (i
= 0; i
< argc
; i
++)
7060 buffer_putc (b
, ' ');
7063 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
7068 buffer_putstr (b
, argv
[i
]);
7070 buffer_putc (b
, '\0');
7072 regstr
= buffer_getstr (b
);
7075 regex
= bgp_regcomp (regstr
);
7076 XFREE(MTYPE_TMP
, regstr
);
7079 vty_out (vty
, "Can't compile regexp %s%s", argv
[0],
7084 rc
= bgp_show (vty
, NULL
, afi
, safi
, type
, regex
);
7085 bgp_regex_free (regex
);
7089 DEFUN (show_ip_bgp_regexp
,
7090 show_ip_bgp_regexp_cmd
,
7091 "show ip bgp regexp .LINE",
7095 "Display routes matching the AS path regular expression\n"
7096 "A regular-expression to match the BGP AS paths\n")
7098 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
7099 bgp_show_type_regexp
);
7102 DEFUN (show_ip_bgp_flap_regexp
,
7103 show_ip_bgp_flap_regexp_cmd
,
7104 "show ip bgp flap-statistics regexp .LINE",
7108 "Display flap statistics of routes\n"
7109 "Display routes matching the AS path regular expression\n"
7110 "A regular-expression to match the BGP AS paths\n")
7112 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
7113 bgp_show_type_flap_regexp
);
7116 DEFUN (show_ip_bgp_ipv4_regexp
,
7117 show_ip_bgp_ipv4_regexp_cmd
,
7118 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
7123 "Address Family modifier\n"
7124 "Address Family modifier\n"
7125 "Display routes matching the AS path regular expression\n"
7126 "A regular-expression to match the BGP AS paths\n")
7128 if (strncmp (argv
[0], "m", 1) == 0)
7129 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_MULTICAST
,
7130 bgp_show_type_regexp
);
7132 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
7133 bgp_show_type_regexp
);
7137 DEFUN (show_bgp_regexp
,
7138 show_bgp_regexp_cmd
,
7139 "show bgp regexp .LINE",
7142 "Display routes matching the AS path regular expression\n"
7143 "A regular-expression to match the BGP AS paths\n")
7145 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
7146 bgp_show_type_regexp
);
7149 ALIAS (show_bgp_regexp
,
7150 show_bgp_ipv6_regexp_cmd
,
7151 "show bgp ipv6 regexp .LINE",
7155 "Display routes matching the AS path regular expression\n"
7156 "A regular-expression to match the BGP AS paths\n")
7159 DEFUN (show_ipv6_bgp_regexp
,
7160 show_ipv6_bgp_regexp_cmd
,
7161 "show ipv6 bgp regexp .LINE",
7165 "Display routes matching the AS path regular expression\n"
7166 "A regular-expression to match the BGP AS paths\n")
7168 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
7169 bgp_show_type_regexp
);
7173 DEFUN (show_ipv6_mbgp_regexp
,
7174 show_ipv6_mbgp_regexp_cmd
,
7175 "show ipv6 mbgp regexp .LINE",
7179 "Display routes matching the AS path regular expression\n"
7180 "A regular-expression to match the MBGP AS paths\n")
7182 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
,
7183 bgp_show_type_regexp
);
7185 #endif /* HAVE_IPV6 */
7188 bgp_show_prefix_list (struct vty
*vty
, const char *prefix_list_str
, afi_t afi
,
7189 safi_t safi
, enum bgp_show_type type
)
7191 struct prefix_list
*plist
;
7193 plist
= prefix_list_lookup (afi
, prefix_list_str
);
7196 vty_out (vty
, "%% %s is not a valid prefix-list name%s",
7197 prefix_list_str
, VTY_NEWLINE
);
7201 return bgp_show (vty
, NULL
, afi
, safi
, type
, plist
);
7204 DEFUN (show_ip_bgp_prefix_list
,
7205 show_ip_bgp_prefix_list_cmd
,
7206 "show ip bgp prefix-list WORD",
7210 "Display routes conforming to the prefix-list\n"
7211 "IP prefix-list name\n")
7213 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7214 bgp_show_type_prefix_list
);
7217 DEFUN (show_ip_bgp_flap_prefix_list
,
7218 show_ip_bgp_flap_prefix_list_cmd
,
7219 "show ip bgp flap-statistics prefix-list WORD",
7223 "Display flap statistics of routes\n"
7224 "Display routes conforming to the prefix-list\n"
7225 "IP prefix-list name\n")
7227 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7228 bgp_show_type_flap_prefix_list
);
7231 DEFUN (show_ip_bgp_ipv4_prefix_list
,
7232 show_ip_bgp_ipv4_prefix_list_cmd
,
7233 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
7238 "Address Family modifier\n"
7239 "Address Family modifier\n"
7240 "Display routes conforming to the prefix-list\n"
7241 "IP prefix-list name\n")
7243 if (strncmp (argv
[0], "m", 1) == 0)
7244 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
7245 bgp_show_type_prefix_list
);
7247 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
7248 bgp_show_type_prefix_list
);
7252 DEFUN (show_bgp_prefix_list
,
7253 show_bgp_prefix_list_cmd
,
7254 "show bgp prefix-list WORD",
7257 "Display routes conforming to the prefix-list\n"
7258 "IPv6 prefix-list name\n")
7260 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7261 bgp_show_type_prefix_list
);
7264 ALIAS (show_bgp_prefix_list
,
7265 show_bgp_ipv6_prefix_list_cmd
,
7266 "show bgp ipv6 prefix-list WORD",
7270 "Display routes conforming to the prefix-list\n"
7271 "IPv6 prefix-list name\n")
7274 DEFUN (show_ipv6_bgp_prefix_list
,
7275 show_ipv6_bgp_prefix_list_cmd
,
7276 "show ipv6 bgp prefix-list WORD",
7280 "Display routes matching the prefix-list\n"
7281 "IPv6 prefix-list name\n")
7283 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7284 bgp_show_type_prefix_list
);
7288 DEFUN (show_ipv6_mbgp_prefix_list
,
7289 show_ipv6_mbgp_prefix_list_cmd
,
7290 "show ipv6 mbgp prefix-list WORD",
7294 "Display routes matching the prefix-list\n"
7295 "IPv6 prefix-list name\n")
7297 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
7298 bgp_show_type_prefix_list
);
7300 #endif /* HAVE_IPV6 */
7303 bgp_show_filter_list (struct vty
*vty
, const char *filter
, afi_t afi
,
7304 safi_t safi
, enum bgp_show_type type
)
7306 struct as_list
*as_list
;
7308 as_list
= as_list_lookup (filter
);
7309 if (as_list
== NULL
)
7311 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
7315 return bgp_show (vty
, NULL
, afi
, safi
, type
, as_list
);
7318 DEFUN (show_ip_bgp_filter_list
,
7319 show_ip_bgp_filter_list_cmd
,
7320 "show ip bgp filter-list WORD",
7324 "Display routes conforming to the filter-list\n"
7325 "Regular expression access list name\n")
7327 return bgp_show_filter_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7328 bgp_show_type_filter_list
);
7331 DEFUN (show_ip_bgp_flap_filter_list
,
7332 show_ip_bgp_flap_filter_list_cmd
,
7333 "show ip bgp flap-statistics filter-list WORD",
7337 "Display flap statistics of routes\n"
7338 "Display routes conforming to the filter-list\n"
7339 "Regular expression access list name\n")
7341 return bgp_show_filter_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7342 bgp_show_type_flap_filter_list
);
7345 DEFUN (show_ip_bgp_ipv4_filter_list
,
7346 show_ip_bgp_ipv4_filter_list_cmd
,
7347 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
7352 "Address Family modifier\n"
7353 "Address Family modifier\n"
7354 "Display routes conforming to the filter-list\n"
7355 "Regular expression access list name\n")
7357 if (strncmp (argv
[0], "m", 1) == 0)
7358 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
7359 bgp_show_type_filter_list
);
7361 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
7362 bgp_show_type_filter_list
);
7366 DEFUN (show_bgp_filter_list
,
7367 show_bgp_filter_list_cmd
,
7368 "show bgp filter-list WORD",
7371 "Display routes conforming to the filter-list\n"
7372 "Regular expression access list name\n")
7374 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7375 bgp_show_type_filter_list
);
7378 ALIAS (show_bgp_filter_list
,
7379 show_bgp_ipv6_filter_list_cmd
,
7380 "show bgp ipv6 filter-list WORD",
7384 "Display routes conforming to the filter-list\n"
7385 "Regular expression access list name\n")
7388 DEFUN (show_ipv6_bgp_filter_list
,
7389 show_ipv6_bgp_filter_list_cmd
,
7390 "show ipv6 bgp filter-list WORD",
7394 "Display routes conforming to the filter-list\n"
7395 "Regular expression access list name\n")
7397 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7398 bgp_show_type_filter_list
);
7402 DEFUN (show_ipv6_mbgp_filter_list
,
7403 show_ipv6_mbgp_filter_list_cmd
,
7404 "show ipv6 mbgp filter-list WORD",
7408 "Display routes conforming to the filter-list\n"
7409 "Regular expression access list name\n")
7411 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
7412 bgp_show_type_filter_list
);
7414 #endif /* HAVE_IPV6 */
7417 bgp_show_route_map (struct vty
*vty
, const char *rmap_str
, afi_t afi
,
7418 safi_t safi
, enum bgp_show_type type
)
7420 struct route_map
*rmap
;
7422 rmap
= route_map_lookup_by_name (rmap_str
);
7425 vty_out (vty
, "%% %s is not a valid route-map name%s",
7426 rmap_str
, VTY_NEWLINE
);
7430 return bgp_show (vty
, NULL
, afi
, safi
, type
, rmap
);
7433 DEFUN (show_ip_bgp_route_map
,
7434 show_ip_bgp_route_map_cmd
,
7435 "show ip bgp route-map WORD",
7439 "Display routes matching the route-map\n"
7440 "A route-map to match on\n")
7442 return bgp_show_route_map (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7443 bgp_show_type_route_map
);
7446 DEFUN (show_ip_bgp_flap_route_map
,
7447 show_ip_bgp_flap_route_map_cmd
,
7448 "show ip bgp flap-statistics route-map WORD",
7452 "Display flap statistics of routes\n"
7453 "Display routes matching the route-map\n"
7454 "A route-map to match on\n")
7456 return bgp_show_route_map (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7457 bgp_show_type_flap_route_map
);
7460 DEFUN (show_ip_bgp_ipv4_route_map
,
7461 show_ip_bgp_ipv4_route_map_cmd
,
7462 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
7467 "Address Family modifier\n"
7468 "Address Family modifier\n"
7469 "Display routes matching the route-map\n"
7470 "A route-map to match on\n")
7472 if (strncmp (argv
[0], "m", 1) == 0)
7473 return bgp_show_route_map (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
7474 bgp_show_type_route_map
);
7476 return bgp_show_route_map (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
7477 bgp_show_type_route_map
);
7480 DEFUN (show_bgp_route_map
,
7481 show_bgp_route_map_cmd
,
7482 "show bgp route-map WORD",
7485 "Display routes matching the route-map\n"
7486 "A route-map to match on\n")
7488 return bgp_show_route_map (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7489 bgp_show_type_route_map
);
7492 ALIAS (show_bgp_route_map
,
7493 show_bgp_ipv6_route_map_cmd
,
7494 "show bgp ipv6 route-map WORD",
7498 "Display routes matching the route-map\n"
7499 "A route-map to match on\n")
7501 DEFUN (show_ip_bgp_cidr_only
,
7502 show_ip_bgp_cidr_only_cmd
,
7503 "show ip bgp cidr-only",
7507 "Display only routes with non-natural netmasks\n")
7509 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7510 bgp_show_type_cidr_only
, NULL
);
7513 DEFUN (show_ip_bgp_flap_cidr_only
,
7514 show_ip_bgp_flap_cidr_only_cmd
,
7515 "show ip bgp flap-statistics cidr-only",
7519 "Display flap statistics of routes\n"
7520 "Display only routes with non-natural netmasks\n")
7522 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7523 bgp_show_type_flap_cidr_only
, NULL
);
7526 DEFUN (show_ip_bgp_ipv4_cidr_only
,
7527 show_ip_bgp_ipv4_cidr_only_cmd
,
7528 "show ip bgp ipv4 (unicast|multicast) cidr-only",
7533 "Address Family modifier\n"
7534 "Address Family modifier\n"
7535 "Display only routes with non-natural netmasks\n")
7537 if (strncmp (argv
[0], "m", 1) == 0)
7538 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
7539 bgp_show_type_cidr_only
, NULL
);
7541 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7542 bgp_show_type_cidr_only
, NULL
);
7545 DEFUN (show_ip_bgp_community_all
,
7546 show_ip_bgp_community_all_cmd
,
7547 "show ip bgp community",
7551 "Display routes matching the communities\n")
7553 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7554 bgp_show_type_community_all
, NULL
);
7557 DEFUN (show_ip_bgp_ipv4_community_all
,
7558 show_ip_bgp_ipv4_community_all_cmd
,
7559 "show ip bgp ipv4 (unicast|multicast) community",
7564 "Address Family modifier\n"
7565 "Address Family modifier\n"
7566 "Display routes matching the communities\n")
7568 if (strncmp (argv
[0], "m", 1) == 0)
7569 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
7570 bgp_show_type_community_all
, NULL
);
7572 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7573 bgp_show_type_community_all
, NULL
);
7577 DEFUN (show_bgp_community_all
,
7578 show_bgp_community_all_cmd
,
7579 "show bgp community",
7582 "Display routes matching the communities\n")
7584 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
7585 bgp_show_type_community_all
, NULL
);
7588 ALIAS (show_bgp_community_all
,
7589 show_bgp_ipv6_community_all_cmd
,
7590 "show bgp ipv6 community",
7594 "Display routes matching the communities\n")
7597 DEFUN (show_ipv6_bgp_community_all
,
7598 show_ipv6_bgp_community_all_cmd
,
7599 "show ipv6 bgp community",
7603 "Display routes matching the communities\n")
7605 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
7606 bgp_show_type_community_all
, NULL
);
7610 DEFUN (show_ipv6_mbgp_community_all
,
7611 show_ipv6_mbgp_community_all_cmd
,
7612 "show ipv6 mbgp community",
7616 "Display routes matching the communities\n")
7618 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
7619 bgp_show_type_community_all
, NULL
);
7621 #endif /* HAVE_IPV6 */
7624 bgp_show_community (struct vty
*vty
, int argc
, const char **argv
, int exact
,
7625 u_int16_t afi
, u_char safi
)
7627 struct community
*com
;
7633 b
= buffer_new (1024);
7634 for (i
= 0; i
< argc
; i
++)
7637 buffer_putc (b
, ' ');
7640 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
7645 buffer_putstr (b
, argv
[i
]);
7647 buffer_putc (b
, '\0');
7649 str
= buffer_getstr (b
);
7652 com
= community_str2com (str
);
7653 XFREE (MTYPE_TMP
, str
);
7656 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
7660 return bgp_show (vty
, NULL
, afi
, safi
,
7661 (exact
? bgp_show_type_community_exact
:
7662 bgp_show_type_community
), com
);
7665 DEFUN (show_ip_bgp_community
,
7666 show_ip_bgp_community_cmd
,
7667 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
7671 "Display routes matching the communities\n"
7672 "community number\n"
7673 "Do not send outside local AS (well-known community)\n"
7674 "Do not advertise to any peer (well-known community)\n"
7675 "Do not export to next AS (well-known community)\n")
7677 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
7680 ALIAS (show_ip_bgp_community
,
7681 show_ip_bgp_community2_cmd
,
7682 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7686 "Display routes matching the communities\n"
7687 "community number\n"
7688 "Do not send outside local AS (well-known community)\n"
7689 "Do not advertise to any peer (well-known community)\n"
7690 "Do not export to next AS (well-known community)\n"
7691 "community number\n"
7692 "Do not send outside local AS (well-known community)\n"
7693 "Do not advertise to any peer (well-known community)\n"
7694 "Do not export to next AS (well-known community)\n")
7696 ALIAS (show_ip_bgp_community
,
7697 show_ip_bgp_community3_cmd
,
7698 "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)",
7702 "Display routes matching the communities\n"
7703 "community number\n"
7704 "Do not send outside local AS (well-known community)\n"
7705 "Do not advertise to any peer (well-known community)\n"
7706 "Do not export to next AS (well-known community)\n"
7707 "community number\n"
7708 "Do not send outside local AS (well-known community)\n"
7709 "Do not advertise to any peer (well-known community)\n"
7710 "Do not export to next AS (well-known community)\n"
7711 "community number\n"
7712 "Do not send outside local AS (well-known community)\n"
7713 "Do not advertise to any peer (well-known community)\n"
7714 "Do not export to next AS (well-known community)\n")
7716 ALIAS (show_ip_bgp_community
,
7717 show_ip_bgp_community4_cmd
,
7718 "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)",
7722 "Display routes matching the communities\n"
7723 "community number\n"
7724 "Do not send outside local AS (well-known community)\n"
7725 "Do not advertise to any peer (well-known community)\n"
7726 "Do not export to next AS (well-known community)\n"
7727 "community number\n"
7728 "Do not send outside local AS (well-known community)\n"
7729 "Do not advertise to any peer (well-known community)\n"
7730 "Do not export to next AS (well-known community)\n"
7731 "community number\n"
7732 "Do not send outside local AS (well-known community)\n"
7733 "Do not advertise to any peer (well-known community)\n"
7734 "Do not export to next AS (well-known community)\n"
7735 "community number\n"
7736 "Do not send outside local AS (well-known community)\n"
7737 "Do not advertise to any peer (well-known community)\n"
7738 "Do not export to next AS (well-known community)\n")
7740 DEFUN (show_ip_bgp_ipv4_community
,
7741 show_ip_bgp_ipv4_community_cmd
,
7742 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
7747 "Address Family modifier\n"
7748 "Address Family modifier\n"
7749 "Display routes matching the communities\n"
7750 "community number\n"
7751 "Do not send outside local AS (well-known community)\n"
7752 "Do not advertise to any peer (well-known community)\n"
7753 "Do not export to next AS (well-known community)\n")
7755 if (strncmp (argv
[0], "m", 1) == 0)
7756 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_MULTICAST
);
7758 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
7761 ALIAS (show_ip_bgp_ipv4_community
,
7762 show_ip_bgp_ipv4_community2_cmd
,
7763 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7768 "Address Family modifier\n"
7769 "Address Family modifier\n"
7770 "Display routes matching the communities\n"
7771 "community number\n"
7772 "Do not send outside local AS (well-known community)\n"
7773 "Do not advertise to any peer (well-known community)\n"
7774 "Do not export to next AS (well-known community)\n"
7775 "community number\n"
7776 "Do not send outside local AS (well-known community)\n"
7777 "Do not advertise to any peer (well-known community)\n"
7778 "Do not export to next AS (well-known community)\n")
7780 ALIAS (show_ip_bgp_ipv4_community
,
7781 show_ip_bgp_ipv4_community3_cmd
,
7782 "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)",
7787 "Address Family modifier\n"
7788 "Address Family modifier\n"
7789 "Display routes matching the communities\n"
7790 "community number\n"
7791 "Do not send outside local AS (well-known community)\n"
7792 "Do not advertise to any peer (well-known community)\n"
7793 "Do not export to next AS (well-known community)\n"
7794 "community number\n"
7795 "Do not send outside local AS (well-known community)\n"
7796 "Do not advertise to any peer (well-known community)\n"
7797 "Do not export to next AS (well-known community)\n"
7798 "community number\n"
7799 "Do not send outside local AS (well-known community)\n"
7800 "Do not advertise to any peer (well-known community)\n"
7801 "Do not export to next AS (well-known community)\n")
7803 ALIAS (show_ip_bgp_ipv4_community
,
7804 show_ip_bgp_ipv4_community4_cmd
,
7805 "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)",
7810 "Address Family modifier\n"
7811 "Address Family modifier\n"
7812 "Display routes matching the communities\n"
7813 "community number\n"
7814 "Do not send outside local AS (well-known community)\n"
7815 "Do not advertise to any peer (well-known community)\n"
7816 "Do not export to next AS (well-known community)\n"
7817 "community number\n"
7818 "Do not send outside local AS (well-known community)\n"
7819 "Do not advertise to any peer (well-known community)\n"
7820 "Do not export to next AS (well-known community)\n"
7821 "community number\n"
7822 "Do not send outside local AS (well-known community)\n"
7823 "Do not advertise to any peer (well-known community)\n"
7824 "Do not export to next AS (well-known community)\n"
7825 "community number\n"
7826 "Do not send outside local AS (well-known community)\n"
7827 "Do not advertise to any peer (well-known community)\n"
7828 "Do not export to next AS (well-known community)\n")
7830 DEFUN (show_ip_bgp_community_exact
,
7831 show_ip_bgp_community_exact_cmd
,
7832 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7836 "Display routes matching the communities\n"
7837 "community number\n"
7838 "Do not send outside local AS (well-known community)\n"
7839 "Do not advertise to any peer (well-known community)\n"
7840 "Do not export to next AS (well-known community)\n"
7841 "Exact match of the communities")
7843 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
7846 ALIAS (show_ip_bgp_community_exact
,
7847 show_ip_bgp_community2_exact_cmd
,
7848 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7852 "Display routes matching the communities\n"
7853 "community number\n"
7854 "Do not send outside local AS (well-known community)\n"
7855 "Do not advertise to any peer (well-known community)\n"
7856 "Do not export to next AS (well-known community)\n"
7857 "community number\n"
7858 "Do not send outside local AS (well-known community)\n"
7859 "Do not advertise to any peer (well-known community)\n"
7860 "Do not export to next AS (well-known community)\n"
7861 "Exact match of the communities")
7863 ALIAS (show_ip_bgp_community_exact
,
7864 show_ip_bgp_community3_exact_cmd
,
7865 "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",
7869 "Display routes matching the communities\n"
7870 "community number\n"
7871 "Do not send outside local AS (well-known community)\n"
7872 "Do not advertise to any peer (well-known community)\n"
7873 "Do not export to next AS (well-known community)\n"
7874 "community number\n"
7875 "Do not send outside local AS (well-known community)\n"
7876 "Do not advertise to any peer (well-known community)\n"
7877 "Do not export to next AS (well-known community)\n"
7878 "community number\n"
7879 "Do not send outside local AS (well-known community)\n"
7880 "Do not advertise to any peer (well-known community)\n"
7881 "Do not export to next AS (well-known community)\n"
7882 "Exact match of the communities")
7884 ALIAS (show_ip_bgp_community_exact
,
7885 show_ip_bgp_community4_exact_cmd
,
7886 "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",
7890 "Display routes matching the communities\n"
7891 "community number\n"
7892 "Do not send outside local AS (well-known community)\n"
7893 "Do not advertise to any peer (well-known community)\n"
7894 "Do not export to next AS (well-known community)\n"
7895 "community number\n"
7896 "Do not send outside local AS (well-known community)\n"
7897 "Do not advertise to any peer (well-known community)\n"
7898 "Do not export to next AS (well-known community)\n"
7899 "community number\n"
7900 "Do not send outside local AS (well-known community)\n"
7901 "Do not advertise to any peer (well-known community)\n"
7902 "Do not export to next AS (well-known community)\n"
7903 "community number\n"
7904 "Do not send outside local AS (well-known community)\n"
7905 "Do not advertise to any peer (well-known community)\n"
7906 "Do not export to next AS (well-known community)\n"
7907 "Exact match of the communities")
7909 DEFUN (show_ip_bgp_ipv4_community_exact
,
7910 show_ip_bgp_ipv4_community_exact_cmd
,
7911 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7916 "Address Family modifier\n"
7917 "Address Family modifier\n"
7918 "Display routes matching the communities\n"
7919 "community number\n"
7920 "Do not send outside local AS (well-known community)\n"
7921 "Do not advertise to any peer (well-known community)\n"
7922 "Do not export to next AS (well-known community)\n"
7923 "Exact match of the communities")
7925 if (strncmp (argv
[0], "m", 1) == 0)
7926 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_MULTICAST
);
7928 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
7931 ALIAS (show_ip_bgp_ipv4_community_exact
,
7932 show_ip_bgp_ipv4_community2_exact_cmd
,
7933 "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",
7938 "Address Family modifier\n"
7939 "Address Family modifier\n"
7940 "Display routes matching the communities\n"
7941 "community number\n"
7942 "Do not send outside local AS (well-known community)\n"
7943 "Do not advertise to any peer (well-known community)\n"
7944 "Do not export to next AS (well-known community)\n"
7945 "community number\n"
7946 "Do not send outside local AS (well-known community)\n"
7947 "Do not advertise to any peer (well-known community)\n"
7948 "Do not export to next AS (well-known community)\n"
7949 "Exact match of the communities")
7951 ALIAS (show_ip_bgp_ipv4_community_exact
,
7952 show_ip_bgp_ipv4_community3_exact_cmd
,
7953 "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",
7958 "Address Family modifier\n"
7959 "Address Family modifier\n"
7960 "Display routes matching the communities\n"
7961 "community number\n"
7962 "Do not send outside local AS (well-known community)\n"
7963 "Do not advertise to any peer (well-known community)\n"
7964 "Do not export to next AS (well-known community)\n"
7965 "community number\n"
7966 "Do not send outside local AS (well-known community)\n"
7967 "Do not advertise to any peer (well-known community)\n"
7968 "Do not export to next AS (well-known community)\n"
7969 "community number\n"
7970 "Do not send outside local AS (well-known community)\n"
7971 "Do not advertise to any peer (well-known community)\n"
7972 "Do not export to next AS (well-known community)\n"
7973 "Exact match of the communities")
7975 ALIAS (show_ip_bgp_ipv4_community_exact
,
7976 show_ip_bgp_ipv4_community4_exact_cmd
,
7977 "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",
7982 "Address Family modifier\n"
7983 "Address Family modifier\n"
7984 "Display routes matching the communities\n"
7985 "community number\n"
7986 "Do not send outside local AS (well-known community)\n"
7987 "Do not advertise to any peer (well-known community)\n"
7988 "Do not export to next AS (well-known community)\n"
7989 "community number\n"
7990 "Do not send outside local AS (well-known community)\n"
7991 "Do not advertise to any peer (well-known community)\n"
7992 "Do not export to next AS (well-known community)\n"
7993 "community number\n"
7994 "Do not send outside local AS (well-known community)\n"
7995 "Do not advertise to any peer (well-known community)\n"
7996 "Do not export to next AS (well-known community)\n"
7997 "community number\n"
7998 "Do not send outside local AS (well-known community)\n"
7999 "Do not advertise to any peer (well-known community)\n"
8000 "Do not export to next AS (well-known community)\n"
8001 "Exact match of the communities")
8004 DEFUN (show_bgp_community
,
8005 show_bgp_community_cmd
,
8006 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
8009 "Display routes matching the communities\n"
8010 "community number\n"
8011 "Do not send outside local AS (well-known community)\n"
8012 "Do not advertise to any peer (well-known community)\n"
8013 "Do not export to next AS (well-known community)\n")
8015 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
8018 ALIAS (show_bgp_community
,
8019 show_bgp_ipv6_community_cmd
,
8020 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
8024 "Display routes matching the communities\n"
8025 "community number\n"
8026 "Do not send outside local AS (well-known community)\n"
8027 "Do not advertise to any peer (well-known community)\n"
8028 "Do not export to next AS (well-known community)\n")
8030 ALIAS (show_bgp_community
,
8031 show_bgp_community2_cmd
,
8032 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8035 "Display routes matching the communities\n"
8036 "community number\n"
8037 "Do not send outside local AS (well-known community)\n"
8038 "Do not advertise to any peer (well-known community)\n"
8039 "Do not export to next AS (well-known community)\n"
8040 "community number\n"
8041 "Do not send outside local AS (well-known community)\n"
8042 "Do not advertise to any peer (well-known community)\n"
8043 "Do not export to next AS (well-known community)\n")
8045 ALIAS (show_bgp_community
,
8046 show_bgp_ipv6_community2_cmd
,
8047 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8051 "Display routes matching the communities\n"
8052 "community number\n"
8053 "Do not send outside local AS (well-known community)\n"
8054 "Do not advertise to any peer (well-known community)\n"
8055 "Do not export to next AS (well-known community)\n"
8056 "community number\n"
8057 "Do not send outside local AS (well-known community)\n"
8058 "Do not advertise to any peer (well-known community)\n"
8059 "Do not export to next AS (well-known community)\n")
8061 ALIAS (show_bgp_community
,
8062 show_bgp_community3_cmd
,
8063 "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)",
8066 "Display routes matching the communities\n"
8067 "community number\n"
8068 "Do not send outside local AS (well-known community)\n"
8069 "Do not advertise to any peer (well-known community)\n"
8070 "Do not export to next AS (well-known community)\n"
8071 "community number\n"
8072 "Do not send outside local AS (well-known community)\n"
8073 "Do not advertise to any peer (well-known community)\n"
8074 "Do not export to next AS (well-known community)\n"
8075 "community number\n"
8076 "Do not send outside local AS (well-known community)\n"
8077 "Do not advertise to any peer (well-known community)\n"
8078 "Do not export to next AS (well-known community)\n")
8080 ALIAS (show_bgp_community
,
8081 show_bgp_ipv6_community3_cmd
,
8082 "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)",
8086 "Display routes matching the communities\n"
8087 "community number\n"
8088 "Do not send outside local AS (well-known community)\n"
8089 "Do not advertise to any peer (well-known community)\n"
8090 "Do not export to next AS (well-known community)\n"
8091 "community number\n"
8092 "Do not send outside local AS (well-known community)\n"
8093 "Do not advertise to any peer (well-known community)\n"
8094 "Do not export to next AS (well-known community)\n"
8095 "community number\n"
8096 "Do not send outside local AS (well-known community)\n"
8097 "Do not advertise to any peer (well-known community)\n"
8098 "Do not export to next AS (well-known community)\n")
8100 ALIAS (show_bgp_community
,
8101 show_bgp_community4_cmd
,
8102 "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)",
8105 "Display routes matching the communities\n"
8106 "community number\n"
8107 "Do not send outside local AS (well-known community)\n"
8108 "Do not advertise to any peer (well-known community)\n"
8109 "Do not export to next AS (well-known community)\n"
8110 "community number\n"
8111 "Do not send outside local AS (well-known community)\n"
8112 "Do not advertise to any peer (well-known community)\n"
8113 "Do not export to next AS (well-known community)\n"
8114 "community number\n"
8115 "Do not send outside local AS (well-known community)\n"
8116 "Do not advertise to any peer (well-known community)\n"
8117 "Do not export to next AS (well-known community)\n"
8118 "community number\n"
8119 "Do not send outside local AS (well-known community)\n"
8120 "Do not advertise to any peer (well-known community)\n"
8121 "Do not export to next AS (well-known community)\n")
8123 ALIAS (show_bgp_community
,
8124 show_bgp_ipv6_community4_cmd
,
8125 "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)",
8129 "Display routes matching the communities\n"
8130 "community number\n"
8131 "Do not send outside local AS (well-known community)\n"
8132 "Do not advertise to any peer (well-known community)\n"
8133 "Do not export to next AS (well-known community)\n"
8134 "community number\n"
8135 "Do not send outside local AS (well-known community)\n"
8136 "Do not advertise to any peer (well-known community)\n"
8137 "Do not export to next AS (well-known community)\n"
8138 "community number\n"
8139 "Do not send outside local AS (well-known community)\n"
8140 "Do not advertise to any peer (well-known community)\n"
8141 "Do not export to next AS (well-known community)\n"
8142 "community number\n"
8143 "Do not send outside local AS (well-known community)\n"
8144 "Do not advertise to any peer (well-known community)\n"
8145 "Do not export to next AS (well-known community)\n")
8148 DEFUN (show_ipv6_bgp_community
,
8149 show_ipv6_bgp_community_cmd
,
8150 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
8154 "Display routes matching the communities\n"
8155 "community number\n"
8156 "Do not send outside local AS (well-known community)\n"
8157 "Do not advertise to any peer (well-known community)\n"
8158 "Do not export to next AS (well-known community)\n")
8160 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
8164 ALIAS (show_ipv6_bgp_community
,
8165 show_ipv6_bgp_community2_cmd
,
8166 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8170 "Display routes matching the communities\n"
8171 "community number\n"
8172 "Do not send outside local AS (well-known community)\n"
8173 "Do not advertise to any peer (well-known community)\n"
8174 "Do not export to next AS (well-known community)\n"
8175 "community number\n"
8176 "Do not send outside local AS (well-known community)\n"
8177 "Do not advertise to any peer (well-known community)\n"
8178 "Do not export to next AS (well-known community)\n")
8181 ALIAS (show_ipv6_bgp_community
,
8182 show_ipv6_bgp_community3_cmd
,
8183 "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)",
8187 "Display routes matching the communities\n"
8188 "community number\n"
8189 "Do not send outside local AS (well-known community)\n"
8190 "Do not advertise to any peer (well-known community)\n"
8191 "Do not export to next AS (well-known community)\n"
8192 "community number\n"
8193 "Do not send outside local AS (well-known community)\n"
8194 "Do not advertise to any peer (well-known community)\n"
8195 "Do not export to next AS (well-known community)\n"
8196 "community number\n"
8197 "Do not send outside local AS (well-known community)\n"
8198 "Do not advertise to any peer (well-known community)\n"
8199 "Do not export to next AS (well-known community)\n")
8202 ALIAS (show_ipv6_bgp_community
,
8203 show_ipv6_bgp_community4_cmd
,
8204 "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)",
8208 "Display routes matching the communities\n"
8209 "community number\n"
8210 "Do not send outside local AS (well-known community)\n"
8211 "Do not advertise to any peer (well-known community)\n"
8212 "Do not export to next AS (well-known community)\n"
8213 "community number\n"
8214 "Do not send outside local AS (well-known community)\n"
8215 "Do not advertise to any peer (well-known community)\n"
8216 "Do not export to next AS (well-known community)\n"
8217 "community number\n"
8218 "Do not send outside local AS (well-known community)\n"
8219 "Do not advertise to any peer (well-known community)\n"
8220 "Do not export to next AS (well-known community)\n"
8221 "community number\n"
8222 "Do not send outside local AS (well-known community)\n"
8223 "Do not advertise to any peer (well-known community)\n"
8224 "Do not export to next AS (well-known community)\n")
8226 DEFUN (show_bgp_community_exact
,
8227 show_bgp_community_exact_cmd
,
8228 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8231 "Display routes matching the communities\n"
8232 "community number\n"
8233 "Do not send outside local AS (well-known community)\n"
8234 "Do not advertise to any peer (well-known community)\n"
8235 "Do not export to next AS (well-known community)\n"
8236 "Exact match of the communities")
8238 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
8241 ALIAS (show_bgp_community_exact
,
8242 show_bgp_ipv6_community_exact_cmd
,
8243 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8247 "Display routes matching the communities\n"
8248 "community number\n"
8249 "Do not send outside local AS (well-known community)\n"
8250 "Do not advertise to any peer (well-known community)\n"
8251 "Do not export to next AS (well-known community)\n"
8252 "Exact match of the communities")
8254 ALIAS (show_bgp_community_exact
,
8255 show_bgp_community2_exact_cmd
,
8256 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8259 "Display routes matching the communities\n"
8260 "community number\n"
8261 "Do not send outside local AS (well-known community)\n"
8262 "Do not advertise to any peer (well-known community)\n"
8263 "Do not export to next AS (well-known community)\n"
8264 "community number\n"
8265 "Do not send outside local AS (well-known community)\n"
8266 "Do not advertise to any peer (well-known community)\n"
8267 "Do not export to next AS (well-known community)\n"
8268 "Exact match of the communities")
8270 ALIAS (show_bgp_community_exact
,
8271 show_bgp_ipv6_community2_exact_cmd
,
8272 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8276 "Display routes matching the communities\n"
8277 "community number\n"
8278 "Do not send outside local AS (well-known community)\n"
8279 "Do not advertise to any peer (well-known community)\n"
8280 "Do not export to next AS (well-known community)\n"
8281 "community number\n"
8282 "Do not send outside local AS (well-known community)\n"
8283 "Do not advertise to any peer (well-known community)\n"
8284 "Do not export to next AS (well-known community)\n"
8285 "Exact match of the communities")
8287 ALIAS (show_bgp_community_exact
,
8288 show_bgp_community3_exact_cmd
,
8289 "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",
8292 "Display routes matching the communities\n"
8293 "community number\n"
8294 "Do not send outside local AS (well-known community)\n"
8295 "Do not advertise to any peer (well-known community)\n"
8296 "Do not export to next AS (well-known community)\n"
8297 "community number\n"
8298 "Do not send outside local AS (well-known community)\n"
8299 "Do not advertise to any peer (well-known community)\n"
8300 "Do not export to next AS (well-known community)\n"
8301 "community number\n"
8302 "Do not send outside local AS (well-known community)\n"
8303 "Do not advertise to any peer (well-known community)\n"
8304 "Do not export to next AS (well-known community)\n"
8305 "Exact match of the communities")
8307 ALIAS (show_bgp_community_exact
,
8308 show_bgp_ipv6_community3_exact_cmd
,
8309 "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",
8313 "Display routes matching the communities\n"
8314 "community number\n"
8315 "Do not send outside local AS (well-known community)\n"
8316 "Do not advertise to any peer (well-known community)\n"
8317 "Do not export to next AS (well-known community)\n"
8318 "community number\n"
8319 "Do not send outside local AS (well-known community)\n"
8320 "Do not advertise to any peer (well-known community)\n"
8321 "Do not export to next AS (well-known community)\n"
8322 "community number\n"
8323 "Do not send outside local AS (well-known community)\n"
8324 "Do not advertise to any peer (well-known community)\n"
8325 "Do not export to next AS (well-known community)\n"
8326 "Exact match of the communities")
8328 ALIAS (show_bgp_community_exact
,
8329 show_bgp_community4_exact_cmd
,
8330 "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",
8333 "Display routes matching the communities\n"
8334 "community number\n"
8335 "Do not send outside local AS (well-known community)\n"
8336 "Do not advertise to any peer (well-known community)\n"
8337 "Do not export to next AS (well-known community)\n"
8338 "community number\n"
8339 "Do not send outside local AS (well-known community)\n"
8340 "Do not advertise to any peer (well-known community)\n"
8341 "Do not export to next AS (well-known community)\n"
8342 "community number\n"
8343 "Do not send outside local AS (well-known community)\n"
8344 "Do not advertise to any peer (well-known community)\n"
8345 "Do not export to next AS (well-known community)\n"
8346 "community number\n"
8347 "Do not send outside local AS (well-known community)\n"
8348 "Do not advertise to any peer (well-known community)\n"
8349 "Do not export to next AS (well-known community)\n"
8350 "Exact match of the communities")
8352 ALIAS (show_bgp_community_exact
,
8353 show_bgp_ipv6_community4_exact_cmd
,
8354 "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",
8358 "Display routes matching the communities\n"
8359 "community number\n"
8360 "Do not send outside local AS (well-known community)\n"
8361 "Do not advertise to any peer (well-known community)\n"
8362 "Do not export to next AS (well-known community)\n"
8363 "community number\n"
8364 "Do not send outside local AS (well-known community)\n"
8365 "Do not advertise to any peer (well-known community)\n"
8366 "Do not export to next AS (well-known community)\n"
8367 "community number\n"
8368 "Do not send outside local AS (well-known community)\n"
8369 "Do not advertise to any peer (well-known community)\n"
8370 "Do not export to next AS (well-known community)\n"
8371 "community number\n"
8372 "Do not send outside local AS (well-known community)\n"
8373 "Do not advertise to any peer (well-known community)\n"
8374 "Do not export to next AS (well-known community)\n"
8375 "Exact match of the communities")
8378 DEFUN (show_ipv6_bgp_community_exact
,
8379 show_ipv6_bgp_community_exact_cmd
,
8380 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8384 "Display routes matching the communities\n"
8385 "community number\n"
8386 "Do not send outside local AS (well-known community)\n"
8387 "Do not advertise to any peer (well-known community)\n"
8388 "Do not export to next AS (well-known community)\n"
8389 "Exact match of the communities")
8391 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
8395 ALIAS (show_ipv6_bgp_community_exact
,
8396 show_ipv6_bgp_community2_exact_cmd
,
8397 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8401 "Display routes matching the communities\n"
8402 "community number\n"
8403 "Do not send outside local AS (well-known community)\n"
8404 "Do not advertise to any peer (well-known community)\n"
8405 "Do not export to next AS (well-known community)\n"
8406 "community number\n"
8407 "Do not send outside local AS (well-known community)\n"
8408 "Do not advertise to any peer (well-known community)\n"
8409 "Do not export to next AS (well-known community)\n"
8410 "Exact match of the communities")
8413 ALIAS (show_ipv6_bgp_community_exact
,
8414 show_ipv6_bgp_community3_exact_cmd
,
8415 "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",
8419 "Display routes matching the communities\n"
8420 "community number\n"
8421 "Do not send outside local AS (well-known community)\n"
8422 "Do not advertise to any peer (well-known community)\n"
8423 "Do not export to next AS (well-known community)\n"
8424 "community number\n"
8425 "Do not send outside local AS (well-known community)\n"
8426 "Do not advertise to any peer (well-known community)\n"
8427 "Do not export to next AS (well-known community)\n"
8428 "community number\n"
8429 "Do not send outside local AS (well-known community)\n"
8430 "Do not advertise to any peer (well-known community)\n"
8431 "Do not export to next AS (well-known community)\n"
8432 "Exact match of the communities")
8435 ALIAS (show_ipv6_bgp_community_exact
,
8436 show_ipv6_bgp_community4_exact_cmd
,
8437 "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",
8441 "Display routes matching the communities\n"
8442 "community number\n"
8443 "Do not send outside local AS (well-known community)\n"
8444 "Do not advertise to any peer (well-known community)\n"
8445 "Do not export to next AS (well-known community)\n"
8446 "community number\n"
8447 "Do not send outside local AS (well-known community)\n"
8448 "Do not advertise to any peer (well-known community)\n"
8449 "Do not export to next AS (well-known community)\n"
8450 "community number\n"
8451 "Do not send outside local AS (well-known community)\n"
8452 "Do not advertise to any peer (well-known community)\n"
8453 "Do not export to next AS (well-known community)\n"
8454 "community number\n"
8455 "Do not send outside local AS (well-known community)\n"
8456 "Do not advertise to any peer (well-known community)\n"
8457 "Do not export to next AS (well-known community)\n"
8458 "Exact match of the communities")
8461 DEFUN (show_ipv6_mbgp_community
,
8462 show_ipv6_mbgp_community_cmd
,
8463 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
8467 "Display routes matching the communities\n"
8468 "community number\n"
8469 "Do not send outside local AS (well-known community)\n"
8470 "Do not advertise to any peer (well-known community)\n"
8471 "Do not export to next AS (well-known community)\n")
8473 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
8477 ALIAS (show_ipv6_mbgp_community
,
8478 show_ipv6_mbgp_community2_cmd
,
8479 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8483 "Display routes matching the communities\n"
8484 "community number\n"
8485 "Do not send outside local AS (well-known community)\n"
8486 "Do not advertise to any peer (well-known community)\n"
8487 "Do not export to next AS (well-known community)\n"
8488 "community number\n"
8489 "Do not send outside local AS (well-known community)\n"
8490 "Do not advertise to any peer (well-known community)\n"
8491 "Do not export to next AS (well-known community)\n")
8494 ALIAS (show_ipv6_mbgp_community
,
8495 show_ipv6_mbgp_community3_cmd
,
8496 "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)",
8500 "Display routes matching the communities\n"
8501 "community number\n"
8502 "Do not send outside local AS (well-known community)\n"
8503 "Do not advertise to any peer (well-known community)\n"
8504 "Do not export to next AS (well-known community)\n"
8505 "community number\n"
8506 "Do not send outside local AS (well-known community)\n"
8507 "Do not advertise to any peer (well-known community)\n"
8508 "Do not export to next AS (well-known community)\n"
8509 "community number\n"
8510 "Do not send outside local AS (well-known community)\n"
8511 "Do not advertise to any peer (well-known community)\n"
8512 "Do not export to next AS (well-known community)\n")
8515 ALIAS (show_ipv6_mbgp_community
,
8516 show_ipv6_mbgp_community4_cmd
,
8517 "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)",
8521 "Display routes matching the communities\n"
8522 "community number\n"
8523 "Do not send outside local AS (well-known community)\n"
8524 "Do not advertise to any peer (well-known community)\n"
8525 "Do not export to next AS (well-known community)\n"
8526 "community number\n"
8527 "Do not send outside local AS (well-known community)\n"
8528 "Do not advertise to any peer (well-known community)\n"
8529 "Do not export to next AS (well-known community)\n"
8530 "community number\n"
8531 "Do not send outside local AS (well-known community)\n"
8532 "Do not advertise to any peer (well-known community)\n"
8533 "Do not export to next AS (well-known community)\n"
8534 "community number\n"
8535 "Do not send outside local AS (well-known community)\n"
8536 "Do not advertise to any peer (well-known community)\n"
8537 "Do not export to next AS (well-known community)\n")
8540 DEFUN (show_ipv6_mbgp_community_exact
,
8541 show_ipv6_mbgp_community_exact_cmd
,
8542 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8546 "Display routes matching the communities\n"
8547 "community number\n"
8548 "Do not send outside local AS (well-known community)\n"
8549 "Do not advertise to any peer (well-known community)\n"
8550 "Do not export to next AS (well-known community)\n"
8551 "Exact match of the communities")
8553 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
8557 ALIAS (show_ipv6_mbgp_community_exact
,
8558 show_ipv6_mbgp_community2_exact_cmd
,
8559 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8563 "Display routes matching the communities\n"
8564 "community number\n"
8565 "Do not send outside local AS (well-known community)\n"
8566 "Do not advertise to any peer (well-known community)\n"
8567 "Do not export to next AS (well-known community)\n"
8568 "community number\n"
8569 "Do not send outside local AS (well-known community)\n"
8570 "Do not advertise to any peer (well-known community)\n"
8571 "Do not export to next AS (well-known community)\n"
8572 "Exact match of the communities")
8575 ALIAS (show_ipv6_mbgp_community_exact
,
8576 show_ipv6_mbgp_community3_exact_cmd
,
8577 "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",
8581 "Display routes matching the communities\n"
8582 "community number\n"
8583 "Do not send outside local AS (well-known community)\n"
8584 "Do not advertise to any peer (well-known community)\n"
8585 "Do not export to next AS (well-known community)\n"
8586 "community number\n"
8587 "Do not send outside local AS (well-known community)\n"
8588 "Do not advertise to any peer (well-known community)\n"
8589 "Do not export to next AS (well-known community)\n"
8590 "community number\n"
8591 "Do not send outside local AS (well-known community)\n"
8592 "Do not advertise to any peer (well-known community)\n"
8593 "Do not export to next AS (well-known community)\n"
8594 "Exact match of the communities")
8597 ALIAS (show_ipv6_mbgp_community_exact
,
8598 show_ipv6_mbgp_community4_exact_cmd
,
8599 "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",
8603 "Display routes matching the communities\n"
8604 "community number\n"
8605 "Do not send outside local AS (well-known community)\n"
8606 "Do not advertise to any peer (well-known community)\n"
8607 "Do not export to next AS (well-known community)\n"
8608 "community number\n"
8609 "Do not send outside local AS (well-known community)\n"
8610 "Do not advertise to any peer (well-known community)\n"
8611 "Do not export to next AS (well-known community)\n"
8612 "community number\n"
8613 "Do not send outside local AS (well-known community)\n"
8614 "Do not advertise to any peer (well-known community)\n"
8615 "Do not export to next AS (well-known community)\n"
8616 "community number\n"
8617 "Do not send outside local AS (well-known community)\n"
8618 "Do not advertise to any peer (well-known community)\n"
8619 "Do not export to next AS (well-known community)\n"
8620 "Exact match of the communities")
8621 #endif /* HAVE_IPV6 */
8624 bgp_show_community_list (struct vty
*vty
, const char *com
, int exact
,
8625 u_int16_t afi
, u_char safi
)
8627 struct community_list
*list
;
8629 list
= community_list_lookup (bgp_clist
, com
, COMMUNITY_LIST_MASTER
);
8632 vty_out (vty
, "%% %s is not a valid community-list name%s", com
,
8637 return bgp_show (vty
, NULL
, afi
, safi
,
8638 (exact
? bgp_show_type_community_list_exact
:
8639 bgp_show_type_community_list
), list
);
8642 DEFUN (show_ip_bgp_community_list
,
8643 show_ip_bgp_community_list_cmd
,
8644 "show ip bgp community-list (<1-500>|WORD)",
8648 "Display routes matching the community-list\n"
8649 "community-list number\n"
8650 "community-list name\n")
8652 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP
, SAFI_UNICAST
);
8655 DEFUN (show_ip_bgp_ipv4_community_list
,
8656 show_ip_bgp_ipv4_community_list_cmd
,
8657 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
8662 "Address Family modifier\n"
8663 "Address Family modifier\n"
8664 "Display routes matching the community-list\n"
8665 "community-list number\n"
8666 "community-list name\n")
8668 if (strncmp (argv
[0], "m", 1) == 0)
8669 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_MULTICAST
);
8671 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_UNICAST
);
8674 DEFUN (show_ip_bgp_community_list_exact
,
8675 show_ip_bgp_community_list_exact_cmd
,
8676 "show ip bgp community-list (<1-500>|WORD) exact-match",
8680 "Display routes matching the community-list\n"
8681 "community-list number\n"
8682 "community-list name\n"
8683 "Exact match of the communities\n")
8685 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP
, SAFI_UNICAST
);
8688 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
8689 show_ip_bgp_ipv4_community_list_exact_cmd
,
8690 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
8695 "Address Family modifier\n"
8696 "Address Family modifier\n"
8697 "Display routes matching the community-list\n"
8698 "community-list number\n"
8699 "community-list name\n"
8700 "Exact match of the communities\n")
8702 if (strncmp (argv
[0], "m", 1) == 0)
8703 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_MULTICAST
);
8705 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_UNICAST
);
8709 DEFUN (show_bgp_community_list
,
8710 show_bgp_community_list_cmd
,
8711 "show bgp community-list (<1-500>|WORD)",
8714 "Display routes matching the community-list\n"
8715 "community-list number\n"
8716 "community-list name\n")
8718 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
8721 ALIAS (show_bgp_community_list
,
8722 show_bgp_ipv6_community_list_cmd
,
8723 "show bgp ipv6 community-list (<1-500>|WORD)",
8727 "Display routes matching the community-list\n"
8728 "community-list number\n"
8729 "community-list name\n")
8732 DEFUN (show_ipv6_bgp_community_list
,
8733 show_ipv6_bgp_community_list_cmd
,
8734 "show ipv6 bgp community-list WORD",
8738 "Display routes matching the community-list\n"
8739 "community-list name\n")
8741 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
8745 DEFUN (show_ipv6_mbgp_community_list
,
8746 show_ipv6_mbgp_community_list_cmd
,
8747 "show ipv6 mbgp community-list WORD",
8751 "Display routes matching the community-list\n"
8752 "community-list name\n")
8754 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_MULTICAST
);
8757 DEFUN (show_bgp_community_list_exact
,
8758 show_bgp_community_list_exact_cmd
,
8759 "show bgp community-list (<1-500>|WORD) exact-match",
8762 "Display routes matching the community-list\n"
8763 "community-list number\n"
8764 "community-list name\n"
8765 "Exact match of the communities\n")
8767 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
8770 ALIAS (show_bgp_community_list_exact
,
8771 show_bgp_ipv6_community_list_exact_cmd
,
8772 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
8776 "Display routes matching the community-list\n"
8777 "community-list number\n"
8778 "community-list name\n"
8779 "Exact match of the communities\n")
8782 DEFUN (show_ipv6_bgp_community_list_exact
,
8783 show_ipv6_bgp_community_list_exact_cmd
,
8784 "show ipv6 bgp community-list WORD exact-match",
8788 "Display routes matching the community-list\n"
8789 "community-list name\n"
8790 "Exact match of the communities\n")
8792 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
8796 DEFUN (show_ipv6_mbgp_community_list_exact
,
8797 show_ipv6_mbgp_community_list_exact_cmd
,
8798 "show ipv6 mbgp community-list WORD exact-match",
8802 "Display routes matching the community-list\n"
8803 "community-list name\n"
8804 "Exact match of the communities\n")
8806 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_MULTICAST
);
8808 #endif /* HAVE_IPV6 */
8811 bgp_show_prefix_longer (struct vty
*vty
, const char *prefix
, afi_t afi
,
8812 safi_t safi
, enum bgp_show_type type
)
8819 ret
= str2prefix (prefix
, p
);
8822 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
8826 ret
= bgp_show (vty
, NULL
, afi
, safi
, type
, p
);
8831 DEFUN (show_ip_bgp_prefix_longer
,
8832 show_ip_bgp_prefix_longer_cmd
,
8833 "show ip bgp A.B.C.D/M longer-prefixes",
8837 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8838 "Display route and more specific routes\n")
8840 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8841 bgp_show_type_prefix_longer
);
8844 DEFUN (show_ip_bgp_flap_prefix_longer
,
8845 show_ip_bgp_flap_prefix_longer_cmd
,
8846 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
8850 "Display flap statistics of routes\n"
8851 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8852 "Display route and more specific routes\n")
8854 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8855 bgp_show_type_flap_prefix_longer
);
8858 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
8859 show_ip_bgp_ipv4_prefix_longer_cmd
,
8860 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
8865 "Address Family modifier\n"
8866 "Address Family modifier\n"
8867 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8868 "Display route and more specific routes\n")
8870 if (strncmp (argv
[0], "m", 1) == 0)
8871 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
8872 bgp_show_type_prefix_longer
);
8874 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
8875 bgp_show_type_prefix_longer
);
8878 DEFUN (show_ip_bgp_flap_address
,
8879 show_ip_bgp_flap_address_cmd
,
8880 "show ip bgp flap-statistics A.B.C.D",
8884 "Display flap statistics of routes\n"
8885 "Network in the BGP routing table to display\n")
8887 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8888 bgp_show_type_flap_address
);
8891 DEFUN (show_ip_bgp_flap_prefix
,
8892 show_ip_bgp_flap_prefix_cmd
,
8893 "show ip bgp flap-statistics A.B.C.D/M",
8897 "Display flap statistics of routes\n"
8898 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8900 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8901 bgp_show_type_flap_prefix
);
8904 DEFUN (show_bgp_prefix_longer
,
8905 show_bgp_prefix_longer_cmd
,
8906 "show bgp X:X::X:X/M longer-prefixes",
8909 "IPv6 prefix <network>/<length>\n"
8910 "Display route and more specific routes\n")
8912 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8913 bgp_show_type_prefix_longer
);
8916 ALIAS (show_bgp_prefix_longer
,
8917 show_bgp_ipv6_prefix_longer_cmd
,
8918 "show bgp ipv6 X:X::X:X/M longer-prefixes",
8922 "IPv6 prefix <network>/<length>\n"
8923 "Display route and more specific routes\n")
8926 DEFUN (show_ipv6_bgp_prefix_longer
,
8927 show_ipv6_bgp_prefix_longer_cmd
,
8928 "show ipv6 bgp X:X::X:X/M longer-prefixes",
8932 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8933 "Display route and more specific routes\n")
8935 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8936 bgp_show_type_prefix_longer
);
8940 DEFUN (show_ipv6_mbgp_prefix_longer
,
8941 show_ipv6_mbgp_prefix_longer_cmd
,
8942 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
8946 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8947 "Display route and more specific routes\n")
8949 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
8950 bgp_show_type_prefix_longer
);
8952 #endif /* HAVE_IPV6 */
8954 static struct peer
*
8955 peer_lookup_in_view (struct vty
*vty
, const char *view_name
,
8963 /* BGP structure lookup. */
8966 bgp
= bgp_lookup_by_name (view_name
);
8969 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
8975 bgp
= bgp_get_default ();
8978 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
8983 /* Get peer sockunion. */
8984 ret
= str2sockunion (ip_str
, &su
);
8987 vty_out (vty
, "Malformed address: %s%s", ip_str
, VTY_NEWLINE
);
8991 /* Peer structure lookup. */
8992 peer
= peer_lookup (bgp
, &su
);
8995 vty_out (vty
, "No such neighbor%s", VTY_NEWLINE
);
9004 BGP_STATS_MAXBITLEN
= 0,
9008 BGP_STATS_UNAGGREGATEABLE
,
9009 BGP_STATS_MAX_AGGREGATEABLE
,
9010 BGP_STATS_AGGREGATES
,
9012 BGP_STATS_ASPATH_COUNT
,
9013 BGP_STATS_ASPATH_MAXHOPS
,
9014 BGP_STATS_ASPATH_TOTHOPS
,
9015 BGP_STATS_ASPATH_MAXSIZE
,
9016 BGP_STATS_ASPATH_TOTSIZE
,
9017 BGP_STATS_ASN_HIGHEST
,
9021 static const char *table_stats_strs
[] =
9023 [BGP_STATS_PREFIXES
] = "Total Prefixes",
9024 [BGP_STATS_TOTPLEN
] = "Average prefix length",
9025 [BGP_STATS_RIB
] = "Total Advertisements",
9026 [BGP_STATS_UNAGGREGATEABLE
] = "Unaggregateable prefixes",
9027 [BGP_STATS_MAX_AGGREGATEABLE
] = "Maximum aggregateable prefixes",
9028 [BGP_STATS_AGGREGATES
] = "BGP Aggregate advertisements",
9029 [BGP_STATS_SPACE
] = "Address space advertised",
9030 [BGP_STATS_ASPATH_COUNT
] = "Advertisements with paths",
9031 [BGP_STATS_ASPATH_MAXHOPS
] = "Longest AS-Path (hops)",
9032 [BGP_STATS_ASPATH_MAXSIZE
] = "Largest AS-Path (bytes)",
9033 [BGP_STATS_ASPATH_TOTHOPS
] = "Average AS-Path length (hops)",
9034 [BGP_STATS_ASPATH_TOTSIZE
] = "Average AS-Path size (bytes)",
9035 [BGP_STATS_ASN_HIGHEST
] = "Highest public ASN",
9036 [BGP_STATS_MAX
] = NULL
,
9039 struct bgp_table_stats
9041 struct bgp_table
*table
;
9042 unsigned long long counts
[BGP_STATS_MAX
];
9046 #define TALLY_SIGFIG 100000
9047 static unsigned long
9048 ravg_tally (unsigned long count
, unsigned long oldavg
, unsigned long newval
)
9050 unsigned long newtot
= (count
-1) * oldavg
+ (newval
* TALLY_SIGFIG
);
9051 unsigned long res
= (newtot
* TALLY_SIGFIG
) / count
;
9052 unsigned long ret
= newtot
/ count
;
9054 if ((res
% TALLY_SIGFIG
) > (TALLY_SIGFIG
/2))
9062 bgp_table_stats_walker (struct thread
*t
)
9064 struct bgp_node
*rn
;
9065 struct bgp_node
*top
;
9066 struct bgp_table_stats
*ts
= THREAD_ARG (t
);
9067 unsigned int space
= 0;
9069 if (!(top
= bgp_table_top (ts
->table
)))
9072 switch (top
->p
.family
)
9075 space
= IPV4_MAX_BITLEN
;
9078 space
= IPV6_MAX_BITLEN
;
9082 ts
->counts
[BGP_STATS_MAXBITLEN
] = space
;
9084 for (rn
= top
; rn
; rn
= bgp_route_next (rn
))
9086 struct bgp_info
*ri
;
9087 struct bgp_node
*prn
= rn
->parent
;
9088 unsigned int rinum
= 0;
9096 ts
->counts
[BGP_STATS_PREFIXES
]++;
9097 ts
->counts
[BGP_STATS_TOTPLEN
] += rn
->p
.prefixlen
;
9100 ts
->counts
[BGP_STATS_AVGPLEN
]
9101 = ravg_tally (ts
->counts
[BGP_STATS_PREFIXES
],
9102 ts
->counts
[BGP_STATS_AVGPLEN
],
9106 /* check if the prefix is included by any other announcements */
9107 while (prn
&& !prn
->info
)
9110 if (prn
== NULL
|| prn
== top
)
9112 ts
->counts
[BGP_STATS_UNAGGREGATEABLE
]++;
9113 /* announced address space */
9115 ts
->counts
[BGP_STATS_SPACE
] += 1 << (space
- rn
->p
.prefixlen
);
9118 ts
->counts
[BGP_STATS_MAX_AGGREGATEABLE
]++;
9120 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
9123 ts
->counts
[BGP_STATS_RIB
]++;
9126 (CHECK_FLAG (ri
->attr
->flag
,
9127 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
))))
9128 ts
->counts
[BGP_STATS_AGGREGATES
]++;
9131 if (ri
->attr
&& ri
->attr
->aspath
)
9133 unsigned int hops
= aspath_count_hops (ri
->attr
->aspath
);
9134 unsigned int size
= aspath_size (ri
->attr
->aspath
);
9135 as_t highest
= aspath_highest (ri
->attr
->aspath
);
9137 ts
->counts
[BGP_STATS_ASPATH_COUNT
]++;
9139 if (hops
> ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
])
9140 ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
] = hops
;
9142 if (size
> ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
])
9143 ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
] = size
;
9145 ts
->counts
[BGP_STATS_ASPATH_TOTHOPS
] += hops
;
9146 ts
->counts
[BGP_STATS_ASPATH_TOTSIZE
] += size
;
9148 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
]
9149 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
9150 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
],
9152 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
]
9153 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
9154 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
],
9157 if (highest
> ts
->counts
[BGP_STATS_ASN_HIGHEST
])
9158 ts
->counts
[BGP_STATS_ASN_HIGHEST
] = highest
;
9166 bgp_table_stats (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
)
9168 struct bgp_table_stats ts
;
9171 if (!bgp
->rib
[afi
][safi
])
9173 vty_out (vty
, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE
);
9177 memset (&ts
, 0, sizeof (ts
));
9178 ts
.table
= bgp
->rib
[afi
][safi
];
9179 thread_execute (bm
->master
, bgp_table_stats_walker
, &ts
, 0);
9181 vty_out (vty
, "BGP %s RIB statistics%s%s",
9182 afi_safi_print (afi
, safi
), VTY_NEWLINE
, VTY_NEWLINE
);
9184 for (i
= 0; i
< BGP_STATS_MAX
; i
++)
9186 if (!table_stats_strs
[i
])
9192 case BGP_STATS_ASPATH_AVGHOPS
:
9193 case BGP_STATS_ASPATH_AVGSIZE
:
9194 case BGP_STATS_AVGPLEN
:
9195 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9196 vty_out (vty
, "%12.2f",
9197 (float)ts
.counts
[i
] / (float)TALLY_SIGFIG
);
9200 case BGP_STATS_ASPATH_TOTHOPS
:
9201 case BGP_STATS_ASPATH_TOTSIZE
:
9202 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9203 vty_out (vty
, "%12.2f",
9205 (float)ts
.counts
[i
] /
9206 (float)ts
.counts
[BGP_STATS_ASPATH_COUNT
]
9209 case BGP_STATS_TOTPLEN
:
9210 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9211 vty_out (vty
, "%12.2f",
9213 (float)ts
.counts
[i
] /
9214 (float)ts
.counts
[BGP_STATS_PREFIXES
]
9217 case BGP_STATS_SPACE
:
9218 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9219 vty_out (vty
, "%12llu%s", ts
.counts
[i
], VTY_NEWLINE
);
9220 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 9)
9222 vty_out (vty
, "%30s: ", "%% announced ");
9223 vty_out (vty
, "%12.2f%s",
9224 100 * (float)ts
.counts
[BGP_STATS_SPACE
] /
9225 (float)((uint64_t)1UL << ts
.counts
[BGP_STATS_MAXBITLEN
]),
9227 vty_out (vty
, "%30s: ", "/8 equivalent ");
9228 vty_out (vty
, "%12.2f%s",
9229 (float)ts
.counts
[BGP_STATS_SPACE
] /
9230 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 8)),
9232 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 25)
9234 vty_out (vty
, "%30s: ", "/24 equivalent ");
9235 vty_out (vty
, "%12.2f",
9236 (float)ts
.counts
[BGP_STATS_SPACE
] /
9237 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 24)));
9240 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9241 vty_out (vty
, "%12llu", ts
.counts
[i
]);
9244 vty_out (vty
, "%s", VTY_NEWLINE
);
9250 bgp_table_stats_vty (struct vty
*vty
, const char *name
,
9251 const char *afi_str
, const char *safi_str
)
9258 bgp
= bgp_lookup_by_name (name
);
9260 bgp
= bgp_get_default ();
9264 vty_out (vty
, "%% No such BGP instance exist%s", VTY_NEWLINE
);
9267 if (strncmp (afi_str
, "ipv", 3) == 0)
9269 if (strncmp (afi_str
, "ipv4", 4) == 0)
9271 else if (strncmp (afi_str
, "ipv6", 4) == 0)
9275 vty_out (vty
, "%% Invalid address family %s%s",
9276 afi_str
, VTY_NEWLINE
);
9279 if (strncmp (safi_str
, "m", 1) == 0)
9280 safi
= SAFI_MULTICAST
;
9281 else if (strncmp (safi_str
, "u", 1) == 0)
9282 safi
= SAFI_UNICAST
;
9283 else if (strncmp (safi_str
, "vpnv4", 5) == 0)
9284 safi
= BGP_SAFI_VPNV4
;
9285 else if (strncmp (safi_str
, "vpnv6", 6) == 0)
9286 safi
= BGP_SAFI_VPNV6
;
9289 vty_out (vty
, "%% Invalid subsequent address family %s%s",
9290 safi_str
, VTY_NEWLINE
);
9296 vty_out (vty
, "%% Invalid address family %s%s",
9297 afi_str
, VTY_NEWLINE
);
9301 if ((afi
== AFI_IP
&& safi
== BGP_SAFI_VPNV6
)
9302 || (afi
== AFI_IP6
&& safi
== BGP_SAFI_VPNV4
))
9304 vty_out (vty
, "%% Invalid subsequent address family %s for %s%s",
9305 afi_str
, safi_str
, VTY_NEWLINE
);
9308 return bgp_table_stats (vty
, bgp
, afi
, safi
);
9311 DEFUN (show_bgp_statistics
,
9312 show_bgp_statistics_cmd
,
9313 "show bgp (ipv4|ipv6) (unicast|multicast) statistics",
9318 "Address Family modifier\n"
9319 "Address Family modifier\n"
9320 "BGP RIB advertisement statistics\n")
9322 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
9325 ALIAS (show_bgp_statistics
,
9326 show_bgp_statistics_vpnv4_cmd
,
9327 "show bgp (ipv4) (vpnv4) statistics",
9331 "Address Family modifier\n"
9332 "BGP RIB advertisement statistics\n")
9334 DEFUN (show_bgp_statistics_view
,
9335 show_bgp_statistics_view_cmd
,
9336 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics",
9342 "Address Family modifier\n"
9343 "Address Family modifier\n"
9344 "BGP RIB advertisement statistics\n")
9346 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
9349 ALIAS (show_bgp_statistics_view
,
9350 show_bgp_statistics_view_vpnv4_cmd
,
9351 "show bgp view WORD (ipv4) (vpnv4) statistics",
9356 "Address Family modifier\n"
9357 "BGP RIB advertisement statistics\n")
9369 PCOUNT_PFCNT
, /* the figure we display to users */
9373 static const char *pcount_strs
[] =
9375 [PCOUNT_ADJ_IN
] = "Adj-in",
9376 [PCOUNT_DAMPED
] = "Damped",
9377 [PCOUNT_REMOVED
] = "Removed",
9378 [PCOUNT_HISTORY
] = "History",
9379 [PCOUNT_STALE
] = "Stale",
9380 [PCOUNT_VALID
] = "Valid",
9381 [PCOUNT_ALL
] = "All RIB",
9382 [PCOUNT_COUNTED
] = "PfxCt counted",
9383 [PCOUNT_PFCNT
] = "Useable",
9384 [PCOUNT_MAX
] = NULL
,
9389 unsigned int count
[PCOUNT_MAX
];
9390 const struct peer
*peer
;
9391 const struct bgp_table
*table
;
9395 bgp_peer_count_walker (struct thread
*t
)
9397 struct bgp_node
*rn
;
9398 struct peer_pcounts
*pc
= THREAD_ARG (t
);
9399 const struct peer
*peer
= pc
->peer
;
9401 for (rn
= bgp_table_top (pc
->table
); rn
; rn
= bgp_route_next (rn
))
9403 struct bgp_adj_in
*ain
;
9404 struct bgp_info
*ri
;
9406 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
9407 if (ain
->peer
== peer
)
9408 pc
->count
[PCOUNT_ADJ_IN
]++;
9410 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
9412 char buf
[SU_ADDRSTRLEN
];
9414 if (ri
->peer
!= peer
)
9417 pc
->count
[PCOUNT_ALL
]++;
9419 if (CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
))
9420 pc
->count
[PCOUNT_DAMPED
]++;
9421 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
9422 pc
->count
[PCOUNT_HISTORY
]++;
9423 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
9424 pc
->count
[PCOUNT_REMOVED
]++;
9425 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
9426 pc
->count
[PCOUNT_STALE
]++;
9427 if (CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
))
9428 pc
->count
[PCOUNT_VALID
]++;
9429 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9430 pc
->count
[PCOUNT_PFCNT
]++;
9432 if (CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
9434 pc
->count
[PCOUNT_COUNTED
]++;
9435 if (CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9436 plog_warn (peer
->log
,
9437 "%s [pcount] %s/%d is counted but flags 0x%x",
9439 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
9440 buf
, SU_ADDRSTRLEN
),
9446 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9447 plog_warn (peer
->log
,
9448 "%s [pcount] %s/%d not counted but flags 0x%x",
9450 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
9451 buf
, SU_ADDRSTRLEN
),
9461 bgp_peer_counts (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
)
9463 struct peer_pcounts pcounts
= { .peer
= peer
};
9466 if (!peer
|| !peer
->bgp
|| !peer
->afc
[afi
][safi
]
9467 || !peer
->bgp
->rib
[afi
][safi
])
9469 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
9473 memset (&pcounts
, 0, sizeof(pcounts
));
9474 pcounts
.peer
= peer
;
9475 pcounts
.table
= peer
->bgp
->rib
[afi
][safi
];
9477 /* in-place call via thread subsystem so as to record execution time
9478 * stats for the thread-walk (i.e. ensure this can't be blamed on
9479 * on just vty_read()).
9481 thread_execute (bm
->master
, bgp_peer_count_walker
, &pcounts
, 0);
9483 vty_out (vty
, "Prefix counts for %s, %s%s",
9484 peer
->host
, afi_safi_print (afi
, safi
), VTY_NEWLINE
);
9485 vty_out (vty
, "PfxCt: %ld%s", peer
->pcount
[afi
][safi
], VTY_NEWLINE
);
9486 vty_out (vty
, "%sCounts from RIB table walk:%s%s",
9487 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
9489 for (i
= 0; i
< PCOUNT_MAX
; i
++)
9490 vty_out (vty
, "%20s: %-10d%s",
9491 pcount_strs
[i
], pcounts
.count
[i
], VTY_NEWLINE
);
9493 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
9495 vty_out (vty
, "%s [pcount] PfxCt drift!%s",
9496 peer
->host
, VTY_NEWLINE
);
9497 vty_out (vty
, "Please report this bug, with the above command output%s",
9504 DEFUN (show_ip_bgp_neighbor_prefix_counts
,
9505 show_ip_bgp_neighbor_prefix_counts_cmd
,
9506 "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9510 "Detailed information on TCP and BGP neighbor connections\n"
9511 "Neighbor to display information about\n"
9512 "Neighbor to display information about\n"
9513 "Display detailed prefix count information\n")
9517 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9521 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
);
9524 DEFUN (show_bgp_ipv6_neighbor_prefix_counts
,
9525 show_bgp_ipv6_neighbor_prefix_counts_cmd
,
9526 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9530 "Detailed information on TCP and BGP neighbor connections\n"
9531 "Neighbor to display information about\n"
9532 "Neighbor to display information about\n"
9533 "Display detailed prefix count information\n")
9537 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9541 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
);
9544 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts
,
9545 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
,
9546 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9551 "Address Family modifier\n"
9552 "Address Family modifier\n"
9553 "Detailed information on TCP and BGP neighbor connections\n"
9554 "Neighbor to display information about\n"
9555 "Neighbor to display information about\n"
9556 "Display detailed prefix count information\n")
9560 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9564 if (strncmp (argv
[0], "m", 1) == 0)
9565 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MULTICAST
);
9567 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
);
9570 DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts
,
9571 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
,
9572 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9577 "Address Family modifier\n"
9578 "Address Family modifier\n"
9579 "Detailed information on TCP and BGP neighbor connections\n"
9580 "Neighbor to display information about\n"
9581 "Neighbor to display information about\n"
9582 "Display detailed prefix count information\n")
9586 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9590 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MPLS_VPN
);
9595 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
9598 struct bgp_table
*table
;
9599 struct bgp_adj_in
*ain
;
9600 struct bgp_adj_out
*adj
;
9601 unsigned long output_count
;
9602 struct bgp_node
*rn
;
9612 table
= bgp
->rib
[afi
][safi
];
9616 if (! in
&& CHECK_FLAG (peer
->af_sflags
[afi
][safi
],
9617 PEER_STATUS_DEFAULT_ORIGINATE
))
9619 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9620 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9621 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9623 vty_out (vty
, "Originating default network 0.0.0.0%s%s",
9624 VTY_NEWLINE
, VTY_NEWLINE
);
9628 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
9631 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
9632 if (ain
->peer
== peer
)
9636 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9637 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9638 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9643 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
9648 route_vty_out_tmp (vty
, &rn
->p
, ain
->attr
, safi
);
9655 for (adj
= rn
->adj_out
; adj
; adj
= adj
->next
)
9656 if (adj
->peer
== peer
)
9660 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9661 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9662 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9667 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
9672 route_vty_out_tmp (vty
, &rn
->p
, adj
->attr
, safi
);
9678 if (output_count
!= 0)
9679 vty_out (vty
, "%sTotal number of prefixes %ld%s",
9680 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
9684 peer_adj_routes (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
, int in
)
9686 if (! peer
|| ! peer
->afc
[afi
][safi
])
9688 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
9692 if (in
&& ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
9694 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s",
9699 show_adj_route (vty
, peer
, afi
, safi
, in
);
9704 DEFUN (show_ip_bgp_view_neighbor_advertised_route
,
9705 show_ip_bgp_view_neighbor_advertised_route_cmd
,
9706 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9712 "Detailed information on TCP and BGP neighbor connections\n"
9713 "Neighbor to display information about\n"
9714 "Neighbor to display information about\n"
9715 "Display the routes advertised to a BGP neighbor\n")
9720 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9722 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9727 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0);
9730 ALIAS (show_ip_bgp_view_neighbor_advertised_route
,
9731 show_ip_bgp_neighbor_advertised_route_cmd
,
9732 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9736 "Detailed information on TCP and BGP neighbor connections\n"
9737 "Neighbor to display information about\n"
9738 "Neighbor to display information about\n"
9739 "Display the routes advertised to a BGP neighbor\n")
9741 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
9742 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
9743 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9748 "Address Family modifier\n"
9749 "Address Family modifier\n"
9750 "Detailed information on TCP and BGP neighbor connections\n"
9751 "Neighbor to display information about\n"
9752 "Neighbor to display information about\n"
9753 "Display the routes advertised to a BGP neighbor\n")
9757 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9761 if (strncmp (argv
[0], "m", 1) == 0)
9762 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 0);
9764 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0);
9768 DEFUN (show_bgp_view_neighbor_advertised_route
,
9769 show_bgp_view_neighbor_advertised_route_cmd
,
9770 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9775 "Detailed information on TCP and BGP neighbor connections\n"
9776 "Neighbor to display information about\n"
9777 "Neighbor to display information about\n"
9778 "Display the routes advertised to a BGP neighbor\n")
9783 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9785 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9790 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0);
9793 ALIAS (show_bgp_view_neighbor_advertised_route
,
9794 show_bgp_view_ipv6_neighbor_advertised_route_cmd
,
9795 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9801 "Detailed information on TCP and BGP neighbor connections\n"
9802 "Neighbor to display information about\n"
9803 "Neighbor to display information about\n"
9804 "Display the routes advertised to a BGP neighbor\n")
9806 DEFUN (show_bgp_view_neighbor_received_routes
,
9807 show_bgp_view_neighbor_received_routes_cmd
,
9808 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
9813 "Detailed information on TCP and BGP neighbor connections\n"
9814 "Neighbor to display information about\n"
9815 "Neighbor to display information about\n"
9816 "Display the received routes from neighbor\n")
9821 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9823 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9828 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1);
9831 ALIAS (show_bgp_view_neighbor_received_routes
,
9832 show_bgp_view_ipv6_neighbor_received_routes_cmd
,
9833 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
9839 "Detailed information on TCP and BGP neighbor connections\n"
9840 "Neighbor to display information about\n"
9841 "Neighbor to display information about\n"
9842 "Display the received routes from neighbor\n")
9844 ALIAS (show_bgp_view_neighbor_advertised_route
,
9845 show_bgp_neighbor_advertised_route_cmd
,
9846 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9849 "Detailed information on TCP and BGP neighbor connections\n"
9850 "Neighbor to display information about\n"
9851 "Neighbor to display information about\n"
9852 "Display the routes advertised to a BGP neighbor\n")
9854 ALIAS (show_bgp_view_neighbor_advertised_route
,
9855 show_bgp_ipv6_neighbor_advertised_route_cmd
,
9856 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9860 "Detailed information on TCP and BGP neighbor connections\n"
9861 "Neighbor to display information about\n"
9862 "Neighbor to display information about\n"
9863 "Display the routes advertised to a BGP neighbor\n")
9866 ALIAS (show_bgp_view_neighbor_advertised_route
,
9867 ipv6_bgp_neighbor_advertised_route_cmd
,
9868 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9872 "Detailed information on TCP and BGP neighbor connections\n"
9873 "Neighbor to display information about\n"
9874 "Neighbor to display information about\n"
9875 "Display the routes advertised to a BGP neighbor\n")
9878 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
9879 ipv6_mbgp_neighbor_advertised_route_cmd
,
9880 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9884 "Detailed information on TCP and BGP neighbor connections\n"
9885 "Neighbor to display information about\n"
9886 "Neighbor to display information about\n"
9887 "Display the routes advertised to a BGP neighbor\n")
9891 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9895 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 0);
9897 #endif /* HAVE_IPV6 */
9899 DEFUN (show_ip_bgp_view_neighbor_received_routes
,
9900 show_ip_bgp_view_neighbor_received_routes_cmd
,
9901 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
9907 "Detailed information on TCP and BGP neighbor connections\n"
9908 "Neighbor to display information about\n"
9909 "Neighbor to display information about\n"
9910 "Display the received routes from neighbor\n")
9915 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9917 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9922 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1);
9925 ALIAS (show_ip_bgp_view_neighbor_received_routes
,
9926 show_ip_bgp_neighbor_received_routes_cmd
,
9927 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
9931 "Detailed information on TCP and BGP neighbor connections\n"
9932 "Neighbor to display information about\n"
9933 "Neighbor to display information about\n"
9934 "Display the received routes from neighbor\n")
9936 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
9937 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
9938 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
9943 "Address Family modifier\n"
9944 "Address Family modifier\n"
9945 "Detailed information on TCP and BGP neighbor connections\n"
9946 "Neighbor to display information about\n"
9947 "Neighbor to display information about\n"
9948 "Display the received routes from neighbor\n")
9952 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9956 if (strncmp (argv
[0], "m", 1) == 0)
9957 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 1);
9959 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1);
9962 DEFUN (show_ip_bgp_neighbor_received_prefix_filter
,
9963 show_ip_bgp_neighbor_received_prefix_filter_cmd
,
9964 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9968 "Detailed information on TCP and BGP neighbor connections\n"
9969 "Neighbor to display information about\n"
9970 "Neighbor to display information about\n"
9971 "Display information received from a BGP neighbor\n"
9972 "Display the prefixlist filter\n")
9975 union sockunion
*su
;
9979 su
= sockunion_str2su (argv
[0]);
9983 peer
= peer_lookup (NULL
, su
);
9987 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
9988 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
9991 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
9992 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
9998 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter
,
9999 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
,
10000 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10005 "Address Family modifier\n"
10006 "Address Family modifier\n"
10007 "Detailed information on TCP and BGP neighbor connections\n"
10008 "Neighbor to display information about\n"
10009 "Neighbor to display information about\n"
10010 "Display information received from a BGP neighbor\n"
10011 "Display the prefixlist filter\n")
10014 union sockunion
*su
;
10018 su
= sockunion_str2su (argv
[1]);
10020 return CMD_WARNING
;
10022 peer
= peer_lookup (NULL
, su
);
10024 return CMD_WARNING
;
10026 if (strncmp (argv
[0], "m", 1) == 0)
10028 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_MULTICAST
);
10029 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
10032 vty_out (vty
, "Address family: IPv4 Multicast%s", VTY_NEWLINE
);
10033 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
10038 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
10039 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
10042 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
10043 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
10047 return CMD_SUCCESS
;
10052 ALIAS (show_bgp_view_neighbor_received_routes
,
10053 show_bgp_neighbor_received_routes_cmd
,
10054 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
10057 "Detailed information on TCP and BGP neighbor connections\n"
10058 "Neighbor to display information about\n"
10059 "Neighbor to display information about\n"
10060 "Display the received routes from neighbor\n")
10062 ALIAS (show_bgp_view_neighbor_received_routes
,
10063 show_bgp_ipv6_neighbor_received_routes_cmd
,
10064 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
10068 "Detailed information on TCP and BGP neighbor connections\n"
10069 "Neighbor to display information about\n"
10070 "Neighbor to display information about\n"
10071 "Display the received routes from neighbor\n")
10073 DEFUN (show_bgp_neighbor_received_prefix_filter
,
10074 show_bgp_neighbor_received_prefix_filter_cmd
,
10075 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10078 "Detailed information on TCP and BGP neighbor connections\n"
10079 "Neighbor to display information about\n"
10080 "Neighbor to display information about\n"
10081 "Display information received from a BGP neighbor\n"
10082 "Display the prefixlist filter\n")
10085 union sockunion
*su
;
10089 su
= sockunion_str2su (argv
[0]);
10091 return CMD_WARNING
;
10093 peer
= peer_lookup (NULL
, su
);
10095 return CMD_WARNING
;
10097 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
10098 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
);
10101 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
10102 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
);
10105 return CMD_SUCCESS
;
10108 ALIAS (show_bgp_neighbor_received_prefix_filter
,
10109 show_bgp_ipv6_neighbor_received_prefix_filter_cmd
,
10110 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10114 "Detailed information on TCP and BGP neighbor connections\n"
10115 "Neighbor to display information about\n"
10116 "Neighbor to display information about\n"
10117 "Display information received from a BGP neighbor\n"
10118 "Display the prefixlist filter\n")
10121 ALIAS (show_bgp_view_neighbor_received_routes
,
10122 ipv6_bgp_neighbor_received_routes_cmd
,
10123 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
10127 "Detailed information on TCP and BGP neighbor connections\n"
10128 "Neighbor to display information about\n"
10129 "Neighbor to display information about\n"
10130 "Display the received routes from neighbor\n")
10133 DEFUN (ipv6_mbgp_neighbor_received_routes
,
10134 ipv6_mbgp_neighbor_received_routes_cmd
,
10135 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
10139 "Detailed information on TCP and BGP neighbor connections\n"
10140 "Neighbor to display information about\n"
10141 "Neighbor to display information about\n"
10142 "Display the received routes from neighbor\n")
10146 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10148 return CMD_WARNING
;
10150 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 1);
10153 DEFUN (show_bgp_view_neighbor_received_prefix_filter
,
10154 show_bgp_view_neighbor_received_prefix_filter_cmd
,
10155 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10160 "Detailed information on TCP and BGP neighbor connections\n"
10161 "Neighbor to display information about\n"
10162 "Neighbor to display information about\n"
10163 "Display information received from a BGP neighbor\n"
10164 "Display the prefixlist filter\n")
10167 union sockunion
*su
;
10172 /* BGP structure lookup. */
10173 bgp
= bgp_lookup_by_name (argv
[0]);
10176 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10177 return CMD_WARNING
;
10180 su
= sockunion_str2su (argv
[1]);
10182 return CMD_WARNING
;
10184 peer
= peer_lookup (bgp
, su
);
10186 return CMD_WARNING
;
10188 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
10189 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
);
10192 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
10193 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
);
10196 return CMD_SUCCESS
;
10199 ALIAS (show_bgp_view_neighbor_received_prefix_filter
,
10200 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
,
10201 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10207 "Detailed information on TCP and BGP neighbor connections\n"
10208 "Neighbor to display information about\n"
10209 "Neighbor to display information about\n"
10210 "Display information received from a BGP neighbor\n"
10211 "Display the prefixlist filter\n")
10212 #endif /* HAVE_IPV6 */
10215 bgp_show_neighbor_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
,
10216 safi_t safi
, enum bgp_show_type type
)
10218 if (! peer
|| ! peer
->afc
[afi
][safi
])
10220 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
10221 return CMD_WARNING
;
10224 return bgp_show (vty
, peer
->bgp
, afi
, safi
, type
, &peer
->su
);
10227 DEFUN (show_ip_bgp_neighbor_routes
,
10228 show_ip_bgp_neighbor_routes_cmd
,
10229 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
10233 "Detailed information on TCP and BGP neighbor connections\n"
10234 "Neighbor to display information about\n"
10235 "Neighbor to display information about\n"
10236 "Display routes learned from neighbor\n")
10240 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10242 return CMD_WARNING
;
10244 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10245 bgp_show_type_neighbor
);
10248 DEFUN (show_ip_bgp_neighbor_flap
,
10249 show_ip_bgp_neighbor_flap_cmd
,
10250 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10254 "Detailed information on TCP and BGP neighbor connections\n"
10255 "Neighbor to display information about\n"
10256 "Neighbor to display information about\n"
10257 "Display flap statistics of the routes learned from neighbor\n")
10261 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10263 return CMD_WARNING
;
10265 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10266 bgp_show_type_flap_neighbor
);
10269 DEFUN (show_ip_bgp_neighbor_damp
,
10270 show_ip_bgp_neighbor_damp_cmd
,
10271 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10275 "Detailed information on TCP and BGP neighbor connections\n"
10276 "Neighbor to display information about\n"
10277 "Neighbor to display information about\n"
10278 "Display the dampened routes received from neighbor\n")
10282 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10284 return CMD_WARNING
;
10286 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10287 bgp_show_type_damp_neighbor
);
10290 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
10291 show_ip_bgp_ipv4_neighbor_routes_cmd
,
10292 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
10297 "Address Family modifier\n"
10298 "Address Family modifier\n"
10299 "Detailed information on TCP and BGP neighbor connections\n"
10300 "Neighbor to display information about\n"
10301 "Neighbor to display information about\n"
10302 "Display routes learned from neighbor\n")
10306 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
10308 return CMD_WARNING
;
10310 if (strncmp (argv
[0], "m", 1) == 0)
10311 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_MULTICAST
,
10312 bgp_show_type_neighbor
);
10314 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10315 bgp_show_type_neighbor
);
10318 DEFUN (show_ip_bgp_view_rsclient
,
10319 show_ip_bgp_view_rsclient_cmd
,
10320 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
10326 "Information about Route Server Client\n"
10329 struct bgp_table
*table
;
10333 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10335 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10338 return CMD_WARNING
;
10340 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
10342 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10344 return CMD_WARNING
;
10347 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
10348 PEER_FLAG_RSERVER_CLIENT
))
10350 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10352 return CMD_WARNING
;
10355 table
= peer
->rib
[AFI_IP
][SAFI_UNICAST
];
10357 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
10360 ALIAS (show_ip_bgp_view_rsclient
,
10361 show_ip_bgp_rsclient_cmd
,
10362 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
10366 "Information about Route Server Client\n"
10369 DEFUN (show_ip_bgp_view_rsclient_route
,
10370 show_ip_bgp_view_rsclient_route_cmd
,
10371 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
10377 "Information about Route Server Client\n"
10379 "Network in the BGP routing table to display\n")
10384 /* BGP structure lookup. */
10387 bgp
= bgp_lookup_by_name (argv
[0]);
10390 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10391 return CMD_WARNING
;
10396 bgp
= bgp_get_default ();
10399 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10400 return CMD_WARNING
;
10405 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10407 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10410 return CMD_WARNING
;
10412 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
10414 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10416 return CMD_WARNING
;
10419 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
10420 PEER_FLAG_RSERVER_CLIENT
))
10422 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10424 return CMD_WARNING
;
10427 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][SAFI_UNICAST
],
10428 (argc
== 3) ? argv
[2] : argv
[1],
10429 AFI_IP
, SAFI_UNICAST
, NULL
, 0);
10432 ALIAS (show_ip_bgp_view_rsclient_route
,
10433 show_ip_bgp_rsclient_route_cmd
,
10434 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
10438 "Information about Route Server Client\n"
10440 "Network in the BGP routing table to display\n")
10442 DEFUN (show_ip_bgp_view_rsclient_prefix
,
10443 show_ip_bgp_view_rsclient_prefix_cmd
,
10444 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
10450 "Information about Route Server Client\n"
10452 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10457 /* BGP structure lookup. */
10460 bgp
= bgp_lookup_by_name (argv
[0]);
10463 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10464 return CMD_WARNING
;
10469 bgp
= bgp_get_default ();
10472 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10473 return CMD_WARNING
;
10478 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10480 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10483 return CMD_WARNING
;
10485 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
10487 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10489 return CMD_WARNING
;
10492 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
10493 PEER_FLAG_RSERVER_CLIENT
))
10495 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10497 return CMD_WARNING
;
10500 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][SAFI_UNICAST
],
10501 (argc
== 3) ? argv
[2] : argv
[1],
10502 AFI_IP
, SAFI_UNICAST
, NULL
, 1);
10505 ALIAS (show_ip_bgp_view_rsclient_prefix
,
10506 show_ip_bgp_rsclient_prefix_cmd
,
10507 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
10511 "Information about Route Server Client\n"
10513 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10517 DEFUN (show_bgp_view_neighbor_routes
,
10518 show_bgp_view_neighbor_routes_cmd
,
10519 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
10524 "Detailed information on TCP and BGP neighbor connections\n"
10525 "Neighbor to display information about\n"
10526 "Neighbor to display information about\n"
10527 "Display routes learned from neighbor\n")
10532 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10534 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10537 return CMD_WARNING
;
10539 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
10540 bgp_show_type_neighbor
);
10543 ALIAS (show_bgp_view_neighbor_routes
,
10544 show_bgp_view_ipv6_neighbor_routes_cmd
,
10545 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
10551 "Detailed information on TCP and BGP neighbor connections\n"
10552 "Neighbor to display information about\n"
10553 "Neighbor to display information about\n"
10554 "Display routes learned from neighbor\n")
10556 DEFUN (show_bgp_view_neighbor_damp
,
10557 show_bgp_view_neighbor_damp_cmd
,
10558 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10563 "Detailed information on TCP and BGP neighbor connections\n"
10564 "Neighbor to display information about\n"
10565 "Neighbor to display information about\n"
10566 "Display the dampened routes received from neighbor\n")
10571 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10573 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10576 return CMD_WARNING
;
10578 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
10579 bgp_show_type_damp_neighbor
);
10582 ALIAS (show_bgp_view_neighbor_damp
,
10583 show_bgp_view_ipv6_neighbor_damp_cmd
,
10584 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10590 "Detailed information on TCP and BGP neighbor connections\n"
10591 "Neighbor to display information about\n"
10592 "Neighbor to display information about\n"
10593 "Display the dampened routes received from neighbor\n")
10595 DEFUN (show_bgp_view_neighbor_flap
,
10596 show_bgp_view_neighbor_flap_cmd
,
10597 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10602 "Detailed information on TCP and BGP neighbor connections\n"
10603 "Neighbor to display information about\n"
10604 "Neighbor to display information about\n"
10605 "Display flap statistics of the routes learned from neighbor\n")
10610 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10612 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10615 return CMD_WARNING
;
10617 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
10618 bgp_show_type_flap_neighbor
);
10621 ALIAS (show_bgp_view_neighbor_flap
,
10622 show_bgp_view_ipv6_neighbor_flap_cmd
,
10623 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10629 "Detailed information on TCP and BGP neighbor connections\n"
10630 "Neighbor to display information about\n"
10631 "Neighbor to display information about\n"
10632 "Display flap statistics of the routes learned from neighbor\n")
10634 ALIAS (show_bgp_view_neighbor_routes
,
10635 show_bgp_neighbor_routes_cmd
,
10636 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
10639 "Detailed information on TCP and BGP neighbor connections\n"
10640 "Neighbor to display information about\n"
10641 "Neighbor to display information about\n"
10642 "Display routes learned from neighbor\n")
10645 ALIAS (show_bgp_view_neighbor_routes
,
10646 show_bgp_ipv6_neighbor_routes_cmd
,
10647 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
10651 "Detailed information on TCP and BGP neighbor connections\n"
10652 "Neighbor to display information about\n"
10653 "Neighbor to display information about\n"
10654 "Display routes learned from neighbor\n")
10657 ALIAS (show_bgp_view_neighbor_routes
,
10658 ipv6_bgp_neighbor_routes_cmd
,
10659 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
10663 "Detailed information on TCP and BGP neighbor connections\n"
10664 "Neighbor to display information about\n"
10665 "Neighbor to display information about\n"
10666 "Display routes learned from neighbor\n")
10669 DEFUN (ipv6_mbgp_neighbor_routes
,
10670 ipv6_mbgp_neighbor_routes_cmd
,
10671 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
10675 "Detailed information on TCP and BGP neighbor connections\n"
10676 "Neighbor to display information about\n"
10677 "Neighbor to display information about\n"
10678 "Display routes learned from neighbor\n")
10682 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10684 return CMD_WARNING
;
10686 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
,
10687 bgp_show_type_neighbor
);
10690 ALIAS (show_bgp_view_neighbor_flap
,
10691 show_bgp_neighbor_flap_cmd
,
10692 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10695 "Detailed information on TCP and BGP neighbor connections\n"
10696 "Neighbor to display information about\n"
10697 "Neighbor to display information about\n"
10698 "Display flap statistics of the routes learned from neighbor\n")
10700 ALIAS (show_bgp_view_neighbor_flap
,
10701 show_bgp_ipv6_neighbor_flap_cmd
,
10702 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10706 "Detailed information on TCP and BGP neighbor connections\n"
10707 "Neighbor to display information about\n"
10708 "Neighbor to display information about\n"
10709 "Display flap statistics of the routes learned from neighbor\n")
10711 ALIAS (show_bgp_view_neighbor_damp
,
10712 show_bgp_neighbor_damp_cmd
,
10713 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10716 "Detailed information on TCP and BGP neighbor connections\n"
10717 "Neighbor to display information about\n"
10718 "Neighbor to display information about\n"
10719 "Display the dampened routes received from neighbor\n")
10721 ALIAS (show_bgp_view_neighbor_damp
,
10722 show_bgp_ipv6_neighbor_damp_cmd
,
10723 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10727 "Detailed information on TCP and BGP neighbor connections\n"
10728 "Neighbor to display information about\n"
10729 "Neighbor to display information about\n"
10730 "Display the dampened routes received from neighbor\n")
10732 DEFUN (show_bgp_view_rsclient
,
10733 show_bgp_view_rsclient_cmd
,
10734 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
10739 "Information about Route Server Client\n"
10742 struct bgp_table
*table
;
10746 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10748 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10751 return CMD_WARNING
;
10753 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
10755 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10757 return CMD_WARNING
;
10760 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
10761 PEER_FLAG_RSERVER_CLIENT
))
10763 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10765 return CMD_WARNING
;
10768 table
= peer
->rib
[AFI_IP6
][SAFI_UNICAST
];
10770 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
10773 ALIAS (show_bgp_view_rsclient
,
10774 show_bgp_rsclient_cmd
,
10775 "show bgp rsclient (A.B.C.D|X:X::X:X)",
10778 "Information about Route Server Client\n"
10781 DEFUN (show_bgp_view_rsclient_route
,
10782 show_bgp_view_rsclient_route_cmd
,
10783 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
10788 "Information about Route Server Client\n"
10790 "Network in the BGP routing table to display\n")
10795 /* BGP structure lookup. */
10798 bgp
= bgp_lookup_by_name (argv
[0]);
10801 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10802 return CMD_WARNING
;
10807 bgp
= bgp_get_default ();
10810 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10811 return CMD_WARNING
;
10816 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10818 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10821 return CMD_WARNING
;
10823 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
10825 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10827 return CMD_WARNING
;
10830 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
10831 PEER_FLAG_RSERVER_CLIENT
))
10833 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10835 return CMD_WARNING
;
10838 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][SAFI_UNICAST
],
10839 (argc
== 3) ? argv
[2] : argv
[1],
10840 AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
10843 ALIAS (show_bgp_view_rsclient_route
,
10844 show_bgp_rsclient_route_cmd
,
10845 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
10848 "Information about Route Server Client\n"
10850 "Network in the BGP routing table to display\n")
10852 DEFUN (show_bgp_view_rsclient_prefix
,
10853 show_bgp_view_rsclient_prefix_cmd
,
10854 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
10859 "Information about Route Server Client\n"
10861 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
10866 /* BGP structure lookup. */
10869 bgp
= bgp_lookup_by_name (argv
[0]);
10872 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10873 return CMD_WARNING
;
10878 bgp
= bgp_get_default ();
10881 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10882 return CMD_WARNING
;
10887 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10889 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10892 return CMD_WARNING
;
10894 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
10896 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10898 return CMD_WARNING
;
10901 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
10902 PEER_FLAG_RSERVER_CLIENT
))
10904 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10906 return CMD_WARNING
;
10909 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][SAFI_UNICAST
],
10910 (argc
== 3) ? argv
[2] : argv
[1],
10911 AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
10914 ALIAS (show_bgp_view_rsclient_prefix
,
10915 show_bgp_rsclient_prefix_cmd
,
10916 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
10919 "Information about Route Server Client\n"
10921 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
10923 #endif /* HAVE_IPV6 */
10925 struct bgp_table
*bgp_distance_table
;
10927 struct bgp_distance
10929 /* Distance value for the IP source prefix. */
10932 /* Name of the access-list to be matched. */
10936 static struct bgp_distance
*
10937 bgp_distance_new (void)
10939 return XCALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
10943 bgp_distance_free (struct bgp_distance
*bdistance
)
10945 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
10949 bgp_distance_set (struct vty
*vty
, const char *distance_str
,
10950 const char *ip_str
, const char *access_list_str
)
10953 struct prefix_ipv4 p
;
10955 struct bgp_node
*rn
;
10956 struct bgp_distance
*bdistance
;
10958 ret
= str2prefix_ipv4 (ip_str
, &p
);
10961 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
10962 return CMD_WARNING
;
10965 distance
= atoi (distance_str
);
10967 /* Get BGP distance node. */
10968 rn
= bgp_node_get (bgp_distance_table
, (struct prefix
*) &p
);
10971 bdistance
= rn
->info
;
10972 bgp_unlock_node (rn
);
10976 bdistance
= bgp_distance_new ();
10977 rn
->info
= bdistance
;
10980 /* Set distance value. */
10981 bdistance
->distance
= distance
;
10983 /* Reset access-list configuration. */
10984 if (bdistance
->access_list
)
10986 free (bdistance
->access_list
);
10987 bdistance
->access_list
= NULL
;
10989 if (access_list_str
)
10990 bdistance
->access_list
= strdup (access_list_str
);
10992 return CMD_SUCCESS
;
10996 bgp_distance_unset (struct vty
*vty
, const char *distance_str
,
10997 const char *ip_str
, const char *access_list_str
)
11000 struct prefix_ipv4 p
;
11002 struct bgp_node
*rn
;
11003 struct bgp_distance
*bdistance
;
11005 ret
= str2prefix_ipv4 (ip_str
, &p
);
11008 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
11009 return CMD_WARNING
;
11012 distance
= atoi (distance_str
);
11014 rn
= bgp_node_lookup (bgp_distance_table
, (struct prefix
*)&p
);
11017 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
11018 return CMD_WARNING
;
11021 bdistance
= rn
->info
;
11023 if (bdistance
->access_list
)
11024 free (bdistance
->access_list
);
11025 bgp_distance_free (bdistance
);
11028 bgp_unlock_node (rn
);
11029 bgp_unlock_node (rn
);
11031 return CMD_SUCCESS
;
11034 /* Apply BGP information to distance method. */
11036 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, struct bgp
*bgp
)
11038 struct bgp_node
*rn
;
11039 struct prefix_ipv4 q
;
11041 struct bgp_distance
*bdistance
;
11042 struct access_list
*alist
;
11043 struct bgp_static
*bgp_static
;
11048 if (p
->family
!= AF_INET
)
11051 peer
= rinfo
->peer
;
11053 if (peer
->su
.sa
.sa_family
!= AF_INET
)
11056 memset (&q
, 0, sizeof (struct prefix_ipv4
));
11057 q
.family
= AF_INET
;
11058 q
.prefix
= peer
->su
.sin
.sin_addr
;
11059 q
.prefixlen
= IPV4_MAX_BITLEN
;
11061 /* Check source address. */
11062 rn
= bgp_node_match (bgp_distance_table
, (struct prefix
*) &q
);
11065 bdistance
= rn
->info
;
11066 bgp_unlock_node (rn
);
11068 if (bdistance
->access_list
)
11070 alist
= access_list_lookup (AFI_IP
, bdistance
->access_list
);
11071 if (alist
&& access_list_apply (alist
, p
) == FILTER_PERMIT
)
11072 return bdistance
->distance
;
11075 return bdistance
->distance
;
11078 /* Backdoor check. */
11079 rn
= bgp_node_lookup (bgp
->route
[AFI_IP
][SAFI_UNICAST
], p
);
11082 bgp_static
= rn
->info
;
11083 bgp_unlock_node (rn
);
11085 if (bgp_static
->backdoor
)
11087 if (bgp
->distance_local
)
11088 return bgp
->distance_local
;
11090 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
11094 if (peer_sort (peer
) == BGP_PEER_EBGP
)
11096 if (bgp
->distance_ebgp
)
11097 return bgp
->distance_ebgp
;
11098 return ZEBRA_EBGP_DISTANCE_DEFAULT
;
11102 if (bgp
->distance_ibgp
)
11103 return bgp
->distance_ibgp
;
11104 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
11108 DEFUN (bgp_distance
,
11110 "distance bgp <1-255> <1-255> <1-255>",
11111 "Define an administrative distance\n"
11113 "Distance for routes external to the AS\n"
11114 "Distance for routes internal to the AS\n"
11115 "Distance for local routes\n")
11121 bgp
->distance_ebgp
= atoi (argv
[0]);
11122 bgp
->distance_ibgp
= atoi (argv
[1]);
11123 bgp
->distance_local
= atoi (argv
[2]);
11124 return CMD_SUCCESS
;
11127 DEFUN (no_bgp_distance
,
11128 no_bgp_distance_cmd
,
11129 "no distance bgp <1-255> <1-255> <1-255>",
11131 "Define an administrative distance\n"
11133 "Distance for routes external to the AS\n"
11134 "Distance for routes internal to the AS\n"
11135 "Distance for local routes\n")
11141 bgp
->distance_ebgp
= 0;
11142 bgp
->distance_ibgp
= 0;
11143 bgp
->distance_local
= 0;
11144 return CMD_SUCCESS
;
11147 ALIAS (no_bgp_distance
,
11148 no_bgp_distance2_cmd
,
11151 "Define an administrative distance\n"
11154 DEFUN (bgp_distance_source
,
11155 bgp_distance_source_cmd
,
11156 "distance <1-255> A.B.C.D/M",
11157 "Define an administrative distance\n"
11158 "Administrative distance\n"
11159 "IP source prefix\n")
11161 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
11162 return CMD_SUCCESS
;
11165 DEFUN (no_bgp_distance_source
,
11166 no_bgp_distance_source_cmd
,
11167 "no distance <1-255> A.B.C.D/M",
11169 "Define an administrative distance\n"
11170 "Administrative distance\n"
11171 "IP source prefix\n")
11173 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
11174 return CMD_SUCCESS
;
11177 DEFUN (bgp_distance_source_access_list
,
11178 bgp_distance_source_access_list_cmd
,
11179 "distance <1-255> A.B.C.D/M WORD",
11180 "Define an administrative distance\n"
11181 "Administrative distance\n"
11182 "IP source prefix\n"
11183 "Access list name\n")
11185 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
11186 return CMD_SUCCESS
;
11189 DEFUN (no_bgp_distance_source_access_list
,
11190 no_bgp_distance_source_access_list_cmd
,
11191 "no distance <1-255> A.B.C.D/M WORD",
11193 "Define an administrative distance\n"
11194 "Administrative distance\n"
11195 "IP source prefix\n"
11196 "Access list name\n")
11198 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
11199 return CMD_SUCCESS
;
11202 DEFUN (bgp_damp_set
,
11204 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
11205 "BGP Specific commands\n"
11206 "Enable route-flap dampening\n"
11207 "Half-life time for the penalty\n"
11208 "Value to start reusing a route\n"
11209 "Value to start suppressing a route\n"
11210 "Maximum duration to suppress a stable route\n")
11213 int half
= DEFAULT_HALF_LIFE
* 60;
11214 int reuse
= DEFAULT_REUSE
;
11215 int suppress
= DEFAULT_SUPPRESS
;
11216 int max
= 4 * half
;
11220 half
= atoi (argv
[0]) * 60;
11221 reuse
= atoi (argv
[1]);
11222 suppress
= atoi (argv
[2]);
11223 max
= atoi (argv
[3]) * 60;
11225 else if (argc
== 1)
11227 half
= atoi (argv
[0]) * 60;
11232 return bgp_damp_enable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
),
11233 half
, reuse
, suppress
, max
);
11236 ALIAS (bgp_damp_set
,
11238 "bgp dampening <1-45>",
11239 "BGP Specific commands\n"
11240 "Enable route-flap dampening\n"
11241 "Half-life time for the penalty\n")
11243 ALIAS (bgp_damp_set
,
11246 "BGP Specific commands\n"
11247 "Enable route-flap dampening\n")
11249 DEFUN (bgp_damp_unset
,
11250 bgp_damp_unset_cmd
,
11251 "no bgp dampening",
11253 "BGP Specific commands\n"
11254 "Enable route-flap dampening\n")
11259 return bgp_damp_disable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
));
11262 ALIAS (bgp_damp_unset
,
11263 bgp_damp_unset2_cmd
,
11264 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
11266 "BGP Specific commands\n"
11267 "Enable route-flap dampening\n"
11268 "Half-life time for the penalty\n"
11269 "Value to start reusing a route\n"
11270 "Value to start suppressing a route\n"
11271 "Maximum duration to suppress a stable route\n")
11273 DEFUN (show_ip_bgp_dampened_paths
,
11274 show_ip_bgp_dampened_paths_cmd
,
11275 "show ip bgp dampened-paths",
11279 "Display paths suppressed due to dampening\n")
11281 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_dampend_paths
,
11285 DEFUN (show_ip_bgp_flap_statistics
,
11286 show_ip_bgp_flap_statistics_cmd
,
11287 "show ip bgp flap-statistics",
11291 "Display flap statistics of routes\n")
11293 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
11294 bgp_show_type_flap_statistics
, NULL
);
11297 /* Display specified route of BGP table. */
11299 bgp_clear_damp_route (struct vty
*vty
, const char *view_name
,
11300 const char *ip_str
, afi_t afi
, safi_t safi
,
11301 struct prefix_rd
*prd
, int prefix_check
)
11304 struct prefix match
;
11305 struct bgp_node
*rn
;
11306 struct bgp_node
*rm
;
11307 struct bgp_info
*ri
;
11308 struct bgp_info
*ri_temp
;
11310 struct bgp_table
*table
;
11312 /* BGP structure lookup. */
11315 bgp
= bgp_lookup_by_name (view_name
);
11318 vty_out (vty
, "%% Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
11319 return CMD_WARNING
;
11324 bgp
= bgp_get_default ();
11327 vty_out (vty
, "%% No BGP process is configured%s", VTY_NEWLINE
);
11328 return CMD_WARNING
;
11332 /* Check IP address argument. */
11333 ret
= str2prefix (ip_str
, &match
);
11336 vty_out (vty
, "%% address is malformed%s", VTY_NEWLINE
);
11337 return CMD_WARNING
;
11340 match
.family
= afi2family (afi
);
11342 if (safi
== SAFI_MPLS_VPN
)
11344 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][SAFI_MPLS_VPN
]); rn
; rn
= bgp_route_next (rn
))
11346 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
11349 if ((table
= rn
->info
) != NULL
)
11350 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
11351 if (! prefix_check
|| rm
->p
.prefixlen
== match
.prefixlen
)
11356 if (ri
->extra
&& ri
->extra
->damp_info
)
11358 ri_temp
= ri
->next
;
11359 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
11370 if ((rn
= bgp_node_match (bgp
->rib
[afi
][safi
], &match
)) != NULL
)
11371 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
11376 if (ri
->extra
&& ri
->extra
->damp_info
)
11378 ri_temp
= ri
->next
;
11379 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
11388 return CMD_SUCCESS
;
11391 DEFUN (clear_ip_bgp_dampening
,
11392 clear_ip_bgp_dampening_cmd
,
11393 "clear ip bgp dampening",
11397 "Clear route flap dampening information\n")
11399 bgp_damp_info_clean ();
11400 return CMD_SUCCESS
;
11403 DEFUN (clear_ip_bgp_dampening_prefix
,
11404 clear_ip_bgp_dampening_prefix_cmd
,
11405 "clear ip bgp dampening A.B.C.D/M",
11409 "Clear route flap dampening information\n"
11410 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11412 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
11413 SAFI_UNICAST
, NULL
, 1);
11416 DEFUN (clear_ip_bgp_dampening_address
,
11417 clear_ip_bgp_dampening_address_cmd
,
11418 "clear ip bgp dampening A.B.C.D",
11422 "Clear route flap dampening information\n"
11423 "Network to clear damping information\n")
11425 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
11426 SAFI_UNICAST
, NULL
, 0);
11429 DEFUN (clear_ip_bgp_dampening_address_mask
,
11430 clear_ip_bgp_dampening_address_mask_cmd
,
11431 "clear ip bgp dampening A.B.C.D A.B.C.D",
11435 "Clear route flap dampening information\n"
11436 "Network to clear damping information\n"
11440 char prefix_str
[BUFSIZ
];
11442 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
11445 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
11446 return CMD_WARNING
;
11449 return bgp_clear_damp_route (vty
, NULL
, prefix_str
, AFI_IP
,
11450 SAFI_UNICAST
, NULL
, 0);
11454 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
11455 afi_t afi
, safi_t safi
, int *write
)
11457 struct bgp_node
*prn
;
11458 struct bgp_node
*rn
;
11459 struct bgp_table
*table
;
11461 struct prefix_rd
*prd
;
11462 struct bgp_static
*bgp_static
;
11464 char buf
[SU_ADDRSTRLEN
];
11465 char rdbuf
[RD_ADDRSTRLEN
];
11467 /* Network configuration. */
11468 for (prn
= bgp_table_top (bgp
->route
[afi
][safi
]); prn
; prn
= bgp_route_next (prn
))
11469 if ((table
= prn
->info
) != NULL
)
11470 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
11471 if ((bgp_static
= rn
->info
) != NULL
)
11474 prd
= (struct prefix_rd
*) &prn
->p
;
11476 /* "address-family" display. */
11477 bgp_config_write_family_header (vty
, afi
, safi
, write
);
11479 /* "network" configuration display. */
11480 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
11481 label
= decode_label (bgp_static
->tag
);
11483 vty_out (vty
, " network %s/%d rd %s tag %d",
11484 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
11487 vty_out (vty
, "%s", VTY_NEWLINE
);
11492 /* Configuration of static route announcement and aggregate
11495 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
11496 afi_t afi
, safi_t safi
, int *write
)
11498 struct bgp_node
*rn
;
11500 struct bgp_static
*bgp_static
;
11501 struct bgp_aggregate
*bgp_aggregate
;
11502 char buf
[SU_ADDRSTRLEN
];
11504 if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
11505 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
11507 /* Network configuration. */
11508 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
11509 if ((bgp_static
= rn
->info
) != NULL
)
11513 /* "address-family" display. */
11514 bgp_config_write_family_header (vty
, afi
, safi
, write
);
11516 /* "network" configuration display. */
11517 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
11519 u_int32_t destination
;
11520 struct in_addr netmask
;
11522 destination
= ntohl (p
->u
.prefix4
.s_addr
);
11523 masklen2ip (p
->prefixlen
, &netmask
);
11524 vty_out (vty
, " network %s",
11525 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
));
11527 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
11528 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
11529 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
11530 || p
->u
.prefix4
.s_addr
== 0)
11532 /* Natural mask is not display. */
11535 vty_out (vty
, " mask %s", inet_ntoa (netmask
));
11539 vty_out (vty
, " network %s/%d",
11540 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
11544 if (bgp_static
->rmap
.name
)
11545 vty_out (vty
, " route-map %s", bgp_static
->rmap
.name
);
11548 if (bgp_static
->backdoor
)
11549 vty_out (vty
, " backdoor");
11550 if (bgp_static
->ttl
)
11551 vty_out (vty
, " pathlimit %u", bgp_static
->ttl
);
11554 vty_out (vty
, "%s", VTY_NEWLINE
);
11557 /* Aggregate-address configuration. */
11558 for (rn
= bgp_table_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
11559 if ((bgp_aggregate
= rn
->info
) != NULL
)
11563 /* "address-family" display. */
11564 bgp_config_write_family_header (vty
, afi
, safi
, write
);
11566 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
11568 struct in_addr netmask
;
11570 masklen2ip (p
->prefixlen
, &netmask
);
11571 vty_out (vty
, " aggregate-address %s %s",
11572 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
11573 inet_ntoa (netmask
));
11577 vty_out (vty
, " aggregate-address %s/%d",
11578 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
11582 if (bgp_aggregate
->as_set
)
11583 vty_out (vty
, " as-set");
11585 if (bgp_aggregate
->summary_only
)
11586 vty_out (vty
, " summary-only");
11588 vty_out (vty
, "%s", VTY_NEWLINE
);
11595 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
)
11597 struct bgp_node
*rn
;
11598 struct bgp_distance
*bdistance
;
11600 /* Distance configuration. */
11601 if (bgp
->distance_ebgp
11602 && bgp
->distance_ibgp
11603 && bgp
->distance_local
11604 && (bgp
->distance_ebgp
!= ZEBRA_EBGP_DISTANCE_DEFAULT
11605 || bgp
->distance_ibgp
!= ZEBRA_IBGP_DISTANCE_DEFAULT
11606 || bgp
->distance_local
!= ZEBRA_IBGP_DISTANCE_DEFAULT
))
11607 vty_out (vty
, " distance bgp %d %d %d%s",
11608 bgp
->distance_ebgp
, bgp
->distance_ibgp
, bgp
->distance_local
,
11611 for (rn
= bgp_table_top (bgp_distance_table
); rn
; rn
= bgp_route_next (rn
))
11612 if ((bdistance
= rn
->info
) != NULL
)
11614 vty_out (vty
, " distance %d %s/%d %s%s", bdistance
->distance
,
11615 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
11616 bdistance
->access_list
? bdistance
->access_list
: "",
11623 /* Allocate routing table structure and install commands. */
11625 bgp_route_init (void)
11627 /* Init BGP distance table. */
11628 bgp_distance_table
= bgp_table_init (AFI_IP
, SAFI_UNICAST
);
11630 /* IPv4 BGP commands. */
11631 install_element (BGP_NODE
, &bgp_network_cmd
);
11632 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
11633 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
11634 install_element (BGP_NODE
, &bgp_network_route_map_cmd
);
11635 install_element (BGP_NODE
, &bgp_network_mask_route_map_cmd
);
11636 install_element (BGP_NODE
, &bgp_network_mask_natural_route_map_cmd
);
11637 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
11638 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
11639 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
11640 install_element (BGP_NODE
, &bgp_network_ttl_cmd
);
11641 install_element (BGP_NODE
, &bgp_network_mask_ttl_cmd
);
11642 install_element (BGP_NODE
, &bgp_network_mask_natural_ttl_cmd
);
11643 install_element (BGP_NODE
, &bgp_network_backdoor_ttl_cmd
);
11644 install_element (BGP_NODE
, &bgp_network_mask_backdoor_ttl_cmd
);
11645 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_ttl_cmd
);
11646 install_element (BGP_NODE
, &no_bgp_network_cmd
);
11647 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
11648 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
11649 install_element (BGP_NODE
, &no_bgp_network_route_map_cmd
);
11650 install_element (BGP_NODE
, &no_bgp_network_mask_route_map_cmd
);
11651 install_element (BGP_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
11652 install_element (BGP_NODE
, &no_bgp_network_backdoor_cmd
);
11653 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_cmd
);
11654 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_cmd
);
11655 install_element (BGP_NODE
, &no_bgp_network_ttl_cmd
);
11656 install_element (BGP_NODE
, &no_bgp_network_mask_ttl_cmd
);
11657 install_element (BGP_NODE
, &no_bgp_network_mask_natural_ttl_cmd
);
11658 install_element (BGP_NODE
, &no_bgp_network_backdoor_ttl_cmd
);
11659 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_ttl_cmd
);
11660 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_ttl_cmd
);
11662 install_element (BGP_NODE
, &aggregate_address_cmd
);
11663 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
11664 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
11665 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
11666 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
11667 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
11668 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
11669 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
11670 install_element (BGP_NODE
, &aggregate_address_summary_as_set_cmd
);
11671 install_element (BGP_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
11672 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
11673 install_element (BGP_NODE
, &no_aggregate_address_summary_only_cmd
);
11674 install_element (BGP_NODE
, &no_aggregate_address_as_set_cmd
);
11675 install_element (BGP_NODE
, &no_aggregate_address_as_set_summary_cmd
);
11676 install_element (BGP_NODE
, &no_aggregate_address_summary_as_set_cmd
);
11677 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
11678 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
11679 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_cmd
);
11680 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
11681 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
11683 /* IPv4 unicast configuration. */
11684 install_element (BGP_IPV4_NODE
, &bgp_network_cmd
);
11685 install_element (BGP_IPV4_NODE
, &bgp_network_mask_cmd
);
11686 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_cmd
);
11687 install_element (BGP_IPV4_NODE
, &bgp_network_route_map_cmd
);
11688 install_element (BGP_IPV4_NODE
, &bgp_network_mask_route_map_cmd
);
11689 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_route_map_cmd
);
11690 install_element (BGP_IPV4_NODE
, &bgp_network_ttl_cmd
);
11691 install_element (BGP_IPV4_NODE
, &bgp_network_mask_ttl_cmd
);
11692 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_ttl_cmd
);
11693 install_element (BGP_IPV4_NODE
, &bgp_network_backdoor_ttl_cmd
);
11694 install_element (BGP_IPV4_NODE
, &bgp_network_mask_backdoor_ttl_cmd
);
11695 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_backdoor_ttl_cmd
); install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
11696 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_cmd
);
11697 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_cmd
);
11698 install_element (BGP_IPV4_NODE
, &no_bgp_network_route_map_cmd
);
11699 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_route_map_cmd
);
11700 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
11701 install_element (BGP_IPV4_NODE
, &no_bgp_network_ttl_cmd
);
11702 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_ttl_cmd
);
11703 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_ttl_cmd
);
11704 install_element (BGP_IPV4_NODE
, &no_bgp_network_backdoor_ttl_cmd
);
11705 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_backdoor_ttl_cmd
);
11706 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_backdoor_ttl_cmd
); install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
11707 install_element (BGP_IPV4_NODE
, &aggregate_address_cmd
);
11708 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_cmd
);
11709 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_only_cmd
);
11710 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_only_cmd
);
11711 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_cmd
);
11712 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_cmd
);
11713 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_summary_cmd
);
11714 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
11715 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_as_set_cmd
);
11716 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
11717 install_element (BGP_IPV4_NODE
, &no_aggregate_address_cmd
);
11718 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_only_cmd
);
11719 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_cmd
);
11720 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_summary_cmd
);
11721 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_as_set_cmd
);
11722 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_cmd
);
11723 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
11724 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_cmd
);
11725 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
11726 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
11728 /* IPv4 multicast configuration. */
11729 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
11730 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
11731 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
11732 install_element (BGP_IPV4M_NODE
, &bgp_network_route_map_cmd
);
11733 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_route_map_cmd
);
11734 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_route_map_cmd
);
11735 install_element (BGP_IPV4M_NODE
, &bgp_network_ttl_cmd
);
11736 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_ttl_cmd
);
11737 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_ttl_cmd
);
11738 install_element (BGP_IPV4M_NODE
, &bgp_network_backdoor_ttl_cmd
);
11739 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_backdoor_ttl_cmd
);
11740 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_backdoor_ttl_cmd
); install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
11741 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
11742 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
11743 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
11744 install_element (BGP_IPV4M_NODE
, &no_bgp_network_route_map_cmd
);
11745 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_route_map_cmd
);
11746 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
11747 install_element (BGP_IPV4M_NODE
, &no_bgp_network_ttl_cmd
);
11748 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_ttl_cmd
);
11749 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_ttl_cmd
);
11750 install_element (BGP_IPV4M_NODE
, &no_bgp_network_backdoor_ttl_cmd
);
11751 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_backdoor_ttl_cmd
);
11752 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_backdoor_ttl_cmd
); install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
11753 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
11754 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
11755 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
11756 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
11757 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
11758 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
11759 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
11760 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
11761 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_as_set_cmd
);
11762 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
11763 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
11764 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_only_cmd
);
11765 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_cmd
);
11766 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_summary_cmd
);
11767 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_as_set_cmd
);
11768 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
11769 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
11770 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_cmd
);
11771 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
11772 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
11774 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
11775 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
11776 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
11777 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
11778 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
11779 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
11780 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
11781 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
11782 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
11783 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
11784 install_element (VIEW_NODE
, &show_ip_bgp_view_cmd
);
11785 install_element (VIEW_NODE
, &show_ip_bgp_view_route_cmd
);
11786 install_element (VIEW_NODE
, &show_ip_bgp_view_prefix_cmd
);
11787 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
11788 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
11789 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
11790 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
11791 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
11792 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
11793 install_element (VIEW_NODE
, &show_ip_bgp_route_map_cmd
);
11794 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
11795 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
11796 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
11797 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
11798 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
11799 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
11800 install_element (VIEW_NODE
, &show_ip_bgp_community2_cmd
);
11801 install_element (VIEW_NODE
, &show_ip_bgp_community3_cmd
);
11802 install_element (VIEW_NODE
, &show_ip_bgp_community4_cmd
);
11803 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
11804 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
11805 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
11806 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
11807 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
11808 install_element (VIEW_NODE
, &show_ip_bgp_community2_exact_cmd
);
11809 install_element (VIEW_NODE
, &show_ip_bgp_community3_exact_cmd
);
11810 install_element (VIEW_NODE
, &show_ip_bgp_community4_exact_cmd
);
11811 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
11812 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
11813 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
11814 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
11815 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
11816 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
11817 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
11818 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
11819 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
11820 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
11821 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
11822 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
11823 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
11824 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
11825 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
11826 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
11827 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
11828 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
11829 install_element (VIEW_NODE
, &show_ip_bgp_dampened_paths_cmd
);
11830 install_element (VIEW_NODE
, &show_ip_bgp_flap_statistics_cmd
);
11831 install_element (VIEW_NODE
, &show_ip_bgp_flap_address_cmd
);
11832 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_cmd
);
11833 install_element (VIEW_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
11834 install_element (VIEW_NODE
, &show_ip_bgp_flap_regexp_cmd
);
11835 install_element (VIEW_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
11836 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
11837 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
11838 install_element (VIEW_NODE
, &show_ip_bgp_flap_route_map_cmd
);
11839 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
11840 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
11841 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_cmd
);
11842 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_route_cmd
);
11843 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
11844 install_element (VIEW_NODE
, &show_ip_bgp_view_neighbor_advertised_route_cmd
);
11845 install_element (VIEW_NODE
, &show_ip_bgp_view_neighbor_received_routes_cmd
);
11846 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_cmd
);
11847 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
11848 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
11850 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
11851 install_element (RESTRICTED_NODE
, &show_ip_bgp_route_cmd
);
11852 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_route_cmd
);
11853 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
11854 install_element (RESTRICTED_NODE
, &show_ip_bgp_prefix_cmd
);
11855 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
11856 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
11857 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
11858 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_route_cmd
);
11859 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_prefix_cmd
);
11860 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_cmd
);
11861 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_cmd
);
11862 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_cmd
);
11863 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_cmd
);
11864 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_cmd
);
11865 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
11866 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
11867 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
11868 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_exact_cmd
);
11869 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_exact_cmd
);
11870 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_exact_cmd
);
11871 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_exact_cmd
);
11872 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
11873 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
11874 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
11875 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
11876 install_element (RESTRICTED_NODE
, &show_ip_bgp_rsclient_route_cmd
);
11877 install_element (RESTRICTED_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
11878 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
11879 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
11881 install_element (ENABLE_NODE
, &show_ip_bgp_cmd
);
11882 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cmd
);
11883 install_element (ENABLE_NODE
, &show_ip_bgp_route_cmd
);
11884 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_cmd
);
11885 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
11886 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
11887 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_cmd
);
11888 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
11889 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
11890 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
11891 install_element (ENABLE_NODE
, &show_ip_bgp_view_cmd
);
11892 install_element (ENABLE_NODE
, &show_ip_bgp_view_route_cmd
);
11893 install_element (ENABLE_NODE
, &show_ip_bgp_view_prefix_cmd
);
11894 install_element (ENABLE_NODE
, &show_ip_bgp_regexp_cmd
);
11895 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
11896 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_list_cmd
);
11897 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
11898 install_element (ENABLE_NODE
, &show_ip_bgp_filter_list_cmd
);
11899 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
11900 install_element (ENABLE_NODE
, &show_ip_bgp_route_map_cmd
);
11901 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
11902 install_element (ENABLE_NODE
, &show_ip_bgp_cidr_only_cmd
);
11903 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
11904 install_element (ENABLE_NODE
, &show_ip_bgp_community_all_cmd
);
11905 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
11906 install_element (ENABLE_NODE
, &show_ip_bgp_community_cmd
);
11907 install_element (ENABLE_NODE
, &show_ip_bgp_community2_cmd
);
11908 install_element (ENABLE_NODE
, &show_ip_bgp_community3_cmd
);
11909 install_element (ENABLE_NODE
, &show_ip_bgp_community4_cmd
);
11910 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_cmd
);
11911 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
11912 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
11913 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
11914 install_element (ENABLE_NODE
, &show_ip_bgp_community_exact_cmd
);
11915 install_element (ENABLE_NODE
, &show_ip_bgp_community2_exact_cmd
);
11916 install_element (ENABLE_NODE
, &show_ip_bgp_community3_exact_cmd
);
11917 install_element (ENABLE_NODE
, &show_ip_bgp_community4_exact_cmd
);
11918 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
11919 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
11920 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
11921 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
11922 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_cmd
);
11923 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
11924 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_exact_cmd
);
11925 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
11926 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_longer_cmd
);
11927 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
11928 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
11929 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
11930 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
11931 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
11932 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
11933 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
11934 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
11935 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
11936 install_element (ENABLE_NODE
, &show_ip_bgp_dampened_paths_cmd
);
11937 install_element (ENABLE_NODE
, &show_ip_bgp_flap_statistics_cmd
);
11938 install_element (ENABLE_NODE
, &show_ip_bgp_flap_address_cmd
);
11939 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_cmd
);
11940 install_element (ENABLE_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
11941 install_element (ENABLE_NODE
, &show_ip_bgp_flap_regexp_cmd
);
11942 install_element (ENABLE_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
11943 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
11944 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
11945 install_element (ENABLE_NODE
, &show_ip_bgp_flap_route_map_cmd
);
11946 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
11947 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
11948 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_cmd
);
11949 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_route_cmd
);
11950 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
11951 install_element (ENABLE_NODE
, &show_ip_bgp_view_neighbor_advertised_route_cmd
);
11952 install_element (ENABLE_NODE
, &show_ip_bgp_view_neighbor_received_routes_cmd
);
11953 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_cmd
);
11954 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
11955 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
11957 /* BGP dampening clear commands */
11958 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_cmd
);
11959 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_prefix_cmd
);
11960 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_cmd
);
11961 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_mask_cmd
);
11964 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_prefix_counts_cmd
);
11965 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
);
11966 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
);
11968 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_prefix_counts_cmd
);
11970 /* New config IPv6 BGP commands. */
11971 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
11972 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_route_map_cmd
);
11973 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_ttl_cmd
);
11974 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
11975 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_route_map_cmd
);
11976 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_ttl_cmd
);
11978 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
11979 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
11980 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
11981 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
11983 /* Old config IPv6 BGP commands. */
11984 install_element (BGP_NODE
, &old_ipv6_bgp_network_cmd
);
11985 install_element (BGP_NODE
, &old_no_ipv6_bgp_network_cmd
);
11987 install_element (BGP_NODE
, &old_ipv6_aggregate_address_cmd
);
11988 install_element (BGP_NODE
, &old_ipv6_aggregate_address_summary_only_cmd
);
11989 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_cmd
);
11990 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_summary_only_cmd
);
11992 install_element (VIEW_NODE
, &show_bgp_cmd
);
11993 install_element (VIEW_NODE
, &show_bgp_ipv6_cmd
);
11994 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
11995 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
11996 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
11997 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
11998 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
11999 install_element (VIEW_NODE
, &show_bgp_ipv6_regexp_cmd
);
12000 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
12001 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
12002 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
12003 install_element (VIEW_NODE
, &show_bgp_ipv6_filter_list_cmd
);
12004 install_element (VIEW_NODE
, &show_bgp_route_map_cmd
);
12005 install_element (VIEW_NODE
, &show_bgp_ipv6_route_map_cmd
);
12006 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
12007 install_element (VIEW_NODE
, &show_bgp_ipv6_community_all_cmd
);
12008 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
12009 install_element (VIEW_NODE
, &show_bgp_ipv6_community_cmd
);
12010 install_element (VIEW_NODE
, &show_bgp_community2_cmd
);
12011 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_cmd
);
12012 install_element (VIEW_NODE
, &show_bgp_community3_cmd
);
12013 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_cmd
);
12014 install_element (VIEW_NODE
, &show_bgp_community4_cmd
);
12015 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_cmd
);
12016 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
12017 install_element (VIEW_NODE
, &show_bgp_ipv6_community_exact_cmd
);
12018 install_element (VIEW_NODE
, &show_bgp_community2_exact_cmd
);
12019 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
12020 install_element (VIEW_NODE
, &show_bgp_community3_exact_cmd
);
12021 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
12022 install_element (VIEW_NODE
, &show_bgp_community4_exact_cmd
);
12023 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
12024 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
12025 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_cmd
);
12026 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
12027 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
12028 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
12029 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
12030 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
12031 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
12032 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
12033 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
12034 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
12035 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
12036 install_element (VIEW_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
12037 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
12038 install_element (VIEW_NODE
, &show_bgp_neighbor_flap_cmd
);
12039 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
12040 install_element (VIEW_NODE
, &show_bgp_neighbor_damp_cmd
);
12041 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
12042 install_element (VIEW_NODE
, &show_bgp_rsclient_cmd
);
12043 install_element (VIEW_NODE
, &show_bgp_rsclient_route_cmd
);
12044 install_element (VIEW_NODE
, &show_bgp_rsclient_prefix_cmd
);
12045 install_element (VIEW_NODE
, &show_bgp_view_cmd
);
12046 install_element (VIEW_NODE
, &show_bgp_view_ipv6_cmd
);
12047 install_element (VIEW_NODE
, &show_bgp_view_route_cmd
);
12048 install_element (VIEW_NODE
, &show_bgp_view_ipv6_route_cmd
);
12049 install_element (VIEW_NODE
, &show_bgp_view_prefix_cmd
);
12050 install_element (VIEW_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
12051 install_element (VIEW_NODE
, &show_bgp_view_neighbor_advertised_route_cmd
);
12052 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_advertised_route_cmd
);
12053 install_element (VIEW_NODE
, &show_bgp_view_neighbor_received_routes_cmd
);
12054 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_received_routes_cmd
);
12055 install_element (VIEW_NODE
, &show_bgp_view_neighbor_routes_cmd
);
12056 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_routes_cmd
);
12057 install_element (VIEW_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
12058 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
12059 install_element (VIEW_NODE
, &show_bgp_view_neighbor_flap_cmd
);
12060 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_flap_cmd
);
12061 install_element (VIEW_NODE
, &show_bgp_view_neighbor_damp_cmd
);
12062 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_damp_cmd
);
12063 install_element (VIEW_NODE
, &show_bgp_view_rsclient_cmd
);
12064 install_element (VIEW_NODE
, &show_bgp_view_rsclient_route_cmd
);
12065 install_element (VIEW_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
12068 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
12070 install_element (RESTRICTED_NODE
, &show_bgp_route_cmd
);
12071 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_route_cmd
);
12072 install_element (RESTRICTED_NODE
, &show_bgp_prefix_cmd
);
12073 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_prefix_cmd
);
12074 install_element (RESTRICTED_NODE
, &show_bgp_community_cmd
);
12075 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_cmd
);
12076 install_element (RESTRICTED_NODE
, &show_bgp_community2_cmd
);
12077 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_cmd
);
12078 install_element (RESTRICTED_NODE
, &show_bgp_community3_cmd
);
12079 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_cmd
);
12080 install_element (RESTRICTED_NODE
, &show_bgp_community4_cmd
);
12081 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_cmd
);
12082 install_element (RESTRICTED_NODE
, &show_bgp_community_exact_cmd
);
12083 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_exact_cmd
);
12084 install_element (RESTRICTED_NODE
, &show_bgp_community2_exact_cmd
);
12085 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
12086 install_element (RESTRICTED_NODE
, &show_bgp_community3_exact_cmd
);
12087 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
12088 install_element (RESTRICTED_NODE
, &show_bgp_community4_exact_cmd
);
12089 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
12090 install_element (RESTRICTED_NODE
, &show_bgp_rsclient_route_cmd
);
12091 install_element (RESTRICTED_NODE
, &show_bgp_rsclient_prefix_cmd
);
12092 install_element (RESTRICTED_NODE
, &show_bgp_view_route_cmd
);
12093 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_route_cmd
);
12094 install_element (RESTRICTED_NODE
, &show_bgp_view_prefix_cmd
);
12095 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
12096 install_element (RESTRICTED_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
12097 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
12098 install_element (RESTRICTED_NODE
, &show_bgp_view_rsclient_route_cmd
);
12099 install_element (RESTRICTED_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
12101 install_element (ENABLE_NODE
, &show_bgp_cmd
);
12102 install_element (ENABLE_NODE
, &show_bgp_ipv6_cmd
);
12103 install_element (ENABLE_NODE
, &show_bgp_route_cmd
);
12104 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_cmd
);
12105 install_element (ENABLE_NODE
, &show_bgp_prefix_cmd
);
12106 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_cmd
);
12107 install_element (ENABLE_NODE
, &show_bgp_regexp_cmd
);
12108 install_element (ENABLE_NODE
, &show_bgp_ipv6_regexp_cmd
);
12109 install_element (ENABLE_NODE
, &show_bgp_prefix_list_cmd
);
12110 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
12111 install_element (ENABLE_NODE
, &show_bgp_filter_list_cmd
);
12112 install_element (ENABLE_NODE
, &show_bgp_ipv6_filter_list_cmd
);
12113 install_element (ENABLE_NODE
, &show_bgp_route_map_cmd
);
12114 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_map_cmd
);
12115 install_element (ENABLE_NODE
, &show_bgp_community_all_cmd
);
12116 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_all_cmd
);
12117 install_element (ENABLE_NODE
, &show_bgp_community_cmd
);
12118 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_cmd
);
12119 install_element (ENABLE_NODE
, &show_bgp_community2_cmd
);
12120 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_cmd
);
12121 install_element (ENABLE_NODE
, &show_bgp_community3_cmd
);
12122 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_cmd
);
12123 install_element (ENABLE_NODE
, &show_bgp_community4_cmd
);
12124 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_cmd
);
12125 install_element (ENABLE_NODE
, &show_bgp_community_exact_cmd
);
12126 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_exact_cmd
);
12127 install_element (ENABLE_NODE
, &show_bgp_community2_exact_cmd
);
12128 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
12129 install_element (ENABLE_NODE
, &show_bgp_community3_exact_cmd
);
12130 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
12131 install_element (ENABLE_NODE
, &show_bgp_community4_exact_cmd
);
12132 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
12133 install_element (ENABLE_NODE
, &show_bgp_community_list_cmd
);
12134 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_cmd
);
12135 install_element (ENABLE_NODE
, &show_bgp_community_list_exact_cmd
);
12136 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
12137 install_element (ENABLE_NODE
, &show_bgp_prefix_longer_cmd
);
12138 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
12139 install_element (ENABLE_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
12140 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
12141 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_routes_cmd
);
12142 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
12143 install_element (ENABLE_NODE
, &show_bgp_neighbor_routes_cmd
);
12144 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
12145 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
12146 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
12147 install_element (ENABLE_NODE
, &show_bgp_neighbor_flap_cmd
);
12148 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
12149 install_element (ENABLE_NODE
, &show_bgp_neighbor_damp_cmd
);
12150 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
12151 install_element (ENABLE_NODE
, &show_bgp_rsclient_cmd
);
12152 install_element (ENABLE_NODE
, &show_bgp_rsclient_route_cmd
);
12153 install_element (ENABLE_NODE
, &show_bgp_rsclient_prefix_cmd
);
12154 install_element (ENABLE_NODE
, &show_bgp_view_cmd
);
12155 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_cmd
);
12156 install_element (ENABLE_NODE
, &show_bgp_view_route_cmd
);
12157 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_route_cmd
);
12158 install_element (ENABLE_NODE
, &show_bgp_view_prefix_cmd
);
12159 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
12160 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_advertised_route_cmd
);
12161 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_advertised_route_cmd
);
12162 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_received_routes_cmd
);
12163 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_received_routes_cmd
);
12164 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_routes_cmd
);
12165 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_routes_cmd
);
12166 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
12167 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
12168 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_flap_cmd
);
12169 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_flap_cmd
);
12170 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_damp_cmd
);
12171 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_damp_cmd
);
12172 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_cmd
);
12173 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_route_cmd
);
12174 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
12177 install_element (ENABLE_NODE
, &show_bgp_statistics_cmd
);
12178 install_element (ENABLE_NODE
, &show_bgp_statistics_vpnv4_cmd
);
12179 install_element (ENABLE_NODE
, &show_bgp_statistics_view_cmd
);
12180 install_element (ENABLE_NODE
, &show_bgp_statistics_view_vpnv4_cmd
);
12183 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
12184 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
12185 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
12186 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
12187 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
12188 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
12189 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
12190 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
12191 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_cmd
);
12192 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_cmd
);
12193 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_cmd
);
12194 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
12195 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
12196 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
12197 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
12198 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
12199 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
12200 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
12201 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
12202 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
12203 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
12204 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
12205 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
12206 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
12207 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
12208 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
12209 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_cmd
);
12210 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_cmd
);
12211 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_cmd
);
12212 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
12213 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
12214 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
12215 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
12216 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
12217 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
12218 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
12221 install_element (ENABLE_NODE
, &show_ipv6_bgp_cmd
);
12222 install_element (ENABLE_NODE
, &show_ipv6_bgp_route_cmd
);
12223 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_cmd
);
12224 install_element (ENABLE_NODE
, &show_ipv6_bgp_regexp_cmd
);
12225 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
12226 install_element (ENABLE_NODE
, &show_ipv6_bgp_filter_list_cmd
);
12227 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_all_cmd
);
12228 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_cmd
);
12229 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_cmd
);
12230 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_cmd
);
12231 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_cmd
);
12232 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_exact_cmd
);
12233 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
12234 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
12235 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
12236 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_cmd
);
12237 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
12238 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
12239 install_element (ENABLE_NODE
, &show_ipv6_mbgp_cmd
);
12240 install_element (ENABLE_NODE
, &show_ipv6_mbgp_route_cmd
);
12241 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_cmd
);
12242 install_element (ENABLE_NODE
, &show_ipv6_mbgp_regexp_cmd
);
12243 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
12244 install_element (ENABLE_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
12245 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_all_cmd
);
12246 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_cmd
);
12247 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_cmd
);
12248 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_cmd
);
12249 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_cmd
);
12250 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
12251 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
12252 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
12253 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
12254 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_cmd
);
12255 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
12256 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
12259 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
12260 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
12261 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
12262 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
12265 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
12266 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
12267 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
12268 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
12271 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
12272 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
12273 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
12274 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
12275 #endif /* HAVE_IPV6 */
12277 install_element (BGP_NODE
, &bgp_distance_cmd
);
12278 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
12279 install_element (BGP_NODE
, &no_bgp_distance2_cmd
);
12280 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
12281 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
12282 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
12283 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
12285 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
12286 install_element (BGP_NODE
, &bgp_damp_set2_cmd
);
12287 install_element (BGP_NODE
, &bgp_damp_set3_cmd
);
12288 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
12289 install_element (BGP_NODE
, &bgp_damp_unset2_cmd
);
12290 install_element (BGP_IPV4_NODE
, &bgp_damp_set_cmd
);
12291 install_element (BGP_IPV4_NODE
, &bgp_damp_set2_cmd
);
12292 install_element (BGP_IPV4_NODE
, &bgp_damp_set3_cmd
);
12293 install_element (BGP_IPV4_NODE
, &bgp_damp_unset_cmd
);
12294 install_element (BGP_IPV4_NODE
, &bgp_damp_unset2_cmd
);
12298 bgp_route_finish (void)
12300 bgp_table_unlock (bgp_distance_table
);
12301 bgp_distance_table
= NULL
;